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

edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcdalcaRecotriggerBitsToken_
 
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_
 
edm::EDGetTokenT< L1GlobalTriggerReadoutRecordgtInputToken_
 
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 42 of file TriggerHelper.h.

Constructor & Destructor Documentation

◆ TriggerHelper() [1/3]

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

◆ TriggerHelper() [2/3]

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

Definition at line 134 of file TriggerHelper.h.

135  : TriggerHelper(config) {
136  if (onL1_ && (!l1DBKey_.empty() || !l1LogicalExpressions_.empty())) {
137  l1Gt_ = std::make_unique<L1GtUtils>(config, iC, false, module, L1GtUtils::UseEventSetupIn::Event);
138  }
139 }

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

◆ ~TriggerHelper()

TriggerHelper::~TriggerHelper ( )

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

Definition at line 79 of file TriggerHelper.cc.

79  {
80  if (on_)
81  delete watchDB_;
82 }

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 12 of file TriggerHelper.cc.

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

References andOr_, andOrDcs_, andOrGt_, andOrHlt_, andOrL1_, dcsInputTag_, dcsPartitions_, errorReplyDcs_, errorReplyGt_, errorReplyHlt_, errorReplyL1_, gtDBKey_, 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 125 of file TriggerHelper.cc.

125  {
126  if (!on_)
127  return true;
128 
129  // Determine decision
130  if (andOr_)
133 }

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 135 of file TriggerHelper.cc.

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

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 168 of file TriggerHelper.cc.

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

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 208 of file TriggerHelper.cc.

208  {
209  // An empty GT status bits logical expressions list acts as switch.
210  if (!onGt_ || gtLogicalExpressions_.empty())
211  return (!andOr_); // logically neutral, depending on base logical connective
212 
213  // Accessing the L1GlobalTriggerReadoutRecord
215  event.getByToken(gtInputToken_, gtReadoutRecord);
216  if (!gtReadoutRecord.isValid()) {
217  //edm::LogError("TriggerHelper") << "L1GlobalTriggerReadoutRecord product with InputTag \"" << gtInputTag_.encode()
218  // << "\" not in event ==> decision: " << errorReplyGt_;
219  return errorReplyGt_;
220  }
221 
222  // Determine decision of GT status bits logical expression combination and
223  // return
224  if (andOrGt_) { // OR combination
225  for (std::vector<std::string>::const_iterator gtLogicalExpression = gtLogicalExpressions_.begin();
226  gtLogicalExpression != gtLogicalExpressions_.end();
227  ++gtLogicalExpression) {
228  if (acceptGtLogicalExpression(gtReadoutRecord, *gtLogicalExpression))
229  return true;
230  }
231  return false;
232  }
233  for (std::vector<std::string>::const_iterator gtLogicalExpression = gtLogicalExpressions_.begin();
234  gtLogicalExpression != gtLogicalExpressions_.end();
235  ++gtLogicalExpression) {
236  if (!acceptGtLogicalExpression(gtReadoutRecord, *gtLogicalExpression))
237  return false;
238  }
239  return true;
240 }

References acceptGtLogicalExpression(), andOr_, andOrGt_, errorReplyGt_, gtInputToken_, 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 243 of file TriggerHelper.cc.

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

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 354 of file TriggerHelper.cc.

354  {
355  // An empty HLT logical expressions list acts as switch.
356  if (!onHlt_ || hltLogicalExpressions_.empty())
357  return (!andOr_); // logically neutral, depending on base logical connective
358 
359  // Checking the HLT configuration,
360  if (!hltConfigInit_) {
361  edm::LogError("TriggerHelper") << "HLT config error ==> decision: " << errorReplyHlt_;
362  return errorReplyHlt_;
363  }
364 
365  // Accessing the TriggerResults
366  edm::Handle<edm::TriggerResults> hltTriggerResults;
367  event.getByLabel(hltInputTag_, hltTriggerResults);
368  if (!hltTriggerResults.isValid()) {
369  edm::LogError("TriggerHelper") << "TriggerResults product with InputTag \"" << hltInputTag_.encode()
370  << "\" not in event ==> decision: " << errorReplyHlt_;
371  return errorReplyHlt_;
372  }
373 
374  // Determine decision of HLT logical expression combination and return
375  if (andOrHlt_) { // OR combination
376  for (std::vector<std::string>::const_iterator hltLogicalExpression = hltLogicalExpressions_.begin();
377  hltLogicalExpression != hltLogicalExpressions_.end();
378  ++hltLogicalExpression) {
379  if (acceptHltLogicalExpression(hltTriggerResults, *hltLogicalExpression))
380  return true;
381  }
382  return false;
383  }
384  for (std::vector<std::string>::const_iterator hltLogicalExpression = hltLogicalExpressions_.begin();
385  hltLogicalExpression != hltLogicalExpressions_.end();
386  ++hltLogicalExpression) {
387  if (!acceptHltLogicalExpression(hltTriggerResults, *hltLogicalExpression))
388  return false;
389  }
390  return true;
391 }

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 394 of file TriggerHelper.cc.

