StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
L2gammaAlgo.h
1 #ifndef __L2gammaAlgo_h__
2 #define __L2gammaAlgo_h__
3 
4 #ifdef IS_REAL_L2 //in l2-ana environment
5  #include "L2VirtualAlgo.h"
6  #include "L2Histo.h"
7  #include "L2EmcDb.h"
8 
9 #else
10  #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2VirtualAlgo.h"
11  #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2EmcDb.h"
12  #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2Histo.h"
13 
14 #endif
15 
16 
17 
18 /* CHANGE THIS WITH EVERY COMPILATION ON L2 MACHINE DURING RUN */
19 #define LEVEL2_GAMMA_ALGORITHM_VERSION 0x1
20 
21 #define MAX_TOWERS 4800
22 
23 
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <math.h>
27 #include <string.h>
28 #include <assert.h> /* tmp */
29 #include <time.h>
30 #include <string>
31 
32 
33 
35 
55 class L2gammaAlgo;
56 
57 class L2gammaAlgo : public L2VirtualAlgo
58 {
59 
60  public:
61  enum { kBEmcAlgo=0, kEEmcAlgo };
62  enum { kThresh1=0, kThresh2 };
63 
64  private:
65  protected:
66 
70  unsigned short mEEmc;
71  unsigned short mBEmc;
72  unsigned short mThresholdLevel;
73  unsigned short mNumEtas;
74  unsigned short mNumPhis;
75  unsigned short mNumSubs;
76  unsigned short mNumSecs;
77  unsigned short mNumTower;
78  unsigned short mNumClust;
79  unsigned short mNumRdo;
80  const float *mEtaBins; /* points to preexisting array, no "new" allocation */
81  unsigned short mMaxADC;
82  float mMaxET;
83  float mIdealGainT;
84  int mHistogramBase;
85  unsigned short mHistogramPres;
86  unsigned short mIdThreshold; // 0=low threshold, 1=high threshold
87 
88  public:
89 
90 
91  /*
92  * The following are made publicly available for the possible
93  * use of other algorithms.
94  */
95 
96  unsigned short getNumberOfHighTowers(){ return nRdosHT; }
97  unsigned short getRdoOfHighTower(unsigned short i){ return mListOfRdosHT[i]; }
98  unsigned short rdo2tower(unsigned short rdo){ return mRdo2tower[rdo]; }
99  unsigned short tower2rdo(unsigned short tow){ return mTower2rdo[tow]; }
100 
101  unsigned short mListOfRdosHT[ MAX_TOWERS ]; /* list of rdos where HT exceeded specified threshold */
102  unsigned short mListOfRdosTP[ MAX_TOWERS ]; /* list of rdos where 3x3 "cluster" exceeded specified threshold */
103  unsigned short nRdosHT; /* number of high towers */
104  unsigned short nRdosTP; /* number of clusters (patches) */
105  float mETofTP[ MAX_TOWERS ]; /* ET of clusters (patches) */
106  unsigned short mADCofHT[ MAX_TOWERS ]; /* raw ADC of high tower */
107 
108  /*
109  * Algorithm parameters, may be set in constructor
110  * using I_par[5] and F_par[5]
111  */
112 
114  void setTowerThreshold( float pt );
116  void setPatchThreshold( float pt );
117 
118  float getTowerThreshold(){ return mTowerThreshold; }
119  float getPatchThreshold(){ return mPatchThreshold; }
120 
122  void setUseOfflineGains();
123 
124 
126  L2gammaAlgo(const char* name, L2EmcDb* db, char* outDir, int resOff);
128  ~L2gammaAlgo(){ /* nada */ };
129 
131  void init(int run, int I_par[5], float F_par[5]);
132 
134  int initRun( int run );
136  int initRun( int run, int I_par[5], float F_par[5] );
137 
138  int initRun( char *myname, int run, int I_par[5], float F_par[5] );
139 
148  bool doEvent(int inpEveId, TrgDataType* trgData, int emcIn, unsigned short *emcData );
149 
150 
153  bool doEvent( int L0trigger, int inuptEventID, TrgDataType* trgData,
154  int bemcIn, unsigned short *bemcData,
155  int eemcIn, unsigned short *eemcData );
156 
157 
158 
159  /*****
160  //
161  // There aren't supposed to be any "calorimeter specific" methods in the header file.
162  // These got slipped in while I wasn't looking. I suspect l2main already uses them.
163  // These disapeear at the end of the run.
164  //
165  bool doEventBtow( int inpEveId, TrgDataType* trgData, int bemcIn, unsigned short *bemcData )
166  { return doEvent(inpEveId,trgData, bemcIn,bemcData);};// it allows to add soe security - if you want, JB
167  bool doEventEtow(int inpEveId, TrgDataType* trgData, int eemcIn, unsigned short *eemcData )
168  { return doEvent(inpEveId,trgData, eemcIn,eemcData);};// it allows to add soe security - if you want, JB
169 
170  *****/
171 
172 
174  void clear();
175 
177  void finishRun();
178 
180  void finish();
181 
182 
184  void setLogFile( const char *fname = "./bsqueal.log" );//{ mLogFile=fopen(fname,"w"); }
185 
187  void setHistFile( const char *fname = "./bsqueal.dat" );//{ mHistFile=fopen(fname,"w"); }
188 
189 #ifdef OPT_PREPROCESS
190  void setL2input( L2gammaAlgo *in ){ mL2input=in; }
195 #endif
196 
197  private:
198  protected:
199 
200 
204 
207 
215  int mUseBbc;
216 
217  int mDefaultI_par[5];
218  float mDefaultF_par[5];
219 
222  int mNumberAcceptHT;
223  int mNumberAcceptTP;
224  int mPrescale;
225 
226  int mTowerFrequency[MAX_TOWERS];
227  int mPatchFrequency[MAX_TOWERS];
228 
231  unsigned short mTowerAdcThreshold[MAX_TOWERS];
232 
237  float mPatchAdcThreshold[MAX_TOWERS];
238 
239  /*
240  ******************************************************************
241  Thresholds on the high tower and associated 3x3 tower cluster
242  (generically refered to as a "patch" throughout this code) will be
243  initialzed at the start of the run and stored in the following
244  lookup tables. The LUTs have sufficient space to store the 4800
245  values needed by the barrel. The endcap's 720 towers will fit
246  just fine within that space.
247  ******************************************************************
248  */
249 
250 
253  unsigned short mPatchStat[MAX_TOWERS];
254  unsigned short mPatchFail[MAX_TOWERS];
255 
256  unsigned short mTowerStat[MAX_TOWERS];
257  unsigned short mTowerFail[MAX_TOWERS];
258 
260  unsigned short mRdo2tower[ MAX_TOWERS ];
261  unsigned short mTower2rdo[ MAX_TOWERS ];
262 
264  unsigned short mNumPatch[ MAX_TOWERS ];
265  unsigned short mRdoPatch[ MAX_TOWERS ][ 9 ];
266 
267  float mTowerPed[ MAX_TOWERS ];
268  float mPatchPed[ MAX_TOWERS ];
269 
270  float mTowerGain[ MAX_TOWERS ];
271  float mTowerGainIdeal[ MAX_TOWERS ];
272  float mTowerAdcCorrection[ MAX_TOWERS ];
273 
274 
275 
278  void printPatchConfig( int rdo );
279 
280 
282 
283  int mNumberLive; /* number of unmasked towers in db */
284  int mEvalTime; /* total time spent in eval in kTicks */
285 
288  void jbook();
289  void jclear();
290 
292  // FILE *mLogFile;
293  // FILE *mHistFile;
294 
295  unsigned short phibin( unsigned short sec, unsigned short sub ) { return mNumSubs * sec + sub; }
296  unsigned short tower( unsigned short phi, unsigned short eta ) { return mNumEtas * phi + eta; }
297 
298 
299 
300 };
301 
302 inline void L2gammaAlgo::setTowerThreshold(float pt)
303 {
304  mTowerThreshold=pt;
305 }
306 inline void L2gammaAlgo::setPatchThreshold(float pt)
307 {
308  mPatchThreshold=pt;
309 }
311 {
312  mUseOfflineGains=true;
313 }
314 
315 // $Log: L2gammaAlgo.h,v $
316 // Revision 1.4 2007/11/14 03:58:11 balewski
317 // cleanup of common timing measurement
318 //
319 // Revision 1.3 2007/11/08 04:02:29 balewski
320 // run on l2ana as well
321 //
322 // Revision 1.2 2007/11/02 03:03:44 balewski
323 // modified L2VirtualAlgo
324 //
325 // Revision 1.1 2007/10/25 15:30:50 balewski
326 // added L2gamma, full
327 //
328 // Revision 1.1 2006/03/29 13:08:15 balewski
329 // ver 16c
330 //
331 
332 
333 
334 #endif
unsigned short mEEmc
Definition: L2gammaAlgo.h:70
bool doEvent(int inpEveId, TrgDataType *trgData, int emcIn, unsigned short *emcData)
L2gammaAlgo(const char *name, L2EmcDb *db, char *outDir, int resOff)
class constructor
Definition: L2gammaAlgo.cxx:17
float mPatchAdcThreshold[MAX_TOWERS]
Definition: L2gammaAlgo.h:237
int mNumberInput
event counters
Definition: L2gammaAlgo.h:221
void finishRun()
cleanup for runs. output of warnings (eg hot channels) etc...
void printPatchConfig(int rdo)
float mPatchThreshold
Patch threshold.
Definition: L2gammaAlgo.h:211
unsigned short mTowerAdcThreshold[MAX_TOWERS]
Definition: L2gammaAlgo.h:231
unsigned short mRdo2tower[MAX_TOWERS]
Map to go from Rdo to Tower and Tower to Rdo.
Definition: L2gammaAlgo.h:260
void setLogFile(const char *fname="./bsqueal.log")
Set logfile for summary output (overrides constructor option)
Definition: L2gammaAlgo.cxx:11
void setPatchThreshold(float pt)
set the L2 trigger patch threshold. F_par[1]
Definition: L2gammaAlgo.h:306
L2Histo mHistos[19]
L2 histograms.
Definition: L2gammaAlgo.h:287
unsigned short mPatchStat[MAX_TOWERS]
Definition: L2gammaAlgo.h:253
int mNumberLive
Counters for error monitoring.
Definition: L2gammaAlgo.h:283
L2gammaAlgo * mL2input
Definition: L2gammaAlgo.h:203
int initRun(int run)
initialize the data structures for the next run
~L2gammaAlgo()
class destructor
Definition: L2gammaAlgo.h:128
void init(int run, int I_par[5], float F_par[5])
One time initialization.
Definition: L2gammaAlgo.cxx:66
void clear()
clear data structures for ...
void setHistFile(const char *fname="./bsqueal.dat")
Set filename for histogram output (overrides constructor option)
Definition: L2gammaAlgo.cxx:12
unsigned short mNumPatch[MAX_TOWERS]
Number and list of up to 9 neighboring towers.
Definition: L2gammaAlgo.h:264
void setUseOfflineGains()
if set, instructs the algo to correct for offline gains
Definition: L2gammaAlgo.h:310
A level-2 &quot;cluster&quot; based trigger.
Definition: L2gammaAlgo.h:57
void finish()
final output of statistics, histograms, etc...
unsigned short phibin(unsigned short sec, unsigned short sub)
Log file.
Definition: L2gammaAlgo.h:295
float mTowerThreshold
High tower threshold.
Definition: L2gammaAlgo.h:209
void setTowerThreshold(float pt)
set the L2 high tower threshold. F_par[0]
Definition: L2gammaAlgo.h:302
int mUseBbc
Option to correct for vertex effects (not in use yet)
Definition: L2gammaAlgo.h:215
int mRunNumber
Run number for the current run.
Definition: L2gammaAlgo.h:206
int mUseOfflineGains
Option to use offline gains.
Definition: L2gammaAlgo.h:213