5 TFile *
f_1 =
new TFile(
"/sphenix/user/gregtom3/data/Summer2018/ExclusiveReco_studies/latest_run/10x100_1M_dvmp.root",
"READ");
17 gROOT->SetBatch(kTRUE);
21 const int nbins = 100;
22 TH2F * h2_eta_phi_em_base =
new TH2F(
"",
"",nbins,-4,4,nbins,-3.5,3.5);
23 TH2F * h2_eta_phi_pr_base =
new TH2F(
"",
"",nbins,-20,20,nbins,-3.5,3.5);
24 TH2F * h2_mom_eta_em_base =
new TH2F(
"",
"",nbins,-4,4,nbins,0,20);
25 TH2F * h2_mom_eta_pr_base =
new TH2F(
"",
"",nbins,-20,20,nbins,0,150);
26 TH2F * h2_distance =
new TH2F(
"",
"",nbins,-20,20,nbins,0,150);
30 h2_eta_phi_em_base->GetXaxis()->SetTitle(
"#eta");
31 h2_eta_phi_em_base->GetYaxis()->SetTitle(
"#phi");
32 h2_eta_phi_pr_base->GetXaxis()->SetTitle(
"#eta");
33 h2_eta_phi_pr_base->GetYaxis()->SetTitle(
"#phi");
35 h2_mom_eta_em_base->GetXaxis()->SetTitle(
"#eta");
36 h2_mom_eta_em_base->GetYaxis()->SetTitle(
"Momentum [GeV]");
37 h2_mom_eta_pr_base->GetXaxis()->SetTitle(
"#eta");
38 h2_mom_eta_pr_base->GetYaxis()->SetTitle(
"Momentum [GeV]");
42 std::vector<TString> types_eta_phi_em_reco;
43 std::vector<TString> types_eta_phi_em_true;
44 std::vector<TString> types_eta_phi_pr;
45 std::vector<TString> types_mom_eta_em_reco;
46 std::vector<TString> types_mom_eta_em_true;
47 std::vector<TString> types_mom_eta_pr;
48 types_eta_phi_em_reco.push_back(
"reco_decay_positron_eta_phi");
49 types_eta_phi_em_reco.push_back(
"reco_decay_electron_eta_phi");
50 types_eta_phi_em_reco.push_back(
"reco_scattered_electron_eta_phi");
51 types_mom_eta_em_reco.push_back(
"reco_decay_positron_mom_eta");
52 types_mom_eta_em_reco.push_back(
"reco_decay_electron_mom_eta");
53 types_mom_eta_em_reco.push_back(
"reco_scattered_electron_mom_eta");
54 types_eta_phi_em_true.push_back(
"true_decay_positron_eta_phi");
55 types_eta_phi_em_true.push_back(
"true_decay_electron_eta_phi");
56 types_eta_phi_em_true.push_back(
"true_scattered_electron_eta_phi");
57 types_eta_phi_pr.push_back(
"true_scattered_proton_eta_phi");
58 types_mom_eta_em_true.push_back(
"true_decay_positron_mom_eta");
59 types_mom_eta_em_true.push_back(
"true_decay_electron_mom_eta");
60 types_mom_eta_em_true.push_back(
"true_scattered_electron_mom_eta");
61 types_mom_eta_pr.push_back(
"true_scattered_proton_mom_eta");
65 for(
unsigned idx = 0 ;
idx < types_eta_phi_em_reco.size() ;
idx++)
68 hist_to_png(h2_eta_phi_em_base,
"10x100", types_eta_phi_em_reco.at(
idx));
71 for(
unsigned idx = 0 ;
idx < types_eta_phi_em_true.size() ;
idx++)
74 hist_to_png(h2_eta_phi_em_base,
"10x100", types_eta_phi_em_true.at(
idx));
77 for(
unsigned idx = 0 ;
idx < types_eta_phi_pr.size() ;
idx++)
80 hist_to_png(h2_eta_phi_pr_base,
"10x100", types_eta_phi_pr.at(
idx));
83 for(
unsigned idx = 0 ;
idx < types_mom_eta_em_reco.size() ;
idx++)
86 hist_to_png(h2_mom_eta_em_base,
"10x100", types_mom_eta_em_reco.at(
idx));
89 for(
unsigned idx = 0 ;
idx < types_mom_eta_em_true.size() ;
idx++)
92 hist_to_png(h2_mom_eta_em_base,
"10x100", types_mom_eta_em_true.at(
idx));
96 for(
unsigned idx = 0 ;
idx < types_mom_eta_pr.size() ;
idx++)
99 hist_to_png(h2_mom_eta_pr_base,
"10x100", types_mom_eta_pr.at(
idx));
104 void fillHist(TH2F *
h, TTree *t_reco, TTree *t_truth, TString type_TString,
bool reco)
107 std::vector<float> reco_eta;
108 std::vector<float> true_eta;
109 std::vector<float> reco_phi;
110 std::vector<float> true_phi;
111 std::vector<float> reco_ptotal;
112 std::vector<float> true_ptotal;
113 std::vector<int> reco_charge;
114 std::vector<int>
pid;
115 std::vector<bool> reco_is_scattered_lepton;
116 std::vector<bool> is_scattered_lepton;
117 std::vector<float> reco_cluster_e;
120 std::vector<float>* reco_eta_pointer = &reco_eta;
121 std::vector<float>* true_eta_pointer = &true_eta;
122 std::vector<float>* reco_phi_pointer = &reco_phi;
123 std::vector<float>* true_phi_pointer = &true_phi;
124 std::vector<float>* reco_ptotal_pointer = &reco_ptotal;
125 std::vector<float>* true_ptotal_pointer = &true_ptotal;
126 std::vector<int>* reco_charge_pointer = &reco_charge;
127 std::vector<int>* pid_pointer = &
pid;
128 std::vector<bool>* reco_is_scattered_lepton_pointer = &reco_is_scattered_lepton;
129 std::vector<bool>* is_scattered_lepton_pointer = &is_scattered_lepton;
130 std::vector<float>* reco_cluster_e_pointer = &reco_cluster_e;
136 t_reco->SetBranchAddress(
"eta",&reco_eta_pointer);
137 t_reco->SetBranchAddress(
"phi",&reco_phi_pointer);
138 t_reco->SetBranchAddress(
"ptotal",&reco_ptotal_pointer);
139 t_reco->SetBranchAddress(
"charge",&reco_charge_pointer);
140 t_reco->SetBranchAddress(
"is_scattered_lepton",&reco_is_scattered_lepton_pointer);
141 t_reco->SetBranchAddress(
"cluster_e",&reco_cluster_e_pointer);
143 t_truth->SetBranchAddress(
"geta",&true_eta_pointer);
144 t_truth->SetBranchAddress(
"gphi",&true_phi_pointer);
145 t_truth->SetBranchAddress(
"gptotal",&true_ptotal_pointer);
146 t_truth->SetBranchAddress(
"pid",&pid_pointer);
147 t_truth->SetBranchAddress(
"is_scattered_lepton",&is_scattered_lepton_pointer);
152 Int_t nentries = Int_t(t_reco->GetEntries());
155 char *
type = type_TString.Data();
158 for(Int_t entryInChain=0; entryInChain<nentries; entryInChain++)
160 Int_t entryInTree = t_reco->LoadTree(entryInChain);
161 if (entryInTree < 0)
break;
162 t_reco->GetEntry(entryInChain);
163 t_truth->GetEntry(entryInChain);
164 if(entryInChain%1000==0)
165 cout <<
"Processing event " << count <<
" of " << nentries << endl;
168 unsigned size_reco = reco_eta.size();
171 for(
unsigned i = 0 ;
i < size_reco ;
i++)
174 bool is_scatter = reco_is_scattered_lepton.at(
i);
175 bool is_decay = !is_scatter;
179 for(
unsigned temp = 0 ; temp < true_eta.size() ; temp++)
181 bool is_true_scatter = is_scattered_lepton.at(temp);
182 float eta_diff = abs(reco_eta.at(
i)-true_eta.at(temp));
183 if(is_true_scatter&&is_scatter&&eta_diff>0.2)
191 for(
unsigned temp = 0 ; temp < true_eta.size() ; temp++)
193 float phi_diff = abs(reco_phi.at(
i)-true_phi.at(temp));
194 float eta_diff = abs(reco_eta.at(
i)-true_eta.at(temp));
195 if(phi_diff<0.5&&eta_diff<0.2&&pid.at(temp)==11)
196 reco_charge.at(
i)==-1;
197 else if(phi_diff<0.5&&eta_diff<0.2&&pid.at(temp)==-11)
198 reco_charge.at(
i)==1;
202 if(reco_eta.at(
i)<-1.434)
203 reco_ptotal.at(
i) = reco_cluster_e.at(
i);
207 if(strcmp(type,
"reco_decay_positron_eta_phi")==0)
209 if(reco_charge.at(
i)==1)
210 h->Fill(reco_eta.at(
i),reco_phi.at(
i));
212 else if(strcmp(type,
"reco_decay_electron_eta_phi")==0)
214 if(reco_charge.at(
i)==-1&&is_decay)
215 h->Fill(reco_eta.at(
i),reco_phi.at(
i));
218 else if(strcmp(type,
"reco_scattered_electron_eta_phi")==0)
220 if(reco_charge.at(
i)==-1&&is_scatter)
221 h->Fill(reco_eta.at(
i),reco_phi.at(
i));
223 else if(strcmp(type,
"reco_decay_positron_mom_eta")==0)
225 if(reco_charge.at(
i)==1)
226 h->Fill(reco_eta.at(
i),reco_ptotal.at(
i));
228 else if(strcmp(type,
"reco_decay_electron_mom_eta")==0)
230 if(reco_charge.at(
i)==-1&&is_decay)
231 h->Fill(reco_eta.at(
i),reco_ptotal.at(
i));
233 else if(strcmp(type,
"reco_scattered_electron_mom_eta")==0)
235 if(reco_charge.at(
i)==-1&&is_scatter)
236 h->Fill(reco_eta.at(
i),reco_ptotal.at(
i));
243 Int_t nentries = Int_t(t_truth->GetEntries());
244 char *
type = type_TString.Data();
245 for(Int_t entryInChain=0; entryInChain<nentries; entryInChain++)
247 Int_t entryInTree = t_truth->LoadTree(entryInChain);
248 if (entryInTree < 0)
break;
249 t_truth->GetEntry(entryInChain);
251 unsigned size_truth = true_eta.size();
253 for(
unsigned i = 0 ;
i < size_truth ;
i++)
256 bool is_scatter = is_scattered_lepton.at(
i);
257 bool is_decay = !is_scatter;
259 if(strcmp(type,
"true_decay_positron_eta_phi")==0)
262 h->Fill(true_eta.at(
i),true_phi.at(
i));
264 else if(strcmp(type,
"true_decay_electron_eta_phi")==0)
266 if(pid.at(
i)==11&&is_decay)
267 h->Fill(true_eta.at(
i),true_phi.at(
i));
269 else if(strcmp(type,
"true_scattered_electron_eta_phi")==0)
271 if(pid.at(
i)==11&&is_scatter)
272 h->Fill(true_eta.at(
i),true_phi.at(
i));
274 else if(strcmp(type,
"true_decay_positron_mom_eta")==0)
276 if(pid.at(
i)==-11&&is_decay)
277 h->Fill(true_eta.at(
i),true_ptotal.at(
i));
279 else if(strcmp(type,
"true_decay_electron_mom_eta")==0)
281 if(pid.at(
i)==11&&is_decay)
282 h->Fill(true_eta.at(
i),true_ptotal.at(
i));
284 else if(strcmp(type,
"true_scattered_electron_mom_eta")==0)
286 if(pid.at(
i)==11&&is_scatter)
287 h->Fill(true_eta.at(
i),true_ptotal.at(
i));
289 else if(strcmp(type,
"true_scattered_proton_mom_eta")==0)
292 h->Fill(true_eta.at(
i),true_ptotal.at(
i));
294 else if(strcmp(type,
"true_scattered_proton_eta_phi")==0)
297 h->Fill(true_eta.at(
i),true_phi.at(
i));
306 saveTitle = type2 +
"_" + saveTitle+
".png";
307 TCanvas *cPNG =
new TCanvas(saveTitle,
"",700,500);
308 TImage *img = TImage::Create();
309 gStyle->SetOptStat(0);
311 char *
type = type2.Data();
313 if(strcmp(type,
"reco_decay_electron_eta_phi")==0)
315 h->SetTitle(
"#eta-#phi space : decay e^{-} reco");
317 else if(strcmp(type,
"reco_decay_positron_eta_phi")==0)
319 h->SetTitle(
"#eta-#phi space : decay e^{+} reco");
321 else if(strcmp(type,
"reco_scattered_electron_eta_phi")==0)
323 h->SetTitle(
"#eta-#phi space : scattered e^{-} reco");
325 else if(strcmp(type,
"reco_decay_electron_mom_eta")==0)
327 h->SetTitle(
"Momentum vs Eta : decay e^{-} reco");
329 else if(strcmp(type,
"reco_decay_positron_mom_eta")==0)
331 h->SetTitle(
"Momentum vs Eta : decay e^{+} reco");
333 else if(strcmp(type,
"reco_scattered_electron_mom_eta")==0)
335 h->SetTitle(
"Momentum vs Eta : scattered e^{-} reco");
337 else if(strcmp(type,
"true_decay_electron_eta_phi")==0)
339 h->SetTitle(
"#eta-#phi space : decay e^{-} truth");
341 else if(strcmp(type,
"true_decay_positron_eta_phi")==0)
343 h->SetTitle(
"#eta-#phi space : decay e^{+} truth");
345 else if(strcmp(type,
"true_scattered_electron_eta_phi")==0)
347 h->SetTitle(
"#eta-#phi space : scattered e^{-} truth");
349 else if(strcmp(type,
"true_decay_electron_mom_eta")==0)
351 h->SetTitle(
"Momentum vs Eta : decay e^{-} truth");
353 else if(strcmp(type,
"true_decay_positron_mom_eta")==0)
355 h->SetTitle(
"Momentum vs Eta : decay e^{+} truth");
357 else if(strcmp(type,
"true_scattered_electron_mom_eta")==0)
359 h->SetTitle(
"Momentum vs Eta : scattered e^{-} truth");
361 else if(strcmp(type,
"true_scattered_proton_mom_eta")==0)
363 h->SetTitle(
"Momentum vs Eta : scattered proton truth");
365 else if(strcmp(type,
"true_scattered_proton_eta_phi")==0)
367 h->SetTitle(
"#eta-#phi space : scattered proton truth");
373 img->WriteImage(saveTitle);