Produces the central entry point to full PAT trigger information. More...
#include <PhysicsTools/PatAlgos/plugins/PATTriggerEventProducer.h>
Public Member Functions | |
PATTriggerEventProducer (const edm::ParameterSet &iConfig) | |
~PATTriggerEventProducer () | |
Private Member Functions | |
virtual void | beginLuminosityBlock (edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) |
virtual void | beginRun (edm::Run &iRun, const edm::EventSetup &iSetup) |
virtual void | produce (edm::Event &iEvent, const edm::EventSetup &iSetup) |
Private Attributes | |
bool | autoProcessName_ |
edm::ConditionsInLumiBlock | condLumi_ |
edm::ConditionsInRunBlock | condRun_ |
bool | gtCondLumiInit_ |
bool | gtCondRunInit_ |
HLTConfigProvider | hltConfig_ |
bool | hltConfigInit_ |
std::string | nameProcess_ |
edm::InputTag | tagCondGt_ |
edm::InputTag | tagL1Gt_ |
std::vector< edm::InputTag > | tagsTriggerMatcher_ |
edm::InputTag | tagTriggerEvent_ |
edm::InputTag | tagTriggerProducer_ |
edm::InputTag | tagTriggerResults_ |
Produces the central entry point to full PAT trigger information.
This producer extract general trigger and conditions information from
For me information, s. https://twiki.cern.ch/twiki/bin/view/CMS/SWGuidePATTrigger
Definition at line 47 of file PATTriggerEventProducer.h.
PATTriggerEventProducer::PATTriggerEventProducer | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 29 of file PATTriggerEventProducer.cc.
References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), tagCondGt_, tagL1Gt_, tagsTriggerMatcher_, tagTriggerEvent_, tagTriggerProducer_, and tagTriggerResults_.
: nameProcess_( iConfig.getParameter< std::string >( "processName" ) ), autoProcessName_( nameProcess_ == "*" ), tagTriggerProducer_( "patTrigger" ), tagsTriggerMatcher_(), // L1 configuration parameters tagL1Gt_(), // HLT configuration parameters tagTriggerResults_( "TriggerResults" ), tagTriggerEvent_( "hltTriggerSummaryAOD" ), // Conditions configuration parameters tagCondGt_() { if ( iConfig.exists( "triggerResults" ) ) tagTriggerResults_ = iConfig.getParameter< InputTag >( "triggerResults" ); if ( iConfig.exists( "triggerEvent" ) ) tagTriggerEvent_ = iConfig.getParameter< InputTag >( "triggerEvent" ); if ( iConfig.exists( "patTriggerProducer" ) ) tagTriggerProducer_ = iConfig.getParameter< InputTag >( "patTriggerProducer" ); if ( iConfig.exists( "condGtTag" ) ) tagCondGt_ = iConfig.getParameter< InputTag >( "condGtTag" ); if ( iConfig.exists( "l1GtTag" ) ) tagL1Gt_ = iConfig.getParameter< InputTag >( "l1GtTag" ); if ( iConfig.exists( "patTriggerMatches" ) ) tagsTriggerMatcher_ = iConfig.getParameter< std::vector< InputTag > >( "patTriggerMatches" ); for ( size_t iMatch = 0; iMatch < tagsTriggerMatcher_.size(); ++iMatch ) { produces< TriggerObjectMatch >( tagsTriggerMatcher_.at( iMatch ).label() ); } produces< TriggerEvent >(); }
pat::PATTriggerEventProducer::~PATTriggerEventProducer | ( | ) | [inline] |
Definition at line 52 of file PATTriggerEventProducer.h.
{};
void PATTriggerEventProducer::beginLuminosityBlock | ( | edm::LuminosityBlock & | iLumi, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 122 of file PATTriggerEventProducer.cc.
References condLumi_, edm::InputTag::encode(), edm::LuminosityBlock::getByLabel(), gtCondLumiInit_, edm::HandleBase::isValid(), edm::InputTag::label(), nameProcess_, and tagCondGt_.
{ // Terminate, if auto process name determination failed if ( nameProcess_ == "*" ) return; gtCondLumiInit_ = false; if ( ! tagCondGt_.label().empty() ) { Handle< ConditionsInLumiBlock > condLumiBlock; iLuminosityBlock.getByLabel( tagCondGt_, condLumiBlock ); if ( condLumiBlock.isValid() ) { condLumi_ = *condLumiBlock; gtCondLumiInit_ = true; } else { LogError( "conditionsInEdm" ) << "ConditionsInLumiBlock product with InputTag '" << tagCondGt_.encode() << "' not in lumi"; } } }
void PATTriggerEventProducer::beginRun | ( | edm::Run & | iRun, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 58 of file PATTriggerEventProducer.cc.
References autoProcessName_, condRun_, edm::InputTag::encode(), edm::ParameterSet::exists(), edm::Run::getByLabel(), gtCondRunInit_, hltConfig_, hltConfigInit_, HLTConfigProvider::init(), edm::InputTag::instance(), edm::HandleBase::isValid(), edm::InputTag::label(), LogDebug, nameProcess_, edm::InputTag::process(), edm::Run::processHistory(), HLTConfigProvider::size(), tagCondGt_, tagTriggerEvent_, and tagTriggerResults_.
{ // Initialize process name if ( autoProcessName_ ) { // reset nameProcess_ = "*"; // determine process name from last run TriggerSummaryProducerAOD module in process history of input const ProcessHistory & processHistory( iRun.processHistory() ); ProcessConfiguration processConfiguration; ParameterSet processPSet; // unbroken loop, which relies on time ordering (accepts the last found entry) for ( ProcessHistory::const_iterator iHist = processHistory.begin(); iHist != processHistory.end(); ++iHist ) { if ( processHistory.getConfigurationForProcess( iHist->processName(), processConfiguration ) && pset::Registry::instance()->getMapped( processConfiguration.parameterSetID(), processPSet ) && processPSet.exists( tagTriggerEvent_.label() ) ) { nameProcess_ = iHist->processName(); LogDebug( "autoProcessName" ) << "HLT process name '" << nameProcess_ << "' discovered"; } } // terminate, if nothing is found if ( nameProcess_ == "*" ) { LogError( "autoProcessName" ) << "trigger::TriggerEvent product with label '" << tagTriggerEvent_.label() << "' not produced according to process history of input data\n" << "No trigger information produced."; return; } LogInfo( "autoProcessName" ) << "HLT process name " << nameProcess_ << " used for PAT trigger information"; } // adapt configuration of used input tags if ( tagTriggerResults_.process().empty() || tagTriggerResults_.process() == "*" ) { tagTriggerResults_ = InputTag( tagTriggerResults_.label(), tagTriggerResults_.instance(), nameProcess_ ); } else if ( tagTriggerEvent_.process() != nameProcess_ ) { LogWarning( "triggerResultsTag" ) << "TriggerResults process name '" << tagTriggerResults_.process() << "' differs from HLT process name '" << nameProcess_ << "'"; } if ( tagTriggerEvent_.process().empty() || tagTriggerEvent_.process() == "*" ) { tagTriggerEvent_ = InputTag( tagTriggerEvent_.label(), tagTriggerEvent_.instance(), nameProcess_ ); } else if ( tagTriggerEvent_.process() != nameProcess_ ) { LogWarning( "triggerEventTag" ) << "TriggerEvent process name '" << tagTriggerEvent_.process() << "' differs from HLT process name '" << nameProcess_ << "'"; } gtCondRunInit_ = false; if ( ! tagCondGt_.label().empty() ) { Handle< ConditionsInRunBlock > condRunBlock; iRun.getByLabel( tagCondGt_, condRunBlock ); if ( condRunBlock.isValid() ) { condRun_ = *condRunBlock; gtCondRunInit_ = true; } else { LogError( "conditionsInEdm" ) << "ConditionsInRunBlock product with InputTag '" << tagCondGt_.encode() << "' not in run"; } } // Initialize HLTConfigProvider hltConfigInit_ = false; bool changed( true ); if ( ! hltConfig_.init( iRun, iSetup, nameProcess_, changed ) ) { LogError( "hltConfigExtraction" ) << "HLT config extraction error with process name '" << nameProcess_ << "'"; } else if ( hltConfig_.size() <= 0 ) { LogError( "hltConfigSize" ) << "HLT config size error"; } else hltConfigInit_ = true; }
void PATTriggerEventProducer::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 143 of file PATTriggerEventProducer.cc.
References edm::ConditionsInRunBlock::BAvgCurrent, edm::ConditionsInRunBlock::beamMode, edm::ConditionsInRunBlock::beamMomentum, edm::ConditionsInRunBlock::BStartCurrent, edm::ConditionsInRunBlock::BStopCurrent, condLumi_, condRun_, edm::InputTag::encode(), edm::AssociativeIterator< KeyRefType, AssociativeCollection, ItemGetter >::end(), edm::helper::Filler< Map >::fill(), edm::EventSetup::get(), edm::Event::get(), edm::Event::getByLabel(), gtCondLumiInit_, gtCondRunInit_, hltConfig_, hltConfigInit_, edm::helper::Filler< Map >::insert(), edm::EventBase::isRealData(), edm::HandleBase::isValid(), edm::InputTag::label(), edm::ConditionsInRunBlock::lhcFillNumber, nameProcess_, L1GtFdlWord::physicsDeclared(), edm::Event::put(), HLTConfigProvider::tableName(), tagCondGt_, tagL1Gt_, tagsTriggerMatcher_, tagTriggerProducer_, tagTriggerResults_, edm::ConditionsInLumiBlock::totalIntensityBeam1, and edm::ConditionsInLumiBlock::totalIntensityBeam2.
{ // Terminate, if auto process name determination failed if ( nameProcess_ == "*" ) return; if ( ! hltConfigInit_ ) return; ESHandle< L1GtTriggerMenu > handleL1GtTriggerMenu; iSetup.get< L1GtTriggerMenuRcd >().get( handleL1GtTriggerMenu ); Handle< TriggerResults > handleTriggerResults; iEvent.getByLabel( tagTriggerResults_, handleTriggerResults ); if ( ! handleTriggerResults.isValid() ) { LogError( "triggerResultsValid" ) << "TriggerResults product with InputTag '" << tagTriggerResults_.encode() << "' not in event\n" << "No trigger information produced"; return; } Handle< TriggerAlgorithmCollection > handleTriggerAlgorithms; iEvent.getByLabel( tagTriggerProducer_, handleTriggerAlgorithms ); Handle< TriggerConditionCollection > handleTriggerConditions; iEvent.getByLabel( tagTriggerProducer_, handleTriggerConditions ); Handle< TriggerPathCollection > handleTriggerPaths; iEvent.getByLabel( tagTriggerProducer_, handleTriggerPaths ); Handle< TriggerFilterCollection > handleTriggerFilters; iEvent.getByLabel( tagTriggerProducer_, handleTriggerFilters ); Handle< TriggerObjectCollection > handleTriggerObjects; iEvent.getByLabel( tagTriggerProducer_, handleTriggerObjects ); Handle< TriggerObjectStandAloneCollection > handleTriggerObjectsStandAlone; iEvent.getByLabel( tagTriggerProducer_, handleTriggerObjectsStandAlone ); assert( handleTriggerObjects->size() == handleTriggerObjectsStandAlone->size() ); bool physDecl( false ); if ( iEvent.isRealData() && ! tagL1Gt_.label().empty() ) { Handle< L1GlobalTriggerReadoutRecord > handleL1GlobalTriggerReadoutRecord; iEvent.getByLabel( tagL1Gt_, handleL1GlobalTriggerReadoutRecord ); if ( handleL1GlobalTriggerReadoutRecord.isValid() ) { L1GtFdlWord fdlWord = handleL1GlobalTriggerReadoutRecord->gtFdlWord(); if ( fdlWord.physicsDeclared() == 1 ) { physDecl = true; } } else { LogError( "l1GlobalTriggerReadoutRecordValid" ) << "L1GlobalTriggerReadoutRecord product with InputTag '" << tagL1Gt_.encode() << "' not in event"; } } else { physDecl = true; } // produce trigger event std::auto_ptr< TriggerEvent > triggerEvent( new TriggerEvent( handleL1GtTriggerMenu->gtTriggerMenuName(), std::string( hltConfig_.tableName() ), handleTriggerResults->wasrun(), handleTriggerResults->accept(), handleTriggerResults->error(), physDecl ) ); // set product references to trigger collections if ( handleTriggerAlgorithms.isValid() ) { triggerEvent->setAlgorithms( handleTriggerAlgorithms ); } else { LogError( "triggerAlgorithmsValid" ) << "pat::TriggerAlgorithmCollection product with InputTag '" << tagTriggerProducer_.encode() << "' not in event"; } if ( handleTriggerConditions.isValid() ) { triggerEvent->setConditions( handleTriggerConditions ); } else { LogError( "triggerConditionsValid" ) << "pat::TriggerConditionCollection product with InputTag '" << tagTriggerProducer_.encode() << "' not in event"; } if ( handleTriggerPaths.isValid() ) { triggerEvent->setPaths( handleTriggerPaths ); } else { LogError( "triggerPathsValid" ) << "pat::TriggerPathCollection product with InputTag '" << tagTriggerProducer_.encode() << "' not in event"; } if ( handleTriggerFilters.isValid() ) { triggerEvent->setFilters( handleTriggerFilters ); } else { LogError( "triggerFiltersValid" ) << "pat::TriggerFilterCollection product with InputTag '" << tagTriggerProducer_.encode() << "' not in event"; } if ( handleTriggerObjects.isValid() ) { triggerEvent->setObjects( handleTriggerObjects ); } else { LogError( "triggerObjectsValid" ) << "pat::TriggerObjectCollection product with InputTag '" << tagTriggerProducer_.encode() << "' not in event"; } if ( gtCondRunInit_ ) { triggerEvent->setLhcFill( condRun_.lhcFillNumber ); triggerEvent->setBeamMode( condRun_.beamMode ); triggerEvent->setBeamMomentum( condRun_.beamMomentum ); triggerEvent->setBCurrentStart( condRun_.BStartCurrent ); triggerEvent->setBCurrentStop( condRun_.BStopCurrent ); triggerEvent->setBCurrentAvg( condRun_.BAvgCurrent ); } if ( gtCondLumiInit_ ) { triggerEvent->setIntensityBeam1( condLumi_.totalIntensityBeam1 ); triggerEvent->setIntensityBeam2( condLumi_.totalIntensityBeam2 ); } if ( ! tagCondGt_.label().empty() ) { Handle< ConditionsInEventBlock > condEventBlock; iEvent.getByLabel( tagCondGt_, condEventBlock ); if ( condEventBlock.isValid() ) { triggerEvent->setBstMasterStatus( condEventBlock->bstMasterStatus ); triggerEvent->setTurnCount( condEventBlock->turnCountNumber ); } else { LogError( "conditionsInEdm" ) << "ConditionsInEventBlock product with InputTag '" << tagCondGt_.encode() << "' not in event"; } } // produce trigger match association and set references if ( handleTriggerObjects.isValid() ) { for ( size_t iMatch = 0; iMatch < tagsTriggerMatcher_.size(); ++iMatch ) { const std::string labelTriggerObjectMatcher( tagsTriggerMatcher_.at( iMatch ).label() ); // copy trigger match association using TriggerObjectStandAlone to those using TriggerObject // relying on the fact, that only one candidate collection is present in the association Handle< TriggerObjectStandAloneMatch > handleTriggerObjectStandAloneMatch; iEvent.getByLabel( labelTriggerObjectMatcher, handleTriggerObjectStandAloneMatch ); if ( ! handleTriggerObjectStandAloneMatch.isValid() ) { LogError( "triggerMatchValid" ) << "pat::TriggerObjectStandAloneMatch product with InputTag '" << labelTriggerObjectMatcher << "' not in event"; continue; } AssociativeIterator< reco::CandidateBaseRef, TriggerObjectStandAloneMatch > it( *handleTriggerObjectStandAloneMatch, EdmEventItemGetter< reco::CandidateBaseRef >( iEvent ) ), itEnd( it.end() ); Handle< reco::CandidateView > handleCands; if ( it != itEnd ) iEvent.get( it->first.id(), handleCands ); std::vector< int > indices; while ( it != itEnd ) { indices.push_back( it->second.key() ); ++it; } std::auto_ptr< TriggerObjectMatch > triggerObjectMatch( new TriggerObjectMatch( handleTriggerObjects ) ); TriggerObjectMatch::Filler matchFiller( *triggerObjectMatch ); if ( handleCands.isValid() ) { matchFiller.insert( handleCands, indices.begin(), indices.end() ); } matchFiller.fill(); OrphanHandle< TriggerObjectMatch > handleTriggerObjectMatch( iEvent.put( triggerObjectMatch, labelTriggerObjectMatcher ) ); // set product reference to trigger match association if ( ! handleTriggerObjectMatch.isValid() ) { LogError( "triggerMatchValid" ) << "pat::TriggerObjectMatch product with InputTag '" << labelTriggerObjectMatcher << "' not in event"; continue; } if ( ! ( triggerEvent->addObjectMatchResult( handleTriggerObjectMatch, labelTriggerObjectMatcher ) ) ) { LogWarning( "triggerObjectMatchReplication" ) << "pat::TriggerEvent contains already a pat::TriggerObjectMatch from matcher module '" << labelTriggerObjectMatcher << "'"; } } } iEvent.put( triggerEvent ); }
bool pat::PATTriggerEventProducer::autoProcessName_ [private] |
Definition at line 61 of file PATTriggerEventProducer.h.
Referenced by beginRun().
Definition at line 74 of file PATTriggerEventProducer.h.
Referenced by beginLuminosityBlock(), and produce().
Definition at line 73 of file PATTriggerEventProducer.h.
Referenced by beginRun(), and produce().
bool pat::PATTriggerEventProducer::gtCondLumiInit_ [private] |
Definition at line 76 of file PATTriggerEventProducer.h.
Referenced by beginLuminosityBlock(), and produce().
bool pat::PATTriggerEventProducer::gtCondRunInit_ [private] |
Definition at line 75 of file PATTriggerEventProducer.h.
Referenced by beginRun(), and produce().
Definition at line 67 of file PATTriggerEventProducer.h.
Referenced by beginRun(), and produce().
bool pat::PATTriggerEventProducer::hltConfigInit_ [private] |
Definition at line 68 of file PATTriggerEventProducer.h.
Referenced by beginRun(), and produce().
std::string pat::PATTriggerEventProducer::nameProcess_ [private] |
Definition at line 60 of file PATTriggerEventProducer.h.
Referenced by beginLuminosityBlock(), beginRun(), and produce().
Definition at line 72 of file PATTriggerEventProducer.h.
Referenced by beginLuminosityBlock(), beginRun(), PATTriggerEventProducer(), and produce().
Definition at line 65 of file PATTriggerEventProducer.h.
Referenced by PATTriggerEventProducer(), and produce().
std::vector< edm::InputTag > pat::PATTriggerEventProducer::tagsTriggerMatcher_ [private] |
Definition at line 63 of file PATTriggerEventProducer.h.
Referenced by PATTriggerEventProducer(), and produce().
Definition at line 70 of file PATTriggerEventProducer.h.
Referenced by beginRun(), and PATTriggerEventProducer().
Definition at line 62 of file PATTriggerEventProducer.h.
Referenced by PATTriggerEventProducer(), and produce().
Definition at line 69 of file PATTriggerEventProducer.h.
Referenced by beginRun(), PATTriggerEventProducer(), and produce().