00001 #ifndef TrigConf_L1DataDef
00002 #define TrigConf_L1DataDef
00003
00004 #include <string>
00005 #include <map>
00006 #include <vector>
00007
00008 #define declareBackwardCompatibleMethdods(TL,TU) \
00009 public: \
00010 static std::string TL##Type() { return typeConfig(TU).name; } \
00011 static unsigned int max_##TU##_Threshold_Number() { return typeConfig(TU).max; }
00012
00013 #define registerTriggerType(TU, MAX) \
00014 bool is##TU = TrigConf::L1DataDef::addConfig(TrigConf::L1DataDef::TU, #TU, MAX);
00015
00016 #define registerInternalTriggerType(TU, MAX) \
00017 bool is##TU = TrigConf::L1DataDef::addConfig(TrigConf::L1DataDef::TU, #TU, MAX, true);
00018
00019 namespace TrigConf {
00020
00021 class L1DataDef {
00022 public:
00023
00024 enum TriggerType {
00025 EM=1, TAU, MUON,
00026 JET, FJET, FJ, JE, JF, JB,
00027 XE, TE, XS,
00028 MBTS, MBTSSI, LUCID, TRT, BCM, ZDC, NIM,
00029 ZB, TH, M, BCMCMB, CALREQ, BPTX,
00030 TOPO,
00031 ALFA,
00032 BGRP = 100, RNDM, PCLK,
00033 UNDEF = 199
00034 };
00035
00036 struct TriggerTypeConfig {
00037 TriggerTypeConfig(TriggerType t=UNDEF, const std::string& n="UNDEF", unsigned int m=0, bool i=false) :
00038 type(t), name(n), max(m), internal(i) {};
00039 TriggerType type;
00040 std::string name;
00041 unsigned int max;
00042 bool internal;
00043 };
00044
00045 typedef TriggerTypeConfig InternalTriggerType;
00046
00047 typedef std::map<TriggerType, TriggerTypeConfig> TypeConfigMap_t;
00048 typedef std::map<std::string, TriggerType> STypeTypeMap_t;
00049
00050 public:
00051
00052 static void setMaxThresholdsFromL1Version(unsigned int l1version);
00053
00054 static void printMaxThresholds();
00055
00056 static TriggerType stringAsType(const std::string& type) { return g_sTypeType[type]; }
00057 static std::string& typeAsString(TriggerType tt) { return typeConfig(tt).name; }
00058
00059 static std::vector<TriggerType>& types() { return g_Types; }
00060
00061 static TypeConfigMap_t& typeConfigs() { return g_typeConfigs; }
00062 static TriggerTypeConfig& typeConfig(TriggerType tt);
00063
00064 static bool addConfig(TriggerType tt, const std::string& name, unsigned int max, bool internal=false) {
00065 g_typeConfigs.insert(TypeConfigMap_t::value_type(tt, TriggerTypeConfig(tt, name, max, internal)));
00066 g_sTypeType.insert(STypeTypeMap_t::value_type(name,tt));
00067 g_Types.push_back(tt);
00068 return true;
00069 }
00070
00071
00072
00073 declareBackwardCompatibleMethdods(em, EM);
00074 declareBackwardCompatibleMethdods(tau, TAU);
00075 declareBackwardCompatibleMethdods(muon, MUON);
00076 declareBackwardCompatibleMethdods(jet, JET);
00077 declareBackwardCompatibleMethdods(fjet, FJET);
00078 declareBackwardCompatibleMethdods(fj, FJ);
00079 declareBackwardCompatibleMethdods(jf, JF);
00080 declareBackwardCompatibleMethdods(jb, JB);
00081 declareBackwardCompatibleMethdods(xe, XE);
00082 declareBackwardCompatibleMethdods(je, JE);
00083 declareBackwardCompatibleMethdods(te, TE);
00084 declareBackwardCompatibleMethdods(xs, XS);
00085 declareBackwardCompatibleMethdods(th, TH);
00086
00087
00088 declareBackwardCompatibleMethdods(bgrp, BGRP);
00089 declareBackwardCompatibleMethdods(rndm, RNDM);
00090 declareBackwardCompatibleMethdods(pclk, PCLK);
00091
00092
00093 declareBackwardCompatibleMethdods(zdc, ZDC);
00094 declareBackwardCompatibleMethdods(trt, TRT);
00095 declareBackwardCompatibleMethdods(bcm, BCM);
00096 declareBackwardCompatibleMethdods(lucid,LUCID);
00097 declareBackwardCompatibleMethdods(mbts, MBTS);
00098 declareBackwardCompatibleMethdods(nim, NIM);
00099 declareBackwardCompatibleMethdods(bptx, BPTX);
00100
00101
00102 declareBackwardCompatibleMethdods(zb, ZB);
00103
00104 public:
00105
00106 static std::string bcmcmbType() { return "BCMCMB"; }
00107 static std::string mbtssiType() { return "MBTSSI"; }
00108 static std::string calreqType() { return "CALREQ"; }
00109
00110 static unsigned int max_M_Threshold_Number() { return max_MUON_Threshold_Number(); }
00111
00112
00113 static void setOldJEP3Cabling();
00114 static void setNewJEP3Cabling();
00115
00116
00117
00118 private:
00119 static TypeConfigMap_t g_typeConfigs;
00120 static STypeTypeMap_t g_sTypeType;
00121 static std::vector<TriggerType> g_Types;
00122 static unsigned int g_l1Version;
00123
00124 };
00125
00126 }
00127
00128 #endif