CMS 3D CMS Logo

PATCompositeCandidateProducer.cc
Go to the documentation of this file.
1 //
2 //
3 
11 #include <memory>
12 
13 #include <iostream>
14 
15 using namespace pat;
16 using namespace std;
17 using namespace edm;
18 
20  : srcToken_(consumes<edm::View<reco::CompositeCandidate> >(iConfig.getParameter<InputTag>("src"))),
21  useUserData_(iConfig.exists("userData")),
22  userDataHelper_(iConfig.getParameter<edm::ParameterSet>("userData"), consumesCollector()),
23  addEfficiencies_(iConfig.getParameter<bool>("addEfficiencies")),
24  addResolutions_(iConfig.getParameter<bool>("addResolutions")) {
25  // Efficiency configurables
26  if (addEfficiencies_) {
28  pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"), consumesCollector());
29  }
30 
31  // Resolution configurables
32  if (addResolutions_) {
34  }
35 
36  // produces vector of particles
37  produces<vector<pat::CompositeCandidate> >();
38 }
39 
41 
43  // Get the vector of CompositeCandidate's from the event
45  iEvent.getByToken(srcToken_, cands);
46 
50  resolutionLoader_.newEvent(iEvent, iSetup);
51 
52  auto myCompositeCandidates = std::make_unique<vector<pat::CompositeCandidate> >();
53 
54  if (cands.isValid()) {
55  View<reco::CompositeCandidate>::const_iterator ibegin = cands->begin(), iend = cands->end(), i = ibegin;
56  for (; i != iend; ++i) {
58 
59  if (useUserData_) {
60  userDataHelper_.add(cand, iEvent, iSetup);
61  }
62 
64  efficiencyLoader_.setEfficiencies(cand, cands->refAt(i - cands->begin()));
67 
68  myCompositeCandidates->push_back(std::move(cand));
69  }
70 
71  } // end if the two handles are valid
72 
73  iEvent.put(std::move(myCompositeCandidates));
74 }
75 
77 
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
Analysis-level particle class.
T getParameter(std::string const &) const
void newEvent(const edm::Event &event)
To be called for each new event, reads in the ValueMaps for efficiencies.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
pat::PATUserDataHelper< pat::CompositeCandidate > userDataHelper_
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
Definition: HeavyIon.h:7
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void newEvent(const edm::Event &event, const edm::EventSetup &setup)
To be called for each new event, reads in the EventSetup object.
pat::helper::KinResolutionsLoader resolutionLoader_
bool isValid() const
Definition: HandleBase.h:70
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
Produces the pat::CompositeCandidate.
const edm::EDGetTokenT< edm::View< reco::CompositeCandidate > > srcToken_
fixed size matrix
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
PATCompositeCandidateProducer(const edm::ParameterSet &iConfig)
def move(src, dest)
Definition: eostools.py:511
pat::helper::EfficiencyLoader efficiencyLoader_