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
pat::PATPFParticleProducer Class Reference

Produces pat::PFParticle's. More...

#include "PhysicsTools/PatAlgos/interface/PATPFParticleProducer.h"

Inheritance diagram for pat::PATPFParticleProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATPFParticleProducer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PATPFParticleProducer ()
 
- 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

void fetchCandidateCollection (edm::Handle< edm::View< reco::PFCandidate > > &c, const edm::InputTag &tag, const edm::Event &iSetup) const
 

Private Attributes

bool addEfficiencies_
 
bool addGenMatch_
 
bool addResolutions_
 
pat::helper::EfficiencyLoader efficiencyLoader_
 
bool embedGenMatch_
 
bool embedPFCandidate_
 
std::vector< edm::InputTaggenMatchSrc_
 
edm::InputTag pfCandidateSrc_
 
GreaterByPt< PFParticlepTComparator_
 
pat::helper::KinResolutionsLoader resolutionLoader_
 
pat::PATUserDataHelper
< pat::PFParticle
userDataHelper_
 
bool useUserData_
 

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

Produces pat::PFParticle's.

The PATPFParticleProducer produces analysis-level pat::PFParticle's starting from a collection of objects of reco::PFCandidate.

Author
Steven Lowette, Roger Wolf
Version
Id:
PATPFParticleProducer.h,v 1.9 2013/02/27 23:26:56 wmtan Exp

Definition at line 44 of file PATPFParticleProducer.h.

Constructor & Destructor Documentation

PATPFParticleProducer::PATPFParticleProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 26 of file PATPFParticleProducer.cc.

References addEfficiencies_, addGenMatch_, addResolutions_, efficiencyLoader_, embedGenMatch_, edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), genMatchSrc_, edm::ParameterSet::getParameter(), pfCandidateSrc_, resolutionLoader_, and useUserData_.

26  :
27  userDataHelper_ ( iConfig.getParameter<edm::ParameterSet>("userData") )
28 {
29  // general configurables
30  pfCandidateSrc_ = iConfig.getParameter<edm::InputTag>( "pfCandidateSource" );
31 
32  // MC matching configurables
33  addGenMatch_ = iConfig.getParameter<bool> ( "addGenMatch" );
34  if (addGenMatch_) {
35  embedGenMatch_ = iConfig.getParameter<bool> ( "embedGenMatch" );
36  if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
37  genMatchSrc_.push_back(iConfig.getParameter<edm::InputTag>( "genParticleMatch" ));
38  } else {
39  genMatchSrc_ = iConfig.getParameter<std::vector<edm::InputTag> >( "genParticleMatch" );
40  }
41  }
42 
43  // Efficiency configurables
44  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
45  if (addEfficiencies_) {
47  }
48 
49  // Resolution configurables
50  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
51  if (addResolutions_) {
53  }
54 
55  // Check to see if the user wants to add user data
56  useUserData_ = false;
57  if ( iConfig.exists("userData") ) {
58  useUserData_ = true;
59  }
60 
61  // produces vector of muons
62  produces<std::vector<PFParticle> >();
63 
64 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:187
pat::helper::KinResolutionsLoader resolutionLoader_
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< edm::InputTag > genMatchSrc_
pat::helper::EfficiencyLoader efficiencyLoader_
pat::PATUserDataHelper< pat::PFParticle > userDataHelper_
PATPFParticleProducer::~PATPFParticleProducer ( )

Definition at line 67 of file PATPFParticleProducer.cc.

67  {
68 }

Member Function Documentation

void PATPFParticleProducer::fetchCandidateCollection ( edm::Handle< edm::View< reco::PFCandidate > > &  c,
const edm::InputTag tag,
const edm::Event iSetup 
) const
private

Definition at line 140 of file PATPFParticleProducer.cc.

References trackerHits::c, edm::hlt::Exception, newFWLiteAna::found, and edm::Event::getByLabel().

Referenced by produce().

142  {
143 
144  bool found = iEvent.getByLabel(tag, c);
145 
146  if(!found ) {
147  std::ostringstream err;
148  err<<" cannot get PFCandidates: "
149  <<tag<<std::endl;
150  edm::LogError("PFCandidates")<<err.str();
151  throw cms::Exception( "MissingProduct", err.str());
152  }
153 
154 }
int iEvent
Definition: GenABIO.cc:243
void PATPFParticleProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 71 of file PATPFParticleProducer.cc.

References addGenMatch_, pat::PATObject< ObjectType >::addGenParticleRef(), efficiencyLoader_, embedGenMatch_, pat::PATObject< ObjectType >::embedGenParticle(), pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), fetchCandidateCollection(), genMatchSrc_, edm::Event::getByLabel(), i, customizeTrackingMonitorSeedNumber::idx, j, n, pat::helper::EfficiencyLoader::newEvent(), pat::helper::KinResolutionsLoader::newEvent(), pfParticleProducer_cfi::patPFParticles, reco::tau::pfCandidates(), pfCandidateSrc_, pTComparator_, edm::Event::put(), resolutionLoader_, pat::helper::EfficiencyLoader::setEfficiencies(), pat::helper::KinResolutionsLoader::setResolutions(), python.multivaluedict::sort(), userDataHelper_, and useUserData_.

