CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TriggerHelper Class Reference

Provides a code based selection for trigger and DCS information in order to have no failing filters in the CMSSW path. More...

#include <TriggerHelper.h>

Public Member Functions

bool accept (const edm::Event &event, const edm::EventSetup &setup)
 To be called from analyze/filter() methods. More...
 
void initRun (const edm::Run &run, const edm::EventSetup &setup)
 To be called from beginedm::Run() methods. More...
 
bool off ()
 
bool on ()
 
template<typename T >
 TriggerHelper (const edm::ParameterSet &config, edm::ConsumesCollector &&iC, T &module)
 
template<typename T >
 TriggerHelper (const edm::ParameterSet &config, edm::ConsumesCollector &iC, T &module)
 
 ~TriggerHelper ()
 To be called from d'tors by 'delete'. More...
 

Private Member Functions

bool acceptDcs (const edm::Event &event)
 
bool acceptDcsPartition (const edm::Handle< DcsStatusCollection > &dcsStatus, int dcsPartition) const
 
bool acceptGt (const edm::Event &event)
 
bool acceptGtLogicalExpression (const edm::Handle< L1GlobalTriggerReadoutRecord > &gtReadoutRecord, std::string gtLogicalExpression)
 Does this event fulfill this particular GT status bits' logical expression? More...
 
bool acceptHlt (const edm::Event &event)
 
bool acceptHltLogicalExpression (const edm::Handle< edm::TriggerResults > &hltTriggerResults, std::string hltLogicalExpression) const
 Was this event accepted by this particular HLT paths' logical expression? More...
 
bool acceptL1 (const edm::Event &event, const edm::EventSetup &setup)
 Was this event accepted by the configured L1 logical expression combination? More...
 
bool acceptL1LogicalExpression (const edm::Event &event, std::string l1LogicalExpression)
 
std::vector< std::string > expressionsFromDB (const std::string &key, const edm::EventSetup &setup)
 Reads and returns logical expressions from DB. More...
 
bool negate (std::string &word) const
 Checks for negated words. More...
 
 TriggerHelper (const edm::ParameterSet &config)
 To be called from the ED module's c'tor. More...
 

Private Attributes

bool andOr_
 
bool andOrDcs_
 
bool andOrGt_
 
bool andOrHlt_
 
bool andOrL1_
 
const std::string configError_
 
edm::InputTag dcsInputTag_
 
std::vector< int > dcsPartitions_
 
bool errorReplyDcs_
 
bool errorReplyGt_
 
bool errorReplyHlt_
 
bool errorReplyL1_
 
std::string gtDBKey_
 
edm::InputTag gtInputTag_
 
std::vector< std::string > gtLogicalExpressions_
 
HLTConfigProvider hltConfig_
 
bool hltConfigInit_
 
std::string hltDBKey_
 
edm::InputTag hltInputTag_
 
std::vector< std::string > hltLogicalExpressions_
 
std::string l1DBKey_
 
std::unique_ptr< L1GtUtilsl1Gt_
 
std::vector< std::string > l1LogicalExpressions_
 
bool on_
 
bool onDcs_
 
bool onGt_
 
bool onHlt_
 
bool onL1_
 
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_
 

Detailed Description

Provides a code based selection for trigger and DCS information in order to have no failing filters in the CMSSW path.

"DQM/TrackerCommon/interface/TriggerHelper.h" [...]

Author
Volker Adler

Definition at line 39 of file TriggerHelper.h.

Constructor & Destructor Documentation

template<typename T >
TriggerHelper::TriggerHelper ( const edm::ParameterSet config,
edm::ConsumesCollector &&  iC,
T module 
)

Definition at line 121 of file TriggerHelper.h.

122  : TriggerHelper(config, iC, module) {}
TriggerHelper(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, T &module)
Definition: vlib.h:198
template<typename T >
TriggerHelper::TriggerHelper ( const edm::ParameterSet config,
edm::ConsumesCollector iC,
T module 
)

Definition at line 125 of file TriggerHelper.h.

References l1Gt_.

126  : TriggerHelper(config) {
127  l1Gt_.reset(new L1GtUtils(config, iC, false, module));
128 }
std::unique_ptr< L1GtUtils > l1Gt_
Definition: TriggerHelper.h:42
TriggerHelper(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, T &module)
Definition: vlib.h:198
TriggerHelper::~TriggerHelper ( )

To be called from d'tors by 'delete'.

Definition at line 83 of file TriggerHelper.cc.

References on_, and watchDB_.

83  {
84  if (on_)
85  delete watchDB_;
86 }
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_
Definition: TriggerHelper.h:41
TriggerHelper::TriggerHelper ( const edm::ParameterSet config)
private

To be called from the ED module's c'tor.

Definition at line 15 of file TriggerHelper.cc.