395  {
396  // Check empty std::strings
397  if (hltLogicalExpression.empty()) {
398  edm::LogError("TriggerHelper") << "Empty logical expression ==> decision: " << errorReplyHlt_;
399  return errorReplyHlt_;
400  }
401 
402  // Negated paths
403  bool negExpr(negate(hltLogicalExpression));
404  if (negExpr && hltLogicalExpression.empty()) {
405  edm::LogError("TriggerHelper") << "Empty (negated) logical expression ==> decision: " << errorReplyHlt_;
406  return errorReplyHlt_;
407  }
408 
409  // Parse logical expression and determine HLT decision
410  L1GtLogicParser hltAlgoLogicParser(hltLogicalExpression);
411  // Loop over paths
412  for (size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath) {
413  const std::string hltPathName(hltAlgoLogicParser.operandTokenVector().at(iPath).tokenName);
414  const unsigned indexPath(hltConfig_.triggerIndex(hltPathName));
415  // Further error checks
416  if (indexPath == hltConfig_.size()) {
417  edm::LogError("TriggerHelper") << "HLT path \"" << hltPathName << "\" is not found in process "
418  << hltInputTag_.process() << " ==> decision: " << errorReplyHlt_;
419  hltAlgoLogicParser.operandTokenVector().at(iPath).tokenResult = errorReplyHlt_;
420  continue;
421  }
422  if (hltTriggerResults->error(indexPath)) {
423  edm::LogError("TriggerHelper") << "HLT path \"" << hltPathName << "\" in error ==> decision: " << errorReplyHlt_;
424  hltAlgoLogicParser.operandTokenVector().at(iPath).tokenResult = errorReplyHlt_;
425  continue;
426  }
427  // Manipulate algo decision as stored in the parser
428  const bool decision(hltTriggerResults->accept(indexPath));
429  hltAlgoLogicParser.operandTokenVector().at(iPath).tokenResult = decision;
430  }
431 
432  // Determine decision
433  const bool hltDecision(hltAlgoLogicParser.expressionResult());
434  return negExpr ? (!hltDecision) : hltDecision;
435 }

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 282 of file TriggerHelper.cc.

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

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 311 of file TriggerHelper.cc.

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

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 438 of file TriggerHelper.cc.

438  {
439  const AlCaRecoTriggerBits *logicalExpressions = &(setup.getData(alcaRecotriggerBitsToken_));
440  const std::map<std::string, std::string> &expressionMap = logicalExpressions->m_alcarecoToTrig;
441  std::map<std::string, std::string>::const_iterator listIter = expressionMap.find(key);
442  if (listIter == expressionMap.end()) {
443  edm::LogError("TriggerHelper") << "No logical expressions found under key " << key
444  << " in 'AlCaRecoTriggerBitsRcd'";
445  return std::vector<std::string>(1, configError_);
446  }
447  return logicalExpressions->decompose(listIter->second);
448 }

References alcaRecotriggerBitsToken_, configError_, AlCaRecoTriggerBits::decompose(), 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 85 of file TriggerHelper.cc.

