CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
pat::PATPFParticleProducer Class Reference

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

Inheritance diagram for pat::PATPFParticleProducer:
edm::stream::EDProducer<>

Public Member Functions

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

bool addEfficiencies_
 
bool addGenMatch_
 
bool addResolutions_
 
pat::helper::EfficiencyLoader efficiencyLoader_
 
bool embedGenMatch_
 
bool embedPFCandidate_
 
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
 
edm::EDGetTokenT< edm::View< reco::PFCandidate > > pfCandidateToken_
 
GreaterByPt< PFParticlepTComparator_
 
pat::helper::KinResolutionsLoader resolutionLoader_
 
pat::PATUserDataHelper< pat::PFParticleuserDataHelper_
 
bool useUserData_
 

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

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.8 2012/05/26 10:42:53 gpetrucc Exp

Definition at line 39 of file PATPFParticleProducer.cc.

Constructor & Destructor Documentation

◆ PATPFParticleProducer()

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

Definition at line 70 of file PATPFParticleProducer.cc.

References addEfficiencies_, addGenMatch_, addResolutions_, efficiencyLoader_, embedGenMatch_, edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), genMatchTokens_, edm::ParameterSet::getParameter(), pfCandidateToken_, resolutionLoader_, makeGlobalPositionRcd_cfg::tag, useUserData_, and edm::vector_transform().

71  : userDataHelper_(iConfig.getParameter<edm::ParameterSet>("userData"), consumesCollector()) {
72  // general configurables
73  pfCandidateToken_ = consumes<edm::View<reco::PFCandidate> >(iConfig.getParameter<edm::InputTag>("pfCandidateSource"));
74 
75  // MC matching configurables
76  addGenMatch_ = iConfig.getParameter<bool>("addGenMatch");
77  if (addGenMatch_) {
78  embedGenMatch_ = iConfig.getParameter<bool>("embedGenMatch");
79  if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
81  iConfig.getParameter<edm::InputTag>("genParticleMatch")));
82  } else {
84  iConfig.getParameter<std::vector<edm::InputTag> >("genParticleMatch"),
85  [this](edm::InputTag const& tag) { return consumes<edm::Association<reco::GenParticleCollection> >(tag); });
86  }
87  }
88 
89  // Efficiency configurables
90  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
91  if (addEfficiencies_) {
93  pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"), consumesCollector());
94  }
95 
96  // Resolution configurables
97  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
98  if (addResolutions_) {
100  pat::helper::KinResolutionsLoader(iConfig.getParameter<edm::ParameterSet>("resolutions"), consumesCollector());
101  }
102 
103  // Check to see if the user wants to add user data
104  useUserData_ = false;
105  if (iConfig.exists("userData")) {
106  useUserData_ = true;
107  }
108 
109  // produces vector of muons
110  produces<std::vector<PFParticle> >();
111 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
pat::helper::KinResolutionsLoader resolutionLoader_
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:172
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
pat::helper::EfficiencyLoader efficiencyLoader_
edm::EDGetTokenT< edm::View< reco::PFCandidate > > pfCandidateToken_
pat::PATUserDataHelper< pat::PFParticle > userDataHelper_

◆ ~PATPFParticleProducer()

PATPFParticleProducer::~PATPFParticleProducer ( )
override

Definition at line 113 of file PATPFParticleProducer.cc.

113 {}

Member Function Documentation

◆ produce()

void PATPFParticleProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 115 of file PATPFParticleProducer.cc.

References pat::PATUserDataHelper< ObjectType >::add(), addGenMatch_, pat::PATObject< ObjectType >::addGenParticleRef(), efficiencyLoader_, embedGenMatch_, pat::PATObject< ObjectType >::embedGenParticle(), pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), genMatchTokens_, mps_fire::i, heavyIonCSV_trainingSettings::idx, iEvent, dqmiolumiharvest::j, eostools::move(), dqmiodumpmetadata::n, pat::helper::EfficiencyLoader::newEvent(), pat::helper::KinResolutionsLoader::newEvent(), pfParticleProducer_cfi::patPFParticles, zmumugammaAnalyzer_cfi::pfCandidates, pfCandidateToken_, pTComparator_, resolutionLoader_, pat::helper::EfficiencyLoader::setEfficiencies(), pat::helper::KinResolutionsLoader::setResolutions(), jetUpdater_cfi::sort, userDataHelper_, and useUserData_.

