WCSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WCSimRootEvent.hh
Go to the documentation of this file.
1 #ifndef WCSim_RootEvent
2 #define WCSim_RootEvent
3 
5 // //
6 // WCSim_RootEvent //
7 // //
9 
10 #include <stdint.h>
11 #include "TObject.h"
12 #include "TClonesArray.h"
13 #include "TVector3.h"
14 #include "TLorentzVector.h"
15 #include <string>
16 #include <vector>
17 #include <iostream>
18 #include "jhfNtuple.h"
19 //#include <map>
20 //#include "G4Transform3D.hh"
21 
22 // #include "WCSimDetectorConstruction.hh"
23 #include "WCSimEnumerations.hh"
24 
25 class TDirectory;
26 
27 
28 class WCSimRootTrack : public TObject {
29 
30 private:
31 
32  // See jhfNtuple.h for the meaning of these data members:
33  Int_t fIpnu;
34  Int_t fFlag;
35  Float_t fM;
36  Float_t fP;
37  Float_t fE;
38  Int_t fStartvol;
39  Int_t fStopvol;
40  Float_t fDir[3];
41  Float_t fPdir[3];
42  Float_t fStop[3];
43  Float_t fStart[3];
44  Int_t fParenttype;
45  Double_t fTime;
46  Int_t fId;
47 
48 public:
50  WCSimRootTrack(Int_t ipnu,
51  Int_t flag,
52  Double_t m,
53  Double_t p,
54  Double_t E,
55  Int_t startvol,
56  Int_t stopvol,
57  Double_t dir[3],
58  Double_t pdir[3],
59  Double_t stop[3],
60  Double_t start[3],
61  Int_t parenttype,
62  Double_t time,Int_t id);
63  virtual ~WCSimRootTrack() { }
64  bool CompareAllVariables(const WCSimRootTrack * c) const;
65 
66  Int_t GetIpnu() const { return fIpnu;}
67  Int_t GetFlag() const { return fFlag;}
68  Float_t GetM() const { return fM;}
69  Float_t GetP() const { return fP;}
70  Float_t GetE() const { return fE;}
71  Int_t GetStartvol() const { return fStartvol;}
72  Int_t GetStopvol() const { return fStopvol;}
73  Float_t GetDir(Int_t i=0) const {return (i<3) ? fDir[i] : 0;}
74  Float_t GetPdir(Int_t i=0) const {return (i<3) ? fPdir[i] : 0;}
75  Float_t GetStop(Int_t i=0) const {return (i<3) ? fStop[i] : 0;}
76  Float_t GetStart(Int_t i=0) const {return (i<3) ? fStart[i] : 0;}
77  Int_t GetParenttype(/*Int_t i=0*/) const {return fParenttype;}
78  Double_t GetTime() const { return fTime;}
79  Int_t GetId() const {return fId;}
80 
81  ClassDef(WCSimRootTrack,1)
82 };
83 
84 
86 
87 
88 class WCSimRootCherenkovHit : public TObject {
89 
90 private:
91  Int_t fTubeID;
92  Int_t fTotalPe[2];
93 
94 public:
96  WCSimRootCherenkovHit(Int_t tubeID,
97  Int_t totalPe[2]);
98 
99  virtual ~WCSimRootCherenkovHit() { }
100 
101  bool CompareAllVariables(const WCSimRootCherenkovHit * c) const;
102 
103  Int_t GetTubeID() const { return fTubeID;}
104  Int_t GetTotalPe(int i) const { return (i<2) ? fTotalPe[i]: 0;}
105 
106  ClassDef(WCSimRootCherenkovHit,1)
107 };
108 
109 class WCSimRootCherenkovHitTime : public TObject {
110 
111 private:
112  // See jhfNtuple.h for the meaning of these data members:
113  Double_t fTruetime;
115 
116 public:
118  WCSimRootCherenkovHitTime(Double_t truetime,
119  Int_t primaryParentID);
121  bool CompareAllVariables(const WCSimRootCherenkovHitTime * c) const;
122 
123  Double_t GetTruetime() const { return fTruetime;}
124  Int_t GetParentID() const { return fPrimaryParentID;}
125 
126  ClassDef(WCSimRootCherenkovHitTime,1)
127 };
128 
129 
131 
132 
133 class WCSimRootCherenkovDigiHit : public TObject {
134 
135 private:
136  // See jhfNtuple.h for the meaning of these data members:
137  Float_t fQ;
138  Double_t fT;
139  Int_t fTubeId;
140  std::vector<int> fPhotonIds;
141 
142 public:
144  WCSimRootCherenkovDigiHit(Double_t q, Double_t t, Int_t tubeid, std::vector<int> photon_ids);
145 
147  bool CompareAllVariables(const WCSimRootCherenkovDigiHit * c) const;
148 
149  void SetT(float t) { fT = t; }
150  void SetPhotonIds(std::vector<int> photon_ids) { fPhotonIds = photon_ids; }
151  Float_t GetQ() const { return fQ;}
152  Double_t GetT() const { return fT;}
153  Int_t GetTubeId() const { return fTubeId;}
154  std::vector<int> GetPhotonIds() const { return fPhotonIds; }
155 
156  ClassDef(WCSimRootCherenkovDigiHit,2)
157 };
158 
159 
161 
163 
164 private:
165  Int_t fEvtNum;
166  Int_t fRun;
167  int64_t fDate;
169 
170 public:
172  virtual ~WCSimRootEventHeader() { }
173  bool CompareAllVariables(const WCSimRootEventHeader * c) const;
174  void Set(Int_t i, Int_t r, int64_t d, Int_t s=1) { fEvtNum = i; fRun = r; fDate = d; fSubEvtNumber = s;}
175  void SetDate(int64_t d) { fDate=d; }
176  Int_t GetEvtNum() const { return fEvtNum; }
177  Int_t GetRun() const { return fRun; }
178  int64_t GetDate() const { return fDate; }
179  Int_t GetSubEvtNumber() const { return fSubEvtNumber;}
180 
181 
182  ClassDef(WCSimRootEventHeader,2) //WCSimRootEvent Header
183 };
184 
186 
187 class WCSimRootPi0 : public TObject {
188  // this is a class used specifically for Pi0 events
189 
190 private:
191  Float_t fPi0Vtx[3];
192  Int_t fGammaID[2];
193  Float_t fGammaE[2];
194  Float_t fGammaVtx[2][3];
195 
196 public:
198 
199  virtual ~WCSimRootPi0() { }
200  bool CompareAllVariables(const WCSimRootPi0 * c) const;
201 
202  void Set(Double_t pi0Vtx[3],
203  Int_t gammaID[2],
204  Double_t gammaE[2],
205  Double_t gammaVtx[2][3]);
206 
207  Float_t GetPi0Vtx(int i) const { return (i<3) ? fPi0Vtx[i]: 0;}
208  Int_t GetGammaID(int i) const { return (i<2) ? fGammaID[i]: 0;}
209  Float_t GetGammaE(int i) const { return (i<2) ? fGammaE[i]: 0;}
210  Float_t GetGammaVtx(int i, int j) const { return fGammaVtx[i][j];}
211 
212  ClassDef(WCSimRootPi0,1)
213 };
214 
216 
217 class WCSimRootTrigger : public TObject {
218 
219 private:
221  // See jhfNtuple.h for the meaning of these data members:
223  Int_t fNvtxs;
225  Float_t fVtxs[MAX_N_VERTICES][4];
226  Int_t fVecRecNumber; // "info event" number in inputvectorfile
227  Int_t fJmu;
228  Int_t fJp;
229 
230  WCSimRootPi0 fPi0; // Pi0 info (default = not used)
231 
232  Int_t fNpar; // Number of particles
233  Int_t fNtrack; // Number of tracks in the array
234  Int_t fNtrack_slots; // Number of slots in the tracks array. This is potentially more than fNtrack (i.e. if any tracks have been removed that aren't at the very start/end)
235  TClonesArray *fTracks; //-> Array of WCSimRootTracks
236 
237  Int_t fNumTubesHit; // Number of tubes hit
238  Int_t fNcherenkovhits; // Number of hits in the array
239  TClonesArray *fCherenkovHits; //-> Array of WCSimRootCherenkovHits
240 
242  Int_t fNcherenkovhittimes; // Number of hits in the array
243  TClonesArray *fCherenkovHitTimes; //-> Array of WCSimRootCherenkovHits
244 
245  Int_t fNumDigitizedTubes; // Number of digitized tubes
246  Int_t fNcherenkovdigihits; // Number of digihits in the array
247  Int_t fNcherenkovdigihits_slots; // Number of slots in the digihits array. This is potentially more than fNcherenkovdigihits (i.e. if any digihits have been removed that aren't at the very start/end)
248  Float_t fSumQ;
249  TClonesArray *fCherenkovDigiHits; //-> Array of WCSimRootCherenkovDigiHit's
250 
251  TriggerType_t fTriggerType; // Trigger algorithm that created this trigger
252  std::vector<Float_t> fTriggerInfo; // Information about how it passed the trigger (e.g. how many hits in the NDigits window)
253 
254  bool IsZombie;
255 
256 public:
258  WCSimRootTrigger(int, int);
259  virtual ~WCSimRootTrigger();
261  bool CompareAllVariables(const WCSimRootTrigger * c, bool deep_comparison = false) const;
262 
263  void Initialize();
264 
265  void Clear(Option_t *option ="");
266  static void Reset(Option_t *option ="");
267 
268  void SetHeader(Int_t i, Int_t run, int64_t date,Int_t subevtn=1);
269  void SetTriggerInfo(TriggerType_t trigger_type, std::vector<Float_t> trigger_info);
270  bool IsASubEvent() { return (fEvtHdr.GetSubEvtNumber()>=1); }
271  void SetMode(Int_t i) {fMode[0] = i;}
272  void SetMode(Int_t index, Int_t value){fMode[index]=value;}
273  void SetNvtxs(Int_t i) {fNvtxs = i;}
274  void SetVtxvol(Int_t i) {fVtxsvol[0] = i;}
275  void SetVtxsvol(Int_t i, Int_t v) {fVtxsvol[i] = v;}
276  void SetVtx(Int_t i, Double_t f) {SetVtxs(0,i,f);}
277  void SetVtxs(Int_t n, Int_t i, Double_t f) {fVtxs[n][i]= ( (i<4) ? f : 0);}
278  void SetVecRecNumber(Int_t i) {fVecRecNumber = i;}
279  void SetJmu(Int_t i) {fJmu = i;}
280  void SetJp(Int_t i) {fJp = i;}
281  void SetNpar(Int_t i) {fNpar = i;}
282  void SetNumTubesHit(Int_t i) {fNumTubesHit = i;}
283  void SetSumQ(Double_t x){fSumQ = x;}
285  void SetPi0Info(Double_t pi0Vtx[3],
286  Int_t gammaID[2],
287  Double_t gammaE[2],
288  Double_t gammaVtx[2][3]);
289 
291  const WCSimRootEventHeader * GetHeader() const {return &fEvtHdr; }
292  WCSimRootPi0 *GetPi0Info() {return &fPi0; }
293  const WCSimRootPi0 * GetPi0Info() const {return &fPi0; }
294  Int_t GetMode() const {return fMode[0];}
295  Int_t GetMode(Int_t index) const {return fMode[index];}
296  Int_t GetVtxvol() const {return fVtxsvol[0];}
297  Float_t GetVtx(Int_t i=0) {return (i<3) ? fVtxs[0][i]: 0;}
298  TVector3 GetVertex(Int_t i) {return TVector3(fVtxs[i][0],fVtxs[i][1],fVtxs[i][2]);}
299  Int_t GetNvtxs() const {return fNvtxs;}
300  Int_t GetVtxsvol(Int_t i) const {return fVtxsvol[i];}
301  Float_t GetVtxs(Int_t n, Int_t i=0) const {return (i<3) ? fVtxs[n][i]: 0;}
302  TLorentzVector Get4Vertex(Int_t i) {return TLorentzVector(fVtxs[i][0],fVtxs[i][1],fVtxs[i][2],fVtxs[i][3]);}
303  Int_t GetVecRecNumber() const {return fVecRecNumber;}
304  Int_t GetJmu() const {return fJmu;}
305  Int_t GetJp() const {return fJp;}
306  Int_t GetNpar() const {return fNpar;}
307  Int_t GetNumTubesHit() const {return fNumTubesHit;}
308  Int_t GetNumDigiTubesHit() const {return fNumDigitizedTubes;}
309  Int_t GetNtrack() const {return fNtrack; }
310  Int_t GetNtrack_slots() const {return fTracks->GetLast() + 1; } //don't use fNtrack_slots directly as it doesn't take into account automatic TClonesArray shortening when tracks at start/end are removed
311  Int_t GetNcherenkovhits() const {return fNcherenkovhits; }
314  Int_t GetNcherenkovdigihits_slots() const {return fCherenkovDigiHits->GetLast() + 1; } //don't use fNcherenkovdigihits_slots directly as it doesn't take into account automatic TClonesArray shortening when digits at start/end are removed
315  Float_t GetSumQ() const { return fSumQ;}
317  std::vector<Float_t> GetTriggerInfo() const { return fTriggerInfo;}
318 
319  WCSimRootTrack *AddTrack(Int_t ipnu,
320  Int_t flag,
321  Double_t m,
322  Double_t p,
323  Double_t E,
324  Int_t startvol,
325  Int_t stopvol,
326  Double_t dir[3],
327  Double_t pdir[3],
328  Double_t stop[3],
329  Double_t start[3],
330  Int_t parenttype,
331  Double_t time,
332  Int_t id);
333 
336 
337  TClonesArray *GetTracks() const {return fTracks;}
338 
340  std::vector<Double_t> truetime,
341  std::vector<Int_t> primParID);
342  TClonesArray *GetCherenkovHits() const {return fCherenkovHits;}
343  TClonesArray *GetCherenkovHitTimes() const {return fCherenkovHitTimes;}
344 
346  Double_t t,
347  Int_t tubeid,
348  std::vector<int> photon_ids);
349 // WCSimRootCherenkovDigiHit *AddCherenkovDigiHit(Double_t q,
350 // Double_t t,
351 // Int_t tubeid,
352  // Double_t sumq);
355  TClonesArray *GetCherenkovDigiHits() const {return fCherenkovDigiHits;}
356 
357  ClassDef(WCSimRootTrigger,3) //WCSimRootEvent structure
358 };
359 
360 
361 class WCSimRootEvent : public TObject {
362 public:
363  WCSimRootEvent();
364  virtual ~WCSimRootEvent();
366  bool CompareAllVariables(const WCSimRootEvent * c, bool deep_comparison = false) const;
367 
368  void Clear(Option_t *option ="");
369  static void Reset(Option_t *option ="");
370  Int_t GetCurrentIndex() { return Current;}
371 
372  // WCSimRootTrigger* GetTrigger(int number) { return fEventList[number];}
373  WCSimRootTrigger * GetTrigger(int number) { return (WCSimRootTrigger*) (*fEventList)[number];}
374  const WCSimRootTrigger * GetTrigger(int number) const { return (WCSimRootTrigger*) (*fEventList)[number];}
375 
376  Int_t GetNumberOfEvents() const { return fEventList->GetEntriesFast();}
377  Int_t GetNumberOfSubEvents() const { return (fEventList->GetEntriesFast()-1);}
378  bool HasSubEvents() { return (fEventList->GetEntriesFast() > 1); }
379 
380  //Int_t GetNumberOfEvents() const { return fEventList.size();}
381  //Int_t GetNumberOfSubEvents() const { return (fEventList.size()-1);}
382 
383  //void AddSubEvent() { fEventList.push_back(new WCSimRootTrigger()); }
384  void AddSubEvent() {
385  // be sure not to call the default constructor BUT the actual one
386  WCSimRootTrigger* tmp = dynamic_cast<WCSimRootTrigger*>( (*fEventList)[0] );
387  int num = tmp->GetHeader()->GetEvtNum();
388  ++Current;
389  if ( Current > 9 ) fEventList->Expand(150);
390  fEventList->AddAt(new WCSimRootTrigger(num,Current),Current);
391  }
392 
393  /* void ReInitialize() { // need to remove all subevents at the end, or they just get added anyway...
394  std::vector<WCSimRootTrigger*>::iterator iter = fEventList.begin();
395  ++iter; // do not delete the first event --> regular beaviour for this program ?
396  */
397  void Initialize();
398 
399  void ReInitialize() { // need to remove all subevents at the end, or they just get added anyway...
400  for ( int i = fEventList->GetLast() ; i>=1 ; i--) {
401  // G4cout << "removing element # " << i << "...";
402  WCSimRootTrigger* tmp =
403  dynamic_cast<WCSimRootTrigger*>(fEventList->RemoveAt(i));
404  delete tmp;
405  //G4cout <<"done !\n";
406  }
407  Current = 0;
408  WCSimRootTrigger* tmp = dynamic_cast<WCSimRootTrigger*>( (*fEventList)[0]);
409  tmp->Clear();
410  }
411 
412 private:
413  //std::vector<WCSimRootTrigger*> fEventList;
414  TObjArray* fEventList;
415  Int_t Current;
416  ClassDef(WCSimRootEvent,1)
417 
418 };
419 
420 
421 #endif
Float_t fGammaE[2]
Int_t GetSubEvtNumber() const
virtual ~WCSimRootEvent()
Int_t GetRun() const
Float_t fPi0Vtx[3]
Float_t GetM() const
Double_t GetTruetime() const
WCSimRootTrigger & operator=(const WCSimRootTrigger &in)
Float_t GetGammaE(int i) const
virtual ~WCSimRootCherenkovHit()
enum ETriggerType TriggerType_t
Int_t GetEvtNum() const
void SetNumDigitizedTubes(Int_t i)
int64_t GetDate() const
TriggerType_t fTriggerType
Int_t GetCurrentIndex()
const WCSimRootPi0 * GetPi0Info() const
Int_t GetGammaID(int i) const
WCSimRootCherenkovHit * AddCherenkovHit(Int_t tubeID, std::vector< Double_t > truetime, std::vector< Int_t > primParID)
const WCSimRootEventHeader * GetHeader() const
void SetMode(Int_t index, Int_t value)
void SetVtxvol(Int_t i)
Double_t GetTime() const
bool CompareAllVariables(const WCSimRootTrack *c) const
Float_t GetPdir(Int_t i=0) const
Float_t GetPi0Vtx(int i) const
TClonesArray * GetCherenkovHitTimes() const
WCSimRootEventHeader * GetHeader()
static void Reset(Option_t *option="")
void SetVtxs(Int_t n, Int_t i, Double_t f)
Int_t GetTubeID() const
Int_t GetNcherenkovdigihits() const
void SetNumTubesHit(Int_t i)
TLorentzVector Get4Vertex(Int_t i)
TClonesArray * GetCherenkovHits() const
WCSimRootEvent & operator=(const WCSimRootEvent &in)
Float_t GetGammaVtx(int i, int j) const
Int_t GetJmu() const
WCSimRootCherenkovDigiHit * RemoveCherenkovDigiHit(WCSimRootCherenkovDigiHit *digit)
void SetDate(int64_t d)
Float_t GetVtxs(Int_t n, Int_t i=0) const
Float_t GetVtx(Int_t i=0)
void SetPhotonIds(std::vector< int > photon_ids)
Int_t GetNumTubesHit() const
Float_t fStop[3]
Float_t GetStart(Int_t i=0) const
const WCSimRootTrigger * GetTrigger(int number) const
std::vector< Float_t > GetTriggerInfo() const
bool CompareAllVariables(const WCSimRootCherenkovHitTime *c) const
TClonesArray * fTracks
Float_t fPdir[3]
void Clear(Option_t *option="")
std::vector< Float_t > fTriggerInfo
WCSimRootPi0 * GetPi0Info()
Int_t fNcherenkovdigihits_slots
TClonesArray * GetTracks() const
Int_t GetVtxvol() const
Int_t GetStartvol() const
WCSimRootCherenkovDigiHit * AddCherenkovDigiHit(Double_t q, Double_t t, Int_t tubeid, std::vector< int > photon_ids)
void Clear(Option_t *option="")
Float_t fVtxs[MAX_N_VERTICES][4]
std::vector< int > GetPhotonIds() const
TClonesArray * fCherenkovDigiHits
bool CompareAllVariables(const WCSimRootPi0 *c) const
Int_t GetVtxsvol(Int_t i) const
void SetJp(Int_t i)
bool CompareAllVariables(const WCSimRootEvent *c, bool deep_comparison=false) const
Int_t GetJp() const
void SetTriggerInfo(TriggerType_t trigger_type, std::vector< Float_t > trigger_info)
virtual ~WCSimRootEventHeader()
Int_t GetParenttype() const
TVector3 GetVertex(Int_t i)
Int_t fMode[MAX_N_VERTICES]
std::vector< int > fPhotonIds
void SetPi0Info(Double_t pi0Vtx[3], Int_t gammaID[2], Double_t gammaE[2], Double_t gammaVtx[2][3])
Float_t fGammaVtx[2][3]
Int_t GetMode() const
WCSimRootTrigger * GetTrigger(int number)
Int_t GetNtrack() const
Float_t GetE() const
WCSimRootPi0 fPi0
WCSimRootEventHeader fEvtHdr
Float_t GetStop(Int_t i=0) const
void SetNpar(Int_t i)
void SetJmu(Int_t i)
Float_t fDir[3]
Int_t GetNtrack_slots() const
Int_t fGammaID[2]
virtual ~WCSimRootTrack()
Int_t GetNumberOfEvents() const
Float_t GetP() const
Int_t GetMode(Int_t index) const
Int_t GetNpar() const
bool CompareAllVariables(const WCSimRootCherenkovHit *c) const
TClonesArray * fCherenkovHitTimes
static void Reset(Option_t *option="")
WCSimRootTrack * AddTrack(Int_t ipnu, Int_t flag, Double_t m, Double_t p, Double_t E, Int_t startvol, Int_t stopvol, Double_t dir[3], Double_t pdir[3], Double_t stop[3], Double_t start[3], Int_t parenttype, Double_t time, Int_t id)
Int_t GetNcherenkovhits() const
TriggerType_t GetTriggerType() const
TClonesArray * GetCherenkovDigiHits() const
Int_t GetNumberOfSubEvents() const
void SetHeader(Int_t i, Int_t run, int64_t date, Int_t subevtn=1)
virtual ~WCSimRootTrigger()
bool CompareAllVariables(const WCSimRootEventHeader *c) const
Float_t GetSumQ() const
void Set(Double_t pi0Vtx[3], Int_t gammaID[2], Double_t gammaE[2], Double_t gammaVtx[2][3])
Int_t GetId() const
Int_t GetFlag() const
Int_t GetIpnu() const
void Set(Int_t i, Int_t r, int64_t d, Int_t s=1)
Int_t GetVecRecNumber() const
virtual ~WCSimRootPi0()
bool CompareAllVariables(const WCSimRootCherenkovDigiHit *c) const
static const int MAX_N_VERTICES
Definition: jhfNtuple.h:3
Int_t GetNvtxs() const
Float_t GetDir(Int_t i=0) const
TObjArray * fEventList
void SetVecRecNumber(Int_t i)
TClonesArray * fCherenkovHits
void SetMode(Int_t i)
Int_t GetTotalPe(int i) const
bool CompareAllVariables(const WCSimRootTrigger *c, bool deep_comparison=false) const
void SetVtxsvol(Int_t i, Int_t v)
WCSimRootTrack * RemoveTrack(WCSimRootTrack *track)
void SetVtx(Int_t i, Double_t f)
Float_t fStart[3]
void SetSumQ(Double_t x)
Int_t GetNcherenkovdigihits_slots() const
Int_t GetNumDigiTubesHit() const
Int_t GetNcherenkovhittimes() const
Int_t fVtxsvol[MAX_N_VERTICES]
Int_t GetStopvol() const
void SetNvtxs(Int_t i)