References andOr_, andOrDcs_, andOrGt_, andOrHlt_, andOrL1_, dcsInputTag_, dcsPartitions_, errorReplyDcs_, errorReplyGt_, errorReplyHlt_, errorReplyL1_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), gtDBKey_, gtInputTag_, gtLogicalExpressions_, hltDBKey_, hltInputTag_, hltLogicalExpressions_, l1DBKey_, l1LogicalExpressions_, on_, onDcs_, onGt_, onHlt_, onL1_, AlCaHLTBitMon_QueryRunRegistry::string, and watchDB_.

16  : watchDB_(nullptr),
17  gtDBKey_(""),
18  l1DBKey_(""),
19  hltDBKey_(""),
20  on_(true),
21  onDcs_(true),
22  onGt_(true),
23  onL1_(true),
24  onHlt_(true),
25  configError_("CONFIG_ERROR") {
26  // General switch(es)
27  if (config.exists("andOr")) {
28  andOr_ = config.getParameter<bool>("andOr");
29  } else {
30  on_ = false;
31  onDcs_ = false;
32  onGt_ = false;
33  onL1_ = false;
34  onHlt_ = false;
35  }
36 
37  if (on_) {
38  if (config.exists("andOrDcs")) {
39  andOrDcs_ = config.getParameter<bool>("andOrDcs");
40  dcsInputTag_ = config.getParameter<edm::InputTag>("dcsInputTag");
41  dcsPartitions_ = config.getParameter<std::vector<int>>("dcsPartitions");
42  errorReplyDcs_ = config.getParameter<bool>("errorReplyDcs");
43  } else {
44  onDcs_ = false;
45  }
46  if (config.exists("andOrGt")) {
47  andOrGt_ = config.getParameter<bool>("andOrGt");
48  gtInputTag_ = config.getParameter<edm::InputTag>("gtInputTag");
49  gtLogicalExpressions_ = config.getParameter<std::vector<std::string>>("gtStatusBits");
50  errorReplyGt_ = config.getParameter<bool>("errorReplyGt");
51  if (config.exists("gtDBKey"))
52  gtDBKey_ = config.getParameter<std::string>("gtDBKey");
53  } else {
54  onGt_ = false;
55  }
56  if (config.exists("andOrL1")) {
57  andOrL1_ = config.getParameter<bool>("andOrL1");
58  l1LogicalExpressions_ = config.getParameter<std::vector<std::string>>("l1Algorithms");
59  errorReplyL1_ = config.getParameter<bool>("errorReplyL1");
60  if (config.exists("l1DBKey"))
61  l1DBKey_ = config.getParameter<std::string>("l1DBKey");
62  } else {
63  onL1_ = false;
64  }
65  if (config.exists("andOrHlt")) {
66  andOrHlt_ = config.getParameter<bool>("andOrHlt");
67  hltInputTag_ = config.getParameter<edm::InputTag>("hltInputTag");
68  hltLogicalExpressions_ = config.getParameter<std::vector<std::string>>("hltPaths");
69  errorReplyHlt_ = config.getParameter<bool>("errorReplyHlt");
70  if (config.exists("hltDBKey"))
71  hltDBKey_ = config.getParameter<std::string>("hltDBKey");
72  } else {
73  onHlt_ = false;
74  }
75  if (!onDcs_ && !onGt_ && !onL1_ && !onHlt_)
76  on_ = false;
77  else
79  }
80 }
T getParameter(std::string const &) const
std::vector< std::string > l1LogicalExpressions_
Definition: TriggerHelper.h:58
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string l1DBKey_
Definition: TriggerHelper.h:57
const std::string configError_
Definition: TriggerHelper.h:72
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_
Definition: TriggerHelper.h:41
std::vector< std::string > hltLogicalExpressions_
Definition: TriggerHelper.h:63
std::string gtDBKey_
Definition: TriggerHelper.h:53
std::vector< std::string > gtLogicalExpressions_
Definition: TriggerHelper.h:54
edm::InputTag hltInputTag_
Definition: TriggerHelper.h:61
edm::InputTag gtInputTag_
Definition: TriggerHelper.h:52
std::vector< int > dcsPartitions_
Definition: TriggerHelper.h:49
edm::InputTag dcsInputTag_
Definition: TriggerHelper.h:48
std::string hltDBKey_
Definition: TriggerHelper.h:62

Member Function Documentation

bool TriggerHelper::accept ( const edm::Event event,
const edm::EventSetup setup 
)

To be called from analyze/filter() methods.

Definition at line 129 of file TriggerHelper.cc.

References acceptDcs(), acceptGt(), acceptHlt(), acceptL1(), andOr_, and on_.

Referenced by Vispa.Gui.BoxContentDialog.BoxContentDialog::apply(), Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog::apply(), and esMonitoring.FDJsonServer::handle_accept().

129  {
130  if (!on_)
131  return true;
132 
133  // Determine decision
134  if (andOr_)
135  return (acceptDcs(event) || acceptGt(event) || acceptL1(event, setup) || acceptHlt(event));
136  return (acceptDcs(event) && acceptGt(event) && acceptL1(event, setup) && acceptHlt(event));
137 }
bool acceptHlt(const edm::Event &event)
bool acceptL1(const edm::Event &event, const edm::EventSetup &setup)
Was this event accepted by the configured L1 logical expression combination?
bool acceptDcs(const edm::Event &event)
bool acceptGt(const edm::Event &event)
bool TriggerHelper::acceptDcs ( const edm::Event event)
private

