Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Photons.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Photons.C
1 //This is an analysis package designed to collect single photons
2 //They can be embedded or not, and can be in either the central
3 //or forward arms - there are trees for each
4 
5 
6 #include "Photons.h"
7 
9 #include <g4main/PHG4Hit.h>
10 #include <g4main/PHG4Particle.h>
12 #include <phool/PHCompositeNode.h>
13 #include <phool/getClass.h>
14 
15 #include <TLorentzVector.h>
16 #include <g4jets/Jet.h>
17 #include <g4jets/JetMap.h>
18 #include <iostream>
19 
20 #include <calobase/RawCluster.h>
21 #include <calobase/RawClusterContainer.h>
22 #include <calobase/RawClusterUtility.h>
23 #include <calobase/RawTower.h>
24 #include <calobase/RawTowerContainer.h>
25 #include <calobase/RawTowerGeom.h>
26 #include <calobase/RawTowerGeomContainer.h>
28 #include <g4eval/JetEvalStack.h>
29 
30 #include <g4vertex/GlobalVertex.h>
31 #include <g4vertex/GlobalVertexMap.h>
32 
33 #include <g4eval/SvtxEvalStack.h>
34 #include <sstream>
35 
36 #include <HepMC/GenEvent.h>
37 #include <HepMC/GenVertex.h>
39 using namespace std;
40 
41 #include <cassert>
42 #include <iostream>
43 
45  : SubsysReco("PHOTONS")
46 {
47  outfilename = name;
48  //initialize global variables to -999 so that they have a spot in memory
50 
51  //add other initializers here
52 
53 
54  //default central arm
55  _etalow = -1;
56  _etahi = 1;
57 
58  nevents = 0;
59 
60  //default no hijing embedding
61  _embed = 0;
62 }
63 
65 {
66  file = new TFile(outfilename.c_str(), "RECREATE");
67 
68  histo = new TH1F("histo", "histo", 100, -3, 3);
69 
70  tree = new TTree("tree", "a tree");
71  tree->Branch("nevents", &nevents, "nevents/I");
72 
73  //set all the tree branches
75 
76  return 0;
77 }
78 
80 {
81  if (nevents % 10 == 0)
82  cout << "at event number " << nevents << endl;
83 
84 
85 
86  //get the nodes from the NodeTree
87  PHG4TruthInfoContainer *truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topnode, "G4TruthInfo");
88  //Raw clusters
89  RawClusterContainer *clusters = findNode::getClass<RawClusterContainer>(topnode, "CLUSTER_CEMC");
90 
91  //Recalib clusters
92  RawClusterContainer *recal_clusters = findNode::getClass<RawClusterContainer>(topnode, "CLUSTER_POS_COR_CEMC");
93 
94  RawClusterContainer *fclusters = 0;
95  if (_etalow > 1)
96  {
97  fclusters = findNode::getClass<RawClusterContainer>(topnode, "CLUSTER_FEMC");
98  }
99 
100  RawClusterContainer *hcalin_clusters = findNode::getClass<RawClusterContainer>(topnode, "CLUSTER_HCALIN");
101 
102  RawTowerContainer *_towers = findNode::getClass<RawTowerContainer>(topnode, "TOWER_CALIB_CEMC");
103 
104  GlobalVertexMap *vertexmap = findNode::getClass<GlobalVertexMap>(topnode, "GlobalVertexMap");
105  if (!vertexmap)
106  {
107  cout << "Photons::process_event - Fatal Error - GlobalVertexMap node is missing. Please turn on the do_global flag in the main macro in order to reconstruct the global vertex." << endl;
108  assert(vertexmap); // force quit
109 
110  return 0;
111  }
112 
113  if (vertexmap->empty())
114  {
115  cout << "Photons::process_event - Fatal Error - GlobalVertexMap node is empty. Please turn on the do_global flag in the main macro in order to reconstruct the global vertex." << endl;
116  return 0;
117  }
118 
119  GlobalVertex *vtx = vertexmap->begin()->second;
120  if (vtx == nullptr) return 0;
121 
122  if (!recal_clusters)
123  {
124  cout << "no recalibrated cemc clusters, bailing" << endl;
125  return 0;
126  }
127 
128  if (!_towers)
129  {
130  cout << "NO CALIBRATED CEMC TOWERS, BAILING" << endl;
131  return 0;
132  }
133  if (!fclusters && _etalow > 1)
134  {
135  cout << "not forward cluster info" << endl;
136  return 0;
137  }
138  if (!truthinfo)
139  {
140  cout << "no truth track info" << endl;
141  return 0;
142  }
143  if (!clusters)
144  {
145  cout << "no cluster info" << endl;
146  return 0;
147  }
148 
149  if (!hcalin_clusters)
150  {
151  cout << "no hcal in cluster info" << endl;
152  return 0;
153  }
154 
155  if (Verbosity() > 1)
156  {
157  cout << "Getting truth particles" << endl;
158  }
159 
161 
162  for (PHG4TruthInfoContainer::ConstIterator iter = range.first; iter != range.second; ++iter)
163  {
164  PHG4Particle *truth = iter->second;
165 
166  const int this_embed_id = truthinfo->isEmbeded(truth->get_track_id());
167 
168  //check that the truth particle is from the event generator
169  //and not from the hijing background.
170  //if it is from the hijing background this_embed_id == 0
171  if (this_embed_id != 1 && _embed)
172  continue;
173  truthpid = truth->get_pid();
174  truthpx = truth->get_px();
175  truthpy = truth->get_py();
176  truthpz = truth->get_pz();
177  truthp = sqrt(truthpx * truthpx + truthpy * truthpy + truthpz * truthpz);
178  truthenergy = truth->get_e();
179 
180  TLorentzVector vec;
181  vec.SetPxPyPzE(truthpx, truthpy, truthpz, truthenergy);
182 
183  truthpt = sqrt(truthpx * truthpx + truthpy * truthpy);
184 
185  truthphi = vec.Phi();
186  trutheta = vec.Eta();
187 
188  truth_g4particles->Fill();
189  }
190 
191  /***********************************************
192 
193  GET THE HCAL_INNER CLUSTERS
194  (for looking for leakage between emcal towers and/or tunneling)
195  This map not be necessary in the future if we don't have an
196  inner HCal :/
197  ************************************************/
198 
199  RawClusterContainer::ConstRange begin_end_hcal = hcalin_clusters->getClusters();
201 
202  if (Verbosity() > 1)
203  {
204  cout << "Getting inner HCal clusters for energy leakage studies" << endl;
205  }
206 
207  for (hcaliter = begin_end_hcal.first;
208  hcaliter != begin_end_hcal.second;
209  ++hcaliter)
210  {
211  RawCluster *cluster = hcaliter->second;
212  CLHEP::Hep3Vector vertex(vtx->get_x(), vtx->get_y(), vtx->get_z());
213  CLHEP::Hep3Vector E_vec_cluster = RawClusterUtility::GetEVec(*cluster, vertex);
214  hcal_energy = E_vec_cluster.mag();
215  hcal_eta = E_vec_cluster.pseudoRapidity();
216  hcal_theta = E_vec_cluster.getTheta();
217  hcal_pt = E_vec_cluster.perp();
218  hcal_phi = E_vec_cluster.getPhi();
219 
220  if (hcal_pt < 0.5)
221  continue;
222 
223  TLorentzVector *clus = new TLorentzVector();
224  clus->SetPtEtaPhiE(hcal_pt, hcal_eta, hcal_phi, hcal_energy);
225  float dumarray[4];
226  clus->GetXYZT(dumarray);
227  hcal_x = dumarray[0];
228  hcal_y = dumarray[1];
229  hcal_z = dumarray[2];
230  hcal_t = dumarray[3];
231 
232  hcal_px = hcal_pt * TMath::Cos(hcal_phi);
233  hcal_py = hcal_pt * TMath::Sin(hcal_phi);
235 
236  //find the associated truth high pT photon with this reconstructed
237  //hcal cluster
238 
239  for (PHG4TruthInfoContainer::ConstIterator iter = range.first; iter != range.second; ++iter)
240  {
241  PHG4Particle *truth = iter->second;
242 
243  hclustruthpid = truth->get_pid();
244  if (hclustruthpid == 22)
245  {
246  hclustruthpx = truth->get_px();
247  hclustruthpy = truth->get_py();
248  hclustruthpz = truth->get_pz();
249  hclustruthenergy = truth->get_e();
251  if (hclustruthpt < 0.5)
252  continue;
253 
254  TLorentzVector vec;
256  hclustruthphi = vec.Phi();
257  hclustrutheta = vec.Eta();
258  //once found it break out
259  break;
260  }
261  }
262 
263  inhcal_tree->Fill();
264  }
265 
266  /***********************************************
267 
268  GET THE FORWARD EMCAL CLUSTERS
269 
270  ************************************************/
271 
272  if (_etalow > 1)
273  {
274  if (Verbosity() > 1)
275  {
276  cout << "getting forward EMCal clusters" << endl;
277  }
278 
279  RawClusterContainer::ConstRange fclus = fclusters->getClusters();
281 
282  for (fclusiter = fclus.first;
283  fclusiter != fclus.second;
284  ++fclusiter)
285  {
286  RawCluster *cluster = fclusiter->second;
287 
288  CLHEP::Hep3Vector vertex(vtx->get_x(), vtx->get_y(), vtx->get_z());
289  CLHEP::Hep3Vector E_vec_cluster = RawClusterUtility::GetEVec(*cluster, vertex);
290  fclusenergy = E_vec_cluster.mag();
291  fclus_eta = E_vec_cluster.pseudoRapidity();
292  fclus_theta = E_vec_cluster.getTheta();
293  fclus_pt = E_vec_cluster.perp();
294  fclus_phi = E_vec_cluster.getPhi();
295 
296  fclus_px = fclus_pt * TMath::Cos(fclus_phi);
297  fclus_py = fclus_pt * TMath::Sin(fclus_phi);
298  fclus_pz = fclusenergy * TMath::Cos(fclus_theta);
299 
300 
301 
302  //find the truth photon that corresponds to this event
303  for (PHG4TruthInfoContainer::ConstIterator fiter = range.first;
304  fiter != range.second;
305  ++fiter)
306  {
307  PHG4Particle *truth = fiter->second;
308 
309  fclustruthpid = truth->get_pid();
310  //can run for photons or electrons
311  if (fclustruthpid == 22 || abs(fclustruthpid) == 11)
312  {
313  fclustruthpx = truth->get_px();
314  fclustruthpy = truth->get_py();
315  fclustruthpz = truth->get_pz();
316  fclustruthenergy = truth->get_e();
318  if (fclustruthpt < 0.3)
319  continue;
320 
321  TLorentzVector vec;
322  vec.SetPxPyPzE(fclustruthpx, fclustruthpy, fclustruthpz, fclustruthenergy);
323  fclustruthphi = vec.Phi();
324  fclustrutheta = vec.Eta();
325  //once found it break out
326  break;
327  }
328  }
329 
330  fcluster_tree->Fill();
331  }
332  }
333 
334 
335 
336 
337 
338 
339  /***********************************************
340 
341  GET THE POSITION RECALIBRATED EMCAL CLUSTERS
342 
343  ************************************************/
344 
345  RawClusterContainer::ConstRange rbegin_end = recal_clusters->getClusters();
347 
348  if (Verbosity() > 1)
349  cout << "Getting the position recalibrated clusters" << endl;
350 
351  //check that we are analyzing central arms
352  //position correction doesn't exist for forward arms
353  if (_etahi < 1.1)
354  {
355  for (rclusiter = rbegin_end.first;
356  rclusiter != rbegin_end.second;
357  ++rclusiter)
358  {
359 
360  RawCluster *cluster = rclusiter->second;
361 
362  CLHEP::Hep3Vector vertex(vtx->get_x(), vtx->get_y(), vtx->get_z());
363  CLHEP::Hep3Vector E_vec_cluster = RawClusterUtility::GetEVec(*cluster, vertex);
364  rclus_energy = E_vec_cluster.mag();
365  rclus_eta = E_vec_cluster.pseudoRapidity();
366  rclus_theta = E_vec_cluster.getTheta();
367  rclus_pt = E_vec_cluster.perp();
368  rclus_phi = E_vec_cluster.getPhi();
369 
370  if (rclus_pt < mincluspt)
371  continue;
372  if(Verbosity() > 1)
373  cout<<"passed recal pt cut"<<endl;
374  TLorentzVector *clus = new TLorentzVector();
375  clus->SetPtEtaPhiE(rclus_pt, rclus_eta, rclus_phi, rclus_energy);
376 
377  float dumarray[4];
378  clus->GetXYZT(dumarray);
379  rclus_x = dumarray[0];
380  rclus_y = dumarray[1];
381  rclus_z = dumarray[2];
382  rclus_t = dumarray[3];
383 
384  rclus_px = rclus_pt * TMath::Cos(rclus_phi);
385  rclus_py = rclus_pt * TMath::Sin(rclus_phi);
387  rclus_ecore = cluster->get_ecore();
388  rclus_prob = cluster->get_prob();
389  rclus_chi2 = cluster->get_chi2();
390 
391  //find the associated truth high pT photon with this reconstructed photon
392 
393  for (PHG4TruthInfoContainer::ConstIterator iter = range.first; iter != range.second; ++iter)
394  {
395  PHG4Particle *truth = iter->second;
396 
397  clustruthpid = truth->get_pid();
398  const int this_embed_id = truthinfo->isEmbeded(truth->get_track_id());
399 
400  //if it is embedded make sure that it is from the event
401  //generation and not the HIJING background
402  if (this_embed_id != 1 && _embed)
403  continue;
404 
405  //can run for photons or electrons in the EMCal
406  if (clustruthpid == 22 || fabs(clustruthpid) == 11)
407  {
408  clustruthpx = truth->get_px();
409  clustruthpy = truth->get_py();
410  clustruthpz = truth->get_pz();
411  clustruthenergy = truth->get_e();
413 
414  if (clustruthpt < mincluspt)
415  continue;
416 
417  TLorentzVector vec;
418  vec.SetPxPyPzE(clustruthpx, clustruthpy, clustruthpz, clustruthenergy);
419  clustruthphi = vec.Phi();
420  clustrutheta = vec.Eta();
421  //once found it break out
422  if(Verbosity() > 1)
423  cout<<"found recal truth photon"<<endl;
424  break;
425  }
426  }
427  if(Verbosity() > 1)
428  cout<<"filling recal cluster tree"<<endl;
429 
430  recal_cluster_tree->Fill();
431  }
432  }
433 
434 
435 
436 
437 
438  /***********************************************
439 
440  GET THE REGULAR, NON POSITION CORRECTED EMCAL CLUSTERS
441 
442  ************************************************/
443 
444  RawClusterContainer::ConstRange begin_end = clusters->getClusters();
446 
447  if (Verbosity() > 1)
448  cout << "Get the non-position recalibrated clusters" << endl;
449 
450  for (clusiter = begin_end.first;
451  clusiter != begin_end.second;
452  ++clusiter)
453  {
454 
455  RawCluster *cluster = clusiter->second;
456 
457  CLHEP::Hep3Vector vertex(vtx->get_x(), vtx->get_y(), vtx->get_z());
458  CLHEP::Hep3Vector E_vec_cluster = RawClusterUtility::GetEVec(*cluster, vertex);
459  clus_energy = E_vec_cluster.mag();
460  clus_eta = E_vec_cluster.pseudoRapidity();
461  clus_theta = E_vec_cluster.getTheta();
462  clus_pt = E_vec_cluster.perp();
463  clus_phi = E_vec_cluster.getPhi();
464 
465  clus_ecore = cluster->get_ecore();
466  clus_chi2 = cluster->get_chi2();
467  clus_prob = cluster->get_prob();
468 
469  if (clus_pt < mincluspt)
470  continue;
471 
472  if(Verbosity() > 1)
473  cout<<"passed cluster pt cut"<<endl;
474 
475  TLorentzVector *clus = new TLorentzVector();
476  clus->SetPtEtaPhiE(clus_pt, clus_eta, clus_phi, clus_energy);
477 
478  float dumarray[4];
479  clus->GetXYZT(dumarray);
480  clus_x = dumarray[0];
481  clus_y = dumarray[1];
482  clus_z = dumarray[2];
483  clus_t = dumarray[3];
484 
485  clus_px = clus_pt * TMath::Cos(clus_phi);
486  clus_py = clus_pt * TMath::Sin(clus_phi);
488 
489  //find the associated truth high pT photon with this reconstructed photon
490 
491  for (PHG4TruthInfoContainer::ConstIterator iter = range.first; iter != range.second; ++iter)
492  {
493  PHG4Particle *truth = iter->second;
494 
495  clustruthpid = truth->get_pid();
496  const int this_embed_id = truthinfo->isEmbeded(truth->get_track_id());
497  if (this_embed_id != 1 && _embed)
498  continue;
499  if (clustruthpid == 22 || fabs(clustruthpid) == 11)
500  {
501  clustruthpx = truth->get_px();
502  clustruthpy = truth->get_py();
503  clustruthpz = truth->get_pz();
504  clustruthenergy = truth->get_e();
506 
507  if (clustruthpt < mincluspt)
508  continue;
509 
510  TLorentzVector vec;
511  vec.SetPxPyPzE(clustruthpx, clustruthpy, clustruthpz, clustruthenergy);
512  clustruthphi = vec.Phi();
513  clustrutheta = vec.Eta();
514  //once found it break out
515 
516  break;
517  }
518  }
519 
520  /***********************************************
521 
522  DO THE EMCAL RECALIBRATION (if need be, recals are in database as of January 2018)
523  I'm leaving the code here commented out in case it ever needs to be used
524  again for new recalibrations e.g. for a new clusterizer
525 
526  ************************************************/
527  /*
528  std::vector<float> toweretas;
529  std::vector<float> towerphis;
530  std::vector<float> towerenergies;
531 
532  RawCluster::TowerConstRange towerbegend = cluster->get_towers();
533  RawCluster::TowerConstIterator toweriter;
534 
535  //loop over the towers in the cluster
536  for(toweriter=towerbegend.first;
537  toweriter!=towerbegend.second;
538  ++toweriter){
539 
540  RawTower *tower = _towers->getTower(toweriter->first);
541 
542  int towereta = tower->get_bineta();
543  int towerphi = tower->get_binphi();
544  double towerenergy = tower->get_energy();
545 
546  //put the etabin, phibin, and energy into the corresponding vectors
547  toweretas.push_back(towereta);
548  towerphis.push_back(towerphi);
549  towerenergies.push_back(towerenergy);
550 
551  }
552 
553  int ntowers = toweretas.size();
554 
555  //loop over the towers to determine the energy
556  //weighted eta and phi position of the cluster
557 
558  float etamult=0;
559  float etasum=0;
560  float phimult=0;
561  float phisum=0;
562 
563  for(int j=0; j<ntowers; j++){
564 
565  float energymult = towerenergies.at(j)*toweretas.at(j);
566  etamult+=energymult;
567  etasum+=towerenergies.at(j);
568 
569  energymult = towerenergies.at(j)*towerphis.at(j);
570  phimult+=energymult;
571  phisum+=towerenergies.at(j);
572  }
573  float avgphi = phimult/phisum;
574  float avgeta = etamult/etasum;
575 
576  fmodphi = fmod(avgphi,2.);
577  fmodeta = fmod(avgeta,2.);
578 
579 
580 
581  cluster_tree->Fill();
582 
583 
584  }
585 
586 
587 
588 
589 
590  //TOWER GEOMETRY, if needed can use to check the actual limits of the towers
591 
592 
593  RawTowerGeomContainer *_towergeoms = findNode::getClass<RawTowerGeomContainer>(topnode,"TOWERGEOM_CEMC");
594 
595  if(!_towergeoms){
596  cout<<"no tower geometry, bailing"<<endl;
597  return 0;
598  }
599 
600  RawTowerGeomContainer::ConstRange towbegend =
601  _towergeoms->get_tower_geometries();
602  RawTowerGeomContainer::ConstIterator towiter;
603  for(towiter=towbegend.first;
604  towiter!=towbegend.second;
605  ++towiter){
606 
607 
608  RawTowerGeom *geom = towiter->second;
609 
610 
611 
612  double eta = geom->get_eta();
613  double phi = geom->get_phi();
614  double center_x = geom->get_center_x();
615  double center_y = geom->get_center_y();
616  double center_z = geom->get_center_z();
617  double size_x = geom->get_size_x();
618  double size_y = geom->get_size_y();
619  double size_z = geom->get_size_z();
620 
621  cout<<eta<<" "<<phi<<" "<<center_x<<","<<center_y<<","<<center_z<<" "<<size_x<<","<<size_y<<","<<size_z<<endl;
622 
623  */
624 
625 
626 
627  cluster_tree->Fill();
628  }
629 
630  if(Verbosity() > 1)
631  cout<<"Finished event in Photons package"<<endl;
632 
633  nevents++;
634  tree->Fill();
635  return 0;
636 }
637 
639 {
640  std::cout << " DONE PROCESSING " << endl;
641 
642  file->Write();
643  file->Close();
644  return 0;
645 }
646 
648 {
649  inhcal_tree = new TTree("hcalclustree", "a tree with inner hcal cluster information");
650  inhcal_tree->Branch("hcal_energy", &hcal_energy, "hcal_energy/F");
651  inhcal_tree->Branch("hcal_eta", &hcal_eta, "hcal_eta/F");
652  inhcal_tree->Branch("hcal_phi", &hcal_phi, "hcal_phi/F");
653  inhcal_tree->Branch("hcal_pt", &hcal_pt, "hcal_pt/F");
654  inhcal_tree->Branch("hcal_theta", &hcal_theta, "hcal_theta/F");
655  inhcal_tree->Branch("hcal_x", &hcal_x, "hcal_x/F");
656  inhcal_tree->Branch("hcal_y", &hcal_y, "hcal_y/F");
657  inhcal_tree->Branch("hcal_z", &hcal_z, "hcal_z/F");
658  inhcal_tree->Branch("hcal_t", &hcal_t, "hcal_t/F");
659  inhcal_tree->Branch("hcal_px", &hcal_px, "hcal_px/F");
660  inhcal_tree->Branch("hcal_py", &hcal_py, "hcal_py/F");
661  inhcal_tree->Branch("hcal_pz", &hcal_pz, "hcal_pz/F");
662  inhcal_tree->Branch("nevents", &nevents, "nevents/I");
663  inhcal_tree->Branch("hclustruthpx", &hclustruthpx, "hclustruthpx/F");
664  inhcal_tree->Branch("hclustruthpy", &hclustruthpy, "hclustruthpy/F");
665  inhcal_tree->Branch("hclustruthpz", &hclustruthpz, "hclustruthpz/F");
666  inhcal_tree->Branch("hclustruthenergy", &hclustruthenergy, "hclustruthenergy/F");
667  inhcal_tree->Branch("hclustruthpt", &hclustruthpt, "hclustruthpt/F");
668  inhcal_tree->Branch("hclustruthphi", &hclustruthphi, "hclustruthphi/F");
669  inhcal_tree->Branch("hclustrutheta", &hclustrutheta, "hclustrutheta/F");
670 
671  cluster_tree = new TTree("clustertree", "A tree with EMCal cluster information");
672  cluster_tree->Branch("clus_energy", &clus_energy, "clus_energy/F");
673  cluster_tree->Branch("clus_eta", &clus_eta, "clus_eta/F");
674  cluster_tree->Branch("clus_phi", &clus_phi, "clus_phi/F");
675  cluster_tree->Branch("clus_pt", &clus_pt, "clus_pt/F");
676  cluster_tree->Branch("clus_theta", &clus_theta, "clus_theta/F");
677  cluster_tree->Branch("clus_x", &clus_x, "clus_x/F");
678  cluster_tree->Branch("clus_y", &clus_y, "clus_y/F");
679  cluster_tree->Branch("clus_z", &clus_z, "clus_z/F");
680  cluster_tree->Branch("clus_t", &clus_t, "clus_t/F");
681  cluster_tree->Branch("clus_px", &clus_px, "clus_px/F");
682  cluster_tree->Branch("clus_py", &clus_py, "clus_py/F");
683  cluster_tree->Branch("clus_pz", &clus_pz, "clus_pz/F");
684  cluster_tree->Branch("nevents", &nevents, "nevents/I");
685  cluster_tree->Branch("clus_ecore", &clus_ecore, "clus_ecore/F");
686  cluster_tree->Branch("clus_chi2", &clus_chi2, "clus_chi2/F");
687  cluster_tree->Branch("clustruthpx", &clustruthpx, "clustruthpx/F");
688  cluster_tree->Branch("clustruthpy", &clustruthpy, "clustruthpy/F");
689  cluster_tree->Branch("clustruthpz", &clustruthpz, "clustruthpz/F");
690  cluster_tree->Branch("clustruthenergy", &clustruthenergy, "clustruthenergy/F");
691  cluster_tree->Branch("clustruthpt", &clustruthpt, "clustruthpt/F");
692  cluster_tree->Branch("clustruthphi", &clustruthphi, "clustruthphi/F");
693  cluster_tree->Branch("clustrutheta", &clustrutheta, "clustrutheta/F");
694  cluster_tree->Branch("fmodphi", &fmodphi, "fmodphi/F");
695  cluster_tree->Branch("fmodeta", &fmodeta, "fmodeta/F");
696 
697  recal_cluster_tree = new TTree("recalclustertree", "A tree with EMCal recalib cluster information");
698  recal_cluster_tree->Branch("rclus_energy", &rclus_energy, "rclus_energy/F");
699  recal_cluster_tree->Branch("rclus_eta", &rclus_eta, "rclus_eta/F");
700  recal_cluster_tree->Branch("rclus_phi", &rclus_phi, "rclus_phi/F");
701  recal_cluster_tree->Branch("rclus_pt", &rclus_pt, "rclus_pt/F");
702  recal_cluster_tree->Branch("rclus_theta", &rclus_theta, "rclus_theta/F");
703  recal_cluster_tree->Branch("rclus_ecore", &rclus_ecore, "rclus_ecore/F");
704  recal_cluster_tree->Branch("rclus_chi2", &rclus_chi2, "rclus_chi2/F");
705  recal_cluster_tree->Branch("rclus_x", &rclus_x, "rclus_x/F");
706  recal_cluster_tree->Branch("rclus_y", &rclus_y, "rclus_y/F");
707  recal_cluster_tree->Branch("rclus_z", &rclus_z, "rclus_z/F");
708  recal_cluster_tree->Branch("rclus_t", &rclus_t, "rclus_t/F");
709  recal_cluster_tree->Branch("rclus_px", &rclus_px, "rclus_px/F");
710  recal_cluster_tree->Branch("rclus_py", &rclus_py, "rclus_py/F");
711  recal_cluster_tree->Branch("rclus_pz", &rclus_pz, "rclus_pz/F");
712  recal_cluster_tree->Branch("nevents", &nevents, "nevents/I");
713  recal_cluster_tree->Branch("clustruthpx", &clustruthpx, "clustruthpx/F");
714  recal_cluster_tree->Branch("clustruthpy", &clustruthpy, "clustruthpy/F");
715  recal_cluster_tree->Branch("clustruthpz", &clustruthpz, "clustruthpz/F");
716  recal_cluster_tree->Branch("clustruthenergy", &clustruthenergy, "clustruthenergy/F");
717  recal_cluster_tree->Branch("clustruthpt", &clustruthpt, "clustruthpt/F");
718  recal_cluster_tree->Branch("clustruthphi", &clustruthphi, "clustruthphi/F");
719  recal_cluster_tree->Branch("clustrutheta", &clustrutheta, "clustrutheta/F");
720 
721  fcluster_tree = new TTree("fclustertree", "A tree with FEMCal cluster information");
722  fcluster_tree->Branch("fclusenergy", &fclusenergy, "fclusenergy/F");
723  fcluster_tree->Branch("fclus_eta", &fclus_eta, "fclus_eta/F");
724  fcluster_tree->Branch("fclus_phi", &fclus_phi, "fclus_phi/F");
725  fcluster_tree->Branch("fclus_pt", &fclus_pt, "fclus_pt/F");
726  fcluster_tree->Branch("fclus_theta", &fclus_theta, "fclus_theta/F");
727  fcluster_tree->Branch("fclus_px", &fclus_px, "fclus_px/F");
728  fcluster_tree->Branch("fclus_py", &fclus_py, "fclus_py/F");
729  fcluster_tree->Branch("fclus_pz", &fclus_pz, "fclus_pz/F");
730  fcluster_tree->Branch("nevents", &nevents, "nevents/I");
731  fcluster_tree->Branch("fclustruthpx", &fclustruthpx, "fclustruthpx/F");
732  fcluster_tree->Branch("fclustruthpy", &fclustruthpy, "fclustruthpy/F");
733  fcluster_tree->Branch("fclustruthpz", &fclustruthpz, "fclustruthpz/F");
734  fcluster_tree->Branch("fclustruthenergy", &fclustruthenergy, "fclustruthenergy/F");
735  fcluster_tree->Branch("fclustruthpt", &fclustruthpt, "fclustruthpt/F");
736  fcluster_tree->Branch("fclustruthphi", &fclustruthphi, "fclustruthphi/F");
737  fcluster_tree->Branch("fclustrutheta", &fclustrutheta, "fclustrutheta/F");
738 
739  truth_g4particles = new TTree("truthtree_g4", "a tree with all truth g4 particles");
740  truth_g4particles->Branch("truthpx", &truthpx, "truthpx/F");
741  truth_g4particles->Branch("truthpy", &truthpy, "truthpy/F");
742  truth_g4particles->Branch("truthpz", &truthpz, "truthpz/F");
743  truth_g4particles->Branch("truthp", &truthp, "truthp/F");
744  truth_g4particles->Branch("truthenergy", &truthenergy, "truthenergy/F");
745  truth_g4particles->Branch("truthphi", &truthphi, "truthphi/F");
746  truth_g4particles->Branch("trutheta", &trutheta, "trutheta/F");
747  truth_g4particles->Branch("truthpt", &truthpt, "truthpt/F");
748  truth_g4particles->Branch("truthpid", &truthpid, "truthpid/I");
749  truth_g4particles->Branch("nevents", &nevents, "nevents/I");
750 }
751 
753 {
754  file = 0;
755  tree = 0;
756  cluster_tree = 0;
757  truth_g4particles = 0;
758  inhcal_tree = 0;
759  fcluster_tree = 0;
760 
761  recal_cluster_tree = 0;
762  rclus_energy = 0;
763  rclus_eta = 0;
764  rclus_phi = 0;
765  rclus_pt = 0;
766  rclus_px = 0;
767  rclus_pz = 0;
768  rclus_py = 0;
769  rclus_theta = 0;
770  rclus_x = 0;
771  rclus_y = 0;
772  rclus_z = 0;
773  rclus_t = 0;
774 
775  nevents = 0;
776  histo = 0;
777  hcal_energy = 0;
778  hcal_eta = 0;
779  hcal_phi = 0;
780  hcal_pt = 0;
781  hcal_px = 0;
782  hcal_py = 0;
783  hcal_pz = 0;
784  hcal_theta = 0;
785  hcal_x = 0;
786  hcal_y = 0;
787  hcal_z = 0;
788  hcal_t = 0;
789 
790  clus_energy = 0;
791  clus_eta = 0;
792  clus_phi = 0;
793  clus_pt = 0;
794  clus_px = 0;
795  clus_py = 0;
796  clus_pz = 0;
797  clus_theta = 0;
798  clus_x = 0;
799  clus_y = 0;
800  clus_z = 0;
801  clus_t = 0;
802  fmodphi = 0;
803  fmodeta = 0;
804 
805  truthpx = 0;
806  truthpy = 0;
807  truthpz = 0;
808  truthp = 0;
809  truthphi = 0;
810  trutheta = 0;
811  truthpt = 0;
812  truthenergy = 0;
813  truthpid = 0;
815  process_id = 0;
816 
817  clustruthpx = 0;
818  clustruthpy = 0;
819  clustruthpz = 0;
820  clustruthenergy = 0;
821  clustruthpt = 0;
822  clustruthphi = 0;
823  clustrutheta = 0;
824  clustruthpid = 0;
825  hclustruthpx = 0;
826  hclustruthpy = 0;
827  hclustruthpz = 0;
828  hclustruthenergy = 0;
829  hclustruthpt = 0;
830  hclustruthphi = 0;
831  hclustrutheta = 0;
832  hclustruthpid = 0;
833 
834  fclusenergy = 0;
835  fclus_eta = 0;
836  fclus_phi = 0;
837  fclus_theta = 0;
838  fclus_pt = 0;
839  fclustruthpid = 0;
840  fclustruthpx = 0;
841  fclustruthpy = 0;
842  fclustruthpz = 0;
843  fclustruthenergy = 0;
844  fclustruthpt = 0;
845  fclustruthphi = 0;
846  fclustrutheta = 0;
847  fclus_px = 0;
848  fclus_py = 0;
849  fclus_pz = 0;
850 }