EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EvalRootTTree.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EvalRootTTree.cc
1 #include "EvalRootTTree.h"
2 
3 #include "EvalCluster.h"
4 #include "EvalHit.h"
5 #include "EvalTower.h"
6 
7 #include <g4main/PHG4Hit.h> // for PHG4Hit
8 
9 #include <calobase/RawCluster.h>
10 #include <calobase/RawTower.h>
11 
12 #include <TClonesArray.h>
13 
14 static const int NHIT = 100000;
15 static const int NTWR = 100;
16 static const int NCLU = 100;
17 
19 {
20  SnglHits = new TClonesArray("EvalHit", NHIT);
21  SnglTowers = new TClonesArray("EvalTower", NTWR);
22  SnglClusters = new TClonesArray("EvalCluster", NCLU);
23 }
24 
26 {
27  SnglHits->Clear();
28  delete SnglHits;
29  SnglTowers->Clear();
30  delete SnglTowers;
31  SnglClusters->Clear();
32  delete SnglClusters;
33 }
34 
36 {
37  SnglHits->Clear();
38  if (SnglHits->GetSize() > NHIT)
39  {
40  SnglHits->Expand(NHIT);
41  }
42  SnglTowers->Clear();
43  if (SnglTowers->GetSize() > NTWR)
44  {
45  SnglTowers->Expand(NTWR);
46  }
47  SnglClusters->Clear();
48  if (SnglClusters->GetSize() > NTWR)
49  {
50  SnglClusters->Expand(NTWR);
51  }
52  event = 0;
53  gpid = -99999;
54  nhits = 0;
55  ntowers = 0;
56  nclusters = 0;
57  hesum = 0.;
58  tesum = 0.;
59  cesum = 0.;
60  gvx = NAN;
61  gvy = NAN;
62  gvz = NAN;
63  gpx = NAN;
64  gpy = NAN;
65  ge = NAN;
66  gpz = NAN;
67  geta = NAN;
68  gphi = NAN;
69  gtheta = NAN;
70 
71 }
72 
73 EvalHit *
75 {
76  TClonesArray &cl = *SnglHits;
77  int nextindex = SnglHits->GetLast() + 1;
78  if (nextindex == SnglHits->GetSize())
79  {
80  SnglHits->Expand(SnglHits->GetSize() + NHIT / 10);
81  }
82  new (cl[nextindex]) EvalHit(g4hit);
83  return (static_cast<EvalHit *>(cl[nextindex]));
84 }
85 
86 EvalHit *
87 EvalRootTTree::get_hit(const size_t i) const
88 {
89  return (EvalHit *) SnglHits->At(i);
90 }
91 
92 EvalTower *
94 {
95  TClonesArray &cl = *SnglTowers;
96  int nextindex = SnglTowers->GetLast() + 1;
97  if (nextindex == SnglTowers->GetSize())
98  {
99  SnglTowers->Expand(SnglTowers->GetSize() + NTWR / 10);
100  }
101  new (cl[nextindex]) EvalTower(twr);
102  return (static_cast<EvalTower *>(cl[nextindex]));
103 }
104 
105 EvalTower *
106 EvalRootTTree::get_tower(const size_t i) const
107 {
108  return (EvalTower *) SnglTowers->At(i);
109 }
110 
111 EvalCluster *
113 {
114  TClonesArray &cl = *SnglClusters;
115  int nextindex = SnglClusters->GetLast() + 1;
116  if (nextindex == SnglClusters->GetSize())
117  {
118  SnglClusters->Expand(SnglClusters->GetSize() + NCLU / 10);
119  }
120  new (cl[nextindex]) EvalCluster(clus);
121  return (static_cast<EvalCluster *>(cl[nextindex]));
122 }
123 
124 EvalCluster *
125 EvalRootTTree::get_cluster(const size_t i) const
126 {
127  return (EvalCluster *) SnglClusters->At(i);
128 }