CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PATCompositeCandidateProducer.cc
Go to the documentation of this file.
1 
31 
32 namespace pat {
33 
35  public:
38 
39  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
40 
41  private:
42  // configurables
43  const edm::EDGetTokenT<edm::View<reco::CompositeCandidate> > srcToken_; // list of reco::CompositeCandidates
44 
45  const bool useUserData_;
47 
48  const bool addEfficiencies_;
50 
51  const bool addResolutions_;
53  };
54 
55 } // namespace pat
56 
57 using namespace pat;
58 using namespace std;
59 using namespace edm;
60 
62  : srcToken_(consumes<edm::View<reco::CompositeCandidate> >(iConfig.getParameter<InputTag>("src"))),
63  useUserData_(iConfig.exists("userData")),
64  userDataHelper_(iConfig.getParameter<edm::ParameterSet>("userData"), consumesCollector()),
65  addEfficiencies_(iConfig.getParameter<bool>("addEfficiencies")),
66  addResolutions_(iConfig.getParameter<bool>("addResolutions")) {
67  // Efficiency configurables
68  if (addEfficiencies_) {
70  pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"), consumesCollector());
71  }
72 
73  // Resolution configurables
74  if (addResolutions_) {
76  pat::helper::KinResolutionsLoader(iConfig.getParameter<edm::ParameterSet>("resolutions"), consumesCollector());
77  }
78 
79  // produces vector of particles
80  produces<vector<pat::CompositeCandidate> >();
81 }
82 
84 
86  // Get the vector of CompositeCandidate's from the event
88  iEvent.getByToken(srcToken_, cands);
89 
93  resolutionLoader_.newEvent(iEvent, iSetup);
94 
95  auto myCompositeCandidates = std::make_unique<vector<pat::CompositeCandidate> >();
96 
97  if (cands.isValid()) {
98  View<reco::CompositeCandidate>::const_iterator ibegin = cands->begin(), iend = cands->end(), i = ibegin;
99  for (; i != iend; ++i) {
100  pat::CompositeCandidate cand(*i);
101 
102  if (useUserData_) {
103  userDataHelper_.add(cand, iEvent, iSetup);
104  }
105 
107  efficiencyLoader_.setEfficiencies(cand, cands->refAt(i - cands->begin()));
110 
111  myCompositeCandidates->push_back(std::move(cand));
112  }
113 
114  } // end if the two handles are valid
115 
116  iEvent.put(std::move(myCompositeCandidates));
117 }
118 
120 
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
Analysis-level particle class.
Assists in assimilating all pat::UserData into pat objects.
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:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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
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.
pat::helper::KinResolutionsLoader resolutionLoader_
def move
Definition: eostools.py:511
bool isValid() const
Definition: HandleBase.h:70
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
PATCompositeCandidateProducer(const edm::ParameterSet &iConfig)
pat::helper::EfficiencyLoader efficiencyLoader_