85  {
86  // FIXME Can this stay safely in the run loop, or does it need to go to the
87  // event loop? Means: Are the event setups identical?
88  if (watchDB_->check(setup)) {
89  if (onGt_ && !gtDBKey_.empty()) {
90  const std::vector<std::string> exprs(expressionsFromDB(gtDBKey_, setup));
91  if (exprs.empty() || exprs.at(0) != configError_)
92  gtLogicalExpressions_ = exprs;
93  }
94  if (onL1_ && !l1DBKey_.empty()) {
95  const std::vector<std::string> exprs(expressionsFromDB(l1DBKey_, setup));
96  if (exprs.empty() || exprs.at(0) != configError_)
97  l1LogicalExpressions_ = exprs;
98  }
99  if (onHlt_ && !hltDBKey_.empty()) {
100  const std::vector<std::string> exprs(expressionsFromDB(hltDBKey_, setup));
101  if (exprs.empty() || exprs.at(0) != configError_)
102  hltLogicalExpressions_ = exprs;
103  }
104  }
105 
106  hltConfigInit_ = false;
107  if (onHlt_) {
108  if (hltInputTag_.process().empty()) {
109  edm::LogError("TriggerHelper") << "HLT TriggerResults InputTag \"" << hltInputTag_.encode()
110  << "\" specifies no process";
111  } else {
112  bool hltChanged(false);
113  if (!hltConfig_.init(run, setup, hltInputTag_.process(), hltChanged)) {
114  edm::LogError("TriggerHelper") << "HLT config initialization error with process name \""
115  << hltInputTag_.process() << "\"";
116  } else if (hltConfig_.size() <= 0) {
117  edm::LogError("TriggerHelper") << "HLT config size error";
118  } else
119  hltConfigInit_ = true;
120  }
121  }
122 }

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 451 of file TriggerHelper.cc.

451  {
452  bool negate(false);
453  if (word.at(0) == '~') {
454  negate = true;
455  word.erase(0, 1);
456  }
457  return negate;
458 }

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

◆ off()

bool TriggerHelper::off ( )
inline

Definition at line 91 of file TriggerHelper.h.

91 { return (!on_); }

References on_.

◆ on()

bool TriggerHelper::on ( )
inline

Definition at line 90 of file TriggerHelper.h.

90 { return on_; }

References on_.

Member Data Documentation

◆ alcaRecotriggerBitsToken_

edm::ESGetToken<AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd> TriggerHelper::alcaRecotriggerBitsToken_
private

Definition at line 62 of file TriggerHelper.h.

Referenced by expressionsFromDB(), and TriggerHelper().

◆ andOr_

bool TriggerHelper::andOr_
private

Definition at line 49 of file TriggerHelper.h.

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

◆ andOrDcs_

bool TriggerHelper::andOrDcs_
private

Definition at line 50 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

◆ andOrGt_

bool TriggerHelper::andOrGt_
private

Definition at line 54 of file TriggerHelper.h.

Referenced by acceptGt(), and TriggerHelper().

◆ andOrHlt_

bool TriggerHelper::andOrHlt_
private

Definition at line 65 of file TriggerHelper.h.

Referenced by acceptHlt(), and TriggerHelper().

◆ andOrL1_

bool TriggerHelper::andOrL1_
private

Definition at line 60 of file TriggerHelper.h.

Referenced by acceptL1(), and TriggerHelper().

◆ configError_

const std::string TriggerHelper::configError_
private

Definition at line 77 of file TriggerHelper.h.

Referenced by expressionsFromDB(), and initRun().

◆ dcsInputTag_

edm::InputTag TriggerHelper::dcsInputTag_
private

Definition at line 51 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

◆ dcsPartitions_

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

Definition at line 52 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

◆ errorReplyDcs_

bool TriggerHelper::errorReplyDcs_
private

◆ errorReplyGt_

bool TriggerHelper::errorReplyGt_
private

Definition at line 59 of file TriggerHelper.h.

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

◆ errorReplyHlt_

bool TriggerHelper::errorReplyHlt_
private

Definition at line 69 of file TriggerHelper.h.

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

◆ errorReplyL1_

bool TriggerHelper::errorReplyL1_
private

Definition at line 64 of file TriggerHelper.h.

Referenced by acceptL1LogicalExpression(), and TriggerHelper().

◆ gtDBKey_

std::string TriggerHelper::gtDBKey_
private

Definition at line 57 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

◆ gtInputTag_

edm::InputTag TriggerHelper::gtInputTag_
private

Definition at line 55 of file TriggerHelper.h.

Referenced by TriggerHelper().

◆ gtInputToken_

edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> TriggerHelper::gtInputToken_
private

Definition at line 56 of file TriggerHelper.h.

Referenced by acceptGt(), and TriggerHelper().

◆ gtLogicalExpressions_

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

Definition at line 58 of file TriggerHelper.h.

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

◆ hltConfig_

HLTConfigProvider TriggerHelper::hltConfig_
private

Definition at line 46 of file TriggerHelper.h.