Definition at line 139 of file TriggerHelper.cc.

References acceptDcsPartition(), andOr_, andOrDcs_, dcsInputTag_, dcsPartitions_, edm::InputTag::encode(), errorReplyDcs_, edm::HandleBase::isValid(), and onDcs_.

Referenced by accept().

139  {
140  // An empty DCS partitions list acts as switch.
141  if (!onDcs_ || dcsPartitions_.empty())
142  return (!andOr_); // logically neutral, depending on base logical connective
143 
144  // Accessing the DcsStatusCollection
146  event.getByLabel(dcsInputTag_, dcsStatus);
147  if (!dcsStatus.isValid()) {
148  edm::LogError("TriggerHelper") << "DcsStatusCollection product with InputTag \"" << dcsInputTag_.encode()
149  << "\" not in event ==> decision: " << errorReplyDcs_;
150  return errorReplyDcs_;
151  }
152 
153  // Determine decision of DCS partition combination and return
154  if (andOrDcs_) { // OR combination
155  for (std::vector<int>::const_iterator partitionNumber = dcsPartitions_.begin();
156  partitionNumber != dcsPartitions_.end();
157  ++partitionNumber) {
158  if (acceptDcsPartition(dcsStatus, *partitionNumber))
159  return true;
160  }
161  return false;
162  }
163  for (std::vector<int>::const_iterator partitionNumber = dcsPartitions_.begin();
164  partitionNumber != dcsPartitions_.end();
165  ++partitionNumber) {
166  if (!acceptDcsPartition(dcsStatus, *partitionNumber))
167  return false;
168  }
169  return true;
170 }
std::string encode() const
Definition: InputTag.cc:159
bool isValid() const
Definition: HandleBase.h:70
std::vector< int > dcsPartitions_
Definition: TriggerHelper.h:49
bool acceptDcsPartition(const edm::Handle< DcsStatusCollection > &dcsStatus, int dcsPartition) const
edm::InputTag dcsInputTag_
Definition: TriggerHelper.h:48
bool TriggerHelper::acceptDcsPartition ( const edm::Handle< DcsStatusCollection > &  dcsStatus,
int  dcsPartition 
) const
private

Definition at line 172 of file TriggerHelper.cc.

References DcsStatus::BPIX, DcsStatus::CASTOR, DcsStatus::CSCm, DcsStatus::CSCp, DcsStatus::DT0, DcsStatus::DTm, DcsStatus::DTp, DcsStatus::EBm, DcsStatus::EBp, DcsStatus::EEm, DcsStatus::EEp, errorReplyDcs_, DcsStatus::ESm, DcsStatus::ESp, DcsStatus::FPIX, DcsStatus::HBHEa, DcsStatus::HBHEb, DcsStatus::HBHEc, DcsStatus::HF, DcsStatus::HO, DcsStatus::RPC, DcsStatus::TECm, DcsStatus::TECp, DcsStatus::TIBTID, and DcsStatus::TOB.

Referenced by acceptDcs().

172  {
173  // Error checks
174  switch (dcsPartition) {
175  case DcsStatus::EBp:
176  case DcsStatus::EBm:
177  case DcsStatus::EEp:
178  case DcsStatus::EEm:
179  case DcsStatus::HBHEa:
180  case DcsStatus::HBHEb:
181  case DcsStatus::HBHEc:
182  case DcsStatus::HF:
183  case DcsStatus::HO:
184  case DcsStatus::RPC:
185  case DcsStatus::DT0:
186  case DcsStatus::DTp:
187  case DcsStatus::DTm:
188  case DcsStatus::CSCp:
189  case DcsStatus::CSCm:
190  case DcsStatus::CASTOR:
191  case DcsStatus::TIBTID:
192  case DcsStatus::TOB:
193  case DcsStatus::TECp:
194  case DcsStatus::TECm:
195  case DcsStatus::BPIX:
196  case DcsStatus::FPIX:
197  case DcsStatus::ESp:
198  case DcsStatus::ESm:
199  break;
200  default:
201  edm::LogError("TriggerHelper") << "DCS partition number \"" << dcsPartition
202  << "\" does not exist ==> decision: " << errorReplyDcs_;
203  return errorReplyDcs_;
204  }
205 
206  // Determine decision
207  return dcsStatus->at(0).ready(dcsPartition);
208 }
bool TriggerHelper::acceptGt ( const edm::Event event)
private

Does this event fulfill the configured GT status logical expression combination?

Definition at line 212 of file TriggerHelper.cc.

References acceptGtLogicalExpression(), andOr_, andOrGt_, edm::InputTag::encode(), errorReplyGt_, gtInputTag_, gtLogicalExpressions_, edm::HandleBase::isValid(), and onGt_.

Referenced by accept().

