CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/PhysicsTools/IsolationAlgos/interface/CalIsolationAlgo.h

Go to the documentation of this file.
00001 #ifndef IsolationUtils_CalIsolationAlgo_h
00002 #define IsolationUtils_CalIsolationAlgo_h
00003 /* \class CalIsolationAlgo<T1, C2>
00004  *
00005  * \author Christian Autermann, U Hamburg
00006  *
00007  * template class to calculate calorimeter isolation, the extrapolation
00008  * to the calorimeter surface is optional.
00009  *
00010  */
00011 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00012 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00013 #include "DataFormats/Math/interface/deltaR.h"
00014 #include "PhysicsTools/IsolationAlgos/interface/PropagateToCal.h"
00015 
00016 template <typename T1, typename C2>
00017 class CalIsolationAlgo {
00018 public:
00019   typedef double value_type;
00020   CalIsolationAlgo( ) { }
00021   CalIsolationAlgo(double dRMin, double dRMax, bool do_propagation,
00022                    double radius, double minZ, double maxZ, bool theIgnoreMaterial):
00023      dRMin_( dRMin ), dRMax_( dRMax ), do_propagation_( do_propagation ),
00024      SrcAtCal(radius, minZ, maxZ, theIgnoreMaterial) { }
00025   ~CalIsolationAlgo();
00026   
00027   void setBfield( const MagneticField * bField ) {
00028        bField_ = bField;  }
00029   double operator()(const T1 &, const C2 &) const;
00030 
00031 private:
00032   double dRMin_, dRMax_;
00033   bool   do_propagation_;
00034   const MagneticField * bField_;
00035   PropagateToCal SrcAtCal;
00036 };
00037 
00038 
00039 template <typename T1, typename C2>
00040 CalIsolationAlgo<T1,C2>::~CalIsolationAlgo() {
00041 }
00042 
00043 template <typename T1, typename C2> double CalIsolationAlgo<T1,C2>::
00044 operator()(const T1 & cand, const C2 & elements) const {
00045   const GlobalPoint Vertex(cand.vx(), cand.vy(), cand.vz());//@@check if this is [cm]!
00046   //GlobalVector Cand(cand.pt(), cand.eta(), cand.phi()); 
00047   GlobalVector Cand(cand.px(), cand.py(), cand.pz()); 
00048 
00051   if (do_propagation_ && cand.charge()!=0) 
00052      SrcAtCal.propagate(Vertex, Cand, cand.charge(), bField_);
00053 
00054   double etSum = 0;
00055   for( typename C2::const_iterator elem = elements.begin(); 
00056        elem != elements.end(); ++elem ) {
00057     double dR = deltaR( elem->eta(), elem->phi(), 
00058                         (double)Cand.eta(), (double)Cand.phi() );
00059     if ( dR < dRMax_ && dR > dRMin_ ) {
00060       etSum += elem->et();
00061     }
00062   }
00063   return etSum;
00064 }
00065 
00066 #endif