115  {
116  // Get the collection of PFCandidates from the event
119 
120  // prepare the MC matching
121  std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > > genMatches(genMatchTokens_.size());
122  if (addGenMatch_) {
123  for (size_t j = 0, nd = genMatchTokens_.size(); j < nd; ++j) {
124  iEvent.getByToken(genMatchTokens_[j], genMatches[j]);
125  }
126  }
127 
132 
133  // loop over PFCandidates
134  std::vector<PFParticle>* patPFParticles = new std::vector<PFParticle>();
135  for (edm::View<reco::PFCandidate>::const_iterator itPFParticle = pfCandidates->begin();
136  itPFParticle != pfCandidates->end();
137  ++itPFParticle) {
138  // construct the PFParticle from the ref -> save ref to original object
139  unsigned int idx = itPFParticle - pfCandidates->begin();
140  edm::RefToBase<reco::PFCandidate> pfCandidatesRef = pfCandidates->refAt(idx);
141 
142  PFParticle aPFParticle(pfCandidatesRef);
143 
144  if (addGenMatch_) {
145  for (size_t i = 0, n = genMatches.size(); i < n; ++i) {
146  reco::GenParticleRef genPFParticle = (*genMatches[i])[pfCandidatesRef];
147  aPFParticle.addGenParticleRef(genPFParticle);
148  }
149  if (embedGenMatch_)
150  aPFParticle.embedGenParticle();
151  }
152 
153  if (efficiencyLoader_.enabled()) {
154  efficiencyLoader_.setEfficiencies(aPFParticle, pfCandidatesRef);
155  }
156 
157  if (resolutionLoader_.enabled()) {
158  resolutionLoader_.setResolutions(aPFParticle);
159  }
160 
161  if (useUserData_) {
162  userDataHelper_.add(aPFParticle, iEvent, iSetup);
163  }
164 
165  // add sel to selected
166  patPFParticles->push_back(aPFParticle);
167  }
168 
169  // sort pfCandidates in pt
171 
172  // put genEvt object in Event
173  std::unique_ptr<std::vector<PFParticle> > ptr(patPFParticles);
174  iEvent.put(std::move(ptr));
175 }
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
pat::helper::KinResolutionsLoader resolutionLoader_
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
int iEvent
Definition: GenABIO.cc:224
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
pat::helper::EfficiencyLoader efficiencyLoader_
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
edm::EDGetTokenT< edm::View< reco::PFCandidate > > pfCandidateToken_
Analysis-level class for reconstructed particles.
Definition: PFParticle.h:32
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
pat::PATUserDataHelper< pat::PFParticle > userDataHelper_
def move(src, dest)
Definition: eostools.py:511
GreaterByPt< PFParticle > pTComparator_

Member Data Documentation

◆ addEfficiencies_

bool pat::PATPFParticleProducer::addEfficiencies_
private

Definition at line 56 of file PATPFParticleProducer.cc.

Referenced by PATPFParticleProducer().

◆ addGenMatch_

bool pat::PATPFParticleProducer::addGenMatch_
private

Definition at line 50 of file PATPFParticleProducer.cc.

Referenced by PATPFParticleProducer(), and produce().

◆ addResolutions_

bool pat::PATPFParticleProducer::addResolutions_
private

Definition at line 59 of file PATPFParticleProducer.cc.

Referenced by PATPFParticleProducer().

◆ efficiencyLoader_

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

Definition at line 57 of file PATPFParticleProducer.cc.

Referenced by PATPFParticleProducer(), and produce().

◆ embedGenMatch_

bool pat::PATPFParticleProducer::embedGenMatch_
private

Definition at line 51 of file PATPFParticleProducer.cc.

Referenced by PATPFParticleProducer(), and produce().

◆ embedPFCandidate_

bool pat::PATPFParticleProducer::embedPFCandidate_
private

Definition at line 49 of file PATPFParticleProducer.cc.

◆ genMatchTokens_

std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > > pat::PATPFParticleProducer::genMatchTokens_
private

Definition at line 52 of file PATPFParticleProducer.cc.

Referenced by PATPFParticleProducer(), and produce().

◆ pfCandidateToken_

edm::EDGetTokenT<edm::View<reco::PFCandidate> > pat::PATPFParticleProducer::pfCandidateToken_
private

Definition at line 48 of file PATPFParticleProducer.cc.

Referenced by PATPFParticleProducer(), and produce().

◆ pTComparator_

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

Definition at line 54 of file PATPFParticleProducer.cc.

Referenced by produce().

◆ resolutionLoader_

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

Definition at line 60 of file PATPFParticleProducer.cc.

Referenced by PATPFParticleProducer(), and produce().

◆ userDataHelper_

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

Definition at line 63 of file PATPFParticleProducer.cc.

Referenced by produce().

◆ useUserData_

bool pat::PATPFParticleProducer::useUserData_
private

Definition at line 62 of file PATPFParticleProducer.cc.

Referenced by PATPFParticleProducer(), and produce().