Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:05

0001 #include "RecoMuon/MuonIsolation/interface/MuPFIsoHelper.h"
0002 
0003 MuPFIsoHelper::MuPFIsoHelper(const std::map<std::string, edm::ParameterSet>& labelMap, edm::ConsumesCollector&& iC)
0004     : labelMap_(labelMap) {
0005   edm::Handle<CandDoubleMap> nullHandle;
0006   for (std::map<std::string, edm::ParameterSet>::const_iterator i = labelMap_.begin(); i != labelMap_.end(); ++i) {
0007     chargedParticle_.push_back(nullHandle);
0008     chargedHadron_.push_back(nullHandle);
0009     neutralHadron_.push_back(nullHandle);
0010     neutralHadronHighThreshold_.push_back(nullHandle);
0011     photon_.push_back(nullHandle);
0012     photonHighThreshold_.push_back(nullHandle);
0013     pu_.push_back(nullHandle);
0014 
0015     chargedParticleToken_.push_back(
0016         iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("chargedParticle")));
0017     chargedHadronToken_.push_back(iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("chargedHadron")));
0018     neutralHadronToken_.push_back(iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("neutralHadron")));
0019     neutralHadronHighThresholdToken_.push_back(
0020         iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("neutralHadronHighThreshold")));
0021     photonToken_.push_back(iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("photon")));
0022     photonHighThresholdToken_.push_back(
0023         iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("photonHighThreshold")));
0024     puToken_.push_back(iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("pu")));
0025   }
0026 }
0027 
0028 MuPFIsoHelper::~MuPFIsoHelper() {}
0029 
0030 reco::MuonPFIsolation MuPFIsoHelper::makeIsoDeposit(reco::MuonRef& muonRef,
0031                                                     const edm::Handle<CandDoubleMap>& chargedParticle,
0032                                                     const edm::Handle<CandDoubleMap>& chargedHadron,
0033                                                     const edm::Handle<CandDoubleMap>& neutralHadron,
0034                                                     const edm::Handle<CandDoubleMap>& neutralHadronHighThreshold,
0035                                                     const edm::Handle<CandDoubleMap>& photon,
0036                                                     const edm::Handle<CandDoubleMap>& photonHighThreshold,
0037                                                     const edm::Handle<CandDoubleMap>& pu) {
0038   reco::MuonPFIsolation iso;
0039   if (chargedParticle.isValid())
0040     iso.sumChargedParticlePt = (*chargedParticle)[muonRef];
0041 
0042   if (chargedHadron.isValid())
0043     iso.sumChargedHadronPt = (*chargedHadron)[muonRef];
0044 
0045   if (neutralHadron.isValid())
0046     iso.sumNeutralHadronEt = (*neutralHadron)[muonRef];
0047 
0048   if (neutralHadronHighThreshold.isValid())
0049     iso.sumNeutralHadronEtHighThreshold = (*neutralHadronHighThreshold)[muonRef];
0050 
0051   if (photon.isValid())
0052     iso.sumPhotonEt = (*photon)[muonRef];
0053 
0054   if (photonHighThreshold.isValid())
0055     iso.sumPhotonEtHighThreshold = (*photonHighThreshold)[muonRef];
0056 
0057   if (pu.isValid())
0058     iso.sumPUPt = (*pu)[muonRef];
0059 
0060   return iso;
0061 }
0062 
0063 int MuPFIsoHelper::embedPFIsolation(reco::Muon& muon, reco::MuonRef& muonRef) {
0064   unsigned int count = 0;
0065   for (std::map<std::string, edm::ParameterSet>::const_iterator i = labelMap_.begin(); i != labelMap_.end(); ++i) {
0066     reco::MuonPFIsolation iso = makeIsoDeposit(muonRef,
0067                                                chargedParticle_[count],
0068                                                chargedHadron_[count],
0069                                                neutralHadron_[count],
0070                                                neutralHadronHighThreshold_[count],
0071                                                photon_[count],
0072                                                photonHighThreshold_[count],
0073                                                pu_[count]);
0074 
0075     muon.setPFIsolation(i->first, iso);
0076     count++;
0077   }
0078 
0079   return 0;
0080 }
0081 
0082 void MuPFIsoHelper::beginEvent(const edm::Event& iEvent) {
0083   unsigned int count = 0;
0084   for (std::map<std::string, edm::ParameterSet>::const_iterator i = labelMap_.begin(); i != labelMap_.end(); ++i) {
0085     iEvent.getByToken(chargedParticleToken_[count], chargedParticle_[count]);
0086     iEvent.getByToken(chargedHadronToken_[count], chargedHadron_[count]);
0087     iEvent.getByToken(neutralHadronToken_[count], neutralHadron_[count]);
0088     iEvent.getByToken(neutralHadronHighThresholdToken_[count], neutralHadronHighThreshold_[count]);
0089     iEvent.getByToken(photonToken_[count], photon_[count]);
0090     iEvent.getByToken(photonHighThresholdToken_[count], photonHighThreshold_[count]);
0091     iEvent.getByToken(puToken_[count], pu_[count]);
0092     count++;
0093   }
0094 }