File indexing completed on 2024-04-06 12:23:30
0001 #ifndef IsolationUtils_CalIsolationAlgo_h
0002 #define IsolationUtils_CalIsolationAlgo_h
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0012 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0013 #include "DataFormats/Math/interface/deltaR.h"
0014 #include "PhysicsTools/IsolationAlgos/interface/PropagateToCal.h"
0015
0016 template <typename T1, typename C2>
0017 class CalIsolationAlgo {
0018 public:
0019 typedef double value_type;
0020 CalIsolationAlgo() {}
0021 CalIsolationAlgo(
0022 double dRMin, double dRMax, bool do_propagation, double radius, double minZ, double maxZ, bool theIgnoreMaterial)
0023 : dRMin_(dRMin),
0024 dRMax_(dRMax),
0025 do_propagation_(do_propagation),
0026 SrcAtCal(radius, minZ, maxZ, theIgnoreMaterial) {}
0027 ~CalIsolationAlgo();
0028
0029 void setBfield(const MagneticField *bField) { bField_ = bField; }
0030 double operator()(const T1 &, const C2 &) const;
0031
0032 private:
0033 double dRMin_, dRMax_;
0034 bool do_propagation_;
0035 const MagneticField *bField_;
0036 PropagateToCal SrcAtCal;
0037 };
0038
0039 template <typename T1, typename C2>
0040 CalIsolationAlgo<T1, C2>::~CalIsolationAlgo() {}
0041
0042 template <typename T1, typename C2>
0043 double CalIsolationAlgo<T1, C2>::operator()(const T1 &cand, const C2 &elements) const {
0044 const GlobalPoint Vertex(cand.vx(), cand.vy(), cand.vz());
0045
0046 GlobalVector Cand(cand.px(), cand.py(), cand.pz());
0047
0048
0049
0050 if (do_propagation_ && cand.charge() != 0)
0051 SrcAtCal.propagate(Vertex, Cand, cand.charge(), bField_);
0052
0053 double etSum = 0;
0054 for (typename C2::const_iterator elem = elements.begin(); elem != elements.end(); ++elem) {
0055 double dR = deltaR(elem->eta(), elem->phi(), (double)Cand.eta(), (double)Cand.phi());
0056 if (dR < dRMax_ && dR > dRMin_) {
0057 etSum += elem->et();
0058 }
0059 }
0060 return etSum;
0061 }
0062
0063 #endif