Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-09 00:01:08

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