StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
L2upsilon2006.hh
1 //
2 // Pibero Djawwotho <pibero@iucf.indiana.edu>
3 // Indiana University
4 // October 23, 2007
5 //
6 
7 #ifndef L2upsilon2006_hh
8 #define L2upsilon2006_hh
9 
10 #include <cstdio>
11 #include <vector>
12 #include <list>
13 #include <ctime>
14 
15 using namespace std;
16 class L2Histo;
17 #ifdef IS_REAL_L2 //in l2-ana environmen
18  #include "L2VirtualAlgo.h"
19 #else
20  #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2VirtualAlgo.h"
21 #endif
22 
23 struct BemcTower {
24  int softId;
25  int crate;
26  int crateSeq;
27  float gain;
28  float x;
29  float y;
30  float z;
31  float eta;
32  float phi;
33  float pedestal;
34  int stat;
35  int fail;
36  int numberOfNeighbors;
37  int neighbor[8];
38 };
39 
40 
41 class L2EmcDb;
42 
43 struct BemcCluster {
44  float x;
45  float y;
46  float z;
47  float E;
48 };
49 
50 class Timer {
51 public:
52  void start();
53  time_t time() const;
54 
55 private:
56  time_t startTime;
57 };
58 
59 class L2upsilon2006 : public L2VirtualAlgo {
60 public:
61  L2upsilon2006(const char* name, L2EmcDb* db, char* outDir, int resOff);
62  ~L2upsilon2006();
63 
64  int initRun(int runNumber, int* userInt, float* userFloat);
65  bool doEvent(int L0trg, int eventNumber, TrgDataType* trgData,
66  int bemcIn, unsigned short* bemcData,
67  int eemcIn, unsigned short* eemcData);
68  void finishRun();
69  void print();
70  void readGeomXYZ(const char *fname);
71 
72 private:
73  void findSeedTowers(vector<int>& L0Seeds, vector<int>& L2Seeds);
74  void calcCluster(int rdo);
75 
76  void createHistograms();
77  void writeHistograms();
78  void resetHistograms();
79  void deleteHistograms();
80 
81  const char* timeString() const;
82 
83  BemcTower bemcTower[4800];
84  BemcCluster bemcCluster[4800];
85  int mSoftIdToRdo[4801];
86  int mPhiEtaToRdo[120][40];
87  TrgDataType* trgData;
88  unsigned short* bemcData;
89 
90  FILE* mLogFile;
91 
92  int mRunNumber;
93  bool mUnfinished;
94  int mEventsSeen;
95  int mEventsAccepted;
96 
97  // float parameters
98  float mMinL0ClusterEnergy;
99  float mMinL2ClusterEnergy;
100  float mMinInvMass;
101  float mMaxInvMass;
102  float mMaxCosTheta;
103 
104  // int parameters
105  int mL0SeedThreshold;
106  int mL2SeedThreshold;
107  int mUseCtb;
108  int mUseVertexZ;
109  int mNumberOfTowersPerCluster;
110 
111  // Histograms
112  list<L2Histo*> mHistograms;
113  L2Histo* hL0SeedTowers;
114  L2Histo* hL2SeedTowers;
115  L2Histo* hNumberOfL0Seeds;
116  L2Histo* hNumberOfL2Seeds;
117  L2Histo* hInvMass;
118  L2Histo* hTime;
119  L2Histo* hEnergyOfL0Cluster;
120  L2Histo* hEnergyOfL2Cluster;
121  L2Histo* hCosTheta;
122  L2Histo* hVertexZ;
123  L2Histo* hCtbIndex;
124  L2Histo* hHighTowers;
125  L2Histo* hL0rate;
126  L2Histo* hL2rate;
127 
128 
129  // Timer
130  Timer timer;
131 };
132 
133 inline void Timer::start() { startTime = std::time(0); }
134 inline time_t Timer::time() const { return std::time(0) - startTime; }
135 
136 inline const char* L2upsilon2006::timeString() const
137 {
138  time_t t = time(0);
139  return ctime(&t);
140 }
141 
142 #endif