ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DGele/PhysicsTools/PatAlgos/plugins/PATCompositeCandidateProducer.cc
Revision: 1.1.1.1 (vendor branch)
Committed: Tue Oct 20 17:15:14 2009 UTC (15 years, 6 months ago) by dgele
Content type: text/plain
Branch: ANA
CVS Tags: start
Changes since 1.1: +0 -0 lines
Error occurred while calculating annotation data.
Log Message:
version CMSSW_2_2_10

File Contents

# Content
1 //
2 // $Id: PATCompositeCandidateProducer.cc,v 1.1.2.1 2009/04/30 09:11:45 gpetrucc Exp $
3 //
4
5 #include "PhysicsTools/PatAlgos/plugins/PATCompositeCandidateProducer.h"
6 #include "FWCore/MessageLogger/interface/MessageLogger.h"
7 #include "DataFormats/Common/interface/View.h"
8 #include "PhysicsTools/CandUtils/interface/AddFourMomenta.h"
9 #include "FWCore/MessageLogger/interface/MessageLogger.h"
10 #include "PhysicsTools/Utilities/interface/StringObjectFunction.h"
11 #include "FWCore/Utilities/interface/Exception.h"
12 #include <memory>
13
14
15 #include <iostream>
16
17 using namespace pat;
18 using namespace std;
19 using namespace edm;
20
21 PATCompositeCandidateProducer::PATCompositeCandidateProducer(const ParameterSet & iConfig) :
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_) {
35 efficiencyLoader_ = pat::helper::EfficiencyLoader(iConfig.getParameter<edm::ParameterSet>("efficiencies"));
36 }
37
38 // Resolution configurables
39 addResolutions_ = iConfig.getParameter<bool>("addResolutions");
40 if (addResolutions_) {
41 resolutionLoader_ = pat::helper::KinResolutionsLoader(iConfig.getParameter<edm::ParameterSet>("resolutions"));
42 }
43
44 // produces vector of particles
45 produces<vector<pat::CompositeCandidate> >();
46
47 }
48
49 PATCompositeCandidateProducer::~PATCompositeCandidateProducer() {
50 }
51
52 void PATCompositeCandidateProducer::produce(Event & iEvent, const EventSetup & iSetup) {
53 // Get the vector of CompositeCandidate's from the event
54 Handle<View<reco::CompositeCandidate> > cands;
55 iEvent.getByLabel(src_, cands);
56
57 if (efficiencyLoader_.enabled()) efficiencyLoader_.newEvent(iEvent);
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
68 pat::CompositeCandidate cand(*i);
69
70 if ( useUserData_ ) {
71 userDataHelper_.add( cand, iEvent, iSetup );
72 }
73
74 if (efficiencyLoader_.enabled()) efficiencyLoader_.setEfficiencies( cand, cands->refAt(i - cands->begin()) );
75 if (resolutionLoader_.enabled()) resolutionLoader_.setResolutions(cand);
76
77 myCompositeCandidates->push_back( cand );
78 }
79
80 }// end if the two handles are valid
81
82 iEvent.put(myCompositeCandidates);
83
84 }
85
86 #include "FWCore/Framework/interface/MakerMacros.h"
87
88 DEFINE_FWK_MODULE(PATCompositeCandidateProducer);