EDM4eic
EIC data model
Loading...
Searching...
No Matches
Track.h
Go to the documentation of this file.
1// AUTOMATICALLY GENERATED FILE - DO NOT EDIT
2
3#ifndef EDM4EIC_Track_H
4#define EDM4EIC_Track_H
5
6#include "edm4eic/TrackObj.h"
7
8#include "edm4eic/Cov6f.h"
10#include "edm4hep/Vector3f.h"
11#include "podio/RelationRange.h"
12#include <cstdint>
13#include <vector>
14
15#include "podio/utilities/MaybeSharedPtr.h"
16#include "podio/detail/OrderKey.h"
17
18#include <ostream>
19#include <cstdint>
20
21#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
22#include "nlohmann/json_fwd.hpp"
23#endif
24
25// forward declarations
26namespace edm4eic {
27class TrackCollection;
28class Trajectory;
30}
31
32
33namespace podio::detail {
34// Internal function used in less comparison operators of the datatypes and interface types
35OrderKey getOrderKey(const edm4eic::Track& obj);
36};
37
38namespace edm4eic {
39
40class MutableTrack;
41class TrackCollection;
43
44/** @class Track
45 * Track information at the vertex
46 * @author: S. Joosten, J. Osborn
47 */
48class Track {
49
50 friend class MutableTrack;
51 friend class TrackCollection;
54 friend podio::detail::OrderKey podio::detail::getOrderKey(const Track & obj);
55
56public:
59
60 /// default constructor
61 Track() = default;
62
63 /// Constructor initializing all members
64 Track(const std::int32_t type, const edm4hep::Vector3f& position, const edm4hep::Vector3f& momentum, const edm4eic::Cov6f& positionMomentumCovariance, const float time, const float timeError, const float charge, const float chi2, const std::uint32_t ndf, const std::int32_t pdg);
65
66 /// copy constructor
67 Track(const Track& other) noexcept = default;
68
69 /// move constructor
70 Track(Track&& other) noexcept = default;
71
72 /// copy-assignment operator
73 Track& operator=(Track other) &; // Rebind this to other's internal object
74 Track& operator=(Track other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
75
76 /// create a mutable deep-copy of the object with identical relations
77 /// if cloneRelations=false, the relations are not cloned and will be empty
78 MutableTrack clone(bool cloneRelations=true) const;
79
80 /// destructor
81 ~Track() = default;
82
83 /// converting constructor from mutable object
84 Track(const MutableTrack& other);
85
86 static Track makeEmpty();
87
88public:
89
90 static constexpr std::string_view typeName = "edm4eic::Track";
91
92 /// Access the Flag that defines the type of track
93 std::int32_t getType() const;
94
95 /// Access the Track 3-position at the vertex
96 const edm4hep::Vector3f& getPosition() const;
97
98 /// Access the Track 3-momentum at the vertex [GeV]
99 const edm4hep::Vector3f& getMomentum() const;
100
101 /// Access the Covariance matrix in basis [x,y,z,px,py,pz]
103
104 /// Access the Track time at the vertex [ns]
105 float getTime() const;
106
107 /// Access the Error on the track vertex time
108 float getTimeError() const;
109
110 /// Access the Particle charge
111 float getCharge() const;
112
113 /// Access the Total chi2
114 float getChi2() const;
115
116 /// Access the Number of degrees of freedom
117 std::uint32_t getNdf() const;
118
119 /// Access the PDG particle ID hypothesis
120 std::int32_t getPdg() const;
121
122
123 /// Access the Trajectory of this track
125
126 std::size_t measurements_size() const;
127 edm4eic::Measurement2D getMeasurements(std::size_t) const;
128 std::vector<edm4eic::Measurement2D>::const_iterator measurements_begin() const;
129 std::vector<edm4eic::Measurement2D>::const_iterator measurements_end() const;
130 podio::RelationRange<edm4eic::Measurement2D> getMeasurements() const;
131 std::size_t tracks_size() const;
132 edm4eic::Track getTracks(std::size_t) const;
133 std::vector<edm4eic::Track>::const_iterator tracks_begin() const;
134 std::vector<edm4eic::Track>::const_iterator tracks_end() const;
135 podio::RelationRange<edm4eic::Track> getTracks() const;
136
137
138 /// check whether the object is actually available
139 bool isAvailable() const;
140 /// disconnect from TrackObj instance
141 void unlink() { m_obj = podio::utils::MaybeSharedPtr<TrackObj>{nullptr}; }
142
143 constexpr bool operator==(const Track& other) const { return m_obj == other.m_obj; }
144 bool operator==(const MutableTrack& other) const;
145
146 constexpr bool operator!=(const Track& other) const { return !(*this == other); }
147 bool operator!=(const MutableTrack& other) const { return !(*this == other); }
148
149 // less comparison operator, so that objects can be e.g. stored in sets.
150 bool operator<(const Track& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
151
152 podio::ObjectID id() const { return getObjectID(); }
153
154 const podio::ObjectID getObjectID() const;
155
156 friend std::hash<Track>;
157
158 friend void swap(Track& a, Track& b) {
159 using std::swap;
160 swap(a.m_obj, b.m_obj); // swap out the internal pointers
161 }
162
163private:
164 /// constructor from existing TrackObj
165 explicit Track(podio::utils::MaybeSharedPtr<TrackObj> obj);
166 Track(TrackObj* obj);
167
168 podio::utils::MaybeSharedPtr<TrackObj> m_obj{new TrackObj{}, podio::utils::MarkOwned};
169};
170
171std::ostream& operator<<(std::ostream& o, const Track& value);
172
173#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
174void to_json(nlohmann::json& j, const Track& value);
175#endif
176
177
178} // namespace edm4eic
179
180
181
182template<>
183struct std::hash<edm4eic::Track> {
184 std::size_t operator()(const edm4eic::Track& obj) const {
185 return std::hash<edm4eic::TrackObj*>{}(obj.m_obj.get());
186 }
187};
188
189
190// This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
191// until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
192// and https://github.com/AIDASoft/podio/issues/770
193#if defined(__clang__)
194 #pragma clang diagnostic push
195 #pragma clang diagnostic ignored "-Wunknown-warning-option"
196 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
197 #pragma clang diagnostic ignored "-Wdeprecated"
198constexpr std::string_view edm4eic::Track::typeName;
199 #pragma clang diagnostic pop
200#elif defined(__GNUC__)
201 #pragma GCC diagnostic push
202 #pragma GCC diagnostic ignored "-Wdeprecated"
203constexpr std::string_view edm4eic::Track::typeName;
204 #pragma GCC diagnostic pop
205#endif
206
207
208#endif
Definition Cov6f.h:20
Definition Measurement2D.h:46
Definition MutableTrack.h:40
Definition MutableTrajectory.h:39
Definition TrackCollectionData.h:33
Definition TrackCollection.h:139
Definition Track.h:48
friend class MutableTrack
Definition Track.h:50
Track & operator=(Track other) &&=delete
const edm4hep::Vector3f & getPosition() const
Access the Track 3-position at the vertex.
Definition Track.cc:84
std::int32_t getType() const
Access the Flag that defines the type of track.
Definition Track.cc:83
void unlink()
disconnect from TrackObj instance
Definition Track.h:141
MutableTrack mutable_type
Definition Track.h:57
Track()=default
default constructor
float getChi2() const
Access the Total chi2.
Definition Track.cc:90
const edm4hep::Vector3f & getMomentum() const
Access the Track 3-momentum at the vertex [GeV].
Definition Track.cc:85
podio::RelationRange< edm4eic::Track > getTracks() const
Definition Track.cc:158
MutableTrack clone(bool cloneRelations=true) const
Definition Track.cc:39
std::vector< edm4eic::Measurement2D >::const_iterator measurements_end() const
Definition Track.cc:109
podio::ObjectID id() const
Definition Track.h:152
std::vector< edm4eic::Track >::const_iterator tracks_end() const
Definition Track.cc:141
~Track()=default
destructor
std::int32_t getPdg() const
Access the PDG particle ID hypothesis.
Definition Track.cc:92
Track(Track &&other) noexcept=default
move constructor
friend void swap(Track &a, Track &b)
Definition Track.h:158
podio::RelationRange< edm4eic::Measurement2D > getMeasurements() const
Definition Track.cc:126
bool operator<(const Track &other) const
Definition Track.h:150
bool operator!=(const MutableTrack &other) const
Definition Track.h:147
float getTime() const
Access the Track time at the vertex [ns].
Definition Track.cc:87
TrackCollection collection_type
Definition Track.h:58
Track & operator=(Track other) &
copy-assignment operator
Definition Track.cc:34
std::vector< edm4eic::Track >::const_iterator tracks_begin() const
Definition Track.cc:135
constexpr bool operator==(const Track &other) const
Definition Track.h:143
friend class TrackCollectionIterator
Definition Track.h:53
std::size_t measurements_size() const
Definition Track.cc:115
const podio::ObjectID getObjectID() const
Definition Track.cc:174
std::uint32_t getNdf() const
Access the Number of degrees of freedom.
Definition Track.cc:91
std::size_t tracks_size() const
Definition Track.cc:147
const edm4eic::Cov6f & getPositionMomentumCovariance() const
Access the Covariance matrix in basis [x,y,z,px,py,pz].
Definition Track.cc:86
constexpr bool operator!=(const Track &other) const
Definition Track.h:146
static Track makeEmpty()
Definition Track.cc:79
float getCharge() const
Access the Particle charge.
Definition Track.cc:89
const edm4eic::Trajectory getTrajectory() const
Access the Trajectory of this track.
Definition Track.cc:94
float getTimeError() const
Access the Error on the track vertex time.
Definition Track.cc:88
bool isAvailable() const
check whether the object is actually available
Definition Track.cc:170
std::vector< edm4eic::Measurement2D >::const_iterator measurements_begin() const
Definition Track.cc:103
Track(const Track &other) noexcept=default
copy constructor
friend class TrackCollection
Definition Track.h:51
static constexpr std::string_view typeName
Definition Track.h:90
Definition TrackObj.h:24
Definition Trajectory.h:47
Definition ArrowMapper.cc:63
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:99
Definition CalorimeterHit.h:31
OrderKey getOrderKey(const edm4eic::CalorimeterHit &obj)
Definition CalorimeterHit.cc:146
std::size_t operator()(const edm4eic::Track &obj) const
Definition Track.h:184