CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFPileUp.cc
Go to the documentation of this file.
2 
6 
8 
9 // #include "FWCore/MessageLogger/interface/MessageLogger.h"
12 
13 
14 using namespace std;
15 using namespace edm;
16 using namespace reco;
17 
19 
20  inputTagPFCandidates_
21  = iConfig.getParameter<InputTag>("PFCandidates");
22 
23  inputTagVertices_
24  = iConfig.getParameter<InputTag>("Vertices");
25 
26  enable_ = iConfig.getParameter<bool>("Enable");
27 
28  verbose_ =
29  iConfig.getUntrackedParameter<bool>("verbose",false);
30 
31 
32  if ( iConfig.exists("checkClosestZVertex") ) {
33  checkClosestZVertex_ = iConfig.getParameter<bool>("checkClosestZVertex");
34  } else {
35  checkClosestZVertex_ = false;
36  }
37 
38  // Configure the algo
39  pileUpAlgo_.setVerbose(verbose_);
40  pileUpAlgo_.setCheckClosestZVertex(checkClosestZVertex_);
41 
42  produces<reco::PFCandidateCollection>();
43 
44 }
45 
46 
47 
49 
50 
51 
53 
54 
56  const EventSetup& iSetup) {
57 
58 // LogDebug("PFPileUp")<<"START event: "<<iEvent.id().event()
59 // <<" in run "<<iEvent.id().run()<<endl;
60 
61 
62  // get PFCandidates
63 
64  auto_ptr< reco::PFCandidateCollection >
65  pOutput( new reco::PFCandidateCollection );
66 
67  if(enable_) {
68 
70  iEvent.getByLabel( inputTagPFCandidates_, pfCandidates);
71 
72 
73  // get vertices
74 
75  Handle<VertexCollection> vertices;
76  iEvent.getByLabel( inputTagVertices_, vertices);
77 
78  pileUpAlgo_.process(*pfCandidates,*vertices,&pfCandidates);
79 
80  pOutput->insert(pOutput->end(),pileUpAlgo_.getPFCandidatesFromPU().begin(),pileUpAlgo_.getPFCandidatesFromPU().end());
81  }
82  // outsize of the loop to fill the collection anyway even when disabled
83  iEvent.put( pOutput );
84 }
85 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
Definition: PFPileUp.cc:55
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
~PFPileUp()
Definition: PFPileUp.cc:48
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
virtual void beginJob()
Definition: PFPileUp.cc:52
PFPileUp(const edm::ParameterSet &)
Definition: PFPileUp.cc:18