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

◆ TriggerHelper() [1/3]

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() [2/3]

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

Definition at line 125 of file TriggerHelper.h.

126  : TriggerHelper(config) {
127  if (onL1_ && (!l1DBKey_.empty() || !l1LogicalExpressions_.empty())) {
129  }
130 }

References L1GtUtils::Event, l1DBKey_, l1Gt_, l1LogicalExpressions_, and onL1_.

◆ ~TriggerHelper()

TriggerHelper::~TriggerHelper ( )

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

Definition at line 83 of file TriggerHelper.cc.

83  {
84  if (on_)
85  delete watchDB_;
86 }

References on_, and watchDB_.

◆ TriggerHelper() [3/3]

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.

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 }

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

Member Function Documentation

◆ accept()

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.

129  {
130  if (!on_)
131  return true;
132 
133  // Determine decision
134  if (andOr_)
137 }

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

Referenced by esMonitoring.FDJsonServer::handle_accept().

◆ acceptDcs()

bool TriggerHelper::acceptDcs ( const edm::Event event)
private

Definition at line 139 of file TriggerHelper.cc.

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 }

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

Referenced by accept().

◆ acceptDcsPartition()

bool TriggerHelper::acceptDcsPartition ( const edm::Handle< DcsStatusCollection > &  dcsStatus,
int  dcsPartition 
) const
private

Definition at line 172 of file TriggerHelper.cc.

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 }

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().

◆ acceptGt()

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.

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 }

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

Referenced by accept().

◆ acceptGtLogicalExpression()

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.

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 }

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

Referenced by acceptGt().

◆ acceptHlt()

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.

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 }

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

Referenced by accept().

◆ acceptHltLogicalExpression()

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.

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 }

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().

◆ acceptL1()

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.

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 }

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

Referenced by accept().

◆ acceptL1LogicalExpression()

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.

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 }

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

Referenced by acceptL1().

◆ expressionsFromDB()

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.

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 }

References configError_, AlCaRecoTriggerBits::decompose(), get, crabWrapper::key, AlCaRecoTriggerBits::m_alcarecoToTrig, and singleTopDQM_cfi::setup.

Referenced by initRun().

◆ initRun()

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.

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 }

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(), writedatasetfile::run, singleTopDQM_cfi::setup, HLTConfigProvider::size(), and watchDB_.

◆ negate()

bool TriggerHelper::negate ( std::string &  word) const
private

Checks for negated words.

Definition at line 456 of file TriggerHelper.cc.

456  {
457  bool negate(false);
458  if (word.at(0) == '~') {
459  negate = true;
460  word.erase(0, 1);
461  }
462  return negate;
463 }

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

◆ off()

bool TriggerHelper::off ( )
inline

Definition at line 86 of file TriggerHelper.h.

86 { return (!on_); }

References on_.

◆ on()

bool TriggerHelper::on ( )
inline

Definition at line 85 of file TriggerHelper.h.

85 { return on_; }

References on_.

Member Data Documentation

◆ andOr_

bool TriggerHelper::andOr_
private

Definition at line 46 of file TriggerHelper.h.

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

◆ andOrDcs_

bool TriggerHelper::andOrDcs_
private

Definition at line 47 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

◆ andOrGt_

bool TriggerHelper::andOrGt_
private

Definition at line 51 of file TriggerHelper.h.

Referenced by acceptGt(), and TriggerHelper().

◆ andOrHlt_

bool TriggerHelper::andOrHlt_
private

Definition at line 60 of file TriggerHelper.h.

Referenced by acceptHlt(), and TriggerHelper().

◆ andOrL1_

bool TriggerHelper::andOrL1_
private

Definition at line 56 of file TriggerHelper.h.

Referenced by acceptL1(), and TriggerHelper().

◆ configError_

const std::string TriggerHelper::configError_
private

Definition at line 72 of file TriggerHelper.h.

Referenced by expressionsFromDB(), and initRun().

◆ dcsInputTag_

edm::InputTag TriggerHelper::dcsInputTag_
private

