Project
Loading...
Searching...
No Matches
Point.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14#ifndef ALICEO2_TPC_POINT_H
15#define ALICEO2_TPC_POINT_H
16
18#include <vector>
20
21namespace o2
22{
23namespace tpc
24{
25
26// a minimal and plain TPC hit class
28{
29 public:
30 //:: so as to get the right Point3D
31 math_utils::Point3D<float> mPos; // cartesian position of Hit
32 float mTime = -1; // time of flight
33 float mELoss = -2; // energy loss
34
35 float GetX() const { return mPos.X(); }
36 float GetY() const { return mPos.Y(); }
37 float GetZ() const { return mPos.Z(); }
38 const math_utils::Point3D<float>& getPos() const { return mPos; }
39 float GetEnergyLoss() const { return mELoss; }
40 float GetTime() const { return mTime; }
41
42 public:
43 ElementalHit() = default; // for ROOT IO
44 ~ElementalHit() = default;
45 ElementalHit(ElementalHit const&) = default;
46
47 // constructor
48 ElementalHit(float x, float y, float z, float time, float e)
49 : mPos(x, y, z), mTime(time), mELoss(e) {}
50
52};
53
54} // namespace tpc
55} // namespace o2
56
57#ifdef USESHM
58namespace std
59{
60template <>
61class allocator<o2::tpc::ElementalHit> : public o2::utils::ShmAllocator<o2::tpc::ElementalHit>
62{
63};
64} // namespace std
65#endif
66
67namespace o2
68{
69namespace tpc
70{
71
72// an index to uniquely identify a single hit group of TPC
74 TPCHitGroupID() = default;
75 TPCHitGroupID(int sindex, int c, int e, int gid, int src = 0)
76 : storeindex{sindex}, collision{c}, entry{e}, groupID{gid}, sourceID{src}
77 {
78 }
79 int storeindex = -1; // tells in which index/entry of some hitvector I should look up this hit group
80 int collision = -1; // the collision id --> determines the time
81 int entry = -1; // the real entry/eventID in some branch (not necessarily the same as collision but often the case)
82 int groupID = -1;
83 int sourceID = 0;
84};
85
86// a higher order hit class encapsulating
87// a set of elemental hits belonging to the same trackid (and sector)
88// construct used to do less MC truth linking and to save memory
89class HitGroup : public o2::BaseHit
90{
91 public:
93#ifdef HIT_AOS
94 mHits()
95#else
96 mHitsXVctr(),
97 mHitsYVctr(),
98 mHitsZVctr(),
99 mHitsTVctr(),
100 mHitsEVctr()
101#endif
102 {
103 }
104
105 HitGroup(int trackID) : o2::BaseHit(trackID),
106#ifdef HIT_AOS
107 mHits()
108#else
109 mHitsXVctr(),
110 mHitsYVctr(),
111 mHitsZVctr(),
112 mHitsTVctr(),
113 mHitsEVctr()
114#endif
115 {
116 }
117
118 ~HitGroup() = default;
119
120 void addHit(float x, float y, float z, float time, short e)
121 {
122#ifdef HIT_AOS
123 mHits.emplace_back(x, y, z, time, e);
124#else
125 mHitsXVctr.emplace_back(x);
126 mHitsYVctr.emplace_back(y);
127 mHitsZVctr.emplace_back(z);
128 mHitsTVctr.emplace_back(time);
129 mHitsEVctr.emplace_back(e);
130#endif
131 }
132
133 size_t getSize() const
134 {
135#ifdef HIT_AOS
136 return mHits.size();
137#else
138 return mHitsXVctr.size();
139#endif
140 }
141
143 {
144#ifdef HIT_AOS
145 // std::vector storage
146 return mHits[index];
147#else
149#endif
150 }
151
153 {
154 // shrink all the containers to have exactly the required size
155 // might improve overall memory consumption
156#ifdef HIT_AOS
157 // std::vector storage
158 mHits.shrink_to_fit();
159#else
160 mHitsXVctr.shrink_to_fit();
161 mHitsYVctr.shrink_to_fit();
162 mHitsZVctr.shrink_to_fit();
163 mHitsTVctr.shrink_to_fit();
164 mHitsEVctr.shrink_to_fit();
165#endif
166 }
167
168 // in future we might want to have a method
169 // FitAndCompress()
170 // which does a track fit and produces a parametrized hit
171 // (such as done in a similar form in AliRoot)
172 public:
173#ifdef HIT_AOS
174 std::vector<o2::tpc::ElementalHit> mHits; // the hits for this group
175#else
176 using vec_t = std::vector<float, o2::utils::ShmAllocator<float>>;
182#endif
184};
185
186class Point : public o2::BasicXYZEHit<float>
187{
188 public:
190 Point() = default;
191
200 Point(float x, float y, float z, float time, float nElectrons, float trackID, float detID);
201
203 ~Point() = default;
204
206 void Print(const Option_t* opt) const;
207
208 private:
210 Point(const Point& point);
211 Point operator=(const Point& point);
212
213 ClassDefNV(o2::tpc::Point, 1);
214};
215
216inline Point::Point(float x, float y, float z, float time, float nElectrons, float trackID, float detID)
217 : BasicXYZEHit<float>(x, y, z, time, nElectrons, trackID, detID)
218{
219}
220
221} // namespace tpc
222} // namespace o2
223
224#ifdef USESHM
225namespace std
226{
227template <>
228class allocator<o2::tpc::HitGroup> : public o2::utils::ShmAllocator<o2::tpc::HitGroup>
229{
230};
231} // namespace std
232#endif
233
234#endif
int16_t time
Definition RawEventData.h:4
uint32_t c
Definition RawData.h:2
float GetEnergyLoss() const
Definition Point.h:39
float GetY() const
Definition Point.h:36
float GetZ() const
Definition Point.h:37
math_utils::Point3D< float > mPos
Definition Point.h:31
float GetTime() const
Definition Point.h:40
const math_utils::Point3D< float > & getPos() const
Definition Point.h:38
ElementalHit(float x, float y, float z, float time, float e)
Definition Point.h:48
ClassDefNV(ElementalHit, 1)
ElementalHit(ElementalHit const &)=default
float GetX() const
Definition Point.h:35
void shrinkToFit()
Definition Point.h:152
vec_t mHitsYVctr
Definition Point.h:178
ElementalHit getHit(size_t index) const
Definition Point.h:142
HitGroup(int trackID)
Definition Point.h:105
ClassDefNV(HitGroup, 1)
size_t getSize() const
Definition Point.h:133
std::vector< float, o2::utils::ShmAllocator< float > > vec_t
Definition Point.h:176
~HitGroup()=default
vec_t mHitsXVctr
Definition Point.h:177
void addHit(float x, float y, float z, float time, short e)
Definition Point.h:120
vec_t mHitsTVctr
Definition Point.h:180
vec_t mHitsZVctr
Definition Point.h:179
vec_t mHitsEVctr
Definition Point.h:181
void Print(const Option_t *opt) const
Output to screen.
Definition Point.cxx:20
Point()=default
Default constructor.
~Point()=default
Destructor.
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
GLuint entry
Definition glcorearb.h:5735
GLuint index
Definition glcorearb.h:781
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
TPCHitGroupID(int sindex, int c, int e, int gid, int src=0)
Definition Point.h:75