ATLAS Offline Software
EMFourMomBuilder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3  */
4 
8 
9 namespace {
10 constexpr float el_mass = 0.510998;
11 constexpr float ph_mass = 0.0;
12 
13 void
14 setFromCluster(xAOD::Egamma& eg)
15 {
16 
17  const xAOD::CaloCluster* cluster = eg.caloCluster();
18  const float eta = cluster->eta();
19  const float phi = cluster->phi();
20  const float E = cluster->e();
21  if (eg.type() == xAOD::Type::Electron) {
22  const double pt =
23  E > el_mass ? sqrt(E * E - el_mass * el_mass) / cosh(eta) : 0;
24  eg.setP4(pt, eta, phi, el_mass);
25  } else {
26  eg.setP4(E / cosh(eta), eta, phi, ph_mass);
27  }
28 }
29 
30 void
31 setFromTrkCluster(xAOD::Electron& el)
32 {
33 
34  const xAOD::CaloCluster* cluster = el.caloCluster();
35  const xAOD::TrackParticle* trackParticle = el.trackParticle();
36 
37  bool goodTrack = (xAOD::EgammaHelpers::numberOfSiHits(trackParticle) >= 4);
38  const float E = cluster->e();
39  const float eta = goodTrack ? trackParticle->eta() : cluster->eta();
40  const float phi = goodTrack ? trackParticle->phi() : cluster->phi();
41 
42  const double pt =
43  E > el_mass ? sqrt(E * E - el_mass * el_mass) / cosh(eta) : 0;
44  el.setP4(pt, eta, phi, el_mass);
45 }
46 
47 void
48 setFromTrkCluster(xAOD::Photon& ph)
49 {
50  const xAOD::CaloCluster* cluster = ph.caloCluster();
51  float E = cluster->e();
52  float eta = cluster->eta();
53  float phi = cluster->phi();
55  if (momentumAtVertex.mag() > 1e-5) { // protection against p = 0
56  eta = momentumAtVertex.eta();
57  phi = momentumAtVertex.phi();
58  }
59  ph.setP4(E / cosh(eta), eta, phi, ph_mass);
60 }
61 }
62 
64 
65 namespace EMFourMomBuilder
66 {
67 void
69  if (electron.trackParticle()) {
70  return setFromTrkCluster(electron);
71  } else {
72  setFromCluster(electron);
73  }
74 }
75 
76 void
80  setFromTrkCluster(photon);
81  } else {
82  setFromCluster(photon);
83  }
84 }
85 }
86 
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
EMFourMomBuilder
Definition: EMFourMomBuilder.h:22
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
ParticleTest.eg
eg
Definition: ParticleTest.py:29
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
xAOD::TrackParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TrackParticle_v1.cxx:77
test_pyathena.pt
pt
Definition: test_pyathena.py:11
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
EgammaxAODHelpers.h
xAOD::Egamma_v1::setP4
void setP4(float pt, float eta, float phi, float m)
set the 4-vec
Definition: Egamma_v1.cxx:104
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
xAOD::Egamma_v1::caloCluster
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
Definition: Egamma_v1.cxx:388
xAOD::EgammaHelpers::momentumAtVertex
Amg::Vector3D momentumAtVertex(const xAOD::Photon *, bool debug=false)
return the momentum at the vertex (which can be 0)
Definition: PhotonxAODHelpers.cxx:88
xAOD::EgammaParameters::doubleSi
@ doubleSi
two tracks, both with Si hits
Definition: EgammaEnums.h:279
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
EMFourMomBuilder.h
EventPrimitives.h
EMFourMomBuilder::calculate
void calculate(xAOD::Electron &electron)
Definition: EMFourMomBuilder.cxx:68
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
xAOD::EgammaHelpers::numberOfSiHits
std::size_t numberOfSiHits(const xAOD::TrackParticle *tp)
return the number of Si hits in the track particle
Definition: ElectronxAODHelpers.cxx:66
xAOD::Electron_v1
Definition: Electron_v1.h:34
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:199
xAOD::Photon_v1
Definition: Photon_v1.h:37
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
xAOD::EgammaHelpers::conversionType
xAOD::EgammaParameters::ConversionType conversionType(const xAOD::Photon *ph)
return the photon conversion type (see EgammaEnums)
Definition: PhotonxAODHelpers.cxx:26
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
xAOD::CaloCluster_v1::e
virtual double e() const
The total energy of the particle.
Definition: CaloCluster_v1.cxx:265
xAOD::TrackParticle_v1::phi
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)