00001
00002
00003
00004
00005
00006
00007 #ifndef L2upsilon2006_hh
00008 #define L2upsilon2006_hh
00009
00010 #include <cstdio>
00011 #include <vector>
00012 #include <list>
00013 #include <ctime>
00014
00015 using namespace std;
00016 class L2Histo;
00017 #ifdef IS_REAL_L2 //in l2-ana environmen
00018 #include "L2VirtualAlgo.h"
00019 #else
00020 #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2VirtualAlgo.h"
00021 #endif
00022
00023 struct BemcTower {
00024 int softId;
00025 int crate;
00026 int crateSeq;
00027 float gain;
00028 float x;
00029 float y;
00030 float z;
00031 float eta;
00032 float phi;
00033 float pedestal;
00034 int stat;
00035 int fail;
00036 int numberOfNeighbors;
00037 int neighbor[8];
00038 };
00039
00040
00041 class L2EmcDb;
00042
00043 struct BemcCluster {
00044 float x;
00045 float y;
00046 float z;
00047 float E;
00048 };
00049
00050 class Timer {
00051 public:
00052 void start();
00053 time_t time() const;
00054
00055 private:
00056 time_t startTime;
00057 };
00058
00059 class L2upsilon2006 : public L2VirtualAlgo {
00060 public:
00061 L2upsilon2006(const char* name, L2EmcDb* db, char* outDir, int resOff);
00062 ~L2upsilon2006();
00063
00064 int initRun(int runNumber, int* userInt, float* userFloat);
00065 bool doEvent(int L0trg, int eventNumber, TrgDataType* trgData,
00066 int bemcIn, unsigned short* bemcData,
00067 int eemcIn, unsigned short* eemcData);
00068 void finishRun();
00069 void print();
00070 void readGeomXYZ(const char *fname);
00071
00072 private:
00073 void findSeedTowers(vector<int>& L0Seeds, vector<int>& L2Seeds);
00074 void calcCluster(int rdo);
00075
00076 void createHistograms();
00077 void writeHistograms();
00078 void resetHistograms();
00079 void deleteHistograms();
00080
00081 const char* timeString() const;
00082
00083 BemcTower bemcTower[4800];
00084 BemcCluster bemcCluster[4800];
00085 int mSoftIdToRdo[4801];
00086 int mPhiEtaToRdo[120][40];
00087 TrgDataType* trgData;
00088 unsigned short* bemcData;
00089
00090 FILE* mLogFile;
00091
00092 int mRunNumber;
00093 bool mUnfinished;
00094 int mEventsSeen;
00095 int mEventsAccepted;
00096
00097
00098 float mMinL0ClusterEnergy;
00099 float mMinL2ClusterEnergy;
00100 float mMinInvMass;
00101 float mMaxInvMass;
00102 float mMaxCosTheta;
00103
00104
00105 int mL0SeedThreshold;
00106 int mL2SeedThreshold;
00107 int mUseCtb;
00108 int mUseVertexZ;
00109 int mNumberOfTowersPerCluster;
00110
00111
00112 list<L2Histo*> mHistograms;
00113 L2Histo* hL0SeedTowers;
00114 L2Histo* hL2SeedTowers;
00115 L2Histo* hNumberOfL0Seeds;
00116 L2Histo* hNumberOfL2Seeds;
00117 L2Histo* hInvMass;
00118 L2Histo* hTime;
00119 L2Histo* hEnergyOfL0Cluster;
00120 L2Histo* hEnergyOfL2Cluster;
00121 L2Histo* hCosTheta;
00122 L2Histo* hVertexZ;
00123 L2Histo* hCtbIndex;
00124 L2Histo* hHighTowers;
00125 L2Histo* hL0rate;
00126 L2Histo* hL2rate;
00127
00128
00129
00130 Timer timer;
00131 };
00132
00133 inline void Timer::start() { startTime = std::time(0); }
00134 inline time_t Timer::time() const { return std::time(0) - startTime; }
00135
00136 inline const char* L2upsilon2006::timeString() const
00137 {
00138 time_t t = time(0);
00139 return ctime(&t);
00140 }
00141
00142 #endif