CMS 3D CMS Logo

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>

List of all members.

Public Member Functions

bool accept (const edm::Event &event, const edm::EventSetup &setup)
 To be called from analyze/filter() methods.
std::vector< std::string > expressionsFromDB (const std::string &key, const edm::EventSetup &setup)
 Reads and returns logical expressions from DB.
 GenericTriggerEventFlag (const edm::ParameterSet &config)
 To be called from the ED module's c'tor.
std::string gtDBKey ()
std::string hltDBKey ()
void initRun (const edm::Run &run, const edm::EventSetup &setup)
 To be called from beginRun() methods.
std::string l1DBKey ()
bool off ()
bool on ()
 ~GenericTriggerEventFlag ()
 To be called from d'tors by 'delete'.

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?
bool acceptGtLogicalExpression (const edm::Event &event, std::string gtLogicalExpression)
 Does this event fulfill this particular GT status bits' logical expression?
bool acceptHlt (const edm::Event &event)
 Was this event accepted by the configured HLT logical expression combination?
bool acceptHltLogicalExpression (const edm::Handle< edm::TriggerResults > &hltTriggerResults, std::string hltLogicalExpression) const
 Was this event accepted by this particular HLT paths' logical expression?
bool acceptL1 (const edm::Event &event, const edm::EventSetup &setup)
 Was this event accepted by the configured L1 logical expression combination?
bool acceptL1LogicalExpression (const edm::Event &event, std::string l1LogicalExpression)
 Was this event accepted by this particular L1 algorithms' logical expression?
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.
bool negate (std::string &word) const
 Checks for negated words.

Private Attributes

bool andOr_
bool andOrDcs_
bool andOrGt_
bool andOrHlt_
bool andOrL1_
const std::string configError_
std::string dbLabel_
edm::InputTag dcsInputTag_
std::vector< int > dcsPartitions_
const std::string emptyKeyError_
bool errorReplyDcs_
bool errorReplyGt_
bool errorReplyHlt_
bool errorReplyL1_
std::string gtDBKey_
edm::InputTag gtEvmInputTag_
edm::InputTag gtInputTag_
std::vector< std::string > gtLogicalExpressions_
HLTConfigProvider hltConfig_
bool hltConfigInit_
std::string hltDBKey_
edm::InputTag hltInputTag_
std::vector< std::string > hltLogicalExpressions_
std::vector< std::string > hltLogicalExpressionsCache_
bool l1BeforeMask_
std::string l1DBKey_
L1GtUtils l1Gt_
std::vector< std::string > l1LogicalExpressions_
std::vector< std::string > l1LogicalExpressionsCache_
bool on_
bool onDcs_
bool onGt_
bool onHlt_
bool onL1_
unsigned verbose_
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.6 2012/01/20 18:18:11 vadler Exp

Definition at line 36 of file GenericTriggerEventFlag.h.


Constructor & Destructor Documentation

GenericTriggerEventFlag::GenericTriggerEventFlag ( const edm::ParameterSet config)

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

