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::stream::EDProducer<>

Public Member Functions

 CandidateTriggerObjectProducer (const edm::ParameterSet &)
 
 ~CandidateTriggerObjectProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

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

Private Attributes

HLTPrescaleProvider hltPrescaleProvider_
 additional class data memebers More...
 
const std::string processName_
 
const edm::EDGetTokenT< trigger::TriggerEventtriggerEventToken_
 
const std::string triggerName_
 
const edm::EDGetTokenT< edm::TriggerResultstriggerResultsToken_
 module config parameters More...
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

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  triggerEventToken_(consumes<trigger::TriggerEvent>(ps.getParameter<edm::InputTag>("triggerEvent"))),
22  processName_(ps.getParameter<edm::InputTag>("triggerEvent").process()),
23  triggerName_(ps.getParameter<std::string>("triggerName")),
24  hltPrescaleProvider_(ps, consumesCollector(), *this) {
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

◆ beginRun()

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

Definition at line 37 of file CandidateTriggerObjectProducer.cc.

37  {
38  using namespace edm;
39 
40  bool changed(false);
41  if (!hltPrescaleProvider_.init(iRun, iSetup, processName_, 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(), and processName_.

◆ produce()

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

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

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_FULL_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(), processName_, edm::HLTGlobalStatus::size(), AlCaHLTBitMon_QueryRunRegistry::string, triggerEventToken_, triggerName_, triggerResultsToken_, and edm::HLTGlobalStatus::wasrun().

Member Data Documentation

◆ hltPrescaleProvider_

HLTPrescaleProvider CandidateTriggerObjectProducer::hltPrescaleProvider_
private

additional class data memebers

Definition at line 39 of file CandidateTriggerObjectProducer.h.

Referenced by beginRun(), and produce().

◆ processName_

const std::string CandidateTriggerObjectProducer::processName_
private

Definition at line 35 of file CandidateTriggerObjectProducer.h.

Referenced by beginRun(), and produce().

◆ triggerEventToken_

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

Definition at line 34 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

◆ triggerName_

const std::string CandidateTriggerObjectProducer::triggerName_
private

Definition at line 36 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

◆ triggerResultsToken_

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

module config parameters

Definition at line 33 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

TriggerObject
Definition: TriggerObject.py:1
mps_fire.i
i
Definition: mps_fire.py:428
CandidateTriggerObjectProducer::triggerName_
const std::string triggerName_
Definition: CandidateTriggerObjectProducer.h:36
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
HLTPrescaleProvider::hltConfigProvider
HLTConfigProvider const & hltConfigProvider() const
Definition: HLTPrescaleProvider.h:52
edm
HLT enums.
Definition: AlignableModifier.h:19
HLTPrescaleProvider::prescaleValues
std::pair< TL1, THLT > 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.h:72
edm::HLTGlobalStatus::wasrun
bool wasrun() const
Was at least one path run?
Definition: HLTGlobalStatus.h:47
cms::cuda::assert
assert(be >=bs)
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
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
edm::Handle< edm::TriggerResults >
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::triggerEventToken_
const edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
Definition: CandidateTriggerObjectProducer.h:34
CandidateTriggerObjectProducer::triggerResultsToken_
const edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
module config parameters
Definition: CandidateTriggerObjectProducer.h:33
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
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
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
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CandidateTriggerObjectProducer::hltPrescaleProvider_
HLTPrescaleProvider hltPrescaleProvider_
additional class data memebers
Definition: CandidateTriggerObjectProducer.h:39
trigger::TriggerEvent::filterIds
const Vids & filterIds(trigger::size_type index) const
Definition: TriggerEvent.h:117
CandidateTriggerObjectProducer::processName_
const std::string processName_
Definition: CandidateTriggerObjectProducer.h:35
HLTConfigProvider
Definition: HLTConfigProvider.h:29
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:245
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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
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