Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:33

0001 #ifndef L1TGlobal_TriggerMenuParser_h
0002 #define L1TGlobal_TriggerMenuParser_h
0003 
0004 /**
0005  * \class TriggerMenuParser
0006  *
0007  *
0008  * Description: Xerces-C XML parser for the L1 Trigger menu.
0009  *
0010  * Implementation:
0011  *    <TODO: enter implementation details>
0012  *
0013  * \author: Vasile Mihai Ghete - HEPHY Vienna
0014  * \author  M. Eder            - HEPHY Vienna - ORCA version, reduced functionality
0015  * \author  Vladimir Rekovic
0016  *                - indexing
0017  *                - correlations with overlap object removal
0018  * \author R. Cavanaugh
0019  *                - displaced muons
0020  * \author Elisa Fontanesi                                                                               
0021  *                - extended for three-body correlation conditions                                                               
0022  *                                                                  
0023  *
0024  * $Date$
0025  * $Revision$
0026  *
0027  */
0028 
0029 // system include files
0030 #include <string>
0031 #include <vector>
0032 
0033 #include "L1Trigger/L1TGlobal/interface/TriggerMenuFwd.h"
0034 
0035 #include "L1Trigger/L1TGlobal/interface/MuonTemplate.h"
0036 #include "L1Trigger/L1TGlobal/interface/MuonShowerTemplate.h"
0037 #include "L1Trigger/L1TGlobal/interface/CaloTemplate.h"
0038 #include "L1Trigger/L1TGlobal/interface/EnergySumTemplate.h"
0039 #include "L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h"
0040 #include "L1Trigger/L1TGlobal/interface/AXOL1TLTemplate.h"
0041 #include "L1Trigger/L1TGlobal/interface/CorrelationTemplate.h"
0042 #include "L1Trigger/L1TGlobal/interface/CorrelationThreeBodyTemplate.h"
0043 #include "L1Trigger/L1TGlobal/interface/CorrelationWithOverlapRemovalTemplate.h"
0044 #include "L1Trigger/L1TGlobal/interface/ExternalTemplate.h"
0045 
0046 #include "L1Trigger/L1TGlobal/interface/GlobalScales.h"
0047 
0048 #include "CondFormats/L1TObjects/interface/L1TUtmTriggerMenu.h"
0049 
0050 #include <cmath>
0051 #include "CondFormats/L1TObjects/interface/L1TUtmTriggerMenu.h"
0052 #include "CondFormats/L1TObjects/interface/L1TUtmAlgorithm.h"
0053 #include "CondFormats/L1TObjects/interface/L1TUtmCondition.h"
0054 #include "CondFormats/L1TObjects/interface/L1TUtmObject.h"
0055 #include "CondFormats/L1TObjects/interface/L1TUtmCut.h"
0056 #include "CondFormats/L1TObjects/interface/L1TUtmScale.h"
0057 
0058 // forward declarations
0059 class GlobalCondition;
0060 class GlobalAlgorithm;
0061 
0062 namespace l1t {
0063 
0064   typedef enum { COS, SIN } TrigFunc_t;
0065 
0066   // class declaration
0067   class TriggerMenuParser {
0068   public:
0069     /// constructor
0070     ///    empty
0071     TriggerMenuParser();
0072 
0073     /// destructor
0074     virtual ~TriggerMenuParser();
0075 
0076   public:
0077     ///   get / set the number of condition chips in GTL
0078     inline const unsigned int gtNumberConditionChips() const { return m_numberConditionChips; }
0079 
0080     void setGtNumberConditionChips(const unsigned int&);
0081 
0082     ///   get / set the number of pins on the GTL condition chips
0083     inline const unsigned int gtPinsOnConditionChip() const { return m_pinsOnConditionChip; }
0084 
0085     void setGtPinsOnConditionChip(const unsigned int&);
0086 
0087     ///   get / set the correspondence "condition chip - GTL algorithm word"
0088     ///   in the hardware
0089     inline std::vector<int> gtOrderConditionChip() const { return m_orderConditionChip; }
0090 
0091     void setGtOrderConditionChip(const std::vector<int>&);
0092 
0093     /// get / set the number of physics trigger algorithms
0094     inline const unsigned int gtNumberPhysTriggers() const { return m_numberPhysTriggers; }
0095 
0096     void setGtNumberPhysTriggers(const unsigned int&);
0097 
0098   public:
0099     /// get / set / build the condition maps
0100     inline const std::vector<ConditionMap>& gtConditionMap() const { return m_conditionMap; }
0101 
0102     void setGtConditionMap(const std::vector<ConditionMap>&);
0103 
0104     /// get / set the trigger menu names
0105     inline const std::string& gtTriggerMenuInterface() const { return m_triggerMenuInterface; }
0106 
0107     void setGtTriggerMenuInterface(const std::string&);
0108 
0109     //
0110     inline const std::string& gtTriggerMenuName() const { return m_triggerMenuName; }
0111 
0112     void setGtTriggerMenuName(const std::string&);
0113 
0114     //
0115     inline const unsigned long gtTriggerMenuImplementation() const { return m_triggerMenuImplementation; }
0116 
0117     void setGtTriggerMenuImplementation(const unsigned long&);
0118 
0119     /// menu associated scale key
0120     inline const std::string& gtScaleDbKey() const { return m_scaleDbKey; }
0121 
0122     /// menu associated scales
0123     inline const GlobalScales& gtScales() const { return m_gtScales; }
0124 
0125     void setGtScaleDbKey(const std::string&);
0126 
0127     /// get / set the vectors containing the conditions
0128     inline const std::vector<std::vector<MuonTemplate> >& vecMuonTemplate() const { return m_vecMuonTemplate; }
0129     void setVecMuonTemplate(const std::vector<std::vector<MuonTemplate> >&);
0130 
0131     //
0132     inline const std::vector<std::vector<MuonShowerTemplate> >& vecMuonShowerTemplate() const {
0133       return m_vecMuonShowerTemplate;
0134     }
0135     void setVecMuonShowerTemplate(const std::vector<std::vector<MuonShowerTemplate> >&);
0136 
0137     //
0138     inline const std::vector<std::vector<CaloTemplate> >& vecCaloTemplate() const { return m_vecCaloTemplate; }
0139 
0140     void setVecCaloTemplate(const std::vector<std::vector<CaloTemplate> >&);
0141 
0142     //
0143     inline const std::vector<std::vector<EnergySumTemplate> >& vecEnergySumTemplate() const {
0144       return m_vecEnergySumTemplate;
0145     }
0146 
0147     void setVecEnergySumTemplate(const std::vector<std::vector<EnergySumTemplate> >&);
0148 
0149     //
0150     inline const std::vector<std::vector<EnergySumZdcTemplate> >& vecEnergySumZdcTemplate() const {
0151       return m_vecEnergySumZdcTemplate;
0152     }
0153 
0154     void setVecEnergySumZdcTemplate(const std::vector<std::vector<EnergySumZdcTemplate> >&);
0155 
0156     //
0157     inline const std::vector<std::vector<AXOL1TLTemplate> >& vecAXOL1TLTemplate() const { return m_vecAXOL1TLTemplate; }
0158     void setVecAXOL1TLTemplate(const std::vector<std::vector<AXOL1TLTemplate> >&);
0159 
0160     //
0161     inline const std::vector<std::vector<ExternalTemplate> >& vecExternalTemplate() const {
0162       return m_vecExternalTemplate;
0163     }
0164 
0165     void setVecExternalTemplate(const std::vector<std::vector<ExternalTemplate> >&);
0166 
0167     //
0168     inline const std::vector<std::vector<CorrelationTemplate> >& vecCorrelationTemplate() const {
0169       return m_vecCorrelationTemplate;
0170     }
0171 
0172     void setVecCorrelationTemplate(const std::vector<std::vector<CorrelationTemplate> >&);
0173 
0174     //
0175     inline const std::vector<std::vector<CorrelationThreeBodyTemplate> >& vecCorrelationThreeBodyTemplate() const {
0176       return m_vecCorrelationThreeBodyTemplate;
0177     }
0178 
0179     void setVecCorrelationThreeBodyTemplate(const std::vector<std::vector<CorrelationThreeBodyTemplate> >&);
0180 
0181     //
0182     inline const std::vector<std::vector<CorrelationWithOverlapRemovalTemplate> >&
0183     vecCorrelationWithOverlapRemovalTemplate() const {
0184       return m_vecCorrelationWithOverlapRemovalTemplate;
0185     }
0186 
0187     void setVecCorrelationWithOverlapRemovalTemplate(
0188         const std::vector<std::vector<CorrelationWithOverlapRemovalTemplate> >&);
0189 
0190     // get / set the vectors containing the conditions for correlation templates
0191     //
0192     inline const std::vector<std::vector<MuonTemplate> >& corMuonTemplate() const { return m_corMuonTemplate; }
0193 
0194     void setCorMuonTemplate(const std::vector<std::vector<MuonTemplate> >&);
0195 
0196     //
0197     inline const std::vector<std::vector<CaloTemplate> >& corCaloTemplate() const { return m_corCaloTemplate; }
0198 
0199     void setCorCaloTemplate(const std::vector<std::vector<CaloTemplate> >&);
0200 
0201     //
0202     inline const std::vector<std::vector<EnergySumTemplate> >& corEnergySumTemplate() const {
0203       return m_corEnergySumTemplate;
0204     }
0205 
0206     void setCorEnergySumTemplate(const std::vector<std::vector<EnergySumTemplate> >&);
0207 
0208     /// get / set the algorithm map (by name)
0209     inline const AlgorithmMap& gtAlgorithmMap() const { return m_algorithmMap; }
0210 
0211     void setGtAlgorithmMap(const AlgorithmMap&);
0212 
0213     /// get / set the algorithm map (by alias)
0214     inline const AlgorithmMap& gtAlgorithmAliasMap() const { return m_algorithmAliasMap; }
0215 
0216     void setGtAlgorithmAliasMap(const AlgorithmMap&);
0217 
0218   public:
0219     void parseCondFormats(const L1TUtmTriggerMenu* utmMenu);
0220 
0221     std::map<std::string, unsigned int> getExternalSignals(const L1TUtmTriggerMenu* utmMenu);
0222 
0223   public:
0224     /// get / set the XML parser creation date, author, description for menu interface, menu
0225     inline const std::string& gtTriggerMenuInterfaceDate() const { return m_triggerMenuInterfaceDate; }
0226 
0227     void setGtTriggerMenuInterfaceDate(const std::string&);
0228 
0229     inline const std::string& gtTriggerMenuInterfaceAuthor() const { return m_triggerMenuInterfaceAuthor; }
0230 
0231     void setGtTriggerMenuInterfaceAuthor(const std::string&);
0232 
0233     inline const std::string& gtTriggerMenuInterfaceDescription() const { return m_triggerMenuInterfaceDescription; }
0234 
0235     void setGtTriggerMenuInterfaceDescription(const std::string&);
0236 
0237     //
0238 
0239     inline const int gtTriggerMenuUUID() const { return m_triggerMenuUUID; }
0240 
0241     void setGtTriggerMenuUUID(const int);
0242 
0243     inline const std::string& gtTriggerMenuDate() const { return m_triggerMenuDate; }
0244 
0245     void setGtTriggerMenuDate(const std::string&);
0246 
0247     inline const std::string& gtTriggerMenuAuthor() const { return m_triggerMenuAuthor; }
0248 
0249     void setGtTriggerMenuAuthor(const std::string&);
0250 
0251     inline const std::string& gtTriggerMenuDescription() const { return m_triggerMenuDescription; }
0252 
0253     void setGtTriggerMenuDescription(const std::string&);
0254 
0255     inline const std::string& gtAlgorithmImplementation() const { return m_algorithmImplementation; }
0256 
0257     void setGtAlgorithmImplementation(const std::string&);
0258 
0259   private:
0260     // methods for conditions and algorithms
0261 
0262     /// clearMaps - delete all conditions and algorithms in
0263     /// the maps and clear the maps.
0264     void clearMaps();
0265 
0266     /// insertConditionIntoMap - safe insert of condition into condition map.
0267     /// if the condition name already exists, do not insert it and return false
0268     bool insertConditionIntoMap(GlobalCondition& cond, const int chipNr);
0269 
0270     /// insert an algorithm into algorithm map
0271     bool insertAlgorithmIntoMap(const GlobalAlgorithm& alg);
0272 
0273     template <typename T>
0274     std::string l1t2string(T);
0275     int l1tstr2int(const std::string data);
0276 
0277     /// parse scales
0278     /*     bool parseScale(L1TUtmScale scale); */
0279     //    bool parseScales( L1TUtmScale scale);
0280     bool parseScales(std::map<std::string, tmeventsetup::esScale> scaleMap);
0281 
0282     /// parse a muon condition
0283     /*     bool parseMuon(XERCES_CPP_NAMESPACE::DOMNode* node, */
0284     /*             const std::string& name, unsigned int chipNr = 0, */
0285     /*             const bool corrFlag = false); */
0286     bool parseMuon(L1TUtmCondition condMu, unsigned int chipNr = 0, const bool corrFlag = false);
0287 
0288     bool parseMuonCorr(const L1TUtmObject* condMu, unsigned int chipNr = 0);
0289 
0290     /// parse a muon shower condition
0291     bool parseMuonShower(L1TUtmCondition condMu, unsigned int chipNr = 0, const bool corrFlag = false);
0292 
0293     /// parse a calorimeter condition
0294     /*     bool parseCalo(XERCES_CPP_NAMESPACE::DOMNode* node, */
0295     /*             const std::string& name, unsigned int chipNr = 0, */
0296     /*             const bool corrFlag = false); */
0297     bool parseCalo(L1TUtmCondition condCalo, unsigned int chipNr = 0, const bool corrFlag = false);
0298 
0299     bool parseCaloCorr(const L1TUtmObject* corrCalo, unsigned int chipNr = 0);
0300 
0301     /// parse an "energy sum" condition
0302     /* bool parseEnergySum(XERCES_CPP_NAMESPACE::DOMNode* node, */
0303     /*         const std::string& name, unsigned int chipNr = 0, */
0304     /*         const bool corrFlag = false); */
0305 
0306     bool parseEnergySum(L1TUtmCondition condEnergySums, unsigned int chipNr = 0, const bool corrFlag = false);
0307 
0308     bool parseEnergySumZdc(L1TUtmCondition condEnergySumZdcs, unsigned int chipNr = 0, const bool corrFlag = false);
0309 
0310     bool parseAXOL1TL(L1TUtmCondition condAXOL1TL, unsigned int chipNr = 0);
0311 
0312     bool parseEnergySumCorr(const L1TUtmObject* corrESum, unsigned int chipNr = 0);
0313 
0314     bool parseExternal(L1TUtmCondition condExt, unsigned int chipNr = 0);
0315 
0316     /// parse a correlation condition
0317     bool parseCorrelation(L1TUtmCondition corrCond, unsigned int chipNr = 0);
0318 
0319     /// parse a three-body correlation condition
0320     bool parseCorrelationThreeBody(L1TUtmCondition corrCond, unsigned int chipNr = 0);
0321 
0322     /// parse a correlation condition with overlap removal
0323     bool parseCorrelationWithOverlapRemoval(const L1TUtmCondition& corrCond, unsigned int chipNr = 0);
0324 
0325     /// parse all algorithms
0326     //bool parseAlgorithms(XERCES_CPP_NAMESPACE::XercesDOMParser* parser);
0327     bool parseAlgorithm(L1TUtmAlgorithm algorithm, unsigned int chipNr = 0);
0328 
0329     // Parse LUT for Cal Mu Eta
0330     void parseCalMuEta_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap, std::string obj1, std::string obj2);
0331 
0332     // Parse LUT for Cal Mu Phi
0333     void parseCalMuPhi_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap, std::string obj1, std::string obj2);
0334 
0335     // Parse LUT for Pt LUT in Mass calculation
0336     void parsePt_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
0337                       std::string lutpfx,
0338                       std::string obj1,
0339                       unsigned int prec);
0340 
0341     // Parse LUT for Upt LUT in Mass calculation for displaced muons
0342     void parseUpt_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
0343                        std::string lutpfx,
0344                        std::string obj1,
0345                        unsigned int prec);
0346 
0347     // Parse LUT for Delta Eta and Cosh
0348     void parseDeltaEta_Cosh_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
0349                                  std::string obj1,
0350                                  std::string obj2,
0351                                  unsigned int prec1,
0352                                  unsigned int prec2);
0353 
0354     // Parse LUT for Delta Eta and Cosh
0355     void parseDeltaPhi_Cos_LUTS(const std::map<std::string, tmeventsetup::esScale>& scaleMap,
0356                                 const std::string& obj1,
0357                                 const std::string& obj2,
0358                                 unsigned int prec1,
0359                                 unsigned int prec2);
0360 
0361     // Parse LUT for Sin(Phi),Cos(Phi) in TwoBodyPt algorithm calculation
0362     void parsePhi_Trig_LUTS(const std::map<std::string, tmeventsetup::esScale>& scaleMap,
0363                             const std::string& obj,
0364                             TrigFunc_t func,
0365                             unsigned int prec);
0366 
0367   private:
0368     /// hardware limits
0369 
0370     /// number of condition chips
0371     unsigned int m_numberConditionChips;
0372 
0373     /// number of pins on the GTL condition chips
0374     unsigned int m_pinsOnConditionChip;
0375 
0376     /// correspondence "condition chip - GTL algorithm word" in the hardware
0377     /// chip 2: 0 - 95;  chip 1: 96 - 128 (191)
0378     std::vector<int> m_orderConditionChip;
0379 
0380     /// number of physics trigger algorithms
0381     unsigned int m_numberPhysTriggers;
0382 
0383     /// number of technical triggers
0384     //unsigned int m_numberTechTriggers;
0385 
0386   private:
0387     std::string m_triggerMenuInterfaceDate;
0388     std::string m_triggerMenuInterfaceAuthor;
0389     std::string m_triggerMenuInterfaceDescription;
0390 
0391     std::string m_triggerMenuDate;
0392     std::string m_triggerMenuAuthor;
0393     std::string m_triggerMenuDescription;
0394 
0395     std::string m_algorithmImplementation;
0396 
0397   private:
0398     /// map containing the conditions (per condition chip) - transient
0399     std::vector<ConditionMap> m_conditionMap;
0400 
0401   private:
0402     /// menu names
0403     std::string m_triggerMenuInterface;
0404     std::string m_triggerMenuName;
0405     unsigned long m_triggerMenuImplementation;
0406     unsigned long m_triggerMenuUUID;
0407 
0408     /// menu associated scale key
0409     std::string m_scaleDbKey;
0410 
0411     /// vectors containing the conditions
0412     /// explicit, due to persistency...
0413     std::vector<std::vector<MuonTemplate> > m_vecMuonTemplate;
0414     std::vector<std::vector<MuonShowerTemplate> > m_vecMuonShowerTemplate;
0415     std::vector<std::vector<CaloTemplate> > m_vecCaloTemplate;
0416     std::vector<std::vector<EnergySumTemplate> > m_vecEnergySumTemplate;
0417     std::vector<std::vector<EnergySumZdcTemplate> > m_vecEnergySumZdcTemplate;
0418     std::vector<std::vector<AXOL1TLTemplate> > m_vecAXOL1TLTemplate;
0419     std::vector<std::vector<ExternalTemplate> > m_vecExternalTemplate;
0420 
0421     std::vector<std::vector<CorrelationTemplate> > m_vecCorrelationTemplate;
0422     std::vector<std::vector<CorrelationThreeBodyTemplate> > m_vecCorrelationThreeBodyTemplate;
0423     std::vector<std::vector<CorrelationWithOverlapRemovalTemplate> > m_vecCorrelationWithOverlapRemovalTemplate;
0424     std::vector<std::vector<MuonTemplate> > m_corMuonTemplate;
0425     std::vector<std::vector<CaloTemplate> > m_corCaloTemplate;
0426     std::vector<std::vector<EnergySumTemplate> > m_corEnergySumTemplate;
0427 
0428     /// map containing the physics algorithms (by name)
0429     AlgorithmMap m_algorithmMap;
0430 
0431     /// map containing the physics algorithms (by alias)
0432     AlgorithmMap m_algorithmAliasMap;
0433 
0434     // class containing the scales from the L1 Menu XML
0435     GlobalScales m_gtScales;
0436   };
0437 
0438 }  // namespace l1t
0439 #endif /*L1TGlobal_TriggerMenuParser_h*/