CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CandidateTriggerObjectProducer Class Reference

#include <CandidateTriggerObjectProducer.h>

Inheritance diagram for CandidateTriggerObjectProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CandidateTriggerObjectProducer (const edm::ParameterSet &)
 
 ~CandidateTriggerObjectProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginJob () override
 
void beginRun (const edm::Run &iRun, edm::EventSetup const &iSetup) override
 
void endJob () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

HLTPrescaleProvider hltPrescaleProvider_
 
edm::Handle< trigger::TriggerEventtriggerEventHandle_
 
edm::InputTag triggerEventTag_
 
edm::EDGetTokenT< trigger::TriggerEventtriggerEventToken_
 
std::string triggerName_
 
edm::Handle< edm::TriggerResultstriggerResultsHandle_
 additional class data memebers More...
 
edm::InputTag triggerResultsTag_
 module config parameters More...
 
edm::EDGetTokenT< edm::TriggerResultstriggerResultsToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

This class creates a list of candidates based on the last accepted filter

Author
Paolo Meridiani

Definition at line 23 of file CandidateTriggerObjectProducer.h.

Constructor & Destructor Documentation

◆ CandidateTriggerObjectProducer()

CandidateTriggerObjectProducer::CandidateTriggerObjectProducer ( const edm::ParameterSet ps)
explicit

Definition at line 19 of file CandidateTriggerObjectProducer.cc.

20  : triggerResultsToken_(consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("triggerResults"))),
21  triggerEventTag_(ps.getParameter<edm::InputTag>("triggerEvent")),
22  triggerEventToken_(consumes<trigger::TriggerEvent>(triggerEventTag_)),
23  triggerName_(ps.getParameter<std::string>("triggerName")),
25  // cout << "Trigger Object Producer:" << endl
26  // << " TriggerResultsTag = " << triggerResultsTag_.encode() << endl
27  // << " TriggerEventTag = " << triggerEventTag_.encode() << endl;
28 
29  produces<reco::CandidateCollection>();
30 }

◆ ~CandidateTriggerObjectProducer()

CandidateTriggerObjectProducer::~CandidateTriggerObjectProducer ( )
override

Definition at line 32 of file CandidateTriggerObjectProducer.cc.

32 {}

Member Function Documentation

◆ beginJob()

void CandidateTriggerObjectProducer::beginJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 30 of file CandidateTriggerObjectProducer.h.

30 {};

◆ beginRun()