212  {
213  // An empty GT status bits logical expressions list acts as switch.
214  if (!onGt_ || gtLogicalExpressions_.empty())
215  return (!andOr_); // logically neutral, depending on base logical connective
216 
217  // Accessing the L1GlobalTriggerReadoutRecord
219  event.getByLabel(gtInputTag_, gtReadoutRecord);
220  if (!gtReadoutRecord.isValid()) {
221  edm::LogError("TriggerHelper") << "L1GlobalTriggerReadoutRecord product with InputTag \"" << gtInputTag_.encode()
222  << "\" not in event ==> decision: " << errorReplyGt_;
223  return errorReplyGt_;
224  }
225 
226  // Determine decision of GT status bits logical expression combination and
227  // return
228  if (andOrGt_) { // OR combination
229  for (std::vector<std::string>::const_iterator gtLogicalExpression = gtLogicalExpressions_.begin();
230  gtLogicalExpression != gtLogicalExpressions_.end();
231  ++gtLogicalExpression) {
232  if (acceptGtLogicalExpression(gtReadoutRecord, *gtLogicalExpression))
233  return true;
234  }
235  return false;
236  }
237  for (std::vector<std::string>::const_iterator gtLogicalExpression = gtLogicalExpressions_.begin();
238  gtLogicalExpression != gtLogicalExpressions_.end();
239  ++gtLogicalExpression) {
240  if (!acceptGtLogicalExpression(gtReadoutRecord, *gtLogicalExpression))
241  return false;
242  }
243  return true;
244 }
bool acceptGtLogicalExpression(const edm::Handle< L1GlobalTriggerReadoutRecord > &gtReadoutRecord, std::string gtLogicalExpression)
Does this event fulfill this particular GT status bits&#39; logical expression?
std::string encode() const
Definition: InputTag.cc:159
std::vector< std::string > gtLogicalExpressions_
Definition: TriggerHelper.h:54
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag gtInputTag_
Definition: TriggerHelper.h:52
bool TriggerHelper::acceptGtLogicalExpression ( const edm::Handle< L1GlobalTriggerReadoutRecord > &  gtReadoutRecord,
std::string  gtLogicalExpression 
)
private

Does this event fulfill this particular GT status bits' logical expression?

Definition at line 247 of file TriggerHelper.cc.

