CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/RecoMuon/MuonIsolation/src/MuPFIsoHelper.cc

Go to the documentation of this file.
00001 #include "RecoMuon/MuonIsolation/interface/MuPFIsoHelper.h"
00002 
00003 
00004 MuPFIsoHelper::MuPFIsoHelper(const std::map<std::string,edm::ParameterSet>& labelMap):
00005   labelMap_(labelMap)  
00006 {
00007   edm::Handle<CandDoubleMap> nullHandle;
00008   for(std::map<std::string,edm::ParameterSet>::const_iterator i = labelMap_.begin();i!=labelMap_.end();++i) {
00009     chargedParticle_.push_back(nullHandle);
00010     chargedHadron_.push_back(nullHandle);
00011     neutralHadron_.push_back(nullHandle);
00012     neutralHadronHighThreshold_.push_back(nullHandle);
00013     photon_.push_back(nullHandle);
00014     photonHighThreshold_.push_back(nullHandle);
00015     pu_.push_back(nullHandle);
00016   }
00017     
00018 
00019 
00020 
00021 }
00022 
00023 
00024 
00025 MuPFIsoHelper::~MuPFIsoHelper() {
00026 
00027 }
00028 
00029 
00030 reco::MuonPFIsolation MuPFIsoHelper::makeIsoDeposit(reco::MuonRef& muonRef,
00031                                                     const edm::Handle<CandDoubleMap>& chargedParticle,
00032                                                     const edm::Handle<CandDoubleMap>& chargedHadron,
00033                                                     const edm::Handle<CandDoubleMap>& neutralHadron,
00034                                                     const edm::Handle<CandDoubleMap>& neutralHadronHighThreshold,
00035                                                     const edm::Handle<CandDoubleMap>& photon,
00036                                                     const edm::Handle<CandDoubleMap>& photonHighThreshold,
00037                                                     const edm::Handle<CandDoubleMap>& pu) {
00038 
00039   reco::MuonPFIsolation iso;
00040   if(chargedParticle.isValid()) 
00041     iso.sumChargedParticlePt = (*chargedParticle)[muonRef];
00042 
00043   if(chargedHadron.isValid()) 
00044        iso.sumChargedHadronPt = (*chargedHadron)[muonRef];
00045 
00046   if(neutralHadron.isValid()) 
00047        iso.sumNeutralHadronEt = (*neutralHadron)[muonRef];
00048 
00049   if(neutralHadronHighThreshold.isValid()) 
00050        iso.sumNeutralHadronEtHighThreshold = (*neutralHadronHighThreshold)[muonRef];
00051 
00052   if(photon.isValid()) 
00053        iso.sumPhotonEt = (*photon)[muonRef];
00054 
00055   if(photonHighThreshold.isValid()) 
00056        iso.sumPhotonEtHighThreshold = (*photonHighThreshold)[muonRef];
00057 
00058   if(pu.isValid()) 
00059        iso.sumPUPt = (*pu)[muonRef];
00060 
00061   return iso;
00062 }
00063 
00064 
00065 int MuPFIsoHelper::embedPFIsolation(reco::Muon& muon,reco::MuonRef& muonRef ) {
00066 
00067   unsigned int count=0;
00068   for(std::map<std::string,edm::ParameterSet>::const_iterator i = labelMap_.begin();i!=labelMap_.end();++i) {
00069     reco::MuonPFIsolation iso =makeIsoDeposit(muonRef,
00070                                               chargedParticle_[count],
00071                                               chargedHadron_[count],
00072                                               neutralHadron_[count],
00073                                               neutralHadronHighThreshold_[count],
00074                                               photon_[count],
00075                                               photonHighThreshold_[count],
00076                                               pu_[count]);
00077  
00078     muon.setPFIsolation(i->first,iso);
00079     count++;
00080   }
00081 
00082 
00083   return 0;
00084 }
00085 
00086 
00087 
00088 void MuPFIsoHelper::beginEvent(const edm::Event& iEvent){
00089 
00090   unsigned int count=0;
00091   for(std::map<std::string,edm::ParameterSet>::const_iterator i = labelMap_.begin();i!=labelMap_.end();++i) {
00092     iEvent.getByLabel(i->second.getParameter<edm::InputTag>("chargedParticle"),chargedParticle_[count]);
00093     iEvent.getByLabel(i->second.getParameter<edm::InputTag>("chargedHadron"),chargedHadron_[count]);
00094     iEvent.getByLabel(i->second.getParameter<edm::InputTag>("neutralHadron"),neutralHadron_[count]);
00095     iEvent.getByLabel(i->second.getParameter<edm::InputTag>("neutralHadronHighThreshold"),neutralHadronHighThreshold_[count]);
00096     iEvent.getByLabel(i->second.getParameter<edm::InputTag>("photon"),photon_[count]);
00097     iEvent.getByLabel(i->second.getParameter<edm::InputTag>("photonHighThreshold"),photonHighThreshold_[count]);
00098     iEvent.getByLabel(i->second.getParameter<edm::InputTag>("pu"),pu_[count]);
00099     count++;
00100   }
00101 
00102 }