void CandidateTriggerObjectProducer::beginRun ( const edm::Run iRun,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 37 of file CandidateTriggerObjectProducer.cc.

37  {
38  using namespace edm;
39 
40  bool changed(false);
41  if (!hltPrescaleProvider_.init(iRun, iSetup, triggerEventTag_.process(), changed)) {
42  edm::LogError("CandidateTriggerObjectProducer") << "Error! Can't initialize HLTConfigProvider";
43  throw cms::Exception("HLTConfigProvider::init() returned non 0");
44  }
45 
46  return;
47 }

References Exception, hltPrescaleProvider_, HLTPrescaleProvider::init(), edm::InputTag::process(), and triggerEventTag_.

◆ endJob()

void CandidateTriggerObjectProducer::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 32 of file CandidateTriggerObjectProducer.h.

32 {};

Referenced by o2olib.O2ORunMgr::executeJob().

◆ produce()

void CandidateTriggerObjectProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 50 of file CandidateTriggerObjectProducer.cc.

50  {
51  using namespace edm;
52  using namespace reco;
53  using namespace trigger;
54 
55  std::unique_ptr<reco::CandidateCollection> coll(new reco::CandidateCollection);
56 
57  // get event products
60  edm::LogError("CandidateTriggerObjectProducer")
61  << "CandidateTriggerObjectProducer::analyze: Error in getting TriggerResults product from Event!";
62  return;
63  }
66  edm::LogError("CandidateTriggerObjectProducer")
67  << "CandidateTriggerObjectProducer::analyze: Error in getting TriggerEvent product from Event!";
68  return;
69  }
70 
72 
73  // sanity check
74  // std::cout << hltConfig.size() << std::endl;
75  // std::cout << triggerResultsHandle_->size() << std::endl;
77 
78  const unsigned int n(hltConfig.size());
79  std::vector<std::string> activeHLTPathsInThisEvent = hltConfig.triggerNames();
80  std::map<std::string, bool> triggerInMenu;
81  std::map<std::string, bool> triggerUnprescaled;
82 
83  for (std::vector<std::string>::const_iterator iHLT = activeHLTPathsInThisEvent.begin();
84  iHLT != activeHLTPathsInThisEvent.end();
85  ++iHLT) {
86  //matching with regexp filter name. More than 1 matching filter is allowed
87  if (TString(*iHLT).Contains(TRegexp(TString(triggerName_)))) {
88  triggerInMenu[*iHLT] = true;
89  const std::pair<int, int> prescales(hltPrescaleProvider_.prescaleValues(iEvent, iSetup, *iHLT));
90  if (prescales.first * prescales.second == 1)
91  triggerUnprescaled[*iHLT] = true;
92  }
93  }
94 
95  for (std::map<std::string, bool>::const_iterator iMyHLT = triggerInMenu.begin(); iMyHLT != triggerInMenu.end();
96  ++iMyHLT) {
97  //using only unprescaled triggers
98  if (!(iMyHLT->second && triggerUnprescaled[iMyHLT->first]))
99  continue;
100  const unsigned int triggerIndex(hltConfig.triggerIndex(iMyHLT->first));
101 
102  assert(triggerIndex == iEvent.triggerNames(*triggerResultsHandle_).triggerIndex(iMyHLT->first));
103 
104  // abort on invalid trigger name
105  if (triggerIndex >= n) {
106  edm::LogError("CandidateTriggerObjectProducer")
107  << "CandidateTriggerObjectProducer::analyzeTrigger: path " << triggerName_ << " - not found!";
108  return;
109  }
110 
111  // modules on this trigger path
112  // const unsigned int m(hltConfig.size(triggerIndex));
113  const std::vector<std::string>& moduleLabels(hltConfig.saveTagsModules(triggerIndex));
114 
115  // Results from TriggerResults product
116  if (!(triggerResultsHandle_->wasrun(triggerIndex)) || !(triggerResultsHandle_->accept(triggerIndex)) ||
117  (triggerResultsHandle_->error(triggerIndex))) {
118  continue;
119  }
120 
121  // const unsigned int moduleIndex(triggerResultsHandle_->index(triggerIndex));
122 
123  // assert (moduleIndex<m);
124 
125  // Results from TriggerEvent product - Looking only on last filter since trigger is accepted
126  for (unsigned int imodule = 0; imodule < moduleLabels.size(); ++imodule) {
127  const std::string& moduleLabel(moduleLabels[imodule]);
128  const std::string moduleType(hltConfig.moduleType(moduleLabel));
129  //Avoiding L1 seeds
130  if (moduleType.find("Level1GTSeed") != std::string::npos)
131  continue;
132  // check whether the module is packed up in TriggerEvent product
133  const unsigned int filterIndex(
135  if (filterIndex < triggerEventHandle_->sizeFilters()) {
136  // std::cout << " 'L3' filter in slot " << imodule
137  // << " - label/type " << moduleLabel << "/" << moduleType << std::endl;
138  const Vids& VIDS(triggerEventHandle_->filterIds(filterIndex));
139  const Keys& KEYS(triggerEventHandle_->filterKeys(filterIndex));
140  const size_type nI(VIDS.size());
141  const size_type nK(KEYS.size());
142  assert(nI == nK);
143  const size_type n(std::max(nI, nK));
144  // std::cout << " " << n << " accepted 'L3' objects found: " << std::endl;
146  for (size_type i = 0; i != n; ++i) {
147  const TriggerObject& TO(TOC[KEYS[i]]);
148  coll->push_back(reco::LeafCandidate(0, TO.particle().p4(), reco::Particle::Point(0., 0., 0.), TO.id()));
149  // std::cout << " " << i << " " << VIDS[i] << "/" << KEYS[i] << ": "
150  // << TO.id() << " " << TO.pt() << " " << TO.eta() << " " << TO.phi() << " " << TO.mass()
151  // << std::endl;
152  }
153  }
154  }
155  }
156 
157  iEvent.put(std::move(coll));
158  return;
159 }

References edm::HLTGlobalStatus::accept(), cms::cuda::assert(), edm::HLTGlobalStatus::error(), trigger::TriggerEvent::filterIds(), trigger::TriggerEvent::filterIndex(), trigger::TriggerEvent::filterKeys(), trigger::TriggerEvent::getObjects(), HltComparatorCreateWorkflow::hltConfig, HLTPrescaleProvider::hltConfigProvider(), hltPrescaleProvider_, mps_fire::i, trigger::TriggerObject::id(), iEvent, HLT_2018_cff::InputTag, edm::HandleBase::isValid(), SiStripPI::max, HerwigMaxPtPartonFilter_cfi::moduleLabel, eostools::move(), dqmiodumpmetadata::n, reco::Particle::p4(), trigger::TriggerObject::particle(), hltrates_dqm_sourceclient-live_cfg::prescales, HLTPrescaleProvider::prescaleValues(), edm::InputTag::process(), edm::HLTGlobalStatus::size(), AlCaHLTBitMon_QueryRunRegistry::string, triggerEventHandle_, triggerEventTag_, triggerEventToken_, triggerName_, triggerResultsHandle_, triggerResultsToken_, and edm::HLTGlobalStatus::wasrun().

Member Data Documentation

◆ hltPrescaleProvider_

HLTPrescaleProvider CandidateTriggerObjectProducer::hltPrescaleProvider_
private

Definition at line 44 of file CandidateTriggerObjectProducer.h.

Referenced by beginRun(), and produce().

◆ triggerEventHandle_

edm::Handle<trigger::TriggerEvent> CandidateTriggerObjectProducer::triggerEventHandle_
private

