CMS 3D CMS Logo

PrescaleWeightProvider.cc
Go to the documentation of this file.
1 //
2 // See header file for description
3 //
4 
6 
7 #include <sstream>
8 
13 
16 
18  // default values
19  : init_(false),
20  verbosity_(0),
21  triggerResultsTag_("TriggerResults::HLT"),
22  triggerResultsToken_(iC.mayConsume<edm::TriggerResults>(triggerResultsTag_)),
23  l1GtTriggerMenuLiteTag_("l1GtTriggerMenuLite"),
24  l1GtTriggerMenuLiteToken_(iC.mayConsume<L1GtTriggerMenuLite, edm::InRun>(l1GtTriggerMenuLiteTag_)) {
25  hltPaths_.clear();
26  if (config.exists("prescaleWeightVerbosityLevel"))
27  verbosity_ = config.getParameter<unsigned>("prescaleWeightVerbosityLevel");
28  if (config.exists("prescaleWeightTriggerResults"))
29  triggerResultsTag_ = config.getParameter<edm::InputTag>("prescaleWeightTriggerResults");
30  if (config.exists("prescaleWeightL1GtTriggerMenuLite"))
31  l1GtTriggerMenuLiteTag_ = config.getParameter<edm::InputTag>("prescaleWeightL1GtTriggerMenuLite");
32  if (config.exists("prescaleWeightHltPaths"))
33  hltPaths_ = config.getParameter<std::vector<std::string> >("prescaleWeightHltPaths");
34 
35  configured_ = true;
36  if (triggerResultsTag_.process().empty()) {
37  configured_ = false;
38  if (verbosity_ > 0)
39  edm::LogWarning("PrescaleWeightProvider") << "Process name not configured via TriggerResults InputTag";
40  } else if (triggerResultsTag_.label().empty()) {
41  configured_ = false;
42  if (verbosity_ > 0)
43  edm::LogWarning("PrescaleWeightProvider") << "TriggerResults label not configured";
44  } else if (l1GtTriggerMenuLiteTag_.label().empty()) {
45  configured_ = false;
46  if (verbosity_ > 0)
47  edm::LogWarning("PrescaleWeightProvider") << "L1GtTriggerMenuLite label not configured";
48  } else if (hltPaths_.empty()) {
49  configured_ = false;
50  if (verbosity_ > 0)
51  edm::LogError("PrescaleWeightProvider") << "HLT paths of interest not configured";
52  }
53  if (configured_) {
56  }
57 }
58 
60  init_ = true;
61 
62  if (!configured_) {
63  init_ = false;
64  if (verbosity_ > 0)
65  edm::LogWarning("PrescaleWeightProvider") << "Run initialisation failed due to failing configuration";
66  return;
67  }
68 
69  HLTConfigProvider const& hltConfig = hltPrescaleProvider_->hltConfigProvider();
70  bool hltChanged(false);
71  if (!hltPrescaleProvider_->init(run, setup, triggerResultsTag_.process(), hltChanged)) {
72  if (verbosity_ > 0)
73  edm::LogError("PrescaleWeightProvider")
74  << "HLT config initialization error with process name \"" << triggerResultsTag_.process() << "\"";
75  init_ = false;
76  } else if (hltConfig.size() <= 0) {
77  if (verbosity_ > 0)
78  edm::LogError("PrescaleWeightProvider") << "HLT config size error";
79  init_ = false;
80  } else if (hltChanged) {
81  if (verbosity_ > 0)
82  edm::LogInfo("PrescaleWeightProvider") << "HLT configuration changed";
83  }
84  if (!init_)
85  return;
86 
88  if (!triggerMenuLite_.isValid()) {
89  if (verbosity_ > 0)
90  edm::LogError("PrescaleWeightProvider")
91  << "L1GtTriggerMenuLite with label \"" << l1GtTriggerMenuLiteTag_.label() << "\" not found";
92  init_ = false;
93  }
94 }
95 
97  l1SeedPaths_.clear();
98  std::stringstream ss(l1Seeds);
100 
101  while (ss.good() && !ss.eof()) {
102  ss >> buf;
103  if (buf[0] == '(' || buf[buf.size() - 1] == ')' || buf == "AND" || buf == "NOT") {
104  l1SeedPaths_.clear();
105  if (verbosity_ > 0)
106  edm::LogWarning("PrescaleWeightProvider::parseL1Seeds") << "Only supported logical expression is OR";
107  return;
108  } else if (buf == "OR")
109  continue;
110  else
111  l1SeedPaths_.push_back(buf);
112  }
113 }
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
PrescaleWeightProvider(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, T &module)
edm::Handle< L1GtTriggerMenuLite > triggerMenuLite_
Definition: config.py:1
std::string const & label() const
Definition: InputTag.h:36
Log< level::Error, false > LogError
std::vector< std::string > l1SeedPaths_
std::vector< std::string > hltPaths_
std::unique_ptr< HLTPrescaleProvider > hltPrescaleProvider_
void initRun(const edm::Run &run, const edm::EventSetup &setup)
edm::EDGetTokenT< L1GtTriggerMenuLite > l1GtTriggerMenuLiteToken_
Log< level::Info, false > LogInfo
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Log< level::Warning, false > LogWarning
std::string const & process() const
Definition: InputTag.h:40
void parseL1Seeds(const std::string &l1Seeds)
Definition: Run.h:45