Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:24

0001 #ifndef HLTrigger_HLTcore_HLTConfigData_h
0002 #define HLTrigger_HLTcore_HLTConfigData_h
0003 
0004 /** \class HLTConfigData
0005  *
0006  *  
0007  *  This class provides access routines to get hold of the HLT Configuration
0008  *
0009  *
0010  *  \author Martin Grunewald
0011  *
0012  */
0013 
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 #include "DataFormats/HLTReco/interface/HLTPrescaleTable.h"
0016 #include "HLTrigger/HLTcore/interface/FractionalPrescale.h"
0017 
0018 #include <map>
0019 #include <string>
0020 #include <vector>
0021 #include <type_traits>
0022 
0023 //
0024 // class declaration
0025 //
0026 
0027 class HLTConfigData {
0028 public:
0029   HLTConfigData();
0030   HLTConfigData(const edm::ParameterSet* iID);
0031 
0032 private:
0033   /// extract information into data members - called by init() methods
0034   void extract();
0035 
0036 public:
0037   /// Dumping config info to cout
0038   void dump(const std::string& what) const;
0039 
0040   /// Accessors (const methods)
0041 
0042   /// process name
0043   const std::string& processName() const;
0044 
0045   /// GlobalTag.globaltag
0046   const std::string& globalTag() const;
0047 
0048   /// HLT ConfDB table name
0049   const std::string& tableName() const;
0050 
0051   /// number of trigger paths in trigger table
0052   unsigned int size() const;
0053   /// number of modules on a specific trigger path
0054   unsigned int size(unsigned int trigger) const;
0055   unsigned int size(const std::string& trigger) const;
0056 
0057   /// names of trigger paths
0058   const std::vector<std::string>& triggerNames() const;
0059   const std::string& triggerName(unsigned int triggerIndex) const;
0060 
0061   /// slot position of trigger path in trigger table (0 - size-1)
0062   unsigned int triggerIndex(const std::string& triggerName) const;
0063 
0064   /// label(s) of module(s) on a trigger path
0065   const std::vector<std::string>& moduleLabels(unsigned int trigger) const;
0066   const std::vector<std::string>& moduleLabels(const std::string& trigger) const;
0067   const std::vector<std::string>& saveTagsModules(unsigned int trigger) const;
0068   const std::vector<std::string>& saveTagsModules(const std::string& trigger) const;
0069   const std::string& moduleLabel(unsigned int trigger, unsigned int module) const;
0070   const std::string& moduleLabel(const std::string& trigger, unsigned int module) const;
0071 
0072   /// slot position of module on trigger path (0 - size-1)
0073   unsigned int moduleIndex(unsigned int trigger, const std::string& module) const;
0074   unsigned int moduleIndex(const std::string& trigger, const std::string& module) const;
0075 
0076   /// C++ class name of module
0077   const std::string moduleType(const std::string& module) const;
0078 
0079   /// C++ base class name of module
0080   const std::string moduleEDMType(const std::string& module) const;
0081 
0082   /// ParameterSet of process
0083   const edm::ParameterSet& processPSet() const;
0084 
0085   /// ParameterSet of module
0086   const edm::ParameterSet& modulePSet(const std::string& module) const;
0087 
0088   /// Is module an L3 filter (ie, tracked saveTags=true)
0089   bool saveTags(const std::string& module) const;
0090 
0091   /// L1T type (0=unknown, 1=legacy/stage-1 or 2=stage-2)
0092   unsigned int l1tType() const;
0093 
0094   /// HLTLevel1GTSeed module
0095   /// HLTLevel1GTSeed modules for all trigger paths
0096   const std::vector<std::vector<std::pair<bool, std::string>>>& hltL1GTSeeds() const;
0097   /// HLTLevel1GTSeed modules for trigger path with name
0098   const std::vector<std::pair<bool, std::string>>& hltL1GTSeeds(const std::string& trigger) const;
0099   /// HLTLevel1GTSeed modules for trigger path with index i
0100   const std::vector<std::pair<bool, std::string>>& hltL1GTSeeds(unsigned int trigger) const;
0101 
0102   /// HLTL1TSeed module
0103   /// HLTL1TSeed modules for all trigger paths
0104   const std::vector<std::vector<std::string>>& hltL1TSeeds() const;
0105   /// HLTL1TSeed modules for trigger path with name
0106   const std::vector<std::string>& hltL1TSeeds(const std::string& trigger) const;
0107   /// HLTL1TSeed modules for trigger path with index i
0108   const std::vector<std::string>& hltL1TSeeds(unsigned int trigger) const;
0109 
0110   /// Streams
0111   /// list of names of all streams
0112   const std::vector<std::string>& streamNames() const;
0113   /// name of stream with index i
0114   const std::string& streamName(unsigned int stream) const;
0115   /// index of stream with name
0116   unsigned int streamIndex(const std::string& stream) const;
0117   /// names of datasets for all streams
0118   const std::vector<std::vector<std::string>>& streamContents() const;
0119   /// names of datasets in stream with index i
0120   const std::vector<std::string>& streamContent(unsigned int stream) const;
0121   /// names of datasets in stream with name
0122   const std::vector<std::string>& streamContent(const std::string& stream) const;
0123 
0124   /// Datasets
0125   /// list of names of all datasets
0126   const std::vector<std::string>& datasetNames() const;
0127   /// name of dataset with index i
0128   const std::string& datasetName(unsigned int dataset) const;
0129   /// index of dataset with name
0130   unsigned int datasetIndex(const std::string& dataset) const;
0131   /// names of trigger paths for all datasets
0132   const std::vector<std::vector<std::string>>& datasetContents() const;
0133   /// names of trigger paths in dataset with index i
0134   const std::vector<std::string>& datasetContent(unsigned int dataset) const;
0135   /// names of trigger paths in dataset with name
0136   const std::vector<std::string>& datasetContent(const std::string& dataset) const;
0137 
0138   /// HLT prescale info
0139   /// Number of HLT prescale sets
0140   unsigned int prescaleSize() const;
0141   /// HLT prescale value in specific prescale set for a specific trigger path
0142   template <typename T = unsigned int>
0143   T prescaleValue(unsigned int set, const std::string& trigger) const;
0144   /// labels of HLT prescale columns
0145   const std::vector<std::string>& prescaleLabels() const;
0146   /// map of HLT prescales by trigger-path name (key=path, value=prescales)
0147   template <typename T = unsigned int>
0148   std::map<std::string, std::vector<T>> const& prescaleTable() const;
0149 
0150   /// technical: id() function needed for use with ThreadSafeRegistry
0151   edm::ParameterSetID id() const;
0152 
0153 private:
0154   const edm::ParameterSet* processPSet_;
0155 
0156   std::string processName_;
0157   std::string globalTag_;
0158   std::string tableName_;
0159   std::vector<std::string> triggerNames_;
0160   std::vector<std::vector<std::string>> moduleLabels_;
0161   std::vector<std::vector<std::string>> saveTagsModules_;
0162 
0163   std::map<std::string, unsigned int> triggerIndex_;
0164   std::vector<std::map<std::string, unsigned int>> moduleIndex_;
0165 
0166   unsigned int l1tType_;
0167   std::vector<std::vector<std::pair<bool, std::string>>> hltL1GTSeeds_;
0168   std::vector<std::vector<std::string>> hltL1TSeeds_;
0169 
0170   std::vector<std::string> streamNames_;
0171   std::map<std::string, unsigned int> streamIndex_;
0172   std::vector<std::vector<std::string>> streamContents_;
0173 
0174   std::vector<std::string> datasetNames_;
0175   std::map<std::string, unsigned int> datasetIndex_;
0176   std::vector<std::vector<std::string>> datasetContents_;
0177 
0178   trigger::HLTPrescaleTable hltPrescaleTable_;
0179   std::map<std::string, std::vector<double>> hltPrescaleTableValuesDouble_;
0180   std::map<std::string, std::vector<FractionalPrescale>> hltPrescaleTableValuesFractional_;
0181 };
0182 
0183 template <typename T>
0184 T HLTConfigData::prescaleValue(unsigned int set, const std::string& trigger) const {
0185   static_assert(std::is_same_v<T, double> or std::is_same_v<T, FractionalPrescale>,
0186                 "\n\tPlease use prescaleValue<double> or prescaleValue<FractionalPrescale>"
0187                 "\n\t(other types for HLT prescales are not supported anymore by HLTConfigData)");
0188   return hltPrescaleTable_.prescale(set, trigger);
0189 }
0190 
0191 template <typename T>
0192 std::map<std::string, std::vector<T>> const& HLTConfigData::prescaleTable() const {
0193   static_assert(std::is_same_v<T, double> or std::is_same_v<T, FractionalPrescale>,
0194                 "\n\tPlease use prescaleTable<double> or prescaleTable<FractionalPrescale>"
0195                 "\n\t(other types for HLT prescales are not supported anymore by HLTConfigData)");
0196   return hltPrescaleTable_.table();
0197 }
0198 
0199 template <>
0200 std::map<std::string, std::vector<double>> const& HLTConfigData::prescaleTable() const;
0201 
0202 template <>
0203 std::map<std::string, std::vector<FractionalPrescale>> const& HLTConfigData::prescaleTable() const;
0204 
0205 #endif  // HLTrigger_HLTcore_HLTConfigData_h