CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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,
AlCaRecoTriggerBitsRcd
alcaRecotriggerBitsToken_
 
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
< L1GlobalTriggerReadoutRecord
gtInputToken_
 
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

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

Definition at line 126 of file TriggerHelper.h.

References alcaRecotriggerBitsToken_, edm::ParameterSet::getParameter(), gtInputTag_, and gtInputToken_.

127  : TriggerHelper(config, iC, module) {
128  gtInputTag_ = config.getParameter<edm::InputTag>("gtInputTag");
131 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
TriggerHelper(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, T &module)
edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > alcaRecotriggerBitsToken_
Definition: TriggerHelper.h:62
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::InputTag gtInputTag_
Definition: TriggerHelper.h:55
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtInputToken_
Definition: TriggerHelper.h:56
tuple module
Definition: callgraph.py:69
template<typename T >
TriggerHelper::TriggerHelper ( const edm::ParameterSet config,
edm::ConsumesCollector iC,
T module 
)

Definition at line 134 of file TriggerHelper.h.

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

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 }
std::unique_ptr< L1GtUtils > l1Gt_
Definition: TriggerHelper.h:45
std::vector< std::string > l1LogicalExpressions_
Definition: TriggerHelper.h:63
std::string l1DBKey_
Definition: TriggerHelper.h:61
TriggerHelper(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, T &module)
tuple config
parse the configuration file
tuple module
Definition: callgraph.py:69
TriggerHelper::~TriggerHelper ( )

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

Definition at line 79 of file TriggerHelper.cc.

References on_, and watchDB_.

79  {
80  if (on_)
81  delete watchDB_;
82 }
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_
Definition: TriggerHelper.h:44
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.

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

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 }
std::vector< std::string > l1LogicalExpressions_
Definition: TriggerHelper.h:63
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string l1DBKey_
Definition: TriggerHelper.h:61
const std::string configError_
Definition: TriggerHelper.h:77
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_
Definition: TriggerHelper.h:44
std::vector< std::string > hltLogicalExpressions_
Definition: TriggerHelper.h:68
std::string gtDBKey_
Definition: TriggerHelper.h:57
std::vector< std::string > gtLogicalExpressions_
Definition: TriggerHelper.h:58
edm::InputTag hltInputTag_
Definition: TriggerHelper.h:66
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< int > dcsPartitions_
Definition: TriggerHelper.h:52
edm::InputTag dcsInputTag_
Definition: TriggerHelper.h:51
std::string hltDBKey_
Definition: TriggerHelper.h:67

Member Function Documentation

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.

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

Referenced by esMonitoring.FDJsonServer::handle_accept().

125  {
126  if (!on_)
127  return true;
128 
129  // Determine decision
130  if (andOr_)
131  return (acceptDcs(event) || acceptGt(event) || acceptL1(event, setup) || acceptHlt(event));
132  return (acceptDcs(event) && acceptGt(event) && acceptL1(event, setup) && acceptHlt(event));
133 }
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 135 of file TriggerHelper.cc.

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

Referenced by accept().

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 }
Log< level::Error, false > LogError
std::string encode() const
Definition: InputTag.cc:159
bool isValid() const
Definition: HandleBase.h:70
std::vector< int > dcsPartitions_
Definition: TriggerHelper.h:52
bool acceptDcsPartition(const edm::Handle< DcsStatusCollection > &dcsStatus, int dcsPartition) const
edm::InputTag dcsInputTag_
Definition: TriggerHelper.h:51
bool TriggerHelper::acceptDcsPartition ( const edm::Handle< DcsStatusCollection > &  dcsStatus,
int  dcsPartition 
) const
private

Definition at line 168 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().

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 }
Log< level::Error, false > LogError
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.

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

Referenced by accept().

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 }
bool acceptGtLogicalExpression(const edm::Handle< L1GlobalTriggerReadoutRecord > &gtReadoutRecord, std::string gtLogicalExpression)
Does this event fulfill this particular GT status bits&#39; logical expression?
std::vector< std::string > gtLogicalExpressions_
Definition: TriggerHelper.h:58
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtInputToken_
Definition: TriggerHelper.h:56
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.

References errorReplyDcs_, errorReplyGt_, L1GtLogicParser::expressionResult(), negate(), L1GtLogicParser::operandTokenVector(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by acceptGt().

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 }
bool negate(std::string &word) const
Checks for negated words.
Log< level::Error, false > LogError
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.

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

Referenced by accept().

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 }
bool acceptHltLogicalExpression(const edm::Handle< edm::TriggerResults > &hltTriggerResults, std::string hltLogicalExpression) const
Was this event accepted by this particular HLT paths&#39; logical expression?
Log< level::Error, false > LogError
std::string encode() const
Definition: InputTag.cc:159
std::vector< std::string > hltLogicalExpressions_
Definition: TriggerHelper.h:68
edm::InputTag hltInputTag_
Definition: TriggerHelper.h:66
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 394 of file TriggerHelper.cc.

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

Referenced by acceptHlt().

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 }
unsigned int size() const
number of trigger paths in trigger table
bool negate(std::string &word) const
Checks for negated words.
Log< level::Error, false > LogError
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
edm::InputTag hltInputTag_
Definition: TriggerHelper.h:66
HLTConfigProvider hltConfig_
Definition: TriggerHelper.h:46
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 282 of file TriggerHelper.cc.

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

