CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

HLTPrescaleProvider hltPrescaleProvider_
 
edm::Handle
< trigger::TriggerEvent
triggerEventHandle_
 
edm::InputTag triggerEventTag_
 
edm::EDGetTokenT
< trigger::TriggerEvent
triggerEventToken_
 
std::string triggerName_
 
edm::Handle< edm::TriggerResultstriggerResultsHandle_
 additional class data memebers More...
 
edm::InputTag triggerResultsTag_
 module config parameters More...
 
edm::EDGetTokenT
< edm::TriggerResults
triggerResultsToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
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)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, 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 ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, 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 ( const edm::ParameterSet ps)
explicit

Definition at line 20 of file CandidateTriggerObjectProducer.cc.

20  :
21  triggerResultsToken_(consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("triggerResults"))),
22  triggerEventTag_(ps.getParameter<edm::InputTag>("triggerEvent")),
23  triggerEventToken_(consumes<trigger::TriggerEvent>(triggerEventTag_)),
24  triggerName_(ps.getParameter<std::string>("triggerName")),
26 {
27 
28 // cout << "Trigger Object Producer:" << endl
29 // << " TriggerResultsTag = " << triggerResultsTag_.encode() << endl
30 // << " TriggerEventTag = " << triggerEventTag_.encode() << endl;
31 
32  produces<reco::CandidateCollection>();
33 
34 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
CandidateTriggerObjectProducer::~CandidateTriggerObjectProducer ( )

Definition at line 36 of file CandidateTriggerObjectProducer.cc.

37 {
38 }

Member Function Documentation

virtual void CandidateTriggerObjectProducer::beginJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 31 of file CandidateTriggerObjectProducer.h.

31 {} ;
void CandidateTriggerObjectProducer::beginRun ( const edm::Run iRun,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 44 of file CandidateTriggerObjectProducer.cc.

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

45 {
46  using namespace edm;
47 
48  bool changed(false);
49  if(!hltPrescaleProvider_.init(iRun,iSetup,triggerEventTag_.process(),changed) ){
50  edm::LogError( "CandidateTriggerObjectProducer" ) <<
51  "Error! Can't initialize HLTConfigProvider";
52  throw cms::Exception("HLTConfigProvider::init() returned non 0");
53  }
54 
55  return;
56 
57 }
std::string const & process() const
Definition: InputTag.h:40
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
virtual void CandidateTriggerObjectProducer::endJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 33 of file CandidateTriggerObjectProducer.h.

33 {} ;
void CandidateTriggerObjectProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 61 of file CandidateTriggerObjectProducer.cc.

References assert(), coll, edm::Event::getByToken(), HltComparatorCreateWorkflow::hltConfig, HLTPrescaleProvider::hltConfigProvider(), hltPrescaleProvider_, i, trigger::TriggerObject::id(), edm::HandleBase::isValid(), bookConverter::max, gen::n, reco::Particle::p4(), trigger::TriggerObject::particle(), makeHLTPrescaleTable::prescales, HLTPrescaleProvider::prescaleValues(), edm::InputTag::process(), edm::Event::put(), dt_dqm_sourceclient_common_cff::reco, AlCaHLTBitMon_QueryRunRegistry::string, triggerEventHandle_, triggerEventTag_, triggerEventToken_, edm::TriggerNames::triggerIndex(), triggerName_, edm::Event::triggerNames(), triggerResultsHandle_, and triggerResultsToken_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

62 {
63  using namespace edm;
64  using namespace reco;
65  using namespace trigger;
66 
67  std::auto_ptr<reco::CandidateCollection> coll( new reco::CandidateCollection );
68 
69  // get event products
72  edm::LogError( "CandidateTriggerObjectProducer" ) << "CandidateTriggerObjectProducer::analyze: Error in getting TriggerResults product from Event!" ;
73  return;
74  }
77  edm::LogError( "CandidateTriggerObjectProducer" ) << "CandidateTriggerObjectProducer::analyze: Error in getting TriggerEvent product from Event!" ;
78  return;
79  }
80 
82 
83  // sanity check
84  // std::cout << hltConfig.size() << std::endl;
85  // std::cout << triggerResultsHandle_->size() << std::endl;
86  assert(triggerResultsHandle_->size()==hltConfig.size());
87 
88  const unsigned int n(hltConfig.size());
89  std::vector<std::string> activeHLTPathsInThisEvent = hltConfig.triggerNames();
90  std::map<std::string, bool> triggerInMenu;
91  std::map<std::string, bool> triggerUnprescaled;
92 
93  for (std::vector<std::string>::const_iterator iHLT = activeHLTPathsInThisEvent.begin();
94  iHLT != activeHLTPathsInThisEvent.end(); ++iHLT)
95  {
96  //matching with regexp filter name. More than 1 matching filter is allowed
97  if (TString(*iHLT).Contains(TRegexp(TString(triggerName_))))
98  {
99  triggerInMenu[*iHLT] = true;
100  const std::pair<int,int> prescales(hltPrescaleProvider_.prescaleValues(iEvent,iSetup,*iHLT));
101  if (prescales.first * prescales.second == 1)
102  triggerUnprescaled[*iHLT] = true;
103  }
104  }
105 
106  for (std::map<std::string, bool>::const_iterator iMyHLT = triggerInMenu.begin();
107  iMyHLT != triggerInMenu.end(); ++iMyHLT)
108  {
109  //using only unprescaled triggers
110  if (!(iMyHLT->second && triggerUnprescaled[iMyHLT->first]))
111  continue;
112  const unsigned int triggerIndex(hltConfig.triggerIndex(iMyHLT->first));
113 
114  assert(triggerIndex==iEvent.triggerNames(*triggerResultsHandle_).triggerIndex(iMyHLT->first));
115 
116  // abort on invalid trigger name
117  if (triggerIndex>=n) {
118  edm::LogError( "CandidateTriggerObjectProducer" ) << "CandidateTriggerObjectProducer::analyzeTrigger: path "
119  << triggerName_ << " - not found!" ;
120  return;
121  }
122 
123  // modules on this trigger path
124  // const unsigned int m(hltConfig.size(triggerIndex));
125  const std::vector<std::string>& moduleLabels(hltConfig.saveTagsModules(triggerIndex));
126 
127  // Results from TriggerResults product
128  if (!(triggerResultsHandle_->wasrun(triggerIndex)) ||
129  !(triggerResultsHandle_->accept(triggerIndex)) ||
130  (triggerResultsHandle_->error(triggerIndex)))
131  {
132  continue;
133  }
134 
135 // const unsigned int moduleIndex(triggerResultsHandle_->index(triggerIndex));
136 
137 // assert (moduleIndex<m);
138 
139  // Results from TriggerEvent product - Looking only on last filter since trigger is accepted
140  for (unsigned int imodule=0;imodule<moduleLabels.size();++imodule)
141  {
142  const std::string& moduleLabel(moduleLabels[imodule]);
143  const std::string moduleType(hltConfig.moduleType(moduleLabel));
144  //Avoiding L1 seeds
145  if (moduleType.find("Level1GTSeed") != std::string::npos)
146  continue;
147  // check whether the module is packed up in TriggerEvent product
148  const unsigned int filterIndex(triggerEventHandle_->filterIndex(InputTag(moduleLabel,"",triggerEventTag_.process())));
149  if (filterIndex<triggerEventHandle_->sizeFilters()) {
150  // std::cout << " 'L3' filter in slot " << imodule << " - label/type " << moduleLabel << "/" << moduleType << std::endl;
151  const Vids& VIDS (triggerEventHandle_->filterIds(filterIndex));
152  const Keys& KEYS(triggerEventHandle_->filterKeys(filterIndex));
153  const size_type nI(VIDS.size());
154  const size_type nK(KEYS.size());
155  assert(nI==nK);
156  const size_type n(std::max(nI,nK));
157  // std::cout << " " << n << " accepted 'L3' objects found: " << std::endl;
158  const TriggerObjectCollection& TOC(triggerEventHandle_->getObjects());
159  for (size_type i=0; i!=n; ++i) {
160  const TriggerObject& TO(TOC[KEYS[i]]);
161  coll->push_back(reco::LeafCandidate( 0, TO.particle().p4(), reco::Particle::Point( 0., 0., 0. ), TO.id() ));
162 // std::cout << " " << i << " " << VIDS[i] << "/" << KEYS[i] << ": "
163 // << TO.id() << " " << TO.pt() << " " << TO.eta() << " " << TO.phi() << " " << TO.mass()
164 // << std::endl;
165  }
166  }
167  }
168  }
169 
170 
171  iEvent.put(coll);
172  return;
173 }
int i
Definition: DBlmapReader.cc:9
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:215
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void push_back(key_type i, value_type const &j, label_type const &flav="")
assert(m_qm.get())
edm::Handle< edm::TriggerResults > triggerResultsHandle_
additional class data memebers
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
uint16_t size_type
edm::Handle< trigger::TriggerEvent > triggerEventHandle_
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:22
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
math::XYZPoint Point
point in the space
Definition: Particle.h:25
bool isValid() const
Definition: HandleBase.h:75
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
JetCorrectorParametersCollection coll
Definition: classes.h:10
std::vector< size_type > Keys
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.
HLTConfigProvider const & hltConfigProvider() const
std::string const & process() const
Definition: InputTag.h:40
std::vector< int > Vids

Member Data Documentation

HLTPrescaleProvider CandidateTriggerObjectProducer::hltPrescaleProvider_
private

Definition at line 45 of file CandidateTriggerObjectProducer.h.

Referenced by beginRun(), and produce().

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

Definition at line 44 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

edm::InputTag CandidateTriggerObjectProducer::triggerEventTag_
private

Definition at line 38 of file CandidateTriggerObjectProducer.h.

Referenced by beginRun(), and produce().

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

Definition at line 39 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

std::string CandidateTriggerObjectProducer::triggerName_
private

Definition at line 40 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

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

additional class data memebers

Definition at line 43 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

edm::InputTag CandidateTriggerObjectProducer::triggerResultsTag_
private

module config parameters

Definition at line 33 of file CandidateTriggerObjectProducer.h.

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

Definition at line 37 of file CandidateTriggerObjectProducer.h.

Referenced by produce().