92 TFile *
f =
new TFile(
"/sphenix/user/gregtom3/data/Summer2018/DVCS_studies/500k_10x250_sartre_dvcs.root",
"READ");
93 TTree *
t= (TTree*)f->Get(
"event_truth");
154 add_to_array(
"x_Q2",
"/sphenix/user/gregtom3/data/Summer2018/DVCS_studies/png/milou_cuts/10x250_x_Q2_EEMC_plot.png",
"x-Q2 Distribution 10x250 DVCS EEMC (LoI cuts)",ev_standard_cut,l_standard_cut,EEMC,h_standard_cut);
174 std::vector<float>
energy;
175 std::vector<float>
eta;
176 std::vector<float>
pid;
177 std::vector<float>
theta;
178 std::vector<float>
phi;
179 std::vector<float> xvector;
181 std::vector<float>* energy_pointer=&
energy;
182 std::vector<float>* eta_pointer=&
eta;
183 std::vector<float>* pid_pointer=&
pid;
184 std::vector<float>* theta_pointer=&
theta;
185 std::vector<float>* phi_pointer=&
phi;
186 std::vector<float>* xvector_pointer=&xvector;
188 t->SetBranchAddress(
"evtgen_Q2",&Q2);
189 t->SetBranchAddress(
"evtgen_x",&x);
190 t->SetBranchAddress(
"evtgen_y",&y);
191 t->SetBranchAddress(
"evtgen_W",&W);
192 t->SetBranchAddress(
"evtgen_t",&T);
193 t->SetBranchAddress(
"em_evtgen_ptotal",&energy_pointer);
194 t->SetBranchAddress(
"em_evtgen_eta",&eta_pointer);
195 t->SetBranchAddress(
"em_evtgen_pid",&pid_pointer);
196 t->SetBranchAddress(
"em_evtgen_theta",&theta_pointer);
197 t->SetBranchAddress(
"em_evtgen_phi",&phi_pointer);
198 t->SetBranchAddress(
"em_reco_x_e",&xvector_pointer);
222 Int_t nentries = Int_t(t->GetEntries());
224 cout <<
"Warning : Number of Events specified to run is greater than entries in the tree, using all entries" << endl;
227 for(Int_t entryInChain=0; entryInChain<nentries; entryInChain++)
229 if(entryInChain%1000==0)
230 cout <<
"Processing event " << entryInChain <<
" of " << nentries << endl;
231 Int_t entryInTree = t->LoadTree(entryInChain);
232 if (entryInTree < 0)
break;
233 t->GetEntry(entryInChain);
235 for(
unsigned i = 0;
i<energy.size();
i++)
239 gamma_eta = eta.at(
i);
240 gamma_mom = energy.at(
i);
241 gamma_theta = theta.at(
i);
242 gamma_phi = phi.at(
i);
246 lepton_eta = eta.at(
i);
247 lepton_mom = energy.at(
i);
248 lepton_theta = theta.at(
i);
249 lepton_phi = phi.at(
i);
254 hadron_eta = eta.at(
i);
255 hadron_mom = energy.at(
i);
256 hadron_theta = theta.at(
i);
257 hadron_phi = phi.at(
i);
276 char *histTitle =
h2array[
n]->GetName();
277 float sep = angle_separation;
279 bool passed_Q2 = (Q2 >= myCut.
min_Q2 && Q2<= myCut.
max_Q2);
280 bool passed_y = (y >= myCut.
min_y && y <= myCut.
max_y);
281 bool passed_t = (T >= myCut.
min_t && T <= myCut.
max_t);
283 bool ev_passed = passed_Q2 && passed_y && passed_t && passed_separation;
285 bool passed_lepton_eta = (lepton_eta >= lCut.
min_eta && lepton_eta <= lCut.
max_eta);
286 bool passed_lepton_mom = (lepton_mom >= lCut.
min_mom && lepton_mom <= lCut.
max_mom);
287 bool passed_lepton_theta = (lepton_theta >= lCut.
min_theta && lepton_theta <= lCut.
max_theta);
288 bool lepton_passed = passed_lepton_eta && passed_lepton_mom && passed_lepton_theta;
290 bool passed_gamma_eta = (gamma_eta >= gCut.
min_eta && gamma_eta <= gCut.
max_eta);
291 bool passed_gamma_mom = (gamma_mom >= gCut.
min_mom && gamma_mom <= gCut.
max_mom);
292 bool passed_gamma_theta = (gamma_theta >= gCut.
min_theta && gamma_theta <= gCut.
max_theta);
293 bool gamma_passed = passed_gamma_eta && passed_gamma_mom && passed_gamma_theta;
295 bool passed_hadron_eta = (hadron_eta >= hCut.
min_eta && hadron_eta <= hCut.
max_eta);
296 bool passed_hadron_mom = (hadron_mom >= hCut.
min_mom && hadron_mom <= hCut.
max_mom);
297 bool passed_hadron_theta = (hadron_theta >= hCut.
min_theta && hadron_theta <= hCut.
max_theta);
298 bool hadron_passed = passed_hadron_eta && passed_hadron_mom && passed_hadron_theta;
300 bool passed = ev_passed && lepton_passed && gamma_passed && hadron_passed;
303 if(strcmp(histTitle,
"x_Q2")==0)
307 else if(strcmp(histTitle,
"lepton_mom_eta")==0)
309 h2array[
n]->Fill(lepton_eta,lepton_mom);
311 else if(strcmp(histTitle,
"gamma_mom_eta")==0)
313 h2array[
n]->Fill(gamma_eta,gamma_mom);
315 else if(strcmp(histTitle,
"hadron_mom_eta")==0)
317 h2array[
n]->Fill(hadron_eta,hadron_mom);
319 else if(strcmp(histTitle,
"scatter")==0)
323 else if(strcmp(histTitle,
"angle_separation")==0)
325 h2array[
n]->Fill(lepton_theta,angle_separation);
327 else if(strcmp(histTitle,
"nils_plot")==0)
329 float eta_diff = lepton_eta-gamma_eta;
330 float phi_diff = lepton_phi-gamma_phi;
331 if(eta_diff<0) eta_diff=-eta_diff;
332 if(phi_diff<0) phi_diff=-phi_diff;
333 h2array[
n]->Fill(eta_diff,phi_diff*180/3.14159265);
337 cout <<
"Error: Histogram type '"<< histTitle <<
"' not found. Please use one of the specified types" << endl;
357 float photon_x = cos(g_phi)*sin(g_theta);
358 float photon_y = sin(g_phi)*sin(g_theta);
359 float photon_z = cos(g_theta);
361 float electron_x = cos(e_phi)*sin(e_theta);
362 float electron_y = sin(e_phi)*sin(e_theta);
363 float electron_z = cos(e_theta);
365 float dot_prod = photon_x*electron_x+photon_y*electron_y+photon_z*electron_z;
369 else if(dot_prod<=-1)
372 return acos(dot_prod);
377 TCanvas *cPNG =
new TCanvas(saveTitle,
"",700,500);
378 TImage *img = TImage::Create();
379 gStyle->SetOptStat(0);
380 if(strcmp(h->GetName(),
"x_Q2")==0)
384 h->GetXaxis()->SetTitle(
"x");
385 h->GetYaxis()->SetTitle(
"Q2 [GeV^{2}]");
387 else if(strcmp(h->GetName(),
"gamma_mom_eta")==0)
389 h->GetXaxis()->SetTitle(
"Photon #eta");
390 h->GetYaxis()->SetTitle(
"Photon Momentum [GeV]");
393 else if(strcmp(h->GetName(),
"lepton_mom_eta")==0)
395 h->GetXaxis()->SetTitle(
"Electron #eta");
396 h->GetYaxis()->SetTitle(
"Electron Momentum [GeV]");
399 else if(strcmp(h->GetName(),
"hadron_mom_eta")==0)
401 h->GetXaxis()->SetTitle(
"Proton #eta");
402 h->GetYaxis()->SetTitle(
"Proton Momentum [GeV]");
405 else if(strcmp(h->GetName(),
"scatter")==0)
407 h->GetXaxis()->SetTitle(
"|t| [GeV^2]");
408 h->GetYaxis()->SetTitle(
"Proton Scatter Angle [rad]");
410 else if(strcmp(h->GetName(),
"angle_separation")==0)
412 h->GetXaxis()->SetTitle(
"Electron #theta");
413 h->GetYaxis()->SetTitle(
"Electron Photon Angle Separation [rad]");
415 else if(strcmp(h->GetName(),
"nils_plot")==0)
417 h->GetXaxis()->SetTitle(
"Electron Photon Eta Separation");
418 h->GetYaxis()->SetTitle(
"Electron Photon Phi Separation [deg]");
422 img->WriteImage(saveTitle);
435 cout <<
"Warning: Set 'arraySize' to a value which matches the number of histograms you wish to plot" << endl;
436 cout <<
"Not plotting Plot Index " <<
index << endl;
442 if(strcmp(type,
"x_Q2")==0)
447 else if(strcmp(type,
"lepton_mom_eta")==0)
451 else if(strcmp(type,
"gamma_mom_eta")==0)
455 else if(strcmp(type,
"hadron_mom_eta")==0)
459 else if(strcmp(type,
"scatter")==0)
463 else if(strcmp(type,
"angle_separation")==0)
467 else if(strcmp(type,
"nils_plot")==0)
472 ev_cutarray[
index] = ev_c;
473 l_cutarray[
index] = l_c;
474 g_cutarray[
index] = g_c;
475 h_cutarray[
index] = h_c;
478 theH->SetTitle(title);
485 TAxis *axis = h->GetXaxis();
486 int bins = axis->GetNbins();
488 Axis_t from = axis->GetXmin();
489 Axis_t to = axis->GetXmax();
490 Axis_t
width = (to - from) / bins;
491 Axis_t *new_bins =
new Axis_t[bins + 1];
493 for (
int i = 0;
i <=
bins;
i++) {
494 new_bins[
i] = TMath::Power(10, from +
i * width);
496 axis->Set(bins, new_bins);
498 TAxis *axis2 = h->GetYaxis();
499 int bins2 = axis2->GetNbins();
501 Axis_t from2 = axis2->GetXmin();
502 Axis_t to2 = axis2->GetXmax();
503 Axis_t width2 = (to2 - from2) / bins2;
504 Axis_t *new_bins2 =
new Axis_t[bins2 + 1];
506 for (
int i = 0;
i <= bins2;
i++) {
507 new_bins2[
i] = TMath::Power(10, from2 +
i * width2);
509 axis2->Set(bins2, new_bins2);