72  {
73 
74  // Get the collection of PFCandidates from the event
76 
77  fetchCandidateCollection(pfCandidates,
79  iEvent );
80 
81  // prepare the MC matching
82  std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > > genMatches(genMatchSrc_.size());
83  if (addGenMatch_) {
84  for (size_t j = 0, nd = genMatchSrc_.size(); j < nd; ++j) {
85  iEvent.getByLabel(genMatchSrc_[j], genMatches[j]);
86  }
87  }
88 
90  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
91 
92  // loop over PFCandidates
93  std::vector<PFParticle> * patPFParticles = new std::vector<PFParticle>();
95  itPFParticle = pfCandidates->begin();
96  itPFParticle != pfCandidates->end();
97  ++itPFParticle) {
98 
99  // construct the PFParticle from the ref -> save ref to original object
100  unsigned int idx = itPFParticle - pfCandidates->begin();
101  edm::RefToBase<reco::PFCandidate> pfCandidatesRef = pfCandidates->refAt(idx);
102 
103  PFParticle aPFParticle(pfCandidatesRef);
104 
105  if (addGenMatch_) {
106  for(size_t i = 0, n = genMatches.size(); i < n; ++i) {
107  reco::GenParticleRef genPFParticle = (*genMatches[i])[pfCandidatesRef];
108  aPFParticle.addGenParticleRef(genPFParticle);
109  }
110  if (embedGenMatch_) aPFParticle.embedGenParticle();
111  }
112 
113  if (efficiencyLoader_.enabled()) {
114  efficiencyLoader_.setEfficiencies( aPFParticle, pfCandidatesRef );
115  }
116 
117  if (resolutionLoader_.enabled()) {
118  resolutionLoader_.setResolutions(aPFParticle);
119  }
120 
121  if ( useUserData_ ) {
122  userDataHelper_.add( aPFParticle, iEvent, iSetup );
123  }
124 
125 
126  // add sel to selected
127  patPFParticles->push_back(aPFParticle);
128  }
129 
130  // sort pfCandidates in pt
131  std::sort(patPFParticles->begin(), patPFParticles->end(), pTComparator_);
132 
133  // put genEvt object in Event
134  std::auto_ptr<std::vector<PFParticle> > ptr(patPFParticles);
135  iEvent.put(ptr);
136 
137 }
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
pat::helper::KinResolutionsLoader resolutionLoader_
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
std::vector< edm::InputTag > genMatchSrc_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
pat::helper::EfficiencyLoader efficiencyLoader_
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
Analysis-level class for reconstructed particles.
Definition: PFParticle.h:37
pat::PATUserDataHelper< pat::PFParticle > userDataHelper_
void fetchCandidateCollection(edm::Handle< edm::View< reco::PFCandidate > > &c, const edm::InputTag &tag, const edm::Event &iSetup) const
void newEvent(const edm::Event &event, const edm::EventSetup &setup) const
To be called for each new event, reads in the EventSetup object.
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.
GreaterByPt< PFParticle > pTComparator_

Member Data Documentation

bool pat::PATPFParticleProducer::addEfficiencies_
private

Definition at line 68 of file PATPFParticleProducer.h.

Referenced by PATPFParticleProducer().

bool pat::PATPFParticleProducer::addGenMatch_
private

Definition at line 62 of file PATPFParticleProducer.h.

Referenced by PATPFParticleProducer(), and produce().

bool pat::PATPFParticleProducer::addResolutions_
private

Definition at line 71 of file PATPFParticleProducer.h.

Referenced by PATPFParticleProducer().

pat::helper::EfficiencyLoader pat::PATPFParticleProducer::efficiencyLoader_
private

Definition at line 69 of file PATPFParticleProducer.h.

Referenced by PATPFParticleProducer(), and produce().

bool pat::PATPFParticleProducer::embedGenMatch_
private

Definition at line 63 of file PATPFParticleProducer.h.

Referenced by PATPFParticleProducer(), and produce().

bool pat::PATPFParticleProducer::embedPFCandidate_
private

Definition at line 61 of file PATPFParticleProducer.h.

std::vector<edm::InputTag> pat::PATPFParticleProducer::genMatchSrc_
private

Definition at line 64 of file PATPFParticleProducer.h.

Referenced by PATPFParticleProducer(), and produce().

edm::InputTag pat::PATPFParticleProducer::pfCandidateSrc_
private

Definition at line 60 of file PATPFParticleProducer.h.

Referenced by PATPFParticleProducer(), and produce().

GreaterByPt<PFParticle> pat::PATPFParticleProducer::pTComparator_
private

Definition at line 66 of file PATPFParticleProducer.h.

Referenced by produce().

pat::helper::KinResolutionsLoader pat::PATPFParticleProducer::resolutionLoader_
private

Definition at line 72 of file PATPFParticleProducer.h.

Referenced by PATPFParticleProducer(), and produce().

pat::PATUserDataHelper<pat::PFParticle> pat::PATPFParticleProducer::userDataHelper_
private

Definition at line 75 of file PATPFParticleProducer.h.

Referenced by produce().

bool pat::PATPFParticleProducer::useUserData_
private

Definition at line 74 of file PATPFParticleProducer.h.

Referenced by PATPFParticleProducer(), and produce().