CMS 3D CMS Logo

HLTPrescaleProvider.h
Go to the documentation of this file.
1 #ifndef HLTcore_HLTPrescaleProvider_h
2 #define HLTcore_HLTPrescaleProvider_h
3 
24 
25 #include <memory>
26 #include <string>
27 #include <utility>
28 #include <vector>
29 
30 namespace edm {
31  class ConsumesCollector;
32  class Event;
33  class EventSetup;
34  class ParameterSet;
35  class Run;
36 } // namespace edm
37 
39 public:
40  template <typename T>
42 
43  template <typename T>
45 
50  bool init(const edm::Run& iRun, const edm::EventSetup& iSetup, const std::string& processName, bool& changed);
51 
53  L1GtUtils const& l1GtUtils() const;
54  l1t::L1TGlobalUtil const& l1tGlobalUtil() const;
55 
58  int prescaleSet(const edm::Event& iEvent, const edm::EventSetup& iSetup);
59  // negative == error
60 
62  template <typename T = unsigned int>
64  const int set(prescaleSet(iEvent, iSetup));
65  //there is a template specialisation for unsigned in which returns +1 which
66  //emulates old behaviour
67  return set < 0 ? -1 : hltConfigProvider_.prescaleValue<T>(static_cast<unsigned int>(set), trigger);
68  }
69 
71  template <typename TL1 = int, typename THLT = TL1>
72  std::pair<TL1, THLT> prescaleValues(const edm::Event& iEvent,
73  const edm::EventSetup& iSetup,
74  const std::string& trigger) {
75  return {convertL1PS<TL1>(getL1PrescaleValue(iEvent, iSetup, trigger)),
76  prescaleValue<THLT>(iEvent, iSetup, trigger)};
77  }
78  // any one negative => error in retrieving this (L1T or HLT) prescale
79 
80  // In case of a complex Boolean expression as L1 seed
81  template <typename TL1 = int, typename THLT = TL1>
82  std::pair<std::vector<std::pair<std::string, TL1> >, THLT> prescaleValuesInDetail(const edm::Event& iEvent,
83  const edm::EventSetup& iSetup,
84  const std::string& trigger) {
85  std::pair<std::vector<std::pair<std::string, TL1> >, THLT> retval;
86  for (auto& entry : getL1PrescaleValueInDetail(iEvent, iSetup, trigger)) {
87  retval.first.emplace_back(std::move(entry.first), convertL1PS<TL1>(entry.second));
88  }
89  retval.second = prescaleValue<THLT>(iEvent, iSetup, trigger);
90  return retval;
91  }
92  // Event rejected by HLTPrescaler on ith HLT path?
93  bool rejectedByHLTPrescaler(const edm::TriggerResults& triggerResults, unsigned int i) const;
95 
96 private:
97  void checkL1GtUtils() const;
98  void checkL1TGlobalUtil() const;
99  template <typename T>
100  T convertL1PS(double val) const {
101  return T(val);
102  }
103 
104  double getL1PrescaleValue(const edm::Event& iEvent, const edm::EventSetup& iSetup, const std::string& trigger);
105  std::vector<std::pair<std::string, double> > getL1PrescaleValueInDetail(const edm::Event& iEvent,
106  const edm::EventSetup& iSetup,
107  const std::string& trigger);
108  static constexpr int kL1PrescaleDenominator_ = 100;
110  std::unique_ptr<L1GtUtils> l1GtUtils_;
111  std::unique_ptr<l1t::L1TGlobalUtil> l1tGlobalUtil_;
112  unsigned char count_[5] = {0, 0, 0, 0, 0};
113  bool inited_ = false;
114 };
115 
116 template <typename T>
118  : HLTPrescaleProvider(pset, iC, module) {}
119 
120 template <typename T>
122  unsigned int stageL1Trigger = pset.getParameter<unsigned int>("stageL1Trigger");
123  if (stageL1Trigger <= 1) {
124  l1GtUtils_ = std::make_unique<L1GtUtils>(pset, iC, false, module, L1GtUtils::UseEventSetupIn::Run);
125  } else {
126  l1tGlobalUtil_ = std::make_unique<l1t::L1TGlobalUtil>(pset, iC, module, l1t::UseEventSetupIn::Run);
127  }
128 }
129 
130 template <>
131 FractionalPrescale HLTPrescaleProvider::convertL1PS<FractionalPrescale>(double val) const;
132 
133 template <>
134 unsigned int HLTPrescaleProvider::prescaleValue<unsigned int>(const edm::Event& iEvent,
135  const edm::EventSetup& iSetup,
136  const std::string& trigger);
137 
138 #endif
HLTPrescaleProvider::checkL1TGlobalUtil
void checkL1TGlobalUtil() const
Definition: HLTPrescaleProvider.cc:354
HLTPrescaleProvider::l1tGlobalUtil
l1t::L1TGlobalUtil const & l1tGlobalUtil() const
Definition: HLTPrescaleProvider.cc:55
mps_fire.i
i
Definition: mps_fire.py:428
TriggerResults.h
edm::Run
Definition: Run.h:45
HLTPrescaleProvider::hltConfigProvider
HLTConfigProvider const & hltConfigProvider() const
Definition: HLTPrescaleProvider.h:52
edm
HLT enums.
Definition: AlignableModifier.h:19
mps_splice.entry
entry
Definition: mps_splice.py:68
HLTPrescaleProvider::HLTPrescaleProvider
HLTPrescaleProvider(edm::ParameterSet const &pset, edm::ConsumesCollector &&iC, T &module)
Definition: HLTPrescaleProvider.h:117
HLTPrescaleProvider::convertL1PS
T convertL1PS(double val) const
Definition: HLTPrescaleProvider.h:100
HLTPrescaleProvider::prescaleValues
std::pair< TL1, THLT > prescaleValues(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger)
Combined L1T (pair.first) and HLT (pair.second) prescales per HLT path.
Definition: HLTPrescaleProvider.h:72
HLTPrescaleProvider::prescaleSet
int prescaleSet(const edm::Event &iEvent, const edm::EventSetup &iSetup)
Definition: HLTPrescaleProvider.cc:60
triggerResults
static const std::string triggerResults
Definition: EdmProvDump.cc:45
HLTPrescaleProvider::count_
unsigned char count_[5]
Definition: HLTPrescaleProvider.h:112
l1t::UseEventSetupIn::Run
HLTPrescaleProvider::rejectedByHLTPrescaler
bool rejectedByHLTPrescaler(const edm::TriggerResults &triggerResults, unsigned int i) const
Definition: HLTPrescaleProvider.cc:340
HLTPrescaleProvider::l1PrescaleDenominator
static int l1PrescaleDenominator()
Definition: HLTPrescaleProvider.h:94
GlobalLogicParser.h
HLTPrescaleProvider::l1GtUtils
L1GtUtils const & l1GtUtils() const
Definition: HLTPrescaleProvider.cc:50
PDWG_DiPhoton_SD_cff.stageL1Trigger
stageL1Trigger
Definition: PDWG_DiPhoton_SD_cff.py:40
l1t::L1TGlobalUtil
Definition: L1TGlobalUtil.h:44
HLTPrescaleProvider::l1tGlobalUtil_
std::unique_ptr< l1t::L1TGlobalUtil > l1tGlobalUtil_
Definition: HLTPrescaleProvider.h:111
Event
L1GtUtils
Definition: L1GtUtils.h:66
HLTPrescaleProvider::kL1PrescaleDenominator_
static constexpr int kL1PrescaleDenominator_
Definition: HLTPrescaleProvider.h:108
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTPrescaleProvider::prescaleValuesInDetail
std::pair< std::vector< std::pair< std::string, TL1 > >, THLT > prescaleValuesInDetail(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger)
Definition: HLTPrescaleProvider.h:82
HLTConfigProvider::prescaleValue
T prescaleValue(unsigned int set, const std::string &trigger) const
HLT prescale value in specific prescale set for a specific trigger path.
Definition: HLTConfigProvider.h:188
edm::ParameterSet
Definition: ParameterSet.h:47
ParameterSet
Definition: Functions.h:16
L1GtUtils::UseEventSetupIn::Run
HLTPrescaleProvider::inited_
bool inited_
Definition: HLTPrescaleProvider.h:113
iEvent
int iEvent
Definition: GenABIO.cc:224
FractionalPrescale.h
HLTPrescaleProvider
Definition: HLTPrescaleProvider.h:38
HLTPrescaleProvider::l1GtUtils_
std::unique_ptr< L1GtUtils > l1GtUtils_
Definition: HLTPrescaleProvider.h:110
edm::EventSetup
Definition: EventSetup.h:58
FractionalPrescale
boost::rational< int > FractionalPrescale
Definition: FractionalPrescale.h:5
HLTConfigProvider.h
HLTPrescaleProvider::init
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
Definition: HLTPrescaleProvider.cc:21
HLTPrescaleProvider::getL1PrescaleValueInDetail
std::vector< std::pair< std::string, double > > getL1PrescaleValueInDetail(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger)
Definition: HLTPrescaleProvider.cc:217
HLTPrescaleProvider::prescaleValue
T prescaleValue(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger)
combining the two methods above
Definition: HLTPrescaleProvider.h:63
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
HLTConfigProvider
Definition: HLTConfigProvider.h:29
heppy_batch.val
val
Definition: heppy_batch.py:351
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLTPrescaleProvider::getL1PrescaleValue
double getL1PrescaleValue(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger)
Definition: HLTPrescaleProvider.cc:118
T
long double T
Definition: Basic3DVectorLD.h:48
L1GtUtils.h
L1TGlobalUtil.h
trigger
Definition: HLTPrescaleTableCond.h:8
HLTPrescaleProvider::checkL1GtUtils
void checkL1GtUtils() const
Definition: HLTPrescaleProvider.cc:344
EventSetup
edm::Event
Definition: Event.h:73
HLTPrescaleProvider::hltConfigProvider_
HLTConfigProvider hltConfigProvider_
Definition: HLTPrescaleProvider.h:109
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
edm::TriggerResults
Definition: TriggerResults.h:35
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
Run