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();
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) = default;
68
69 /// copy-assignment operator
70 Track& operator=(Track other) &; // Rebind this to other's internal object
71 Track& operator=(Track other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
72
73 /// create a mutable deep-copy of the object with identical relations
74 /// if cloneRelations=false, the relations are not cloned and will be empty
75 MutableTrack clone(bool cloneRelations=true) const;
76
77 /// destructor
78 ~Track() = default;
79
80 /// converting constructor from mutable object
81 Track(const MutableTrack& other);
82
83 static Track makeEmpty();
84
85public:
86
87 static constexpr std::string_view typeName = "edm4eic::Track";
88
89 /// Access the Flag that defines the type of track
90 std::int32_t getType() const;
91
92 /// Access the Track 3-position at the vertex
93 const edm4hep::Vector3f& getPosition() const;
94
95 /// Access the Track 3-momentum at the vertex [GeV]
96 const edm4hep::Vector3f& getMomentum() const;
97
98 /// Access the Covariance matrix in basis [x,y,z,px,py,pz]
100
101 /// Access the Track time at the vertex [ns]
102 float getTime() const;
103
104 /// Access the Error on the track vertex time
105 float getTimeError() const;
106
107 /// Access the Particle charge
108 float getCharge() const;
109
110 /// Access the Total chi2
111 float getChi2() const;
112
113 /// Access the Number of degrees of freedom
114 std::uint32_t getNdf() const;
115
116 /// Access the PDG particle ID hypothesis
117 std::int32_t getPdg() const;
118
119
120 /// Access the Trajectory of this track
122
123 std::size_t measurements_size() const;
124 edm4eic::Measurement2D getMeasurements(std::size_t) const;
125 std::vector<edm4eic::Measurement2D>::const_iterator measurements_begin() const;
126 std::vector<edm4eic::Measurement2D>::const_iterator measurements_end() const;
127 podio::RelationRange<edm4eic::Measurement2D> getMeasurements() const;
128 std::size_t tracks_size() const;
129 edm4eic::Track getTracks(std::size_t) const;
130 std::vector<edm4eic::Track>::const_iterator tracks_begin() const;
131 std::vector<edm4eic::Track>::const_iterator tracks_end() const;
132 podio::RelationRange<edm4eic::Track> getTracks() const;
133
134
135 /// check whether the object is actually available
136 bool isAvailable() const;
137 /// disconnect from TrackObj instance
138 void unlink() { m_obj = podio::utils::MaybeSharedPtr<TrackObj>{nullptr}; }
139
140 bool operator==(const Track& other) const { return m_obj == other.m_obj; }
141 bool operator==(const MutableTrack& other) const;
142
143 bool operator!=(const Track& other) const { return !(*this == other); }
144 bool operator!=(const MutableTrack& other) const { return !(*this == other); }
145
146 // less comparison operator, so that objects can be e.g. stored in sets.
147 bool operator<(const Track& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
148
149 podio::ObjectID id() const { return getObjectID(); }
150
151 const podio::ObjectID getObjectID() const;
152
153 friend std::hash<Track>;
154
155 friend void swap(Track& a, Track& b) {
156 using std::swap;
157 swap(a.m_obj, b.m_obj); // swap out the internal pointers
158 }
159
160private:
161 /// constructor from existing TrackObj
162 explicit Track(podio::utils::MaybeSharedPtr<TrackObj> obj);
163 Track(TrackObj* obj);
164
165 podio::utils::MaybeSharedPtr<TrackObj> m_obj{nullptr};
166};
167
168std::ostream& operator<<(std::ostream& o, const Track& value);
169
170#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
171void to_json(nlohmann::json& j, const Track& value);
172#endif
173
174
175} // namespace edm4eic
176
177
178
179template<>
180struct std::hash<edm4eic::Track> {
181 std::size_t operator()(const edm4eic::Track& obj) const {
182 return std::hash<edm4eic::TrackObj*>{}(obj.m_obj.get());
183 }
184};
185
186
187// This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
188// until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
189// and https://github.com/AIDASoft/podio/issues/770
190#if defined(__clang__)
191#pragma clang diagnostic push
192#pragma clang diagnostic ignored "-Wunknown-warning-option"
193#pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
194#pragma clang diagnostic ignored "-Wdeprecated"
195constexpr std::string_view edm4eic::Track::typeName;
196#pragma clang diagnostic pop
197#elif defined(__GNUC__)
198#pragma GCC diagnostic push
199#pragma GCC diagnostic ignored "-Wdeprecated"
200constexpr std::string_view edm4eic::Track::typeName;
201#pragma GCC diagnostic pop
202#endif
203
204#endif
Definition Cov6f.h:19
Definition Measurement2D.h:46
Definition MutableTrack.h:40
Definition MutableTrajectory.h:39
Definition TrackCollectionData.h:32
Definition TrackCollection.h:137
Definition Track.h:48
bool operator==(const Track &other) const
Definition Track.h:140
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:88
std::int32_t getType() const
Access the Flag that defines the type of track.
Definition Track.cc:87
void unlink()
disconnect from TrackObj instance
Definition Track.h:138
MutableTrack mutable_type
Definition Track.h:57
float getChi2() const
Access the Total chi2.
Definition Track.cc:94
const edm4hep::Vector3f & getMomentum() const
Access the Track 3-momentum at the vertex [GeV].
Definition Track.cc:89
podio::RelationRange< edm4eic::Track > getTracks() const
Definition Track.cc:162
bool operator!=(const Track &other) const
Definition Track.h:143
MutableTrack clone(bool cloneRelations=true) const
Definition Track.cc:43
std::vector< edm4eic::Measurement2D >::const_iterator measurements_end() const
Definition Track.cc:113
podio::ObjectID id() const
Definition Track.h:149
std::vector< edm4eic::Track >::const_iterator tracks_end() const
Definition Track.cc:145
~Track()=default
destructor
std::int32_t getPdg() const
Access the PDG particle ID hypothesis.
Definition Track.cc:96
friend void swap(Track &a, Track &b)
Definition Track.h:155
podio::RelationRange< edm4eic::Measurement2D > getMeasurements() const
Definition Track.cc:130
Track(const Track &other)=default
copy constructor
bool operator<(const Track &other) const
Definition Track.h:147
bool operator!=(const MutableTrack &other) const
Definition Track.h:144
float getTime() const
Access the Track time at the vertex [ns].
Definition Track.cc:91
TrackCollection collection_type
Definition Track.h:58
Track & operator=(Track other) &
copy-assignment operator
Definition Track.cc:38
std::vector< edm4eic::Track >::const_iterator tracks_begin() const
Definition Track.cc:139
friend class TrackCollectionIterator
Definition Track.h:53
std::size_t measurements_size() const
Definition Track.cc:119
const podio::ObjectID getObjectID() const
Definition Track.cc:178
std::uint32_t getNdf() const
Access the Number of degrees of freedom.
Definition Track.cc:95
std::size_t tracks_size() const
Definition Track.cc:151
const edm4eic::Cov6f & getPositionMomentumCovariance() const
Access the Covariance matrix in basis [x,y,z,px,py,pz].
Definition Track.cc:90
static Track makeEmpty()
Definition Track.cc:83
float getCharge() const
Access the Particle charge.
Definition Track.cc:93
const edm4eic::Trajectory getTrajectory() const
Access the Trajectory of this track.
Definition Track.cc:98
float getTimeError() const
Access the Error on the track vertex time.
Definition Track.cc:92
bool isAvailable() const
check whether the object is actually available
Definition Track.cc:174
Track()
default constructor
Definition Track.cc:21
std::vector< edm4eic::Measurement2D >::const_iterator measurements_begin() const
Definition Track.cc:107
friend class TrackCollection
Definition Track.h:51
static constexpr std::string_view typeName
Definition Track.h:87
Definition TrackObj.h:24
Definition Trajectory.h:47
Definition CalorimeterHit.cc:17
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:103
Definition CalorimeterHit.h:31
OrderKey getOrderKey(const edm4eic::CalorimeterHit &obj)
Definition CalorimeterHit.cc:150
std::size_t operator()(const edm4eic::Track &obj) const
Definition Track.h:181