CMS 3D CMS Logo

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 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
34 
35 //
36 // class declaration
37 //
38 
40 public:
41  explicit MuPFIsoEmbedder(const edm::ParameterSet&);
42  ~MuPFIsoEmbedder() override;
43 
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46 private:
47  void produce(edm::Event&, const edm::EventSetup&) override;
48 
49  // ----------member data ---------------------------
53 };
54 
55 //
57  : muons_(iConfig.getParameter<edm::InputTag>("src")) {
58  //decide what to read
59  //Define a map between the isolation and the PSet for the PFHelper
60  std::map<std::string, edm::ParameterSet> psetMap;
61 
62  //First declare what isolation you are going to read
63  std::vector<std::string> isolationLabels;
64  isolationLabels.push_back("pfIsolationR03");
65  isolationLabels.push_back("pfIsoMeanDRProfileR03");
66  isolationLabels.push_back("pfIsoSumDRProfileR03");
67  isolationLabels.push_back("pfIsolationR04");
68  isolationLabels.push_back("pfIsoMeanDRProfileR04");
69  isolationLabels.push_back("pfIsoSumDRProfileR04");
70 
71  //Fill the label,pet map and initialize MuPFIsoHelper
72  for (std::vector<std::string>::const_iterator label = isolationLabels.begin(); label != isolationLabels.end();
73  ++label)
74  psetMap[*label] = iConfig.getParameter<edm::ParameterSet>(*label);
75  helper_ = new MuPFIsoHelper(psetMap, consumesCollector());
76  muonToken_ = consumes<reco::MuonCollection>(muons_);
77  produces<reco::MuonCollection>();
78 }
79 
81  // do anything here that needs to be done at desctruction time
82  // (e.g. close files, deallocate resources etc.)
83  delete helper_;
84 }
85 
86 //
87 // member functions
88 //
89 
90 // ------------ method called to produce the data ------------
92  using namespace edm;
93  using namespace reco;
94 
96 
98  iEvent.getByToken(muonToken_, muons);
99 
100  auto out = std::make_unique<MuonCollection>();
101 
102  for (unsigned int i = 0; i < muons->size(); ++i) {
103  MuonRef muonRef(muons, i);
104  Muon muon = muons->at(i);
105  helper_->embedPFIsolation(muon, muonRef);
106  out->push_back(muon);
107  }
108 
109  iEvent.put(std::move(out));
110 }
111 
112 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
114  //The following says we do not know what parameters are allowed so do no validation
115  // Please change this to state exactly what you do use, even if it is no parameters
117  desc.setUnknown();
118  descriptions.addDefault(desc);
119 }
120 
121 //define this as a plug-in
void produce(edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< reco::MuonCollection > muonToken_
char const * label
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
Definition: Muon.py:1
MuPFIsoEmbedder(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MuPFIsoHelper * helper_
int embedPFIsolation(reco::Muon &, reco::MuonRef &)
void beginEvent(const edm::Event &iEvent)
fixed size matrix
HLT enums.
edm::InputTag muons_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
def move(src, dest)
Definition: eostools.py:511
~MuPFIsoEmbedder() override