Definition at line 27 of file GenericTriggerEventFlag.cc.

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

  : watchDB_( 0 )
  , hltConfigInit_( false )
  , andOr_( false )
  , dbLabel_( "" )
  , verbose_( 0 )
  , andOrDcs_( false )
  , errorReplyDcs_( false )
  , andOrGt_( false )
  , gtInputTag_( "" )
  , gtEvmInputTag_( "" )
  , gtDBKey_( "" )
  , errorReplyGt_( false )
  , andOrL1_( false )
  , l1BeforeMask_( true )
  , l1DBKey_( "" )
  , errorReplyL1_( false )
  , andOrHlt_( false )
  , hltDBKey_( "" )
  , errorReplyHlt_( false )
  , on_( true )
  , onDcs_( true )
  , onGt_( true )
  , onL1_( true )
  , onHlt_( true )
  , configError_( "CONFIG_ERROR" )
  , emptyKeyError_( "EMPTY_KEY_ERROR" )
{

  // General switch(es)
  if ( config.exists( "andOr" ) ) {
    andOr_ = config.getParameter< bool >( "andOr" );
    if ( config.exists( "verbosityLevel" ) ) verbose_ = config.getParameter< unsigned >( "verbosityLevel" );
  } else {
    on_    = false;
    onDcs_ = false;
    onGt_  = false;
    onL1_  = false;
    onHlt_ = false;
  }

  if ( on_ ) {
    if ( config.exists( "andOrDcs" ) ) {
      andOrDcs_      = config.getParameter< bool >( "andOrDcs" );
      dcsInputTag_   = config.getParameter< edm::InputTag >( "dcsInputTag" );
      dcsPartitions_ = config.getParameter< std::vector< int > >( "dcsPartitions" );
      errorReplyDcs_ = config.getParameter< bool >( "errorReplyDcs" );
    } else {
      onDcs_ = false;
    }
    if ( config.exists( "andOrGt" ) ) {
      andOrGt_              = config.getParameter< bool >( "andOrGt" );
      gtInputTag_           = config.getParameter< edm::InputTag >( "gtInputTag" );
      gtLogicalExpressions_ = config.getParameter< std::vector< std::string > >( "gtStatusBits" );
      errorReplyGt_         = config.getParameter< bool >( "errorReplyGt" );
      if ( config.exists( "gtEvmInputTag" ) ) gtEvmInputTag_ = config.getParameter< edm::InputTag >( "gtEvmInputTag" );
      if ( config.exists( "gtDBKey" ) )       gtDBKey_       = config.getParameter< std::string >( "gtDBKey" );
    } else {
      onGt_ = false;
    }
    if ( config.exists( "andOrL1" ) ) {
      andOrL1_                   = config.getParameter< bool >( "andOrL1" );
      l1LogicalExpressionsCache_ = config.getParameter< std::vector< std::string > >( "l1Algorithms" );
      errorReplyL1_              = config.getParameter< bool >( "errorReplyL1" );
      if ( config.exists( "l1DBKey" ) )      l1DBKey_      = config.getParameter< std::string >( "l1DBKey" );
      if ( config.exists( "l1BeforeMask" ) ) l1BeforeMask_ = config.getParameter< bool >( "l1BeforeMask" );
    } else {
      onL1_ = false;
    }
    if ( config.exists( "andOrHlt" ) ) {
      andOrHlt_                   = config.getParameter< bool >( "andOrHlt" );
      hltInputTag_                = config.getParameter< edm::InputTag >( "hltInputTag" );
      hltLogicalExpressionsCache_ = config.getParameter< std::vector< std::string > >( "hltPaths" );
      errorReplyHlt_              = config.getParameter< bool >( "errorReplyHlt" );
      if ( config.exists( "hltDBKey" ) ) hltDBKey_ = config.getParameter< std::string >( "hltDBKey" );
    } else {
      onHlt_ = false;
    }
    if ( ! onDcs_ && ! onGt_ && ! onL1_ && ! onHlt_ ) on_ = false;
    else {
      if ( config.exists( "dbLabel" ) ) dbLabel_ = config.getParameter< std::string >( "dbLabel" );
      watchDB_ = new edm::ESWatcher< AlCaRecoTriggerBitsRcd >;
    }
  }

}
GenericTriggerEventFlag::~GenericTriggerEventFlag ( )

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

Definition at line 116 of file GenericTriggerEventFlag.cc.

References on_, and watchDB_.

{

  if ( on_ ) delete watchDB_;

}

Member Function Documentation

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

To be called from analyze/filter() methods.

Definition at line 213 of file GenericTriggerEventFlag.cc.

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

Referenced by MonitorTrackResiduals::analyze(), TauTagValidation::analyze(), dEdxAnalyzer::analyze(), TrackingMonitor::analyze(), SiStripMonitorCluster::analyze(), LogMessageMonitor::analyze(), and SiStripMonitorTrack::analyze().

{

  if ( ! on_ ) return true;

  // Determine decision
  if ( andOr_ ) return ( acceptDcs( event ) || acceptGt( event ) || acceptL1( event, setup ) || acceptHlt( event ) );
  return ( acceptDcs( event ) && acceptGt( event ) && acceptL1( event, setup ) && acceptHlt( event ) );

}
bool GenericTriggerEventFlag::acceptDcs ( const edm::Event event) [private]

Definition at line 225 of file GenericTriggerEventFlag.cc.

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

Referenced by accept().

{

  // An empty DCS partitions list acts as switch.
  if ( ! onDcs_ || dcsPartitions_.empty() ) return ( ! andOr_ ); // logically neutral, depending on base logical connective

  // Accessing the DcsStatusCollection
  edm::Handle< DcsStatusCollection > dcsStatus;
  event.getByLabel( dcsInputTag_, dcsStatus );
  if ( ! dcsStatus.isValid() ) {
    if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "DcsStatusCollection product with InputTag \"" << dcsInputTag_.encode() << "\" not in event ==> decision: " << errorReplyDcs_;
    return errorReplyDcs_;
  }
  if ( ( *dcsStatus ).size() == 0 ) {
    if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "DcsStatusCollection product with InputTag \"" << dcsInputTag_.encode() << "\" empty ==> decision: " << errorReplyDcs_;
    return errorReplyDcs_;
  }

  // Determine decision of DCS partition combination and return
  if ( andOrDcs_ ) { // OR combination
    for ( std::vector< int >::const_iterator partitionNumber = dcsPartitions_.begin(); partitionNumber != dcsPartitions_.end(); ++partitionNumber ) {
      if ( acceptDcsPartition( dcsStatus, *partitionNumber ) ) return true;
    }
    return false;
  }
  for ( std::vector< int >::const_iterator partitionNumber = dcsPartitions_.begin(); partitionNumber != dcsPartitions_.end(); ++partitionNumber ) {
    if ( ! acceptDcsPartition( dcsStatus, *partitionNumber ) ) return false;
  }
  return true;

}
bool GenericTriggerEventFlag::acceptDcsPartition ( const edm::Handle< DcsStatusCollection > &  dcsStatus,
int  dcsPartition 
) const [private]

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

