Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
Track.cc
Go to the documentation of this file.
1
9#include "Objects/Track.h"
10
11#include <algorithm>
12#include <cmath>
13
14namespace pandora
15{
16
18{
20 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
21
23}
24
25//------------------------------------------------------------------------------------------------------------------------------------------
26
27bool Track::operator< (const Track &rhs) const
28{
29 const CartesianVector deltaPosition(rhs.GetTrackStateAtCalorimeter().GetPosition() - this->GetTrackStateAtCalorimeter().GetPosition());
30
31 if (std::fabs(deltaPosition.GetZ()) > std::numeric_limits<float>::epsilon())
32 return (deltaPosition.GetZ() > std::numeric_limits<float>::epsilon());
33
34 if (std::fabs(deltaPosition.GetX()) > std::numeric_limits<float>::epsilon())
35 return (deltaPosition.GetX() > std::numeric_limits<float>::epsilon());
36
37 if (std::fabs(deltaPosition.GetY()) > std::numeric_limits<float>::epsilon())
38 return (deltaPosition.GetY() > std::numeric_limits<float>::epsilon());
39
40 return (this->GetEnergyAtDca() > rhs.GetEnergyAtDca());
41}
42
43//------------------------------------------------------------------------------------------------------------------------------------------
44
46 m_d0(parameters.m_d0.Get()),
47 m_z0(parameters.m_z0.Get()),
48 m_particleId(parameters.m_particleId.Get()),
49 m_charge(parameters.m_charge.Get()),
50 m_mass(parameters.m_mass.Get()),
51 m_momentumAtDca(parameters.m_momentumAtDca.Get()),
52 m_energyAtDca(std::sqrt(m_mass * m_mass + m_momentumAtDca.GetMagnitudeSquared())),
53 m_trackStateAtStart(parameters.m_trackStateAtStart.Get()),
54 m_trackStateAtEnd(parameters.m_trackStateAtEnd.Get()),
55 m_trackStateAtCalorimeter(parameters.m_trackStateAtCalorimeter.Get()),
56 m_timeAtCalorimeter(parameters.m_timeAtCalorimeter.Get()),
57 m_reachesCalorimeter(parameters.m_reachesCalorimeter.Get()),
58 m_isProjectedToEndCap(parameters.m_isProjectedToEndCap.Get()),
59 m_canFormPfo(parameters.m_canFormPfo.Get()),
60 m_canFormClusterlessPfo(parameters.m_canFormClusterlessPfo.Get()),
61 m_pAssociatedCluster(nullptr),
62 m_pParentAddress(parameters.m_pParentAddress.Get()),
63 m_isAvailable(true)
64{
65 // Consistency checks
66 if (m_energyAtDca < std::numeric_limits<float>::epsilon())
67 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
68
69 if (0 == m_charge)
70 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
71}
72
73//------------------------------------------------------------------------------------------------------------------------------------------
74
76{
77}
78
79//------------------------------------------------------------------------------------------------------------------------------------------
80
81void Track::SetMCParticleWeightMap(const MCParticleWeightMap &mcParticleWeightMap)
82{
83 m_mcParticleWeightMap = mcParticleWeightMap;
84}
85
86//------------------------------------------------------------------------------------------------------------------------------------------
87
92
93//------------------------------------------------------------------------------------------------------------------------------------------
94
96{
97 if (!pCluster)
98 return STATUS_CODE_INVALID_PARAMETER;
99
100 if (nullptr != m_pAssociatedCluster)
101 return STATUS_CODE_ALREADY_INITIALIZED;
102
103 m_pAssociatedCluster = pCluster;
104 return STATUS_CODE_SUCCESS;
105}
106
107//------------------------------------------------------------------------------------------------------------------------------------------
108
110{
111 if (pCluster != m_pAssociatedCluster)
112 return STATUS_CODE_NOT_FOUND;
113
114 m_pAssociatedCluster = nullptr;
115 return STATUS_CODE_SUCCESS;
116}
117
118//------------------------------------------------------------------------------------------------------------------------------------------
119
121{
122 if (!pTrack)
123 return STATUS_CODE_INVALID_PARAMETER;
124
125 if (m_parentTrackList.end() != std::find(m_parentTrackList.begin(), m_parentTrackList.end(), pTrack))
126 return STATUS_CODE_ALREADY_PRESENT;
127
128 m_parentTrackList.push_back(pTrack);
129 return STATUS_CODE_SUCCESS;
130}
131
132//------------------------------------------------------------------------------------------------------------------------------------------
133
135{
136 if (!pTrack)
137 return STATUS_CODE_INVALID_PARAMETER;
138
139 if (m_daughterTrackList.end() != std::find(m_daughterTrackList.begin(), m_daughterTrackList.end(), pTrack))
140 return STATUS_CODE_ALREADY_PRESENT;
141
142 m_daughterTrackList.push_back(pTrack);
143 return STATUS_CODE_SUCCESS;
144}
145
146//------------------------------------------------------------------------------------------------------------------------------------------
147
149{
150 if (!pTrack)
151 return STATUS_CODE_INVALID_PARAMETER;
152
153 if (m_siblingTrackList.end() != std::find(m_siblingTrackList.begin(), m_siblingTrackList.end(), pTrack))
154 return STATUS_CODE_ALREADY_PRESENT;
155
156 m_siblingTrackList.push_back(pTrack);
157 return STATUS_CODE_SUCCESS;
158}
159
160} // namespace pandora
Header file for the track class.
CartesianVector class.
float GetX() const
Get the cartesian x coordinate.
float GetZ() const
Get the cartesian z coordinate.
float GetY() const
Get the cartesian y coordinate.
Cluster class.
Definition Cluster.h:31
StatusCodeException class.
Track class.
Definition Track.h:26
MCParticleWeightMap m_mcParticleWeightMap
The mc particle weight map.
Definition Track.h:281
StatusCode SetAssociatedCluster(const Cluster *const pCluster)
Set the cluster associated with the track.
Definition Track.cc:95
void SetMCParticleWeightMap(const MCParticleWeightMap &mcParticleWeightMap)
Set the mc particles associated with the track.
Definition Track.cc:81
float GetEnergyAtDca() const
Get the track energy at the 2D distance of closest approach.
Definition Track.h:337
const int m_charge
The charge of the tracked particle.
Definition Track.h:268
StatusCode AddSibling(const Track *const pTrack)
Add a sibling track to the sibling track list.
Definition Track.cc:148
bool operator<(const Track &rhs) const
operator< sorting by position at calorimeter, then energy at the 2D distance of closest approach
Definition Track.cc:27
const float m_energyAtDca
The track energy at the 2D distance of closest approach, units GeV.
Definition Track.h:271
const Cluster * GetAssociatedCluster() const
Get address of the cluster associated with the track.
Definition Track.cc:17
void RemoveMCParticles()
Remove the mc particles associated with the track.
Definition Track.cc:88
Track(const object_creation::Track::Parameters &parameters)
Constructor.
Definition Track.cc:45
StatusCode AddDaughter(const Track *const pTrack)
Add a daughter track to the daughter track list.
Definition Track.cc:134
virtual ~Track()
Destructor.
Definition Track.cc:75
StatusCode RemoveAssociatedCluster(const Cluster *const pCluster)
Remove the association with a cluster.
Definition Track.cc:109
TrackList m_siblingTrackList
The list of sibling track addresses.
Definition Track.h:284
StatusCode AddParent(const Track *const pTrack)
Add a parent track to the parent track list.
Definition Track.cc:120
TrackList m_parentTrackList
The list of parent track addresses.
Definition Track.h:283
const TrackState & GetTrackStateAtCalorimeter() const
Get the (sometimes projected) track state at the calorimeter.
Definition Track.h:358
TrackList m_daughterTrackList
The list of daughter track addresses.
Definition Track.h:285
const Cluster * m_pAssociatedCluster
The address of an associated cluster.
Definition Track.h:280
const CartesianVector & GetPosition() const
Get the track position vector.
Definition TrackState.h:73
std::unordered_map< const MCParticle *, float > MCParticleWeightMap
StatusCode
The StatusCode enum.