CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
GenericTriggerEventFlag 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 "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"

Public Member Functions

bool accept (const edm::Event &event, const edm::EventSetup &setup)
 To be called from analyze/filter() methods. More...
 
std::vector< std::string > expressionsFromDB (const std::string &key, const edm::EventSetup &setup)
 Reads and returns logical expressions from DB. More...
 
 GenericTriggerEventFlag (const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
 
 GenericTriggerEventFlag (const edm::ParameterSet &config, edm::ConsumesCollector &iC)
 
template<typename T >
 GenericTriggerEventFlag (const edm::ParameterSet &config, edm::ConsumesCollector &&iC, T &module)
 
template<typename T >
 GenericTriggerEventFlag (const edm::ParameterSet &config, edm::ConsumesCollector &iC, T &module)
 
std::string gtDBKey ()
 
std::string hltDBKey ()
 
void initRun (const edm::Run &run, const edm::EventSetup &setup)
 To be called from beginRun() methods. More...
 
std::string l1DBKey ()
 
bool off ()
 
bool on ()
 

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::Event &event, 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, const edm::EventSetup &setup, std::string l1LogicalExpression)
 Was this event accepted by this particular L1 algorithms' logical expression? More...
 
std::string expandLogicalExpression (const std::vector< std::string > &target, const std::string &expr, bool useAnd=false) const
 Expand wild-carded logical expressions, giving version postfixes priority. More...
 
 GenericTriggerEventFlag (const edm::ParameterSet &config, edm::ConsumesCollector &iC, bool stage1Valid)
 To be called from the ED module's c'tor. 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_
 
std::string dbLabel_
 
edm::InputTag dcsInputTag_
 
edm::EDGetTokenT< DcsStatusCollectiondcsInputToken_
 
std::vector< int > dcsPartitions_
 
const std::string emptyKeyError_
 
bool errorReplyDcs_
 
bool errorReplyGt_
 
bool errorReplyHlt_
 
bool errorReplyL1_
 
std::string gtDBKey_
 
edm::InputTag gtEvmInputTag_
 
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecordgtEvmInputToken_
 
edm::InputTag gtInputTag_
 
edm::EDGetTokenT< L1GlobalTriggerReadoutRecordgtInputToken_
 
std::vector< std::string > gtLogicalExpressions_
 
HLTConfigProvider hltConfig_
 
bool hltConfigInit_
 
std::string hltDBKey_
 
edm::InputTag hltInputTag_
 
edm::EDGetTokenT< edm::TriggerResultshltInputToken_
 
std::vector< std::string > hltLogicalExpressions_
 
std::vector< std::string > hltLogicalExpressionsCache_
 
bool l1BeforeMask_
 
std::string l1DBKey_
 
std::unique_ptr< L1GtUtilsl1Gt_
 
std::vector< std::string > l1LogicalExpressions_
 
std::vector< std::string > l1LogicalExpressionsCache_
 
std::unique_ptr< l1t::L1TGlobalUtill1uGt_
 
bool on_
 
bool onDcs_
 
bool onGt_
 
bool onHlt_
 
bool onL1_
 
bool stage2_
 
unsigned verbose_
 
std::unique_ptr< 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
GenericTriggerEventFlag.h,v 1.5 2012/01/19 20:17:34 vadler Exp

Definition at line 41 of file GenericTriggerEventFlag.h.

Constructor & Destructor Documentation

