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 }
MessageLogger.h
CaloTower.h
ESHandle.h
Electron
Definition: Electron.py:1
Muon.h
pat::CaloIsolationEnergy::~CaloIsolationEnergy
virtual ~CaloIsolationEnergy()
destructor
Definition: CaloIsolationEnergy.cc:20
pat::Electron::gsfTrack
reco::GsfTrackRef gsfTrack() const override
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster
HLT_FULL_cff.dPhi
dPhi
Definition: HLT_FULL_cff.py:13695
Muon
Definition: Muon.py:1
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::Track
Definition: Track.h:27
CaloIsolationEnergy.h
reco::TrackBase::phi
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:649
reco::TrackBase::eta
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
GsfTrack.h
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
pat::Muon::track
reco::TrackRef track() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon)
pat
Definition: HeavyIon.h:7
pat::CaloIsolationEnergy::calculate
float calculate(const Electron &anElectron, const std::vector< CaloTower > &theTowers, float isoConeElectron=0.3) const
calculate the CalIsoE from the lepton object
Definition: CaloIsolationEnergy.cc:23
Exception.h
reco::LeafCandidate::energy
double energy() const final
energy
Definition: LeafCandidate.h:125
Electron.h
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
pat::CaloIsolationEnergy::CaloIsolationEnergy
CaloIsolationEnergy()
constructor
Definition: CaloIsolationEnergy.cc:17
reco::GsfElectron::caloEnergy
float caloEnergy() const
Definition: GsfElectron.h:886