CMS 3D CMS Logo

PtIsolationAlgo.h
Go to the documentation of this file.
1 #ifndef IsolationUtils_PtIsolationAlgo_h
2 #define IsolationUtils_PtIsolationAlgo_h
3 /* \class PtIsolationAlgo<T, C>
4  *
5  * \author Francesco Fabozzi, INFN
6  */
8 
9 template <typename T, typename C>
11 public:
12  typedef double value_type;
14  PtIsolationAlgo( double dRMin, double dRMax, double dzMax,
15  double d0Max, double ptMin ) :
16  dRMin_( dRMin ), dRMax_( dRMax ), dzMax_( dzMax ),
17  d0Max_( d0Max ), ptMin_( ptMin ) { }
18  double operator()(const T &, const C &) const;
19 
20 private:
22 };
23 
24 template <typename T, typename C>
25 double PtIsolationAlgo<T, C>::operator()(const T & cand, const C & elements) const {
26  double ptSum = 0;
27  double candVz = cand.vz();
28  double candEta = cand.eta();
29  double candPhi = cand.phi();
30  for( typename C::const_iterator elem = elements.begin(); elem != elements.end(); ++ elem ) {
31  double elemPt = elem->pt();
32  if ( elemPt < ptMin_ ) continue;
33  double elemVx = elem->vx();
34  double elemVy = elem->vy();
35  double elemD0 = sqrt( elemVx * elemVx + elemVy * elemVy );
36  if ( elemD0 > d0Max_ ) continue;
37  double dz = fabs( elem->vz() - candVz );
38  if ( dz > dzMax_ ) continue;
39  double dR = deltaR( elem->eta(), elem->phi(), candEta, candPhi );
40  if ( (dR > dRMax_) || (dR < dRMin_) ) continue;
41  ptSum += elemPt;
42  }
43  return ptSum;
44 }
45 
46 #endif
double operator()(const T &, const C &) const
PtIsolationAlgo(double dRMin, double dRMax, double dzMax, double d0Max, double ptMin)
T sqrt(T t)
Definition: SSEVec.h:18
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:18
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
long double T