#include <CandidateTriggerObjectProducer.h>
Public Member Functions | |
CandidateTriggerObjectProducer (const edm::ParameterSet &) | |
~CandidateTriggerObjectProducer () | |
Private Member Functions | |
virtual void | beginJob () |
virtual void | beginRun (edm::Run &iRun, edm::EventSetup const &iSetup) |
virtual void | endJob () |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
Private Attributes | |
HLTConfigProvider | hltConfig_ |
edm::Handle < trigger::TriggerEvent > | triggerEventHandle_ |
edm::InputTag | triggerEventTag_ |
std::string | triggerName_ |
edm::Handle< edm::TriggerResults > | triggerResultsHandle_ |
additional class data memebers | |
edm::InputTag | triggerResultsTag_ |
module config parameters |
This class creates a list of candidates based on the last accepted filter
Definition at line 26 of file CandidateTriggerObjectProducer.h.
CandidateTriggerObjectProducer::CandidateTriggerObjectProducer | ( | const edm::ParameterSet & | ps | ) | [explicit] |
Definition at line 15 of file CandidateTriggerObjectProducer.cc.
: triggerResultsTag_(ps.getParameter<edm::InputTag>("triggerResults")), triggerEventTag_(ps.getParameter<edm::InputTag>("triggerEvent")), triggerName_(ps.getParameter<std::string>("triggerName")) { using namespace edm; // cout << "Trigger Object Producer:" << endl // << " TriggerResultsTag = " << triggerResultsTag_.encode() << endl // << " TriggerEventTag = " << triggerEventTag_.encode() << endl; produces<reco::CandidateCollection>(); }
CandidateTriggerObjectProducer::~CandidateTriggerObjectProducer | ( | ) |
Definition at line 30 of file CandidateTriggerObjectProducer.cc.
{ }
virtual void CandidateTriggerObjectProducer::beginJob | ( | void | ) | [inline, private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 34 of file CandidateTriggerObjectProducer.h.
{} ;
void CandidateTriggerObjectProducer::beginRun | ( | edm::Run & | iRun, |
edm::EventSetup const & | iSetup | ||
) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 38 of file CandidateTriggerObjectProducer.cc.
References Exception, hltConfig_, HLTConfigProvider::init(), edm::InputTag::process(), and triggerEventTag_.
{ using namespace edm; bool changed(false); if(!hltConfig_.init(iRun,iSetup,triggerEventTag_.process(),changed) ){ edm::LogError( "CandidateTriggerObjectProducer" ) << "Error! Can't initialize HLTConfigProvider"; throw cms::Exception("HLTConfigProvider::init() returned non 0"); } return; }
virtual void CandidateTriggerObjectProducer::endJob | ( | void | ) | [inline, private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 36 of file CandidateTriggerObjectProducer.h.
{} ;
void CandidateTriggerObjectProducer::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 55 of file CandidateTriggerObjectProducer.cc.
References coll, edm::Event::getByLabel(), hltConfig_, i, trigger::TriggerObject::id(), edm::HandleBase::isValid(), m, max(), moduleLabel(), HLTConfigProvider::moduleLabels(), HLTConfigProvider::moduleType(), n, reco::Particle::p4(), trigger::TriggerObject::particle(), makeHLTPrescaleTable::prescales, HLTConfigProvider::prescaleValues(), edm::InputTag::process(), edm::Event::put(), dt_dqm_sourceclient_common_cff::reco, HLTConfigProvider::size(), triggerEventHandle_, triggerEventTag_, HLTConfigProvider::triggerIndex(), edm::TriggerNames::triggerIndex(), triggerName_, edm::Event::triggerNames(), HLTConfigProvider::triggerNames(), triggerResultsHandle_, and triggerResultsTag_.
{ using namespace edm; using namespace reco; using namespace trigger; std::auto_ptr<reco::CandidateCollection> coll( new reco::CandidateCollection ); // get event products iEvent.getByLabel(triggerResultsTag_,triggerResultsHandle_); if (!triggerResultsHandle_.isValid()) { edm::LogError( "CandidateTriggerObjectProducer" ) << "CandidateTriggerObjectProducer::analyze: Error in getting TriggerResults product from Event!" ; return; } iEvent.getByLabel(triggerEventTag_,triggerEventHandle_); if (!triggerEventHandle_.isValid()) { edm::LogError( "CandidateTriggerObjectProducer" ) << "CandidateTriggerObjectProducer::analyze: Error in getting TriggerEvent product from Event!" ; return; } // sanity check // std::cout << hltConfig_.size() << std::endl; // std::cout << triggerResultsHandle_->size() << std::endl; assert(triggerResultsHandle_->size()==hltConfig_.size()); const unsigned int n(hltConfig_.size()); std::vector<std::string> activeHLTPathsInThisEvent = hltConfig_.triggerNames(); std::map<std::string, bool> triggerInMenu; std::map<std::string, bool> triggerUnprescaled; for (std::vector<std::string>::const_iterator iHLT = activeHLTPathsInThisEvent.begin(); iHLT != activeHLTPathsInThisEvent.end(); ++iHLT) { //matching with regexp filter name. More than 1 matching filter is allowed if (TString(*iHLT).Contains(TRegexp(TString(triggerName_)))) { triggerInMenu[*iHLT] = true; const std::pair<int,int> prescales(hltConfig_.prescaleValues(iEvent,iSetup,*iHLT)); if (prescales.first * prescales.second == 1) triggerUnprescaled[*iHLT] = true; } } for (std::map<std::string, bool>::const_iterator iMyHLT = triggerInMenu.begin(); iMyHLT != triggerInMenu.end(); ++iMyHLT) { //using only unprescaled triggers if (!(iMyHLT->second && triggerUnprescaled[iMyHLT->first])) continue; const unsigned int triggerIndex(hltConfig_.triggerIndex(iMyHLT->first)); assert(triggerIndex==iEvent.triggerNames(*triggerResultsHandle_).triggerIndex(iMyHLT->first)); // abort on invalid trigger name if (triggerIndex>=n) { edm::LogError( "CandidateTriggerObjectProducer" ) << "CandidateTriggerObjectProducer::analyzeTrigger: path " << triggerName_ << " - not found!" ; return; } // modules on this trigger path const unsigned int m(hltConfig_.size(triggerIndex)); const std::vector<std::string>& moduleLabels(hltConfig_.moduleLabels(triggerIndex)); // Results from TriggerResults product if (!(triggerResultsHandle_->wasrun(triggerIndex)) || !(triggerResultsHandle_->accept(triggerIndex)) || (triggerResultsHandle_->error(triggerIndex))) { continue; } const unsigned int moduleIndex(triggerResultsHandle_->index(triggerIndex)); assert (moduleIndex<m); // Results from TriggerEvent product - Looking only on last filter since trigger is accepted const std::string& moduleLabel(moduleLabels[moduleIndex-1]); const std::string moduleType(hltConfig_.moduleType(moduleLabel)); // check whether the module is packed up in TriggerEvent product const unsigned int filterIndex(triggerEventHandle_->filterIndex(InputTag(moduleLabel,"",triggerEventTag_.process()))); if (filterIndex<triggerEventHandle_->sizeFilters()) { // cout << " 'L3' filter in slot " << moduleIndex-1 << " - label/type " << moduleLabel << "/" << moduleType << endl; const Vids& VIDS (triggerEventHandle_->filterIds(filterIndex)); const Keys& KEYS(triggerEventHandle_->filterKeys(filterIndex)); const size_type nI(VIDS.size()); const size_type nK(KEYS.size()); assert(nI==nK); const size_type n(std::max(nI,nK)); // cout << " " << n << " accepted 'L3' objects found: " << endl; const TriggerObjectCollection& TOC(triggerEventHandle_->getObjects()); for (size_type i=0; i!=n; ++i) { const TriggerObject& TO(TOC[KEYS[i]]); coll->push_back(reco::LeafCandidate( 0, TO.particle().p4(), reco::Particle::Point( 0., 0., 0. ), TO.id() )); // cout << " " << i << " " << VIDS[i] << "/" << KEYS[i] << ": " // << TO.id() << " " << TO.pt() << " " << TO.eta() << " " << TO.phi() << " " << TO.mass() // << endl; } } } iEvent.put(coll); return; }
Definition at line 46 of file CandidateTriggerObjectProducer.h.
Referenced by beginRun(), and produce().
Definition at line 45 of file CandidateTriggerObjectProducer.h.
Referenced by produce().
Definition at line 40 of file CandidateTriggerObjectProducer.h.
Referenced by beginRun(), and produce().
std::string CandidateTriggerObjectProducer::triggerName_ [private] |
Definition at line 41 of file CandidateTriggerObjectProducer.h.
Referenced by produce().
additional class data memebers
Definition at line 44 of file CandidateTriggerObjectProducer.h.
Referenced by produce().
module config parameters
Definition at line 36 of file CandidateTriggerObjectProducer.h.
Referenced by produce().