Skip to content

Commit

Permalink
Merge pull request #14820 from mmusich/fixGenericTriggerEventFlag81x
Browse files Browse the repository at this point in the history
tracking and strip DQM : trigger selection via DB + stage2 L1 handling in GenericTriggerEventFlag + update the trigger bits for Tracker DQM
  • Loading branch information
davidlange6 committed Jun 10, 2016
2 parents 1ab0682 + 10da65f commit 45b40a8
Show file tree
Hide file tree
Showing 22 changed files with 194 additions and 122 deletions.
1 change: 1 addition & 0 deletions CommonTools/TriggerUtils/BuildFile.xml
Expand Up @@ -5,6 +5,7 @@
<use name="DataFormats/L1GlobalTrigger"/>
<use name="FWCore/Framework"/>
<use name="L1Trigger/GlobalTriggerAnalyzer"/>
<use name="L1Trigger/L1TGlobal"/>
<use name="HLTrigger/HLTcore"/>
<export>
<lib name="1"/>
Expand Down
15 changes: 13 additions & 2 deletions CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h
Expand Up @@ -31,6 +31,7 @@
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
#include "DataFormats/Scalers/interface/DcsStatus.h"
#include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
#include "L1Trigger/L1TGlobal/interface/L1TGlobalUtil.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"