GenericTriggerEventFlag::GenericTriggerEventFlag ( const edm::ParameterSet config,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 98 of file GenericTriggerEventFlag.h.

Referenced by off().

98  :
99  GenericTriggerEventFlag(config,iC){}
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
GenericTriggerEventFlag::GenericTriggerEventFlag ( const edm::ParameterSet config,
edm::ConsumesCollector iC 
)

Definition at line 24 of file GenericTriggerEventFlag.cc.

References edm::ParameterSet::exists(), l1uGt_, and stage2_.

24  :
25  GenericTriggerEventFlag(config,iC,false)
26 {
27  if ( config.exists( "andOrL1" ) ) {
28  if (stage2_){
29  l1uGt_.reset(new l1t::L1TGlobalUtil(config, iC));
30  }
31  }
32 }
bool exists(std::string const &parameterName) const
checks if a parameter exists
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
std::unique_ptr< l1t::L1TGlobalUtil > l1uGt_
template<typename T >
GenericTriggerEventFlag::GenericTriggerEventFlag ( const edm::ParameterSet config,
edm::ConsumesCollector &&  iC,
T module 
)

Definition at line 153 of file GenericTriggerEventFlag.h.

153  :
154  GenericTriggerEventFlag(config, iC, module) {
155 }
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
Definition: vlib.h:208
template<typename T >
GenericTriggerEventFlag::GenericTriggerEventFlag ( const edm::ParameterSet config,
edm::ConsumesCollector iC,
T module 
)

Definition at line 158 of file GenericTriggerEventFlag.h.

References looper::config, edm::ParameterSet::exists(), l1Gt_, l1uGt_, python.rootplot.argparse::module, and stage2_.

158  :
159  GenericTriggerEventFlag(config, iC,true) {
160  if ( config.exists( "andOrL1" ) ) {
161  if (stage2_){
162  l1uGt_ = std::make_unique<l1t::L1TGlobalUtil>(config, iC);
163  }else{
164  l1Gt_ = std::make_unique<L1GtUtils>(config, iC, false, module);
165  }
166  }
167  //these pointers are already null so no need to reset them to a nullptr
168  //if andOrL1 doesnt exist
169 }
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::unique_ptr< L1GtUtils > l1Gt_
config
Definition: looper.py:287
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
std::unique_ptr< l1t::L1TGlobalUtil > l1uGt_
GenericTriggerEventFlag::GenericTriggerEventFlag ( const edm::ParameterSet config,
edm::ConsumesCollector iC,
bool  stage1Valid 
)
private

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

Definition at line 35 of file GenericTriggerEventFlag.cc.

References andOr_, andOrDcs_, andOrGt_, andOrHlt_, andOrL1_, dbLabel_, dcsInputTag_, dcsInputToken_, dcsPartitions_, errorReplyDcs_, errorReplyGt_, errorReplyHlt_, errorReplyL1_, Exception, edm::ParameterSet::exists(), funct::false, edm::ParameterSet::getParameter(), gtDBKey_, gtEvmInputTag_, gtEvmInputToken_, gtInputTag_, gtInputToken_, gtLogicalExpressions_, hltDBKey_, hltInputTag_, hltInputToken_, hltLogicalExpressionsCache_, l1BeforeMask_, l1DBKey_, l1LogicalExpressionsCache_, edm::ConsumesCollector::mayConsume(), on_, onDcs_, onGt_, onHlt_, onL1_, stage2_, AlCaHLTBitMon_QueryRunRegistry::string, verbose_, and watchDB_.

36  : watchDB_()
37  , hltConfigInit_( false )
38  , andOr_( false )
39  , dbLabel_( "" )
40  , verbose_( 0 )
41  , andOrDcs_( false )
42  , errorReplyDcs_( false )
43  , andOrGt_( false )
44  , gtInputTag_( "" )
45  , gtEvmInputTag_( "" )
46  , gtDBKey_( "" )
47  , errorReplyGt_( false )
48  , andOrL1_( false )
49  , stage2_( false )
50  , l1BeforeMask_( true )
51  , l1DBKey_( "" )
52  , errorReplyL1_( false )
53  , andOrHlt_( false )
54  , hltDBKey_( "" )
55  , errorReplyHlt_( false )
56  , on_( true )
57  , onDcs_( true )
58  , onGt_( true )
59  , onL1_( true )
60  , onHlt_( true )
61  , configError_( "CONFIG_ERROR" )
62  , emptyKeyError_( "EMPTY_KEY_ERROR" )
63 {
64 
65  // General switch(es)
66  if ( config.exists( "andOr" ) ) {
67  andOr_ = config.getParameter< bool >( "andOr" );
68  if ( config.exists( "verbosityLevel" ) ) verbose_ = config.getParameter< unsigned >( "verbosityLevel" );
69  } else {
70  on_ = false;
71  onDcs_ = false;
72  onGt_ = false;
73  onL1_ = false;
74  onHlt_ = false;
75  }
76 
77  if ( on_ ) {
78  if ( config.exists( "andOrDcs" ) ) {
79  andOrDcs_ = config.getParameter< bool >( "andOrDcs" );
80  dcsInputTag_ = config.getParameter< edm::InputTag >( "dcsInputTag" );
82  dcsPartitions_ = config.getParameter< std::vector< int > >( "dcsPartitions" );
83  errorReplyDcs_ = config.getParameter< bool >( "errorReplyDcs" );
84  } else {
85  onDcs_ = false;
86  }
87  if ( config.exists( "andOrGt" ) ) {
88  andOrGt_ = config.getParameter< bool >( "andOrGt" );
89  gtInputTag_ = config.getParameter< edm::InputTag >( "gtInputTag" );
91  gtLogicalExpressions_ = config.getParameter< std::vector< std::string > >( "gtStatusBits" );
92  errorReplyGt_ = config.getParameter< bool >( "errorReplyGt" );
93  if ( config.exists( "gtEvmInputTag" ) ) {
94  gtEvmInputTag_ = config.getParameter< edm::InputTag >( "gtEvmInputTag" );
96  }
97  if ( config.exists( "gtDBKey" ) ) gtDBKey_ = config.getParameter< std::string >( "gtDBKey" );
98  } else {
99  onGt_ = false;
100  }
101  if ( config.exists( "andOrL1" ) ) {
102  andOrL1_ = config.getParameter< bool >( "andOrL1" );
103  if ( config.exists( "stage2" ) )
104  stage2_ = config.getParameter< bool> ( "stage2" );
105  else
106  stage2_ = false;
107  l1LogicalExpressionsCache_ = config.getParameter< std::vector< std::string > >( "l1Algorithms" );
108  errorReplyL1_ = config.getParameter< bool >( "errorReplyL1" );
109  if ( config.exists( "l1DBKey" ) ) l1DBKey_ = config.getParameter< std::string >( "l1DBKey" );
110  if ( config.exists( "l1BeforeMask" ) ) l1BeforeMask_ = config.getParameter< bool >( "l1BeforeMask" );
111  } else {
112  onL1_ = false;
113  }
114  if ( config.exists( "andOrHlt" ) ) {
115  andOrHlt_ = config.getParameter< bool >( "andOrHlt" );
116  hltInputTag_ = config.getParameter< edm::InputTag >( "hltInputTag" );
118  hltLogicalExpressionsCache_ = config.getParameter< std::vector< std::string > >( "hltPaths" );
119  errorReplyHlt_ = config.getParameter< bool >( "errorReplyHlt" );
120  if ( config.exists( "hltDBKey" ) ) hltDBKey_ = config.getParameter< std::string >( "hltDBKey" );
121  } else {
122  onHlt_ = false;
123  }
124  if ( ! onDcs_ && ! onGt_ && ! onL1_ && ! onHlt_ ) on_ = false;
125  else {
126  if ( config.exists( "dbLabel" ) ) dbLabel_ = config.getParameter< std::string >( "dbLabel" );
127  watchDB_ = std::make_unique<edm::ESWatcher< AlCaRecoTriggerBitsRcd > >();
128  }
129  }
130  //check to see we arent trying to setup legacy / stage-1 from a constructor call
131  //that does not support it
132  if ( config.exists( "andOrL1" ) && stage2_ == false ){ //stage-1 setup
133  if( stage1Valid==false ) throw cms::Exception("ConfigError") <<" Error when constructing GenericTriggerEventFlag, legacy/stage-1 is requested but the constructor called is stage2 only";
134  }
135 }
T getParameter(std::string const &) const
std::vector< int > dcsPartitions_
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtInputToken_
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
std::vector< std::string > gtLogicalExpressions_
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< edm::TriggerResults > hltInputToken_
std::vector< std::string > l1LogicalExpressionsCache_
edm::EDGetTokenT< DcsStatusCollection > dcsInputToken_
std::unique_ptr< edm::ESWatcher< AlCaRecoTriggerBitsRcd > > watchDB_
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > gtEvmInputToken_
std::vector< DcsStatus > DcsStatusCollection
Definition: DcsStatus.h:116
std::vector< std::string > hltLogicalExpressionsCache_

Member Function Documentation

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

To be called from analyze/filter() methods.

Definition at line 244 of file GenericTriggerEventFlag.cc.

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

Referenced by dEdxAnalyzer::analyze(), dEdxHitAnalyzer::analyze(), MonitorTrackResidualsBase< pixel_or_strip >::analyze(), SiStripMonitorCluster::analyze(), V0Monitor::analyze(), TagAndProbeBtagTriggerMonitor::analyze(), LogMessageMonitor::analyze(), SiStripMonitorTrack::analyze(), TrackingMonitor::analyze(), BPHMonitor::analyze(), Vispa.Gui.BoxContentDialog.BoxContentDialog::apply(), Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog::apply(), HLTDQMTagAndProbeEff< TagType, TagCollType, ProbeType, ProbeCollType >::fill(), esMonitoring.FDJsonServer::handle_accept(), and off().

245 {
246 
247  if ( ! on_ ) return true;
248 
249  // Determine decision
250  if ( andOr_ ) return ( acceptDcs( event ) || acceptGt( event ) || acceptL1( event, setup ) || acceptHlt( event ) );
251  return ( acceptDcs( event ) && acceptGt( event ) && acceptL1( event, setup ) && acceptHlt( event ) );
252 
253 }
bool acceptHlt(const edm::Event &event)
Was this event accepted by the configured HLT logical expression combination?
bool acceptDcs(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 acceptGt(const edm::Event &event)
Does this event fulfill the configured GT status logical expression combination?
bool GenericTriggerEventFlag::acceptDcs ( const edm::Event event)
private

Definition at line 256 of file GenericTriggerEventFlag.cc.

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

Referenced by accept(), and off().

257 {
258 
259  // An empty DCS partitions list acts as switch.
260  if ( ! onDcs_ || dcsPartitions_.empty() ) return ( ! andOr_ ); // logically neutral, depending on base logical connective
261 
262  // Accessing the DcsStatusCollection
264  event.getByToken( dcsInputToken_, dcsStatus );
265  if ( ! dcsStatus.isValid() ) {
266  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "DcsStatusCollection product with InputTag \"" << dcsInputTag_.encode() << "\" not in event ==> decision: " << errorReplyDcs_;
267  return errorReplyDcs_;
268  }
269  if ( ( *dcsStatus ).empty() ) {
270  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "DcsStatusCollection product with InputTag \"" << dcsInputTag_.encode() << "\" empty ==> decision: " << errorReplyDcs_;
271  return errorReplyDcs_;
272  }
273 
274  // Determine decision of DCS partition combination and return
275  if ( andOrDcs_ ) { // OR combination
276  for ( std::vector< int >::const_iterator partitionNumber = dcsPartitions_.begin(); partitionNumber != dcsPartitions_.end(); ++partitionNumber ) {
277  if ( acceptDcsPartition( dcsStatus, *partitionNumber ) ) return true;
278  }
279  return false;
280  }
281  for ( std::vector< int >::const_iterator partitionNumber = dcsPartitions_.begin(); partitionNumber != dcsPartitions_.end(); ++partitionNumber ) {
282  if ( ! acceptDcsPartition( dcsStatus, *partitionNumber ) ) return false;
283  }
284  return true;
285 
286 }
std::vector< int > dcsPartitions_
std::string encode() const
Definition: InputTag.cc:166
bool acceptDcsPartition(const edm::Handle< DcsStatusCollection > &dcsStatus, int dcsPartition) const
edm::EDGetTokenT< DcsStatusCollection > dcsInputToken_
bool isValid() const
Definition: HandleBase.h:74
bool GenericTriggerEventFlag::acceptDcsPartition ( const edm::Handle< DcsStatusCollection > &  dcsStatus,
int  dcsPartition 
) const
private

Definition at line 289 of file GenericTriggerEventFlag.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, DcsStatus::TOB, and verbose_.

Referenced by acceptDcs(), and off().

290 {
291 
292  // Error checks
293  switch( dcsPartition ) {
294  case DcsStatus::EBp :
295  case DcsStatus::EBm :
296  case DcsStatus::EEp :
297  case DcsStatus::EEm :
298  case DcsStatus::HBHEa :
299  case DcsStatus::HBHEb :
300  case DcsStatus::HBHEc :
301  case DcsStatus::HF :
302  case DcsStatus::HO :
303  case DcsStatus::RPC :
304  case DcsStatus::DT0 :
305  case DcsStatus::DTp :
306  case DcsStatus::DTm :
307  case DcsStatus::CSCp :
308  case DcsStatus::CSCm :
309  case DcsStatus::CASTOR:
310  case DcsStatus::TIBTID:
311  case DcsStatus::TOB :
312  case DcsStatus::TECp :
313  case DcsStatus::TECm :
314  case DcsStatus::BPIX :
315  case DcsStatus::FPIX :
316  case DcsStatus::ESp :
317  case DcsStatus::ESm :
318  break;
319  default:
320  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "DCS partition number \"" << dcsPartition << "\" does not exist ==> decision: " << errorReplyDcs_;
321  return errorReplyDcs_;
322  }
323 
324  // Determine decision
325  return dcsStatus->at( 0 ).ready( dcsPartition );
326 
327 }
bool GenericTriggerEventFlag::acceptGt ( const edm::Event event)
private

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

Definition at line 331 of file GenericTriggerEventFlag.cc.

References acceptGtLogicalExpression(), andOr_, andOrGt_, gtLogicalExpressions_, and onGt_.

Referenced by accept(), and off().

332 {
333 
334  // An empty GT status bits logical expressions list acts as switch.
335  if ( ! onGt_ || gtLogicalExpressions_.empty() ) return ( ! andOr_ ); // logically neutral, depending on base logical connective
336 
337  // Determine decision of GT status bits logical expression combination and return
338  if ( andOrGt_ ) { // OR combination
339  for ( std::vector< std::string >::const_iterator gtLogicalExpression = gtLogicalExpressions_.begin(); gtLogicalExpression != gtLogicalExpressions_.end(); ++gtLogicalExpression ) {
340  if ( acceptGtLogicalExpression( event, *gtLogicalExpression ) ) return true;
341  }
342  return false;
343  }
344  for ( std::vector< std::string >::const_iterator gtLogicalExpression = gtLogicalExpressions_.begin(); gtLogicalExpression != gtLogicalExpressions_.end(); ++gtLogicalExpression ) {
345  if ( ! acceptGtLogicalExpression( event, *gtLogicalExpression ) ) return false;
346  }
347  return true;
348 
349 }
std::vector< std::string > gtLogicalExpressions_
bool acceptGtLogicalExpression(const edm::Event &event, std::string gtLogicalExpression)
Does this event fulfill this particular GT status bits&#39; logical expression?
bool GenericTriggerEventFlag::acceptGtLogicalExpression ( const edm::Event event,
std::string  gtLogicalExpression 
)
private

Does this event fulfill this particular GT status bits' logical expression?

Definition at line 353 of file GenericTriggerEventFlag.cc.

References L1GtfeExtWord::beamMode(), L1GtfeExtWord::beamMomentum(), edm::InputTag::encode(), errorReplyDcs_, errorReplyGt_, L1GtLogicParser::expressionResult(), gtEvmInputTag_, gtEvmInputToken_, L1GlobalTriggerReadoutRecord::gtFdlWord(), L1GlobalTriggerEvmReadoutRecord::gtfeWord(), gtInputTag_, gtInputToken_, edm::HandleBase::isValid(), negate(), L1GtLogicParser::operandTokenVector(), L1GtFdlWord::physicsDeclared(), AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

Referenced by acceptGt(), and off().

354 {
355 
356  // Check empty std::strings
357  if ( gtLogicalExpression.empty() ) {
358  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Empty logical expression ==> decision: " << errorReplyGt_;
359  return errorReplyGt_;
360  }
361 
362  // Negated paths
363  bool negExpr( negate( gtLogicalExpression ) );
364  if ( negExpr && gtLogicalExpression.empty() ) {
365  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Empty (negated) logical expression ==> decision: " << errorReplyGt_;
366  return errorReplyGt_;
367  }
368 
369  // Parse logical expression and determine GT status bit decision
370  L1GtLogicParser gtAlgoLogicParser( gtLogicalExpression );
371  // Loop over status bits
372  for ( size_t iStatusBit = 0; iStatusBit < gtAlgoLogicParser.operandTokenVector().size(); ++iStatusBit ) {
373  const std::string gtStatusBit( gtAlgoLogicParser.operandTokenVector().at( iStatusBit ).tokenName );
374  // Manipulate status bit decision as stored in the parser
375  bool decision( errorReplyDcs_ );
376  // Hard-coded status bits!!!
377  if ( gtStatusBit == "PhysDecl" || gtStatusBit == "PhysicsDeclared" ) {
379  event.getByToken( gtInputToken_, gtReadoutRecord );
380  if ( ! gtReadoutRecord.isValid() ) {
381  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "L1GlobalTriggerReadoutRecord product with InputTag \"" << gtInputTag_.encode() << "\" not in event ==> decision: " << errorReplyGt_;
382  gtAlgoLogicParser.operandTokenVector().at( iStatusBit ).tokenResult = errorReplyDcs_;
383  continue;
384  }
385  decision = ( gtReadoutRecord->gtFdlWord().physicsDeclared() == 1 );
386  } else if ( gtStatusBit == "Stable" || gtStatusBit == "StableBeam" || gtStatusBit == "Adjust" || gtStatusBit == "Sqeeze" || gtStatusBit == "Flat" || gtStatusBit == "FlatTop" ||
387  gtStatusBit == "7TeV" || gtStatusBit == "8TeV" || gtStatusBit == "13TeV" || gtStatusBit == "2360GeV" || gtStatusBit == "900GeV" ) {
389  event.getByToken( gtEvmInputToken_, gtEvmReadoutRecord );
390  if ( ! gtEvmReadoutRecord.isValid() ) {
391  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "L1GlobalTriggerEvmReadoutRecord product with InputTag \"" << gtEvmInputTag_.encode() << "\" not in event ==> decision: " << errorReplyGt_;
392  gtAlgoLogicParser.operandTokenVector().at( iStatusBit ).tokenResult = errorReplyDcs_;
393  continue;
394  }
395  if ( gtStatusBit == "Stable" || gtStatusBit == "StableBeam" ) {
396  decision = ( gtEvmReadoutRecord->gtfeWord().beamMode() == 11 );
397  } else if ( gtStatusBit == "Adjust" ) {
398  decision = ( 10 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
399  } else if ( gtStatusBit == "Sqeeze" ) {
400  decision = ( 9 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
401  } else if ( gtStatusBit == "Flat" || gtStatusBit == "FlatTop" ) {
402  decision = ( 8 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
403  } else if ( gtStatusBit == "7TeV" ) {
404  decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 3500 );
405  } else if ( gtStatusBit == "8TeV" ) {
406  decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 4000 );
407  } else if ( gtStatusBit == "13TeV" ) {
408  decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 6500 );
409  } else if ( gtStatusBit == "2360GeV" ) {
410  decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 1180 );
411  } else if ( gtStatusBit == "900GeV" ) {
412  decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 450 );
413  }
414  } else {
415  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "GT status bit \"" << gtStatusBit << "\" is not defined ==> decision: " << errorReplyGt_;
416  }
417  gtAlgoLogicParser.operandTokenVector().at( iStatusBit ).tokenResult = decision;
418  }
419 
420  // Determine decision
421  const bool gtDecision( gtAlgoLogicParser.expressionResult() );
422  return negExpr ? ( ! gtDecision ) : gtDecision;
423 
424 }
bool negate(std::string &word) const
Checks for negated words.
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtInputToken_
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
std::string encode() const
Definition: InputTag.cc:166
const cms_uint16_t beamMomentum() const
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > gtEvmInputToken_
bool isValid() const
Definition: HandleBase.h:74
const L1GtFdlWord gtFdlWord(int bxInEventValue) const
get / set FDL word (record) in the GT readout record
const cms_uint16_t physicsDeclared() const
get/set "physics declared" bit
Definition: L1GtFdlWord.h:227
const cms_uint16_t beamMode() const
bool GenericTriggerEventFlag::acceptHlt ( const edm::Event event)
private

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

