Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-08-02 05:16:44

0001 #include "CaloExtractorByAssociator.h"
0002 
0003 #include "DataFormats/Common/interface/Handle.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 
0007 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
0008 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0009 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0010 
0011 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0012 
0013 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
0014 
0015 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
0016 #include "TrackingTools/TrackAssociator/interface/TrackAssociatorParameters.h"
0017 #include "TrackingTools/TrackAssociator/interface/TrackDetectorAssociator.h"
0018 
0019 #include "DataFormats/Math/interface/deltaR.h"
0020 
0021 #include "CondFormats/EcalObjects/interface/EcalPFRecHitThresholds.h"
0022 #include "CondFormats/DataRecord/interface/EcalPFRecHitThresholdsRcd.h"
0023 #include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h"
0024 #include "CondTools/Hcal/interface/HcalPFCutsHandler.h"
0025 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
0026 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputerRcd.h"
0027 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
0028 #include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
0029 
0030 using namespace edm;
0031 using namespace std;
0032 using namespace reco;
0033 using namespace muonisolation;
0034 using reco::isodeposit::Direction;
0035 
0036 namespace {
0037   constexpr double dRMax_CandDep = 1.0;  //pick up candidate own deposits up to this dR if theDR_Max is smaller
0038 }
0039 
0040 CaloExtractorByAssociator::CaloExtractorByAssociator(const ParameterSet& par, edm::ConsumesCollector&& iC)
0041     : theUseEcalRecHitsFlag(par.getParameter<bool>("UseEcalRecHitsFlag")),
0042       theUseHcalRecHitsFlag(par.getParameter<bool>("UseHcalRecHitsFlag")),
0043       theUseHORecHitsFlag(par.getParameter<bool>("UseHORecHitsFlag")),
0044       theDepositLabel(par.getUntrackedParameter<string>("DepositLabel")),
0045       theDepositInstanceLabels(par.getParameter<std::vector<std::string> >("DepositInstanceLabels")),
0046       thePropagatorName(par.getParameter<std::string>("PropagatorName")),
0047       theThreshold_E(par.getParameter<double>("Threshold_E")),
0048       theThreshold_H(par.getParameter<double>("Threshold_H")),
0049       theThreshold_HO(par.getParameter<double>("Threshold_HO")),
0050       theMaxSeverityHB(par.getParameter<int>("MaxSeverityHB")),
0051       theMaxSeverityHE(par.getParameter<int>("MaxSeverityHE")),
0052       theDR_Veto_E(par.getParameter<double>("DR_Veto_E")),
0053       theDR_Veto_H(par.getParameter<double>("DR_Veto_H")),
0054       theDR_Veto_HO(par.getParameter<double>("DR_Veto_HO")),
0055       theCenterConeOnCalIntersection(par.getParameter<bool>("CenterConeOnCalIntersection")),
0056       theDR_Max(par.getParameter<double>("DR_Max")),
0057       theNoise_EB(par.getParameter<double>("Noise_EB")),
0058       theNoise_EE(par.getParameter<double>("Noise_EE")),
0059       theNoise_HB(par.getParameter<double>("Noise_HB")),
0060       theNoise_HE(par.getParameter<double>("Noise_HE")),
0061       theNoise_HO(par.getParameter<double>("Noise_HO")),
0062       theNoiseTow_EB(par.getParameter<double>("NoiseTow_EB")),
0063       theNoiseTow_EE(par.getParameter<double>("NoiseTow_EE")),
0064       theService(nullptr),
0065       theAssociator(nullptr),
0066       bFieldToken_(iC.esConsumes()),
0067       thePrintTimeReport(par.getUntrackedParameter<bool>("PrintTimeReport")) {
0068   ParameterSet serviceParameters = par.getParameter<ParameterSet>("ServiceParameters");
0069   theService = new MuonServiceProxy(serviceParameters, edm::ConsumesCollector(iC));
0070 
0071   //theAssociatorParameters = new TrackAssociatorParameters(par.getParameter<edm::ParameterSet>("TrackAssociatorParameters"), iC);
0072   theAssociatorParameters = new TrackAssociatorParameters();
0073   theAssociatorParameters->loadParameters(par.getParameter<edm::ParameterSet>("TrackAssociatorParameters"), iC);
0074   theAssociator = new TrackDetectorAssociator();
0075 
0076   ecalRecHitThresh_ = par.getParameter<bool>("EcalRecHitThresh");
0077   hcalCutsFromDB_ = par.getParameter<bool>("HcalCutsFromDB");
0078 
0079   caloGeomToken_ = iC.esConsumes();
0080   ecalPFRechitThresholdsToken_ = iC.esConsumes();
0081   hcalCutsToken_ = iC.esConsumes();
0082   hcalTopologyToken_ = iC.esConsumes();
0083   hcalChannelQualityToken_ = iC.esConsumes(edm::ESInputTag("", "withTopo"));
0084   hcalSevLvlComputerToken_ = iC.esConsumes();
0085 }
0086 
0087 CaloExtractorByAssociator::~CaloExtractorByAssociator() {
0088   if (theAssociatorParameters)
0089     delete theAssociatorParameters;
0090   if (theService)
0091     delete theService;
0092   if (theAssociator)
0093     delete theAssociator;
0094 }
0095 
0096 void CaloExtractorByAssociator::fillVetos(const edm::Event& event,
0097                                           const edm::EventSetup& eventSetup,
0098                                           const TrackCollection& muons) {
0099   //   LogWarning("CaloExtractorByAssociator")
0100   //     <<"fillVetos does nothing now: IsoDeposit provides enough functionality\n"
0101   //     <<"to remove a deposit at/around given (eta, phi)";
0102 }
0103 
0104 IsoDeposit CaloExtractorByAssociator::deposit(const Event& event,
0105                                               const EventSetup& eventSetup,
0106                                               const Track& muon) const {
0107   IsoDeposit::Direction muonDir(muon.eta(), muon.phi());
0108   IsoDeposit dep(muonDir);
0109 
0110   //   LogWarning("CaloExtractorByAssociator")
0111   //     <<"single deposit is not an option here\n"
0112   //     <<"use ::deposits --> extract all and reweight as necessary";
0113 
0114   return dep;
0115 }
0116 
0117 //! Make separate deposits: for ECAL, HCAL, HO
0118 std::vector<IsoDeposit> CaloExtractorByAssociator::deposits(const Event& event,
0119                                                             const EventSetup& eventSetup,
0120                                                             const Track& muon) const {
0121   theService->update(eventSetup);
0122   theAssociator->setPropagator(&*(theService->propagator(thePropagatorName)));
0123 
0124   const EcalPFRecHitThresholds* ecalThresholds = &eventSetup.getData(ecalPFRechitThresholdsToken_);
0125   const HcalPFCuts* hcalCuts = &eventSetup.getData(hcalCutsToken_);
0126   const HcalTopology* hcalTopology_ = &eventSetup.getData(hcalTopologyToken_);
0127   const HcalChannelQuality* hcalChStatus_ = &eventSetup.getData(hcalChannelQualityToken_);
0128   const HcalSeverityLevelComputer* hcalSevLvlComputer_ = &eventSetup.getData(hcalSevLvlComputerToken_);
0129 
0130   //! check configuration consistency
0131   //! could've been made at construction stage (fix later?)
0132   if (theDepositInstanceLabels.size() != 3) {
0133     LogError("MuonIsolation") << "Configuration is inconsistent: Need 3 deposit instance labels";
0134   }
0135   if (!(theDepositInstanceLabels[0].compare(0, 1, std::string("e")) == 0) ||
0136       !(theDepositInstanceLabels[1].compare(0, 1, std::string("h")) == 0) ||
0137       !(theDepositInstanceLabels[2].compare(0, 2, std::string("ho")) == 0)) {
0138     LogWarning("MuonIsolation")
0139         << "Deposit instance labels do not look like  (e*, h*, ho*):"
0140         << "proceed at your own risk. The extractor interprets lab0=from ecal; lab1=from hcal; lab2=from ho";
0141   }
0142 
0143   typedef IsoDeposit::Veto Veto;
0144   //! this should be (eventually) set to the eta-phi of the crossing point of
0145   //! a straight line tangent to a muon at IP and the calorimeter
0146   IsoDeposit::Direction muonDir(muon.eta(), muon.phi());
0147 
0148   IsoDeposit depEcal(muonDir);
0149   IsoDeposit depHcal(muonDir);
0150   IsoDeposit depHOcal(muonDir);
0151 
0152   auto const& bField = eventSetup.getData(bFieldToken_);
0153 
0154   reco::TransientTrack tMuon(muon, &bField);
0155   FreeTrajectoryState iFTS = tMuon.initialFreeState();
0156   TrackDetMatchInfo mInfo = theAssociator->associate(event, eventSetup, iFTS, *theAssociatorParameters);
0157 
0158   //! each deposit type veto is at the point of intersect with that detector
0159   depEcal.setVeto(
0160       Veto(reco::isodeposit::Direction(mInfo.trkGlobPosAtEcal.eta(), mInfo.trkGlobPosAtEcal.phi()), theDR_Veto_E));
0161   depHcal.setVeto(
0162       Veto(reco::isodeposit::Direction(mInfo.trkGlobPosAtHcal.eta(), mInfo.trkGlobPosAtHcal.phi()), theDR_Veto_H));
0163   depHOcal.setVeto(
0164       Veto(reco::isodeposit::Direction(mInfo.trkGlobPosAtHO.eta(), mInfo.trkGlobPosAtHO.phi()), theDR_Veto_HO));
0165 
0166   if (theCenterConeOnCalIntersection) {
0167     reco::isodeposit::Direction dirTmp = depEcal.veto().vetoDir;
0168     double dRtmp = depEcal.veto().dR;
0169     depEcal = IsoDeposit(dirTmp);
0170     depEcal.setVeto(Veto(dirTmp, dRtmp));
0171 
0172     dirTmp = depHcal.veto().vetoDir;
0173     dRtmp = depHcal.veto().dR;
0174     depHcal = IsoDeposit(dirTmp);
0175     depHcal.setVeto(Veto(dirTmp, dRtmp));
0176 
0177     dirTmp = depHOcal.veto().vetoDir;
0178     dRtmp = depHOcal.veto().dR;
0179     depHOcal = IsoDeposit(dirTmp);
0180     depHOcal.setVeto(Veto(dirTmp, dRtmp));
0181   }
0182 
0183   if (theUseEcalRecHitsFlag) {
0184     //Ecal
0185     auto const& caloGeom = eventSetup.getData(caloGeomToken_);
0186     std::vector<const EcalRecHit*>::const_iterator eHitCI = mInfo.ecalRecHits.begin();
0187     for (; eHitCI != mInfo.ecalRecHits.end(); ++eHitCI) {
0188       const EcalRecHit* eHitCPtr = *eHitCI;
0189       GlobalPoint eHitPos = caloGeom.getPosition(eHitCPtr->detid());
0190       double deltaR2 = reco::deltaR2(muon, eHitPos);
0191       double cosTheta = 1. / cosh(eHitPos.eta());
0192       double energy = eHitCPtr->energy();
0193       double et = energy * cosTheta;
0194       if (deltaR2 > std::max(dRMax_CandDep * dRMax_CandDep, theDR_Max * theDR_Max))
0195         continue;
0196 
0197       if (ecalThresholds != nullptr) {  // use thresholds from rechit
0198         float rhThres = (ecalThresholds != nullptr) ? (*ecalThresholds)[eHitCPtr->detid()] : 0.f;
0199         if (energy <= rhThres)
0200           continue;
0201       } else {  // use thresholds from config
0202         if (et <= theThreshold_E || energy <= 3 * noiseRecHit(eHitCPtr->detid()))
0203           continue;
0204       }
0205 
0206       bool vetoHit = false;
0207       //! first check if the hit is inside the veto cone by dR-alone
0208       if (deltaR2 < std::pow(theDR_Veto_E, 2)) {
0209         LogDebug("RecoMuon|CaloExtractorByAssociator") << " >>> Veto ECAL hit: Calo deltaR2= " << deltaR2;
0210         LogDebug("RecoMuon|CaloExtractorByAssociator")
0211             << " >>> Calo eta phi ethcal: " << eHitPos.eta() << " " << eHitPos.phi() << " " << et;
0212         vetoHit = true;
0213       }
0214       //! and now pitch those in the crossed list
0215       if (!vetoHit) {
0216         for (unsigned int iH = 0; iH < mInfo.crossedEcalIds.size() && !vetoHit; ++iH) {
0217           if (mInfo.crossedEcalIds[iH].rawId() == eHitCPtr->detid().rawId())
0218             vetoHit = true;
0219         }
0220       }
0221 
0222       //check theDR_Max only here to keep vetoHits being added to the veto energy
0223       if (deltaR2 > std::pow(theDR_Max, 2) && !vetoHit)
0224         continue;
0225 
0226       if (vetoHit) {
0227         depEcal.addCandEnergy(et);
0228       } else {
0229         depEcal.addDeposit(reco::isodeposit::Direction(eHitPos.eta(), eHitPos.phi()), et);
0230       }
0231     }
0232   }
0233 
0234   if (theUseHcalRecHitsFlag) {
0235     //Hcal
0236     auto const& caloGeom = eventSetup.getData(caloGeomToken_);
0237     std::vector<const HBHERecHit*>::const_iterator hHitCI = mInfo.hcalRecHits.begin();
0238     for (; hHitCI != mInfo.hcalRecHits.end(); ++hHitCI) {
0239       const HBHERecHit* hHitCPtr = *hHitCI;
0240       GlobalPoint hHitPos = caloGeom.getPosition(hHitCPtr->detid());
0241       double deltaR2 = reco::deltaR2(muon, hHitPos);
0242       double cosTheta = 1. / cosh(hHitPos.eta());
0243       double energy = hHitCPtr->energy();
0244       double et = energy * cosTheta;
0245       if (deltaR2 > std::max(dRMax_CandDep * dRMax_CandDep, theDR_Max * theDR_Max))
0246         continue;
0247 
0248       // check Hcal Cuts from DB
0249       if (hcalCuts != nullptr) {
0250         const HcalPFCut* item = hcalCuts->getValues(hHitCPtr->id().rawId());
0251         if (energy <= item->noiseThreshold())
0252           continue;
0253       } else {
0254         if (et <= theThreshold_H || energy <= 3 * noiseRecHit(hHitCPtr->detid()))
0255           continue;
0256       }
0257 
0258       const HcalDetId hid(hHitCPtr->detid());
0259       DetId did = hcalTopology_->idFront(hid);
0260       const uint32_t flag = hHitCPtr->flags();
0261       const uint32_t dbflag = hcalChStatus_->getValues(did)->getValue();
0262       bool recovered = hcalSevLvlComputer_->recoveredRecHit(did, flag);
0263       int severity = hcalSevLvlComputer_->getSeverityLevel(did, flag, dbflag);
0264 
0265       const bool goodHB = hid.subdet() == HcalBarrel and (severity <= theMaxSeverityHB or recovered);
0266       const bool goodHE = hid.subdet() == HcalEndcap and (severity <= theMaxSeverityHE or recovered);
0267       if (!goodHB and !goodHE)
0268         continue;
0269 
0270       bool vetoHit = false;
0271       //! first check if the hit is inside the veto cone by dR-alone
0272       if (deltaR2 < std::pow(theDR_Veto_H, 2)) {
0273         LogDebug("RecoMuon|CaloExtractorByAssociator") << " >>> Veto HBHE hit: Calo deltaR2= " << deltaR2;
0274         LogDebug("RecoMuon|CaloExtractorByAssociator")
0275             << " >>> Calo eta phi ethcal: " << hHitPos.eta() << " " << hHitPos.phi() << " " << et;
0276         vetoHit = true;
0277       }
0278       //! and now pitch those in the crossed list
0279       if (!vetoHit) {
0280         for (unsigned int iH = 0; iH < mInfo.crossedHcalIds.size() && !vetoHit; ++iH) {
0281           if (mInfo.crossedHcalIds[iH].rawId() == hHitCPtr->detid().rawId())
0282             vetoHit = true;
0283         }
0284       }
0285 
0286       //check theDR_Max only here to keep vetoHits being added to the veto energy
0287       if (deltaR2 > std::pow(theDR_Max, 2) && !vetoHit)
0288         continue;
0289 
0290       if (vetoHit) {
0291         depHcal.addCandEnergy(et);
0292       } else {
0293         depHcal.addDeposit(reco::isodeposit::Direction(hHitPos.eta(), hHitPos.phi()), et);
0294       }
0295     }
0296   }
0297 
0298   if (theUseHORecHitsFlag) {
0299     //HOcal
0300     auto const& caloGeom = eventSetup.getData(caloGeomToken_);
0301     std::vector<const HORecHit*>::const_iterator hoHitCI = mInfo.hoRecHits.begin();
0302     for (; hoHitCI != mInfo.hoRecHits.end(); ++hoHitCI) {
0303       const HORecHit* hoHitCPtr = *hoHitCI;
0304       GlobalPoint hoHitPos = caloGeom.getPosition(hoHitCPtr->detid());
0305       double deltaR2 = reco::deltaR2(muon, hoHitPos);
0306       double cosTheta = 1. / cosh(hoHitPos.eta());
0307       double energy = hoHitCPtr->energy();
0308       double et = energy * cosTheta;
0309       if (deltaR2 > std::max(dRMax_CandDep * dRMax_CandDep, theDR_Max * theDR_Max) ||
0310           !(et > theThreshold_HO && energy > 3 * noiseRecHit(hoHitCPtr->detid())))
0311         continue;
0312 
0313       bool vetoHit = false;
0314       //! first check if the hit is inside the veto cone by dR-alone
0315       if (deltaR2 < std::pow(theDR_Veto_HO, 2)) {
0316         LogDebug("RecoMuon|CaloExtractorByAssociator") << " >>> Veto HO hit: Calo deltaR2= " << deltaR2;
0317         LogDebug("RecoMuon|CaloExtractorByAssociator")
0318             << " >>> Calo eta phi ethcal: " << hoHitPos.eta() << " " << hoHitPos.phi() << " " << et;
0319         vetoHit = true;
0320       }
0321       //! and now pitch those in the crossed list
0322       if (!vetoHit) {
0323         for (unsigned int iH = 0; iH < mInfo.crossedHOIds.size() && !vetoHit; ++iH) {
0324           if (mInfo.crossedHOIds[iH].rawId() == hoHitCPtr->detid().rawId())
0325             vetoHit = true;
0326         }
0327       }
0328 
0329       //check theDR_Max only here to keep vetoHits being added to the veto energy
0330       if (deltaR2 > std::pow(theDR_Max, 2) && !vetoHit)
0331         continue;
0332 
0333       if (vetoHit) {
0334         depHOcal.addCandEnergy(et);
0335       } else {
0336         depHOcal.addDeposit(reco::isodeposit::Direction(hoHitPos.eta(), hoHitPos.phi()), et);
0337       }
0338     }
0339   }
0340 
0341   if (!theUseEcalRecHitsFlag or !theUseHcalRecHitsFlag or !theUseHORecHitsFlag) {
0342     //! use calo towers
0343     std::vector<const CaloTower*>::const_iterator calCI = mInfo.towers.begin();
0344     for (; calCI != mInfo.towers.end(); ++calCI) {
0345       const CaloTower* calCPtr = *calCI;
0346       double deltaR2 = reco::deltaR2(muon, *calCPtr);
0347       if (deltaR2 > std::max(dRMax_CandDep * dRMax_CandDep, theDR_Max * theDR_Max))
0348         continue;
0349 
0350       //even more copy-pasting .. need to refactor
0351       double etecal = calCPtr->emEt();
0352       double eecal = calCPtr->emEnergy();
0353       bool doEcal = etecal > theThreshold_E && eecal > 3 * noiseEcal(*calCPtr);
0354       double ethcal = calCPtr->hadEt();
0355       double ehcal = calCPtr->hadEnergy();
0356       bool doHcal = ethcal > theThreshold_H && ehcal > 3 * noiseHcal(*calCPtr);
0357       double ethocal = calCPtr->outerEt();
0358       double ehocal = calCPtr->outerEnergy();
0359       bool doHOcal = ethocal > theThreshold_HO && ehocal > 3 * noiseHOcal(*calCPtr);
0360       if ((!doEcal) && (!doHcal) && (!doHcal))
0361         continue;
0362 
0363       bool vetoTowerEcal = false;
0364       double deltar2Ecal = reco::deltaR2(mInfo.trkGlobPosAtEcal, *calCPtr);
0365       //! first check if the tower is inside the veto cone by dR-alone
0366       if (deltar2Ecal < std::pow(theDR_Veto_E, 2)) {
0367         LogDebug("RecoMuon|CaloExtractorByAssociator") << " >>> Veto ecal tower: Calo deltaR= " << deltar2Ecal;
0368         LogDebug("RecoMuon|CaloExtractorByAssociator")
0369             << " >>> Calo eta phi ethcal: " << calCPtr->eta() << " " << calCPtr->phi() << " " << ethcal;
0370         vetoTowerEcal = true;
0371       }
0372       bool vetoTowerHcal = false;
0373       double deltar2Hcal = reco::deltaR2(mInfo.trkGlobPosAtHcal, *calCPtr);
0374       //! first check if the tower is inside the veto cone by dR-alone
0375       if (deltar2Hcal < std::pow(theDR_Veto_H, 2)) {
0376         LogDebug("RecoMuon|CaloExtractorByAssociator") << " >>> Veto hcal tower: Calo deltaR= " << deltar2Hcal;
0377         LogDebug("RecoMuon|CaloExtractorByAssociator")
0378             << " >>> Calo eta phi ethcal: " << calCPtr->eta() << " " << calCPtr->phi() << " " << ethcal;
0379         vetoTowerHcal = true;
0380       }
0381       bool vetoTowerHOCal = false;
0382       double deltar2HOcal = reco::deltaR2(mInfo.trkGlobPosAtHO, *calCPtr);
0383       //! first check if the tower is inside the veto cone by dR-alone
0384       if (deltar2HOcal < std::pow(theDR_Veto_HO, 2)) {
0385         LogDebug("RecoMuon|CaloExtractorByAssociator") << " >>> Veto HO tower: Calo deltaR= " << deltar2HOcal;
0386         LogDebug("RecoMuon|CaloExtractorByAssociator")
0387             << " >>> Calo eta phi ethcal: " << calCPtr->eta() << " " << calCPtr->phi() << " " << ethcal;
0388         vetoTowerHOCal = true;
0389       }
0390 
0391       //! and now pitch those in the crossed list
0392       if (!(vetoTowerHOCal && vetoTowerHcal && vetoTowerEcal)) {
0393         for (unsigned int iH = 0; iH < mInfo.crossedTowerIds.size(); ++iH) {
0394           if (mInfo.crossedTowerIds[iH].rawId() == calCPtr->id().rawId()) {
0395             vetoTowerEcal = true;
0396             vetoTowerHcal = true;
0397             vetoTowerHOCal = true;
0398             break;
0399           }
0400         }
0401       }
0402 
0403       if (deltaR2 > std::pow(theDR_Max, 2) && !(vetoTowerEcal || vetoTowerHcal || vetoTowerHOCal))
0404         continue;
0405 
0406       reco::isodeposit::Direction towerDir(calCPtr->eta(), calCPtr->phi());
0407       //! add the Et of the tower to deposits if it's not a vetoed; put into muonEnergy otherwise
0408       if (doEcal and !theUseEcalRecHitsFlag) {
0409         if (vetoTowerEcal)
0410           depEcal.addCandEnergy(etecal);
0411         else if (deltaR2 <= std::pow(theDR_Max, 2))
0412           depEcal.addDeposit(towerDir, etecal);
0413       }
0414       if (doHcal and !theUseHcalRecHitsFlag) {
0415         if (vetoTowerHcal)
0416           depHcal.addCandEnergy(ethcal);
0417         else if (deltaR2 <= std::pow(theDR_Max, 2))
0418           depHcal.addDeposit(towerDir, ethcal);
0419       }
0420       if (doHOcal and !theUseHORecHitsFlag) {
0421         if (vetoTowerHOCal)
0422           depHOcal.addCandEnergy(ethocal);
0423         else if (deltaR2 <= std::pow(theDR_Max, 2))
0424           depHOcal.addDeposit(towerDir, ethocal);
0425       }
0426     }
0427   }
0428 
0429   std::vector<IsoDeposit> resultDeps;
0430   resultDeps.push_back(depEcal);
0431   resultDeps.push_back(depHcal);
0432   resultDeps.push_back(depHOcal);
0433 
0434   return resultDeps;
0435 }
0436 
0437 double CaloExtractorByAssociator::noiseEcal(const CaloTower& tower) const {
0438   double noise = theNoiseTow_EB;
0439   double eta = tower.eta();
0440   if (fabs(eta) > 1.479)
0441     noise = theNoiseTow_EE;
0442   return noise;
0443 }
0444 
0445 double CaloExtractorByAssociator::noiseHcal(const CaloTower& tower) const {
0446   double noise = fabs(tower.eta()) > 1.479 ? theNoise_HE : theNoise_HB;
0447   return noise;
0448 }
0449 
0450 double CaloExtractorByAssociator::noiseHOcal(const CaloTower& tower) const {
0451   double noise = theNoise_HO;
0452   return noise;
0453 }
0454 
0455 double CaloExtractorByAssociator::noiseRecHit(const DetId& detId) const {
0456   double noise = 100;
0457   DetId::Detector det = detId.det();
0458   if (det == DetId::Ecal) {
0459     EcalSubdetector subDet = (EcalSubdetector)(detId.subdetId());
0460     if (subDet == EcalBarrel) {
0461       noise = theNoise_EB;
0462     } else if (subDet == EcalEndcap) {
0463       noise = theNoise_EE;
0464     }
0465   } else if (det == DetId::Hcal) {
0466     HcalSubdetector subDet = (HcalSubdetector)(detId.subdetId());
0467     if (subDet == HcalBarrel) {
0468       noise = theNoise_HB;
0469     } else if (subDet == HcalEndcap) {
0470       noise = theNoise_HE;
0471     } else if (subDet == HcalOuter) {
0472       noise = theNoise_HO;
0473     }
0474   }
0475   return noise;
0476 }