References errorReplyDcs_, errorReplyGt_, L1GtLogicParser::expressionResult(), L1GlobalTriggerReadoutRecord::gtFdlWord(), negate(), L1GtLogicParser::operandTokenVector(), L1GtFdlWord::physicsDeclared(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by acceptGt().

248  {
249  // Check empty std::strings
250  if (gtLogicalExpression.empty()) {
251  edm::LogError("TriggerHelper") << "Empty logical expression ==> decision: " << errorReplyGt_;
252  return errorReplyGt_;
253  }
254 
255  // Negated paths
256  bool negExpr(negate(gtLogicalExpression));
257  if (negExpr && gtLogicalExpression.empty()) {
258  edm::LogError("TriggerHelper") << "Empty (negated) logical expression ==> decision: " << errorReplyGt_;
259  return errorReplyGt_;
260  }
261 
262  // Parse logical expression and determine GT status bit decision
263  L1GtLogicParser gtAlgoLogicParser(gtLogicalExpression);
264  // Loop over status bits
265  for (size_t iStatusBit = 0; iStatusBit < gtAlgoLogicParser.operandTokenVector().size(); ++iStatusBit) {
266  const std::string gtStatusBit(gtAlgoLogicParser.operandTokenVector().at(iStatusBit).tokenName);
267  // Manipulate status bit decision as stored in the parser
268  bool decision;
269  // Hard-coded status bits!!!
270  if (gtStatusBit == "PhysDecl" || gtStatusBit == "PhysicsDeclared") {
271  decision = (gtReadoutRecord->gtFdlWord().physicsDeclared() == 1);
272  } else {
273  edm::LogError("TriggerHelper") << "GT status bit \"" << gtStatusBit
274  << "\" is not defined ==> decision: " << errorReplyGt_;
275  decision = errorReplyDcs_;
276  }
277  gtAlgoLogicParser.operandTokenVector().at(iStatusBit).tokenResult = decision;
278  }
279 
280  // Determine decision
281  const bool gtDecision(gtAlgoLogicParser.expressionResult());
282  return negExpr ? (!gtDecision) : gtDecision;
283 }
bool negate(std::string &word) const
Checks for negated words.
const L1GtFdlWord gtFdlWord(int bxInEventValue) const
get / set FDL word (record) in the GT readout record
const cms_uint16_t physicsDeclared() const
get/set "physics declared" bit
Definition: L1GtFdlWord.h:169
bool TriggerHelper::acceptHlt ( const edm::Event event)
private

Was this event accepted by the configured HLT logical expression combination?

Definition at line 358 of file TriggerHelper.cc.

References acceptHltLogicalExpression(), andOr_, andOrHlt_, edm::InputTag::encode(), errorReplyHlt_, hltConfigInit_, hltInputTag_, hltLogicalExpressions_, edm::HandleBase::isValid(), and onHlt_.

Referenced by accept().

358  {
359  // An empty HLT logical expressions list acts as switch.
360  if (!onHlt_ || hltLogicalExpressions_.empty())
361  return (!andOr_); // logically neutral, depending on base logical connective
362 
363  // Checking the HLT configuration,
364  if (!hltConfigInit_) {
365  edm::LogError("TriggerHelper") << "HLT config error ==> decision: " << errorReplyHlt_;
366  return errorReplyHlt_;
367  }
368 
369  // Accessing the TriggerResults
370  edm::Handle<edm::TriggerResults> hltTriggerResults;
371  event.getByLabel(hltInputTag_, hltTriggerResults);
372  if (!hltTriggerResults.isValid()) {
373  edm::LogError("TriggerHelper") << "TriggerResults product with InputTag \"" << hltInputTag_.encode()
374  << "\" not in event ==> decision: " << errorReplyHlt_;
375  return errorReplyHlt_;
376  }
377 
378  // Determine decision of HLT logical expression combination and return
379  if (andOrHlt_) { // OR combination
380  for (std::vector<std::string>::const_iterator hltLogicalExpression = hltLogicalExpressions_.begin();
381  hltLogicalExpression != hltLogicalExpressions_.end();
382  ++hltLogicalExpression) {
383  if (acceptHltLogicalExpression(hltTriggerResults, *hltLogicalExpression))
384  return true;
385  }
386  return false;
387  }
388  for (std::vector<std::string>::const_iterator hltLogicalExpression = hltLogicalExpressions_.begin();
389  hltLogicalExpression != hltLogicalExpressions_.end();
390  ++hltLogicalExpression) {
391  if (!acceptHltLogicalExpression(hltTriggerResults, *hltLogicalExpression))
392  return false;
393  }
394  return true;
395 }
bool acceptHltLogicalExpression(const edm::Handle< edm::TriggerResults > &hltTriggerResults, std::string hltLogicalExpression) const
Was this event accepted by this particular HLT paths&#39; logical expression?
std::string encode() const
Definition: InputTag.cc:159
std::vector< std::string > hltLogicalExpressions_
Definition: TriggerHelper.h:63
edm::InputTag hltInputTag_
Definition: TriggerHelper.h:61
bool isValid() const
Definition: HandleBase.h:70
bool TriggerHelper::acceptHltLogicalExpression ( const edm::Handle< edm::TriggerResults > &  hltTriggerResults,
std::string  hltLogicalExpression 
) const
private

Was this event accepted by this particular HLT paths' logical expression?

Definition at line 398 of file TriggerHelper.cc.

References edm::HLTGlobalStatus::accept(), edm::HLTGlobalStatus::error(), errorReplyHlt_, L1GtLogicParser::expressionResult(), hltConfig_, hltInputTag_, negate(), L1GtLogicParser::operandTokenVector(), edm::InputTag::process(), HLTConfigProvider::size(), AlCaHLTBitMon_QueryRunRegistry::string, and HLTConfigProvider::triggerIndex().

Referenced by acceptHlt().

399  {
400  // Check empty std::strings
401  if (hltLogicalExpression.empty()) {
402  edm::LogError("TriggerHelper") << "Empty logical expression ==> decision: " << errorReplyHlt_;
403  return errorReplyHlt_;
404  }
405 
406  // Negated paths
407  bool negExpr(negate(hltLogicalExpression));
408  if (negExpr && hltLogicalExpression.empty()) {
409  edm::LogError("TriggerHelper") << "Empty (negated) logical expression ==> decision: " << errorReplyHlt_;
410  return errorReplyHlt_;
411  }
412 
413  // Parse logical expression and determine HLT decision
414  L1GtLogicParser hltAlgoLogicParser(hltLogicalExpression);
415  // Loop over paths
416  for (size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath) {
417  const std::string hltPathName(hltAlgoLogicParser.operandTokenVector().at(iPath).tokenName);
418  const unsigned indexPath(hltConfig_.triggerIndex(hltPathName));
419  // Further error checks
420  if (indexPath == hltConfig_.size()) {
421  edm::LogError("TriggerHelper") << "HLT path \"" << hltPathName << "\" is not found in process "
422  << hltInputTag_.process() << " ==> decision: " << errorReplyHlt_;
423  hltAlgoLogicParser.operandTokenVector().at(iPath).tokenResult = errorReplyHlt_;
424  continue;
425  }
426  if (hltTriggerResults->error(indexPath)) {
427  edm::LogError("TriggerHelper") << "HLT path \"" << hltPathName << "\" in error ==> decision: " << errorReplyHlt_;
428  hltAlgoLogicParser.operandTokenVector().at(iPath).tokenResult = errorReplyHlt_;
429  continue;
430  }
431  // Manipulate algo decision as stored in the parser
432  const bool decision(hltTriggerResults->accept(indexPath));
433  hltAlgoLogicParser.operandTokenVector().at(iPath).tokenResult = decision;
434  }
435 
436  // Determine decision
437  const bool hltDecision(hltAlgoLogicParser.expressionResult());
438  return negExpr ? (!hltDecision) : hltDecision;
439 }
unsigned int size() const
number of trigger paths in trigger table
bool accept() const
Has at least one path accepted the event?
bool negate(std::string &word) const
Checks for negated words.
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
bool error() const
Has any path encountered an error (exception)
edm::InputTag hltInputTag_
Definition: TriggerHelper.h:61
HLTConfigProvider hltConfig_
Definition: TriggerHelper.h:43
std::string const & process() const
Definition: InputTag.h:40
bool TriggerHelper::acceptL1 ( const edm::Event event,
const edm::EventSetup setup 
)
private

Was this event accepted by the configured L1 logical expression combination?

Definition at line 286 of file TriggerHelper.cc.

References acceptL1LogicalExpression(), andOr_, andOrL1_, l1Gt_, l1LogicalExpressions_, and onL1_.

Referenced by accept().

286  {
287  // An empty L1 logical expressions list acts as switch.
288  if (!onL1_ || l1LogicalExpressions_.empty())
289  return (!andOr_); // logically neutral, depending on base logical connective
290 
291  // Getting the L1 event setup
292  l1Gt_->retrieveL1EventSetup(setup); // FIXME This can possibly go to initRun()
293 
294  // Determine decision of L1 logical expression combination and return
295  if (andOrL1_) { // OR combination
296  for (std::vector<std::string>::const_iterator l1LogicalExpression = l1LogicalExpressions_.begin();
297  l1LogicalExpression != l1LogicalExpressions_.end();
298  ++l1LogicalExpression) {
299  if (acceptL1LogicalExpression(event, *l1LogicalExpression))
300  return true;
301  }
302  return false;
303  }
304  for (std::vector<std::string>::const_iterator l1LogicalExpression = l1LogicalExpressions_.begin();
305  l1LogicalExpression != l1LogicalExpressions_.end();
306  ++l1LogicalExpression) {
307  if (!acceptL1LogicalExpression(event, *l1LogicalExpression))
308  return false;
309  }
310  return true;
311 }
std::unique_ptr< L1GtUtils > l1Gt_
Definition: TriggerHelper.h:42
std::vector< std::string > l1LogicalExpressions_
Definition: TriggerHelper.h:58
bool acceptL1LogicalExpression(const edm::Event &event, std::string l1LogicalExpression)
bool TriggerHelper::acceptL1LogicalExpression ( const edm::Event event,
std::string  l1LogicalExpression 
)
private

Was this event accepted by this particular L1 algorithms' logical expression?

Definition at line 315 of file TriggerHelper.cc.

References relativeConstraints::error, errorReplyL1_, L1GtLogicParser::expressionResult(), l1Gt_, negate(), L1GtLogicParser::operandTokenVector(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by acceptL1().

315  {
316  // Check empty std::strings
317  if (l1LogicalExpression.empty()) {
318  edm::LogError("TriggerHelper") << "Empty logical expression ==> decision: " << errorReplyL1_;
319  return errorReplyL1_;
320  }
321 
322  // Negated logical expression
323  bool negExpr(negate(l1LogicalExpression));
324  if (negExpr && l1LogicalExpression.empty()) {
325  edm::LogError("TriggerHelper") << "Empty (negated) logical expression ==> decision: " << errorReplyL1_;
326  return errorReplyL1_;
327  }
328 
329  // Parse logical expression and determine L1 decision
330  L1GtLogicParser l1AlgoLogicParser(l1LogicalExpression);
331  // Loop over algorithms
332  for (size_t iAlgorithm = 0; iAlgorithm < l1AlgoLogicParser.operandTokenVector().size(); ++iAlgorithm) {
333  const std::string l1AlgoName(l1AlgoLogicParser.operandTokenVector().at(iAlgorithm).tokenName);
334  int error(-1);
335  const bool decision(l1Gt_->decision(event, l1AlgoName, error));
336  // Error checks
337  if (error != 0) {
338  if (error == 1)
339  edm::LogError("TriggerHelper") << "L1 algorithm \"" << l1AlgoName
340  << "\" does not exist in the L1 menu ==> decision: " << errorReplyL1_;
341  else
342  edm::LogError("TriggerHelper") << "L1 algorithm \"" << l1AlgoName << "\" received error code " << error
343  << " from L1GtUtils::decisionBeforeMask ==> decision: " << errorReplyL1_;
344  l1AlgoLogicParser.operandTokenVector().at(iAlgorithm).tokenResult = errorReplyL1_;
345  continue;
346  }
347  // Manipulate algo decision as stored in the parser
348  l1AlgoLogicParser.operandTokenVector().at(iAlgorithm).tokenResult = decision;
349  }
350 
351  // Return decision
352  const bool l1Decision(l1AlgoLogicParser.expressionResult());
353  return negExpr ? (!l1Decision) : l1Decision;
354 }
std::unique_ptr< L1GtUtils > l1Gt_
Definition: TriggerHelper.h:42
bool negate(std::string &word) const
Checks for negated words.
std::vector< std::string > TriggerHelper::expressionsFromDB ( const std::string &  key,
const edm::EventSetup setup 
)
private

Reads and returns logical expressions from DB.

Definition at line 442 of file TriggerHelper.cc.

References configError_, AlCaRecoTriggerBits::decompose(), edm::EventSetup::get(), and AlCaRecoTriggerBits::m_alcarecoToTrig.

Referenced by initRun().

442  {
443  edm::ESHandle<AlCaRecoTriggerBits> logicalExpressions;
444  setup.get<AlCaRecoTriggerBitsRcd>().get(logicalExpressions);
445  const std::map<std::string, std::string> &expressionMap = logicalExpressions->m_alcarecoToTrig;
446  std::map<std::string, std::string>::const_iterator listIter = expressionMap.find(key);
447  if (listIter == expressionMap.end()) {
448  edm::LogError("TriggerHelper") << "No logical expressions found under key " << key
449  << " in 'AlCaRecoTriggerBitsRcd'";
450  return std::vector<std::string>(1, configError_);
451  }
452  return logicalExpressions->decompose(listIter->second);
453 }
std::map< std::string, std::string > m_alcarecoToTrig
std::vector< std::string > decompose(const std::string &concatPaths) const
Decompose one value of map from concatenated string.
const std::string configError_
Definition: TriggerHelper.h:72
T get() const
Definition: EventSetup.h:73
void TriggerHelper::initRun ( const edm::Run run,
const edm::EventSetup setup 
)

To be called from beginedm::Run() methods.

Definition at line 89 of file TriggerHelper.cc.

References edm::ESWatcher< T >::check(), configError_, edm::InputTag::encode(), expressionsFromDB(), gtDBKey_, gtLogicalExpressions_, hltConfig_, hltConfigInit_, hltDBKey_, hltInputTag_, hltLogicalExpressions_, HLTConfigProvider::init(), l1DBKey_, l1LogicalExpressions_, onGt_, onHlt_, onL1_, edm::InputTag::process(), HLTConfigProvider::size(), and watchDB_.

89  {
90  // FIXME Can this stay safely in the run loop, or does it need to go to the
91  // event loop? Means: Are the event setups identical?
92  if (watchDB_->check(setup)) {
93  if (onGt_ && !gtDBKey_.empty()) {
94  const std::vector<std::string> exprs(expressionsFromDB(gtDBKey_, setup));
95  if (exprs.empty() || exprs.at(0) != configError_)
96  gtLogicalExpressions_ = exprs;
97  }
98  if (onL1_ && !l1DBKey_.empty()) {
99  const std::vector<std::string> exprs(expressionsFromDB(l1DBKey_, setup));
100  if (exprs.empty() || exprs.at(0) != configError_)
101  l1LogicalExpressions_ = exprs;
102  }
103  if (onHlt_ && !hltDBKey_.empty()) {
104  const std::vector<std::string> exprs(expressionsFromDB(hltDBKey_, setup));
105  if (exprs.empty() || exprs.at(0) != configError_)
106  hltLogicalExpressions_ = exprs;
107  }
108  }
109 
110  hltConfigInit_ = false;
111  if (onHlt_) {
112  if (hltInputTag_.process().empty()) {
113  edm::LogError("TriggerHelper") << "HLT TriggerResults InputTag \"" << hltInputTag_.encode()
114  << "\" specifies no process";
115  } else {
116  bool hltChanged(false);
117  if (!hltConfig_.init(run, setup, hltInputTag_.process(), hltChanged)) {
118  edm::LogError("TriggerHelper") << "HLT config initialization error with process name \""
119  << hltInputTag_.process() << "\"";
120  } else if (hltConfig_.size() <= 0) {
121  edm::LogError("TriggerHelper") << "HLT config size error";
122  } else
123  hltConfigInit_ = true;
124  }
125  }
126 }
unsigned int size() const
number of trigger paths in trigger table
std::vector< std::string > l1LogicalExpressions_
Definition: TriggerHelper.h:58
std::string l1DBKey_
Definition: TriggerHelper.h:57
const std::string configError_
Definition: TriggerHelper.h:72
std::string encode() const
Definition: InputTag.cc:159
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_
Definition: TriggerHelper.h:41
std::vector< std::string > hltLogicalExpressions_
Definition: TriggerHelper.h:63
std::string gtDBKey_
Definition: TriggerHelper.h:53
std::vector< std::string > gtLogicalExpressions_
Definition: TriggerHelper.h:54
edm::InputTag hltInputTag_
Definition: TriggerHelper.h:61
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
HLTConfigProvider hltConfig_
Definition: TriggerHelper.h:43
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
std::string const & process() const
Definition: InputTag.h:40
std::vector< std::string > expressionsFromDB(const std::string &key, const edm::EventSetup &setup)
Reads and returns logical expressions from DB.
std::string hltDBKey_
Definition: TriggerHelper.h:62
bool TriggerHelper::negate ( std::string &  word) const
private

Checks for negated words.

Definition at line 456 of file TriggerHelper.cc.

Referenced by acceptGtLogicalExpression(), acceptHltLogicalExpression(), and acceptL1LogicalExpression().

456  {
457  bool negate(false);
458  if (word.at(0) == '~') {
459  negate = true;
460  word.erase(0, 1);
461  }
462  return negate;
463 }
bool negate(std::string &word) const
Checks for negated words.
uint64_t word
bool TriggerHelper::off ( )
inline
bool TriggerHelper::on ( )
inline

Definition at line 85 of file TriggerHelper.h.

85 { return on_; }

Member Data Documentation

bool TriggerHelper::andOr_
private

Definition at line 46 of file TriggerHelper.h.

Referenced by accept(), acceptDcs(), acceptGt(), acceptHlt(), acceptL1(), and TriggerHelper().

bool TriggerHelper::andOrDcs_
private

Definition at line 47 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

bool TriggerHelper::andOrGt_
private

Definition at line 51 of file TriggerHelper.h.

Referenced by acceptGt(), and TriggerHelper().

bool TriggerHelper::andOrHlt_
private

Definition at line 60 of file TriggerHelper.h.

Referenced by acceptHlt(), and TriggerHelper().

bool TriggerHelper::andOrL1_
private

Definition at line 56 of file TriggerHelper.h.

Referenced by acceptL1(), and TriggerHelper().

const std::string TriggerHelper::configError_
private

Definition at line 72 of file TriggerHelper.h.

Referenced by expressionsFromDB(), and initRun().

edm::InputTag TriggerHelper::dcsInputTag_
private

Definition at line 48 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

std::vector<int> TriggerHelper::dcsPartitions_
private

Definition at line 49 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

bool TriggerHelper::errorReplyDcs_
private
bool TriggerHelper::errorReplyGt_
private

Definition at line 55 of file TriggerHelper.h.

Referenced by acceptGt(), acceptGtLogicalExpression(), and TriggerHelper().

bool TriggerHelper::errorReplyHlt_
private

Definition at line 64 of file TriggerHelper.h.

Referenced by acceptHlt(), acceptHltLogicalExpression(), and TriggerHelper().

bool TriggerHelper::errorReplyL1_
private

Definition at line 59 of file TriggerHelper.h.

Referenced by acceptL1LogicalExpression(), and TriggerHelper().

std::string TriggerHelper::gtDBKey_
private

Definition at line 53 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

edm::InputTag TriggerHelper::gtInputTag_
private

Definition at line 52 of file TriggerHelper.h.

Referenced by acceptGt(), and TriggerHelper().

std::vector<std::string> TriggerHelper::gtLogicalExpressions_
private

Definition at line 54 of file TriggerHelper.h.

Referenced by acceptGt(), initRun(), and TriggerHelper().

HLTConfigProvider TriggerHelper::hltConfig_
private

Definition at line 43 of file TriggerHelper.h.

Referenced by acceptHltLogicalExpression(), and initRun().

bool TriggerHelper::hltConfigInit_
private

Definition at line 44 of file TriggerHelper.h.

Referenced by acceptHlt(), and initRun().

std::string TriggerHelper::hltDBKey_
private

Definition at line 62 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

edm::InputTag TriggerHelper::hltInputTag_
private

Definition at line 61 of file TriggerHelper.h.

Referenced by acceptHlt(), acceptHltLogicalExpression(), initRun(), and TriggerHelper().

std::vector<std::string> TriggerHelper::hltLogicalExpressions_
private

Definition at line 63 of file TriggerHelper.h.

Referenced by acceptHlt(), initRun(), and TriggerHelper().

std::string TriggerHelper::l1DBKey_
private

Definition at line 57 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

std::unique_ptr<L1GtUtils> TriggerHelper::l1Gt_
private

Definition at line 42 of file TriggerHelper.h.

Referenced by acceptL1(), acceptL1LogicalExpression(), and TriggerHelper().

std::vector<std::string> TriggerHelper::l1LogicalExpressions_
private

Definition at line 58 of file TriggerHelper.h.

Referenced by acceptL1(), initRun(), and TriggerHelper().

bool TriggerHelper::on_
private

Definition at line 66 of file TriggerHelper.h.

Referenced by accept(), TriggerHelper(), and ~TriggerHelper().

bool TriggerHelper::onDcs_
private

Definition at line 67 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

bool TriggerHelper::onGt_
private

Definition at line 68 of file TriggerHelper.h.

Referenced by acceptGt(), initRun(), and TriggerHelper().

bool TriggerHelper::onHlt_
private

Definition at line 70 of file TriggerHelper.h.

Referenced by acceptHlt(), initRun(), and TriggerHelper().

bool TriggerHelper::onL1_
private

Definition at line 69 of file TriggerHelper.h.

Referenced by acceptL1(), initRun(), and TriggerHelper().

edm::ESWatcher<AlCaRecoTriggerBitsRcd>* TriggerHelper::watchDB_
private

Definition at line 41 of file TriggerHelper.h.

Referenced by initRun(), TriggerHelper(), and ~TriggerHelper().