Referenced by acceptHltLogicalExpression(), and initRun().

◆ hltConfigInit_

bool TriggerHelper::hltConfigInit_
private

Definition at line 47 of file TriggerHelper.h.

Referenced by acceptHlt(), and initRun().

◆ hltDBKey_

std::string TriggerHelper::hltDBKey_
private

Definition at line 67 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

◆ hltInputTag_

edm::InputTag TriggerHelper::hltInputTag_
private

Definition at line 66 of file TriggerHelper.h.

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

◆ hltLogicalExpressions_

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

Definition at line 68 of file TriggerHelper.h.

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

◆ l1DBKey_

std::string TriggerHelper::l1DBKey_
private

Definition at line 61 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

◆ l1Gt_

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

Definition at line 45 of file TriggerHelper.h.

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

◆ l1LogicalExpressions_

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

Definition at line 63 of file TriggerHelper.h.

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

◆ on_

bool TriggerHelper::on_
private

Definition at line 71 of file TriggerHelper.h.

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

◆ onDcs_

bool TriggerHelper::onDcs_
private

Definition at line 72 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

◆ onGt_

bool TriggerHelper::onGt_
private

Definition at line 73 of file TriggerHelper.h.

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

◆ onHlt_

bool TriggerHelper::onHlt_
private

Definition at line 75 of file TriggerHelper.h.

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

◆ onL1_

bool TriggerHelper::onL1_
private

Definition at line 74 of file TriggerHelper.h.

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

◆ watchDB_

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

Definition at line 44 of file TriggerHelper.h.

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

edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
DcsStatus::EEp
Definition: DcsStatus.h:36
DcsStatus::HBHEc
Definition: DcsStatus.h:40
TriggerHelper::hltConfigInit_
bool hltConfigInit_
Definition: TriggerHelper.h:47
TriggerHelper::errorReplyGt_
bool errorReplyGt_
Definition: TriggerHelper.h:59
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:282
DcsStatus::EEm
Definition: DcsStatus.h:37
TriggerHelper::acceptGt
bool acceptGt(const edm::Event &event)
Definition: TriggerHelper.cc:208
TriggerHelper::andOrGt_
bool andOrGt_
Definition: TriggerHelper.h:54
edm::ESWatcher< AlCaRecoTriggerBitsRcd >
L1GtUtils::UseEventSetupIn::Event
DcsStatus::BPIX
Definition: DcsStatus.h:55
L1GtFdlWord::physicsDeclared
const cms_uint16_t physicsDeclared() const
get/set "physics declared" bit
Definition: L1GtFdlWord.h:169
TriggerHelper::alcaRecotriggerBitsToken_
edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > alcaRecotriggerBitsToken_
Definition: TriggerHelper.h:62
DcsStatus::TIBTID
Definition: DcsStatus.h:51
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:394
DcsStatus::HO
Definition: DcsStatus.h:42
TriggerHelper::dcsPartitions_
std::vector< int > dcsPartitions_
Definition: TriggerHelper.h:52
TriggerHelper::hltInputTag_
edm::InputTag hltInputTag_
Definition: TriggerHelper.h:66
DcsStatus::HBHEa
Definition: DcsStatus.h:38
TriggerHelper::onHlt_
bool onHlt_
Definition: TriggerHelper.h:75
DcsStatus::CSCp
Definition: DcsStatus.h:47
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
DcsStatus::CASTOR
Definition: DcsStatus.h:49
TriggerHelper::acceptHlt
bool acceptHlt(const edm::Event &event)
Definition: TriggerHelper.cc:354
TriggerHelper::hltConfig_
HLTConfigProvider hltConfig_
Definition: TriggerHelper.h:46
TriggerHelper::andOr_
bool andOr_
Definition: TriggerHelper.h:49
TriggerHelper::configError_
const std::string configError_
Definition: TriggerHelper.h:77
TriggerHelper::errorReplyL1_
bool errorReplyL1_
Definition: TriggerHelper.h:64
DcsStatus::DT0
Definition: DcsStatus.h:44
edm::ConsumesCollector::esConsumes
auto esConsumes()
Definition: ConsumesCollector.h:97
edm::Handle
Definition: AssociativeIterator.h:50
relativeConstraints.error
error
Definition: relativeConstraints.py:53
DcsStatus::DTp
Definition: DcsStatus.h:45
TriggerHelper::errorReplyDcs_
bool errorReplyDcs_
Definition: TriggerHelper.h:53
L1GlobalTriggerReadoutRecord
Definition: L1GlobalTriggerReadoutRecord.h:46
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
TriggerHelper::l1LogicalExpressions_
std::vector< std::string > l1LogicalExpressions_
Definition: TriggerHelper.h:63
TriggerHelper::on_
bool on_
Definition: TriggerHelper.h:71
DcsStatus::HBHEb
Definition: DcsStatus.h:39
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
TriggerHelper::acceptDcs
bool acceptDcs(const edm::Event &event)
Definition: TriggerHelper.cc:135
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:438
config
Definition: config.py:1
TriggerHelper::hltDBKey_
std::string hltDBKey_
Definition: TriggerHelper.h:67
TriggerHelper::onL1_
bool onL1_
Definition: TriggerHelper.h:74
DcsStatus::ESm
Definition: DcsStatus.h:58
TriggerHelper::andOrDcs_
bool andOrDcs_
Definition: TriggerHelper.h:50
DcsStatus::TOB
Definition: DcsStatus.h:52
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
AlCaRecoTriggerBits::decompose
std::vector< std::string > decompose(const std::string &concatPaths) const
Decompose one value of map from concatenated string.
Definition: AlCaRecoTriggerBits.cc:31
AlCaRecoTriggerBits
Definition: AlCaRecoTriggerBits.h:9
TriggerHelper::andOrHlt_
bool andOrHlt_
Definition: TriggerHelper.h:65
HLTConfigProvider::size
unsigned int size() const
number of trigger paths in trigger table
Definition: HLTConfigProvider.h:63
AlCaRecoTriggerBitsRcd
Definition: AlCaRecoTriggerBitsRcd.h:22
TriggerHelper::onDcs_
bool onDcs_
Definition: TriggerHelper.h:72
DcsStatus::TECm
Definition: DcsStatus.h:54
TriggerHelper::onGt_
bool onGt_
Definition: TriggerHelper.h:73
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:243
DcsStatus::DTm
Definition: DcsStatus.h:46
TriggerHelper::gtDBKey_
std::string gtDBKey_
Definition: TriggerHelper.h:57
DcsStatus::FPIX
Definition: DcsStatus.h:56
edm::InputTag::encode
std::string encode() const
Definition: InputTag.cc:159
TriggerHelper::errorReplyHlt_
bool errorReplyHlt_
Definition: TriggerHelper.h:69
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
TriggerHelper::hltLogicalExpressions_
std::vector< std::string > hltLogicalExpressions_
Definition: TriggerHelper.h:68
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TriggerHelper::acceptDcsPartition
bool acceptDcsPartition(const edm::Handle< DcsStatusCollection > &dcsStatus, int dcsPartition) const
Definition: TriggerHelper.cc:168
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:73
TriggerHelper::gtInputTag_
edm::InputTag gtInputTag_
Definition: TriggerHelper.h:55
callgraph.module
module
Definition: callgraph.py:61
TriggerHelper::gtInputToken_
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtInputToken_
Definition: TriggerHelper.h:56
DcsStatus::HF
Definition: DcsStatus.h:41
DcsStatus::EBm
Definition: DcsStatus.h:35
TriggerHelper::negate
bool negate(std::string &word) const
Checks for negated words.
Definition: TriggerHelper.cc:451
writedatasetfile.run
run
Definition: writedatasetfile.py:27
TriggerHelper::l1Gt_
std::unique_ptr< L1GtUtils > l1Gt_
Definition: TriggerHelper.h:45
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:51
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:311
TriggerHelper::andOrL1_
bool andOrL1_
Definition: TriggerHelper.h:60
TriggerHelper::l1DBKey_
std::string l1DBKey_
Definition: TriggerHelper.h:61
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:58
DcsStatus::TECp
Definition: DcsStatus.h:53
DcsStatus::CSCm
Definition: DcsStatus.h:48
DcsStatus::EBp
Definition: DcsStatus.h:34
TriggerHelper::watchDB_
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_
Definition: TriggerHelper.h:44
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
crabWrapper.key
key
Definition: crabWrapper.py:19
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
DcsStatus::ESp
Definition: DcsStatus.h:57
DcsStatus::RPC
Definition: DcsStatus.h:43
TriggerHelper::TriggerHelper
TriggerHelper(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, T &module)
Definition: TriggerHelper.h:126