AMSDST
myEvent.h
Go to the documentation of this file.
1 // Authors: M.Duranti - INFN di Perugia
2 #ifndef myEvent_h
3 #define myEvent_h
4 
5 
6 #include <TString.h>
7 #include <TObjArray.h>
8 #include <vector>
9 #include "myParticle.h"
10 #include "myMC.h"
11 #include "myStatus.h"
12 #include "myHeader.h"
13 #include "myBeta.h"
14 #include "myBetaH.h"
15 #include "myTrdTrack.h"
16 #include "myTrdTrackPlus.h"
17 #include "myTrdK.h"
18 #include "myTrdQtFromTrTrack.h"
19 #include "myRichRing.h"
20 #include "myEcalShower.h"
21 #include "myTrTrack.h"
22 #include "myTrTrackPlus.h"
23 #include "myEcalShowerPlus.h"
24 #include "myRichRingPlus.h"
25 #include "myBetaPlus.h"
26 #include "myBetaHPlus.h"
27 #include "myRTI.h"
28 #include <cmath>
29 #include <map>
30 class myUser1;
31 
32 typedef std::map <unsigned int,myRTI> myRTI_m;
33 
34 #define EARTHRADIUS 6371.2
35 
36 class myEvent: public TObject {
37  protected:
38  static myEvent* ptr;
39 
40  public:
42  myEvent();
43  myEvent(const myEvent&);
45  ~myEvent();
46 
47  static myEvent* gethead();
48  static void printptr();
49  virtual void init();
50 
51  bool kMC;
52 
53  myMC* mm;
54 
56 
57  myUser1* us1;
58 
60 
61  std::vector<myParticle*> vmp;
62 
64  std::vector<myTrTrack*> vmt;
66  std::vector<myEcalShower*> vme;
68  std::vector<myTrdTrack*> vmu;
70  std::vector<myBeta*> vmb;
72  std::vector<myBetaH*> vmbh;
74  std::vector<myRichRing*> vmr;
75 
77  std::vector<myTrTrackPlus*> vmtp;
78 
79  std::vector<myTrdTrackPlus*> vmup;
81  std::vector<myTrdK*> vmuktp;
82 
83  std::vector<myTrdK*> vmukup;
84 
85  std::vector<myTrdQtFromTrTrack*> vmuqtp;
86 
87  std::vector<myEcalShowerPlus*> vmep;
88 
89  std::vector<myBetaPlus*> vmbp;
90 
91  std::vector<myBetaHPlus*> vmbhp;
92 
93  std::vector<myRichRingPlus*> vmrp;
94 
95 
96  inline int NmyParticle() { return vmp.size(); };
97 
98  inline int NmyTrTrack() { return vmt.size(); };
99  inline int NmyTrdTrack() { return vmu.size(); };
100  inline int NmyEcalShower() { return vme.size(); };
101  inline int NmyBetaH() { return vmbh.size(); };
102  inline int NmyBeta() { return vmb.size(); };
103  inline int NmyRichRing() { return vmr.size(); };
104 
105  inline int NmyTrTrackPlus() { return vmtp.size(); };
106  inline int NmyTrdTrackPlus() { return vmup.size(); };
107  inline int NmyTrdKFromTrTrack() { return vmuktp.size(); };
108  inline int NmyTrdKFromTrdTrack() { return vmukup.size(); };
109  inline int NmyTrdQtFromTrTrack() { return vmuqtp.size(); };
110  inline int NmyEcalShowerPlus() { return vmep.size(); };
111  inline int NmyBetaHPlus() { return vmbhp.size(); };
112  inline int NmyBetaPlus() { return vmbp.size(); };
113  inline int NmyRichRingPlus() { return vmrp.size(); };
114 
115  inline int nmyParticle() { return vmp.size(); };
116 
117  inline int nmyTrTrack() { return vmt.size(); };
118  inline int nmyTrdTrack() { return vmu.size(); };
119  inline int nmyEcalShower() { return vme.size(); };
120  inline int nmyBetaH() { return vmbh.size(); };
121  inline int nmyBeta() { return vmb.size(); };
122  inline int nmyRichRing() { return vmr.size(); };
123 
124  inline int nmyTrTrackPlus() { return vmtp.size(); };
125  inline int nmyTrdTrackPlus() { return vmup.size(); };
126  inline int nmyTrdKFromTrTrack() { return vmuktp.size(); };
127  inline int nmyTrdKFromTrdTrack() { return vmukup.size(); };
128  inline int nmyTrdQtFromTrTrack() { return vmuqtp.size(); };
129  inline int nmyEcalShowerPlus() { return vmep.size(); };
130  inline int nmyBetaHPlus() { return vmbhp.size(); };
131  inline int nmyBetaPlus() { return vmbp.size(); };
132  inline int nmyRichRingPlus() { return vmrp.size(); };
133 
135  inline int TimeJMDC() { return fHeader.Time[0]; };
137  inline int MuTimeJMDC() { return fHeader.Time[1]; };
138 
139  inline int UTime() { return fHeader.Time[0]; };
140 
141 #ifdef _WITHGBATCH_
142 
143  int GetRTI(AMSSetupR::RTI & a);
144 #endif
145 
146  int GetRTI(myRTI & a);
147  int LoadRTI(unsigned int t1, unsigned int t2, const char *dir=0);
148  int GetRTI(myRTI & a, unsigned int xtime);
149 
153  int GetRTIdL1L9(int extlay,myPoint &nxyz, myPoint &dxyz,unsigned int xtime,unsigned int dt, int rti_flag=0);
154 
155  protected:
156  /* If in future we want to use the same philosofy of gbatch (for example if a "Rebuild" can change the vectors size)
157  Short_t fNmyParticle;//!
158 
159  Short_t fNmyTrTrack;//!
160  Short_t fNmyEcalShower;//!
161  Short_t fNmyTrdTrack;//!
162  Short_t fNmyBeta;//!
163  Short_t fNmyBetaH;//!
164  Short_t fNmyRichRing;//!
165 
166  Short_t fNmyTrTrackPlus;//!
167  Short_t fNmyEcalShowerPlus;//!
168  Short_t fNmyTrdKFromTrTrack;//!
169  Short_t fNmyTrdQtFromTrTrack;//!
170  Short_t fNmyBetaPlus;//!
171  Short_t fNmyBetaHPlus;//!
172  Short_t fNmyRichRingPlus;//!
173 
174  public:
175  inline int nmyParticle() { return fNmyParticle; };
176 
177  inline int nmyTrTrack() { return fNmyTrTrack; };
178  inline int nmyTrdTrack() { return fNmyTrdTrack; };
179  inline int nmyEcalShower() { return fNmyEcalShower; };
180  inline int nmyBetaH() { return fNmyBetaH; };
181  inline int nmyBeta() { return fNmyBeta; };
182  inline int nmyRichRing() { return fNmyRichRing; };
183 
184  inline int nmyTrTrackPlus() { return fNmyTrTrackPlus; };
185  inline int nmyTrdKFromTrTrack() { return fNmyTrdKFromTrTrack; };
186  inline int nmyTrdQtFromTrTrack() { return fNmyTrdQtFromTrTrack; };
187  inline int nmyEcalShowerPlus() { return fNmyEcalShowerPlus; };
188  inline int nmyBetaHPlus() { return fNmyBetaHPlus; };
189  inline int nmyBetaPlus() { return fNmyBetaPlus; };
190  inline int nmyRichRingPlus() { return fNmyRichRingPlus; };
191  */
192 
193  protected:
194  Int_t _nParticle;
195 
196  Int_t _nTrdTrack;
198  Int_t _nTrdRawHit;
200 
202 
203  Int_t _nBetaH;
204 
205  Int_t _nBeta;
206 
207  Int_t _nRichRing;
208  Int_t _nRichHit;
209 
210  Int_t _nTrTrack;
212  Int_t _nTrRawClusterL[9];
213  Int_t _nTrCluster;
214  Int_t _nTrRecHit;
215 
216  Double32_t _UTCTime;
217 
218  public:
219  inline Int_t nParticle() { return _nParticle;}
220 
221  inline Int_t nTrdTrack() { return _nTrdTrack;}
222  inline Int_t nTrdCluster() { return _nTrdCluster;}
223  inline Int_t nTrdRawHit() { return _nTrdRawHit;}
224  inline Int_t nTrdSegment() { return _nTrdSegment;}
225 
226  inline Int_t nEcalShower() { return _nEcalShower;}
227 
228  inline Int_t nBetaH() { return _nBetaH;}
229 
230  inline Int_t nBeta() { return _nBeta;}
231 
232  inline Int_t nRichRing() { return _nRichRing;}
233  inline Int_t nRichHit() { return _nRichHit;}
234 
235  inline Int_t nTrTrack() { return _nTrTrack;}
236  inline Int_t nTrRawCluster() { return _nTrRawCluster;}
237  inline Int_t nTrRawClusterL(int ilay) { return (ilay<9) ? _nTrRawClusterL[ilay] : -99999;}
238  inline Int_t nTrCluster() { return _nTrCluster;}
239  inline Int_t nTrRecHit() { return _nTrRecHit;}
240 
241 
242  inline int IsBadRun (const char *reason){
243  if ( std::string(reason)=="" || ReasonToBeBadRun.Length()==0 ) return _IsBadRun;
244  else if ( std::string(reason)==ReasonToBeBadRun.Data() && ReasonToBeBadRun.Length()!=0 ) return 1;
245  else return 0;
246  }
247 #ifdef _WITHGBATCH_
248  inline bool isBadRun(unsigned int run){
249  for(unsigned int k=0;k<AMSEventR::BadRunList.size();k++){
250  if(run==AMSEventR::BadRunList[k])return true;
251  }
252  return false;
253  }
254 #endif
255 
256  inline int imyParticle(int index) { return pmyParticle(index)!=0?index:-999; }
257 
258  inline int imyTrTrack(int index) { return pmyTrTrack(index)!=0?index:-999; }
259  inline int imyEcalShower(int index) { return pmyEcalShower(index)!=0?index:-999; }
260  inline int imyTrdTrack(int index) { return pmyTrdTrack(index)!=0?index:-999; }
261  inline int imyBeta(int index) { return pmyBeta(index)!=0?index:-999; }
262  inline int imyBetaH(int index) { return pmyBetaH(index)!=0?index:-999; }
263  inline int imyRichRing(int index) { return pmyRichRing(index)!=0?index:-999; }
264  inline int imyTrTrackPlus(int index) { return pmyTrTrackPlus(index)!=0?index:-999; }
265  inline int imyTrdTrackPlus(int index) { return pmyTrdTrackPlus(index)!=0?index:-999; }
266  inline int imyEcalShowerPlus(int index) { return pmyEcalShowerPlus(index)!=0?index:-999; }
267  inline int imyTrdKFromTrTrack(int index) { return pmyTrdKFromTrTrack(index)!=0?index:-999; }
268  inline int imyTrdQtFromTrTrack(int index) { return pmyTrdQtFromTrTrack(index)!=0?index:-999; }
269  inline int imyBetaPlus(int index) { return pmyBetaPlus(index)!=0?index:-999; }
270  inline int imyBetaHPlus(int index) { return pmyBetaHPlus(index)!=0?index:-999; }
271  inline int imyRichRingPlus(int index) { return pmyRichRingPlus(index)!=0?index:-999; }
272 
273  myParticle* pmyParticle(int index);
274 
275  myTrTrack* pmyTrTrack(int index);
276  myTrdTrack* pmyTrdTrack(int index);
277  myEcalShower* pmyEcalShower(int index);
278  myBeta* pmyBeta(int index);
279  myBetaH* pmyBetaH(int index);
280  myRichRing* pmyRichRing(int index);
281  myTrTrackPlus* pmyTrTrackPlus(int index);
282  myTrdTrackPlus* pmyTrdTrackPlus(int index);
284  myTrdK* pmyTrdKFromTrTrack(int index);
285  myTrdK* pmyTrdKFromTrdTrack(int index);
287  myBetaPlus* pmyBetaPlus(int index);
288  myBetaHPlus* pmyBetaHPlus(int index);
289  myRichRingPlus* pmyRichRingPlus(int index);
290 
291  myParticle* pmyParticleByMySelf(int index);
292 
293  myTrTrack* pmyTrTrackByMySelf(int index);
295  myTrdTrack* pmyTrdTrackByMySelf(int index);
296  myBeta* pmyBetaByMySelf(int index);
297  myBetaH* pmyBetaHByMySelf(int index);
298  myRichRing* pmyRichRingByMySelf(int index);
305  myBetaPlus* pmyBetaPlusByMySelf(int index);
306  myBetaHPlus* pmyBetaHPlusByMySelf(int index);
308 
309  public:
310  int TofHSelection();
311  int RebuildTrigPatt(int &L1TrMemPatt,int &PhysTrPatt);
312 
313  // for the events with the pointer null no myRTI object is written on disk (i.e. no space wasted!!!)
315 
318 
320  bool RTIValid(){ return RTI != nullptr; }
321 
322  Float_t LiveTime;
323  UInt_t DeltaT;
324  Double32_t Lvl1Time;
325  Double32_t Lvl1TimePrevious;
326  Double32_t DeltaTMine;
327  Int_t TofFlag1;
328  Int_t TofFlag2;
329  Int_t JMembPatt;
330  Int_t PhysBPatt;
333  Int_t TofPatt1[4];
334  Int_t TofPatt2[4];
335  Int_t EcalFlag;
336  Float_t TrigRates[19];
337 
338  Int_t nAnti;
339  Int_t AntiPatt;
340 
342  Int_t _IsBadRun;
343  Int_t RunAnalCat;
344 
345  UInt_t Run;
346  UInt_t Event;
347 
348 
349  Double32_t DeltaTJMDC;
351  UInt_t TimeJMDCLast;
352  Double32_t Duration;
353 
357  inline Double32_t UTCTime(){ return _UTCTime;}
358 
359  Int_t nTofClusterL[4];
360  Int_t nTofCluster;
361 
362  Double32_t SensorA;
363  Double32_t SensorC;
364  Double32_t SensorK;
365  Double32_t SensorL;
366  Double32_t SensorM;
367  Double32_t Plane1N_M70;
368  Double32_t Plane1N_M71;
369  Double32_t Plane1N_M72;
370  Double32_t Plane1N_M73;
371  Double32_t Sensor8;
372 
373  Int_t isInShadow(myPoint &pt, int ipart);
374  bool isMC(){ return mm != nullptr ; }
375  bool isISS(){ return !isMC() and Run > 1305795600; }
376  bool isTB(){ return !isMC() and Run < 1305795600; }
377 
379  inline Double_t Lat(){ return 180.0*fHeader.ThetaS/M_PI; };
381  inline Double_t Lon(){ Double_t _Lon=180.0*fHeader.PhiS/M_PI; _Lon=((_Lon)<180)?(_Lon):((_Lon)-360); return _Lon; };
383  inline Double_t Alt(){ return (fHeader.RadS/100000.0 - EARTHRADIUS); };
384 
385  bool InSAA();
386 
387  Double32_t GeoMagSphericalCoo[3];
388  inline Double_t Lshell(){ return (GeoMagSphericalCoo[0]/(EARTHRADIUS*100000.0))/pow(cos(GeoMagSphericalCoo[2]*TMath::DegToRad()), 2.0); };
389 
391  Double32_t LatPred;
392 
393  Double32_t LonPred;
394 
395  Double32_t AltPred;
396 
398  Double32_t LatCGM;
399 
400  Double32_t LonCGM;
401 
402  Double32_t RadCGM;
403 
404  inline Double_t VerticalCutOffCGM(){
405  Double_t co=14.5*pow(cos(LatCGM), 4.0)/pow(RadCGM, 2.0);
406  // printf("Vertical CutOff CGM = %f GV\n", co); //only for debug
407  return co;
408  }
409 
411  inline Double_t LatMAG(){return fHeader.ThetaM;};
413  inline Double_t LonMAG(){return ((fHeader.PhiM)>0)?(fHeader.PhiM):((fHeader.PhiM)+2*M_PI);};
415  inline Double_t RadMAG(){return fHeader.RadS/(100000.0*EARTHRADIUS);};
416 
418  inline Double_t VerticalCutOffMAG(){
419  Double_t co=14.5*pow(cos(LatMAG()), 4.0)/pow((RadMAG()), 2.0);
420  // printf("Vertical CutOff MAG = %f GV\n", co); //only for debug
421  return co;
422  }
423 
424 #ifndef CGM
425  Double_t GeoMagLatitude(){return LatMAG();};
426  Double_t GeoMagLongitude(){return LonMAG();};
427  Double_t VerticalCutOff(){return VerticalCutOffMAG();};
428 #else
429 
430  Double_t GeoMagLatitude(){return ((RadCGM)<999.0)?LatCGM:LatMAG();};
432  Double_t GeoMagLongitude(){return ((RadCGM)<999.0)?LonCGM:LonMAG();};
434  Double_t VerticalCutOff(){return ((RadCGM)<999.0)?VerticalCutOffCGM:VerticalCutOffMAG();};
435 #endif
436 
438  Double32_t MaxGeoCutOff_p;
440  Double32_t MaxGeoCutOff_n;
442  inline Double_t MaxGeoCutOff(){return std::max(fabs(MaxGeoCutOff_p), fabs(MaxGeoCutOff_n));};
443 
444  Double32_t Field;
445 
446  UInt_t Lenght;
447  UInt_t Tdr;
448  UInt_t Udr;
449  UInt_t Sdr;
450  UInt_t Rdr;
451  UInt_t Edr;
452  UInt_t L1dr;
453  UInt_t L3dr;
454  ULong64_t L3Error;
455  UInt_t L3VEvent;
456  UInt_t L3TimeD;
457  UShort_t JINJStatus[4];
458  UChar_t JError[24];
459 
460  inline bool Status(unsigned int group, unsigned int bitgroup){ return true;}//WTF?! in AMS/CC/root.C is like this...
461 
462  inline bool Status(unsigned int bit){
463  if (!ms) return true; // --> mean error...
464  if (bit<64) return (ms->fStatus & (1<<bit));
465  else return false;
466  }
467 
468  //--------------------------------------
469 
470  myUser1* user1() {return us1;}
471 
473  static Double32_t zlay[9];
474 
475  //methods
476  void Clear(Option_t* =nullptr);
477 
478  public:
479  ClassDef(myEvent,30);
480 };
481 #endif
482 
483 #ifdef _WITHGBATCH_
484 
485 #ifndef myEventFiller_h
486 #define myEventFiller_h
487 
488 class myEventFiller : public myEvent
489 {
490  public:
492  myEventFiller();
494  ~myEventFiller();
495 
496  virtual void init();
497 
498  static myEventFiller* gethead();
499  inline static myEvent* getfather() {return ptr;};
500 
501  /*
502  static bool NoTRDPlus;//!
503  static bool NoTRDKPlus;//!
504  static bool NoTRDQtPlus;//!
505  static bool NoEcalPlus;//!
506  static bool NoBetaPlus;//!
507  static bool NoBetaHPlus;//!
508  static bool NoRichPlus;//!
509  static bool NoTrackerPlus;//!
510  static bool NoHeaderTree;//!
511  */
512 
513  TObjArray tmp_filler;
514 
515  MCEventgR* mcevent;
516 
517  AMSEventR* pev;
518 
519  HeaderR* head;
520 
521  Level1R* lvl1;
522 
523  std::vector<TrRecHitR>* tkrechitsevent;
524 
525  AMSSetupR* setup;
526 
527  AMSSetupR::SlowControlR* slowcontrol;
528 
529  DaqEventR* daqev;
530 
531 #if !defined _B524_ && !defined _B550_ && !defined _B572_
532  AMSSetupR::DSPError* pdsperr;
533 #endif
534 
535  //methods
536  virtual void Clear(Option_t* =nullptr);
537 
538  void Fill(int fTree, Long64_t fEntry);
539  void Fill();
540  // void RebuildLkTrk(myParticle& mp, myTrTrackPlus& mt, myEcalShower& me, myBetaPlus& mb);
541 
542  ClassDef(myEventFiller,2);
543 };
544 #endif // #ifdef _WITHGBATCH_
545 
546 static bool pnpoly(int npol, float *xp, float *yp, float x, float y);
547 
548 #endif