]>
Commit | Line | Data |
---|---|---|
e1e03704 | 1 | //-*- Mode: C++ -*- |
2 | // $Id$ | |
3 | #ifndef ALIHLTTRACKGEOMETRY_H | |
4 | #define ALIHLTTRACKGEOMETRY_H | |
5 | //* This file is property of and copyright by the ALICE HLT Project * | |
6 | //* ALICE Experiment at CERN, All rights reserved. * | |
7 | //* See cxx source for full Copyright notice * | |
8 | ||
9 | /// @file AliHLTTrackGeometry.h | |
10 | /// @author Matthias Richter | |
11 | /// @date 2011-05-20 | |
12 | /// @brief Desciption of a track by a sequence of track points | |
13 | /// | |
14 | ||
15 | #include <vector> | |
16 | #include <TObject.h> | |
17 | #include "AliHLTLogging.h" | |
18 | #include "AliHLTDataTypes.h" | |
19 | #include "AliHLTStdIncludes.h" | |
20 | #include "AliHLTExternalTrackParam.h" | |
c5efb946 | 21 | #include "AliHLTIndexGrid.h" |
e1e03704 | 22 | |
23 | class AliHLTGlobalBarrelTrack; | |
24 | class AliHLTSpacePointContainer; | |
54ff4c01 | 25 | class TH2; |
e1e03704 | 26 | |
27 | /** | |
28 | * @class AliHLTTrackGeometry | |
29 | * Description of a track by a sequence of track points given by the | |
30 | * intersection of the track with a set of planes. | |
31 | * | |
32 | * Each plane describes a local 2D coordinate system with origin at the | |
33 | * norm vector going through global {0,0,0}. The local coordinates u and v | |
34 | * correspond to global y and z at zero alpha and theta. In that case, r | |
35 | * corresponds to global x. | |
36 | * | |
37 | * Each plane is identified by | |
38 | * - rotation angle alpha in the global xy plane | |
39 | * - rotation angle theta | |
40 | * - unique 32bit AliHLTUInt32_t plane id | |
41 | * | |
42 | * The geometry of planes can be defined in child classes defining the | |
43 | * plane id. | |
44 | * @ingroup alihlt_base | |
45 | */ | |
46 | class AliHLTTrackGeometry : public TObject, public AliHLTLogging | |
47 | { | |
48 | public: | |
49 | /// standard constructor | |
50 | AliHLTTrackGeometry(); | |
51 | /// copy constructor | |
52 | AliHLTTrackGeometry(const AliHLTTrackGeometry&); | |
53 | /// assignment operator | |
54 | AliHLTTrackGeometry& operator=(const AliHLTTrackGeometry&); | |
55 | ||
56 | /// destructor | |
57 | ~AliHLTTrackGeometry(); | |
58 | ||
c5efb946 | 59 | typedef AliHLTIndexGrid<int, AliHLTUInt32_t> AliHLTTrackGrid; |
60 | ||
e1e03704 | 61 | /// set the track id |
62 | void SetTrackId(int trackId) {fTrackId=trackId;} | |
63 | /// get the track id | |
64 | int GetTrackId() const {return fTrackId;} | |
65 | ||
66 | enum { | |
67 | kLower = 0, | |
68 | kUpper = 1, | |
69 | kBoundsDimension | |
70 | }; | |
71 | ||
72 | /** | |
73 | * class AliHLTTrackPlane | |
74 | * Helper class to describe a plane | |
75 | */ | |
76 | class AliHLTTrackPlane { | |
77 | public: | |
78 | AliHLTTrackPlane(AliHLTUInt32_t id, float alpha, float r, float theta) | |
79 | : fId(id), fAlpha(alpha), fR(r), fTheta(theta), fBoundsU(), fBoundsV() { | |
80 | fBoundsU[kLower]=-5.0; fBoundsU[kUpper]=5.0; fBoundsV[kLower]=-5.0; fBoundsV[kUpper]=5.0; | |
81 | } | |
82 | virtual ~AliHLTTrackPlane() {} | |
83 | ||
84 | /// id of the plane | |
85 | AliHLTUInt32_t GetId() const {return fId;} | |
86 | /// alpha of the plane | |
87 | float GetPlaneAlpha() const {return fAlpha;} | |
88 | /// radial distance from global {0,0,0} | |
89 | float GetPlaneR() const {return fR;} | |
90 | /// theta of the plane | |
91 | float GetPlaneTheta() const {return fTheta;} | |
92 | ||
93 | // set bounds of u coordinate | |
94 | void SetBoundsU(const float bounds[kBoundsDimension]) { | |
95 | fBoundsU[kLower]=bounds[kLower]; fBoundsU[kUpper]=bounds[kUpper]; | |
96 | } | |
97 | // set bounds of v coordinate | |
98 | void SetBoundsV(const float bounds[kBoundsDimension]) { | |
99 | fBoundsV[kLower]=bounds[kLower]; fBoundsV[kUpper]=bounds[kUpper]; | |
100 | } | |
101 | ||
102 | bool CheckBounds(float u, float v) const { | |
103 | return (u>=fBoundsU[kLower]) && (u<=fBoundsU[kUpper]) | |
104 | && (v>=fBoundsV[kLower]) && (v<=fBoundsV[kUpper]); | |
105 | } | |
106 | ||
107 | private: | |
108 | // standard constructor prohibited | |
109 | AliHLTTrackPlane(); | |
110 | ||
111 | AliHLTUInt32_t fId; // unique id | |
112 | float fAlpha; // alpha of the plane | |
113 | float fR; // radial distance from global {0,0,0} | |
114 | float fTheta; // theta of the plane | |
115 | float fBoundsU[kBoundsDimension]; // bounds u coordinate | |
116 | float fBoundsV[kBoundsDimension]; // bounds v coordinate | |
117 | }; | |
118 | ||
119 | class AliHLTTrackPlaneYZ : public AliHLTTrackPlane { | |
120 | public: | |
121 | AliHLTTrackPlaneYZ(AliHLTUInt32_t id, float alpha, float r) | |
122 | : AliHLTTrackPlane(id, alpha, r, 0.0) {} | |
123 | ~AliHLTTrackPlaneYZ() {} | |
124 | ||
125 | private: | |
126 | // standard constructor prohibited | |
127 | AliHLTTrackPlaneYZ(); | |
128 | }; | |
129 | ||
c5efb946 | 130 | struct AliHLTTrackSpacepoint { |
131 | AliHLTTrackSpacepoint(AliHLTUInt32_t id, float dU=-1000., float dV=-1000.) | |
132 | : fId(id), fdU(dU), fdV(dV) {} | |
133 | ||
134 | int SetResidual(int coordinate, float value) { | |
135 | if (coordinate==0) fdU=value; | |
136 | else if (coordinate==1) fdV=value; | |
137 | return 0; | |
138 | } | |
139 | ||
140 | float GetResidual(int coordinate) const { | |
141 | if (coordinate==0) return fdU; | |
142 | else if (coordinate==1) return fdV; | |
a2057c71 | 143 | return -1000.; |
c5efb946 | 144 | } |
145 | ||
146 | AliHLTUInt32_t fId; // space point id | |
147 | float fdU; // residual of the spacepoint | |
148 | float fdV; // residual of the spacepoint | |
149 | }; | |
150 | ||
e1e03704 | 151 | class AliHLTTrackPoint { |
152 | public: | |
153 | // constructor | |
154 | AliHLTTrackPoint(AliHLTUInt32_t id, float u, float v) | |
c5efb946 | 155 | : fId(id), fU(u), fV(v), fSpacePoints() {} |
e1e03704 | 156 | // copy constructor |
157 | AliHLTTrackPoint(const AliHLTTrackPoint& src) | |
c5efb946 | 158 | : fId(src.fId), fU(src.fU), fV(src.fV), fSpacePoints(src.fSpacePoints) {} |
e1e03704 | 159 | // assignment operator |
160 | AliHLTTrackPoint& operator=(const AliHLTTrackPoint& src) { | |
c5efb946 | 161 | if (this!=&src) {fId=src.fId; fU=src.fU; fV=src.fV; fSpacePoints=src.fSpacePoints;} |
e1e03704 | 162 | return *this; |
163 | } | |
164 | ~AliHLTTrackPoint() {} | |
165 | ||
166 | bool operator==(const AliHLTTrackPoint& point) const { | |
167 | return point.fId==fId; | |
168 | } | |
169 | bool operator==(AliHLTUInt32_t id) const { | |
170 | return id==fId; | |
171 | } | |
172 | ||
173 | /// id of the plane | |
174 | AliHLTUInt32_t GetId() const {return fId;} | |
175 | /// u coordinate | |
176 | float GetU() const {return fU;} | |
177 | /// u coordinate | |
178 | float GetV() const {return fV;} | |
179 | ||
180 | /// check associate space point | |
181 | bool HaveAssociatedSpacePoint() const { | |
c5efb946 | 182 | return fSpacePoints.size()>0; |
e1e03704 | 183 | } |
184 | ||
185 | /// associate a space point | |
c5efb946 | 186 | int AddAssociatedSpacePoint(AliHLTUInt32_t spacepointId, float dU=-1000., float dV=-1000.) { |
187 | fSpacePoints.push_back(AliHLTTrackSpacepoint(spacepointId, dU, dV)); | |
54ff4c01 | 188 | return 0; |
189 | } | |
190 | ||
c5efb946 | 191 | const vector<AliHLTTrackSpacepoint>& GetSpacepoints() const {return fSpacePoints;} |
192 | vector<AliHLTTrackSpacepoint>& GetSpacepoints() {return fSpacePoints;} | |
193 | ||
194 | int SetResidual(AliHLTUInt32_t id, int coordinate, float value) { | |
195 | for (unsigned i=0; i<fSpacePoints.size(); i++) { | |
196 | if (fSpacePoints[i].fId!=id) continue; | |
197 | return fSpacePoints[i].SetResidual(coordinate, value); | |
198 | } | |
199 | return -ENOENT; | |
54ff4c01 | 200 | } |
201 | ||
e1e03704 | 202 | private: |
203 | // standard constructor prohibited | |
204 | AliHLTTrackPoint(); | |
205 | ||
206 | AliHLTUInt32_t fId; // unique id | |
207 | float fU; // u coordinate | |
208 | float fV; // v coordinate | |
c5efb946 | 209 | vector<AliHLTTrackSpacepoint> fSpacePoints; |
e1e03704 | 210 | }; |
211 | ||
212 | // interface to plane description | |
213 | ||
214 | /// alpha of the plane | |
215 | virtual float GetPlaneAlpha(AliHLTUInt32_t planeId) const = 0; | |
216 | /// radial distance from global {0,0,0} | |
217 | virtual float GetPlaneR(AliHLTUInt32_t planeId) const = 0; | |
218 | /// theta of the plane | |
219 | virtual float GetPlaneTheta(AliHLTUInt32_t planeId) const = 0; | |
220 | /// check bounds in u and v coordinate | |
221 | virtual bool CheckBounds(AliHLTUInt32_t planeId, float u, float v) const =0; | |
222 | ||
223 | // track interface | |
224 | ||
225 | /// calculate the track points, expects the global magnetic field to be initialized | |
226 | virtual int CalculateTrackPoints(const AliHLTExternalTrackParam& track) = 0; | |
227 | ||
228 | /// calculate the track points, expects the global magnetic field to be initialized | |
229 | virtual int CalculateTrackPoints(AliHLTGlobalBarrelTrack& track) = 0; | |
230 | ||
231 | /// associate all space points of the container to the calculated track points | |
232 | int AssociateSpacePoints(AliHLTSpacePointContainer& points); | |
233 | /// associate specified space points of the container to the calculated track points | |
234 | int AssociateSpacePoints(const AliHLTUInt32_t* trackpoints, AliHLTUInt32_t nofPoints, AliHLTSpacePointContainer& points); | |
235 | int AssociateUnusedSpacePoints(AliHLTSpacePointContainer& points); | |
236 | ||
237 | /// find the track point which can be associated to a spacepoint with coordinates and id | |
238 | virtual int FindMatchingTrackPoint(AliHLTUInt32_t spacepointId, float spacepoint[3], AliHLTUInt32_t& planeId) = 0; | |
239 | ||
c5efb946 | 240 | /// register track points in the index grid |
241 | virtual int RegisterTrackPoints(AliHLTTrackGrid* pGrid) const; | |
242 | ||
243 | /// fill track points to index grid | |
244 | virtual int FillTrackPoints(AliHLTTrackGrid* pGrid) const; | |
245 | ||
e1e03704 | 246 | /// get track point of id |
247 | const AliHLTTrackPoint* GetTrackPoint(AliHLTUInt32_t id) const; | |
248 | /// get track point of id | |
249 | AliHLTTrackPoint* GetTrackPoint(AliHLTUInt32_t id); | |
250 | ||
3488f70b | 251 | /// create a collection of all points |
54ff4c01 | 252 | virtual AliHLTSpacePointContainer* ConvertToSpacePoints() const {return ConvertToSpacePoints(false);} |
253 | virtual AliHLTSpacePointContainer* ConvertToSpacePoints(bool bAssociated) const; | |
3488f70b | 254 | |
e1e03704 | 255 | /// set the spacepoint associated with a track point |
256 | /// @param planeId track point | |
257 | /// @param spacepointId space point id to be associated with track point | |
258 | /// @param status status flag | |
259 | /// @return 0 on success, -ENOENT planeId not found | |
54ff4c01 | 260 | int SetAssociatedSpacePoint(AliHLTUInt32_t planeId, AliHLTUInt32_t spacepointId, int status, float fdU=0.0, float fdV=0.0); |
e1e03704 | 261 | |
262 | /// get the spacepoint associated with a track point | |
263 | /// @param planeId id of the track point | |
264 | /// @param spacepointId target to get the spacepoint data | |
265 | /// @return status flag if found, -ENOENT planeId not found, -ENODATA no associated spacepoint found | |
266 | int GetAssociatedSpacePoint(AliHLTUInt32_t planeId, AliHLTUInt32_t& spacepointId) const; | |
267 | ||
268 | // services | |
269 | ||
54ff4c01 | 270 | int FillResidual(int coordinate, TH2* histo) const; |
271 | ||
272 | void SetVerbosity(int verbosity) {fVerbosity=verbosity;} | |
273 | int GetVerbosity() const {return fVerbosity;} | |
274 | ||
e1e03704 | 275 | /// inherited from TObject: clear the object and reset pointer references |
276 | virtual void Clear(Option_t * /*option*/ =""); | |
277 | ||
278 | /// inherited from TObject | |
279 | virtual void Print(Option_t *option="") const; | |
280 | ||
281 | virtual void Print(ostream& out, Option_t *option="") const; | |
282 | ||
283 | /// Inherited from TObject, draw the track points | |
284 | virtual void Draw(Option_t *option=""); | |
285 | ||
286 | protected: | |
ec7c650d | 287 | int AddTrackPoint(const AliHLTTrackPoint& point, AliHLTUInt32_t selectionMask=kAliHLTVoidDataSpec); |
e1e03704 | 288 | |
3488f70b | 289 | const vector<AliHLTTrackPoint>& TrackPoints() const {return fTrackPoints;} |
290 | ||
e1e03704 | 291 | private: |
292 | vector<AliHLTTrackPoint> fTrackPoints; // list of points | |
54ff4c01 | 293 | vector<AliHLTUInt32_t> fSelectionMasks; // selection masks |
e1e03704 | 294 | |
295 | int fTrackId; // track id | |
54ff4c01 | 296 | int fVerbosity; // verbosity |
e1e03704 | 297 | |
298 | ClassDef(AliHLTTrackGeometry, 0) | |
299 | }; | |
300 | ||
301 | ostream& operator<<(ostream &out, const AliHLTTrackGeometry& c); | |
302 | ||
303 | #endif |