Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-05-23 08:12:14

0001 #include "analysisHelper.h"
0002 #include "RooUnfoldResponse.h"
0003 
0004 static const int kColA    = kRed   + 1;
0005 static const int kColB = kBlue  + 1;
0006 static const int kMarA    = 21;
0007 static const int kMarB = 20;
0008 
0009 void setMarkers(TH1D *h, bool A)
0010 {
0011     if(A)
0012     {
0013         h->SetMarkerColor(kColA);
0014         h->SetLineColor(kColA);
0015         h->SetMarkerStyle(kMarA);
0016         return;
0017     }
0018 
0019     h->SetMarkerColor(kColB);
0020     h->SetLineColor(kColB);
0021     h->SetMarkerStyle(kMarB);
0022     return;
0023 }
0024 
0025 
0026 void draw_AB_comp(const char* outDir = ".")
0027 {
0028     TFile *respFile = new TFile(std::format("{}/response-all-halfClosure.root",outDir).c_str(),"READ");
0029     if(!respFile)
0030     {
0031         std::cerr << "No half closure file in directory " << outDir << ". Try a different directory" << std::endl;
0032         return;
0033     }
0034 
0035     TCanvas *c2 = new TCanvas("c2","",2*957,957);
0036     gStyle->SetOptStat(0);
0037     c2->SaveAs(std::format("{}/Plots/AB_comp_all.pdf[",outDir).c_str());
0038 
0039     for(int k=0; k<nDphi; k++)
0040     {
0041         std::cout << "working on dPhi bin " << k << std::endl;
0042 
0043         c2->Clear();
0044         c2->Divide(2,1);
0045 
0046         TCanvas *c1 = new TCanvas("c1","",2*957,957);
0047         c1->Divide(2,1);
0048         
0049         RooUnfoldResponse *resp = (RooUnfoldResponse*)respFile->Get(std::format("response_wEEC3D_{}",k).c_str());
0050         TH1D *hTruthA = (TH1D*)resp->Htruth();
0051         setMarkers(hTruthA, true);
0052         TH1D *hTruthB = (TH1D*)respFile->Get(std::format("hWEEC3D_meas_truth_{}",k).c_str());
0053         setMarkers(hTruthB, false);
0054         hTruthB->SetTitle(std::format("Truth AB Comparison #Delta#phi bin {}",k).c_str());
0055 
0056         TH1D *hRecoA = (TH1D*)resp->Hmeasured();
0057         setMarkers(hRecoA, true);
0058         TH1D *hRecoB = (TH1D*)respFile->Get(std::format("hWEEC3D_meas_{}",k).c_str());
0059         setMarkers(hRecoB, false);
0060         hRecoB->SetTitle(std::format("Reco AB Comparison #Delta#phi bin {}",k).c_str());
0061 
0062         std::cout << "got all hists" << std::endl;
0063 
0064         c1->cd(1);
0065         c1->cd(1)->SetLogy();
0066 
0067         TRatioPlot *rpTruth = new TRatioPlot(hTruthB, hTruthA, "divsym");
0068         rpTruth->SetH1DrawOpt("P");
0069         rpTruth->SetH2DrawOpt("P");
0070 
0071         rpTruth->Draw();
0072         
0073         rpTruth->GetLowerPad()->SetLogy();
0074         rpTruth->GetLowerRefYaxis()->SetTitle("\"Data\" / Matrix");
0075 
0076         rpTruth->GetUpperPad()->cd();
0077         TLegend *leg = new TLegend(0.65,0.7,0.85,0.85);
0078         leg->AddEntry(hTruthA,"Matrix Half","P");
0079         leg->AddEntry(hTruthB,"\"Data\" Half","P");
0080         leg->Draw();
0081 
0082         c1->cd(2);
0083         c1->cd(2)->SetLogy();
0084 
0085         TRatioPlot *rpReco = new TRatioPlot(hRecoB, hRecoA, "divsym");
0086         rpReco->SetH1DrawOpt("P");
0087         rpReco->SetH2DrawOpt("P");
0088 
0089         rpReco->Draw();
0090 
0091         rpReco->GetLowerPad()->SetLogy();
0092         rpReco->GetLowerRefYaxis()->SetTitle("\"Data\" / Matrix");
0093         rpReco->Draw();
0094 
0095         rpReco->GetUpperPad()->cd();
0096         leg->Draw();
0097 
0098         c1->SaveAs(std::format("{}/Plots/AB_comp_{}.png",outDir,k).c_str());
0099 
0100         c2->cd(1);
0101         c2->cd(1)->SetLogy();
0102 
0103         rpTruth->Draw();
0104         rpTruth->GetUpperPad()->cd();
0105         leg->Draw();
0106 
0107         c2->cd(2);
0108         c2->cd(2)->SetLogy();
0109 
0110         rpReco->Draw();
0111         rpReco->GetUpperPad()->cd();
0112         leg->Draw();
0113 
0114         c2->SaveAs(std::format("{}/Plots/AB_comp_all.pdf",outDir,k).c_str());
0115 
0116         std::cout << "done with dPhi bin " << k << std::endl;
0117     
0118         delete c1;
0119         delete hTruthA; delete hTruthB;
0120         delete resp; delete hRecoA; delete hRecoB;
0121         delete rpTruth; //delete rpReco;
0122         delete leg;
0123     }
0124     
0125     c2->SaveAs(std::format("{}/Plots/AB_comp_all.pdf]",outDir).c_str());
0126 
0127 }