Go to the documentation of this file.00001 #ifndef IsolationUtils_PtIsolationAlgo_h
00002 #define IsolationUtils_PtIsolationAlgo_h
00003
00004
00005
00006
00007 #include "DataFormats/Math/interface/deltaR.h"
00008
00009 template <typename T, typename C>
00010 class PtIsolationAlgo {
00011 public:
00012 typedef double value_type;
00013 PtIsolationAlgo() { }
00014 PtIsolationAlgo( double dRMin, double dRMax, double dzMax,
00015 double d0Max, double ptMin ) :
00016 dRMin_( dRMin ), dRMax_( dRMax ), dzMax_( dzMax ),
00017 d0Max_( d0Max ), ptMin_( ptMin ) { }
00018 double operator()(const T &, const C &) const;
00019
00020 private:
00021 double dRMin_, dRMax_, dzMax_, d0Max_, ptMin_;
00022 };
00023
00024 template <typename T, typename C>
00025 double PtIsolationAlgo<T, C>::operator()(const T & cand, const C & elements) const {
00026 double ptSum = 0;
00027 double candVz = cand.vz();
00028 double candEta = cand.eta();
00029 double candPhi = cand.phi();
00030 for( typename C::const_iterator elem = elements.begin(); elem != elements.end(); ++ elem ) {
00031 double elemPt = elem->pt();
00032 if ( elemPt < ptMin_ ) continue;
00033 double elemVx = elem->vx();
00034 double elemVy = elem->vy();
00035 double elemD0 = sqrt( elemVx * elemVx + elemVy * elemVy );
00036 if ( elemD0 > d0Max_ ) continue;
00037 double dz = fabs( elem->vz() - candVz );
00038 if ( dz > dzMax_ ) continue;
00039 double dR = deltaR( elem->eta(), elem->phi(), candEta, candPhi );
00040 if ( (dR > dRMax_) || (dR < dRMin_) ) continue;
00041 ptSum += elemPt;
00042 }
00043 return ptSum;
00044 }
00045
00046 #endif