#include <memory>
Expand All @@ -42,6 +43,7 @@ class GenericTriggerEventFlag {
// Utility classes
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_;
std::unique_ptr<L1GtUtils> l1Gt_;
std::unique_ptr<l1t::L1TGlobalUtil> l1uGt_;
HLTConfigProvider hltConfig_;
bool hltConfigInit_;
// Configuration parameters
Expand All @@ -62,6 +64,7 @@ class GenericTriggerEventFlag {
std::vector< std::string > gtLogicalExpressions_;
bool errorReplyGt_;
bool andOrL1_;
bool stage2_;
bool l1BeforeMask_;
std::string l1DBKey_;
std::vector< std::string > l1LogicalExpressionsCache_;
Expand Down Expand Up @@ -117,7 +120,7 @@ class GenericTriggerEventFlag {

// L1
bool acceptL1( const edm::Event & event, const edm::EventSetup & setup );
bool acceptL1LogicalExpression( const edm::Event & event, std::string l1LogicalExpression );
bool acceptL1LogicalExpression( const edm::Event & event, const edm::EventSetup & setup, std::string l1LogicalExpression );

// HLT
bool acceptHlt( const edm::Event & event );
Expand Down Expand Up @@ -147,7 +150,15 @@ GenericTriggerEventFlag::GenericTriggerEventFlag( const edm::ParameterSet & conf
template <typename T>
GenericTriggerEventFlag::GenericTriggerEventFlag( const edm::ParameterSet & config, edm::ConsumesCollector & iC, T& module ) :
GenericTriggerEventFlag(config, iC) {
l1Gt_.reset(new L1GtUtils(config, iC, false, module));
if ( config.exists( "andOrL1" ) )
if (stage2_)
l1uGt_.reset(new l1t::L1TGlobalUtil(config, iC));
else
l1Gt_.reset(new L1GtUtils(config, iC, false, module));
else {
l1uGt_.reset(NULL);
l1Gt_.reset(NULL);
}
}

#endif
98 changes: 69 additions & 29 deletions CommonTools/TriggerUtils/src/GenericTriggerEventFlag.cc
Expand Up @@ -36,6 +36,7 @@ GenericTriggerEventFlag::GenericTriggerEventFlag( const edm::ParameterSet & conf
, gtDBKey_( "" )
, errorReplyGt_( false )
, andOrL1_( false )
, stage2_( false )
, l1BeforeMask_( true )
, l1DBKey_( "" )
, errorReplyL1_( false )
Expand Down Expand Up @@ -89,6 +90,10 @@ GenericTriggerEventFlag::GenericTriggerEventFlag( const edm::ParameterSet & conf
}
if ( config.exists( "andOrL1" ) ) {
andOrL1_ = config.getParameter< bool >( "andOrL1" );
if ( config.exists( "stage2" ) )
stage2_ = config.getParameter< bool> ( "stage2" );
else
stage2_ = false;
l1LogicalExpressionsCache_ = config.getParameter< std::vector< std::string > >( "l1Algorithms" );
errorReplyL1_ = config.getParameter< bool >( "errorReplyL1" );
if ( config.exists( "l1DBKey" ) ) l1DBKey_ = config.getParameter< std::string >( "l1DBKey" );
Expand Down Expand Up @@ -166,21 +171,31 @@ void GenericTriggerEventFlag::initRun( const edm::Run & run, const edm::EventSet
// L1
if ( onL1_ ) {
// build vector of algo names
l1Gt_->getL1GtRunCache( run, setup, useL1EventSetup, useL1GtTriggerMenuLite );
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() );

if (stage2_) {
l1uGt_->retrieveL1Setup(setup);

const std::vector<std::pair<std::string, int> > prescales = l1uGt_->prescales();
for(auto ip : prescales)
algoNames.push_back(ip.first);
} else {
l1Gt_->getL1GtRunCache( run, setup, useL1EventSetup, useL1GtTriggerMenuLite );
edm::ESHandle< L1GtTriggerMenu > handleL1GtTriggerMenu;
setup.get< L1GtTriggerMenuRcd >().get( handleL1GtTriggerMenu );

const AlgorithmMap l1GtPhys( handleL1GtTriggerMenu->gtAlgorithmMap() );
for ( CItAlgo iAlgo = l1GtPhys.begin(); iAlgo != l1GtPhys.end(); ++iAlgo ) {
algoNames.push_back( iAlgo->second.algoName() );
}
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 );
Expand All @@ -193,6 +208,13 @@ void GenericTriggerEventFlag::initRun( const edm::Run & run, const edm::EventSet
}
l1LogicalExpressions_[ iExpr ] = l1LogicalExpression;
}
std::vector<std::string> tmp = l1LogicalExpressions_;
for ( unsigned iExpr = 0; iExpr < tmp.size(); ++iExpr )
if ( std::find(algoNames.begin(),algoNames.end(),tmp[ iExpr ]) == algoNames.end() ) {
l1LogicalExpressions_.erase(l1LogicalExpressions_.begin()+iExpr);
if ( verbose_ > 1 )
edm::LogWarning( "GenericTriggerEventFlag" ) << "L1 algorithm \"" << tmp[ iExpr ] << "\" does not exist in the L1 menu ==> drop it from the list of l1LogicalExpressions";
}
}
// HLT
if ( hltConfigInit_ ) {
Expand Down Expand Up @@ -357,7 +379,7 @@ bool GenericTriggerEventFlag::acceptGtLogicalExpression( const edm::Event & even
}
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" ) {
gtStatusBit == "7TeV" || gtStatusBit == "8TeV" || gtStatusBit == "13TeV" || gtStatusBit == "2360GeV" || gtStatusBit == "900GeV" ) {
edm::Handle< L1GlobalTriggerEvmReadoutRecord > gtEvmReadoutRecord;
event.getByToken( gtEvmInputToken_, gtEvmReadoutRecord );
if ( ! gtEvmReadoutRecord.isValid() ) {
Expand All @@ -377,6 +399,8 @@ bool GenericTriggerEventFlag::acceptGtLogicalExpression( const edm::Event & even
decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 3500 );
} else if ( gtStatusBit == "8TeV" ) {
decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 4000 );
} else if ( gtStatusBit == "13TeV" ) {
decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 6500 );
} else if ( gtStatusBit == "2360GeV" ) {
decision = ( gtEvmReadoutRecord->gtfeWord().beamMomentum() == 1180 );
} else if ( gtStatusBit == "900GeV" ) {
Expand All @@ -402,28 +426,32 @@ bool GenericTriggerEventFlag::acceptL1( const edm::Event & event, const edm::Eve
// 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;
if ( acceptL1LogicalExpression( event, setup, *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;
if ( ! acceptL1LogicalExpression( event, setup, *l1LogicalExpression ) ) return false;
}
return true;

}


/// Was this event accepted by this particular L1 algorithms' logical expression?
bool GenericTriggerEventFlag::acceptL1LogicalExpression( const edm::Event & event, std::string l1LogicalExpression )
bool GenericTriggerEventFlag::acceptL1LogicalExpression( const edm::Event & event, const edm::EventSetup & setup, std::string l1LogicalExpression )
{

// Getting the L1 event setup
if ( stage2_ )
l1uGt_->retrieveL1(event,setup);
else
l1Gt_->getL1GtRunCache( event, setup, useL1EventSetup, useL1GtTriggerMenuLite ); // FIXME This can possibly go to initRun()


// Check empty std::strings
if ( l1LogicalExpression.empty() ) {
if ( verbose_ > 1 ) edm::LogWarning( "GenericTriggerEventFlag" ) << "Empty logical expression ==> decision: " << errorReplyL1_;
Expand All @@ -442,14 +470,27 @@ bool GenericTriggerEventFlag::acceptL1LogicalExpression( const edm::Event & even
// 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 ) );


bool decision = false;
bool error = false;
if ( stage2_ ) {
bool errorBOOL = (l1BeforeMask_ ? l1uGt_->getInitialDecisionByName(l1AlgoName,decision) : l1uGt_->getFinalDecisionByName(l1AlgoName,decision) );
error = !errorBOOL;
} else {
int errorINT( -1 );
// const bool decision( l1BeforeMask_ ? l1Gt_->decisionBeforeMask( event, l1AlgoName, errorINT ) : l1Gt_->decisionAfterMask( event, l1AlgoName, errorINT ) );
decision = ( l1BeforeMask_ ? l1Gt_->decisionBeforeMask( event, l1AlgoName, errorINT ) : l1Gt_->decisionAfterMask( event, l1AlgoName, errorINT ) );
error = ( errorINT != 0 );
if ( errorINT > 1 )
if ( verbose_ > 1 )
edm::LogWarning( "GenericTriggerEventFlag" ) << "L1 algorithm \"" << l1AlgoName << "\" received error code " << error << " from L1GtUtils::decisionBeforeMask ==> decision: " << errorReplyL1_;
}

// 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_;
}
if ( error ) {
if ( verbose_ > 1 )
edm::LogWarning( "GenericTriggerEventFlag" ) << "L1 algorithm \"" << l1AlgoName << "\" does not exist in the L1 menu ==> decision: " << errorReplyL1_;
l1AlgoLogicParser.operandTokenVector().at( iAlgorithm ).tokenResult = errorReplyL1_;
continue;
}
Expand Down Expand Up @@ -604,8 +645,7 @@ bool GenericTriggerEventFlag::negate( std::string & word ) const

/// Reads and returns logical expressions from DB
std::vector< std::string > GenericTriggerEventFlag::expressionsFromDB( const std::string & key, const edm::EventSetup & setup )
{

{
if ( key.size() == 0 ) return std::vector< std::string >( 1, emptyKeyError_ );
edm::ESHandle< AlCaRecoTriggerBits > logicalExpressions;
std::vector< edm::eventsetup::DataKey > labels;
Expand Down
28 changes: 14 additions & 14 deletions Configuration/AlCa/python/autoCond.py
Expand Up @@ -2,29 +2,29 @@

### NEW KEYS ###
# GlobalTag for MC production with perfectly aligned and calibrated detector for Run1
'run1_design' : '80X_mcRun1_design_v4',
'run1_design' : '81X_mcRun1_design_v0',
# GlobalTag for MC production (pp collisions) with realistic alignment and calibrations for Run1
'run1_mc' : '80X_mcRun1_realistic_v4',
'run1_mc' : '81X_mcRun1_realistic_v0',
# GlobalTag for MC production (Heavy Ions collisions) with realistic alignment and calibrations for Run1
'run1_mc_hi' : '80X_mcRun1_HeavyIon_v4',
'run1_mc_hi' : '81X_mcRun1_HeavyIon_v0',
# GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run1
'run1_mc_pa' : '80X_mcRun1_pA_v4',
'run1_mc_pa' : '81X_mcRun1_pA_v0',
# GlobalTag for MC production with perfectly aligned and calibrated detector for Run2
'run2_design' : '80X_mcRun2_design_v14',
'run2_design' : '81X_mcRun2_design_v0',
# GlobalTag for MC production with pessimistic alignment and calibrations for Run2
'run2_mc_50ns' : '80X_mcRun2_startup_v14',
'run2_mc_50ns' : '81X_mcRun2_startup_v0',
#GlobalTag for MC production with optimistic alignment and calibrations for Run2
'run2_mc' : '80X_mcRun2_asymptotic_v14',
'run2_mc' : '81X_mcRun2_asymptotic_v0',
# GlobalTag for MC production (cosmics) with starup-like alignment and calibrations for Run2, Strip tracker in peak mode
'run2_mc_cosmics' : '80X_mcRun2cosmics_startup_peak_v13',
'run2_mc_cosmics' : '81X_mcRun2cosmics_startup_peak_v0',
# GlobalTag for MC production (Heavy Ions collisions) with optimistic alignment and calibrations for Run2
'run2_mc_hi' : '80X_mcRun2_HeavyIon_v8',
'run2_mc_hi' : '81X_mcRun2_HeavyIon_v0',
# GlobalTag for Run1 data reprocessing
'run1_data' : '80X_dataRun2_v14',
'run1_data' : '81X_dataRun2_v0',
# GlobalTag for Run2 data reprocessing
'run2_data' : '80X_dataRun2_v14',
'run2_data' : '81X_dataRun2_v0',
# GlobalTag for Run2 data relvals: allows customization to run with fixed L1 menu
'run2_data_relval' : '80X_dataRun2_relval_v12',
'run2_data_relval' : '81X_dataRun2_relval_v0',
# GlobalTag for Run1 HLT: it points to the online GT
'run1_hlt' : '80X_dataRun2_HLT_frozen_v12',
# GlobalTag for Run2 HLT: it points to the online GT
Expand All @@ -34,9 +34,9 @@
# GlobalTag for Run2 HLT for HI: it points to the online GT
'run2_hlt_hi' : '80X_dataRun2_HLTHI_frozen_v9',
# GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017
'phase1_2017_design' : '81X_upgrade2017_design_v1',
'phase1_2017_design' : '81X_upgrade2017_design_v2',
# GlobalTag for MC production with realistic conditions for for Phase1 2017 detector
'phase1_2017_realistic': '81X_upgrade2017_realistic_v1',
'phase1_2017_realistic': '81X_upgrade2017_realistic_v2',
# GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019
'phase1_2019_design' : 'DES19_70_V2', # placeholder (GT not meant for standard RelVal)
# GlobalTag for MC production with perfectly aligned and calibrated detector for Phase2
Expand Down
35 changes: 13 additions & 22 deletions DQM/SiStripMonitorClient/python/SiStripSourceConfigTier0_cff.py
Expand Up @@ -34,6 +34,8 @@
SiStripMonitorDigi.TProfNShotsVsTime.globalswitchon = False
SiStripMonitorDigi.TProfGlobalNShots.globalswitchon = True

from DQM.SiStripMonitorClient.pset4GenericTriggerEventFlag_cfi import *

# SiStripMonitorCluster ####
from DQM.SiStripMonitorCluster.SiStripMonitorCluster_cfi import *
SiStripMonitorClusterBPTX = SiStripMonitorCluster.clone()
Expand All @@ -48,14 +50,7 @@
SiStripMonitorClusterBPTX.TH1StripNoise2ApvCycle.globalswitchon = True
SiStripMonitorClusterBPTX.TH1StripNoise3ApvCycle.globalswitchon = True
SiStripMonitorClusterBPTX.ClusterHisto = True
SiStripMonitorClusterBPTX.BPTXfilter = cms.PSet(
andOr = cms.bool( False ),
dbLabel = cms.string("SiStripDQMTrigger"),
l1Algorithms = cms.vstring( 'L1Tech_BPTX_plus_AND_minus.v0', 'L1_ZeroBias' ),
andOrL1 = cms.bool( True ),
errorReplyL1 = cms.bool( True ),
l1BeforeMask = cms.bool( True ) # specifies, if the L1 algorithm decision should be read as before (true) or after (false) masking is applied.
)
SiStripMonitorClusterBPTX.BPTXfilter = genericTriggerEventFlag4L1bd
SiStripMonitorClusterBPTX.PixelDCSfilter = cms.PSet(
andOr = cms.bool( False ),
dcsInputTag = cms.InputTag( "scalersRawToDigi" ),
Expand All @@ -71,6 +66,14 @@
errorReplyDcs = cms.bool( True ),
)

from Configuration.StandardSequences.Eras import eras
eras.stage2L1Trigger.toModify(SiStripMonitorClusterBPTX,
BPTXfilter = dict(
stage2 = cms.bool(True),
l1tAlgBlkInputTag = cms.InputTag("gtStage2Digis"),
l1tExtBlkInputTag = cms.InputTag("gtStage2Digis")
)
)


# Clone for SiStripMonitorTrack for all PDs but Minimum Bias and Jet ####
Expand All @@ -86,13 +89,7 @@
SiStripMonitorTrackMB = DQM.SiStripMonitorTrack.SiStripMonitorTrack_cfi.SiStripMonitorTrack.clone()
SiStripMonitorTrackMB.TrackProducer = 'generalTracks'
SiStripMonitorTrackMB.Mod_On = False
SiStripMonitorTrackMB.andOr = cms.bool( False )
SiStripMonitorTrackMB.dbLabel = cms.string("SiStripDQMTrigger")
SiStripMonitorTrackMB.hltInputTag = cms.InputTag( "TriggerResults::HLT" )
SiStripMonitorTrackMB.hltPaths = cms.vstring("HLT_ZeroBias_v*","HLT_HIZeroBias_v*")
SiStripMonitorTrackMB.hltDBKey = cms.string("Tracker_MB")
SiStripMonitorTrackMB.errorReplyHlt = cms.bool( False )
SiStripMonitorTrackMB.andOrHlt = cms.bool(True) # True:=OR; False:=AND
SiStripMonitorTrackMB.genericTriggerEventPSet = genericTriggerEventFlag4HLTdb
SiStripMonitorTrackMB.TH1ClusterCharge.ringView = cms.bool( True )
SiStripMonitorTrackMB.TH1ClusterStoNCorr.ringView = cms.bool( True )

Expand All @@ -101,13 +98,7 @@
MonitorTrackResiduals.trajectoryInput = 'generalTracks'
MonitorTrackResiduals.Tracks = 'generalTracks'
MonitorTrackResiduals.Mod_On = False
MonitorTrackResiduals.andOr = cms.bool( False )
MonitorTrackResiduals.dbLabel = cms.string("SiStripDQMTrigger")
MonitorTrackResiduals.hltInputTag = cms.InputTag( "TriggerResults::HLT" )
MonitorTrackResiduals.hltPaths = cms.vstring("HLT_ZeroBias_v*","HLT_HIZeroBias_v*")
MonitorTrackResiduals.hltDBKey = cms.string("Tracker_MB")
MonitorTrackResiduals.errorReplyHlt = cms.bool( False )
MonitorTrackResiduals.andOrHlt = cms.bool(True)
MonitorTrackResiduals.genericTriggerEventPSet = genericTriggerEventFlag4HLTdb

# DQM Services
dqmInfoSiStrip = cms.EDAnalyzer("DQMEventInfo",
Expand Down

0 comments on commit 45b40a8

Please sign in to comment.