CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PATCompositeCandidateProducer.cc
Go to the documentation of this file.
1 //
2 //
3 
11 #include <memory>
12 
13 
14 #include <iostream>
15 
16 using namespace pat;
17 using namespace std;
18 using namespace edm;
19 
21  userDataHelper_( iConfig.getParameter<edm::ParameterSet>("userData"), consumesCollector() )
22 {
23  // initialize the configurables
24  srcToken_ = consumes<edm::View<reco::CompositeCandidate> >(iConfig.getParameter<InputTag>( "src" ));
25 
26  useUserData_ = false;
27  if ( iConfig.exists("userData") ) {
28  useUserData_ = true;
29  }
30 
31  // Efficiency configurables
32  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
33  if (addEfficiencies_) {
35  }
36 
37  // Resolution configurables
38  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
39  if (addResolutions_) {
41  }
42 
43 
44  // produces vector of particles
45  produces<vector<pat::CompositeCandidate> >();
46 
47 }
48 
50 }
51 
53  // Get the vector of CompositeCandidate's from the event
55  iEvent.getByToken(srcToken_, cands);
56 
58  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
59 
60  auto_ptr<vector<pat::CompositeCandidate> > myCompositeCandidates ( new vector<pat::CompositeCandidate>() );
61 
62  if ( cands.isValid() ) {
63 
64  View<reco::CompositeCandidate>::const_iterator ibegin = cands->begin(),
65  iend = cands->end(), i = ibegin;
66  for ( ; i != iend; ++i ) {
67 
69 
70  if ( useUserData_ ) {
71  userDataHelper_.add( cand, iEvent, iSetup );
72  }
73 
74  if (efficiencyLoader_.enabled()) efficiencyLoader_.setEfficiencies( cand, cands->refAt(i - cands->begin()) );
76 
77  myCompositeCandidates->push_back( cand );
78  }
79 
80  }// end if the two handles are valid
81 
82  iEvent.put(myCompositeCandidates);
83 
84 }
85 
87 
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
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
pat::PATUserDataHelper< pat::CompositeCandidate > userDataHelper_
bool exists(std::string const &parameterName) const
checks if a parameter exists
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:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
pat::helper::KinResolutionsLoader resolutionLoader_
bool isValid() const
Definition: HandleBase.h:76
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.
PATCompositeCandidateProducer(const edm::ParameterSet &iConfig)
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.
edm::EDGetTokenT< edm::View< reco::CompositeCandidate > > srcToken_
pat::helper::EfficiencyLoader efficiencyLoader_