Definition at line 48 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

◆ dcsPartitions_

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

Definition at line 49 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

◆ errorReplyDcs_

bool TriggerHelper::errorReplyDcs_
private

◆ errorReplyGt_

bool TriggerHelper::errorReplyGt_
private

Definition at line 55 of file TriggerHelper.h.

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

◆ errorReplyHlt_

bool TriggerHelper::errorReplyHlt_
private

Definition at line 64 of file TriggerHelper.h.

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

◆ errorReplyL1_

bool TriggerHelper::errorReplyL1_
private

Definition at line 59 of file TriggerHelper.h.

Referenced by acceptL1LogicalExpression(), and TriggerHelper().

◆ gtDBKey_

std::string TriggerHelper::gtDBKey_
private

Definition at line 53 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

◆ gtInputTag_

edm::InputTag TriggerHelper::gtInputTag_
private

Definition at line 52 of file TriggerHelper.h.

Referenced by acceptGt(), and TriggerHelper().

◆ gtLogicalExpressions_

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

Definition at line 54 of file TriggerHelper.h.

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

◆ hltConfig_

HLTConfigProvider TriggerHelper::hltConfig_
private

Definition at line 43 of file TriggerHelper.h.

Referenced by acceptHltLogicalExpression(), and initRun().

◆ hltConfigInit_

bool TriggerHelper::hltConfigInit_
private

Definition at line 44 of file TriggerHelper.h.

Referenced by acceptHlt(), and initRun().

◆ hltDBKey_

std::string TriggerHelper::hltDBKey_
private

Definition at line 62 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

◆ hltInputTag_

edm::InputTag TriggerHelper::hltInputTag_
private

Definition at line 61 of file TriggerHelper.h.

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

◆ hltLogicalExpressions_

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

Definition at line 63 of file TriggerHelper.h.

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

◆ l1DBKey_

std::string TriggerHelper::l1DBKey_
private

Definition at line 57 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

◆ l1Gt_

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

Definition at line 42 of file TriggerHelper.h.

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

◆ l1LogicalExpressions_

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

Definition at line 58 of file TriggerHelper.h.

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

◆ on_

bool TriggerHelper::on_
private

Definition at line 66 of file TriggerHelper.h.

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

◆ onDcs_

bool TriggerHelper::onDcs_
private

Definition at line 67 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

◆ onGt_

bool TriggerHelper::onGt_
private

Definition at line 68 of file TriggerHelper.h.

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

◆ onHlt_

bool TriggerHelper::onHlt_
private

Definition at line 70 of file TriggerHelper.h.

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

◆ onL1_

bool TriggerHelper::onL1_
private

Definition at line 69 of file TriggerHelper.h.

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

◆ watchDB_

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

Definition at line 41 of file TriggerHelper.h.

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

edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
TriggerHelper::hltConfigInit_
bool hltConfigInit_
Definition: TriggerHelper.h:44
TriggerHelper::errorReplyGt_
bool errorReplyGt_
Definition: TriggerHelper.h:55
TriggerHelper::acceptL1
bool acceptL1(const edm::Event &event, const edm::EventSetup &setup)
Was this event accepted by the configured L1 logical expression combination?
Definition: TriggerHelper.cc:286
TriggerHelper::acceptGt
bool acceptGt(const edm::Event &event)
Definition: TriggerHelper.cc:212
TriggerHelper::andOrGt_
bool andOrGt_
Definition: TriggerHelper.h:51
DcsStatus::CASTOR
Definition: DcsStatus.h:49
DcsStatus::TIBTID
Definition: DcsStatus.h:51
edm::ESWatcher< AlCaRecoTriggerBitsRcd >
L1GtUtils::UseEventSetupIn::Event
DcsStatus::DTm
Definition: DcsStatus.h:46
L1GtFdlWord::physicsDeclared
const cms_uint16_t physicsDeclared() const
get/set "physics declared" bit
Definition: L1GtFdlWord.h:169
TriggerHelper::acceptHltLogicalExpression
bool acceptHltLogicalExpression(const edm::Handle< edm::TriggerResults > &hltTriggerResults, std::string hltLogicalExpression) const
Was this event accepted by this particular HLT paths' logical expression?
Definition: TriggerHelper.cc:398
DcsStatus::EBm
Definition: DcsStatus.h:35
DcsStatus::ESp
Definition: DcsStatus.h:57
TriggerHelper::dcsPartitions_
std::vector< int > dcsPartitions_
Definition: TriggerHelper.h:49
TriggerHelper::hltInputTag_
edm::InputTag hltInputTag_
Definition: TriggerHelper.h:61
TriggerHelper::onHlt_
bool onHlt_
Definition: TriggerHelper.h:70
edm::InputTag::process
std::string const & process() const
Definition: InputTag.h:40
edm::HLTGlobalStatus::error
bool error() const
Has any path encountered an error (exception)
Definition: HLTGlobalStatus.h:51
TriggerHelper::acceptHlt
bool acceptHlt(const edm::Event &event)
Definition: TriggerHelper.cc:358
TriggerHelper::hltConfig_
HLTConfigProvider hltConfig_
Definition: TriggerHelper.h:43
TriggerHelper::andOr_
bool andOr_
Definition: TriggerHelper.h:46
DcsStatus::EEm
Definition: DcsStatus.h:37
TriggerHelper::configError_
const std::string configError_
Definition: TriggerHelper.h:72
TriggerHelper::errorReplyL1_
bool errorReplyL1_
Definition: TriggerHelper.h:59
edm::Handle
Definition: AssociativeIterator.h:50
relativeConstraints.error
error
Definition: relativeConstraints.py:53
DcsStatus::DT0
Definition: DcsStatus.h:44
TriggerHelper::errorReplyDcs_
bool errorReplyDcs_
Definition: TriggerHelper.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
TriggerHelper::l1LogicalExpressions_
std::vector< std::string > l1LogicalExpressions_
Definition: TriggerHelper.h:58
TriggerHelper::on_
bool on_
Definition: TriggerHelper.h:66
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
TriggerHelper::acceptDcs
bool acceptDcs(const edm::Event &event)
Definition: TriggerHelper.cc:139
TriggerHelper::expressionsFromDB
std::vector< std::string > expressionsFromDB(const std::string &key, const edm::EventSetup &setup)
Reads and returns logical expressions from DB.
Definition: TriggerHelper.cc:442
config
Definition: config.py:1
TriggerHelper::hltDBKey_
std::string hltDBKey_
Definition: TriggerHelper.h:62
TriggerHelper::onL1_
bool onL1_
Definition: TriggerHelper.h:69
DcsStatus::HBHEc
Definition: DcsStatus.h:40
edm::ESHandle
Definition: DTSurvey.h:22
DcsStatus::TECm
Definition: DcsStatus.h:54
TriggerHelper::andOrDcs_
bool andOrDcs_
Definition: TriggerHelper.h:47
L1GtUtils
Definition: L1GtUtils.h:66
AlCaRecoTriggerBits::decompose
std::vector< std::string > decompose(const std::string &concatPaths) const
Decompose one value of map from concatenated string.
Definition: AlCaRecoTriggerBits.cc:31
DcsStatus::HO
Definition: DcsStatus.h:42
DcsStatus::HBHEa
Definition: DcsStatus.h:38
TriggerHelper::andOrHlt_
bool andOrHlt_
Definition: TriggerHelper.h:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTConfigProvider::size
unsigned int size() const
number of trigger paths in trigger table
Definition: HLTConfigProvider.h:62
DcsStatus::CSCp
Definition: DcsStatus.h:47
DcsStatus::CSCm
Definition: DcsStatus.h:48
AlCaRecoTriggerBitsRcd
Definition: AlCaRecoTriggerBitsRcd.h:22
edm::LogError
Definition: MessageLogger.h:183
TriggerHelper::onDcs_
bool onDcs_
Definition: TriggerHelper.h:67
TriggerHelper::onGt_
bool onGt_
Definition: TriggerHelper.h:68
TriggerHelper::acceptGtLogicalExpression
bool acceptGtLogicalExpression(const edm::Handle< L1GlobalTriggerReadoutRecord > &gtReadoutRecord, std::string gtLogicalExpression)
Does this event fulfill this particular GT status bits' logical expression?
Definition: TriggerHelper.cc:247
TriggerHelper::gtDBKey_
std::string gtDBKey_
Definition: TriggerHelper.h:53
DcsStatus::EBp
Definition: DcsStatus.h:34
edm::InputTag::encode
std::string encode() const
Definition: InputTag.cc:159
TriggerHelper::errorReplyHlt_
bool errorReplyHlt_
Definition: TriggerHelper.h:64
DcsStatus::TECp
Definition: DcsStatus.h:53
TriggerHelper::hltLogicalExpressions_
std::vector< std::string > hltLogicalExpressions_
Definition: TriggerHelper.h:63
module
Definition: vlib.h:198
get
#define get
TriggerHelper::acceptDcsPartition
bool acceptDcsPartition(const edm::Handle< DcsStatusCollection > &dcsStatus, int dcsPartition) const
Definition: TriggerHelper.cc:172
HLTConfigProvider::triggerIndex
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
Definition: HLTConfigProvider.h:72
TriggerHelper::gtInputTag_
edm::InputTag gtInputTag_
Definition: TriggerHelper.h:52
DcsStatus::FPIX
Definition: DcsStatus.h:56
DcsStatus::EEp
Definition: DcsStatus.h:36
DcsStatus::TOB
Definition: DcsStatus.h:52
TriggerHelper::negate
bool negate(std::string &word) const
Checks for negated words.
Definition: TriggerHelper.cc:456
writedatasetfile.run
run
Definition: writedatasetfile.py:27
TriggerHelper::l1Gt_
std::unique_ptr< L1GtUtils > l1Gt_
Definition: TriggerHelper.h:42
DcsStatus::HF
Definition: DcsStatus.h:41
HLTConfigProvider::init
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
Definition: HLTConfigProvider.cc:36
TriggerHelper::dcsInputTag_
edm::InputTag dcsInputTag_
Definition: TriggerHelper.h:48
AlCaRecoTriggerBits::m_alcarecoToTrig
std::map< std::string, std::string > m_alcarecoToTrig
Definition: AlCaRecoTriggerBits.h:21
L1GtLogicParser
Definition: L1GtLogicParser.h:31
TriggerHelper::acceptL1LogicalExpression
bool acceptL1LogicalExpression(const edm::Event &event, std::string l1LogicalExpression)
Definition: TriggerHelper.cc:315
DcsStatus::BPIX
Definition: DcsStatus.h:55
TriggerHelper::andOrL1_
bool andOrL1_
Definition: TriggerHelper.h:56
TriggerHelper::l1DBKey_
std::string l1DBKey_
Definition: TriggerHelper.h:57
edm::HLTGlobalStatus::accept
bool accept() const
Has at least one path accepted the event?
Definition: HLTGlobalStatus.h:49
TriggerHelper::gtLogicalExpressions_
std::vector< std::string > gtLogicalExpressions_
Definition: TriggerHelper.h:54
DcsStatus::RPC
Definition: DcsStatus.h:43
DcsStatus::HBHEb
Definition: DcsStatus.h:39
DcsStatus::DTp
Definition: DcsStatus.h:45
TriggerHelper::watchDB_
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_
Definition: TriggerHelper.h:41
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
crabWrapper.key
key
Definition: crabWrapper.py:19
DcsStatus::ESm
Definition: DcsStatus.h:58
L1GlobalTriggerReadoutRecord::gtFdlWord
const L1GtFdlWord gtFdlWord(int bxInEventValue) const
get / set FDL word (record) in the GT readout record
Definition: L1GlobalTriggerReadoutRecord.cc:372
edm::InputTag
Definition: InputTag.h:15
TriggerHelper::TriggerHelper
TriggerHelper(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, T &module)
Definition: TriggerHelper.h:121