CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/L1TriggerConfig/L1GtConfigProducers/interface/L1GtTriggerMenuConfigOnlineProd.h

Go to the documentation of this file.
00001 #ifndef L1GtConfigProducers_L1GtTriggerMenuConfigOnlineProd_h
00002 #define L1GtConfigProducers_L1GtTriggerMenuConfigOnlineProd_h
00003 
00020 // system include files
00021 #include "boost/shared_ptr.hpp"
00022 #include "boost/lexical_cast.hpp"
00023 
00024 #include <string>
00025 #include <vector>
00026 #include <iomanip>
00027 #include <iostream>
00028 
00029 // user include files
00030 //   base class
00031 #include "CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h"
00032 
00033 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00034 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00035 
00036 #include "CondFormats/L1TObjects/interface/L1GtMuonTemplate.h"
00037 #include "CondFormats/L1TObjects/interface/L1GtCaloTemplate.h"
00038 #include "CondFormats/L1TObjects/interface/L1GtEnergySumTemplate.h"
00039 #include "CondFormats/L1TObjects/interface/L1GtJetCountsTemplate.h"
00040 #include "CondFormats/L1TObjects/interface/L1GtCastorTemplate.h"
00041 #include "CondFormats/L1TObjects/interface/L1GtHfBitCountsTemplate.h"
00042 #include "CondFormats/L1TObjects/interface/L1GtHfRingEtSumsTemplate.h"
00043 #include "CondFormats/L1TObjects/interface/L1GtCorrelationTemplate.h"
00044 #include "CondFormats/L1TObjects/interface/L1GtBptxTemplate.h"
00045 #include "CondFormats/L1TObjects/interface/L1GtExternalTemplate.h"
00046 
00047 // forward declarations
00048 
00049 // class declaration
00050 class L1GtTriggerMenuConfigOnlineProd :
00051         public L1ConfigOnlineProdBase<L1GtTriggerMenuRcd, L1GtTriggerMenu>
00052 {
00053 
00054 public:
00055 
00057     L1GtTriggerMenuConfigOnlineProd(const edm::ParameterSet&);
00058 
00060     ~L1GtTriggerMenuConfigOnlineProd();
00061 
00063     virtual boost::shared_ptr<L1GtTriggerMenu> newObject(const std::string& objectKey);
00064 
00066     void init(const int numberConditionChips);
00067 
00068 
00069 private:
00070 
00072 
00073     struct TableMenuGeneral {
00074         std::string menuInterface;
00075         std::string menuImplementation;
00076         std::string algoImplTag;
00077         std::string scalesKey;
00078     };
00079 
00080     struct TableMenuAlgo {
00081         short bitNumberSh;
00082         std::string algName;
00083         std::string algAlias;
00084         std::string logExpression;
00085     };
00086 
00087     struct TableMenuAlgoCond {
00088         short bitNumberSh;
00089         float condIndexF;
00090         std::string condFK;
00091     };
00092 
00093     struct TableMenuCond {
00094         std::string cond;
00095         std::string condCategory;
00096         std::string condType;
00097         std::string gtObject1;
00098         std::string gtObject2;
00099         bool condGEq;
00100         short countIndex;
00101         short countThreshold;
00102 
00103         // FIXME - Oracle / Coral pretends that chargeCorrelation is bool in OMDS
00104         //         can not be - it has three values...
00105         bool chargeCorrelation;
00106         std::string objectParameter1FK;
00107         std::string objectParameter2FK;
00108         std::string objectParameter3FK;
00109         std::string objectParameter4FK;
00110         std::string deltaEtaRange;
00111         std::string deltaPhiRange;
00112     };
00113 
00114     struct TableMenuObjectParameters {
00115         std::string opId;
00116         short ptHighThreshold;
00117         short ptLowThreshold;
00118         bool enableMip;
00119         bool enableIso;
00120         bool requestIso;
00121         bool energyOverflow;
00122         float etThreshold;
00123         std::string etaRange;
00124         std::string phiRange;
00125         short phiHigh;
00126         short phiLow;
00127         std::string qualityRange;
00128         bool charge;
00129 
00130     };
00131 
00132     struct TableMenuTechTrig {
00133         short bitNumberSh;
00134         std::string techName;
00135     };
00136 
00138 
00140     bool tableMenuGeneralFromDB(const std::string& gtSchema, const std::string& objKey);
00141 
00143     bool tableMenuAlgoFromDB(const std::string& gtSchema, const std::string& objKey);
00144 
00146     bool tableMenuAlgoCondFromDB(const std::string& gtSchema, const std::string& objKey);
00147 
00149     bool tableMenuCondFromDB(const std::string& gtSchema, const std::string& objKey);
00150 
00152     bool tableMenuObjectParametersFromDB(const std::string& gtSchema, const std::string& objKey);
00153 
00155     bool tableMenuTechTrigFromDB(const std::string& gtSchema, const std::string& objKey);
00156 
00157 private:
00158 
00161     const std::map<int, std::string> condIndexNameMap(const short bitNr) const;
00162 
00164     std::string convertLogicalExpression(const std::string&, const std::map<int, std::string>&) const;
00165 
00167     int chipNumber(short) const;
00168 
00170     void buildAlgorithmMap();
00171 
00173     void buildTechnicalTriggerMap();
00174 
00176     L1GtConditionCategory strToEnumCondCategory(const std::string& strCategory);
00177 
00179     L1GtConditionType strToEnumCondType(const std::string& strType);
00180 
00182     L1GtObject strToEnumL1GtObject(const std::string& strObject);
00183 
00185     void splitHexStringInTwo64bitWords(
00186             const std::string& hexStr, std::string& hex0WordStr, std::string& hex1WordStr);
00187 
00189     std::list<int> listChipNumber(const std::string&);
00190 
00191     void fillMuonObjectParameter(const std::string& opFK, L1GtMuonTemplate::ObjectParameter&);
00192     void addMuonCondition(const TableMenuCond&);
00193 
00194     void fillCaloObjectParameter(const std::string& opFK, L1GtCaloTemplate::ObjectParameter&);
00195     void addCaloCondition(const TableMenuCond&);
00196 
00197     void fillEnergySumObjectParameter(
00198             const std::string& opFK, L1GtEnergySumTemplate::ObjectParameter&, const L1GtObject&);
00199     void addEnergySumCondition(const TableMenuCond&);
00200 
00201     void addJetCountsCondition(const TableMenuCond&);
00202     void addHfBitCountsCondition(const TableMenuCond&);
00203     void addHfRingEtSumsCondition(const TableMenuCond&);
00204     void addCastorCondition(const TableMenuCond&);
00205     void addBptxCondition(const TableMenuCond&);
00206     void addExternalCondition(const TableMenuCond&);
00207     void addCorrelationCondition(const TableMenuCond&);
00208 
00210     void addConditions();
00211 
00212 
00213 private:
00214     template<typename Result, typename Source>
00215     Result lexical_cast_from_hex(Source & value) const;
00216 
00217 
00218 private:
00219 
00221 
00222     TableMenuGeneral m_tableMenuGeneral;
00223     std::vector<TableMenuAlgo> m_tableMenuAlgo;
00224     std::vector<TableMenuAlgoCond> m_tableMenuAlgoCond;
00225     std::vector<TableMenuCond> m_tableMenuCond;
00226     std::vector<TableMenuObjectParameters> m_tableMenuObjectParameters;
00227     std::vector<TableMenuTechTrig> m_tableMenuTechTrig;
00228 
00229 private:
00230 
00232 
00234     std::string m_triggerMenuInterface;
00235     std::string m_triggerMenuName;
00236     std::string m_triggerMenuImplementation;
00237 
00239     std::string m_scaleDbKey;
00240 
00243     std::vector<std::vector<L1GtMuonTemplate> > m_vecMuonTemplate;
00244     std::vector<std::vector<L1GtCaloTemplate> > m_vecCaloTemplate;
00245     std::vector<std::vector<L1GtEnergySumTemplate> > m_vecEnergySumTemplate;
00246     std::vector<std::vector<L1GtJetCountsTemplate> > m_vecJetCountsTemplate;
00247     std::vector<std::vector<L1GtCastorTemplate> > m_vecCastorTemplate;
00248     std::vector<std::vector<L1GtHfBitCountsTemplate> > m_vecHfBitCountsTemplate;
00249     std::vector<std::vector<L1GtHfRingEtSumsTemplate> > m_vecHfRingEtSumsTemplate;
00250     std::vector<std::vector<L1GtBptxTemplate> > m_vecBptxTemplate;
00251     std::vector<std::vector<L1GtExternalTemplate> > m_vecExternalTemplate;
00252 
00253     std::vector<std::vector<L1GtCorrelationTemplate> > m_vecCorrelationTemplate;
00254     std::vector<std::vector<L1GtMuonTemplate> > m_corMuonTemplate;
00255     std::vector<std::vector<L1GtCaloTemplate> > m_corCaloTemplate;
00256     std::vector<std::vector<L1GtEnergySumTemplate> > m_corEnergySumTemplate;
00257 
00259     AlgorithmMap m_algorithmMap;
00260 
00262     AlgorithmMap m_algorithmAliasMap;
00263 
00265     AlgorithmMap m_technicalTriggerMap;
00266 
00267 private:
00268 
00269     bool m_isDebugEnabled;
00270 
00271 
00272 };
00273 
00274 
00275 
00276 template<typename Result, typename Source>
00277 Result L1GtTriggerMenuConfigOnlineProd::lexical_cast_from_hex(Source & value) const {
00278 
00279     std::stringstream convertor;
00280     convertor << value;
00281 
00282     Result result;
00283     if (! ( convertor >> std::hex >> result ) || !convertor.eof()) {
00284         throw boost::bad_lexical_cast();
00285     }
00286 
00287     return result;
00288 }
00289 
00290 
00291 #endif