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 
21 
23 float CaloIsolationEnergy::calculate(const Electron& theElectron,
24  const std::vector<CaloTower>& theTowers,
25  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,
30  const std::vector<CaloTower>& theTowers,
31  float isoConeMuon) const {
32  return this->calculate(*theMuon.track(), theMuon.energy(), theTowers, isoConeMuon);
33 }
34 
37  const float leptonEnergy,
38  const std::vector<CaloTower>& theTowers,
39  float isoCone) const {
40  float isoELepton = 0;
41  // calculate iso energy
42  //const CaloTower * closestTower = 0;
43  float closestDR = 10000;
44  for (std::vector<CaloTower>::const_iterator itTower = theTowers.begin(); itTower != theTowers.end(); itTower++) {
45  // calculate dPhi with correct sign
46  float dPhi = theTrack.phi() - itTower->phi();
47  if (dPhi > M_PI)
48  dPhi = -2 * M_PI + dPhi;
49  if (dPhi < -M_PI)
50  dPhi = 2 * M_PI + dPhi;
51  // calculate dR
52  float dR = sqrt(std::pow(theTrack.eta() - itTower->eta(), 2) + std::pow(dPhi, 2));
53  // calculate energy in cone around direction at vertex of the track
54  if (dR < isoCone) {
55  isoELepton += itTower->energy();
56  if (dR < closestDR) {
57  closestDR = dR;
58  //closestTower = &(*itTower);
59  }
60  }
61  }
62  // subtract track deposits from total energy in cone
63  // if (closestTower) isoELepton -= closestTower->energy();
64  // return the iso energy
65  return isoELepton;
66 }
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:614
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:617
Definition: Muon.py:1
T sqrt(T t)
Definition: SSEVec.h:19
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:815
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
virtual ~CaloIsolationEnergy()
destructor