Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:34

0001 #ifndef IsolationUtils_PtIsolationAlgo_h
0002 #define IsolationUtils_PtIsolationAlgo_h
0003 /* \class PtIsolationAlgo<T, C>
0004  *
0005  * \author Francesco Fabozzi, INFN
0006  */
0007 #include "DataFormats/Math/interface/deltaR.h"
0008 
0009 template <typename T, typename C>
0010 class PtIsolationAlgo {
0011 public:
0012   typedef double value_type;
0013   PtIsolationAlgo() {}
0014   PtIsolationAlgo(double dRMin, double dRMax, double dzMax, double d0Max, double ptMin)
0015       : dRMin_(dRMin), dRMax_(dRMax), dzMax_(dzMax), d0Max_(d0Max), ptMin_(ptMin) {}
0016   double operator()(const T &, const C &) const;
0017 
0018 private:
0019   double dRMin_, dRMax_, dzMax_, d0Max_, ptMin_;
0020 };
0021 
0022 template <typename T, typename C>
0023 double PtIsolationAlgo<T, C>::operator()(const T &cand, const C &elements) const {
0024   double ptSum = 0;
0025   double candVz = cand.vz();
0026   double candEta = cand.eta();
0027   double candPhi = cand.phi();
0028   for (typename C::const_iterator elem = elements.begin(); elem != elements.end(); ++elem) {
0029     double elemPt = elem->pt();
0030     if (elemPt < ptMin_)
0031       continue;
0032     double elemVx = elem->vx();
0033     double elemVy = elem->vy();
0034     double elemD0 = sqrt(elemVx * elemVx + elemVy * elemVy);
0035     if (elemD0 > d0Max_)
0036       continue;
0037     double dz = fabs(elem->vz() - candVz);
0038     if (dz > dzMax_)
0039       continue;
0040     double dR = deltaR(elem->eta(), elem->phi(), candEta, candPhi);
0041     if ((dR > dRMax_) || (dR < dRMin_))
0042       continue;
0043     ptSum += elemPt;
0044   }
0045   return ptSum;
0046 }
0047 
0048 #endif