00001 #ifndef L2VirtualAlgo2008_h
00002 #define L2VirtualAlgo2008_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #define rdtscl_macro(low) \
00017 __asm__ __volatile__("rdtsc" : "=a" (low) : : "edx")
00018
00019 #define rdtsc_macro(low,high) \
00020 __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
00021
00022 #ifdef IS_REAL_L2 //in l2-ana environmen
00023 #include "trgStructures.h"
00024 #else
00025 #include "StDaqLib/TRG/trgStructures.h"
00026 #endif
00027
00028 #include <cassert>
00029 #include <string>
00030 #include "L2eventStream2008.h"
00031
00032 class L2EmcDb;
00033 class L2Histo;
00034 class L2VirtualAlgo2008 {
00035 public:
00036 enum EmcSwitch { kIsBad=0, kIsBtow, kIsEtow, kIsB_Etow };
00037
00038 protected:
00039
00040 EmcSwitch mSwitch;
00041
00042 std::string mOutDir1, mName1;
00043 L2EmcDb *mDb;
00044 FILE *mLogFile, *mHistFile;
00045 L2Histo *mhN;
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 L2Histo *mhTc,*mhTd,*mhTcd;
00057 L2Histo *mhRc, *mhRd, *mhRa ;
00058 int oflTrigId;
00059 int mAccept;
00060 int mEventsInRun;
00061 int mSecondsInRun;
00062 int mRunNumber;
00063 const L2BtowCalibData08 *mEveStream_btow;
00064 const L2EtowCalibData08 *mEveStream_etow;
00065
00066 enum {par_cpuTicksPerSecond=1600000000};
00067 unsigned long mComputeTimeStart, mComputeTimeStop, mComputeTimeDiff[L2eventStream2008::mxToken];
00068 unsigned long mDecisionTimeStart, mDecisionTimeStop, mDecisionTimeDiff;
00069 unsigned long long mRunStartTicks;
00070
00071 L2Histo **hA;
00072 int mxHA;
00073 void setMaxHist(int k) { assert(k>0);
00074 mxHA=k; hA=new L2Histo *[mxHA];
00075 }
00076 int finishCommonHistos();
00077
00078 void computeStart();
00079 void computeStop(int token);
00080
00081 public:
00082 L2VirtualAlgo2008(const char* name, L2EmcDb* db, char*outDir);
00083 virtual ~L2VirtualAlgo2008();
00084 void setOflTrigID(int x) {oflTrigId=x;}
00085 int getOflTrigID() {return oflTrigId;}
00086 bool isAccepted(){ return mAccept; }
00087 static int readParams(const char *fileN, int mxPar, int *iPar, float *fPar);
00088 const char *getName() { return mName1.c_str();}
00089
00090 int initRun(int runNo, int *rc_ints, float *rc_floats);
00091 void compute (int token);
00092 bool decision(int token, void **myL2Result);
00093 void finishRun();
00094
00095
00096 virtual int initRunUser(int runNo, int *rc_ints, float *rc_floats){ return 0;}
00097 virtual void computeUser(int token){};
00098 virtual bool decisionUser(int token, void **myL2Result){myL2Result=0; return true;}
00099 virtual void finishRunUser(){}
00100
00101
00102 void printCalibratedData(int token);
00103 };
00104
00105
00106 #endif