test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 "DQM/TrackerCommon/interface/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 ()
 
 TriggerHelper (const edm::ParameterSet &config)
 To be called from the ED module's c'tor. More...
 
 ~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)
 Does this event fulfill the configured GT status logical expression combination? More...
 
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)
 Was this event accepted by the configured HLT logical expression combination? More...
 
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)
 Was this event accepted by this particular L1 algorithms' logical expression? More...
 
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...
 

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

[...]

Author
Volker Adler

Definition at line 33 of file TriggerHelper.h.

Constructor & Destructor Documentation

TriggerHelper::TriggerHelper ( const edm::ParameterSet config)

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

Definition at line 18 of file TriggerHelper.cc.

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

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

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

Definition at line 85 of file TriggerHelper.cc.

References on_, and watchDB_.

86 {
87 
88  if ( on_ ) delete watchDB_;
89 
90 }
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_
Definition: TriggerHelper.h:36

Member Function Documentation

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

To be called from analyze/filter() methods.

Definition at line 132 of file TriggerHelper.cc.

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

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

133 {
134 
135  if ( ! on_ ) return true;
136 
137  // Determine decision
138  if ( andOr_ ) return ( acceptDcs( event ) || acceptGt( event ) || acceptL1( event, setup ) || acceptHlt( event ) );
139  return ( acceptDcs( event ) && acceptGt( event ) && acceptL1( event, setup ) && acceptHlt( event ) );
140 
141 }
bool acceptHlt(const edm::Event &event)
Was this event accepted by the configured HLT logical expression combination?
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)
Does this event fulfill the configured GT status logical expression combination?
bool TriggerHelper::acceptDcs ( const edm::Event event)
private

Definition at line 144 of file TriggerHelper.cc.

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

Referenced by accept().

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

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

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

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

Definition at line 215 of file TriggerHelper.cc.

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

Referenced by accept().

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

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

Referenced by acceptGt().

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

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

Definition at line 353 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 
356  // An empty HLT logical expressions list acts as switch.
357  if ( ! onHlt_ || hltLogicalExpressions_.empty() ) 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() << "\" not in event ==> decision: " << errorReplyHlt_;
370  return errorReplyHlt_;
371  }
372 
373  // Determine decision of HLT logical expression combination and return
374  if ( andOrHlt_ ) { // OR combination
375  for ( std::vector< std::string >::const_iterator hltLogicalExpression = hltLogicalExpressions_.begin(); hltLogicalExpression != hltLogicalExpressions_.end(); ++hltLogicalExpression ) {
376  if ( acceptHltLogicalExpression( hltTriggerResults, *hltLogicalExpression ) ) return true;
377  }
378  return false;
379  }
380  for ( std::vector< std::string >::const_iterator hltLogicalExpression = hltLogicalExpressions_.begin(); hltLogicalExpression != hltLogicalExpressions_.end(); ++hltLogicalExpression ) {
381  if ( ! acceptHltLogicalExpression( hltTriggerResults, *hltLogicalExpression ) ) return false;
382  }
383  return true;
384 
385 }
bool acceptHltLogicalExpression(const edm::Handle< edm::TriggerResults > &hltTriggerResults, std::string hltLogicalExpression) const
Was this event accepted by this particular HLT paths&#39; logical expression?
std::string encode() const
Definition: InputTag.cc:164
edm::InputTag hltInputTag_
Definition: TriggerHelper.h:56
bool isValid() const
Definition: HandleBase.h:76
std::vector< std::string > hltLogicalExpressions_
Definition: TriggerHelper.h:58
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 389 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().

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

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

Definition at line 286 of file TriggerHelper.cc.

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

Referenced by accept().

