CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloIsolationEnergy.cc
Go to the documentation of this file.
1 //
2 // $Id: CaloIsolationEnergy.cc,v 1.4 2011/11/01 23:35:45 gowdy Exp $
3 //
4 
13 #include <vector>
14 
15 using namespace pat;
16 
19 }
20 
23 }
24 
26 float CaloIsolationEnergy::calculate(const Electron & theElectron, const std::vector<CaloTower> & theTowers, float isoConeElectron) const {
27  float isoE = this->calculate(*theElectron.gsfTrack(), theElectron.energy(), theTowers, isoConeElectron);
28  return isoE - theElectron.caloEnergy();
29 }
30 float CaloIsolationEnergy::calculate(const Muon & theMuon, const std::vector<CaloTower> & theTowers, float isoConeMuon) const {
31  return this->calculate(*theMuon.track(), theMuon.energy(), theTowers, isoConeMuon);
32 }
33 
34 
36 float CaloIsolationEnergy::calculate(const reco::Track & theTrack, const float leptonEnergy, const std::vector<CaloTower> & theTowers, float isoCone) const {
37  float isoELepton = 0;
38  // calculate iso energy
39  //const CaloTower * closestTower = 0;
40  float closestDR = 10000;
41  for (std::vector<CaloTower>::const_iterator itTower = theTowers.begin(); itTower != theTowers.end(); itTower++) {
42  // calculate dPhi with correct sign
43  float dPhi = theTrack.phi() - itTower->phi();
44  if (dPhi > M_PI) dPhi = -2*M_PI + dPhi;
45  if (dPhi < -M_PI) dPhi = 2*M_PI + dPhi;
46  // calculate dR
47  float dR = sqrt(std::pow(theTrack.eta()-itTower->eta(), 2) + std::pow(dPhi, 2));
48  // calculate energy in cone around direction at vertex of the track
49  if (dR < isoCone) {
50  isoELepton += itTower->energy();
51  if (dR < closestDR) {
52  closestDR = dR;
53  //closestTower = &(*itTower);
54  }
55  }
56  }
57  // subtract track deposits from total energy in cone
58 // if (closestTower) isoELepton -= closestTower->energy();
59  // return the iso energy
60  return isoELepton;
61 }
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:139
reco::GsfTrackRef gsfTrack() const
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
Definition: Electron.cc:131
virtual double energy() const
energy
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:141
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:46
#define M_PI
Definition: BFit3D.cc:3
Analysis-level electron class.
Definition: Electron.h:52
float calculate(const Electron &anElectron, const std::vector< CaloTower > &theTowers, float isoConeElectron=0.3) const
calculate the CalIsoE from the lepton object
float caloEnergy() const
Definition: GsfElectron.h:727
Analysis-level muon class.
Definition: Muon.h:51
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
virtual ~CaloIsolationEnergy()
destructor
reco::TrackRef track() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:156