void time_res(void) { gROOT->Reset(); // Timewalk corrections. These were obtained by running the // timewalk.C macro and copying the last few lines that // printed to stdout. char *tn7 = "(tn7-(3.331473*exp(-0.006549*n7)+0.773828+(-0.000631*n7)))"; char *tn8 = "(tn8-(2.421650*exp(-0.005287*n8)+0.410419+(-0.000499*n8)))"; char *ts7 = "(ts7-(3.248674*exp(-0.006659*s7)+0.563583+(-0.000647*s7)))"; char *ts8 = "(ts8-(2.566994*exp(-0.005763*s8)+0.494722+(-0.000601*s8)))"; // Create canvas with 2 pads, top for no timewalk correction, bottom corrected TCanvas *c1 = new TCanvas("c1","",600,800); c1->Divide(1,3); for(int i=1; i<=3; i++){ c1->GetPad(i)->SetTickx(); c1->GetPad(i)->SetTicky(); } // Get pointer to bcal TTree TTree *bcal = (TTree*)gROOT->FindObject("bcal"); // Make histograms to hold time diff vs. photon energy plot TH2F *tdiff_vs_Ephoton = new TH2F("tdiff_vs_Ephoton", "#Deltat vs. Ephoton", 100, 150.0, 650.0, 100, -10.0, 10.0); TH2F *tdiff_vs_Ephoton_corr = new TH2F("tdiff_vs_Ephoton_corr", "#Deltat vs. Ephoton timewalk corrected", 100, 150.0, 650.0, 100, -10.0, 10.0); // Set labels and turn off stats for pretty plotting tdiff_vs_Ephoton->SetStats(0); tdiff_vs_Ephoton->SetYTitle("Difference in mean times between cell 7 and cell 8 (ns)"); tdiff_vs_Ephoton->SetXTitle("E_{#gamma} from tagger (MeV)"); tdiff_vs_Ephoton_corr->SetStats(0); tdiff_vs_Ephoton_corr->SetYTitle("Difference in mean times between cell 7 and cell 8 (ns)"); tdiff_vs_Ephoton_corr->SetXTitle("E_{#gamma} from tagger (MeV)"); // Draw time difference between mean time of cell 7 and cell 8 // vs. photon energy without timewalk correction. c1->cd(1); bcal->Project("tdiff_vs_Ephoton", "(tn8+ts8)/2.0 - (tn7+ts7)/2.0:Ephoton", "Nphotons==1"); tdiff_vs_Ephoton->Draw(); // Draw time difference between mean time of cell 7 and cell 8 // vs. photon energy WITH timewalk corrections. c1->cd(2); char expr[512]; sprintf(expr, "(%s+%s)/2.0 - (%s+%s)/2.0:Ephoton", tn8, ts8, tn7, ts7); bcal->Project("tdiff_vs_Ephoton_corr", expr, "Nphotons==1"); tdiff_vs_Ephoton_corr->SetMarkerColor(kRed); tdiff_vs_Ephoton_corr->Draw(); // Fit slices of both the corrected and uncorrected histograms // and plot the sigmas vs. photon energy to see the improvement. tdiff_vs_Ephoton->FitSlicesY(); tdiff_vs_Ephoton_corr->FitSlicesY(); TH1D* tdiff_vs_Ephoton_2 = (TH1D*)gROOT->FindObject("tdiff_vs_Ephoton_2"); TH1D* tdiff_vs_Ephoton_corr_2 = (TH1D*)gROOT->FindObject("tdiff_vs_Ephoton_corr_2"); c1->cd(3); TH2F *axes = new TH2F("axes","#sigma_{#Deltat} vs. E_{#gamma}", 100, 150, 650, 100, 0.0, 1.5); axes->SetStats(0); axes->SetYTitle("#sigma of difference in mean times between cell 7 and cell 8 (ns)"); axes->SetXTitle("E_{#gamma} from tagger (MeV)"); axes->Draw(); tdiff_vs_Ephoton_2->Draw("same"); tdiff_vs_Ephoton_corr_2->SetMarkerColor(kRed); tdiff_vs_Ephoton_corr_2->SetLineColor(kRed); tdiff_vs_Ephoton_corr_2->Draw("same"); // Save to file c1->SaveAs("bcal_time_res_vs_Ephoton.gif"); }