Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventEvaluator.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EventEvaluator.h
1 #ifndef G4EVAL_EVENTEVALUATOR_H
2 #define G4EVAL_EVENTEVALUATOR_H
3 
4 //===============================================
8 //===============================================
9 
10 #include <fun4all/SubsysReco.h>
11 
12 #include <set>
13 #include <string>
14 
15 class CaloEvalStack;
16 class PHCompositeNode;
17 class PHHepMCGenEventMap;
18 class PHHepMCGenEvent;
19 class TFile;
20 class TNtuple;
21 class TTree; // Added by Barak
22 
31 class EventEvaluator : public SubsysReco
32 {
33  public:
34  enum class TrackSource_t : unsigned short
35  {
36  all = 0,
37  inner = 1
38  };
39 
40  EventEvaluator(const std::string& name = "EventEvaluator",
41  const std::string& filename = "g4eval_cemc.root");
42  ~EventEvaluator() override{};
43 
44  int Init(PHCompositeNode* topNode) override;
45  int process_event(PHCompositeNode* topNode) override;
46  int End(PHCompositeNode* topNode) override;
47 
48  void set_strict(bool b) { _strict = b; }
49 
51  void set_do_HCALIN(bool b) { _do_HCALIN = b; }
52  void set_do_HCALOUT(bool b) { _do_HCALOUT = b; }
53  void set_do_CEMC(bool b) { _do_CEMC = b; }
54  void set_do_HITS(bool b) { _do_HITS = b; }
55  void set_do_TRACKS(bool b) { _do_TRACKS = b; }
56  void set_do_CLUSTERS(bool b) { _do_CLUSTERS = b; }
57  void set_do_VERTEX(bool b) { _do_VERTEX = b; }
60  void set_do_HEPMC(bool b) { _do_HEPMC = b; }
61  void set_do_GEOMETRY(bool b) { _do_GEOMETRY = b; }
62 
63  // limit the tracing of towers and clusters back to the truth particles
64  // to only those reconstructed objects above a particular energy
65  // threshold (evaluation for objects above threshold unaffected)
67  {
68  _reco_e_threshold = thresh;
69  }
71  {
72  _reco_e_threshold_BECAL = thresh;
73  }
74 
76  void set_depth_MCstack(int d)
77  {
78  _depth_MCstack = d;
79  }
80 
81  private:
82  bool _do_store_event_info = false;
83  bool _do_HCALIN = false;
84  bool _do_HCALOUT = false;
85  bool _do_CEMC = false;
86  bool _do_HITS = false;
87  bool _do_TRACKS = false;
88  bool _do_CLUSTERS = false;
89  bool _do_VERTEX = false;
90  bool _do_PROJECTIONS = false;
91  bool _do_MCPARTICLES = false;
92  bool _do_HEPMC = false;
93  bool _do_GEOMETRY = false;
94  unsigned int _ievent = 0;
95 
96  // Event level info
97  float _cross_section = 0.;
98  float _event_weight = 0.;
100 
101  // track hits
102  int _nHitsLayers = 0;
103  int* _hits_layerID = nullptr;
104  int* _hits_trueID = nullptr;
105  float* _hits_x = nullptr;
106  float* _hits_y = nullptr;
107  float* _hits_z = nullptr;
108  float* _hits_t = nullptr;
109 
110  // towers
112  float* _tower_HCALIN_E = nullptr;
113  int* _tower_HCALIN_iEta = nullptr;
114  int* _tower_HCALIN_iPhi = nullptr;
115  int* _tower_HCALIN_trueID = nullptr;
116 
118  float* _tower_HCALOUT_E = nullptr;
119  int* _tower_HCALOUT_iEta = nullptr;
120  int* _tower_HCALOUT_iPhi = nullptr;
121  int* _tower_HCALOUT_trueID = nullptr;
122 
123  int _nTowers_CEMC = 0;
124  float* _tower_CEMC_E = nullptr;
125  int* _tower_CEMC_iEta = nullptr;
126  int* _tower_CEMC_iPhi = nullptr;
127  int* _tower_CEMC_trueID = nullptr;
128 
129  // clusters
131  float* _cluster_HCALIN_E = nullptr;
132  float* _cluster_HCALIN_Eta = nullptr;
133  float* _cluster_HCALIN_Phi = nullptr;
134  int* _cluster_HCALIN_NTower = nullptr;
135  int* _cluster_HCALIN_trueID = nullptr;
136 
138  float* _cluster_HCALOUT_E = nullptr;
139  float* _cluster_HCALOUT_Eta = nullptr;
140  float* _cluster_HCALOUT_Phi = nullptr;
141  int* _cluster_HCALOUT_NTower = nullptr;
142  int* _cluster_HCALOUT_trueID = nullptr;
143 
145  float* _cluster_CEMC_E = nullptr;
146  float* _cluster_CEMC_Eta = nullptr;
147  float* _cluster_CEMC_Phi = nullptr;
148  int* _cluster_CEMC_NTower = nullptr;
149  int* _cluster_CEMC_trueID = nullptr;
150 
151  // vertex
152  float _vertex_x = 0.;
153  float _vertex_y = 0.;
154  float _vertex_z = 0.;
155  int _vertex_NCont = 0;
156  float _vertex_true_x = 0.;
157  float _vertex_true_y = 0.;
158  float _vertex_true_z = 0.;
159 
160  // tracks
161  int _nTracks = 0;
162  float* _track_ID = nullptr;
163  float* _track_px = nullptr;
164  float* _track_py = nullptr;
165  float* _track_pz = nullptr;
166  float* _track_dca = nullptr;
167  float* _track_dca_2d = nullptr;
168  float* _track_trueID = nullptr;
169  unsigned short* _track_source = nullptr;
170 
171  int _nProjections = 0;
172  float* _track_ProjTrackID = nullptr;
173  int* _track_ProjLayer = nullptr;
174  float* _track_TLP_x = nullptr;
175  float* _track_TLP_y = nullptr;
176  float* _track_TLP_z = nullptr;
177  float* _track_TLP_t = nullptr;
178  float* _track_TLP_true_x = nullptr;
179  float* _track_TLP_true_y = nullptr;
180  float* _track_TLP_true_z = nullptr;
181  float* _track_TLP_true_t = nullptr;
182 
183  // MC particles
184  int _nMCPart = 0;
185  int* _mcpart_ID = nullptr;
186  int* _mcpart_ID_parent = nullptr;
187  int* _mcpart_PDG = nullptr;
188  float* _mcpart_E = nullptr;
189  float* _mcpart_px = nullptr;
190  float* _mcpart_py = nullptr;
191  float* _mcpart_pz = nullptr;
192  int* _mcpart_BCID = nullptr;
193 
194  // MC particles
195  int _nHepmcp = 0;
196  int _hepmcp_procid = 0;
197  float _hepmcp_x1 = 0.;
198  float _hepmcp_x2 = 0.;
199  // float* _hepmcp_ID_parent;
200  int* _hepmcp_status = nullptr;
201  int* _hepmcp_PDG = nullptr;
202  float* _hepmcp_E = nullptr;
203  float* _hepmcp_px = nullptr;
204  float* _hepmcp_py = nullptr;
205  float* _hepmcp_pz = nullptr;
206  int* _hepmcp_m1 = nullptr;
207  int* _hepmcp_m2 = nullptr;
208  int* _hepmcp_BCID = nullptr;
209 
210  int _calo_ID = 0;
211  int _calo_towers_N = 0;
212  int* _calo_towers_iEta = nullptr;
213  int* _calo_towers_iPhi = nullptr;
214  float* _calo_towers_Eta = nullptr;
215  float* _calo_towers_Phi = nullptr;
216  float* _calo_towers_x = nullptr;
217  float* _calo_towers_y = nullptr;
218  float* _calo_towers_z = nullptr;
219  int* _geometry_done = nullptr;
220 
221  float _reco_e_threshold = 0.;
223  int _depth_MCstack = 0;
224 
228 
229  //----------------------------------
230  // evaluator output ntuples
231 
232  bool _strict = false;
233 
234  TTree* _event_tree = nullptr; // Added by Barak
235  TTree* _geometry_tree = nullptr; // Added by Barak
236 
237  // evaluator output file
239  TFile* _tfile = nullptr;
240  TFile* _tfile_geometry = nullptr;
241 
242  // subroutines
243  int GetProjectionIndex(const std::string& projname);
244  std::string GetProjectionNameFromIndex(int projindex);
245  void fillOutputNtuples(PHCompositeNode* topNode);
246  void resetGeometryArrays();
247  void resetBuffer();
248 
249  const int _maxNHits = 10000;
250  const int _maxNTowersCentral = 2000;
251  const int _maxNTowersCalo = 5000000;
252  const int _maxNclustersCentral = 2000;
253  const int _maxNTracks = 200;
254  const int _maxNProjections = 2000;
255  const int _maxNMCPart = 100000;
256  const int _maxNHepmcp = 1000;
257 
258  enum calotype
259  {
260  kCEMC = 0,
261  kHCALIN = 1,
263  };
264 };
265 
266 #endif // G4EVAL_EVENTEVALUATOR_H