ATLAS Offline Software
Loading...
Searching...
No Matches
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
10namespace {
11constexpr float el_mass = ParticleConstants::electronMassInMeV;
12
13void
14setFromCluster(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.setPtEtaPhi(pt, eta, phi);
25 } else {
26 eg.setPtEtaPhi(E / cosh(eta), eta, phi);
27 }
28}
29
30void
31setFromTrkCluster(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.setPtEtaPhi(pt, eta, phi);
45}
46
47void
48setFromTrkCluster(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.setPtEtaPhi(E / cosh(eta), eta, phi);
60}
61}
62
64
65namespace EMFourMomBuilder
66{
67void
69 if (electron.trackParticle()) {
70 return setFromTrkCluster(electron);
71 } else {
72 setFromCluster(electron);
73 }
74}
75
76void
80 setFromTrkCluster(photon);
81 } else {
82 setFromCluster(photon);
83 }
84}
85}
86
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
A number of constexpr particle constants to avoid hardcoding them directly in various places.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
void setPtEtaPhi(float pt, float eta, float phi)
set the 4-vec
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Eigen::Matrix< double, 3, 1 > Vector3D
void calculate(xAOD::Electron &electron)
constexpr double electronMassInMeV
the mass of the electron (in MeV)
@ Electron
The object is an electron.
Definition ObjectType.h:46
Amg::Vector3D momentumAtVertex(const xAOD::Photon *, bool debug=false)
return the momentum at the vertex (which can be 0)
xAOD::EgammaParameters::ConversionType conversionType(const xAOD::Photon *ph)
return the photon conversion type (see EgammaEnums)
std::size_t numberOfSiHits(const xAOD::TrackParticle *tp)
return the number of Si hits in the track particle
@ doubleSi
two tracks, both with Si hits
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".