287 {
288 
289  // An empty L1 logical expressions list acts as switch.
290  if ( ! onL1_ || l1LogicalExpressions_.empty() ) return ( ! andOr_ ); // logically neutral, depending on base logical connective
291 
292  // Getting the L1 event setup
293  l1Gt_.retrieveL1EventSetup( setup ); // FIXME This can possibly go to initRun()
294 
295  // Determine decision of L1 logical expression combination and return
296  if ( andOrL1_ ) { // OR combination
297  for ( std::vector< std::string >::const_iterator l1LogicalExpression = l1LogicalExpressions_.begin(); l1LogicalExpression != l1LogicalExpressions_.end(); ++l1LogicalExpression ) {
298  if ( acceptL1LogicalExpression( event, *l1LogicalExpression ) ) return true;
299  }
300  return false;
301  }
302  for ( std::vector< std::string >::const_iterator l1LogicalExpression = l1LogicalExpressions_.begin(); l1LogicalExpression != l1LogicalExpressions_.end(); ++l1LogicalExpression ) {
303  if ( ! acceptL1LogicalExpression( event, *l1LogicalExpression ) ) return false;
304  }
305  return true;
306 
307 }
std::vector< std::string > l1LogicalExpressions_
Definition: TriggerHelper.h:53
L1GtUtils l1Gt_
Definition: TriggerHelper.h:37
void retrieveL1EventSetup(const edm::EventSetup &)
retrieve all the relevant L1 trigger event setup records and cache them to improve the speed ...
Definition: L1GtUtils.cc:111
bool acceptL1LogicalExpression(const edm::Event &event, std::string l1LogicalExpression)
Was this event accepted by this particular L1 algorithms&#39; logical expression?
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 L1GtUtils::decision(), relativeConstraints::error, errorReplyL1_, L1GtLogicParser::expressionResult(), l1Gt_, negate(), L1GtLogicParser::operandTokenVector(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by acceptL1().

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

References configError_, and edm::EventSetup::get().

Referenced by initRun().

437 {
438 
439  edm::ESHandle< AlCaRecoTriggerBits > logicalExpressions;
440  setup.get< AlCaRecoTriggerBitsRcd >().get( logicalExpressions );
441  const std::map< std::string, std::string > & expressionMap = logicalExpressions->m_alcarecoToTrig;
442  std::map< std::string, std::string >::const_iterator listIter = expressionMap.find( key );
443  if ( listIter == expressionMap.end() ) {
444  edm::LogError( "TriggerHelper" ) << "No logical expressions found under key " << key << " in 'AlCaRecoTriggerBitsRcd'";
445  return std::vector< std::string >( 1, configError_ );
446  }
447  return logicalExpressions->decompose( listIter->second );
448 
449 }
const std::string configError_
Definition: TriggerHelper.h:67
const T & get() const
Definition: EventSetup.h:55
list key
Definition: combine.py:13
void TriggerHelper::initRun ( const edm::Run run,
const edm::EventSetup setup 
)

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

Definition at line 94 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_.

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

Checks for negated words.

Definition at line 454 of file TriggerHelper.cc.

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

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

Definition at line 77 of file TriggerHelper.h.

References on_.

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

Definition at line 76 of file TriggerHelper.h.

References on_.

76 { return on_ ; }

Member Data Documentation

bool TriggerHelper::andOr_
private

Definition at line 41 of file TriggerHelper.h.

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

bool TriggerHelper::andOrDcs_
private

Definition at line 42 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

bool TriggerHelper::andOrGt_
private

Definition at line 46 of file TriggerHelper.h.

Referenced by acceptGt(), and TriggerHelper().

bool TriggerHelper::andOrHlt_
private

Definition at line 55 of file TriggerHelper.h.

Referenced by acceptHlt(), and TriggerHelper().

bool TriggerHelper::andOrL1_
private

Definition at line 51 of file TriggerHelper.h.

Referenced by acceptL1(), and TriggerHelper().

const std::string TriggerHelper::configError_
private

Definition at line 67 of file TriggerHelper.h.

Referenced by expressionsFromDB(), and initRun().

edm::InputTag TriggerHelper::dcsInputTag_
private

Definition at line 43 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

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

Definition at line 44 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

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

Definition at line 50 of file TriggerHelper.h.

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

bool TriggerHelper::errorReplyHlt_
private

Definition at line 59 of file TriggerHelper.h.

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

bool TriggerHelper::errorReplyL1_
private

Definition at line 54 of file TriggerHelper.h.

Referenced by acceptL1LogicalExpression(), and TriggerHelper().

std::string TriggerHelper::gtDBKey_
private

Definition at line 48 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

edm::InputTag TriggerHelper::gtInputTag_
private

Definition at line 47 of file TriggerHelper.h.

Referenced by acceptGt(), and TriggerHelper().

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

Definition at line 49 of file TriggerHelper.h.

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

HLTConfigProvider TriggerHelper::hltConfig_
private

Definition at line 38 of file TriggerHelper.h.

Referenced by acceptHltLogicalExpression(), and initRun().

bool TriggerHelper::hltConfigInit_
private

Definition at line 39 of file TriggerHelper.h.

Referenced by acceptHlt(), and initRun().

std::string TriggerHelper::hltDBKey_
private

Definition at line 57 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

edm::InputTag TriggerHelper::hltInputTag_
private

Definition at line 56 of file TriggerHelper.h.

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

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

Definition at line 58 of file TriggerHelper.h.

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

std::string TriggerHelper::l1DBKey_
private

Definition at line 52 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

L1GtUtils TriggerHelper::l1Gt_
private

Definition at line 37 of file TriggerHelper.h.

Referenced by acceptL1(), and acceptL1LogicalExpression().

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

Definition at line 53 of file TriggerHelper.h.

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

bool TriggerHelper::on_
private

Definition at line 61 of file TriggerHelper.h.

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

bool TriggerHelper::onDcs_
private

Definition at line 62 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

bool TriggerHelper::onGt_
private

Definition at line 63 of file TriggerHelper.h.

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

bool TriggerHelper::onHlt_
private

Definition at line 65 of file TriggerHelper.h.

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

bool TriggerHelper::onL1_
private

Definition at line 64 of file TriggerHelper.h.

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

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

Definition at line 36 of file TriggerHelper.h.

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