File indexing completed on 2025-08-06 08:12:52
0001
0002
0003
0004
0005 TFile *f_1 = new TFile("/sphenix/user/gregtom3/data/Summer2018/ExclusiveReco_studies/latest_run/10x100_1M_dvmp.root","READ");
0006
0007
0008
0009
0010 TTree *t_1_exclusive = (TTree*)f_1->Get("event_exclusive");
0011 TTree *t_1_reco = (TTree*)f_1->Get("event_reco");
0012 TTree *t_1_truth = (TTree*)f_1->Get("event_truth");
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 int jpsi_invariant_mass_plot_exclusiveReco()
0027 {
0028
0029
0030
0031
0032 gROOT->LoadMacro("/sphenix/user/gregtom3/SBU/research/macros/macros/sPHENIXStyle/sPhenixStyle.C");
0033 SetsPhenixStyle();
0034
0035
0036
0037 TH1F * h1_inv_mass_base = new TH1F("","",100,0,10);
0038
0039
0040
0041 TH1F * h1_inv_mass_10x100_123456 = (TH1F*)h1_inv_mass_base->Clone();
0042 TH1F * h1_inv_mass_10x100_1 = (TH1F*)h1_inv_mass_base->Clone();
0043 TH1F * h1_inv_mass_10x100_2 = (TH1F*)h1_inv_mass_base->Clone();
0044 TH1F * h1_inv_mass_10x100_3 = (TH1F*)h1_inv_mass_base->Clone();
0045 TH1F * h1_inv_mass_10x100_4 = (TH1F*)h1_inv_mass_base->Clone();
0046 TH1F * h1_inv_mass_10x100_5 = (TH1F*)h1_inv_mass_base->Clone();
0047 TH1F * h1_inv_mass_10x100_6 = (TH1F*)h1_inv_mass_base->Clone();
0048
0049
0050
0051 h1_inv_mass_10x100_123456->GetXaxis()->SetTitle("Invariant Mass [GeV/c^{2}]");
0052 h1_inv_mass_10x100_123456->GetYaxis()->SetTitle("Counts");
0053
0054 h1_inv_mass_10x100_1->GetXaxis()->SetTitle("Invariant Mass [GeV/c^{2}]");
0055 h1_inv_mass_10x100_1->GetYaxis()->SetTitle("Counts");
0056
0057 h1_inv_mass_10x100_2->GetXaxis()->SetTitle("Invariant Mass [GeV/c^{2}]");
0058 h1_inv_mass_10x100_2->GetYaxis()->SetTitle("Counts");
0059
0060 h1_inv_mass_10x100_3->GetXaxis()->SetTitle("Invariant Mass [GeV/c^{2}]");
0061 h1_inv_mass_10x100_3->GetYaxis()->SetTitle("Counts");
0062
0063 h1_inv_mass_10x100_4->GetXaxis()->SetTitle("Invariant Mass [GeV/c^{2}]");
0064 h1_inv_mass_10x100_4->GetYaxis()->SetTitle("Counts");
0065
0066 h1_inv_mass_10x100_5->GetXaxis()->SetTitle("Invariant Mass [GeV/c^{2}]");
0067 h1_inv_mass_10x100_5->GetYaxis()->SetTitle("Counts");
0068
0069 h1_inv_mass_10x100_6->GetXaxis()->SetTitle("Invariant Mass [GeV/c^{2}]");
0070 h1_inv_mass_10x100_6->GetYaxis()->SetTitle("Counts");
0071
0072
0073
0074 std::vector<TString> types;
0075 types.push_back("reco_inv");
0076 types.push_back("true_inv");
0077 types.push_back("reco_inv_decay");
0078 types.push_back("reco_inv_scatter");
0079 types.push_back("true_inv_decay");
0080 types.push_back("true_inv_scatter");
0081
0082 for(unsigned idx_type = 0 ; idx_type < types.size() ; idx_type++)
0083 {
0084
0085
0086 }
0087
0088
0089
0090
0091
0092 fillHist(h1_inv_mass_10x100_1, t_1_exclusive, "reco_inv");
0093 fillHist(h1_inv_mass_10x100_2, t_1_exclusive, "true_inv");
0094 fillHist(h1_inv_mass_10x100_3, t_1_exclusive, "reco_inv_decay");
0095 fillHist(h1_inv_mass_10x100_4, t_1_exclusive, "reco_inv_scatter");
0096 fillHist(h1_inv_mass_10x100_5, t_1_exclusive, "true_inv_decay");
0097 fillHist(h1_inv_mass_10x100_6, t_1_exclusive, "true_inv_scatter");
0098
0099 hist_to_png_special(h1_inv_mass_10x100_1,
0100 h1_inv_mass_10x100_2,
0101 h1_inv_mass_10x100_3,
0102 h1_inv_mass_10x100_4,
0103 h1_inv_mass_10x100_5,
0104 h1_inv_mass_10x100_6, "10x100");
0105
0106 return 0;
0107 }
0108
0109 void fillHist(TH1F * h, TTree *t, TString type_TString)
0110 {
0111 std::vector<float> reco_inv;
0112 std::vector<float> true_inv;
0113 std::vector<float> reco_inv_decay;
0114 std::vector<float> reco_inv_scatter;
0115 std::vector<float> true_inv_decay;
0116 std::vector<float> true_inv_scatter;
0117
0118 std::vector<float>* reco_inv_pointer = &reco_inv;
0119 std::vector<float>* true_inv_pointer = &true_inv;
0120 std::vector<float>* reco_inv_decay_pointer = &reco_inv_decay;
0121 std::vector<float>* reco_inv_scatter_pointer = &reco_inv_scatter;
0122 std::vector<float>* true_inv_decay_pointer = &true_inv_decay;
0123 std::vector<float>* true_inv_scatter_pointer = &true_inv_scatter;
0124
0125 t->SetBranchAddress("reco_inv",&reco_inv_pointer);
0126 t->SetBranchAddress("true_inv",&true_inv_pointer);
0127 t->SetBranchAddress("reco_inv_decay",&reco_inv_decay_pointer);
0128 t->SetBranchAddress("reco_inv_scatter",&reco_inv_scatter_pointer);
0129 t->SetBranchAddress("true_inv_decay",&true_inv_decay_pointer);
0130 t->SetBranchAddress("true_inv_scatter",&true_inv_scatter_pointer);
0131
0132 h->Reset();
0133 Int_t nentries = Int_t(t->GetEntries());
0134 char * type = type_TString.Data();
0135 for(Int_t entryInChain=0; entryInChain<nentries; entryInChain++)
0136 {
0137 Int_t entryInTree = t->LoadTree(entryInChain);
0138 if (entryInTree < 0) break;
0139 t->GetEntry(entryInChain);
0140 if(strcmp(type,"reco_inv")==0)
0141 {
0142 for(unsigned i = 0 ; i<reco_inv.size() ; i++)
0143 h->Fill(reco_inv.at(i));
0144 }
0145 else if(strcmp(type,"true_inv")==0)
0146 {
0147 for(unsigned i = 0 ; i<true_inv.size() ; i++)
0148 h->Fill(true_inv.at(i));
0149 }
0150 else if(strcmp(type,"reco_inv_decay")==0)
0151 {
0152 for(unsigned i = 0 ; i<reco_inv_decay.size() ; i++)
0153 h->Fill(reco_inv_decay.at(i));
0154 }
0155 else if(strcmp(type,"reco_inv_scatter")==0)
0156 {
0157 for(unsigned i = 0 ; i<reco_inv_scatter.size() ; i++)
0158 h->Fill(reco_inv_scatter.at(i));
0159 }
0160 else if(strcmp(type,"true_inv_decay")==0)
0161 {
0162 for(unsigned i = 0 ; i<true_inv_decay.size() ; i++)
0163 h->Fill(true_inv_decay.at(i));
0164 }
0165 else if(strcmp(type,"true_inv_scatter")==0)
0166 {
0167 for(unsigned i = 0 ; i<true_inv_scatter.size() ; i++)
0168 h->Fill(true_inv_scatter.at(i));
0169 }
0170 }
0171 }
0172
0173
0174
0175 void hist_to_png(TH1F * h, TString saveTitle, TString type)
0176 {
0177 saveTitle = type + "_" + saveTitle+".png";
0178 TCanvas *cPNG = new TCanvas(saveTitle,"",700,500);
0179 TImage *img = TImage::Create();
0180
0181 h->Draw();
0182
0183 img->FromPad(cPNG);
0184 img->WriteImage(saveTitle);
0185 delete img;
0186 }
0187
0188 void hist_to_png_special(TH1F * h1, TH1F * h2, TH1F *h3,
0189 TH1F * h4, TH1F * h5, TH1F *h6,
0190 TString type)
0191 {
0192
0193
0194
0195
0196
0197
0198
0199
0200 TCanvas *cPNG_1 = new TCanvas("plot1","",700,500);
0201 TImage *img_1 = TImage::Create();
0202 auto legend_1 = new TLegend(0.6,0.75,0.9,0.9);
0203 h1->SetLineColor(kRed);
0204 h4->SetLineColor(kBlue);
0205 legend_1->SetHeader("Reco Decay Particles");
0206 legend_1->AddEntry(h1,"All e^{-}e^{+}","l");
0207 legend_1->AddEntry(h4,"Background e^{-}e^{+}","l");
0208 h1->Draw();
0209 h4->Draw("SAME");
0210 legend_1->Draw();
0211 gPad->RedrawAxis();
0212 gPad->SetLogy();
0213 img_1->FromPad(cPNG_1);
0214 img_1->WriteImage("plot1__"+type+"_dvmp_reco_inv_full.png");
0215 delete img_1;
0216
0217
0218 TCanvas *cPNG_2 = new TCanvas("plot2","",700,500);
0219 TImage *img_2 = TImage::Create();
0220 h2->SetLineColor(kRed);
0221 h6->SetLineColor(kBlue);
0222 auto legend_2 = new TLegend(0.6,0.75,0.9,0.9);
0223 legend_2->SetHeader("True Decay Particles");
0224 legend_2->AddEntry(h2,"All e^{-}e^{+}","l");
0225 legend_2->AddEntry(h6,"Background e^{-}e^{+}","l");
0226 h2->Draw();
0227 h6->Draw("SAME");
0228 legend_2->Draw();
0229 gPad->RedrawAxis();
0230 gPad->SetLogy();
0231 img_2->FromPad(cPNG_2);
0232 img_2->WriteImage("plot2__"+type+"_dvmp_true_inv_full.png");
0233 delete img_2;
0234
0235
0236 TCanvas *cPNG_3 = new TCanvas("plot3","",1400,500);
0237 TImage *img_3 = TImage::Create();
0238
0239 cPNG_3->Divide(2,1);
0240 cPNG_3->cd(1);
0241 h1->Draw();
0242 h4->Draw("same");
0243 legend_1->Draw();
0244 gPad->RedrawAxis();
0245 gPad->SetLogy();
0246
0247 cPNG_3->cd(2);
0248 h2->Draw();
0249 h6->Draw("same");
0250 legend_2->Draw();
0251 gPad->RedrawAxis();
0252 gPad->SetLogy();
0253
0254 img_3->FromPad(cPNG_3);
0255 img_3->WriteImage("plot3__"+type+"_dvmp_inv_full.png");
0256 delete img_3;
0257 }