Definition at line 514 of file GenericTriggerEventFlag.cc.

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

Referenced by accept(), and off().

515 {
516 
517  // An empty HLT logical expressions list acts as switch.
518  if ( ! onHlt_ || hltLogicalExpressions_.empty() ) return ( ! andOr_ ); // logically neutral, depending on base logical connective
519 
520  // Checking the HLT configuration,
521  if ( ! hltConfigInit_ ) {
522  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "HLT config error ==> decision: " << errorReplyHlt_;
523  return errorReplyHlt_;
524  }
525 
526  // Accessing the TriggerResults
527  edm::Handle< edm::TriggerResults > hltTriggerResults;
528  event.getByToken( hltInputToken_, hltTriggerResults );
529  if ( ! hltTriggerResults.isValid() ) {
530  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "TriggerResults product with InputTag \"" << hltInputTag_.encode() << "\" not in event ==> decision: " << errorReplyHlt_;
531  return errorReplyHlt_;
532  }
533  if ( ( *hltTriggerResults ).size() == 0 ) {
534  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "TriggerResults product with InputTag \"" << hltInputTag_.encode() << "\" empty ==> decision: " << errorReplyHlt_;
535  return errorReplyDcs_;
536  }
537 
538  // Determine decision of HLT logical expression combination and return
539  if ( andOrHlt_ ) { // OR combination
540  for ( std::vector< std::string >::const_iterator hltLogicalExpression = hltLogicalExpressions_.begin(); hltLogicalExpression != hltLogicalExpressions_.end(); ++hltLogicalExpression ) {
541  if ( acceptHltLogicalExpression( hltTriggerResults, *hltLogicalExpression ) ) return true;
542  }
543  return false;
544  }
545  for ( std::vector< std::string >::const_iterator hltLogicalExpression = hltLogicalExpressions_.begin(); hltLogicalExpression != hltLogicalExpressions_.end(); ++hltLogicalExpression ) {
546  if ( ! acceptHltLogicalExpression( hltTriggerResults, *hltLogicalExpression ) ) return false;
547  }
548  return true;
549 
550 }
std::vector< std::string > hltLogicalExpressions_
edm::EDGetTokenT< edm::TriggerResults > hltInputToken_
std::string encode() const
Definition: InputTag.cc:166
bool isValid() const
Definition: HandleBase.h:74
bool acceptHltLogicalExpression(const edm::Handle< edm::TriggerResults > &hltTriggerResults, std::string hltLogicalExpression) const
Was this event accepted by this particular HLT paths&#39; logical expression?
bool GenericTriggerEventFlag::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 554 of file GenericTriggerEventFlag.cc.

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

