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 ()
 
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
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) 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_
 
std::string triggerName_
 
edm::Handle< edm::TriggerResultstriggerResultsHandle_
 additional class data memebers More...
 
edm::InputTag triggerResultsTag_
 module config parameters More...
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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

Date:
2013/02/28 00:22:50
Revision:
1.2
Author
Paolo Meridiani

Definition at line 26 of file CandidateTriggerObjectProducer.h.

Constructor & Destructor Documentation

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

Definition at line 15 of file CandidateTriggerObjectProducer.cc.

15  :
16  triggerResultsTag_(ps.getParameter<edm::InputTag>("triggerResults")),
17  triggerEventTag_(ps.getParameter<edm::InputTag>("triggerEvent")),
18  triggerName_(ps.getParameter<std::string>("triggerName"))
19 {
20  using namespace edm;
21 
22 // cout << "Trigger Object Producer:" << endl
23 // << " TriggerResultsTag = " << triggerResultsTag_.encode() << endl
24 // << " TriggerEventTag = " << triggerEventTag_.encode() << endl;
25 
26  produces<reco::CandidateCollection>();
27 
28 }
T getParameter(std::string const &) const
edm::InputTag triggerResultsTag_
module config parameters
CandidateTriggerObjectProducer::~CandidateTriggerObjectProducer ( )

Definition at line 30 of file CandidateTriggerObjectProducer.cc.

31 {
32 }

Member Function Documentation

virtual void CandidateTriggerObjectProducer::beginJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 34 of file CandidateTriggerObjectProducer.h.

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

Reimplemented from edm::EDProducer.

Definition at line 38 of file CandidateTriggerObjectProducer.cc.

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

39 {
40  using namespace edm;
41 
42  bool changed(false);
43  if(!hltConfig_.init(iRun,iSetup,triggerEventTag_.process(),changed) ){
44  edm::LogError( "CandidateTriggerObjectProducer" ) <<
45  "Error! Can't initialize HLTConfigProvider";
46  throw cms::Exception("HLTConfigProvider::init() returned non 0");
47  }
48 
49  return;
50 
51 }
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 36 of file CandidateTriggerObjectProducer.h.

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

Implements edm::EDProducer.

Definition at line 55 of file CandidateTriggerObjectProducer.cc.

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

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

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

Referenced by beginRun(), and produce().

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

Definition at line 45 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

edm::InputTag CandidateTriggerObjectProducer::triggerEventTag_
private

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().

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

additional class data memebers

Definition at line 44 of file CandidateTriggerObjectProducer.h.

Referenced by produce().

edm::InputTag CandidateTriggerObjectProducer::triggerResultsTag_
private

module config parameters

Definition at line 36 of file CandidateTriggerObjectProducer.h.

Referenced by produce().