00001 #ifndef BesGlobalTrigSvc_h
00002 #define BesGlobalTrigSvc_h 1
00003
00004 #include "Trigger/IBesGlobalTrigSvc.h"
00005 #include "GaudiKernel/Service.h"
00006 #include <vector>
00007 #include <map>
00008 #include <complex>
00009 #include <fstream>
00010
00011 #include "GaudiKernel/IIncidentListener.h"
00012 #include "RealizationSvc/RealizationSvc.h"
00013 #include "RealizationSvc/IRealizationSvc.h"
00014 #include "Trigger/TrigPara.h"
00015
00016 using namespace std;
00017
00018 class IDataProviderSvc;
00019 class BesMdcTrig;
00020 class BesEmcTrig;
00021 class BesTofTrig;
00022 class BesMucTrig;
00023 class BesTMTrig;
00024
00025 class BesGlobalTrigSvc: public Service,
00026 virtual public IIncidentListener,
00027 virtual public IBesGlobalTrigSvc {
00028 public:
00029 BesGlobalTrigSvc(const std::string& name, ISvcLocator* svc);
00030 virtual ~BesGlobalTrigSvc();
00031 public:
00032 virtual StatusCode queryInterface( const InterfaceID& riid,
00033 void** ppvInterface);
00035 virtual StatusCode initialize();
00037 virtual StatusCode finalize();
00038
00039 void handle(const Incident&);
00040
00041 void startMdcTrig();
00042 void startTofTrig();
00043 void startEmcTrig();
00044 void startTMTrig();
00045
00046 StatusCode GlobalTrig();
00047
00048 inline void setEvtTime(double i) { m_evttime = i; };
00049 inline double getEvtTime() { return m_evttime; }
00050
00051 inline void setGoodEvent(bool i) { m_goodEvent = i; };
00052 inline bool getGoodEvent() { return m_goodEvent; };
00053
00054 StatusCode setTrigCondition();
00055
00056
00057 inline double getL1TC_GATE() { return L1TC_GATE; }
00058 inline double getL1TC_THRESH() { return L1TC_THRESH; }
00059 inline int getL1ETOT_L_Peak() { return L1ETOT_L_Peak; }
00060 inline int getL1ETOT_L_Sigma() { return L1ETOT_L_Sigma; }
00061 inline int getL1ETOT_M_Peak() { return L1ETOT_M_Peak; }
00062 inline int getL1ETOT_M_Sigma() { return L1ETOT_M_Sigma; }
00063 inline int getL1ETOT_BR_Peak() { return L1ETOT_BR_Peak; }
00064 inline int getL1ETOT_BR_Sigma() { return L1ETOT_BR_Sigma; }
00065 inline int getL1ETOT_EC_Peak() { return L1ETOT_EC_Peak; }
00066 inline int getL1ETOT_EC_Sigma() { return L1ETOT_EC_Sigma; }
00067 inline int getL1EBL_Z_Peak() { return L1EBL_Z_Peak; }
00068 inline int getL1EBL_Z_Sigma() { return L1EBL_Z_Sigma; }
00069 int getL1ETOT_L();
00070 int getL1ETOT_M();
00071 int getL1ETOT_BR();
00072 int getL1ETOT_EC();
00073 int getL1EBL_BR();
00074 int getL1EBL_EC();
00075 int getL1EDIFF_BR();
00076 int getL1EDIFF_EC();
00077 int getL1BLK_GATE();
00078 int getL1EBL_Z();
00079
00080 inline int getMAXMDCTRACK() { return MAXMDCTRACK; }
00081 inline double getEnergy_Ratio() { return Energy_Ratio; }
00082
00083 inline double getBarrelGate() { return emcBarrelGate; }
00084 inline double getEndGate() { return emcEndGate; }
00085 inline int getTofLayerControl() { return m_tofLayer; }
00086
00087
00088 const int getTrigChan(int i) { return m_trigChannel[i]; }
00089 const int* getTrigChan() const { return m_trigChannel; }
00090
00091 inline void setTrigChan(int i, int j) { m_trigChannel[i] = j; }
00092
00093
00094 const int getTrigCond(int i) { return m_trigCondition[i]; }
00095 const int* getTrigCond() const { return m_trigCondition; }
00096
00097 inline void setTrigCond(int i, bool j) {
00098 trigCond[i] = j;
00099 if(j) m_trigCondition[i] = 1;
00100 else m_trigCondition[i] = 0;
00101 }
00102
00103
00104 inline void setIfpass(bool i) { ifpass = i; }
00105
00106 inline bool getIfpass() { return ifpass; }
00107
00108
00109 inline void setRunMode(int mode) { m_runMode = mode; }
00110
00111 inline int getRunMode() { return m_runMode; }
00112
00113
00114
00115 inline void setSTrk_BB(bool i) { mdc_STrk_BB = i; }
00116 inline void setNStrkN(bool i) { mdc_NStrkN = i; }
00117 inline void setNStrk2(bool i) { mdc_NStrk2 = i; }
00118 inline void setNStrk1(bool i) { mdc_NStrk1 = i; }
00119 inline void setLTrk_BB(bool i) { mdc_LTrk_BB = i; }
00120 inline void setNLtrkN(bool i) { mdc_NLtrkN = i; }
00121 inline void setNLtrk2(bool i) { mdc_NLtrk2 = i; }
00122 inline void setNLtrk1(bool i) { mdc_NLtrk1 = i; }
00123 inline void setNItrk1(bool i) { mdc_NItrk1 = i; }
00124 inline void setNItrk2(bool i) { mdc_NItrk2 = i; }
00125
00126
00127 inline void setMdcStrkId(std::vector<int> i) { mdcStrkId = i; }
00128 inline void setMdcLtrkId(std::vector<int> i) { mdcLtrkId = i; }
00129
00130
00131
00132 inline bool getSTrk_BB() { return mdc_STrk_BB; }
00133 inline bool getNStrkN() { return mdc_NStrkN; }
00134 inline bool getNStrk2() { return mdc_NStrk2; }
00135 inline bool getNStrk1() { return mdc_NStrk1; }
00136 inline bool getLTrk_BB() { return mdc_LTrk_BB; }
00137 inline bool getNLtrkN() { return mdc_NLtrkN; }
00138 inline bool getNLtrk2() { return mdc_NLtrk2; }
00139 inline bool getNLtrk1() { return mdc_NLtrk1; }
00140 inline bool getNItrk1() { return mdc_NItrk1; }
00141 inline bool getNItrk2() { return mdc_NItrk2; }
00142
00143 inline std::vector<int> getMdcStrkId() { return mdcStrkId; }
00144 inline std::vector<int> getMdcLtrkId() { return mdcLtrkId; }
00145
00146
00147
00148 inline void setETofBB(bool i) { tof_ETofBB = i; }
00149 inline void setBTofBB(bool i) { tof_BTofBB = i; }
00150 inline void setNETof2(bool i) { tof_NETof2 = i; }
00151 inline void setNETof1(bool i) { tof_NETof1 = i; }
00152 inline void setNBTof2(bool i) { tof_NBTof2 = i; }
00153 inline void setNBTof1(bool i) { tof_NBTof1 = i; }
00154 inline void setNTof1(bool i) { tof_NTof1 = i; }
00155
00156
00157 inline void setTofHitPos(map<int,vector<int>,greater<int> > i) { tofHitPos = i; }
00158 inline void setBTofHitMap(vector<int> i) { btofHitMap = i; }
00159 inline void setETofHitMap(vector<int> i) { etofHitMap = i; }
00160
00161
00162
00163 inline bool getNBTof1() { return tof_NBTof1; }
00164 inline bool getNBTof2() { return tof_NBTof2; }
00165 inline bool getNETof1() { return tof_NETof1; }
00166 inline bool getNETof2() { return tof_NETof2; }
00167 inline bool getNTof1() { return tof_NTof1; }
00168 inline bool getBTofBB() { return tof_BTofBB; }
00169 inline bool getETofBB() { return tof_ETofBB; }
00170
00171
00172 inline map<int,vector<int>,greater<int> > getTofHitPos() { return tofHitPos; }
00173 inline vector<int> getBTofHitMap() { return btofHitMap; }
00174 inline vector<int> getETofHitMap() { return etofHitMap; }
00175
00176
00177
00178 inline void setNClus1(bool i) { emc_NClus1 = i; }
00179 inline void setNClus2(bool i) { emc_NClus2 = i; }
00180 inline void setNBClus1(bool i) { emc_NBClus1 = i; }
00181 inline void setNEClus1(bool i) { emc_NEClus1 = i; }
00182 inline void setBClusBB(bool i) { emc_BClusBB = i; }
00183 inline void setEClusBB(bool i) { emc_EClusBB = i; }
00184 inline void setClus_Z(bool i) { emc_Clus_Z = i; }
00185 inline void setBClus_PHI(bool i) { emc_BClus_PHI = i; }
00186 inline void setEClus_PHI(bool i) { emc_EClus_PHI = i; }
00187 inline void setBEtot_H(bool i) { emc_BEtot_H = i; }
00188 inline void setEEtot_H(bool i) { emc_EEtot_H = i; }
00189 inline void setEtot_L(bool i) { emc_Etot_L = i; }
00190 inline void setEtot_M(bool i) { emc_Etot_M = i; }
00191 inline void setBL_Z(bool i) { emc_BL_Z = i; }
00192 inline void setDiff_B(bool i) { emc_Diff_B = i; }
00193 inline void setDiff_E(bool i) { emc_Diff_E = i; }
00194 inline void setBL_BBLK(bool i) { emc_BL_BBLK = i; }
00195 inline void setBL_EBLK(bool i) { emc_BL_EBLK = i; }
00196
00197
00198 inline void setEmcNbCluster(int i) { emcNbCluster = i; }
00199 inline void setEmcNweCluster(int i) { emcNweCluster = i; }
00200 inline void setEmcNeeCluster(int i) { emcNeeCluster = i; }
00201 inline void setEmcTotE(double i) { emcTotE = i; }
00202 inline void setEmcLTotE(double i) { emcLTotE = i; }
00203 inline void setEmcRTotE(double i) { emcRTotE = i; }
00204 inline void setEmcBTotE(double i) { emcBTotE = i; }
00205 inline void setEmcETotE(double i) { emcETotE = i; }
00206 inline void setEmcLBTotE(double i) { emcLBTotE = i; }
00207 inline void setEmcRBTotE(double i) { emcRBTotE = i; }
00208 inline void setEmcWETotE(double i) { emcWETotE = i; }
00209 inline void setEmcEETotE(double i) { emcEETotE = i; }
00210 inline void setBTCEnergy(int theta, int phi, double energy) { emcBTCEnergy[theta][phi] = energy; }
00211 inline void setWETCEnergy(int theta, int phi, double energy) { emcWETCEnergy[theta][phi] = energy; }
00212 inline void setEETCEnergy(int theta, int phi, double energy) { emcEETCEnergy[theta][phi] = energy; }
00213 inline void setEmcBlockE(std::vector<double> i) { emcBlockE = i; }
00214 inline void setEmcClusId(map<int,vector<complex<int> >, greater<int> > i) { emcClusId = i; }
00215 inline void setEmcClusE(std::vector<double> i) { emcClusE = i; }
00216
00217
00218
00219 inline bool getNClus1() { return emc_NClus1; }
00220 inline bool getNClus2() { return emc_NClus2; }
00221 inline bool getNBClus1() { return emc_NBClus1; }
00222 inline bool getNEClus1() { return emc_NEClus1; }
00223 inline bool getBClusBB() { return emc_BClusBB; }
00224 inline bool getEClusBB() { return emc_EClusBB; }
00225 inline bool getClus_Z() { return emc_Clus_Z; }
00226 inline bool getBClus_PHI() { return emc_BClus_PHI; }
00227 inline bool getEClus_PHI() { return emc_EClus_PHI; }
00228 inline bool getBEtot_H() { return emc_BEtot_H; }
00229 inline bool getEEtot_H() { return emc_EEtot_H; }
00230 inline bool getEtot_L() { return emc_Etot_L; }
00231 inline bool getEtot_M() { return emc_Etot_M; }
00232 inline bool getBL_Z() { return emc_BL_Z; }
00233 inline bool getDiff_B() { return emc_Diff_B; }
00234 inline bool getDiff_E() { return emc_Diff_E; }
00235 inline bool getBL_BBLK() { return emc_BL_BBLK; }
00236 inline bool getBL_EBLK() { return emc_BL_EBLK; }
00237
00238
00239 inline std::vector<double>& getEmcBlockE() { return emcBlockE; };
00240 inline int getEmcNbCluster() { return emcNbCluster; }
00241 inline int getEmcNweCluster() { return emcNweCluster; }
00242 inline int getEmcNeeCluster() { return emcNeeCluster; }
00243 inline double getEmcTotE() { return emcTotE; }
00244 inline double getEmcLTotE() { return emcLTotE; }
00245 inline double getEmcRTotE() { return emcRTotE; }
00246 inline double getEmcBTotE() { return emcBTotE; }
00247 inline double getEmcETotE() { return emcETotE; }
00248 inline double getEmcLBTotE() { return emcLBTotE; }
00249 inline double getEmcRBTotE() { return emcRBTotE; }
00250 inline double getEmcWETotE() { return emcWETotE; }
00251 inline double getEmcEETotE() { return emcEETotE; }
00252 inline double getBTCEnergy(int theta, int phi) { return emcBTCEnergy[theta][phi]; }
00253 inline double getWETCEnergy(int theta, int phi) { return emcWETCEnergy[theta][phi]; }
00254 inline double getEETCEnergy(int theta, int phi) { return emcEETCEnergy[theta][phi]; }
00255 inline map<int,vector<complex<int> >,greater<int> > getEmcClusId() { return emcClusId; }
00256 inline std::vector<double> getEmcClusE() { return emcClusE; }
00257
00258
00259
00260 inline void setMucBB3478(bool i) { muc_BB3478 = i; }
00261 inline void setMucBB37(bool i) { muc_BB37 = i; }
00262
00263
00264 inline void setMucIndex(std::vector<int> i) { muc_index = i; }
00265 inline void setMucNtrackBR(int i) { muc_ntrackBR = i; }
00266 inline void setMucNtrackEC(int i) { muc_ntrackEC = i; }
00267 inline void setMucN3ltrackTotal(int i) { muc_n3ltracktotal = i; }
00268
00269
00270
00271 inline bool getMucBB3478() { return muc_BB3478; }
00272 inline bool getMucBB37() { return muc_BB37; }
00273
00274
00275 inline std::vector<int> getMuclayerSeg() { return muc_vlayerSeg; }
00276 inline std::vector<int> getMuchitLayer() { return muc_vhitLayer; }
00277 inline std::vector<int> getMuchitSeg() { return muc_vhitSeg; }
00278 inline std::vector<int> getMucIndex() { return muc_index; }
00279 inline int getMucNhitEE() { return muc_nhitEE; }
00280 inline int getMucNhitBR() { return muc_nhitBR; }
00281 inline int getMucNhitWE() { return muc_nhitWE; }
00282 inline int getMucNhitTotal() { return muc_nhitTotal; }
00283 inline int getMucNlayerBR() { return muc_nlayerBR; }
00284 inline int getMucNlayerWE() { return muc_nlayerWE; }
00285 inline int getMucNlayerEE() { return muc_nlayerEE; }
00286 inline int getMucNtrackBR() { return muc_ntrackBR; }
00287 inline int getMucNtrackEC() { return muc_ntrackEC; }
00288 inline int getMucN3ltrackTotal() { return muc_n3ltracktotal; }
00289
00290
00291 inline void setTMNATrk1(bool i) { tm_NATrk1 = i; }
00292 inline void setTMNATrk2(bool i) { tm_NATrk2 = i; }
00293 inline void setTMATrkBB(bool i) { tm_ATrk_BB = i; }
00294 inline void setTMNBTrk1(bool i) { tm_NBTrk1 = i; }
00295 inline void setTMNBTrk2(bool i) { tm_NBTrk2 = i; }
00296 inline void setTMBTrkBB(bool i) { tm_BTrk_BB = i; }
00297 inline void setTMNCTrk1(bool i) { tm_NCTrk1 = i; }
00298 inline void setTMNCTrk2(bool i) { tm_NCTrk2 = i; }
00299 inline void setTMCTrkBB(bool i) { tm_CTrk_BB = i; }
00300
00301
00302 inline bool getTMNATrk1() { return tm_NATrk1; }
00303 inline bool getTMNATrk2() { return tm_NATrk2; }
00304 inline bool getTMATrkBB() { return tm_ATrk_BB; }
00305 inline bool getTMNBTrk1() { return tm_NBTrk1; }
00306 inline bool getTMNBTrk2() { return tm_NBTrk2; }
00307 inline bool getTMBTrkBB() { return tm_BTrk_BB; }
00308 inline bool getTMNCTrk1() { return tm_NCTrk1; }
00309 inline bool getTMNCTrk2() { return tm_NCTrk2; }
00310 inline bool getTMCTrkBB() { return tm_CTrk_BB; }
00311
00312
00313 inline int getEndCapMode() { return tm_endcap; }
00314
00315 private:
00316 BesMdcTrig* m_MdcTrig;
00317 BesTofTrig* m_TofTrig;
00318 BesEmcTrig* m_EmcTrig;
00319 BesMucTrig* m_MucTrig;
00320 BesTMTrig* m_TMTrig;
00321
00322 std::vector<int> trigOut;
00323
00324 std::vector<std::string> trigChannel;
00325 std::vector<std::string> trigCondName;
00326 std::vector<std::string> trigTable;
00327 std::vector<int> channelNo;
00328
00329 double m_evttime;
00330
00331 bool m_goodEvent;
00332
00333
00334
00335 bool mdc_STrk_BB,mdc_NStrkN,mdc_NStrk2,mdc_NStrk1;
00336 bool mdc_LTrk_BB,mdc_NLtrkN,mdc_NLtrk2,mdc_NLtrk1;
00337 bool mdc_NItrk1,mdc_NItrk2;
00338
00339
00340 std::vector<int> mdcStrkId;
00341 std::vector<int> mdcLtrkId;
00342
00343
00344
00345 bool tof_NBTof1,tof_NBTof2,tof_NETof1,tof_NETof2,tof_NTof1;
00346 bool tof_BTofBB,tof_ETofBB;
00347
00348 map<int,vector<int>,greater<int> > tofHitPos;
00349 std::vector<int> btofHitMap;
00350 std::vector<int> etofHitMap;
00351
00352
00353
00354 bool emc_NClus1, emc_NClus2, emc_NBClus1, emc_NEClus1, emc_BClusBB,emc_EClusBB,emc_Clus_Z,emc_BClus_PHI;
00355 bool emc_EClus_PHI,emc_BEtot_H,emc_EEtot_H,emc_Etot_L,emc_Etot_M,emc_BL_Z;
00356 bool emc_Diff_B,emc_Diff_E,emc_BL_BBLK,emc_BL_EBLK;
00357
00358
00359 double emcBarrelGate, emcEndGate;
00360 double emcTotE,emcLTotE,emcRTotE,emcBTotE,emcETotE,emcLBTotE,emcRBTotE,emcWETotE,emcEETotE;
00361 int emcNbCluster,emcNweCluster,emcNeeCluster;
00362 std::vector<double> emcBlockE;
00363 std::vector<double> emcClusE;
00364 map<int,vector<complex<int> >, greater<int> > emcClusId;
00365 double emcBTCEnergy[TrigConf::TCTHETANO_B][TrigConf::TCPHINO_B];
00366 double emcWETCEnergy[TrigConf::TCTHETANO_E][TrigConf::TCPHINO_E];
00367 double emcEETCEnergy[TrigConf::TCTHETANO_E][TrigConf::TCPHINO_E];
00368
00369
00370
00371 bool muc_BB3478, muc_BB37;
00372
00373
00374 int muc_nhitEE, muc_nhitBR, muc_nhitWE, muc_nhitTotal;
00375 int muc_nlayerBR, muc_nlayerWE, muc_nlayerEE;
00376 int muc_ntrackBR, muc_ntrackEC;
00377 int muc_n3ltracktotal;
00378 std::vector<int> muc_vlayerSeg;
00379 std::vector<int> muc_vhitLayer;
00380 std::vector<int> muc_vhitSeg;
00381 std::vector<int> muc_index;
00382
00383
00384
00385 bool tm_NATrk1, tm_NATrk2, tm_ATrk_BB, tm_NBTrk1, tm_NBTrk2, tm_BTrk_BB, tm_NCTrk1, tm_NCTrk2, tm_CTrk_BB;
00386
00387
00388 std::vector<std::string> vTrigLine;
00389
00390
00391 std::vector<int> vTrigCond;
00392
00393
00394 bool trigCond[48];
00395
00396
00397 int m_trigCondition[48];
00398 int m_trigChannel[16];
00399
00400
00401 bool ifpass;
00402
00403
00404 int m_runMode;
00405 int m_tofLayer;
00406 std::string trigTableFile;
00407
00408
00409 double L1TC_GATE;
00410 double L1TC_THRESH;
00411 int L1ETOT_L;
00412 int L1ETOT_L_Peak;
00413 int L1ETOT_L_Sigma;
00414 int L1ETOT_M;
00415 int L1ETOT_M_Peak;
00416 int L1ETOT_M_Sigma;
00417 int L1ETOT_BR;
00418 int L1ETOT_BR_Peak;
00419 int L1ETOT_BR_Sigma;
00420 int L1ETOT_EC;
00421 int L1ETOT_EC_Peak;
00422 int L1ETOT_EC_Sigma;
00423 int L1EBL_BR;
00424 int L1EBL_EC;
00425 int L1EDIFF_BR;
00426 int L1EDIFF_EC;
00427 int L1BLK_GATE;
00428 int L1EBL_Z;
00429 int L1EBL_Z_Peak;
00430 int L1EBL_Z_Sigma;
00431 int MAXMDCTRACK;
00432 double Energy_Ratio;
00433
00434 int tm_endcap;
00435
00436
00437 RealizationSvc* m_RealizationSvc;
00438
00439 static const std::string COND_NAME[48];
00440 };
00441 #endif