Referenced by acceptHlt(), and off().

555 {
556 
557  // Check empty std::strings
558  if ( hltLogicalExpression.empty() ) {
559  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Empty logical expression ==> decision: " << errorReplyHlt_;
560  return errorReplyHlt_;
561  }
562 
563  // Negated paths
564  bool negExpr( negate( hltLogicalExpression ) );
565  if ( negExpr && hltLogicalExpression.empty() ) {
566  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Empty (negated) logical expression ==> decision: " << errorReplyHlt_;
567  return errorReplyHlt_;
568  }
569 
570  // Parse logical expression and determine HLT decision
571  L1GtLogicParser hltAlgoLogicParser( hltLogicalExpression );
572  // Loop over paths
573  for ( size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath ) {
574  const std::string hltPathName( hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenName );
575  const unsigned indexPath( hltConfig_.triggerIndex( hltPathName ) );
576  // Further error checks
577  if ( indexPath == hltConfig_.size() ) {
578  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "HLT path \"" << hltPathName << "\" is not found in process " << hltInputTag_.process() << " ==> decision: " << errorReplyHlt_;
579  hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenResult = errorReplyHlt_;
580  continue;
581  }
582  if ( hltTriggerResults->error( indexPath ) ) {
583  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "HLT path \"" << hltPathName << "\" in error ==> decision: " << errorReplyHlt_;
584  hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenResult = errorReplyHlt_;
585  continue;
586  }
587  // Manipulate algo decision as stored in the parser
588  const bool decision( hltTriggerResults->accept( indexPath ) );
589  hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenResult = decision;
590  }
591 
592  // Determine decision
593  const bool hltDecision( hltAlgoLogicParser.expressionResult() );
594  return negExpr ? ( ! hltDecision ) : hltDecision;
595 
596 }
unsigned int size() const
number of trigger paths in trigger table
bool negate(std::string &word) const
Checks for negated words.
bool accept() const
Has at least one path accepted the event?
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
bool error() const
Has any path encountered an error (exception)
std::string const & process() const
Definition: InputTag.h:40
bool GenericTriggerEventFlag::acceptL1 ( const edm::Event event,
const edm::EventSetup setup 
)
private

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