{

  // Error checks
  switch( dcsPartition ) {
    case DcsStatus::EBp   :
    case DcsStatus::EBm   :
    case DcsStatus::EEp   :
    case DcsStatus::EEm   :
    case DcsStatus::HBHEa :
    case DcsStatus::HBHEb :
    case DcsStatus::HBHEc :
    case DcsStatus::HF    :
    case DcsStatus::HO    :
    case DcsStatus::RPC   :
    case DcsStatus::DT0   :
    case DcsStatus::DTp   :
    case DcsStatus::DTm   :
    case DcsStatus::CSCp  :
    case DcsStatus::CSCm  :
    case DcsStatus::CASTOR:
    case DcsStatus::TIBTID:
    case DcsStatus::TOB   :
    case DcsStatus::TECp  :
    case DcsStatus::TECm  :
    case DcsStatus::BPIX  :
    case DcsStatus::FPIX  :
    case DcsStatus::ESp   :
    case DcsStatus::ESm   :
      break;
    default:
      if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "DCS partition number \"" << dcsPartition << "\" does not exist ==> decision: " << errorReplyDcs_;
      return errorReplyDcs_;
  }

  // Determine decision
  return dcsStatus->at( 0 ).ready( dcsPartition );

}
bool GenericTriggerEventFlag::acceptGt ( const edm::Event event) [private]

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

Definition at line 300 of file GenericTriggerEventFlag.cc.

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

Referenced by accept().

{

  // An empty GT status bits logical expressions list acts as switch.
  if ( ! onGt_ || gtLogicalExpressions_.empty() ) return ( ! andOr_ ); // logically neutral, depending on base logical connective

  // Determine decision of GT status bits logical expression combination and return
  if ( andOrGt_ ) { // OR combination
    for ( std::vector< std::string >::const_iterator gtLogicalExpression = gtLogicalExpressions_.begin(); gtLogicalExpression != gtLogicalExpressions_.end(); ++gtLogicalExpression ) {
      if ( acceptGtLogicalExpression( event, *gtLogicalExpression ) ) return true;
    }
    return false;
  }
  for ( std::vector< std::string >::const_iterator gtLogicalExpression = gtLogicalExpressions_.begin(); gtLogicalExpression != gtLogicalExpressions_.end(); ++gtLogicalExpression ) {
    if ( ! acceptGtLogicalExpression( event, *gtLogicalExpression ) ) return false;
  }
  return true;

}
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 322 of file GenericTriggerEventFlag.cc.

References edm::InputTag::encode(), errorReplyDcs_, errorReplyGt_, L1GtLogicParser::expressionResult(), gtEvmInputTag_, gtInputTag_, edm::HandleBase::isValid(), negate(), L1GtLogicParser::operandTokenVector(), AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

Referenced by acceptGt().