Definition at line 43 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

◆ triggerEventTag_

edm::InputTag CandidateTriggerObjectProducer::triggerEventTag_
private

Definition at line 37 of file CandidateTriggerObjectProducer.h.

Referenced by beginRun(), and produce().

◆ triggerEventToken_

edm::EDGetTokenT<trigger::TriggerEvent> CandidateTriggerObjectProducer::triggerEventToken_
private

Definition at line 38 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

◆ triggerName_

std::string CandidateTriggerObjectProducer::triggerName_
private

Definition at line 39 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

◆ triggerResultsHandle_

edm::Handle<edm::TriggerResults> CandidateTriggerObjectProducer::triggerResultsHandle_
private

additional class data memebers

Definition at line 42 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

◆ triggerResultsTag_

edm::InputTag CandidateTriggerObjectProducer::triggerResultsTag_
private

module config parameters

Definition at line 32 of file CandidateTriggerObjectProducer.h.

◆ triggerResultsToken_

edm::EDGetTokenT<edm::TriggerResults> CandidateTriggerObjectProducer::triggerResultsToken_
private

Definition at line 36 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

TriggerObject
Definition: TriggerObject.py:1
mps_fire.i
i
Definition: mps_fire.py:355
trigger::TriggerEvent::filterKeys
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:118
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
trigger::Vids
std::vector< int > Vids
Definition: TriggerTypeDefs.h:21
CandidateTriggerObjectProducer::triggerEventTag_
edm::InputTag triggerEventTag_
Definition: CandidateTriggerObjectProducer.h:37
HLTPrescaleProvider::hltConfigProvider
HLTConfigProvider const & hltConfigProvider() const
Definition: HLTPrescaleProvider.h:51
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::HLTGlobalStatus::wasrun
bool wasrun() const
Was at least one path run?
Definition: HLTGlobalStatus.h:47
cms::cuda::assert
assert(be >=bs)
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:71
edm::InputTag::process
std::string const & process() const
Definition: InputTag.h:40
edm::HLTGlobalStatus::error
bool error() const
Has any path encountered an error (exception)
Definition: HLTGlobalStatus.h:51
CandidateTriggerObjectProducer::triggerEventToken_
edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
Definition: CandidateTriggerObjectProducer.h:38
CandidateTriggerObjectProducer::triggerName_
std::string triggerName_
Definition: CandidateTriggerObjectProducer.h:39
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
edm::HLTGlobalStatus::size
unsigned int size() const
Get number of paths stored.
Definition: HLTGlobalStatus.h:35
CandidateTriggerObjectProducer::triggerEventHandle_
edm::Handle< trigger::TriggerEvent > triggerEventHandle_
Definition: CandidateTriggerObjectProducer.h:43
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogError
Definition: MessageLogger.h:183
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
hltrates_dqm_sourceclient-live_cfg.prescales
prescales
Definition: hltrates_dqm_sourceclient-live_cfg.py:90
trigger::TriggerObjectCollection
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
iEvent
int iEvent
Definition: GenABIO.cc:224
trigger::TriggerEvent::filterIndex
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:132
trigger::Keys
std::vector< size_type > Keys
Definition: TriggerTypeDefs.h:19
CandidateTriggerObjectProducer::triggerResultsHandle_
edm::Handle< edm::TriggerResults > triggerResultsHandle_
additional class data memebers
Definition: CandidateTriggerObjectProducer.h:42
trigger::TriggerEvent::getObjects
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:101
HLTPrescaleProvider::init
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
Definition: HLTPrescaleProvider.cc:21
CandidateTriggerObjectProducer::hltPrescaleProvider_
HLTPrescaleProvider hltPrescaleProvider_
Definition: CandidateTriggerObjectProducer.h:44
trigger::TriggerEvent::filterIds
const Vids & filterIds(trigger::size_type index) const
Definition: TriggerEvent.h:117
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
HLTConfigProvider
Definition: HLTConfigProvider.h:28
eostools.move
def move(src, dest)
Definition: eostools.py:511
CandidateTriggerObjectProducer::triggerResultsToken_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Definition: CandidateTriggerObjectProducer.h:36
Exception
Definition: hltDiff.cc:246
HltComparatorCreateWorkflow.hltConfig
hltConfig
Definition: HltComparatorCreateWorkflow.py:161
edm::HLTGlobalStatus::accept
bool accept() const
Has at least one path accepted the event?
Definition: HLTGlobalStatus.h:49
trigger
Definition: HLTPrescaleTableCond.h:8
reco::Particle::Point
math::XYZPoint Point
point in the space
Definition: Particle.h:25
reco::LeafCandidate
Definition: LeafCandidate.h:16
HLTPrescaleProvider::prescaleValues
std::pair< int, int > prescaleValues(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger)
Combined L1T (pair.first) and HLT (pair.second) prescales per HLT path.
Definition: HLTPrescaleProvider.cc:116
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
edm::OwnVector
Definition: OwnVector.h:24