Definition at line 428 of file GenericTriggerEventFlag.cc.

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

Referenced by accept(), and off().

429 {
430 
431  // An empty L1 logical expressions list acts as switch.
432  if ( ! onL1_ || l1LogicalExpressions_.empty() ) return ( ! andOr_ ); // logically neutral, depending on base logical connective
433 
434  // Determine decision of L1 logical expression combination and return
435  if ( andOrL1_ ) { // OR combination
436  for ( std::vector< std::string >::const_iterator l1LogicalExpression = l1LogicalExpressions_.begin(); l1LogicalExpression != l1LogicalExpressions_.end(); ++l1LogicalExpression ) {
437  if ( acceptL1LogicalExpression( event, setup, *l1LogicalExpression ) ) return true;
438  }
439  return false;
440  }
441  for ( std::vector< std::string >::const_iterator l1LogicalExpression = l1LogicalExpressions_.begin(); l1LogicalExpression != l1LogicalExpressions_.end(); ++l1LogicalExpression ) {
442  if ( ! acceptL1LogicalExpression( event, setup, *l1LogicalExpression ) ) return false;
443  }
444  return true;
445 
446 }
bool acceptL1LogicalExpression(const edm::Event &event, const edm::EventSetup &setup, std::string l1LogicalExpression)
Was this event accepted by this particular L1 algorithms&#39; logical expression?
std::vector< std::string > l1LogicalExpressions_
bool GenericTriggerEventFlag::acceptL1LogicalExpression ( const edm::Event event,
const edm::EventSetup setup,
std::string  l1LogicalExpression 
)
private

Was this event accepted by this particular L1 algorithms' logical expression?

Definition at line 450 of file GenericTriggerEventFlag.cc.

References relativeConstraints::error, errorReplyL1_, L1GtLogicParser::expressionResult(), l1BeforeMask_, l1Gt_, l1uGt_, negate(), L1GtLogicParser::operandTokenVector(), stage2_, AlCaHLTBitMon_QueryRunRegistry::string, useL1EventSetup(), useL1GtTriggerMenuLite(), and verbose_.

Referenced by acceptL1(), and off().

451 {
452 
453  // Getting the L1 event setup
454  if ( stage2_ )
455  l1uGt_->retrieveL1(event,setup);
456  else
457  l1Gt_->getL1GtRunCache( event, setup, useL1EventSetup, useL1GtTriggerMenuLite ); // FIXME This can possibly go to initRun()
458 
459 
460  // Check empty std::strings
461  if ( l1LogicalExpression.empty() ) {
462  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Empty logical expression ==> decision: " << errorReplyL1_;
463  return errorReplyL1_;
464  }
465 
466  // Negated logical expression
467  bool negExpr( negate( l1LogicalExpression ) );
468  if ( negExpr && l1LogicalExpression.empty() ) {
469  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Empty (negated) logical expression ==> decision: " << errorReplyL1_;
470  return errorReplyL1_;
471  }
472 
473  // Parse logical expression and determine L1 decision
474  L1GtLogicParser l1AlgoLogicParser( l1LogicalExpression );
475  // Loop over algorithms
476  for ( size_t iAlgorithm = 0; iAlgorithm < l1AlgoLogicParser.operandTokenVector().size(); ++iAlgorithm ) {
477  const std::string l1AlgoName( l1AlgoLogicParser.operandTokenVector().at( iAlgorithm ).tokenName );
478 
479 
480  bool decision = false;
481  bool error = false;
482  if ( stage2_ ) {
483  bool errorBOOL = (l1BeforeMask_ ? l1uGt_->getInitialDecisionByName(l1AlgoName,decision) : l1uGt_->getFinalDecisionByName(l1AlgoName,decision) );
484  error = !errorBOOL;
485  } else {
486  int errorINT( -1 );
487  // const bool decision( l1BeforeMask_ ? l1Gt_->decisionBeforeMask( event, l1AlgoName, errorINT ) : l1Gt_->decisionAfterMask( event, l1AlgoName, errorINT ) );
488  decision = ( l1BeforeMask_ ? l1Gt_->decisionBeforeMask( event, l1AlgoName, errorINT ) : l1Gt_->decisionAfterMask( event, l1AlgoName, errorINT ) );
489  error = ( errorINT != 0 );
490  if ( errorINT > 1 )
491  if ( verbose_ > 1 )
492  edm::LogWarning( "GenericTriggerEventFlag" ) << "L1 algorithm \"" << l1AlgoName << "\" received error code " << error << " from L1GtUtils::decisionBeforeMask ==> decision: " << errorReplyL1_;
493  }
494 
495  // Error checks
496  if ( error ) {
497  if ( verbose_ > 1 )
498  edm::LogWarning( "GenericTriggerEventFlag" ) << "L1 algorithm \"" << l1AlgoName << "\" does not exist in the L1 menu ==> decision: " << errorReplyL1_;
499  l1AlgoLogicParser.operandTokenVector().at( iAlgorithm ).tokenResult = errorReplyL1_;
500  continue;
501  }
502  // Manipulate algo decision as stored in the parser
503  l1AlgoLogicParser.operandTokenVector().at( iAlgorithm ).tokenResult = decision;
504  }
505 
506  // Return decision
507  const bool l1Decision( l1AlgoLogicParser.expressionResult() );
508  return negExpr ? ( ! l1Decision ) : l1Decision;
509 
510 }
bool negate(std::string &word) const
Checks for negated words.
static const bool useL1GtTriggerMenuLite(false)
std::unique_ptr< L1GtUtils > l1Gt_
static const bool useL1EventSetup(true)
std::unique_ptr< l1t::L1TGlobalUtil > l1uGt_
std::string GenericTriggerEventFlag::expandLogicalExpression ( const std::vector< std::string > &  target,
const std::string &  expr,
bool  useAnd = false 
) const
private