{

  // Check empty std::strings
  if ( gtLogicalExpression.empty() ) {
    if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Empty logical expression ==> decision: " << errorReplyGt_;
    return errorReplyGt_;
  }

  // Negated paths
  bool negExpr( negate( gtLogicalExpression ) );
  if ( negExpr && gtLogicalExpression.empty() ) {
    if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Empty (negated) logical expression ==> decision: " << errorReplyGt_;
    return errorReplyGt_;
  }

  // Parse logical expression and determine GT status bit decision
  L1GtLogicParser gtAlgoLogicParser( gtLogicalExpression );
  // Loop over status bits
  for ( size_t iStatusBit = 0; iStatusBit < gtAlgoLogicParser.operandTokenVector().size(); ++iStatusBit ) {
    const std::string gtStatusBit( gtAlgoLogicParser.operandTokenVector().at( iStatusBit ).tokenName );
    // Manipulate status bit decision as stored in the parser
    bool decision( errorReplyDcs_ );
    // Hard-coded status bits!!!
    if ( gtStatusBit == "PhysDecl" || gtStatusBit == "PhysicsDeclared" ) {
      edm::Handle< L1GlobalTriggerReadoutRecord > gtReadoutRecord;
      event.getByLabel( gtInputTag_, gtReadoutRecord );
      if ( ! gtReadoutRecord.isValid() ) {
        if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "L1GlobalTriggerReadoutRecord product with InputTag \"" << gtInputTag_.encode() << "\" not in event ==> decision: " << errorReplyGt_;
        gtAlgoLogicParser.operandTokenVector().at( iStatusBit ).tokenResult = errorReplyDcs_;
        continue;
      }
      decision = ( gtReadoutRecord->gtFdlWord().physicsDeclared() == 1 );
    } else if ( gtStatusBit == "Stable" || gtStatusBit == "StableBeam" || gtStatusBit == "Adjust" || gtStatusBit == "Sqeeze" || gtStatusBit == "Flat" || gtStatusBit == "FlatTop" ||
                gtStatusBit == "7TeV" || gtStatusBit == "8TeV" || gtStatusBit == "2360GeV" || gtStatusBit == "900GeV" ) {
      edm::Handle< L1GlobalTriggerEvmReadoutRecord > gtEvmReadoutRecord;
      event.getByLabel( gtEvmInputTag_, gtEvmReadoutRecord );
      if ( ! gtEvmReadoutRecord.isValid() ) {
        if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "L1GlobalTriggerEvmReadoutRecord product with InputTag \"" << gtEvmInputTag_.encode() << "\" not in event ==> decision: " << errorReplyGt_;
        gtAlgoLogicParser.operandTokenVector().at( iStatusBit ).tokenResult = errorReplyDcs_;
        continue;
      }
      if ( gtStatusBit == "Stable" || gtStatusBit == "StableBeam" ) {
        decision = ( gtEvmReadoutRecord->gtfeWord().beamMode() == 11 );
      } else if ( gtStatusBit == "Adjust" ) {
        decision = ( 10 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
      } else if ( gtStatusBit == "Sqeeze" ) {
        decision = ( 9 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
      } else if ( gtStatusBit == "Flat" || gtStatusBit == "FlatTop" ) {
        decision = ( 8 <= gtEvmReadoutRecord->gtfeWord().beamMode() && gtEvmReadoutRecord->gtfeWord().beamMode() <= 11 );
      } else if ( gtStatusBit == "7TeV" ) {
        decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 3500 );
      } else if ( gtStatusBit == "8TeV" ) {
        decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 4000 );
      } else if ( gtStatusBit == "2360GeV" ) {
        decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 1180 );
      } else if ( gtStatusBit == "900GeV" ) {
        decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 450 );
      }
    } else {
      if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "GT status bit \"" << gtStatusBit << "\" is not defined ==> decision: " << errorReplyGt_;
    }
    gtAlgoLogicParser.operandTokenVector().at( iStatusBit ).tokenResult = decision;
  }

  // Determine decision
  const bool gtDecision( gtAlgoLogicParser.expressionResult() );
  return negExpr ? ( ! gtDecision ) : gtDecision;

}
bool GenericTriggerEventFlag::acceptHlt ( const edm::Event event) [private]

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

Definition at line 464 of file GenericTriggerEventFlag.cc.

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

Referenced by accept().

{

  // An empty HLT logical expressions list acts as switch.
  if ( ! onHlt_ || hltLogicalExpressions_.empty() ) return ( ! andOr_ ); // logically neutral, depending on base logical connective

  // Checking the HLT configuration,
  if ( ! hltConfigInit_ ) {
    if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "HLT config error ==> decision: " << errorReplyHlt_;
    return errorReplyHlt_;
  }

  // Accessing the TriggerResults
  edm::Handle< edm::TriggerResults > hltTriggerResults;
  event.getByLabel( hltInputTag_, hltTriggerResults );
  if ( ! hltTriggerResults.isValid() ) {
    if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "TriggerResults product with InputTag \"" << hltInputTag_.encode() << "\" not in event ==> decision: " << errorReplyHlt_;
    return errorReplyHlt_;
  }
  if ( ( *hltTriggerResults ).size() == 0 ) {
    if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "TriggerResults product with InputTag \"" << hltInputTag_.encode() << "\" empty ==> decision: " << errorReplyHlt_;
    return errorReplyDcs_;
  }

  // Determine decision of HLT logical expression combination and return
  if ( andOrHlt_ ) { // OR combination
    for ( std::vector< std::string >::const_iterator hltLogicalExpression = hltLogicalExpressions_.begin(); hltLogicalExpression != hltLogicalExpressions_.end(); ++hltLogicalExpression ) {
      if ( acceptHltLogicalExpression( hltTriggerResults, *hltLogicalExpression ) ) return true;
    }
    return false;
  }
  for ( std::vector< std::string >::const_iterator hltLogicalExpression = hltLogicalExpressions_.begin(); hltLogicalExpression != hltLogicalExpressions_.end(); ++hltLogicalExpression ) {
    if ( ! acceptHltLogicalExpression( hltTriggerResults, *hltLogicalExpression ) ) return false;
  }
  return true;

}
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 504 of file GenericTriggerEventFlag.cc.

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

Referenced by acceptHlt().