Referenced by accept().

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 }
std::unique_ptr< L1GtUtils > l1Gt_
Definition: TriggerHelper.h:45
std::vector< std::string > l1LogicalExpressions_
Definition: TriggerHelper.h:63
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 311 of file TriggerHelper.cc.

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

Referenced by acceptL1().

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 }
std::unique_ptr< L1GtUtils > l1Gt_
Definition: TriggerHelper.h:45
bool negate(std::string &word) const
Checks for negated words.
Log< level::Error, false > LogError
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.

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

Referenced by initRun().

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 }
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:77
Log< level::Error, false > LogError
bool getData(T &iHolder) const
Definition: EventSetup.h:128
edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > alcaRecotriggerBitsToken_
Definition: TriggerHelper.h:62
tuple key
prepare the HTCondor submission files and eventually submit them
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.

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_.

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 }
unsigned int size() const
number of trigger paths in trigger table
std::vector< std::string > l1LogicalExpressions_
Definition: TriggerHelper.h:63
std::string l1DBKey_
Definition: TriggerHelper.h:61
const std::string configError_
Definition: TriggerHelper.h:77
Log< level::Error, false > LogError
std::string encode() const
Definition: InputTag.cc:159
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_
Definition: TriggerHelper.h:44
std::vector< std::string > hltLogicalExpressions_
Definition: TriggerHelper.h:68
std::string gtDBKey_
Definition: TriggerHelper.h:57
std::vector< std::string > gtLogicalExpressions_
Definition: TriggerHelper.h:58
edm::InputTag hltInputTag_
Definition: TriggerHelper.h:66
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
HLTConfigProvider hltConfig_
Definition: TriggerHelper.h:46
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
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:67
bool TriggerHelper::negate ( std::string &  word) const
private

Checks for negated words.

Definition at line 451 of file TriggerHelper.cc.

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

451  {
452  bool negate(false);
453  if (word.at(0) == '~') {
454  negate = true;
455  word.erase(0, 1);
456  }
457  return negate;
458 }
bool negate(std::string &word) const
Checks for negated words.
uint64_t word
bool TriggerHelper::off ( )
inline

Definition at line 91 of file TriggerHelper.h.

References on_.

91 { return (!on_); }
bool TriggerHelper::on ( )
inline

Definition at line 90 of file TriggerHelper.h.

References on_.

90 { return on_; }

Member Data Documentation

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

Definition at line 62 of file TriggerHelper.h.

Referenced by expressionsFromDB(), and TriggerHelper().

bool TriggerHelper::andOr_
private

Definition at line 49 of file TriggerHelper.h.

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

bool TriggerHelper::andOrDcs_
private

Definition at line 50 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

bool TriggerHelper::andOrGt_
private

Definition at line 54 of file TriggerHelper.h.

Referenced by acceptGt(), and TriggerHelper().

bool TriggerHelper::andOrHlt_
private

Definition at line 65 of file TriggerHelper.h.

Referenced by acceptHlt(), and TriggerHelper().

bool TriggerHelper::andOrL1_
private

Definition at line 60 of file TriggerHelper.h.

Referenced by acceptL1(), and TriggerHelper().

const std::string TriggerHelper::configError_
private

Definition at line 77 of file TriggerHelper.h.

Referenced by expressionsFromDB(), and initRun().

edm::InputTag TriggerHelper::dcsInputTag_
private

Definition at line 51 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

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

Definition at line 52 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

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

Definition at line 59 of file TriggerHelper.h.

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

bool TriggerHelper::errorReplyHlt_
private

Definition at line 69 of file TriggerHelper.h.

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

bool TriggerHelper::errorReplyL1_
private

Definition at line 64 of file TriggerHelper.h.

Referenced by acceptL1LogicalExpression(), and TriggerHelper().

std::string TriggerHelper::gtDBKey_
private

Definition at line 57 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

edm::InputTag TriggerHelper::gtInputTag_
private

Definition at line 55 of file TriggerHelper.h.

Referenced by TriggerHelper().

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

Definition at line 56 of file TriggerHelper.h.

Referenced by acceptGt(), and TriggerHelper().

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

Definition at line 58 of file TriggerHelper.h.

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

HLTConfigProvider TriggerHelper::hltConfig_
private

Definition at line 46 of file TriggerHelper.h.

Referenced by acceptHltLogicalExpression(), and initRun().

bool TriggerHelper::hltConfigInit_
private

Definition at line 47 of file TriggerHelper.h.

Referenced by acceptHlt(), and initRun().

std::string TriggerHelper::hltDBKey_
private

Definition at line 67 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

edm::InputTag TriggerHelper::hltInputTag_
private

Definition at line 66 of file TriggerHelper.h.

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

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

Definition at line 68 of file TriggerHelper.h.

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

std::string TriggerHelper::l1DBKey_
private

Definition at line 61 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

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

Definition at line 45 of file TriggerHelper.h.

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

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

Definition at line 63 of file TriggerHelper.h.

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

bool TriggerHelper::on_
private

Definition at line 71 of file TriggerHelper.h.

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

bool TriggerHelper::onDcs_
private

Definition at line 72 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

bool TriggerHelper::onGt_
private

Definition at line 73 of file TriggerHelper.h.

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

bool TriggerHelper::onHlt_
private

Definition at line 75 of file TriggerHelper.h.

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

bool TriggerHelper::onL1_
private

Definition at line 74 of file TriggerHelper.h.

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

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

Definition at line 44 of file TriggerHelper.h.

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