diff --git a/TOF_calib/README b/TOF_calib/README index ae061fef..810b7e4e 100644 --- a/TOF_calib/README +++ b/TOF_calib/README @@ -2,22 +2,40 @@ TOF TDC calibration of ALL paddle PMTS -------------------------------------- This is a new calibration version that is modified to use the ADC signal amplitudes to determine the walk correction of the TDC times. -The main script that controls all steps of the calibration "DOC_CALIB.csh" is modified +The main script that controls all steps of the calibration "DO_CALIB.csh" is modified to do the meantime script and time difference script in parallel threads to improve speed when running on the farm nodes (requires two cores(nodes)). -Of course prior to running the script the root files need to be available. +Of course prior to running these scripts the basic root files need to be available. -after the calibration there are python and root scripts that facilitate reviewing the results +After the calibration there are python and root scripts that facilitate reviewing the results and writing the resulting calibration parameters to the database tables. -The data base tables are new and have an appendix "_NEWAMP" to the table names. +The latest CCDB data base tables that are now used to write the calibration results are: +/TOF2/walkcorr_type : this contains a flag to indicate which walk correction type was used +/TOF2/timewalk_parms_5PAR : contains the walk correction parameters +/TOF2/timing_offsets_5PAR : contains the final timing offsets of the TDCs values of each PMT +/TOF2/propagation_speed : contains the effective speed of light in each paddle +/TOF2/adc_timing_offsets : contains the timing offsets for the ADCs values of each PMT +Note: the "TOF2/" directory is to indicate that the calibration code is up to date to handle + the new TOF geometry. The code is backwards compatible to use the old geometry "TOF/". -A) analyze data with plugin "TOF_calib" - creates root files in "localdir/tofdata_run####.root" - add root files together: "hadd big99999.root tofdata_run####.root ... tofdata_run####.root" -B) All the callibration is now done with one command +FIRST GENERATE THE ROOT FILES FROM RAW DATA REQUIRED FOR CALIBRATION: +------------------------------------------------------------------------ + analyze data with plugin "TOF_calib" (src/plugins/Calibration/TOF_calib/) + creates root files in "localdir/tofdata_run####_*.root" + add root files together: "hadd big99999.root tofdata_run#####_*.root" + + Note: this is done prior to any calibration attempt. Most of the time this is done by a dedicated + operator who handles other detector skim data as well. + Note: For regular GlueX running about 60 raw evio files are required to get sufficient statistics + for the calibration. Generally the size of the summed up root file should be 10GB or more. + "summed up" means the root files from each evio file are added together using "hadd". + +THE ACTUAL CALIBRATION IS DONE IN STEPS CONTROLLED BY THE MASTER SCRIPT "DO_CALIB.CSH" +--------------------------------------------------------------------------------------- + All the callibration is now done with one command ./DO_CALIB.csh "####" where "####" is the run number the input data files is expected to be in localdir with the name "tofdata_run####.root" @@ -27,18 +45,18 @@ The Following is a descrption of all the root scripts and shell scripts used: 1) DO_CALIB.csh : main shell scripts that does it all -2a) src/WALK.C root wrapper to compile the src/walk1.C scripts to run faster. - a) in root: .L src/walk1.C+g; - b) in root: walk1(####); - -2b) calculate walk correction parameters with src/walk1.C - output: tof_walk_parameters_run####dat - tof_TDC_ADC_timediff_run####.dat - walk_results_run%%%%.root - tof_walk_parameters_run####.DB : the walk parameters from the fit - adc_vs_tdc_relative_global_time_run####.DB : global time difference between TDC and ADC - adc_vs_tdc_relative_time_run####.DB : relative time differnece between TDC and ADC times - +2) calculate walk correction parameters with src/walk1.C + output: tof_walk_parameters_run#####dat + tof_TDC_ADC_timediff_run#####.dat + walk_histos_run#####.root + walk_results_run#####.root + tof_walk_parameters_run#####.DB : the walk parameters from the fit + adc_vs_tdc_relative_global_time_run#####.DB : global time difference between TDC and ADC + adc_vs_tdc_relative_time_run#####.DB : relative time differnece between TDC and ADC time + Note: this one of the most critical steps and will result in the largest values of correction + for the timing. The functional form of the walk correction has been modifed several times and + as a result the subsequent use of these parameters is controlled by a flag located in the CCDB data base + table /TOF2/walkcorr_type. 3) domeantime.csh to calculate all meantimes for both planes it uses the root script wrapper src/MT1.C to compile and run @@ -75,7 +93,7 @@ The Following is a descrption of all the root scripts and shell scripts used: tofpmt_tdc_offsets_all.dat tofpmt_tdc_offsets_all_run####.DB -8) root -b -q "src/DOALLFIT.C(RUNNUMBER,10)" +8) root -b -q "src/dofitall.C(RUNNUMBER,10)" get offsets for single ended readout paddles located at the center of the TOF runs src/dofitall.C output files: @@ -90,6 +108,10 @@ The Following is a descrption of all the root scripts and shell scripts used: xTvsEPMTcorrN TimingX timing histograms +9) root -b -q "src/doadctimeoffsets.C+($RUN)" + calculate the timing offsets for the ADC time values based on their relative value to the + corrected TDC times. + diff --git a/TOF_calib/calview.C b/TOF_calib/calview.C deleted file mode 100644 index 1d14b1fd..00000000 --- a/TOF_calib/calview.C +++ /dev/null @@ -1,255 +0,0 @@ -#include -#include - -using namespace std; - -#include -#include -#include - -double DATA[176][1000]; -double X[1000]; - -int DEBUG = 1; - -double Speed[88]; - -void calview(int PAR){ - - - TCanvas *c1 = new TCanvas("c1", "new canvas",1000,800); - - char inf[128]; - RANGE =0; - if (PAR == 1){ - sprintf(inf,"tofcalib_timing_parms.dat"); - RANGE = 176; - } else if (PAR == 2){ - sprintf(inf,"tofcalib_speed_parms.dat"); - RANGE = 88; - } else { - cout<<"Error not such data! PAR="<>runnum; - - X[cnt] = runnum; - for (int k=0;k>DATA[k][cnt]; - } - cnt++; - - } - INF.close(); - cnt--; - - TH1D *hmean[176]; // distribution of parameters over all runs - TGraphErrors *graphs[176]; // parameters as function of runs - - for (int PMT=0; PMTGetXaxis()->SetTitle("timing offset [ns]"); - } else { - hmean[PMT] = new TH1D(hnam, htit, 500, 15., 17.0); - } - - for (int k=0;kFill(DATA[PMT][k]); - } - - - graphs[PMT] = new TGraphErrors(cnt,X,DATA[PMT],NULL,NULL); - if (PAR==1){ - graphs[PMT]->SetTitle("timing offset as function of run number"); - graphs[PMT]->GetXaxis()->SetTitle("run number [#]"); - graphs[PMT]->GetYaxis()->SetTitle("timing offset [ns]"); - } else { - graphs[PMT]->SetTitle("effective velocity as function of run number"); - graphs[PMT]->GetXaxis()->SetTitle("run number [#]"); - graphs[PMT]->GetYaxis()->SetTitle("velocity [cm/ns]"); - } - - } - - TFile *RF; - - if (PAR == 1) { - RF = new TFile("tofcalib_timeres.root","RECREATE"); - } else { - RF = new TFile("tofcalib_velores.root","RECREATE"); - } - - for (int PMT=0; PMTWrite(); - graphs[PMT]->Write(); - - } - RF->Close(); - - - double Velocities[88]; - - for (int k=0; k<44; k++) { - - int PMT1 = k; - int PMT2 = k+44; - - c1->Clear(); - c1->Divide(2,2); - - c1->cd(1); - if (PAR==2){ - if (hmean[PMT1]->GetEntries()>10) { - double max = hmean[PMT1]->GetBinCenter(hmean[PMT1]->GetMaximumBin()); - hmean[PMT1]->Fit("gaus","","R",max-0.03,max+0.03); - TF1 *f1 = hmean[PMT1]->GetFunction("gaus"); - double sig = f1->GetParameter(2); - if (sig>0.05) { - hmean[PMT1]->Fit("gaus","","R",max-0.05,max+0.05); - } - hmean[PMT1]->GetXaxis()->SetRangeUser(max-0.2,max+0.2); - gStyle->SetOptFit(1); - f1 = hmean[PMT1]->GetFunction("gaus"); - Velocities[PMT1] = f1->GetParameter(1); - } - hmean[PMT1]->Draw(); - Speed[PMT1] = hmean[PMT1]->GetMean(); - } else { - double max = hmean[PMT1]->GetBinCenter(hmean[PMT1]->GetMaximumBin()); - hmean[PMT1]->GetXaxis()->SetRangeUser(max-0.5,max+0.5); - hmean[PMT1]->Draw(); - } - gPad->SetGrid(); - c1->cd(2); - graphs[PMT1]->SetMarkerColor(4); - graphs[PMT1]->SetMarkerStyle(21); - graphs[PMT1]->Draw("AP"); - if (PAR==1){ - graphs[PMT1]->GetYaxis()->SetRangeUser(-2.,2.); - } else { - graphs[PMT1]->GetYaxis()->SetRangeUser(15.,17.); - } - gPad->SetGrid(); - gPad->Update(); - - c1->cd(3); - if (PAR==2){ - if (hmean[PMT2]->GetEntries()>10) { - double max = hmean[PMT2]->GetBinCenter(hmean[PMT2]->GetMaximumBin()); - hmean[PMT2]->Fit("gaus","","R",max-0.03,max+0.03); - TF1 *f1 = hmean[PMT2]->GetFunction("gaus"); - double sig = f1->GetParameter(2); - if (sig>0.05) { - hmean[PMT2]->Fit("gaus","","R",max-0.05,max+0.05); - } - hmean[PMT2]->GetXaxis()->SetRangeUser(max-0.2,max+0.2); - gStyle->SetOptFit(1); - f1 = hmean[PMT2]->GetFunction("gaus"); - Velocities[PMT2] = f1->GetParameter(1); - } - hmean[PMT2]->Draw(); - Speed[PMT2] = hmean[PMT1]->GetMean(); - - } else { - double max = hmean[PMT2]->GetBinCenter(hmean[PMT2]->GetMaximumBin()); - hmean[PMT2]->GetXaxis()->SetRangeUser(max-0.5,max+0.5); - hmean[PMT2]->Draw(); - } - gPad->SetGrid(); - c1->cd(4); - graphs[PMT2]->SetMarkerColor(4); - graphs[PMT2]->SetMarkerStyle(21); - graphs[PMT2]->Draw("AP"); - if (PAR==1){ - graphs[PMT2]->GetYaxis()->SetRangeUser(-2.,2.); - } else { - graphs[PMT2]->GetYaxis()->SetRangeUser(15.,17.); - } - gPad->SetGrid(); - gPad->Update(); - - char outfp[128]; - if (PAR==1){ - sprintf(outfp, "figures/pmt%03d_pmt%03d_offsets.pdf",PMT1,PMT2); - } else { - sprintf(outfp, "figures/paddle%03d_paddle%03d_velocities.pdf",PMT1,PMT2); - } - c1->SaveAs(outfp); - - if (DEBUG>1) - getchar(); - - if (PAR == 1) { - PMT1 += 88; - PMT2 += 88; - - sprintf(outfp, "figures/pmt%03d_pmt%03d_offsets.pdf",PMT1,PMT2); - - c1->Clear(); - c1->Divide(2,2); - - c1->cd(1); - double max = hmean[PMT1]->GetBinCenter(hmean[PMT1]->GetMaximumBin()); - hmean[PMT1]->GetXaxis()->SetRangeUser(max-0.5,max+0.5); - hmean[PMT1]->Draw(); - gPad->SetGrid(); - c1->cd(2); - graphs[PMT1]->SetMarkerColor(4); - graphs[PMT1]->SetMarkerStyle(21); - graphs[PMT1]->Draw("AP"); - if (PAR==1){ - graphs[PMT1]->GetYaxis()->SetRangeUser(-2.,2.); - } else { - graphs[PMT1]->GetYaxis()->SetRangeUser(15.,17.); - } - gPad->SetGrid(); - gPad->Update(); - - c1->cd(3); - max = hmean[PMT2]->GetBinCenter(hmean[PMT2]->GetMaximumBin()); - hmean[PMT2]->GetXaxis()->SetRangeUser(max-0.5,max+0.5); - hmean[PMT2]->Draw(); - gPad->SetGrid(); - c1->cd(4); - graphs[PMT2]->SetMarkerColor(4); - graphs[PMT2]->SetMarkerStyle(21); - graphs[PMT2]->Draw("AP"); - graphs[PMT2]->GetYaxis()->SetRangeUser(-2.,2.); - - gPad->SetGrid(); - gPad->Update(); - - if (DEBUG>1) - getchar(); - } - c1->SaveAs(outfp); - - } - - if (PAR == 2){ - ofstream OF("paddle_velocities.dat"); - for (int k=0;k<88;k++){ - OF<>XPOS[Cnt]>>YPOS[Cnt]>>dYPOS[Cnt]; - //cout<SetTitle(atit); - gr->SetMarkerColor(4); - gr->SetMarkerStyle(21); - gr->Draw("AP"); - gr->GetXaxis()->SetTitle("Run Number"); - gr->GetYaxis()->SetTitle("ADC Integral"); - if (AMP) { - gr->GetYaxis()->SetTitle("ADC Signal Amplitude"); - } - double max = TMath::MaxElement(Cnt-1,gr->GetY()); - gr->GetYaxis()->SetRangeUser(0,max*1.1); - gr->Draw("AP"); - sprintf(atit,"figures/adc_mpv_pmt%d.pdf",PMT); - gPad->SetGrid(); - gPad->SaveAs(atit); - -} diff --git a/TOF_calib/findp.C b/TOF_calib/findp.C deleted file mode 100644 index 4b32b2c4..00000000 --- a/TOF_calib/findp.C +++ /dev/null @@ -1,90 +0,0 @@ -// pupose: find ADC peak position of mips in ADC histogram - -int AMP = 1; - -int DEBUG = 0; - -void findp(int R, int amp){ - - AMP = amp; - - char fnam[128]; - sprintf(fnam,"calibration%d/adchists_run%d.root",R,R); - - TFile *RF = new TFile(fnam,"READ"); - - double FitPar[176][4]; - - double Range[2] = {2000.,10000.}; - double Range1[2] = {5000.,15000.}; - char hn[128] = "ADCHists"; - if (AMP){ - Range[0] = 300.; - Range[1] = 1200.; - Range1[0] = 700.; - Range1[1] = 1800.; - sprintf(hn,"ADCPeakHists"); - } - - char hnam[128]; - for (int k=0;k<176;k++){ - sprintf(hnam,"%s%d",hn,k); - TH1D *h = (TH1D*)RF->Get(hnam); - if (h==NULL){ - cout<<"No amplitude histogram found! quit..."<GetEntries()>10000){ - h->GetXaxis()->SetRangeUser(Range[0],Range[1]); - if ( (k==85) || (k==86) || (k==87) || (k==88)){ - h->GetXaxis()->SetRangeUser(Range1[0],Range1[1]); - } - int MaxBin = h->GetMaximumBin(); - double max = h->GetBinCenter(MaxBin); - double hili = max + 10.*h->GetBinWidth(MaxBin); - double loli = max - 6.*h->GetBinWidth(MaxBin); - h->Fit("landau","","R",loli,hili); - TF1 *f1 = h->GetFunction("landau"); - double sig = f1->GetParameter(2); - hili = max + 3*sig; - loli = max - 1.5*sig; - h->Fit("landau","","R",loli,hili); - - if (DEBUG>2){ - h->GetXaxis()->SetRangeUser(0.,4096); - h->Draw(); - h->GetXaxis()->SetTitle("ADC counts"); - h->GetYaxis()->SetTitle("Counts [#]"); - gPad->Update(); - gPad->SaveAs("pmt_response.pdf"); - getchar(); - return; - } - f1 = h->GetFunction("landau"); - FitPar[k][0] = f1->GetParameter(1); - FitPar[k][1] = f1->GetParError(1); - FitPar[k][2] = f1->GetParameter(2); - FitPar[k][3] = f1->GetParError(2); - } - } - - - RF->Close(); - - sprintf(fnam,"ADC_positions/adc_integral_run%d.dat",R); - if (AMP) { - sprintf(fnam,"ADC_positions/adc_amplitudes_run%d.dat",R); - } - ofstream OUTF(fnam); - char str[128]; - for (int k=0;k<176;k++){ - sprintf(str,"%3d %12.4e %12.4e %12.4e %12.4e",k, - FitPar[k][0],FitPar[k][1],FitPar[k][2],FitPar[k][3]); - OUTF< #include #include +#include using namespace std; @@ -94,6 +95,10 @@ void meantime1(int Run, int REF, int RefPlane){ sprintf(inf,"calibration%d/tof_walk_parameters_run%d.dat",RunNumber,RunNumber); ifstream INF; INF.open(inf); + if (!INF){ + cout<<"Error open walk correction parameter file: "<GetYaxis()->SetTitle("Paddle Number [#]"); sprintf(exnam,"MeanTime Difference MT_{i}-MT_{ref} [ns]"); dMT->GetXaxis()->SetTitle(exnam); + dMT->SetStats(0); dMT->Draw("colz"); gPad->SetGrid(); - gPad->SetLogz(1); + //dMT->GetZaxis()->SetRangeUser(0., 10000.); + //TPaletteAxis *palette=(TPaletteAxis*)dMT->FindObject("palette"); + //double x1 = palette->GetX1(); + //double x2 = palette->GetX2(); + //double newx2 = x2-(x2-x1)/2.; + //palette->SetX2(newx2); + //gPad->SetLogz(1); gPad->Update(); sprintf(exnam,"plots/mtdiff_vs_padnum_RefPad%d_RefPlane%d_run%d.pdf",REFPAD,REFPLANE,RunNumber); if (NOWALK){ sprintf(exnam,"plots/mtdiff_vs_padnum_RefPad%d_run%d_nowalk.pdf",REFPAD,RunNumber); } gPad->SaveAs(exnam); + sprintf(exnam,"C/mtdiff_vs_padnum_RefPad%d_RefPlane%d_run%d.C",REFPAD,REFPLANE,RunNumber); + gPad->SaveAs(exnam); + } if (DEBUG>1){ if (!((k-3)%10) || (DEBUG>98)){ @@ -452,6 +467,11 @@ void findpeak(double *MTPosition, double *MTSigma){ sprintf(exnam,"plots/mtdiff_vs_padnum_proj_%d_ref%d_run%d_nowalk.pdf",k,REFPAD,RunNumber); } gPad->SaveAs(exnam); + + sprintf(exnam,"C/mtdiff_vs_padnum_proj_%d_ref%d_RefPlane%d_run%d.C",k,REFPAD,REFPLANE,RunNumber); + gPad->SaveAs(exnam); + + } } } diff --git a/TOF_calib/src/meantime2.C b/TOF_calib/src/meantime2.C index f4dac448..ceaed811 100644 --- a/TOF_calib/src/meantime2.C +++ b/TOF_calib/src/meantime2.C @@ -157,6 +157,8 @@ double getmt(int p1, int p2, double *mtref,int RunNumber) { gPad->Update(); sprintf(fnam,"plots/meantime_average_to_refpaddle%d.pdf",REFPAD[1]); gPad->SaveAs(fnam); + sprintf(fnam,"C/meantime_average_to_refpaddle%d.C",REFPAD[1]); + gPad->SaveAs(fnam); } } //histdt->Draw(); diff --git a/TOF_calib/src/tdlook.C b/TOF_calib/src/tdlook.C index 063d0943..9bf23776 100644 --- a/TOF_calib/src/tdlook.C +++ b/TOF_calib/src/tdlook.C @@ -220,6 +220,9 @@ void gettime(int REFID, int PLANEID, if (!(REFID%5)|| (DEBUG>98)) { sprintf(tnam,"plots/velocity_refpad%d_plane%d_run%d.pdf",REFID,PLANEID,RunNumber); gPad->SaveAs(tnam); + + sprintf(tnam,"C/velocity_refpad%d_plane%d_run%d.C",REFID,PLANEID,RunNumber); + gPad->SaveAs(tnam); double chi2 = p2->GetChisquare(); double ndeg = (double)p2->GetNumberFitPoints() - (double)p2->GetNumberFreeParameters(); diff --git a/TOF_calib/src/timedifference.C b/TOF_calib/src/timedifference.C index 7b82ea8e..928524a3 100644 --- a/TOF_calib/src/timedifference.C +++ b/TOF_calib/src/timedifference.C @@ -258,15 +258,31 @@ void timedifference(int Run, int REF, int REFPLANE){ if (hp->Integral(1,hp->GetNbinsX()-2)>100){ - hp->Rebin(2); + if (hp->GetEntries()<10000) { + hp->Rebin(16); + } else if (hp->GetEntries()<20000) { + hp->Rebin(8); + } else { + hp->Rebin(4); + } if (j-2<8){ - hp->Rebin(4); + //hp->Rebin(4); hp->GetXaxis()->SetRangeUser(-12.,-3.); - } - if (j-2>BARS_PER_PLANE-8){ - hp->Rebin(4); + } else if (j-2<17){ + //hp->Rebin(4); + hp->GetXaxis()->SetRangeUser(-12.,0.); + } else if (j-2<22){ + //hp->Rebin(4); + hp->GetXaxis()->SetRangeUser(-12.,1.); + } else if (j-2>BARS_PER_PLANE-8){ + //hp->Rebin(4); hp->GetXaxis()->SetRangeUser(3.,12.); + } else if (j-2>BARS_PER_PLANE-17){ + //hp->Rebin(4); + hp->GetXaxis()->SetRangeUser(-1.,12.); + } else { + //hp->Rebin(6); } @@ -277,9 +293,9 @@ void timedifference(int Run, int REF, int REFPLANE){ } else { nfound = speaks->Search(hp,2,"nodraw",0.10); } + //printf("Found %d candidate peaks to fit\n",nfound); double *xpeaks = speaks->GetPositionX(); - double *ypeaks = speaks->GetPositionY(); // for paddles on the left of the center take left most peak // for paddles on the right of the center take right most peak @@ -291,33 +307,62 @@ void timedifference(int Run, int REF, int REFPLANE){ double MaxXloc = -100000.; int MinXlocPos = 0; int MaxXlocPos = 0; - for (int pp=0;ppMaxPeak){ - MaxPeak = yp; - MaxPeakLoc = pp; - } - if (xpFindBin(xp); + double by = hp->GetBinContent(b); + max = xpeaks[0]; + if (DEBUG>1) { + cout<<"PeakID: 0 bin is: "<FindBin(max) + <<" content is "<GetBinContent(hp->FindBin(max)) + <<" xposition = "<MaxXloc){ - MaxXloc =xp; - MaxXlocPos = pp; - } - } - /* - if (TMath::Abs(REFPAD-BARS_PER_PLANE/2)>4){ - max = xpeaks[MaxPeakLoc]; - } else { - */ + } else if (nfound>1) { + + for (int pp=0;ppFindBin(xp); + double by = hp->GetBinContent(b); + if (DEBUG>1) { + cout<<"PeakID: "<98){ @@ -325,13 +370,18 @@ void timedifference(int Run, int REF, int REFPLANE){ gPad->Update(); gPad->SetGrid(); gPad->Update(); - cout<<"MAX is at "<10) { + if (max != xpeaks[MaxPeakLoc]){ + max = xpeaks[MaxPeakLoc]; + } + } - - if (TMath::Abs(max - GoodMax[j-2-1])>2.2){ // off by more than 1ns from expected postion TOO MUCH + if (TMath::Abs(max - GoodMax[j-2-1])>3.2){ // off by more than 1ns from expected postion TOO MUCH cout<<"max out of range try to find better max for j-2="<GetPositionX(); - double *ypeaks1 = speaks1->GetPositionY(); + int minid = -1; int maxid = -1; for (int pp=0;ppGetFunction("gaus"); @@ -455,12 +506,16 @@ void timedifference(int Run, int REF, int REFPLANE){ histTD->SetTitle(fnam); histTD->GetYaxis()->SetTitle("#Deltat [ns]"); histTD->GetXaxis()->SetTitle("Paddle number [#]"); + histTD->SetStats(0); histTD->Draw("colz"); gPad->SetGrid(); - gPad->SetLogz(1); + //gPad->SetLogz(1); gPad->Update(); + //gPad->SaveAs("plots/test.root"); sprintf(fnam,"plots/paddleNumber_vs_deltatRefPad%d_plane%d_run%d.pdf",REFPAD,REFPLANE,RunNumber); gPad->SaveAs(fnam); + sprintf(fnam,"C/paddleNumber_vs_deltatRefPad%d_plane%d_run%d.C",REFPAD,REFPLANE,RunNumber); + gPad->SaveAs(fnam); } if (!((j-3)%5) || (DEBUG>2)){ hp->GetXaxis()->SetTitle("#Deltat [ns]"); @@ -475,6 +530,8 @@ void timedifference(int Run, int REF, int REFPLANE){ gPad->Update(); sprintf(hnam1,"plots/deltat_fitposition_p%d_repad%d_plane%d_run%d.pdf",j-2,REFPAD,REFPLANE,RunNumber); gPad->SaveAs(hnam1); + sprintf(hnam1,"C/deltat_fitposition_p%d_repad%d_plane%d_run%d.C",j-2,REFPAD,REFPLANE,RunNumber); + gPad->SaveAs(hnam1); } } if (DEBUG == 99){ diff --git a/TOF_calib/src/walk1.C b/TOF_calib/src/walk1.C index 739786e3..f7f9f47d 100644 --- a/TOF_calib/src/walk1.C +++ b/TOF_calib/src/walk1.C @@ -446,15 +446,26 @@ double fithist(TH2F *hist, double *allp, int plane, int paddle, int side, int id double Chi2 = res->Chi2() / res->Ndf(); cout<<"chi2 = "<100){ - f1->SetParameter(0, 1.); + f1->SetParameter(0, -2.7); f1->SetParameter(1, 1.); f1->SetParameter(2, 1.); f1->SetParameter(3, 1.); f1->SetParameter(4, 1.); res = (TFitResultPtr)graph->Fit(f1, "SQ", "R", f1limit, 3000.); Chi2 = res->Chi2() / res->Ndf(); - cout<<"chi2 = "<Chi2() / res->Ndf(); + cout<<"THIRD ROUND FIT: chi2 = "<GetFunction("f1"); for (int k=0;k<5;k++){ F1->SetParameter(k, fres->GetParameter(k)); @@ -463,6 +474,14 @@ double fithist(TH2F *hist, double *allp, int plane, int paddle, int side, int id } F1->SetLineColor(4); + if (DEBUG>98){ + graph->Draw("AP"); + F1->Draw("same"); + gPad->SetGrid(); + gPad->Update(); + getchar(); + } + f2->SetParameter(0, 1.); f2->SetParameter(1, -0.001); int nbins = graph->GetN(); @@ -477,12 +496,12 @@ double fithist(TH2F *hist, double *allp, int plane, int paddle, int side, int id } return Chi2; } - + + return Chi2; cout<<"Fit f2 for PMT: "<Fit(f2, "SQ", "R", 2000., 3900.); + TFitResultPtr res1 = graph->Fit(f2, "SQ", "R", 2000, 3900.); Chi2 += res->Chi2() / res->Ndf(); fres = (TF1*)graph->GetFunction("f2"); - int OFFS = 10; for (int k=0;k<2;k++){ F2->SetParameter(k, fres->GetParameter(k)); @@ -491,6 +510,14 @@ double fithist(TH2F *hist, double *allp, int plane, int paddle, int side, int id } F2->SetLineColor(2); + if (DEBUG>98){ + graph->Draw("AP"); + F2->Draw("same"); + gPad->SetGrid(); + gPad->Update(); + getchar(); + } + char fitnam[128]; sprintf(fitnam,"fit1hist%d",idx); F1->SetName(fitnam);