Expand wild-carded logical expressions, giving version postfixes priority.

Definition at line 601 of file GenericTriggerEventFlag.cc.

References jets_cff::expr, hltConfig_, HLTConfigProvider::matched(), electrons_cff::matched, HLTConfigProvider::restoreVersion(), AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

Referenced by initRun(), and off().

602 {
603 
604  // Find matching entries in the menu
605  std::vector< std::string > matched;
606  const std::string versionWildcard( "_v*" );
607  if ( expr.substr( expr.size() - versionWildcard.size() ) == versionWildcard ) {
608  const std::string exprBase( expr.substr( 0, expr.size() - versionWildcard.size() ) );
609  matched = hltConfig_.restoreVersion( targets, exprBase );
610  } else {
611  matched = hltConfig_.matched( targets, expr );
612  }
613 
614  // Return input, if no match is found
615  if ( matched.empty() ) {
616  if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Logical expression: \"" << expr << "\" could not be resolved";
617  return expr;
618  }
619 
620  // Compose logical expression
621  std::string expanded( "(" );
622  for ( unsigned iVers = 0; iVers < matched.size(); ++iVers ) {
623  if ( iVers > 0 ) expanded.append( useAnd ? " AND " : " OR " );
624  expanded.append( matched.at( iVers ) );
625  }
626  expanded.append( ")" );
627  if ( verbose_ > 1 ) edm::LogInfo( "GenericTriggerEventFlag" ) << "Logical expression: \"" << expr << "\"\n"
628  << " --> expanded to \"" << expanded << "\"";
629 
630  return expanded;
631 
632 }
static const std::vector< std::string > matched(const std::vector< std::string > &inputs, const std::string &pattern)
regexp processing
static const std::vector< std::string > restoreVersion(const std::vector< std::string > &inputs, const std::string &trigger)
std::vector< std::string > GenericTriggerEventFlag::expressionsFromDB ( const std::string &  key,
const edm::EventSetup setup 
)

Reads and returns logical expressions from DB.

Definition at line 652 of file GenericTriggerEventFlag.cc.

References configError_, dbLabel_, AlCaRecoTriggerBits::decompose(), emptyKeyError_, edm::EventSetup::get(), tablePrinter::labels, AlCaRecoTriggerBits::m_alcarecoToTrig, and verbose_.

Referenced by hltDBKey(), and initRun().