{

  // Check empty std::strings
  if ( hltLogicalExpression.empty() ) {
    if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Empty logical expression ==> decision: " << errorReplyHlt_;
    return errorReplyHlt_;
  }

  // Negated paths
  bool negExpr( negate( hltLogicalExpression ) );
  if ( negExpr && hltLogicalExpression.empty() ) {
    if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Empty (negated) logical expression ==> decision: " << errorReplyHlt_;
    return errorReplyHlt_;
  }

  // Parse logical expression and determine HLT decision
  L1GtLogicParser hltAlgoLogicParser( hltLogicalExpression );
  // Loop over paths
  for ( size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath ) {
    const std::string hltPathName( hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenName );
    const unsigned indexPath( hltConfig_.triggerIndex( hltPathName ) );
    // Further error checks
    if ( indexPath == hltConfig_.size() ) {
      if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "HLT path \"" << hltPathName << "\" is not found in process " << hltInputTag_.process() << " ==> decision: " << errorReplyHlt_;
      hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenResult = errorReplyHlt_;
      continue;
    }
    if ( hltTriggerResults->error( indexPath ) ) {
      if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "HLT path \"" << hltPathName << "\" in error ==> decision: " << errorReplyHlt_;
      hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenResult = errorReplyHlt_;
      continue;
    }
    // Manipulate algo decision as stored in the parser
    const bool decision( hltTriggerResults->accept( indexPath ) );
    hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenResult = decision;
  }

  // Determine decision
  const bool hltDecision( hltAlgoLogicParser.expressionResult() );
  return negExpr ? ( ! hltDecision ) : hltDecision;

}
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 395 of file GenericTriggerEventFlag.cc.

References acceptL1LogicalExpression(), andOr_, andOrL1_, L1GtUtils::getL1GtRunCache(), l1Gt_, l1LogicalExpressions_, onL1_, useL1EventSetup(), and useL1GtTriggerMenuLite().

Referenced by accept().

{

  // An empty L1 logical expressions list acts as switch.
  if ( ! onL1_ || l1LogicalExpressions_.empty() ) return ( ! andOr_ ); // logically neutral, depending on base logical connective

  // Getting the L1 event setup
  l1Gt_.getL1GtRunCache( event, setup, useL1EventSetup, useL1GtTriggerMenuLite ); // FIXME This can possibly go to initRun()

  // Determine decision of L1 logical expression combination and return
  if ( andOrL1_ ) { // OR combination
    for ( std::vector< std::string >::const_iterator l1LogicalExpression = l1LogicalExpressions_.begin(); l1LogicalExpression != l1LogicalExpressions_.end(); ++l1LogicalExpression ) {
      if ( acceptL1LogicalExpression( event, *l1LogicalExpression ) ) return true;
    }
    return false;
  }
  for ( std::vector< std::string >::const_iterator l1LogicalExpression = l1LogicalExpressions_.begin(); l1LogicalExpression != l1LogicalExpressions_.end(); ++l1LogicalExpression ) {
    if ( ! acceptL1LogicalExpression( event, *l1LogicalExpression ) ) return false;
  }
  return true;

}
bool GenericTriggerEventFlag::acceptL1LogicalExpression ( const edm::Event event,
std::string  l1LogicalExpression 
) [private]

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

Definition at line 420 of file GenericTriggerEventFlag.cc.

References L1GtUtils::decisionAfterMask(), L1GtUtils::decisionBeforeMask(), error, errorReplyL1_, L1GtLogicParser::expressionResult(), l1BeforeMask_, l1Gt_, negate(), L1GtLogicParser::operandTokenVector(), AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

Referenced by acceptL1().

