// ----------------------------------------------------------------------------- // ----- pl_over_MCHitSel.C ----- // ----- ----- // ----- created by C. Simon on 2018-10-09 ----- // ----- ----- // ----------------------------------------------------------------------------- void pl_over_MCHitSel() { gStyle->SetPalette(1); gStyle->SetOptStat(kTRUE); gStyle->SetOptFit(kTRUE); gROOT->cd(); gROOT->SetDirLevel(1); TH1* h1(NULL); TH2* h2(NULL); TEfficiency* heff(NULL); TF1* f1(NULL); TLegend* leg(NULL); TLegendEntry* len(NULL); TPaveStats* stats(NULL); TString hname; const Int_t kMaxRefTrackMul = 20; TCanvas* can = new TCanvas("can", "MC hit selection overview", 0, 0, 2000, 1066); can->Divide(8, 4); can->cd(1); hname = "hSelEfficiency"; heff = dynamic_cast(gROOT->FindObjectAny(hname)); if(heff) { heff->Draw("AP"); gPad->Update(); heff->GetPaintedGraph()->GetXaxis()->SetLimits(heff->GetTotalHistogram()->GetXaxis()->GetXmin(), kMaxRefTrackMul); // heff->GetTotalHistogram()->GetXaxis()->GetXmax()); heff->GetPaintedGraph()->GetYaxis()->SetRangeUser(0., 0.11); gPad->Modified(); cout << endl; cout << Form("mean Sel HP efficiency: %7.3f %%", 100.*heff->GetPassedHistogram()->Integral()/heff->GetTotalHistogram()->Integral()) << endl; } else { cout << hname << " not found" << endl; } can->cd(9); hname = "hSelPurity"; heff = dynamic_cast(gROOT->FindObjectAny(hname)); if(heff) { heff->Draw("AP"); gPad->Update(); heff->GetPaintedGraph()->GetXaxis()->SetLimits(heff->GetTotalHistogram()->GetXaxis()->GetXmin(), kMaxRefTrackMul); // heff->GetTotalHistogram()->GetXaxis()->GetXmax()); heff->GetPaintedGraph()->GetYaxis()->SetRangeUser(0., 1.1); gPad->Modified(); cout << Form("mean Sel HP purity: %7.3f %%", 100.*heff->GetPassedHistogram()->Integral()/heff->GetTotalHistogram()->Integral()) << endl; } else { cout << hname << " not found" << endl; } can->cd(2); hname = "hSelRefTrackShare"; heff = dynamic_cast(gROOT->FindObjectAny(hname)); if(heff) { heff->Draw("AP"); gPad->Update(); heff->GetPaintedGraph()->GetXaxis()->SetLimits(heff->GetTotalHistogram()->GetXaxis()->GetXmin(), kMaxRefTrackMul); // heff->GetTotalHistogram()->GetXaxis()->GetXmax()); heff->GetPaintedGraph()->GetYaxis()->SetRangeUser(0., 1.1); gPad->Modified(); cout << Form("mean Sel HP ref track share: %7.3f %%", 100.*heff->GetPassedHistogram()->Integral()/heff->GetTotalHistogram()->Integral()) << endl; } else { cout << hname << " not found" << endl; } can->cd(17); hname = "hSelMatchEfficiency"; heff = dynamic_cast(gROOT->FindObjectAny(hname)); if(heff) { heff->Draw("AP"); gPad->Update(); heff->GetPaintedGraph()->GetXaxis()->SetLimits(heff->GetTotalHistogram()->GetXaxis()->GetXmin(), kMaxRefTrackMul); // heff->GetTotalHistogram()->GetXaxis()->GetXmax()); heff->GetPaintedGraph()->GetYaxis()->SetRangeUser(0., 1.1); gPad->Modified(); cout << Form("mean Sel HP match efficiency: %7.3f %%", 100.*heff->GetPassedHistogram()->Integral()/heff->GetTotalHistogram()->Integral()) << endl; } else { cout << hname << " not found" << endl; } can->cd(25); hname = "hSelMatchPurity"; heff = dynamic_cast(gROOT->FindObjectAny(hname)); if(heff) { heff->Draw("AP"); gPad->Update(); heff->GetPaintedGraph()->GetXaxis()->SetLimits(heff->GetTotalHistogram()->GetXaxis()->GetXmin(), kMaxRefTrackMul); // heff->GetTotalHistogram()->GetXaxis()->GetXmax()); heff->GetPaintedGraph()->GetYaxis()->SetRangeUser(0., 1.1); gPad->Modified(); cout << Form("mean Sel HP match purity: %7.3f %%", 100.*heff->GetPassedHistogram()->Integral()/heff->GetTotalHistogram()->Integral()) << endl; } else { cout << hname << " not found" << endl; } can->cd(10); hname = "hNTracksPerSelMRefHit"; h1 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h1) { h1->Scale(1./h1->Integral()); h1->SetLineColor(kRed); gPad->SetLogy(); h1->Draw("HIST"); gPad->Update(); hname = "hNTracksPerMRefHit"; h1 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h1) { h1->Scale(1./h1->Integral()); h1->Draw("HIST SAMES"); gPad->Update(); stats = dynamic_cast(h1->FindObject("stats")); stats->SetY1NDC(stats->GetY1NDC() - 0.3); stats->SetY2NDC(stats->GetY2NDC() - 0.3); gPad->Modified(); gPad->Update(); } else { cout << hname << " not found" << endl; } } else { cout << hname << " not found" << endl; } can->cd(18); hname = "hNTracksPerSelSel2Hit"; h1 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h1) { h1->Scale(1./h1->Integral()); h1->SetLineColor(kRed); gPad->SetLogy(); h1->Draw("HIST"); gPad->Update(); hname = "hNTracksPerSel2Hit"; h1 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h1) { h1->Scale(1./h1->Integral()); h1->Draw("HIST SAMES"); gPad->Update(); stats = dynamic_cast(h1->FindObject("stats")); stats->SetY1NDC(stats->GetY1NDC() - 0.3); stats->SetY2NDC(stats->GetY2NDC() - 0.3); gPad->Modified(); gPad->Update(); } else { cout << hname << " not found" << endl; } } else { cout << hname << " not found" << endl; } can->cd(26); hname = "hNTracksPerSelDutHit"; h1 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h1) { h1->Scale(1./h1->Integral()); h1->SetLineColor(kRed); gPad->SetLogy(); h1->Draw("HIST"); gPad->Update(); hname = "hNTracksPerDutHit"; h1 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h1) { h1->Scale(1./h1->Integral()); h1->Draw("HIST SAMES"); gPad->Update(); stats = dynamic_cast(h1->FindObject("stats")); stats->SetY1NDC(stats->GetY1NDC() - 0.3); stats->SetY2NDC(stats->GetY2NDC() - 0.3); gPad->Modified(); gPad->Update(); } else { cout << hname << " not found" << endl; } } else { cout << hname << " not found" << endl; } can->cd(3); hname = "hResX04HitExp"; h2 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h2) { gPad->SetLogz(); h2->Draw("colz"); h2->ProfileX()->Draw("sameE1"); can->cd(6); h1 = h2->ProjectionY(Form("%s_py", hname.Data()), 1, h2->GetNbinsX()); gPad->SetLogy(); h1->Draw(); h1->Fit("gaus", "Q"); gPad->Update(); TPaveStats* stats = dynamic_cast(h1->FindObject("stats")); stats->SetOptFit(10001); gPad->Modified(); TH1* h1hs = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigma", hname.Data()))); if(h1hs) { delete h1hs; } h1hs = new TH1F(Form("%sHistSigma", hname.Data()), Form("DUT X residual hist StdDev; %s; #sigma(#DeltaX) [cm]", h2->GetXaxis()->GetTitle()), h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1hst = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaTheory", TString(hname.Data(), 7).Data()))); if(h1hst) { delete h1hst; } h1hst = new TH1F(Form("%sHistSigmaTheory", TString(hname.Data(), 7).Data()), ";;", h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1gs = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigma", hname.Data()))); if(h1gs) { delete h1gs; } h1gs = new TH1F(Form("%sGausSigma", hname.Data()), Form("DUT X residual gaus StdDev; %s; #sigma(#DeltaX) [cm]", h2->GetXaxis()->GetTitle()), h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1gst = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaTheory", TString(hname.Data(), 7).Data()))); if(h1gst) { delete h1gst; } h1gst = new TH1F(Form("%sGausSigmaTheory", TString(hname.Data(), 7).Data()), ";;", h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); for(Int_t iBin = 1; iBin <= h2->GetNbinsX(); iBin++) { h1 = h2->ProjectionY(Form("%s_py%d", hname.Data(), iBin), iBin, iBin); h1hs->SetBinContent(iBin, h1->GetStdDev(1)); h1hs->SetBinError(iBin, h1->GetStdDevError(1)); h1hst->SetBinContent(iBin, h1->GetStdDev(1)); h1hst->SetBinError(iBin, h1->GetStdDevError(1)); if(h1->GetEntries()) { if(0 == static_cast(h1->Fit("gaus", "Q0"))) { h1gs->SetBinContent(iBin, (h1->GetFunction("gaus"))->GetParameter("Sigma")); h1gs->SetBinError(iBin, (h1->GetFunction("gaus"))->GetParError(2)); h1gst->SetBinContent(iBin, (h1->GetFunction("gaus"))->GetParameter("Sigma")); h1gst->SetBinError(iBin, (h1->GetFunction("gaus"))->GetParError(2)); } } delete h1; } can->cd(27); h1hs->SetStats(0); h1hs->GetYaxis()->SetRangeUser(0., 0.5); h1hs->Draw("PE1"); gPad->Update(); h1hs->GetXaxis()->SetRangeUser(h1hs->GetXaxis()->GetXmin(), kMaxRefTrackMul); h1hs->SetLineColor(2); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaLegend", TString(hname.Data(), 7).Data()))); if(leg) { gROOT->GetList()->Remove(leg); delete leg; } leg = new TLegend(0.5, gStyle->GetPadBottomMargin() + 0.05, 1. - gStyle->GetPadRightMargin() - 0.05, 0.5); leg->SetName(Form("%sHistSigmaLegend", TString(hname.Data(), 7).Data())); gROOT->GetList()->Add(leg); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1hs, "#color[2]{hit-exp}", ""); len->SetMarkerSize(1.5); can->cd(30); h1gs->SetStats(0); h1gs->GetYaxis()->SetRangeUser(0., 0.5); h1gs->Draw("PE1"); gPad->Update(); h1gs->GetXaxis()->SetRangeUser(h1gs->GetXaxis()->GetXmin(), kMaxRefTrackMul); h1gs->SetLineColor(2); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaLegend", TString(hname.Data(), 7).Data()))); if(leg) { gROOT->GetList()->Remove(leg); delete leg; } leg = new TLegend(0.5, gStyle->GetPadBottomMargin() + 0.05, 1. - gStyle->GetPadRightMargin() - 0.05, 0.5); leg->SetName(Form("%sGausSigmaLegend", TString(hname.Data(), 7).Data())); gROOT->GetList()->Add(leg); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1gs, "#color[2]{hit-exp}", ""); len->SetMarkerSize(1.5); } else { cout << hname << " not found" << endl; } can->cd(4); hname = "hResY04HitExp"; h2 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h2) { gPad->SetLogz(); h2->Draw("colz"); h2->ProfileX()->Draw("sameE1"); can->cd(7); h1 = h2->ProjectionY(Form("%s_py", hname.Data()), 1, h2->GetNbinsX()); gPad->SetLogy(); h1->Draw(); h1->Fit("gaus", "Q"); gPad->Update(); TPaveStats* stats = dynamic_cast(h1->FindObject("stats")); stats->SetOptFit(10001); gPad->Modified(); TH1* h1hs = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigma", hname.Data()))); if(h1hs) { delete h1hs; } h1hs = new TH1F(Form("%sHistSigma", hname.Data()), Form("DUT Y residual hist StdDev; %s; #sigma(#DeltaY) [cm]", h2->GetXaxis()->GetTitle()), h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1hst = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaTheory", TString(hname.Data(), 7).Data()))); if(h1hst) { delete h1hst; } h1hst = new TH1F(Form("%sHistSigmaTheory", TString(hname.Data(), 7).Data()), ";;", h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1gs = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigma", hname.Data()))); if(h1gs) { delete h1gs; } h1gs = new TH1F(Form("%sGausSigma", hname.Data()), Form("DUT Y residual gaus StdDev; %s; #sigma(#DeltaY) [cm]", h2->GetXaxis()->GetTitle()), h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1gst = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaTheory", TString(hname.Data(), 7).Data()))); if(h1gst) { delete h1gst; } h1gst = new TH1F(Form("%sGausSigmaTheory", TString(hname.Data(), 7).Data()), ";;", h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); for(Int_t iBin = 1; iBin <= h2->GetNbinsX(); iBin++) { h1 = h2->ProjectionY(Form("%s_py%d", hname.Data(), iBin), iBin, iBin); h1hs->SetBinContent(iBin, h1->GetStdDev(1)); h1hs->SetBinError(iBin, h1->GetStdDevError(1)); h1hst->SetBinContent(iBin, h1->GetStdDev(1)); h1hst->SetBinError(iBin, h1->GetStdDevError(1)); if(h1->GetEntries()) { if(0 == static_cast(h1->Fit("gaus", "Q0"))) { h1gs->SetBinContent(iBin, (h1->GetFunction("gaus"))->GetParameter("Sigma")); h1gs->SetBinError(iBin, (h1->GetFunction("gaus"))->GetParError(2)); h1gst->SetBinContent(iBin, (h1->GetFunction("gaus"))->GetParameter("Sigma")); h1gst->SetBinError(iBin, (h1->GetFunction("gaus"))->GetParError(2)); } } delete h1; } can->cd(28); h1hs->SetStats(0); h1hs->GetYaxis()->SetRangeUser(0., 2.5); h1hs->Draw("PE1"); gPad->Update(); h1hs->GetXaxis()->SetRangeUser(h1hs->GetXaxis()->GetXmin(), kMaxRefTrackMul); h1hs->SetLineColor(2); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaLegend", TString(hname.Data(), 7).Data()))); if(leg) { gROOT->GetList()->Remove(leg); delete leg; } leg = new TLegend(0.5, gStyle->GetPadBottomMargin() + 0.05, 1. - gStyle->GetPadRightMargin() - 0.05, 0.5); leg->SetName(Form("%sHistSigmaLegend", TString(hname.Data(), 7).Data())); gROOT->GetList()->Add(leg); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1hs, "#color[2]{hit-exp}", ""); len->SetMarkerSize(1.5); can->cd(31); h1gs->SetStats(0); h1gs->GetYaxis()->SetRangeUser(0., 2.5); h1gs->Draw("PE1"); gPad->Update(); h1gs->GetXaxis()->SetRangeUser(h1gs->GetXaxis()->GetXmin(), kMaxRefTrackMul); h1gs->SetLineColor(2); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaLegend", TString(hname.Data(), 7).Data()))); if(leg) { gROOT->GetList()->Remove(leg); delete leg; } leg = new TLegend(0.5, gStyle->GetPadBottomMargin() + 0.05, 1. - gStyle->GetPadRightMargin() - 0.05, 0.5); leg->SetName(Form("%sGausSigmaLegend", TString(hname.Data(), 7).Data())); gROOT->GetList()->Add(leg); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1gs, "#color[2]{hit-exp}", ""); len->SetMarkerSize(1.5); } else { cout << hname << " not found" << endl; } can->cd(5); hname = "hResT04HitExp"; h2 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h2) { gPad->SetLogz(); h2->Draw("colz"); h2->ProfileX()->Draw("sameE1"); can->cd(8); h1 = h2->ProjectionY(Form("%s_py", hname.Data()), 1, h2->GetNbinsX()); gPad->SetLogy(); h1->Draw(); h1->Fit("gaus", "Q"); gPad->Update(); TPaveStats* stats = dynamic_cast(h1->FindObject("stats")); stats->SetOptFit(10001); gPad->Modified(); TH1* h1hs = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigma", hname.Data()))); if(h1hs) { delete h1hs; } h1hs = new TH1F(Form("%sHistSigma", hname.Data()), Form("DUT T residual hist StdDev; %s; #sigma(#DeltaT) [ns]", h2->GetXaxis()->GetTitle()), h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1hst = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaTheory", TString(hname.Data(), 7).Data()))); if(h1hst) { delete h1hst; } h1hst = new TH1F(Form("%sHistSigmaTheory", TString(hname.Data(), 7).Data()), ";;", h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1gs = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigma", hname.Data()))); if(h1gs) { delete h1gs; } h1gs = new TH1F(Form("%sGausSigma", hname.Data()), Form("DUT T residual gaus StdDev; %s; #sigma(#DeltaT) [ns]", h2->GetXaxis()->GetTitle()), h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1gst = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaTheory", TString(hname.Data(), 7).Data()))); if(h1gst) { delete h1gst; } h1gst = new TH1F(Form("%sGausSigmaTheory", TString(hname.Data(), 7).Data()), ";;", h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); for(Int_t iBin = 1; iBin <= h2->GetNbinsX(); iBin++) { h1 = h2->ProjectionY(Form("%s_py%d", hname.Data(), iBin), iBin, iBin); h1hs->SetBinContent(iBin, h1->GetStdDev(1)); h1hs->SetBinError(iBin, h1->GetStdDevError(1)); h1hst->SetBinContent(iBin, h1->GetStdDev(1)); h1hst->SetBinError(iBin, h1->GetStdDevError(1)); if(h1->GetEntries()) { if(0 == static_cast(h1->Fit("gaus", "Q0"))) { h1gs->SetBinContent(iBin, (h1->GetFunction("gaus"))->GetParameter("Sigma")); h1gs->SetBinError(iBin, (h1->GetFunction("gaus"))->GetParError(2)); h1gst->SetBinContent(iBin, (h1->GetFunction("gaus"))->GetParameter("Sigma")); h1gst->SetBinError(iBin, (h1->GetFunction("gaus"))->GetParError(2)); } } delete h1; } can->cd(29); h1hs->SetStats(0); h1hs->GetYaxis()->SetRangeUser(0., 0.15); h1hs->Draw("PE1"); gPad->Update(); h1hs->GetXaxis()->SetRangeUser(h1hs->GetXaxis()->GetXmin(), kMaxRefTrackMul); h1hs->SetLineColor(2); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaLegend", TString(hname.Data(), 7).Data()))); if(leg) { gROOT->GetList()->Remove(leg); delete leg; } leg = new TLegend(0.5, gStyle->GetPadBottomMargin() + 0.05, 1. - gStyle->GetPadRightMargin() - 0.05, 0.5); leg->SetName(Form("%sHistSigmaLegend", TString(hname.Data(), 7).Data())); gROOT->GetList()->Add(leg); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1hs, "#color[2]{hit-exp}", ""); len->SetMarkerSize(1.5); can->cd(32); h1gs->SetStats(0); h1gs->GetYaxis()->SetRangeUser(0., 0.15); h1gs->Draw("PE1"); gPad->Update(); h1gs->GetXaxis()->SetRangeUser(h1gs->GetXaxis()->GetXmin(), kMaxRefTrackMul); h1gs->SetLineColor(2); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaLegend", TString(hname.Data(), 7).Data()))); if(leg) { gROOT->GetList()->Remove(leg); delete leg; } leg = new TLegend(0.5, gStyle->GetPadBottomMargin() + 0.05, 1. - gStyle->GetPadRightMargin() - 0.05, 0.5); leg->SetName(Form("%sGausSigmaLegend", TString(hname.Data(), 7).Data())); gROOT->GetList()->Add(leg); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1gs, "#color[2]{hit-exp}", ""); len->SetMarkerSize(1.5); } else { cout << hname << " not found" << endl; } can->cd(11); hname = "hResX04ExpMC"; h2 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h2) { gPad->SetLogz(); h2->Draw("colz"); h2->ProfileX()->Draw("sameE1"); can->cd(14); h1 = h2->ProjectionY(Form("%s_py", hname.Data()), 1, h2->GetNbinsX()); gPad->SetLogy(); h1->Draw(); h1->Fit("gaus", "Q"); gPad->Update(); TPaveStats* stats = dynamic_cast(h1->FindObject("stats")); stats->SetOptFit(10001); gPad->Modified(); TH1* h1hs = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigma", hname.Data()))); if(h1hs) { delete h1hs; } h1hs = new TH1F(Form("%sHistSigma", hname.Data()), Form("; %s; #color[602]{hist}/#color[2]{gaus} sigma [cm]", h2->GetXaxis()->GetTitle()), h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1hst = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaTheory", TString(hname.Data(), 7).Data()))); TH1* h1gs = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigma", hname.Data()))); if(h1gs) { delete h1gs; } h1gs = new TH1F(Form("%sGausSigma", hname.Data()), ";;", h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1gst = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaTheory", TString(hname.Data(), 7).Data()))); for(Int_t iBin = 1; iBin <= h2->GetNbinsX(); iBin++) { h1 = h2->ProjectionY(Form("%s_py%d", hname.Data(), iBin), iBin, iBin); h1hs->SetBinContent(iBin, h1->GetStdDev(1)); h1hs->SetBinError(iBin, h1->GetStdDevError(1)); if(h1hst) { Double_t dBinContent = TMath::Power(h1hst->GetBinContent(iBin), 2.) - TMath::Power(h1hs->GetBinContent(iBin), 2.); if(0. < dBinContent) { Double_t dBinError = TMath::Sqrt((TMath::Power(h1hst->GetBinContent(iBin)*h1hst->GetBinError(iBin), 2.) + TMath::Power(h1hs->GetBinContent(iBin)*h1hs->GetBinError(iBin), 2.))/dBinContent); h1hst->SetBinContent(iBin, TMath::Sqrt(dBinContent)); h1hst->SetBinError(iBin, dBinError); } else { h1hst->SetBinContent(iBin, 0.); h1hst->SetBinError(iBin, 0.); } } if(h1->GetEntries()) { if(0 == static_cast(h1->Fit("gaus", "Q0"))) { h1gs->SetBinContent(iBin, (h1->GetFunction("gaus"))->GetParameter("Sigma")); h1gs->SetBinError(iBin, (h1->GetFunction("gaus"))->GetParError(2)); if(h1gst) { Double_t dBinContent = TMath::Power(h1gst->GetBinContent(iBin), 2.) - TMath::Power(h1gs->GetBinContent(iBin), 2.); if(0. < dBinContent) { Double_t dBinError = TMath::Sqrt((TMath::Power(h1gst->GetBinContent(iBin)*h1gst->GetBinError(iBin), 2.) + TMath::Power(h1gs->GetBinContent(iBin)*h1gs->GetBinError(iBin), 2.))/dBinContent); h1gst->SetBinContent(iBin, TMath::Sqrt(dBinContent)); h1gst->SetBinError(iBin, dBinError); } else { h1gst->SetBinContent(iBin, 0.); h1gst->SetBinError(iBin, 0.); } } } } delete h1; } can->cd(27); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaLegend", TString(hname.Data(), 7).Data()))); h1hs->SetStats(0); h1hs->Draw("PE1same"); h1hs->SetLineColor(3); h1hst->SetStats(0); h1hst->Draw("PE1same"); h1hst->SetLineColor(9); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1hs, "#color[3]{exp-MC}", ""); len->SetMarkerSize(1.5); len = leg->AddEntry(h1hst, "#color[9]{hit-MC calc.}", ""); len->SetMarkerSize(1.5); can->cd(30); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaLegend", TString(hname.Data(), 7).Data()))); h1gs->SetStats(0); h1gs->Draw("PE1same"); h1gs->SetLineColor(3); h1gst->SetStats(0); h1gst->Draw("PE1same"); h1gst->SetLineColor(9); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1gs, "#color[3]{exp-MC}", ""); len->SetMarkerSize(1.5); len = leg->AddEntry(h1gst, "#color[9]{hit-MC calc.}", ""); len->SetMarkerSize(1.5); } else { cout << hname << " not found" << endl; } can->cd(12); hname = "hResY04ExpMC"; h2 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h2) { gPad->SetLogz(); h2->Draw("colz"); h2->ProfileX()->Draw("sameE1"); can->cd(15); h1 = h2->ProjectionY(Form("%s_py", hname.Data()), 1, h2->GetNbinsX()); gPad->SetLogy(); h1->Draw(); h1->Fit("gaus", "Q"); gPad->Update(); TPaveStats* stats = dynamic_cast(h1->FindObject("stats")); stats->SetOptFit(10001); gPad->Modified(); TH1* h1hs = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigma", hname.Data()))); if(h1hs) { delete h1hs; } h1hs = new TH1F(Form("%sHistSigma", hname.Data()), Form("; %s; #color[602]{hist}/#color[2]{gaus} sigma [cm]", h2->GetXaxis()->GetTitle()), h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1hst = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaTheory", TString(hname.Data(), 7).Data()))); TH1* h1gs = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigma", hname.Data()))); if(h1gs) { delete h1gs; } h1gs = new TH1F(Form("%sGausSigma", hname.Data()), ";;", h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1gst = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaTheory", TString(hname.Data(), 7).Data()))); for(Int_t iBin = 1; iBin <= h2->GetNbinsX(); iBin++) { h1 = h2->ProjectionY(Form("%s_py%d", hname.Data(), iBin), iBin, iBin); h1hs->SetBinContent(iBin, h1->GetStdDev(1)); h1hs->SetBinError(iBin, h1->GetStdDevError(1)); if(h1hst) { Double_t dBinContent = TMath::Power(h1hst->GetBinContent(iBin), 2.) - TMath::Power(h1hs->GetBinContent(iBin), 2.); if(0. < dBinContent) { Double_t dBinError = TMath::Sqrt((TMath::Power(h1hst->GetBinContent(iBin)*h1hst->GetBinError(iBin), 2.) + TMath::Power(h1hs->GetBinContent(iBin)*h1hs->GetBinError(iBin), 2.))/dBinContent); h1hst->SetBinContent(iBin, TMath::Sqrt(dBinContent)); h1hst->SetBinError(iBin, dBinError); } else { h1hst->SetBinContent(iBin, 0.); h1hst->SetBinError(iBin, 0.); } } if(h1->GetEntries()) { if(0 == static_cast(h1->Fit("gaus", "Q0"))) { h1gs->SetBinContent(iBin, (h1->GetFunction("gaus"))->GetParameter("Sigma")); h1gs->SetBinError(iBin, (h1->GetFunction("gaus"))->GetParError(2)); if(h1gst) { Double_t dBinContent = TMath::Power(h1gst->GetBinContent(iBin), 2.) - TMath::Power(h1gs->GetBinContent(iBin), 2.); if(0. < dBinContent) { Double_t dBinError = TMath::Sqrt((TMath::Power(h1gst->GetBinContent(iBin)*h1gst->GetBinError(iBin), 2.) + TMath::Power(h1gs->GetBinContent(iBin)*h1gs->GetBinError(iBin), 2.))/dBinContent); h1gst->SetBinContent(iBin, TMath::Sqrt(dBinContent)); h1gst->SetBinError(iBin, dBinError); } else { h1gst->SetBinContent(iBin, 0.); h1gst->SetBinError(iBin, 0.); } } } } delete h1; } can->cd(28); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaLegend", TString(hname.Data(), 7).Data()))); h1hs->SetStats(0); h1hs->Draw("PE1same"); h1hs->SetLineColor(3); h1hst->SetStats(0); h1hst->Draw("PE1same"); h1hst->SetLineColor(9); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1hs, "#color[3]{exp-MC}", ""); len->SetMarkerSize(1.5); len = leg->AddEntry(h1hst, "#color[9]{hit-MC calc.}", ""); len->SetMarkerSize(1.5); can->cd(31); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaLegend", TString(hname.Data(), 7).Data()))); h1gs->SetStats(0); h1gs->Draw("PE1same"); h1gs->SetLineColor(3); h1gst->SetStats(0); h1gst->Draw("PE1same"); h1gst->SetLineColor(9); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1gs, "#color[3]{exp-MC}", ""); len->SetMarkerSize(1.5); len = leg->AddEntry(h1gst, "#color[9]{hit-MC calc.}", ""); len->SetMarkerSize(1.5); } else { cout << hname << " not found" << endl; } can->cd(13); hname = "hResT04ExpMC"; h2 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h2) { gPad->SetLogz(); h2->Draw("colz"); h2->ProfileX()->Draw("sameE1"); can->cd(16); h1 = h2->ProjectionY(Form("%s_py", hname.Data()), 1, h2->GetNbinsX()); gPad->SetLogy(); h1->Draw(); h1->Fit("gaus", "Q"); gPad->Update(); TPaveStats* stats = dynamic_cast(h1->FindObject("stats")); stats->SetOptFit(10001); gPad->Modified(); TH1* h1hs = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigma", hname.Data()))); if(h1hs) { delete h1hs; } h1hs = new TH1F(Form("%sHistSigma", hname.Data()), Form("; %s; #color[602]{hist}/#color[2]{gaus} sigma [ns]", h2->GetXaxis()->GetTitle()), h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1hst = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaTheory", TString(hname.Data(), 7).Data()))); TH1* h1gs = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigma", hname.Data()))); if(h1gs) { delete h1gs; } h1gs = new TH1F(Form("%sGausSigma", hname.Data()), ";;", h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1gst = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaTheory", TString(hname.Data(), 7).Data()))); for(Int_t iBin = 1; iBin <= h2->GetNbinsX(); iBin++) { h1 = h2->ProjectionY(Form("%s_py%d", hname.Data(), iBin), iBin, iBin); h1hs->SetBinContent(iBin, h1->GetStdDev(1)); h1hs->SetBinError(iBin, h1->GetStdDevError(1)); if(h1hst) { Double_t dBinContent = TMath::Power(h1hst->GetBinContent(iBin), 2.) - TMath::Power(h1hs->GetBinContent(iBin), 2.); if(0. < dBinContent) { Double_t dBinError = TMath::Sqrt((TMath::Power(h1hst->GetBinContent(iBin)*h1hst->GetBinError(iBin), 2.) + TMath::Power(h1hs->GetBinContent(iBin)*h1hs->GetBinError(iBin), 2.))/dBinContent); h1hst->SetBinContent(iBin, TMath::Sqrt(dBinContent)); h1hst->SetBinError(iBin, dBinError); } else { h1hst->SetBinContent(iBin, 0.); h1hst->SetBinError(iBin, 0.); } } if(h1->GetEntries()) { if(0 == static_cast(h1->Fit("gaus", "Q0"))) { h1gs->SetBinContent(iBin, (h1->GetFunction("gaus"))->GetParameter("Sigma")); h1gs->SetBinError(iBin, (h1->GetFunction("gaus"))->GetParError(2)); if(h1gst) { Double_t dBinContent = TMath::Power(h1gst->GetBinContent(iBin), 2.) - TMath::Power(h1gs->GetBinContent(iBin), 2.); if(0. < dBinContent) { Double_t dBinError = TMath::Sqrt((TMath::Power(h1gst->GetBinContent(iBin)*h1gst->GetBinError(iBin), 2.) + TMath::Power(h1gs->GetBinContent(iBin)*h1gs->GetBinError(iBin), 2.))/dBinContent); h1gst->SetBinContent(iBin, TMath::Sqrt(dBinContent)); h1gst->SetBinError(iBin, dBinError); } else { h1gst->SetBinContent(iBin, 0.); h1gst->SetBinError(iBin, 0.); } } } } delete h1; } can->cd(29); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaLegend", TString(hname.Data(), 7).Data()))); h1hs->SetStats(0); h1hs->Draw("PE1same"); h1hs->SetLineColor(3); h1hst->SetStats(0); h1hst->Draw("PE1same"); h1hst->SetLineColor(9); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1hs, "#color[3]{exp-MC}", ""); len->SetMarkerSize(1.5); len = leg->AddEntry(h1hst, "#color[9]{hit-MC calc.}", ""); len->SetMarkerSize(1.5); can->cd(32); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaLegend", TString(hname.Data(), 7).Data()))); h1gs->SetStats(0); h1gs->Draw("PE1same"); h1gs->SetLineColor(3); h1gst->SetStats(0); h1gst->Draw("PE1same"); h1gst->SetLineColor(9); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1gs, "#color[3]{exp-MC}", ""); len->SetMarkerSize(1.5); len = leg->AddEntry(h1gst, "#color[9]{hit-MC calc.}", ""); len->SetMarkerSize(1.5); } else { cout << hname << " not found" << endl; } can->cd(19); hname = "hResX04HitMC"; h2 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h2) { gPad->SetLogz(); h2->Draw("colz"); h2->ProfileX()->Draw("sameE1"); can->cd(22); h1 = h2->ProjectionY(Form("%s_py", hname.Data()), 1, h2->GetNbinsX()); gPad->SetLogy(); h1->Draw(); h1->Fit("gaus", "Q"); gPad->Update(); TPaveStats* stats = dynamic_cast(h1->FindObject("stats")); stats->SetOptFit(10001); gPad->Modified(); TH1* h1hs = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigma", hname.Data()))); if(h1hs) { delete h1hs; } h1hs = new TH1F(Form("%sHistSigma", hname.Data()), Form("; %s; #color[602]{hist}/#color[2]{gaus} sigma [cm]", h2->GetXaxis()->GetTitle()), h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1gs = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigma", hname.Data()))); if(h1gs) { delete h1gs; } h1gs = new TH1F(Form("%sGausSigma", hname.Data()), ";;", h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); for(Int_t iBin = 1; iBin <= h2->GetNbinsX(); iBin++) { h1 = h2->ProjectionY(Form("%s_py%d", hname.Data(), iBin), iBin, iBin); h1hs->SetBinContent(iBin, h1->GetStdDev(1)); h1hs->SetBinError(iBin, h1->GetStdDevError(1)); if(h1->GetEntries()) { if(0 == static_cast(h1->Fit("gaus", "Q0"))) { h1gs->SetBinContent(iBin, (h1->GetFunction("gaus"))->GetParameter("Sigma")); h1gs->SetBinError(iBin, (h1->GetFunction("gaus"))->GetParError(2)); } } delete h1; } can->cd(27); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaLegend", TString(hname.Data(), 7).Data()))); h1hs->SetStats(0); h1hs->Draw("PE1same"); h1hs->SetLineColor(4); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1hs, "#color[4]{hit-MC}", ""); len->SetMarkerSize(1.5); leg->Draw(); can->cd(30); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaLegend", TString(hname.Data(), 7).Data()))); h1gs->SetStats(0); h1gs->Draw("PE1same"); h1gs->SetLineColor(4); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1gs, "#color[4]{hit-MC}", ""); len->SetMarkerSize(1.5); leg->Draw(); } else { cout << hname << " not found" << endl; } can->cd(20); hname = "hResY04HitMC"; h2 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h2) { gPad->SetLogz(); h2->Draw("colz"); h2->ProfileX()->Draw("sameE1"); can->cd(23); h1 = h2->ProjectionY(Form("%s_py", hname.Data()), 1, h2->GetNbinsX()); gPad->SetLogy(); h1->Draw(); h1->Fit("gaus", "Q"); gPad->Update(); TPaveStats* stats = dynamic_cast(h1->FindObject("stats")); stats->SetOptFit(10001); gPad->Modified(); TH1* h1hs = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigma", hname.Data()))); if(h1hs) { delete h1hs; } h1hs = new TH1F(Form("%sHistSigma", hname.Data()), Form("; %s; #color[602]{hist}/#color[2]{gaus} sigma [cm]", h2->GetXaxis()->GetTitle()), h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1gs = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigma", hname.Data()))); if(h1gs) { delete h1gs; } h1gs = new TH1F(Form("%sGausSigma", hname.Data()), ";;", h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); for(Int_t iBin = 1; iBin <= h2->GetNbinsX(); iBin++) { h1 = h2->ProjectionY(Form("%s_py%d", hname.Data(), iBin), iBin, iBin); h1hs->SetBinContent(iBin, h1->GetStdDev(1)); h1hs->SetBinError(iBin, h1->GetStdDevError(1)); if(h1->GetEntries()) { if(0 == static_cast(h1->Fit("gaus", "Q0"))) { h1gs->SetBinContent(iBin, (h1->GetFunction("gaus"))->GetParameter("Sigma")); h1gs->SetBinError(iBin, (h1->GetFunction("gaus"))->GetParError(2)); } } delete h1; } can->cd(28); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaLegend", TString(hname.Data(), 7).Data()))); h1hs->SetStats(0); h1hs->Draw("PE1same"); h1hs->SetLineColor(4); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1hs, "#color[4]{hit-MC}", ""); len->SetMarkerSize(1.5); leg->Draw(); can->cd(31); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaLegend", TString(hname.Data(), 7).Data()))); h1gs->SetStats(0); h1gs->Draw("PE1same"); h1gs->SetLineColor(4); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1gs, "#color[4]{hit-MC}", ""); len->SetMarkerSize(1.5); leg->Draw(); } else { cout << hname << " not found" << endl; } can->cd(21); hname = "hResT04HitMC"; h2 = dynamic_cast(gROOT->FindObjectAny(hname)); if(h2) { gPad->SetLogz(); h2->Draw("colz"); h2->ProfileX()->Draw("sameE1"); can->cd(24); h1 = h2->ProjectionY(Form("%s_py", hname.Data()), 1, h2->GetNbinsX()); gPad->SetLogy(); h1->Draw(); h1->Fit("gaus", "Q"); gPad->Update(); TPaveStats* stats = dynamic_cast(h1->FindObject("stats")); stats->SetOptFit(10001); gPad->Modified(); TH1* h1hs = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigma", hname.Data()))); if(h1hs) { delete h1hs; } h1hs = new TH1F(Form("%sHistSigma", hname.Data()), Form("; %s; #color[602]{hist}/#color[2]{gaus} sigma [ns]", h2->GetXaxis()->GetTitle()), h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); TH1* h1gs = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigma", hname.Data()))); if(h1gs) { delete h1gs; } h1gs = new TH1F(Form("%sGausSigma", hname.Data()), ";;", h2->GetNbinsX(), h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax()); for(Int_t iBin = 1; iBin <= h2->GetNbinsX(); iBin++) { h1 = h2->ProjectionY(Form("%s_py%d", hname.Data(), iBin), iBin, iBin); h1hs->SetBinContent(iBin, h1->GetStdDev(1)); h1hs->SetBinError(iBin, h1->GetStdDevError(1)); if(h1->GetEntries()) { if(0 == static_cast(h1->Fit("gaus", "Q0"))) { h1gs->SetBinContent(iBin, (h1->GetFunction("gaus"))->GetParameter("Sigma")); h1gs->SetBinError(iBin, (h1->GetFunction("gaus"))->GetParError(2)); } } delete h1; } can->cd(29); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sHistSigmaLegend", TString(hname.Data(), 7).Data()))); h1hs->SetStats(0); h1hs->Draw("PE1same"); h1hs->SetLineColor(4); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1hs, "#color[4]{hit-MC}", ""); len->SetMarkerSize(1.5); leg->Draw(); can->cd(32); leg = dynamic_cast(gROOT->FindObjectAny(Form("%sGausSigmaLegend", TString(hname.Data(), 7).Data()))); h1gs->SetStats(0); h1gs->Draw("PE1same"); h1gs->SetLineColor(4); gPad->Update(); gPad->Modified(); len = leg->AddEntry(h1gs, "#color[4]{hit-MC}", ""); len->SetMarkerSize(1.5); leg->Draw(); } else { cout << hname << " not found" << endl; } can->SaveAs("pl_over_MCHitSel.pdf"); }