CMS 3D CMS Logo

CaloIsolationEnergy.cc
Go to the documentation of this file.
1 //
2 //
3 
12 #include <vector>
13 
14 using namespace pat;
15 
18 }
19 
22 }
23 
25 float CaloIsolationEnergy::calculate(const Electron & theElectron, const std::vector<CaloTower> & theTowers, float isoConeElectron) const {
26  float isoE = this->calculate(*theElectron.gsfTrack(), theElectron.energy(), theTowers, isoConeElectron);
27  return isoE - theElectron.caloEnergy();
28 }
29 float CaloIsolationEnergy::calculate(const Muon & theMuon, const std::vector<CaloTower> & theTowers, float isoConeMuon) const {
30  return this->calculate(*theMuon.track(), theMuon.energy(), theTowers, isoConeMuon);
31 }
32 
33 
35 float CaloIsolationEnergy::calculate(const reco::Track & theTrack, const float leptonEnergy, const std::vector<CaloTower> & theTowers, float isoCone) const {
36  float isoELepton = 0;
37  // calculate iso energy
38  //const CaloTower * closestTower = 0;
39  float closestDR = 10000;
40  for (std::vector<CaloTower>::const_iterator itTower = theTowers.begin(); itTower != theTowers.end(); itTower++) {
41  // calculate dPhi with correct sign
42  float dPhi = theTrack.phi() - itTower->phi();
43  if (dPhi > M_PI) dPhi = -2*M_PI + dPhi;
44  if (dPhi < -M_PI) dPhi = 2*M_PI + dPhi;
45  // calculate dR
46  float dR = sqrt(std::pow(theTrack.eta()-itTower->eta(), 2) + std::pow(dPhi, 2));
47  // calculate energy in cone around direction at vertex of the track
48  if (dR < isoCone) {
49  isoELepton += itTower->energy();
50  if (dR < closestDR) {
51  closestDR = dR;
52  //closestTower = &(*itTower);
53  }
54  }
55  }
56  // subtract track deposits from total energy in cone
57 // if (closestTower) isoELepton -= closestTower->energy();
58  // return the iso energy
59  return isoELepton;
60 }
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:678
reco::TrackRef track() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: HeavyIon.h:7
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:684
Definition: Muon.py:1
T sqrt(T t)
Definition: SSEVec.h:18
double energy() const final
energy
#define M_PI
float calculate(const Electron &anElectron, const std::vector< CaloTower > &theTowers, float isoConeElectron=0.3) const
calculate the CalIsoE from the lepton object
reco::GsfTrackRef gsfTrack() const override
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
float caloEnergy() const
Definition: GsfElectron.h:862
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
virtual ~CaloIsolationEnergy()
destructor