00001 #ifndef __L2gammaAlgo_h__
00002 #define __L2gammaAlgo_h__
00003
00004 #ifdef IS_REAL_L2 //in l2-ana environment
00005 #include "L2VirtualAlgo.h"
00006 #include "L2Histo.h"
00007 #include "L2EmcDb.h"
00008
00009 #else
00010 #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2VirtualAlgo.h"
00011 #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2EmcDb.h"
00012 #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2Histo.h"
00013
00014 #endif
00015
00016
00017
00018
00019 #define LEVEL2_GAMMA_ALGORITHM_VERSION 0x1
00020
00021
00022 typedef unsigned short ushort;
00023
00024 #define MAX_TOWERS 4800
00025
00026
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <math.h>
00030 #include <string.h>
00031 #include <assert.h>
00032 #include <time.h>
00033 #include <string>
00034
00035
00036
00038
00058 class L2gammaAlgo;
00059
00060 class L2gammaAlgo : public L2VirtualAlgo
00061 {
00062
00063 public:
00064 enum { kBEmcAlgo=0, kEEmcAlgo };
00065 enum { kThresh1=0, kThresh2 };
00066
00067 private:
00068 protected:
00069
00073 ushort mEEmc;
00074 ushort mBEmc;
00075 ushort mThresholdLevel;
00076 ushort mNumEtas;
00077 ushort mNumPhis;
00078 ushort mNumSubs;
00079 ushort mNumSecs;
00080 ushort mNumTower;
00081 ushort mNumClust;
00082 ushort mNumRdo;
00083 const float *mEtaBins;
00084 ushort mMaxADC;
00085 float mMaxET;
00086 float mIdealGainT;
00087 int mHistogramBase;
00088 ushort mHistogramPres;
00089 ushort mIdThreshold;
00090
00091 public:
00092
00093
00094
00095
00096
00097
00098
00099 ushort getNumberOfHighTowers(){ return nRdosHT; }
00100 ushort getRdoOfHighTower(ushort i){ return mListOfRdosHT[i]; }
00101 ushort rdo2tower(ushort rdo){ return mRdo2tower[rdo]; }
00102 ushort tower2rdo(ushort tow){ return mTower2rdo[tow]; }
00103
00104 ushort mListOfRdosHT[ MAX_TOWERS ];
00105 ushort mListOfRdosTP[ MAX_TOWERS ];
00106 ushort nRdosHT;
00107 ushort nRdosTP;
00108 float mETofTP[ MAX_TOWERS ];
00109 ushort mADCofHT[ MAX_TOWERS ];
00110
00111
00112
00113
00114
00115
00117 void setTowerThreshold( float pt );
00119 void setPatchThreshold( float pt );
00120
00121 float getTowerThreshold(){ return mTowerThreshold; }
00122 float getPatchThreshold(){ return mPatchThreshold; }
00123
00125 void setUseOfflineGains();
00126
00127
00129 L2gammaAlgo(const char* name, L2EmcDb* db, char* outDir, int resOff);
00131 ~L2gammaAlgo(){ };
00132
00134 void init(int run, int I_par[5], float F_par[5]);
00135
00137 int initRun( int run );
00139 int initRun( int run, int I_par[5], float F_par[5] );
00140
00141 int initRun( char *myname, int run, int I_par[5], float F_par[5] );
00142
00151 bool doEvent(int inpEveId, TrgDataType* trgData, int emcIn, unsigned short *emcData );
00152
00153
00156 bool doEvent( int L0trigger, int inuptEventID, TrgDataType* trgData,
00157 int bemcIn, unsigned short *bemcData,
00158 int eemcIn, unsigned short *eemcData );
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00177 void clear();
00178
00180 void finishRun();
00181
00183 void finish();
00184
00185
00187 void setLogFile( const char *fname = "./bsqueal.log" );
00188
00190 void setHistFile( const char *fname = "./bsqueal.dat" );
00191
00192 #ifdef OPT_PREPROCESS
00197 void setL2input( L2gammaAlgo *in ){ mL2input=in; }
00198 #endif
00199
00200 private:
00201 protected:
00202
00203
00206 L2gammaAlgo *mL2input;
00207
00209 int mRunNumber;
00210
00212 float mTowerThreshold;
00214 float mPatchThreshold;
00216 int mUseOfflineGains;
00218 int mUseBbc;
00219
00220 int mDefaultI_par[5];
00221 float mDefaultF_par[5];
00222
00224 int mNumberInput;
00225 int mNumberAcceptHT;
00226 int mNumberAcceptTP;
00227 int mPrescale;
00228
00229 int mTowerFrequency[MAX_TOWERS];
00230 int mPatchFrequency[MAX_TOWERS];
00231
00234 ushort mTowerAdcThreshold[MAX_TOWERS];
00235
00240 float mPatchAdcThreshold[MAX_TOWERS];
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00256 ushort mPatchStat[MAX_TOWERS];
00257 ushort mPatchFail[MAX_TOWERS];
00258
00259 ushort mTowerStat[MAX_TOWERS];
00260 ushort mTowerFail[MAX_TOWERS];
00261
00263 ushort mRdo2tower[ MAX_TOWERS ];
00264 ushort mTower2rdo[ MAX_TOWERS ];
00265
00267 ushort mNumPatch[ MAX_TOWERS ];
00268 ushort mRdoPatch[ MAX_TOWERS ][ 9 ];
00269
00270 float mTowerPed[ MAX_TOWERS ];
00271 float mPatchPed[ MAX_TOWERS ];
00272
00273 float mTowerGain[ MAX_TOWERS ];
00274 float mTowerGainIdeal[ MAX_TOWERS ];
00275 float mTowerAdcCorrection[ MAX_TOWERS ];
00276
00277
00278
00281 void printPatchConfig( int rdo );
00282
00283
00285
00286 int mNumberLive;
00287 int mEvalTime;
00288
00290 L2Histo mHistos[19];
00291 void jbook();
00292 void jclear();
00293
00295
00296
00297
00298 ushort phibin( ushort sec, ushort sub ) { return mNumSubs * sec + sub; }
00299 ushort tower( ushort phi, ushort eta ) { return mNumEtas * phi + eta; }
00300
00301
00302
00303 };
00304
00305 inline void L2gammaAlgo::setTowerThreshold(float pt)
00306 {
00307 mTowerThreshold=pt;
00308 }
00309 inline void L2gammaAlgo::setPatchThreshold(float pt)
00310 {
00311 mPatchThreshold=pt;
00312 }
00313 inline void L2gammaAlgo::setUseOfflineGains()
00314 {
00315 mUseOfflineGains=true;
00316 }
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337 #endif