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
Version
Id:
TriggerHelper.h,v 1.8 2010/03/27 12:09:10 dutta Exp

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

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

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

Definition at line 86 of file TriggerHelper.cc.

References on_, and watchDB_.

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

Member Function Documentation

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

To be called from analyze/filter() methods.

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

134 {
135 
136  if ( ! on_ ) return true;
137 
138  // Determine decision
139  if ( andOr_ ) return ( acceptDcs( event ) || acceptGt( event ) || acceptL1( event, setup ) || acceptHlt( event ) );
140  return ( acceptDcs( event ) && acceptGt( event ) && acceptL1( event, setup ) && acceptHlt( event ) );
141 
142 }
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 145 of file TriggerHelper.cc.

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

Referenced by accept().

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

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

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

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

Definition at line 216 of file TriggerHelper.cc.

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

Referenced by accept().

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

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

Referenced by acceptGt().

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

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

Referenced by accept().

355 {
356 
357  // An empty HLT logical expressions list acts as switch.
358  if ( ! onHlt_ || hltLogicalExpressions_.empty() ) return ( ! andOr_ ); // logically neutral, depending on base logical connective
359 
360  // Checking the HLT configuration,
361  if ( ! hltConfigInit_ ) {
362  edm::LogError( "TriggerHelper" ) << "HLT config error ==> decision: " << errorReplyHlt_;
363  return errorReplyHlt_;
364  }
365 
366  // Accessing the TriggerResults
367  edm::Handle< edm::TriggerResults > hltTriggerResults;
368  event.getByLabel( hltInputTag_, hltTriggerResults );
369  if ( ! hltTriggerResults.isValid() ) {
370  edm::LogError( "TriggerHelper" ) << "TriggerResults product with InputTag \"" << hltInputTag_.encode() << "\" 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(); hltLogicalExpression != hltLogicalExpressions_.end(); ++hltLogicalExpression ) {
377  if ( acceptHltLogicalExpression( hltTriggerResults, *hltLogicalExpression ) ) return true;
378  }
379  return false;
380  }
381  for ( std::vector< std::string >::const_iterator hltLogicalExpression = hltLogicalExpressions_.begin(); hltLogicalExpression != hltLogicalExpressions_.end(); ++hltLogicalExpression ) {
382  if ( ! acceptHltLogicalExpression( hltTriggerResults, *hltLogicalExpression ) ) return false;
383  }
384  return true;
385 
386 }
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:58
bool isValid() const
Definition: HandleBase.h:76
std::vector< std::string > hltLogicalExpressions_
Definition: TriggerHelper.h:60
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 390 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().

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

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

Referenced by accept().

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

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

Referenced by acceptL1().

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

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

Referenced by initRun().

438 {
439 
440  edm::ESHandle< AlCaRecoTriggerBits > logicalExpressions;
441  setup.get< AlCaRecoTriggerBitsRcd >().get( logicalExpressions );
442  const std::map< std::string, std::string > & expressionMap = logicalExpressions->m_alcarecoToTrig;
443  std::map< std::string, std::string >::const_iterator listIter = expressionMap.find( key );
444  if ( listIter == expressionMap.end() ) {
445  edm::LogError( "TriggerHelper" ) << "No logical expressions found under key " << key << " in 'AlCaRecoTriggerBitsRcd'";
446  return std::vector< std::string >( 1, configError_ );
447  }
448  return logicalExpressions->decompose( listIter->second );
449 
450 }
const std::string configError_
Definition: TriggerHelper.h:69
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 95 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_.

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

Checks for negated words.

Definition at line 455 of file TriggerHelper.cc.

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

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

Definition at line 79 of file TriggerHelper.h.

References on_.

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

Definition at line 78 of file TriggerHelper.h.

References on_.

78 { return on_ ; }

Member Data Documentation

bool TriggerHelper::andOr_
private

Definition at line 43 of file TriggerHelper.h.

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

bool TriggerHelper::andOrDcs_
private

Definition at line 44 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

bool TriggerHelper::andOrGt_
private

Definition at line 48 of file TriggerHelper.h.

Referenced by acceptGt(), and TriggerHelper().

bool TriggerHelper::andOrHlt_
private

Definition at line 57 of file TriggerHelper.h.

Referenced by acceptHlt(), and TriggerHelper().

bool TriggerHelper::andOrL1_
private

Definition at line 53 of file TriggerHelper.h.

Referenced by acceptL1(), and TriggerHelper().

const std::string TriggerHelper::configError_
private

Definition at line 69 of file TriggerHelper.h.

Referenced by expressionsFromDB(), and initRun().

edm::InputTag TriggerHelper::dcsInputTag_
private

Definition at line 45 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

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

Definition at line 46 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

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

Definition at line 52 of file TriggerHelper.h.

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

bool TriggerHelper::errorReplyHlt_
private

Definition at line 61 of file TriggerHelper.h.

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

bool TriggerHelper::errorReplyL1_
private

Definition at line 56 of file TriggerHelper.h.

Referenced by acceptL1LogicalExpression(), and TriggerHelper().

std::string TriggerHelper::gtDBKey_
private

Definition at line 50 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

edm::InputTag TriggerHelper::gtInputTag_
private

Definition at line 49 of file TriggerHelper.h.

Referenced by acceptGt(), and TriggerHelper().

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

Definition at line 51 of file TriggerHelper.h.

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

HLTConfigProvider TriggerHelper::hltConfig_
private

Definition at line 40 of file TriggerHelper.h.

Referenced by acceptHltLogicalExpression(), and initRun().

bool TriggerHelper::hltConfigInit_
private

Definition at line 41 of file TriggerHelper.h.

Referenced by acceptHlt(), and initRun().

std::string TriggerHelper::hltDBKey_
private

Definition at line 59 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

edm::InputTag TriggerHelper::hltInputTag_
private

Definition at line 58 of file TriggerHelper.h.

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

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

Definition at line 60 of file TriggerHelper.h.

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

std::string TriggerHelper::l1DBKey_
private

Definition at line 54 of file TriggerHelper.h.

Referenced by initRun(), and TriggerHelper().

L1GtUtils TriggerHelper::l1Gt_
private

Definition at line 39 of file TriggerHelper.h.

Referenced by acceptL1(), and acceptL1LogicalExpression().

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

Definition at line 55 of file TriggerHelper.h.

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

bool TriggerHelper::on_
private

Definition at line 63 of file TriggerHelper.h.

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

bool TriggerHelper::onDcs_
private

Definition at line 64 of file TriggerHelper.h.

Referenced by acceptDcs(), and TriggerHelper().

bool TriggerHelper::onGt_
private

Definition at line 65 of file TriggerHelper.h.

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

bool TriggerHelper::onHlt_
private

Definition at line 67 of file TriggerHelper.h.

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

bool TriggerHelper::onL1_
private

Definition at line 66 of file TriggerHelper.h.

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

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

Definition at line 38 of file TriggerHelper.h.

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