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 // $Id: PATCompositeCandidateProducer.cc,v 1.3 2009/06/25 23:49:35 gpetrucc Exp $
3 //
4 
12 #include <memory>
13 
14 
15 #include <iostream>
16 
17 using namespace pat;
18 using namespace std;
19 using namespace edm;
20 
22  userDataHelper_( iConfig.getParameter<edm::ParameterSet>("userData") )
23 {
24  // initialize the configurables
25  src_ = iConfig.getParameter<InputTag>( "src" );
26 
27  useUserData_ = false;
28  if ( iConfig.exists("userData") ) {
29  useUserData_ = true;
30  }
31 
32  // Efficiency configurables
33  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
34  if (addEfficiencies_) {
36  }
37 
38  // Resolution configurables
39  addResolutions_ = iConfig.getParameter<bool>("addResolutions");
40  if (addResolutions_) {
42  }
43 
44 
45  // produces vector of particles
46  produces<vector<pat::CompositeCandidate> >();
47 
48 }
49 
51 }
52 
54  // Get the vector of CompositeCandidate's from the event
56  iEvent.getByLabel(src_, cands);
57 
59  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
60 
61  auto_ptr<vector<pat::CompositeCandidate> > myCompositeCandidates ( new vector<pat::CompositeCandidate>() );
62 
63  if ( cands.isValid() ) {
64 
65  View<reco::CompositeCandidate>::const_iterator ibegin = cands->begin(),
66  iend = cands->end(), i = ibegin;
67  for ( ; i != iend; ++i ) {
68 
70 
71  if ( useUserData_ ) {
72  userDataHelper_.add( cand, iEvent, iSetup );
73  }
74 
75  if (efficiencyLoader_.enabled()) efficiencyLoader_.setEfficiencies( cand, cands->refAt(i - cands->begin()) );
77 
78  myCompositeCandidates->push_back( cand );
79  }
80 
81  }// end if the two handles are valid
82 
83  iEvent.put(myCompositeCandidates);
84 
85 }
86 
88 
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
#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:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
pat::helper::KinResolutionsLoader resolutionLoader_
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
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.
pat::helper::EfficiencyLoader efficiencyLoader_