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 
9 
10 namespace {
11 constexpr float el_mass = ParticleConstants::electronMassInMeV;
12 constexpr float ph_mass = 0.0;
13 
14 void
15 setFromCluster(xAOD::Egamma& eg)
16 {
17 
18  const xAOD::CaloCluster* cluster = eg.caloCluster();
19  const float eta = cluster->eta();
20  const float phi = cluster->phi();
21  const float E = cluster->e();
22  if (eg.type() == xAOD::Type::Electron) {
23  const double pt =
24  E > el_mass ? sqrt(E * E - el_mass * el_mass) / cosh(eta) : 0;
25  eg.setP4(pt, eta, phi, el_mass);
26  } else {
27  eg.setP4(E / cosh(eta), eta, phi, ph_mass);
28  }
29 }
30 
31 void
32 setFromTrkCluster(xAOD::Electron& el)
33 {
34 
35  const xAOD::CaloCluster* cluster = el.caloCluster();
36  const xAOD::TrackParticle* trackParticle = el.trackParticle();
37 
38  bool goodTrack = (xAOD::EgammaHelpers::numberOfSiHits(trackParticle) >= 4);
39  const float E = cluster->e();
40  const float eta = goodTrack ? trackParticle->eta() : cluster->eta();
41  const float phi = goodTrack ? trackParticle->phi() : cluster->phi();
42 
43  const double pt =
44  E > el_mass ? sqrt(E * E - el_mass * el_mass) / cosh(eta) : 0;
45  el.setP4(pt, eta, phi, el_mass);
46 }
47 
48 void
49 setFromTrkCluster(xAOD::Photon& ph)
50 {
51  const xAOD::CaloCluster* cluster = ph.caloCluster();
52  float E = cluster->e();
53  float eta = cluster->eta();
54  float phi = cluster->phi();
56  if (momentumAtVertex.mag() > 1e-5) { // protection against p = 0
57  eta = momentumAtVertex.eta();
58  phi = momentumAtVertex.phi();
59  }
60  ph.setP4(E / cosh(eta), eta, phi, ph_mass);
61 }
62 }
63 
65 
66 namespace EMFourMomBuilder
67 {
68 void
70  if (electron.trackParticle()) {
71  return setFromTrkCluster(electron);
72  } else {
73  setFromCluster(electron);
74  }
75 }
76 
77 void
81  setFromTrkCluster(photon);
82  } else {
83  setFromCluster(photon);
84  }
85 }
86 }
87 
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
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:67
ParticleTest.eg
eg
Definition: ParticleTest.py:29
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
xAOD::TrackParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TrackParticle_v1.cxx:78
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:62
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
ParticleConstants.h
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:70
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:69
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
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:200
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:21
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 .)
ParticleConstants::PDG2011::electronMassInMeV
constexpr double electronMassInMeV
the mass of the electron (in MeV)
Definition: ParticleConstants.h:26