CMS 3D CMS Logo

L3MuonSumCaloPFIsolationProducer.cc
Go to the documentation of this file.
2 
3 // Framework
8 
10 
12 
18 
20 
22 
23 #include <string>
24 
25 using namespace edm;
26 using namespace std;
27 using namespace reco;
28 
31  recoChargedCandidateProducer_ = consumes<reco::RecoChargedCandidateCollection>(
32  config.getParameter<edm::InputTag>("recoChargedCandidateProducer"));
33  pfEcalClusterProducer_ =
34  consumes<reco::RecoChargedCandidateIsolationMap>(config.getParameter<edm::InputTag>("pfEcalClusterProducer"));
35  pfHcalClusterProducer_ =
36  consumes<reco::RecoChargedCandidateIsolationMap>(config.getParameter<edm::InputTag>("pfHcalClusterProducer"));
37 
38  produces<edm::ValueMap<float>>();
39 }
40 
42 
45  desc.add<edm::InputTag>("recoChargedCandidateProducer", edm::InputTag("hltL1SeededRecoChargedCandidatePF"));
46  desc.add<edm::InputTag>("pfEcalClusterProducer", edm::InputTag("hltParticleFlowClusterECAL"));
47  desc.add<edm::InputTag>("pfHcalClusterProducer", edm::InputTag("hltParticleFlowClusterHCAL"));
48  descriptions.add(("hltL3MuonSumCaloPFIsolationProducer"), desc);
49 }
50 
53  iEvent.getByToken(recoChargedCandidateProducer_, recochargedcandHandle);
54 
56  iEvent.getByToken(pfEcalClusterProducer_, ecalIsolation);
57 
59  iEvent.getByToken(pfHcalClusterProducer_, hcalIsolation);
60 
61  auto caloIsoMap = std::make_unique<edm::ValueMap<float>>();
62  std::vector<float> isoFloats(recochargedcandHandle->size(), 0);
63 
64  for (unsigned int iReco = 0; iReco < recochargedcandHandle->size(); iReco++) {
65  reco::RecoChargedCandidateRef candRef(recochargedcandHandle, iReco);
66  reco::RecoChargedCandidateIsolationMap::const_iterator mapiECAL = (*ecalIsolation).find(candRef);
67  float valisoECAL = mapiECAL->val;
68  reco::RecoChargedCandidateIsolationMap::const_iterator mapiHCAL = (*hcalIsolation).find(candRef);
69  float valisoHCAL = mapiHCAL->val;
70  float caloIso = valisoECAL + valisoHCAL;
71  isoFloats[iReco] = caloIso;
72  }
73 
74  edm::ValueMap<float>::Filler isoFloatFiller(*caloIsoMap);
75  isoFloatFiller.insert(recochargedcandHandle, isoFloats.begin(), isoFloats.end());
76  isoFloatFiller.fill();
77  iEvent.put(std::move(caloIsoMap));
78 }
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: config.py:1
int iEvent
Definition: GenABIO.cc:224
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
L3MuonSumCaloPFIsolationProducer(const edm::ParameterSet &)
constructor with config
fixed size matrix
HLT enums.
def move(src, dest)
Definition: eostools.py:511