CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuPFIsoEmbedder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MuPFIsoEmbedder
4 // Class: MuPFIsoEmbedder
5 //
13 //
14 // Original Author: Michail Bachtis,32 3-B16,+41227675567,
15 // Created: Thu Jun 9 01:36:17 CEST 2011
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
35 
36 //
37 // class declaration
38 //
39 
41  public:
42  explicit MuPFIsoEmbedder(const edm::ParameterSet&);
44 
45  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
46 
47  private:
48  virtual void produce(edm::Event&, const edm::EventSetup&) override;
49 
50 
51  // ----------member data ---------------------------
55 
56 };
57 
58 
59 
60 
61 //
63  muons_(iConfig.getParameter<edm::InputTag>("src"))
64 {
65 
66  //decide what to read
67  //Define a map between the isolation and the PSet for the PFHelper
68  std::map<std::string,edm::ParameterSet> psetMap;
69 
70  //First declare what isolation you are going to read
71  std::vector<std::string> isolationLabels;
72  isolationLabels.push_back("pfIsolationR03");
73  isolationLabels.push_back("pfIsoMeanDRProfileR03");
74  isolationLabels.push_back("pfIsoSumDRProfileR03");
75  isolationLabels.push_back("pfIsolationR04");
76  isolationLabels.push_back("pfIsoMeanDRProfileR04");
77  isolationLabels.push_back("pfIsoSumDRProfileR04");
78 
79  //Fill the label,pet map and initialize MuPFIsoHelper
80  for( std::vector<std::string>::const_iterator label = isolationLabels.begin();label != isolationLabels.end();++label)
81  psetMap[*label] =iConfig.getParameter<edm::ParameterSet >(*label);
82  helper_ = new MuPFIsoHelper(psetMap,consumesCollector());
83  muonToken_ = consumes<reco::MuonCollection>(muons_);
84  produces<reco::MuonCollection>();
85 }
86 
87 
89 {
90 
91  // do anything here that needs to be done at desctruction time
92  // (e.g. close files, deallocate resources etc.)
93 
94 }
95 
96 
97 //
98 // member functions
99 //
100 
101 // ------------ method called to produce the data ------------
102 void
104 {
105  using namespace edm;
106  using namespace reco;
107 
108 
109  helper_->beginEvent(iEvent);
110 
112  iEvent.getByToken(muonToken_,muons);
113 
114 
115  std::auto_ptr<MuonCollection> out(new MuonCollection);
116 
117  for(unsigned int i=0;i<muons->size();++i) {
118  MuonRef muonRef(muons,i);
119  Muon muon = muons->at(i);
120  helper_->embedPFIsolation(muon,muonRef);
121  out->push_back(muon);
122  }
123 
124  iEvent.put(out);
125 }
126 
127 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
128 void
130  //The following says we do not know what parameters are allowed so do no validation
131  // Please change this to state exactly what you do use, even if it is no parameters
133  desc.setUnknown();
134  descriptions.addDefault(desc);
135 }
136 
137 //define this as a plug-in
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &) override
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< reco::MuonCollection > muonToken_
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
MuPFIsoEmbedder(const edm::ParameterSet &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
tuple out
Definition: dbtoconf.py:99
MuPFIsoHelper * helper_
int embedPFIsolation(reco::Muon &, reco::MuonRef &)
void beginEvent(const edm::Event &iEvent)
tuple muons
Definition: patZpeak.py:38
edm::InputTag muons_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)