StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
St_tpcChargeEventC.h
1 #ifndef St_tpcChargeEventC_h
2 #define St_tpcChargeEventC_h
3 #include "TChair.h"
4 #include "tables/St_tpcChargeEvent_Table.h"
5 #include "TArrayD.h"
6 #include "TArrayF.h"
7 
8 
9 class St_tpcChargeEventC : public TChair {
10  public:
11  static St_tpcChargeEventC* instance();
12 
13  tpcChargeEvent_st *Struct(Int_t i = 0) {return ((St_tpcChargeEvent*) Table())->GetTable()+i;}
14  int nChargeEvents() {return Struct()->nChargeEvents;}
15  unsigned int* eventBunchCrossingsLow() {return Struct()->eventBunchCrossingsLow;}
16  unsigned int* eventBunchCrossingsHigh() {return Struct()->eventBunchCrossingsHigh;}
17  float* eventCharges() {return Struct()->eventCharges;}
18  int badBunch() {return Struct()->badBunch;}
19 
20  unsigned int eventBunchCrossingLow(int idx) {return eventBunchCrossingsLow()[idx]; }
21  unsigned int eventBunchCrossingHigh(int idx) {return eventBunchCrossingsHigh()[idx]; }
22  unsigned long long eventBunchCrossing(int idx) {return (((unsigned long long) (eventBunchCrossingHigh(idx))) << 32)
23  + ((unsigned long long) (eventBunchCrossingLow(idx))); }
24  float eventCharge(int idx) {return eventCharges()[idx];}
25 
26  // user functions for getting the charge and time since charge
27 
28  void lastChargeTime(unsigned long long bunchCrossingNumber, float& charge, double& timeSinceCharge) {
29  int idx = indexBeforeBunchCrossing(bunchCrossingNumber);
30  charge = eventCharge(idx);
31  timeSinceCharge = timeDifference(bunchCrossingNumber,idx);
32  }
33 
34  // must call findLastChargeTime() before getLastChargeTime()
35  void findLastchargeTime(unsigned long long bunchCrossingNumber) {
36  lastChargeTime(bunchCrossingNumber, localStoreCharge, localStoreTimeSinceCharge);
37  }
38  void getLastChargeTime(float& charge, double& timeSinceCharge) {
39  charge = localStoreCharge;
40  timeSinceCharge = localStoreTimeSinceCharge;
41  }
42 
43  // must call findChargeTimes() before getCharges() and getTimes()
44  int findChargeTimes(unsigned long long bunchCrossingNumber, unsigned long long bunchCrossingWindow);
45  int findChargeTimes(unsigned long long bunchCrossingNumber, double timeWindow=1.9);
46  TArrayF* getCharges() { return &localStoreCharges; }
47  TArrayD* getTimes() { return &localStoreTimesSinceCharges; }
48 
49  protected:
50  St_tpcChargeEventC(St_tpcChargeEvent *table=0) : TChair(table) {}
51  virtual ~St_tpcChargeEventC() {fgInstance = 0;}
52  double timeDifference(unsigned long long bunchCrossingNumber, int idx);
53  int indexBeforeBunchCrossing(unsigned long long bunchCrossingNumber);
54  private:
55  int localSearchLowerIndex = 0;
56  int localSearchUpperIndex = -1;
57  float localStoreCharge = 0;
58  double localStoreTimeSinceCharge = 0;
59  TArrayF localStoreCharges;
60  TArrayD localStoreTimesSinceCharges;
61  static St_tpcChargeEventC* fgInstance;
62  ClassDef(St_tpcChargeEventC,1)
63 };
64 #endif
Definition: TChair.h:27