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 }
84 
85 //
86 // member functions
87 //
88 
89 // ------------ method called to produce the data ------------
91  using namespace edm;
92  using namespace reco;
93 
95 
97  iEvent.getByToken(muonToken_, muons);
98 
99  auto out = std::make_unique<MuonCollection>();
100 
101  for (unsigned int i = 0; i < muons->size(); ++i) {
102  MuonRef muonRef(muons, i);
103  Muon muon = muons->at(i);
104  helper_->embedPFIsolation(muon, muonRef);
105  out->push_back(muon);
106  }
107 
108  iEvent.put(std::move(out));
109 }
110 
111 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
113  //The following says we do not know what parameters are allowed so do no validation
114  // Please change this to state exactly what you do use, even if it is no parameters
116  desc.setUnknown();
117  descriptions.addDefault(desc);
118 }
119 
120 //define this as a plug-in
void produce(edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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 &)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
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