test
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 //
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 }
reco::TrackRef track() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:632
virtual double energy() const
energy
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:638
reco::GsfTrackRef gsfTrack() const
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:48
#define M_PI
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:788
Analysis-level muon class.
Definition: Muon.h:49
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
virtual ~CaloIsolationEnergy()
destructor