#include #include #include #include #include #include #include // find signal amplitude of each PMT at +- 5,4,3,2,1ns // using a simple landau fit to the data from // the projection of the 2d histogram APMvsDTRawXXX // where XXX is the PMT number. // The histograms are generated by the plugin TOFmon // The root file is called tofmon.root the location of // the file is selected by the valiable "choice" either in // ./localdir/runXXXXX/ or int genroot/..... // // write data to file: tof_amps_run%d.dat // int DEBUG = 0; float findpeak(TH1D *h){ float locmax = 0; TH1D *hist = (TH1D*) h->Rebin(30,"hist"); int nbins = hist->GetSize(); for (int n=1;nFit("pol2","Q","QR",hist->GetBinCenter(n),hist->GetBinCenter(n+4)); TF1 *f1 = hist->GetFunction("pol2"); float quad = f1->GetParameter(2); if (quad > 0){ hist->GetXaxis()->SetRange(n+4,nbins-2); int maxbin = hist->GetMaximumBin(); locmax = hist->GetBinCenter(maxbin); //cout<<"Maximum Found at "<Get(hnam); if (h2d == NULL){ cout<<"ERROR not histogram:"<ProjectionY("h10",37,39); // projection -5ns h1[1] = h2d->ProjectionY("h11",40,41); // projection -4ns h1[2] = h2d->ProjectionY("h12",43,44); // projection -3ns h1[3] = h2d->ProjectionY("h13",45,46); // projection -2ns h1[4] = h2d->ProjectionY("h14",55,56); // projection 2ns h1[5] = h2d->ProjectionY("h15",57,58); // projection 3ns h1[6] = h2d->ProjectionY("h16",60,61); // projection 4ns h1[7] = h2d->ProjectionY("h17",62,64); // projection 5ns for (int n=0;n<8;n++) { h1[n]->GetXaxis()->SetRangeUser(100., 4000.); float max = findpeak(h1[n]); //int mbin = h1[n]->GetMaximumBin(); //float max = h1[n]->GetBinCenter(mbin); float width = max*0.15; float integr = 5000.; float loli = max - 1.5*width; float hili = max + 7*width; h1[n]->Fit("landau","Q","QR",loli,hili); TF1 *f1 = h1[n]->GetFunction("landau"); float MPV = f1->GetParameter(1); float SIG = f1->GetParameter(2); //cout<GetBinCenter( h1[n]->GetMaximumBin()); width = max*0.15; loli = max - 1.5*width; hili = max + 7*width; h1[n]->Fit("landau","Q","QR",loli,hili); f1 = h1[n]->GetFunction("landau"); MPV = f1->GetParameter(1); SIG = f1->GetParameter(2); //cout<Fit("landau","Q","QR",loli,hili); f1 = h1[n]->GetFunction("landau"); MPV = f1->GetParameter(1); SIG = f1->GetParameter(2); //cout<Fit("landau","Q","QR",loli,hili); f1 = h1[n]->GetFunction("landau"); MPV = f1->GetParameter(1); SIG = f1->GetParameter(2); float dMPV = f1->GetParError(1); cout<Draw(); c1->Modified(); if (DEBUG) { sleep(1); } if (DEBUG>1){ h1[n]->GetXaxis()->SetTitle("ADC amplitude [arb.]"); c1->Modified(); c1->SaveAs("landau_fit.pdf"); getchar(); } } } } } OUTF.close(); RF->Close(); }