StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
L2VirtualAlgo2008.h
1 #ifndef L2VirtualAlgo2008_h
2 #define L2VirtualAlgo2008_h
3 
4 
5 /*************************************************************
6  * $Id: L2VirtualAlgo2008.h,v 1.6 2009/08/26 19:33:57 fine Exp $
7  * \author Jan Balewski, IUCF, 2006
8  *************************************************************
9  * Descripion:
10  * all actual L2 algos should inherit from it the 4 methods
11  *************************************************************
12  */
13 
14 //#include "/asm-i386/msr.h" /* for rdtscl */
15 // A great suggestion from Pibero, to use ASM macro directly
16 #define rdtscl_macro(low) \
17  __asm__ __volatile__("rdtsc" : "=a" (low) : : "edx")
18 
19 #define rdtsc_macro(low,high) \
20  __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
21 
22 #ifdef IS_REAL_L2 //in l2-ana environmen
23  #include "trgStructures.h"
24 #else
25  #include "StDaqLib/TRG/trgStructures.h"
26 #endif
27 
28 #include <cassert>
29 #include <string>
30 #include "L2eventStream2008.h"
31 
32 class L2EmcDb;
33 class L2Histo;
35  public:
36  enum EmcSwitch { kIsBad=0, kIsBtow, kIsEtow, kIsB_Etow }; // changes action of some methods
37 
38  protected:
39  //..... main Barrel/Endcap/Both switch
40  EmcSwitch mSwitch; // use enum above
41 
42  std::string mOutDir1, mName1;
43  L2EmcDb *mDb;
44  FILE *mLogFile, *mHistFile;
45  L2Histo *mhN; /* Neve(case),
46  bins: [0-4],[10-14], reserved for virtual08 algo
47  0 - # of input events
48  1 - # of calls computeUser()
49  2 - # of calls decisionUser()
50  3,4 - free
51  5...9 - user algo
52  10 - # of accepted events
53  11..14 - free
54  15...19 - user algo
55  */
56  L2Histo *mhTc,*mhTd,*mhTcd;/* time/eve : compute, decision, compute+decision */
57  L2Histo *mhRc, *mhRd, *mhRa ; /* rate/sec: compute, decision, accepted */
58  int oflTrigId; // important only for off-line analysis /w Makers
59  int mAccept;
60  int mEventsInRun;
61  int mSecondsInRun;
62  int mRunNumber;
63  const L2BtowCalibData08 *mEveStream_btow;
64  const L2EtowCalibData08 *mEveStream_etow;
65 
66  enum {par_cpuTicksPerSecond=1600000000};
67  unsigned long mComputeTimeStart, mComputeTimeStop, mComputeTimeDiff[L2eventStream2008::mxToken];
68  unsigned long mDecisionTimeStart, mDecisionTimeStop, mDecisionTimeDiff;
69  unsigned long long mRunStartTicks;
70 
71  L2Histo **hA; // my private HBOOK@L2
72  int mxHA; // set by user
73  void setMaxHist(int k) { assert(k>0);
74  mxHA=k; hA=new L2Histo *[mxHA];
75  }
76  int finishCommonHistos();
77 
78  void computeStart();
79  void computeStop(int token);
80 
81  public:
82  L2VirtualAlgo2008(const char* name, L2EmcDb* db, char*outDir);
83  virtual ~L2VirtualAlgo2008(); //memory leak NOT taken care off
84  void setOflTrigID(int x) {oflTrigId=x;} //only for Maker-analysis
85  int getOflTrigID() {return oflTrigId;} //only for Maker-analysis
86  bool isAccepted(){ return mAccept; } // only for Maker-analysis
87  static int readParams(const char *fileN, int mxPar, int *iPar, float *fPar);
88  const char *getName() { return mName1.c_str();}
89 
90  int initRun(int runNo, int *rc_ints, float *rc_floats);
91  void compute (int token);
92  bool decision(int token, void **myL2Result);
93  void finishRun();
94 
95  // implement algo specific operations in the virtual functions
96  virtual int initRunUser(int runNo, int *rc_ints, float *rc_floats){ return 0;}
97  virtual void computeUser(int token){};
98  virtual bool decisionUser(int token, void **myL2Result){myL2Result=0; return true;}
99  virtual void finishRunUser(){}// at the end of each run
100 
101  // read-only access to current 'global' event, updated in compute
102  void printCalibratedData(int token);
103 };
104 
105 
106 #endif