653 {
654  if ( key.empty() ) return std::vector< std::string >( 1, emptyKeyError_ );
655  edm::ESHandle< AlCaRecoTriggerBits > logicalExpressions;
656  std::vector< edm::eventsetup::DataKey > labels;
657  setup.get< AlCaRecoTriggerBitsRcd >().fillRegisteredDataKeys( labels );
658  std::vector< edm::eventsetup::DataKey >::const_iterator iKey = labels.begin();
659  while ( iKey != labels.end() && iKey->name().value() != dbLabel_ ) ++iKey;
660  if ( iKey == labels.end() ) {
661  if ( verbose_ > 0 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Label " << dbLabel_ << " not found in DB for 'AlCaRecoTriggerBitsRcd'";
662  return std::vector< std::string >( 1, configError_ );
663  }
664  setup.get< AlCaRecoTriggerBitsRcd >().get( dbLabel_, logicalExpressions );
665  const std::map< std::string, std::string > & expressionMap = logicalExpressions->m_alcarecoToTrig;
666  std::map< std::string, std::string >::const_iterator listIter = expressionMap.find( key );
667  if ( listIter == expressionMap.end() ) {
668  if ( verbose_ > 0 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "No logical expressions found under key " << key << " in 'AlCaRecoTriggerBitsRcd'";
669  return std::vector< std::string >( 1, configError_ );
670  }
671  return logicalExpressions->decompose( listIter->second );
672 
673 }
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 T & get() const
Definition: EventSetup.h:59
std::string GenericTriggerEventFlag::gtDBKey ( )
inline

Definition at line 144 of file GenericTriggerEventFlag.h.

References gtDBKey_.

144 { return gtDBKey_ ; } // can be empty
std::string GenericTriggerEventFlag::hltDBKey ( )
inline

Definition at line 146 of file GenericTriggerEventFlag.h.

References expressionsFromDB(), hltDBKey_, crabWrapper::key, and AlCaHLTBitMon_QueryRunRegistry::string.

146 { return hltDBKey_; } // can be empty
void GenericTriggerEventFlag::initRun ( const edm::Run run,
const edm::EventSetup setup 
)

To be called from beginRun() methods.

Definition at line 139 of file GenericTriggerEventFlag.cc.

References configError_, edm::InputTag::encode(), expandLogicalExpression(), expressionsFromDB(), spr::find(), edm::EventSetup::get(), L1GtTriggerMenu::gtAlgorithmMap(), gtDBKey_, gtLogicalExpressions_, L1GtTriggerMenu::gtTechnicalTriggerMap(), hltConfig_, hltConfigInit_, hltDBKey_, hltInputTag_, hltLogicalExpressions_, hltLogicalExpressionsCache_, HLTConfigProvider::init(), l1DBKey_, l1Gt_, l1LogicalExpressions_, l1LogicalExpressionsCache_, l1uGt_, onGt_, onHlt_, onL1_, edm::InputTag::process(), HLTConfigProvider::size(), stage2_, AlCaHLTBitMon_QueryRunRegistry::string, tmp, HLTConfigProvider::triggerNames(), useL1EventSetup(), useL1GtTriggerMenuLite(), verbose_, and watchDB_.

Referenced by HLTDQMTagAndProbeEff< TagType, TagCollType, ProbeType, ProbeCollType >::beginRun(), V0Monitor::bookHistograms(), dEdxAnalyzer::bookHistograms(), TagAndProbeBtagTriggerMonitor::bookHistograms(), LogMessageMonitor::bookHistograms(), TrackingMonitor::bookHistograms(), BPHMonitor::bookHistograms(), MonitorTrackResidualsBase< pixel_or_strip >::dqmBeginRun(), dEdxHitAnalyzer::dqmBeginRun(), SiStripMonitorCluster::dqmBeginRun(), SiStripMonitorTrack::dqmBeginRun(), TauTagValidation::dqmBeginRun(), and off().

140 {
141 
142  if ( watchDB_->check( setup ) ) {
143  if ( onGt_ && !gtDBKey_.empty() ) {
144  const std::vector< std::string > exprs( expressionsFromDB( gtDBKey_, setup ) );
145  if ( exprs.empty() || exprs.at( 0 ) != configError_ ) gtLogicalExpressions_ = exprs;
146  }
147  if ( onL1_ && !l1DBKey_.empty() ) {
148  const std::vector< std::string > exprs( expressionsFromDB( l1DBKey_, setup ) );
149  if ( exprs.empty() || exprs.at( 0 ) != configError_ ) l1LogicalExpressionsCache_ = exprs;
150  }
151  if ( onHlt_ && !hltDBKey_.empty() ) {
152  const std::vector< std::string > exprs( expressionsFromDB( hltDBKey_, setup ) );
153  if ( exprs.empty() || exprs.at( 0 ) != configError_ ) hltLogicalExpressionsCache_ = exprs;
154  }
155  }
156 
157  // Re-initialise starting valuse before wild-card expansion
160 
161  hltConfigInit_ = false;
162  if ( onHlt_ ) {
163  if ( hltInputTag_.process().empty() ) {
164  if ( verbose_ > 0 ) edm::LogError( "GenericTriggerEventFlag" ) << "HLT TriggerResults InputTag \"" << hltInputTag_.encode() << "\" specifies no process";
165  } else {
166  bool hltChanged( false );
167  if ( ! hltConfig_.init( run, setup, hltInputTag_.process(), hltChanged ) ) {
168  if ( verbose_ > 0 ) edm::LogError( "GenericTriggerEventFlag" ) << "HLT config initialization error with process name \"" << hltInputTag_.process() << "\"";
169  } else if ( hltConfig_.size() <= 0 ) {
170  if ( verbose_ > 0 ) edm::LogError( "GenericTriggerEventFlag" ) << "HLT config size error";
171  } else hltConfigInit_ = true;
172  }
173  }
174 
175  // Expand version wild-cards in HLT logical expressions
176  // L1
177  if ( onL1_ ) {
178  // build vector of algo names
179 
180  std::vector< std::string > algoNames;
181 
182  if (stage2_) {
183  l1uGt_->retrieveL1Setup(setup);
184 
185  const std::vector<std::pair<std::string, int> > prescales = l1uGt_->prescales();
186  for(auto ip : prescales)
187  algoNames.push_back(ip.first);
188  } else {
189  l1Gt_->getL1GtRunCache( run, setup, useL1EventSetup, useL1GtTriggerMenuLite );
190  edm::ESHandle< L1GtTriggerMenu > handleL1GtTriggerMenu;
191  setup.get< L1GtTriggerMenuRcd >().get( handleL1GtTriggerMenu );
192 
193  const AlgorithmMap l1GtPhys( handleL1GtTriggerMenu->gtAlgorithmMap() );
194  for ( CItAlgo iAlgo = l1GtPhys.begin(); iAlgo != l1GtPhys.end(); ++iAlgo ) {
195  algoNames.push_back( iAlgo->second.algoName() );
196  }
197  const AlgorithmMap l1GtTech( handleL1GtTriggerMenu->gtTechnicalTriggerMap() );
198  for ( CItAlgo iAlgo = l1GtTech.begin(); iAlgo != l1GtTech.end(); ++iAlgo ) {
199  algoNames.push_back( iAlgo->second.algoName() );
200  }
201  }
202 
203 
204  for ( unsigned iExpr = 0; iExpr < l1LogicalExpressions_.size(); ++iExpr ) {
205  std::string l1LogicalExpression( l1LogicalExpressions_.at( iExpr ) );
206  L1GtLogicParser l1AlgoLogicParser( l1LogicalExpression );
207  // Loop over algorithms
208  for ( size_t iAlgo = 0; iAlgo < l1AlgoLogicParser.operandTokenVector().size(); ++iAlgo ) {
209  const std::string l1AlgoName( l1AlgoLogicParser.operandTokenVector().at( iAlgo ).tokenName );
210  if ( l1AlgoName.find( '*' ) != std::string::npos ) {
211  l1LogicalExpression.replace( l1LogicalExpression.find( l1AlgoName ), l1AlgoName.size(), expandLogicalExpression( algoNames, l1AlgoName ) );
212  }
213  }
214  l1LogicalExpressions_[ iExpr ] = l1LogicalExpression;
215  }
216  std::vector<std::string> tmp = l1LogicalExpressions_;
217  for ( unsigned iExpr = 0; iExpr < tmp.size(); ++iExpr )
218  if ( std::find(algoNames.begin(),algoNames.end(),tmp[ iExpr ]) == algoNames.end() ) {
219  l1LogicalExpressions_.erase(l1LogicalExpressions_.begin()+iExpr);
220  if ( verbose_ > 1 )
221  edm::LogWarning( "GenericTriggerEventFlag" ) << "L1 algorithm \"" << tmp[ iExpr ] << "\" does not exist in the L1 menu ==> drop it from the list of l1LogicalExpressions";
222  }
223  }
224  // HLT
225  if ( hltConfigInit_ ) {
226  for ( unsigned iExpr = 0; iExpr < hltLogicalExpressions_.size(); ++iExpr ) {
227  std::string hltLogicalExpression( hltLogicalExpressions_.at( iExpr ) );
228  L1GtLogicParser hltAlgoLogicParser( hltLogicalExpression );
229  // Loop over paths
230  for ( size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath ) {
231  const std::string hltPathName( hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenName );
232  if ( hltPathName.find( '*' ) != std::string::npos ) {
233  hltLogicalExpression.replace( hltLogicalExpression.find( hltPathName ), hltPathName.size(), expandLogicalExpression( hltConfig_.triggerNames(), hltPathName ) );
234  }
235  }
236  hltLogicalExpressions_[ iExpr ] = hltLogicalExpression;
237  }
238  }
239 
240 }
unsigned int size() const
number of trigger paths in trigger table
static const bool useL1GtTriggerMenuLite(false)
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
std::vector< std::string > gtLogicalExpressions_
std::vector< std::string > hltLogicalExpressions_
const std::vector< std::string > & triggerNames() const
names of trigger paths
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::string encode() const
Definition: InputTag.cc:166
std::unique_ptr< L1GtUtils > l1Gt_
std::vector< std::string > l1LogicalExpressionsCache_
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
std::vector< std::string > expressionsFromDB(const std::string &key, const edm::EventSetup &setup)
Reads and returns logical expressions from DB.
std::unique_ptr< edm::ESWatcher< AlCaRecoTriggerBitsRcd > > watchDB_
static const bool useL1EventSetup(true)
std::vector< std::string > hltLogicalExpressionsCache_
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
const T & get() const
Definition: EventSetup.h:59
std::vector< std::string > l1LogicalExpressions_
std::string const & process() const
Definition: InputTag.h:40
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
const AlgorithmMap & gtTechnicalTriggerMap() const
get / set the technical trigger map
std::string expandLogicalExpression(const std::vector< std::string > &target, const std::string &expr, bool useAnd=false) const
Expand wild-carded logical expressions, giving version postfixes priority.
std::unique_ptr< l1t::L1TGlobalUtil > l1uGt_
std::string GenericTriggerEventFlag::l1DBKey ( )
inline

Definition at line 145 of file GenericTriggerEventFlag.h.

References l1DBKey_.

145 { return l1DBKey_ ; } // can be empty
bool GenericTriggerEventFlag::negate ( std::string &  word) const
private

Checks for negated words.

Definition at line 637 of file GenericTriggerEventFlag.cc.

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

638 {
639 
640  bool negate( false );
641  if ( word.at( 0 ) == '~' ) {
642  negate = true;
643  word.erase( 0, 1 );
644  }
645  return negate;
646 
647 }
bool negate(std::string &word) const
Checks for negated words.
bool GenericTriggerEventFlag::off ( )
inline
bool GenericTriggerEventFlag::on ( )
inline

Member Data Documentation

bool GenericTriggerEventFlag::andOr_
private
bool GenericTriggerEventFlag::andOrDcs_
private

Definition at line 53 of file GenericTriggerEventFlag.h.

Referenced by acceptDcs(), and GenericTriggerEventFlag().

bool GenericTriggerEventFlag::andOrGt_
private

Definition at line 58 of file GenericTriggerEventFlag.h.

Referenced by acceptGt(), and GenericTriggerEventFlag().

bool GenericTriggerEventFlag::andOrHlt_
private

Definition at line 73 of file GenericTriggerEventFlag.h.

Referenced by acceptHlt(), and GenericTriggerEventFlag().

bool GenericTriggerEventFlag::andOrL1_
private

Definition at line 66 of file GenericTriggerEventFlag.h.

Referenced by acceptL1(), and GenericTriggerEventFlag().

const std::string GenericTriggerEventFlag::configError_
private

Definition at line 87 of file GenericTriggerEventFlag.h.

Referenced by expressionsFromDB(), and initRun().

std::string GenericTriggerEventFlag::dbLabel_
private

Definition at line 51 of file GenericTriggerEventFlag.h.

Referenced by expressionsFromDB(), and GenericTriggerEventFlag().

edm::InputTag GenericTriggerEventFlag::dcsInputTag_
private

Definition at line 54 of file GenericTriggerEventFlag.h.

Referenced by acceptDcs(), and GenericTriggerEventFlag().

edm::EDGetTokenT< DcsStatusCollection > GenericTriggerEventFlag::dcsInputToken_
private

Definition at line 55 of file GenericTriggerEventFlag.h.

Referenced by acceptDcs(), and GenericTriggerEventFlag().

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

Definition at line 56 of file GenericTriggerEventFlag.h.

Referenced by acceptDcs(), and GenericTriggerEventFlag().

const std::string GenericTriggerEventFlag::emptyKeyError_
private

Definition at line 88 of file GenericTriggerEventFlag.h.

Referenced by expressionsFromDB().

bool GenericTriggerEventFlag::errorReplyDcs_
private
bool GenericTriggerEventFlag::errorReplyGt_
private

Definition at line 65 of file GenericTriggerEventFlag.h.

Referenced by acceptGtLogicalExpression(), and GenericTriggerEventFlag().

bool GenericTriggerEventFlag::errorReplyHlt_
private
bool GenericTriggerEventFlag::errorReplyL1_
private

Definition at line 72 of file GenericTriggerEventFlag.h.

Referenced by acceptL1LogicalExpression(), and GenericTriggerEventFlag().

std::string GenericTriggerEventFlag::gtDBKey_
private

Definition at line 63 of file GenericTriggerEventFlag.h.

Referenced by GenericTriggerEventFlag(), gtDBKey(), and initRun().

edm::InputTag GenericTriggerEventFlag::gtEvmInputTag_
private

Definition at line 61 of file GenericTriggerEventFlag.h.

Referenced by acceptGtLogicalExpression(), and GenericTriggerEventFlag().

edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > GenericTriggerEventFlag::gtEvmInputToken_
private

Definition at line 62 of file GenericTriggerEventFlag.h.

Referenced by acceptGtLogicalExpression(), and GenericTriggerEventFlag().

edm::InputTag GenericTriggerEventFlag::gtInputTag_
private

Definition at line 59 of file GenericTriggerEventFlag.h.

Referenced by acceptGtLogicalExpression(), and GenericTriggerEventFlag().

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

Definition at line 60 of file GenericTriggerEventFlag.h.

Referenced by acceptGtLogicalExpression(), and GenericTriggerEventFlag().

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

Definition at line 64 of file GenericTriggerEventFlag.h.

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

HLTConfigProvider GenericTriggerEventFlag::hltConfig_
private
bool GenericTriggerEventFlag::hltConfigInit_
private

Definition at line 48 of file GenericTriggerEventFlag.h.

Referenced by acceptHlt(), and initRun().

std::string GenericTriggerEventFlag::hltDBKey_
private

Definition at line 76 of file GenericTriggerEventFlag.h.

Referenced by GenericTriggerEventFlag(), hltDBKey(), and initRun().

edm::InputTag GenericTriggerEventFlag::hltInputTag_
private
edm::EDGetTokenT< edm::TriggerResults > GenericTriggerEventFlag::hltInputToken_
private

Definition at line 75 of file GenericTriggerEventFlag.h.

Referenced by acceptHlt(), and GenericTriggerEventFlag().

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

Definition at line 78 of file GenericTriggerEventFlag.h.

Referenced by acceptHlt(), and initRun().

std::vector< std::string > GenericTriggerEventFlag::hltLogicalExpressionsCache_
private

Definition at line 77 of file GenericTriggerEventFlag.h.

Referenced by GenericTriggerEventFlag(), and initRun().

bool GenericTriggerEventFlag::l1BeforeMask_
private

Definition at line 68 of file GenericTriggerEventFlag.h.

Referenced by acceptL1LogicalExpression(), and GenericTriggerEventFlag().

std::string GenericTriggerEventFlag::l1DBKey_
private

Definition at line 69 of file GenericTriggerEventFlag.h.

Referenced by GenericTriggerEventFlag(), initRun(), and l1DBKey().

std::unique_ptr<L1GtUtils> GenericTriggerEventFlag::l1Gt_
private
std::vector< std::string > GenericTriggerEventFlag::l1LogicalExpressions_
private

Definition at line 71 of file GenericTriggerEventFlag.h.

Referenced by acceptL1(), and initRun().

std::vector< std::string > GenericTriggerEventFlag::l1LogicalExpressionsCache_
private

Definition at line 70 of file GenericTriggerEventFlag.h.

Referenced by GenericTriggerEventFlag(), and initRun().

std::unique_ptr<l1t::L1TGlobalUtil> GenericTriggerEventFlag::l1uGt_
private
bool GenericTriggerEventFlag::on_
private

Definition at line 81 of file GenericTriggerEventFlag.h.

Referenced by accept(), GenericTriggerEventFlag(), and on().

bool GenericTriggerEventFlag::onDcs_
private

Definition at line 82 of file GenericTriggerEventFlag.h.

Referenced by acceptDcs(), and GenericTriggerEventFlag().

bool GenericTriggerEventFlag::onGt_
private

Definition at line 83 of file GenericTriggerEventFlag.h.

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

bool GenericTriggerEventFlag::onHlt_
private

Definition at line 85 of file GenericTriggerEventFlag.h.

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

bool GenericTriggerEventFlag::onL1_
private

Definition at line 84 of file GenericTriggerEventFlag.h.

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

bool GenericTriggerEventFlag::stage2_
private
unsigned GenericTriggerEventFlag::verbose_
private
std::unique_ptr<edm::ESWatcher< AlCaRecoTriggerBitsRcd > > GenericTriggerEventFlag::watchDB_
private

Definition at line 44 of file GenericTriggerEventFlag.h.

Referenced by GenericTriggerEventFlag(), and initRun().