{

  // Check empty std::strings
  if ( l1LogicalExpression.empty() ) {
    if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Empty logical expression ==> decision: " << errorReplyL1_;
    return errorReplyL1_;
  }

  // Negated logical expression
  bool negExpr( negate( l1LogicalExpression ) );
  if ( negExpr && l1LogicalExpression.empty() ) {
    if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Empty (negated) logical expression ==> decision: " << errorReplyL1_;
    return errorReplyL1_;
  }

  // Parse logical expression and determine L1 decision
  L1GtLogicParser l1AlgoLogicParser( l1LogicalExpression );
  // Loop over algorithms
  for ( size_t iAlgorithm = 0; iAlgorithm < l1AlgoLogicParser.operandTokenVector().size(); ++iAlgorithm ) {
    const std::string l1AlgoName( l1AlgoLogicParser.operandTokenVector().at( iAlgorithm ).tokenName );
    int error( -1 );
    const bool decision( l1BeforeMask_ ? l1Gt_.decisionBeforeMask( event, l1AlgoName, error ) : l1Gt_.decisionAfterMask( event, l1AlgoName, error ) );
    // Error checks
    if ( error != 0 ) {
      if ( verbose_ > 1 ) {
        if ( error == 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "L1 algorithm \"" << l1AlgoName << "\" does not exist in the L1 menu ==> decision: "                                          << errorReplyL1_;
        else              edm::LogWarning( "GenericTriggerEventFlag" ) << "L1 algorithm \"" << l1AlgoName << "\" received error code " << error << " from L1GtUtils::decisionBeforeMask ==> decision: " << errorReplyL1_;
      }
      l1AlgoLogicParser.operandTokenVector().at( iAlgorithm ).tokenResult = errorReplyL1_;
      continue;
    }
    // Manipulate algo decision as stored in the parser
    l1AlgoLogicParser.operandTokenVector().at( iAlgorithm ).tokenResult = decision;
  }

  // Return decision
  const bool l1Decision( l1AlgoLogicParser.expressionResult() );
  return negExpr ? ( ! l1Decision ) : l1Decision;

}
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 551 of file GenericTriggerEventFlag.cc.

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

Referenced by initRun().

{

  // Find matching entries in the menu
  std::vector< std::string > matched;
  const std::string versionWildcard( "_v*" );
  if ( expr.substr( expr.size() - versionWildcard.size() ) == versionWildcard ) {
    const std::string exprBase( expr.substr( 0, expr.size() - versionWildcard.size() ) );
    matched = hltConfig_.restoreVersion( targets, exprBase );
  } else {
    matched = hltConfig_.matched( targets, expr );
  }

  // Return input, if no match is found
  if ( matched.empty() ) {
    if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Logical expression: \"" << expr << "\" could not be resolved";
    return expr;
  }

  // Compose logical expression
  std::string expanded( "(" );
  for ( unsigned iVers = 0; iVers < matched.size(); ++iVers ) {
    if ( iVers > 0 ) expanded.append( useAnd ? " AND " : " OR " );
    expanded.append( matched.at( iVers ) );
  }
  expanded.append( ")" );
  if ( verbose_ > 1 ) edm::LogInfo( "GenericTriggerEventFlag" ) << "Logical expression: \"" << expr     << "\"\n"
                                                                << "   --> expanded to  \"" << expanded << "\"";

  return expanded;

}
std::vector< std::string > GenericTriggerEventFlag::expressionsFromDB ( const std::string &  key,
const edm::EventSetup setup 
)

Reads and returns logical expressions from DB.

Definition at line 602 of file GenericTriggerEventFlag.cc.

References configError_, dbLabel_, emptyKeyError_, edm::EventSetup::get(), reco_calib_source_client_cfg::labels, and verbose_.

Referenced by MuonRecoOneHLT::beginRun(), and initRun().

{

  if ( key.size() == 0 ) return std::vector< std::string >( 1, emptyKeyError_ );
  edm::ESHandle< AlCaRecoTriggerBits > logicalExpressions;
  std::vector< edm::eventsetup::DataKey > labels;
  setup.get< AlCaRecoTriggerBitsRcd >().fillRegisteredDataKeys( labels );
  std::vector< edm::eventsetup::DataKey >::const_iterator iKey = labels.begin();
  while ( iKey != labels.end() && iKey->name().value() != dbLabel_ ) ++iKey;
  if ( iKey == labels.end() ) {
    if ( verbose_ > 0 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Label " << dbLabel_ << " not found in DB for 'AlCaRecoTriggerBitsRcd'";
    return std::vector< std::string >( 1, configError_ );
  }
  setup.get< AlCaRecoTriggerBitsRcd >().get( dbLabel_, logicalExpressions );
  const std::map< std::string, std::string > & expressionMap = logicalExpressions->m_alcarecoToTrig;
  std::map< std::string, std::string >::const_iterator listIter = expressionMap.find( key );
  if ( listIter == expressionMap.end() ) {
    if ( verbose_ > 0 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "No logical expressions found under key " << key << " in 'AlCaRecoTriggerBitsRcd'";
    return std::vector< std::string >( 1, configError_ );
  }
  return logicalExpressions->decompose( listIter->second );

}
std::string GenericTriggerEventFlag::gtDBKey ( ) [inline]

Definition at line 119 of file GenericTriggerEventFlag.h.

References gtDBKey_.

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

Definition at line 121 of file GenericTriggerEventFlag.h.

References hltDBKey_.

Referenced by MuonRecoOneHLT::beginRun().

{ 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 125 of file GenericTriggerEventFlag.cc.

References edm::ESWatcher< T >::check(), configError_, edm::InputTag::encode(), expandLogicalExpression(), expressionsFromDB(), edm::EventSetup::get(), L1GtUtils::getL1GtRunCache(), gtDBKey_, gtLogicalExpressions_, hltConfig_, hltConfigInit_, hltDBKey_, hltInputTag_, hltLogicalExpressions_, hltLogicalExpressionsCache_, HLTConfigProvider::init(), l1DBKey_, l1Gt_, l1LogicalExpressions_, l1LogicalExpressionsCache_, onGt_, onHlt_, onL1_, edm::InputTag::process(), HLTConfigProvider::size(), AlCaHLTBitMon_QueryRunRegistry::string, HLTConfigProvider::triggerNames(), verbose_, and watchDB_.

Referenced by MuonRecoOneHLT::beginRun(), SiStripMonitorTrack::beginRun(), SiStripMonitorCluster::beginRun(), dEdxAnalyzer::beginRun(), TauTagValidation::beginRun(), LogMessageMonitor::beginRun(), MonitorTrackResiduals::beginRun(), and TrackingMonitor::beginRun().

{

  if ( watchDB_->check( setup ) ) {
    if ( onGt_ && gtDBKey_.size() > 0 ) {
      const std::vector< std::string > exprs( expressionsFromDB( gtDBKey_, setup ) );
      if ( exprs.empty() || exprs.at( 0 ) != configError_ ) gtLogicalExpressions_ = exprs;
    }
    if ( onL1_ && l1DBKey_.size() > 0 ) {
      const std::vector< std::string > exprs( expressionsFromDB( l1DBKey_, setup ) );
      if ( exprs.empty() || exprs.at( 0 ) != configError_ ) l1LogicalExpressionsCache_ = exprs;
    }
    if ( onHlt_ && hltDBKey_.size() > 0 ) {
      const std::vector< std::string > exprs( expressionsFromDB( hltDBKey_, setup ) );
      if ( exprs.empty() || exprs.at( 0 ) != configError_ ) hltLogicalExpressionsCache_ = exprs;
    }
  }

  // Re-initialise starting valuse before wild-card expansion
  l1LogicalExpressions_  = l1LogicalExpressionsCache_;
  hltLogicalExpressions_ = hltLogicalExpressionsCache_;

  hltConfigInit_ = false;
  if ( onHlt_ ) {
    if ( hltInputTag_.process().size() == 0 ) {
      if ( verbose_ > 0 ) edm::LogError( "GenericTriggerEventFlag" ) << "HLT TriggerResults InputTag \"" << hltInputTag_.encode() << "\" specifies no process";
    } else {
      bool hltChanged( false );
      if ( ! hltConfig_.init( run, setup, hltInputTag_.process(), hltChanged ) ) {
        if ( verbose_ > 0 ) edm::LogError( "GenericTriggerEventFlag" ) << "HLT config initialization error with process name \"" << hltInputTag_.process() << "\"";
      } else if ( hltConfig_.size() <= 0 ) {
        if ( verbose_ > 0 ) edm::LogError( "GenericTriggerEventFlag" ) << "HLT config size error";
      } else hltConfigInit_ = true;
    }
  }

  // Expand version wild-cards in HLT logical expressions
  // L1
  if ( onL1_ ) {
    // build vector of algo names
    l1Gt_.getL1GtRunCache( run, setup, true, false );
    edm::ESHandle< L1GtTriggerMenu > handleL1GtTriggerMenu;
    setup.get< L1GtTriggerMenuRcd >().get( handleL1GtTriggerMenu );
//     L1GtTriggerMenu l1GtTriggerMenu( *handleL1GtTriggerMenu );
    std::vector< std::string > algoNames;
//     const AlgorithmMap l1GtPhys( l1GtTriggerMenu.gtAlgorithmMap() );
    const AlgorithmMap l1GtPhys( handleL1GtTriggerMenu->gtAlgorithmMap() );
    for ( CItAlgo iAlgo = l1GtPhys.begin(); iAlgo != l1GtPhys.end(); ++iAlgo ) {
      algoNames.push_back( iAlgo->second.algoName() );
    }
//     const AlgorithmMap l1GtTech( l1GtTriggerMenu.gtTechnicalTriggerMap() );
    const AlgorithmMap l1GtTech( handleL1GtTriggerMenu->gtTechnicalTriggerMap() );
    for ( CItAlgo iAlgo = l1GtTech.begin(); iAlgo != l1GtTech.end(); ++iAlgo ) {
      algoNames.push_back( iAlgo->second.algoName() );
    }
    for ( unsigned iExpr = 0; iExpr < l1LogicalExpressions_.size(); ++iExpr ) {
      std::string l1LogicalExpression( l1LogicalExpressions_.at( iExpr ) );
      L1GtLogicParser l1AlgoLogicParser( l1LogicalExpression );
      // Loop over algorithms
      for ( size_t iAlgo = 0; iAlgo < l1AlgoLogicParser.operandTokenVector().size(); ++iAlgo ) {
        const std::string l1AlgoName( l1AlgoLogicParser.operandTokenVector().at( iAlgo ).tokenName );
        if ( l1AlgoName.find( '*' ) != std::string::npos ) {
          l1LogicalExpression.replace( l1LogicalExpression.find( l1AlgoName ), l1AlgoName.size(), expandLogicalExpression( algoNames, l1AlgoName ) );
        }
      }
      l1LogicalExpressions_[ iExpr ] = l1LogicalExpression;
    }
  }
  // HLT
  if ( hltConfigInit_ ) {
    for ( unsigned iExpr = 0; iExpr < hltLogicalExpressions_.size(); ++iExpr ) {
      std::string hltLogicalExpression( hltLogicalExpressions_.at( iExpr ) );
      L1GtLogicParser hltAlgoLogicParser( hltLogicalExpression );
      // Loop over paths
      for ( size_t iPath = 0; iPath < hltAlgoLogicParser.operandTokenVector().size(); ++iPath ) {
        const std::string hltPathName( hltAlgoLogicParser.operandTokenVector().at( iPath ).tokenName );
        if ( hltPathName.find( '*' ) != std::string::npos ) {
          hltLogicalExpression.replace( hltLogicalExpression.find( hltPathName ), hltPathName.size(), expandLogicalExpression( hltConfig_.triggerNames(), hltPathName ) );
        }
      }
      hltLogicalExpressions_[ iExpr ] = hltLogicalExpression;
    }
  }

}
std::string GenericTriggerEventFlag::l1DBKey ( ) [inline]

Definition at line 120 of file GenericTriggerEventFlag.h.

References l1DBKey_.

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

Checks for negated words.

Definition at line 587 of file GenericTriggerEventFlag.cc.

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

{

  bool negate( false );
  if ( word.at( 0 ) == '~' ) {
    negate = true;
    word.erase( 0, 1 );
  }
  return negate;

}
bool GenericTriggerEventFlag::off ( ) [inline]

Definition at line 87 of file GenericTriggerEventFlag.h.

References on_.

{ return ( ! on_ ); }
bool GenericTriggerEventFlag::on ( ) [inline]

Member Data Documentation

Definition at line 47 of file GenericTriggerEventFlag.h.

Referenced by acceptDcs(), and GenericTriggerEventFlag().

Definition at line 51 of file GenericTriggerEventFlag.h.

Referenced by acceptGt(), and GenericTriggerEventFlag().

Definition at line 63 of file GenericTriggerEventFlag.h.

Referenced by acceptHlt(), and GenericTriggerEventFlag().

Definition at line 57 of file GenericTriggerEventFlag.h.

Referenced by acceptL1(), and GenericTriggerEventFlag().

const std::string GenericTriggerEventFlag::configError_ [private]

Definition at line 76 of file GenericTriggerEventFlag.h.

Referenced by expressionsFromDB(), and initRun().

std::string GenericTriggerEventFlag::dbLabel_ [private]

Definition at line 45 of file GenericTriggerEventFlag.h.

Referenced by expressionsFromDB(), and GenericTriggerEventFlag().

Definition at line 48 of file GenericTriggerEventFlag.h.

Referenced by acceptDcs(), and GenericTriggerEventFlag().

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

Definition at line 49 of file GenericTriggerEventFlag.h.

Referenced by acceptDcs(), and GenericTriggerEventFlag().

const std::string GenericTriggerEventFlag::emptyKeyError_ [private]

Definition at line 77 of file GenericTriggerEventFlag.h.

Referenced by expressionsFromDB().

Definition at line 56 of file GenericTriggerEventFlag.h.

Referenced by acceptGtLogicalExpression(), and GenericTriggerEventFlag().

Definition at line 62 of file GenericTriggerEventFlag.h.

Referenced by acceptL1LogicalExpression(), and GenericTriggerEventFlag().

std::string GenericTriggerEventFlag::gtDBKey_ [private]

Definition at line 54 of file GenericTriggerEventFlag.h.

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

Definition at line 53 of file GenericTriggerEventFlag.h.

Referenced by acceptGtLogicalExpression(), and GenericTriggerEventFlag().

Definition at line 52 of file GenericTriggerEventFlag.h.

Referenced by acceptGtLogicalExpression(), and GenericTriggerEventFlag().

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

Definition at line 55 of file GenericTriggerEventFlag.h.

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

Definition at line 42 of file GenericTriggerEventFlag.h.

Referenced by acceptHlt(), and initRun().

std::string GenericTriggerEventFlag::hltDBKey_ [private]

Definition at line 65 of file GenericTriggerEventFlag.h.

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

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

Definition at line 67 of file GenericTriggerEventFlag.h.

Referenced by acceptHlt(), and initRun().

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

Definition at line 66 of file GenericTriggerEventFlag.h.

Referenced by GenericTriggerEventFlag(), and initRun().

Definition at line 58 of file GenericTriggerEventFlag.h.

Referenced by acceptL1LogicalExpression(), and GenericTriggerEventFlag().

std::string GenericTriggerEventFlag::l1DBKey_ [private]

Definition at line 59 of file GenericTriggerEventFlag.h.

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

Definition at line 40 of file GenericTriggerEventFlag.h.

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

std::vector< std::string > GenericTriggerEventFlag::l1LogicalExpressions_ [private]

Definition at line 61 of file GenericTriggerEventFlag.h.

Referenced by acceptL1(), and initRun().

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

Definition at line 60 of file GenericTriggerEventFlag.h.

Referenced by GenericTriggerEventFlag(), and initRun().

Definition at line 71 of file GenericTriggerEventFlag.h.

Referenced by acceptDcs(), and GenericTriggerEventFlag().

Definition at line 72 of file GenericTriggerEventFlag.h.

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

Definition at line 74 of file GenericTriggerEventFlag.h.

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

Definition at line 73 of file GenericTriggerEventFlag.h.

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