CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/RecoMuon/MuonIsolation/src/IsolatorByDeposit.cc

Go to the documentation of this file.
00001 #include "RecoMuon/MuonIsolation/interface/IsolatorByDeposit.h"
00002 
00003 using std::vector;
00004 using reco::IsoDeposit;
00005 using namespace muonisolation;
00006 
00007 IsolatorByDeposit::IsolatorByDeposit(float conesize, const vector<double>& weights) 
00008   : theConeSizeFunction(0), theConeSize(conesize), theWeights(weights)
00009 { 
00010   theDepThresholds = std::vector<double>(weights.size(), -1e12);
00011 }
00012 
00013 IsolatorByDeposit::IsolatorByDeposit(const ConeSizeFunction * conesize, const vector<double>& weights) 
00014   : theConeSizeFunction(conesize), theConeSize(0.), theWeights(weights)
00015 { 
00016   theDepThresholds = std::vector<double>(weights.size(), -1e12);
00017 }
00018 
00019 IsolatorByDeposit::IsolatorByDeposit(float conesize, const vector<double>& weights, const vector<double>& dThresh) 
00020   : theConeSizeFunction(0), theConeSize(conesize), theWeights(weights),
00021     theDepThresholds(dThresh)
00022 { }
00023 
00024 IsolatorByDeposit::IsolatorByDeposit(const ConeSizeFunction * conesize, 
00025                                      const vector<double>& weights, const vector<double>& dThresh) 
00026   : theConeSizeFunction(conesize), theConeSize(0.), theWeights(weights),
00027     theDepThresholds(dThresh)
00028 { }
00029 
00030 MuIsoBaseIsolator::Result IsolatorByDeposit::result(const DepositContainer& deposits, const edm::Event*) const{
00031   if (deposits.empty()) return Result(resultType());
00032 
00033   // To determine the threshold, the direction of the cone of the first
00034   // set of deposits is used.
00035   // For algorithms where different cone axis definitions are used
00036   // for different types deposits (eg. HCAL and ECAL deposits for
00037   // calorimeter isolation), the first one is used to determine the threshold
00038   // value!
00039   float eta = deposits.front().dep->eta();
00040   float pt = deposits.front().dep->candEnergy();
00041   float dr= coneSize(eta,pt);
00042   float sumDep = weightedSum(deposits,dr);
00043 
00044 
00045   Result res(resultType()); 
00046   res.valFloat = sumDep;
00047   return res;
00048 }
00049 
00050 double
00051 IsolatorByDeposit::weightedSum(const DepositContainer& deposits,
00052                                float dRcone) const {
00053   double sumDep=0;
00054 
00055   assert(deposits.size()==theWeights.size());
00056 
00057   vector<double>::const_iterator w = theWeights.begin();
00058   vector<double>::const_iterator dThresh = theDepThresholds.begin();
00059 
00060   typedef DepositContainer::const_iterator DI;
00061   for (DI dep = deposits.begin(), depEnd = deposits.end(); dep != depEnd; ++dep) {
00062     if (dep->vetos != 0){
00063       sumDep += dep->dep->depositAndCountWithin(dRcone, *dep->vetos, (*dThresh)).first * (*w);
00064     } else {
00065       sumDep += dep->dep->depositAndCountWithin(dRcone, Vetos(), (*dThresh)).first * (*w);
00066     }
00067 //  cout << "IsolatorByDeposit: type = " << (*dep)->type() << " weight = " << (*w) << endl;
00068     w++;
00069     dThresh++;
00070   }
00071   return sumDep;
00072 }