00001
00002
00003 #ifndef STAR_StBemcTriggerSimu
00004 #define STAR_StBemcTriggerSimu
00005
00006 #include "TObject.h"
00007 #include "TString.h"
00008 #include <utility>
00009 #include <vector>
00010 #include <set>
00011 #include <map>
00012 #include "TDatime.h"
00013
00014 using std::pair;
00015 using std::vector;
00016 using std::map;
00017
00018 #include "StTriggerUtilities/StVirtualTriggerSimu.h"
00019 #include "StTriggerUtilities/StTriggerSimuResult.h"
00020
00021 #define kNPatches 300
00022 #define kNJet 12
00023 #define kNTowers 4800
00024 #define k12bits 4096
00025 #define kNCrates 30
00026 #define kNChannels 160
00027 #define kNSeq 10
00028 #define kL0DsmModule 30
00029 #define kL0DsmInputs 10
00030 #define kNLayer0out 36
00031 #define kL1DsmModule 6
00032 #define kL1DsmInputs 6
00033 #define kL2DsmModule 1
00034
00035 class StEvent;
00036 class StEmcDecoder;
00037 class StEmcGeom;
00038 class StEmcADCtoEMaker;
00039 class StBemcTables;
00040 class St_db_Maker;
00041 class StBemcTriggerDbThresholds;
00042 class StTriggerSimuMaker;
00043 class TDataSet;
00044 class St_db_Maker;
00045 class TList;
00046 class TH2;
00047
00048 class DSMLayer_B001_2009;
00049 class DSMLayer_B101_2009;
00050
00051 class StBemcTriggerSimu : public StVirtualTriggerSimu {
00052 private:
00053 std::vector<int> mFiredTriggers;
00054 std::set<int> mAllTriggers;
00055
00056 std::vector<int> layer0;
00057 std::vector<int> layer1;
00058 std::vector<int> layer2;
00059
00060 TObjArray *mHList;
00061
00062
00063 StEmcDecoder *mDecoder;
00064 StBemcTriggerDbThresholds *mDbThres;
00065
00066
00067 StEvent *mEvent;
00068 StEmcGeom *mGeo;
00069 StEmcADCtoEMaker* mAdc2e;
00070 StBemcTables *mTables;
00071 St_db_Maker *starDb;
00072 StTriggerSimuMaker *mHeadMaker;
00073 int mConfig;
00074
00075
00076 Int_t HT_FEE_Offset;
00077 Int_t DSM_HTStatus[kNPatches];
00078 Int_t DSM_TPStatus[kNPatches];
00079 Int_t TowerStatus[kNTowers];
00080 Float_t TowerGain[kNTowers];
00081 unsigned long bitConvValue[kNTowers];
00082 Int_t year,yyyymmdd,hhmmss;
00083 UInt_t timestamp;
00084
00085
00086 int TriggerPatchFromTowerId[kNTowers];
00087 int TriggerPatchFromCrate[kNCrates][kNSeq];
00088
00089 Int_t adc12[kNTowers];
00090 Int_t adc10[kNTowers],adc08[kNTowers];
00091 Float_t ped12[kNTowers];
00092 Int_t FEEped[kNTowers];
00093 Int_t HTadc06[kNTowers];
00094
00095 unsigned long pedTargetValue;
00096 Float_t ped12Diff, ped10Diff;
00097 Int_t ped10DiffI;
00098 Int_t LUT[kNPatches];
00099 Int_t formula[kNCrates][kNSeq], numMaskTow[kNPatches];
00100 Int_t LUTscale[kNCrates][kNSeq], LUTped[kNCrates][kNSeq], LUTsig[kNCrates][kNSeq], LUTpow[kNCrates][kNSeq];
00101 char buffer[10];
00102
00103
00104 Int_t L0_HT_ADC[kNPatches], L0_TP_ADC[kNPatches], L0_TP_PED[kNPatches];
00105
00106
00107 Int_t DSM0_TP_SUM[kL0DsmModule], DSM0_TP_SUM_J1[kL0DsmModule], DSM0_TP_SUM_J3[kL0DsmModule];
00108 Int_t DSM1_JP_ADC[kL0DsmModule];
00109
00110
00111
00112
00113 Int_t DSM0_HT_Bit[kL0DsmModule],DSM0_TP_Bit[kL0DsmModule],DSM0_HTTP_Bit[kL0DsmModule];
00114 Int_t DSM0_HT_Bit_J3[kL0DsmModule],DSM0_TP_Bit_J3[kL0DsmModule],DSM0_HTTP_Bit_J3[kL0DsmModule];
00115 Int_t DSM0_HT_Bit_J1[kL0DsmModule],DSM0_TP_Bit_J1[kL0DsmModule],DSM0_HTTP_Bit_J1[kL0DsmModule];
00116 Int_t DSM0_HT_2Bit[kL0DsmModule],DSM0_HT_2Bit_J1[kL0DsmModule],DSM0_HT_2Bit_J3[kL0DsmModule];
00117 Int_t DSM0_HT_Thr3_Bit[kL0DsmModule], DSM0_HT_Thr3_Bit_J1[kL0DsmModule], DSM0_HT_Thr3_Bit_J3[kL0DsmModule];
00118 Int_t DSM0_HT_Masked_Bit[kL0DsmModule], DSM0_HT_Masked_Bit_J1[kL0DsmModule], DSM0_HT_Masked_Bit_J3[kL0DsmModule];
00119
00120
00121 Int_t DSM0_HT_tp_Bit[kL0DsmInputs], DSM0_TP_tp_Bit[kL0DsmInputs], DSM0_HTTP_tp_Bit[kL0DsmInputs];
00122 Int_t DSM0_HT_Thr3_tp_Bit[kL0DsmModule], DSM0_HT_Thr3_tp_Bit_J1[kL0DsmModule], DSM0_HT_Thr3_tp_Bit_J3[kL0DsmModule];
00123 Int_t DSM0_HT_tp_Bit_J3[kL0DsmInputs], DSM0_TP_tp_Bit_J3[kL0DsmInputs],DSM0_HTTP_tp_Bit_J3[kL0DsmInputs];
00124 Int_t DSM0_HT_tp_Bit_J1[kL0DsmInputs], DSM0_TP_tp_Bit_J1[kL0DsmInputs],DSM0_HTTP_tp_Bit_J1[kL0DsmInputs];
00125 Int_t L0_16bit_Out[kNLayer0out];
00126
00127 Int_t DSM1_JP_Bit[kL1DsmModule], DSM1_HT_Bit[kL1DsmModule], DSM1_TP_Bit[kL1DsmModule], DSM1_HTTP_Bit[kL1DsmModule];
00128 Int_t DSM1_HTj1_Bit[kL1DsmModule], DSM1_HTj0_Bit[kL1DsmModule], DSM1_HT3_Bit[kL1DsmModule];
00129 Int_t DSM1_ETOT_ADC[kL1DsmModule];
00130
00131 Int_t DSM1_JP_jp_Bit[kNJet];
00132
00133
00134 Int_t HT6bit_adc_holder[kNTowers];
00135 Int_t TP6bit_adc_holder[kNPatches];
00136 Int_t JP_adc_holder[kNJet];
00137
00138
00139 vector< pair<int,int> > mJpsiCandidates;
00140
00141
00142 DSMLayer_B001_2009* mB001;
00143 DSMLayer_B101_2009* mB101;
00144
00145 void getTowerStatus();
00146 void getDSM_TPStatus();
00147 void getDSM_HTStatus();
00148 void getLUT();
00149 void getPed();
00150 void GetTriggerPatchFromCrate(int crate, int seq, int& triggerPatch) const;
00151 void FEEout();
00152 void FEEini2009(int runNumber);
00153 void FEEout2009();
00154 void switchoff(int& x, int n) const { x &= ~(1 << n); }
00155 void switchon (int& x, int n) const { x |= (1 << n); }
00156 void simulateFEEfailure();
00157 void get2006_DSMLayer0();
00158 void get2006_DSMLayer1();
00159 void get2006_DSMLayer2();
00160 void get2006_JpsiCandidates(const vector<int>& towerIds1, const vector<int>& towerIds2);
00161 void get2007_DSMLayer0();
00162 void get2007_DSMLayer1();
00163 void get2007_DSMLayer2();
00164 void get2008dAu_DSMLayer0();
00165 void get2008dAu_DSMLayer1();
00166 void get2008dAu_DSMLayer2();
00167 void get2008pp_DSMLayer0();
00168 void get2008pp_DSMLayer1();
00169 void get2008pp_DSMLayer2();
00170 void get2009_DSMLayer0();
00171 void get2009_DSMLayer1();
00172
00173
00174
00175 #ifdef DEBUG
00176
00177 TH2 *mBEMCLayer0HT6bit;
00178 TH2 *mBEMCLayer0TP6bit;
00179 TH2 *mBEMCLayer0HT6bitDiff;
00180 TH2 *mBEMCLayer0TP6bitDiff;
00181 TH2 *mBEMCLayer1HTBits;
00182 TH2 *mBEMCLayer1HTBitsDiff;
00183 TH2 *mBEMCLayer1TPBits;
00184 TH2 *mBEMCLayer1TPBitsDiff;
00185 TH2 *mBEMCLayer1HTTPBits;
00186 TH2 *mBEMCLayer1HTTPBitsDiff;
00187 TH2 *mBEMCLayer1PatchSum;
00188 TH2 *mBEMCLayer1PatchSumDiff;
00189 TH2 *mBEMCLayer1HTmaskBits;
00190 TH2 *mBEMCLayer1HTmaskDiff;
00191 TH2 *mBEMCLayer1HTthr3Bits;
00192 TH2 *mBEMCLayer1HTthr3Diff;
00193 TH2 *mBEMCLayer2PatchSum;
00194 TH2 *mBEMCLayer2PatchSumDiff;
00195 TH2 *mBEMCLayer2HT3Bits;
00196 TH2 *mBEMCLayer2HT3BitsDiff;
00197 TH2 *mBEMCLayer2HTTPBits;
00198 TH2 *mBEMCLayer2HTTPBitsDiff;
00199 TH2 *mBEMCLayer2TPBits;
00200 TH2 *mBEMCLayer2TPBitsDiff;
00201 TH2 *mBEMCLayer2JPBits;
00202 TH2 *mBEMCLayer2JPBitsDiff;
00203 TH2 *mBEMCLayer2HTj0Bits;
00204 TH2 *mBEMCLayer2HTj0BitsDiff;
00205 TH2 *mBEMCLayer2HTj1Bits;
00206 TH2 *mBEMCLayer2HTj1BitsDiff;
00207
00208 #endif
00209
00210 public:
00211 StBemcTriggerSimu();
00212 virtual ~StBemcTriggerSimu();
00213
00214 void Init();
00215 void InitRun(int runnumber);
00216 void Clear();
00217 void Make();
00218
00219 bool isCorrupted() const;
00220 StTriggerSimuDecision triggerDecision(int trigId);
00221 const vector<int>& triggerIds() const { return mFiredTriggers; }
00222
00223 void setHeadMaker(StTriggerSimuMaker *maker) { mHeadMaker = maker; }
00224
00225 void setHList(TObjArray * x){mHList=x;}
00226
00227 int barrelJetPatchTh(int i) const;
00228 int barrelHighTowerTh(int i) const;
00229
00230 int barrelJetPatchAdc(int jp) const;
00231 int barrelHighTowerAdc(int towerId) const { return getHT6bitAdc(towerId); }
00232
00233 public:
00234 enum {kOnline=1, kOffline, kExpert};
00235 void setConfig(int x) {mConfig=x;}
00236
00238 void setTables(StBemcTables *tab) { mTables = tab; }
00239 StEmcDecoder* getDecoder() const { return mDecoder; }
00240 StBemcTables* getTables() const { return mTables; }
00241
00242
00243 Int_t* getBEMC_FEE_HT_ADC() {return L0_HT_ADC;}
00244 Int_t* getBEMC_FEE_TP_ADC() {return L0_TP_ADC;}
00245 int getHT6bitAdc(int towerId) const { return HT6bit_adc_holder[towerId-1]; }
00246 int getTP6bitAdc(int triggerPatch) const { return TP6bit_adc_holder[triggerPatch]; }
00247
00248
00249 Int_t* getBEMC_L0_OUT() {return L0_16bit_Out;}
00250 Int_t* getBEMC_L0_SUM() {return DSM0_TP_SUM;}
00251 Int_t* getBEMC_L0_SUM_J1() {return DSM0_TP_SUM_J1;}
00252 Int_t* getBEMC_L0_SUM_J3() {return DSM0_TP_SUM_J3;}
00253 Int_t* getBEMC_L0_HT_Bit() {return DSM0_HT_Bit;}
00254 Int_t* getBEMC_L0_HT_Bit_J1() {return DSM0_HT_Bit_J3;}
00255 Int_t* getBEMC_L0_HT_Bit_J3() {return DSM0_HT_Bit_J1;}
00256 Int_t* getBEMC_L0_TP_Bit() {return DSM0_TP_Bit;}
00257 Int_t* getBEMC_L0_TP_Bit_J1() {return DSM0_TP_Bit_J3;}
00258 Int_t* getBEMC_L0_TP_Bit_J3() {return DSM0_TP_Bit_J1;}
00259 Int_t* getBEMC_L0_HTTP_Bit() {return DSM0_HTTP_Bit;}
00260 Int_t* getBEMC_L0_HTTP_Bit_J1() {return DSM0_HTTP_Bit_J3;}
00261 Int_t* getBEMC_L0_HTTP_Bit_J3() {return DSM0_HTTP_Bit_J1;}
00262
00263
00264
00265 Int_t* getBEMC_L1_JP() {return DSM1_JP_Bit;}
00266 Int_t* getBEMC_L1_HT() {return DSM1_HT_Bit;}
00267 Int_t* getBEMC_L1_TP() {return DSM1_TP_Bit;}
00268 Int_t* getBEMC_L1_HTTP() {return DSM1_HTTP_Bit;}
00269 Int_t* getBEMC_L1_ETOT_ADC() {return DSM1_ETOT_ADC;}
00270
00271
00272 const vector< pair<int, int> > getTowersAboveThreshold(int trigId) const;
00273 const vector< pair<int, int> > getTriggerPatchesAboveThreshold(int trigId) const;
00274 const vector< pair<int, int> > getJetPatchesAboveThreshold(int trigId) const;
00275 const vector< pair<int,int> >& getJpsiCandidates() const { return mJpsiCandidates; }
00276 int numberOfJpsiCandidates() const { return mJpsiCandidates.size(); }
00277 const pair<int,int>& jpsiCandidate(int i) const { return mJpsiCandidates[i]; }
00278 int jpsiCandidateFirstTowerId(int i) const { return mJpsiCandidates[i].first; }
00279 int jpsiCandidateSecondTowerId(int i) const { return mJpsiCandidates[i].second; }
00280
00281
00282 int getTowerThreshold(int trigId, int dsmid) const;
00283 int getTriggerPatchThreshold(int trigId, int dsmid) const;
00284 int getJetPatchThreshold(int trigId, int dsmid) const;
00285
00286
00287 DSMLayer_B001_2009* get2009_DSMLayer0_Result() { return mB001; }
00288 DSMLayer_B101_2009* get2009_DSMLayer1_Result() { return mB101; }
00289
00290
00291 void fillStEmcTriggerDetector();
00292
00293 ClassDef(StBemcTriggerSimu, 1);
00294 };
00295 #endif