Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "RecoMuon/MuonIsolation/interface/IsolatorByDeposit.h"
0002 
0003 using reco::IsoDeposit;
0004 using std::vector;
0005 using namespace muonisolation;
0006 
0007 IsolatorByDeposit::IsolatorByDeposit(float conesize, const vector<double>& weights)
0008     : theConeSizeFunction(nullptr), theConeSize(conesize), theWeights(weights) {
0009   theDepThresholds = std::vector<double>(weights.size(), -1e12);
0010 }
0011 
0012 IsolatorByDeposit::IsolatorByDeposit(const ConeSizeFunction* conesize, const vector<double>& weights)
0013     : theConeSizeFunction(conesize), theConeSize(0.), theWeights(weights) {
0014   theDepThresholds = std::vector<double>(weights.size(), -1e12);
0015 }
0016 
0017 IsolatorByDeposit::IsolatorByDeposit(float conesize, const vector<double>& weights, const vector<double>& dThresh)
0018     : theConeSizeFunction(nullptr), theConeSize(conesize), theWeights(weights), theDepThresholds(dThresh) {}
0019 
0020 IsolatorByDeposit::IsolatorByDeposit(const ConeSizeFunction* conesize,
0021                                      const vector<double>& weights,
0022                                      const vector<double>& dThresh)
0023     : theConeSizeFunction(conesize), theConeSize(0.), theWeights(weights), theDepThresholds(dThresh) {}
0024 
0025 MuIsoBaseIsolator::Result IsolatorByDeposit::result(const DepositContainer& deposits, const edm::Event*) const {
0026   if (deposits.empty())
0027     return Result(resultType());
0028 
0029   // To determine the threshold, the direction of the cone of the first
0030   // set of deposits is used.
0031   // For algorithms where different cone axis definitions are used
0032   // for different types deposits (eg. HCAL and ECAL deposits for
0033   // calorimeter isolation), the first one is used to determine the threshold
0034   // value!
0035   float eta = deposits.front().dep->eta();
0036   float pt = deposits.front().dep->candEnergy();
0037   float dr = coneSize(eta, pt);
0038   float sumDep = weightedSum(deposits, dr);
0039 
0040   Result res(resultType());
0041   res.valFloat = sumDep;
0042   return res;
0043 }
0044 
0045 double IsolatorByDeposit::weightedSum(const DepositContainer& deposits, float dRcone) const {
0046   double sumDep = 0;
0047 
0048   assert(deposits.size() == theWeights.size());
0049 
0050   vector<double>::const_iterator w = theWeights.begin();
0051   vector<double>::const_iterator dThresh = theDepThresholds.begin();
0052 
0053   typedef DepositContainer::const_iterator DI;
0054   for (DI dep = deposits.begin(), depEnd = deposits.end(); dep != depEnd; ++dep) {
0055     if (dep->vetos != nullptr) {
0056       sumDep += dep->dep->depositAndCountWithin(dRcone, *dep->vetos, (*dThresh)).first * (*w);
0057     } else {
0058       sumDep += dep->dep->depositAndCountWithin(dRcone, Vetos(), (*dThresh)).first * (*w);
0059     }
0060     //  cout << "IsolatorByDeposit: type = " << (*dep)->type() << " weight = " << (*w) << endl;
0061     w++;
0062     dThresh++;
0063   }
0064   return sumDep;
0065 }