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
 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 (const std::string &iProcessName, std::vector< const char * > &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

HLTConfigProvider hltConfig_
 
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
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 19 of file CandidateTriggerObjectProducer.cc.

19  :
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"))
24 {
25 
26 // cout << "Trigger Object Producer:" << endl
27 // << " TriggerResultsTag = " << triggerResultsTag_.encode() << endl
28 // << " TriggerEventTag = " << triggerEventTag_.encode() << endl;
29 
30  produces<reco::CandidateCollection>();
31 
32 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
CandidateTriggerObjectProducer::~CandidateTriggerObjectProducer ( )

Definition at line 34 of file CandidateTriggerObjectProducer.cc.

35 {
36 }

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 42 of file CandidateTriggerObjectProducer.cc.

References Exception, hltConfig_, HLTConfigProvider::init(), edm::InputTag::process(), and triggerEventTag_.

43 {
44  using namespace edm;
45 
46  bool changed(false);
47  if(!hltConfig_.init(iRun,iSetup,triggerEventTag_.process(),changed) ){
48  edm::LogError( "CandidateTriggerObjectProducer" ) <<
49  "Error! Can't initialize HLTConfigProvider";
50  throw cms::Exception("HLTConfigProvider::init() returned non 0");
51  }
52 
53  return;
54 
55 }
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
std::string const & process() const
Definition: InputTag.h:46
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 59 of file CandidateTriggerObjectProducer.cc.

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

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

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

Member Data Documentation

HLTConfigProvider CandidateTriggerObjectProducer::hltConfig_
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().