Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:43

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