Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-09-21 02:12:36

0001 #ifndef HLTcore_HLTConfigProvider_h
0002 #define HLTcore_HLTConfigProvider_h
0003 
0004 /** \class HLTConfigProvider
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/Framework/interface/Run.h"
0015 #include "FWCore/Framework/interface/Event.h"
0016 #include "FWCore/Framework/interface/LuminosityBlock.h"
0017 
0018 #include "HLTrigger/HLTcore/interface/HLTConfigData.h"
0019 #include "HLTrigger/HLTcore/interface/FractionalPrescale.h"
0020 
0021 #include <map>
0022 #include <string>
0023 #include <vector>
0024 #include <type_traits>
0025 
0026 //
0027 // class declaration
0028 //
0029 
0030 class HLTConfigProvider {
0031 private:
0032 public:
0033   /// c'tor
0034   HLTConfigProvider();
0035   /// d'tor
0036   //  ~HLTConfigProvider();
0037 
0038 public:
0039   /// Run-dependent initialisation (non-const method)
0040   ///   "init" return value indicates whether intitialisation has succeeded
0041   ///   "changed" parameter indicates whether the config has actually changed
0042   bool init(const edm::Run& iRun, const edm::EventSetup& iSetup, const std::string& processName, bool& changed);
0043 
0044   /// Dumping config info to cout
0045   void dump(const std::string& what) const { hltConfigData_->dump(what); }
0046 
0047   /// Accessors (const methods)
0048 
0049   /// initialised?
0050   bool inited() const { return inited_; }
0051   /// changed?
0052   bool changed() const { return changed_; }
0053 
0054   /// process name
0055   const std::string& processName() const { return hltConfigData_->processName(); }
0056 
0057   /// global tag
0058   const std::string& globalTag() const { return hltConfigData_->globalTag(); }
0059 
0060   /// HLT ConfDB table name
0061   const std::string& tableName() const { return hltConfigData_->tableName(); }
0062 
0063   /// number of trigger paths in trigger table
0064   unsigned int size() const { return hltConfigData_->size(); }
0065   /// number of modules on a specific trigger path
0066   unsigned int size(unsigned int trigger) const { return hltConfigData_->size(trigger); }
0067   unsigned int size(const std::string& trigger) const { return hltConfigData_->size(trigger); }
0068 
0069   /// names of trigger paths
0070   const std::vector<std::string>& triggerNames() const { return hltConfigData_->triggerNames(); }
0071   const std::string& triggerName(unsigned int triggerIndex) const { return hltConfigData_->triggerName(triggerIndex); }
0072 
0073   /// slot position of trigger path in trigger table (0 to size-1)
0074   unsigned int triggerIndex(const std::string& triggerName) const { return hltConfigData_->triggerIndex(triggerName); }
0075 
0076   /// label(s) of module(s) on a trigger path
0077   const std::vector<std::string>& moduleLabels(unsigned int trigger) const {
0078     return hltConfigData_->moduleLabels(trigger);
0079   }
0080   const std::vector<std::string>& moduleLabels(const std::string& trigger) const {
0081     return hltConfigData_->moduleLabels(trigger);
0082   }
0083   const std::vector<std::string>& saveTagsModules(unsigned int trigger) const {
0084     return hltConfigData_->saveTagsModules(trigger);
0085   }
0086   const std::vector<std::string>& saveTagsModules(const std::string& trigger) const {
0087     return hltConfigData_->saveTagsModules(trigger);
0088   }
0089   const std::string& moduleLabel(unsigned int trigger, unsigned int module) const {
0090     return hltConfigData_->moduleLabel(trigger, module);
0091   }
0092   const std::string& moduleLabel(const std::string& trigger, unsigned int module) const {
0093     return hltConfigData_->moduleLabel(trigger, module);
0094   }
0095 
0096   /// slot position of module on trigger path (0 to size-1)
0097   unsigned int moduleIndex(unsigned int trigger, const std::string& module) const {
0098     return hltConfigData_->moduleIndex(trigger, module);
0099   }
0100   unsigned int moduleIndex(const std::string& trigger, const std::string& module) const {
0101     return hltConfigData_->moduleIndex(trigger, module);
0102   }
0103 
0104   /// C++ class name of module
0105   const std::string moduleType(const std::string& module) const { return hltConfigData_->moduleType(module); }
0106 
0107   /// C++ base class name of module
0108   const std::string moduleEDMType(const std::string& module) const { return hltConfigData_->moduleEDMType(module); }
0109 
0110   /// ParameterSet of process
0111   const edm::ParameterSet& processPSet() const { return hltConfigData_->processPSet(); }
0112 
0113   /// ParameterSet of module
0114   const edm::ParameterSet& modulePSet(const std::string& module) const { return hltConfigData_->modulePSet(module); }
0115 
0116   /// Is module an L3 filter (ie, tracked saveTags=true)
0117   bool saveTags(const std::string& module) const { return hltConfigData_->saveTags(module); }
0118 
0119   /// L1T type (0=unknown, 1=legacy/stage-1 or 2=stage-2)
0120   unsigned int l1tType() const { return hltConfigData_->l1tType(); }
0121 
0122   /// HLTLevel1GTSeed module
0123   /// HLTLevel1GTSeed modules for all trigger paths
0124   const std::vector<std::vector<std::pair<bool, std::string>>>& hltL1GTSeeds() const {
0125     return hltConfigData_->hltL1GTSeeds();
0126   }
0127   /// HLTLevel1GTSeed modules for trigger path with name
0128   const std::vector<std::pair<bool, std::string>>& hltL1GTSeeds(const std::string& trigger) const {
0129     return hltConfigData_->hltL1GTSeeds(trigger);
0130   }
0131   /// HLTLevel1GTSeed modules for trigger path with index i
0132   const std::vector<std::pair<bool, std::string>>& hltL1GTSeeds(unsigned int trigger) const {
0133     return hltConfigData_->hltL1GTSeeds(trigger);
0134   }
0135 
0136   /// HLTL1TSeed module
0137   /// HLTL1TSeed modules for all trigger paths
0138   const std::vector<std::vector<std::string>>& hltL1TSeeds() const { return hltConfigData_->hltL1TSeeds(); }
0139   /// HLTL1TSeed modules for trigger path with name
0140   const std::vector<std::string>& hltL1TSeeds(const std::string& trigger) const {
0141     return hltConfigData_->hltL1TSeeds(trigger);
0142   }
0143   /// HLTL1TSeed modules for trigger path with index i
0144   const std::vector<std::string>& hltL1TSeeds(unsigned int trigger) const {
0145     return hltConfigData_->hltL1TSeeds(trigger);
0146   }
0147 
0148   /// Streams
0149   /// list of names of all streams
0150   const std::vector<std::string>& streamNames() const { return hltConfigData_->streamNames(); }
0151   /// name of stream with index i
0152   const std::string& streamName(unsigned int stream) const { return hltConfigData_->streamName(stream); }
0153   /// index of stream with name
0154   unsigned int streamIndex(const std::string& stream) const { return hltConfigData_->streamIndex(stream); }
0155   /// names of datasets for all streams
0156   const std::vector<std::vector<std::string>>& streamContents() const { return hltConfigData_->streamContents(); }
0157   /// names of datasets in stream with index i
0158   const std::vector<std::string>& streamContent(unsigned int stream) const {
0159     return hltConfigData_->streamContent(stream);
0160   }
0161   /// names of datasets in stream with name
0162   const std::vector<std::string>& streamContent(const std::string& stream) const {
0163     return hltConfigData_->streamContent(stream);
0164   }
0165 
0166   /// Datasets
0167   /// list of names of all datasets
0168   const std::vector<std::string>& datasetNames() const { return hltConfigData_->datasetNames(); }
0169   /// name of dataset with index i
0170   const std::string& datasetName(unsigned int dataset) const { return hltConfigData_->datasetName(dataset); }
0171   /// index of dataset with name
0172   unsigned int datasetIndex(const std::string& dataset) const { return hltConfigData_->datasetIndex(dataset); }
0173   /// names of trigger paths for all datasets
0174   const std::vector<std::vector<std::string>>& datasetContents() const { return hltConfigData_->datasetContents(); }
0175   /// names of trigger paths in dataset with index i
0176   const std::vector<std::string>& datasetContent(unsigned int dataset) const {
0177     return hltConfigData_->datasetContent(dataset);
0178   }
0179   /// names of trigger paths in dataset with name
0180   const std::vector<std::string>& datasetContent(const std::string& dataset) const {
0181     return hltConfigData_->datasetContent(dataset);
0182   }
0183 
0184   /// HLT prescale info
0185   /// Number of HLT prescale sets
0186   unsigned int prescaleSize() const { return hltConfigData_->prescaleSize(); }
0187   /// HLT prescale value in specific prescale set for a specific trigger path
0188   template <typename T = unsigned int>
0189   T prescaleValue(unsigned int set, const std::string& trigger) const {
0190     static_assert(std::is_same_v<T, double> or std::is_same_v<T, FractionalPrescale>,
0191                   "\n\tPlease use prescaleValue<double> or prescaleValue<FractionalPrescale>"
0192                   "\n\t(other types for HLT prescales are not supported anymore by HLTConfigProvider)");
0193     return hltConfigData_->prescaleValue<T>(set, trigger);
0194   }
0195 
0196   /// low-level data member access
0197   const std::vector<std::string>& prescaleLabels() const { return hltConfigData_->prescaleLabels(); }
0198 
0199   template <typename T = unsigned int>
0200   std::map<std::string, std::vector<T>> const& prescaleTable() const {
0201     static_assert(std::is_same_v<T, double> or std::is_same_v<T, FractionalPrescale>,
0202                   "\n\tPlease use prescaleTable<double> or prescaleTable<FractionalPrescale>"
0203                   "\n\t(other types for HLT prescales are not supported anymore by HLTConfigProvider)");
0204     return hltConfigData_->prescaleTable<T>();
0205   }
0206 
0207   /// regexp processing
0208   static const std::vector<std::string> matched(const std::vector<std::string>& inputs, const std::string& pattern);
0209   static const std::string removeVersion(const std::string& trigger);
0210   static const std::vector<std::string> restoreVersion(const std::vector<std::string>& inputs,
0211                                                        const std::string& trigger);
0212 
0213 private:
0214   void getDataFrom(const edm::ParameterSetID& iID);
0215   void init(const edm::ProcessHistory& iHistory, const std::string& processName);
0216   void init(const std::string& processName);
0217   void clear();
0218 
0219   /// data members
0220   std::string processName_;
0221   bool inited_;
0222   bool changed_;
0223   const HLTConfigData* hltConfigData_;
0224 };
0225 #endif