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 *
9 /// @file AliHLTTrackGeometry.h
10 /// @author Matthias Richter
12 /// @brief Desciption of a track by a sequence of track points
17 #include "AliHLTLogging.h"
18 #include "AliHLTDataTypes.h"
19 #include "AliHLTStdIncludes.h"
20 #include "AliHLTExternalTrackParam.h"
21 #include "AliHLTIndexGrid.h"
23 class AliHLTGlobalBarrelTrack;
24 class AliHLTSpacePointContainer;
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.
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.
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
42 * The geometry of planes can be defined in child classes defining the
44 * @ingroup alihlt_base
46 class AliHLTTrackGeometry : public TObject, public AliHLTLogging
49 /// standard constructor
50 AliHLTTrackGeometry();
52 AliHLTTrackGeometry(const AliHLTTrackGeometry&);
53 /// assignment operator
54 AliHLTTrackGeometry& operator=(const AliHLTTrackGeometry&);
57 ~AliHLTTrackGeometry();
59 typedef AliHLTIndexGrid<int, AliHLTUInt32_t> AliHLTTrackGrid;
62 void SetTrackId(int trackId) {fTrackId=trackId;}
64 int GetTrackId() const {return fTrackId;}
73 * class AliHLTTrackPlane
74 * Helper class to describe a plane
76 class AliHLTTrackPlane {
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;
82 virtual ~AliHLTTrackPlane() {}
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;}
93 // set bounds of u coordinate
94 void SetBoundsU(const float bounds[kBoundsDimension]) {
95 fBoundsU[kLower]=bounds[kLower]; fBoundsU[kUpper]=bounds[kUpper];
97 // set bounds of v coordinate
98 void SetBoundsV(const float bounds[kBoundsDimension]) {
99 fBoundsV[kLower]=bounds[kLower]; fBoundsV[kUpper]=bounds[kUpper];
102 bool CheckBounds(float u, float v) const {
103 return (u>=fBoundsU[kLower]) && (u<=fBoundsU[kUpper])
104 && (v>=fBoundsV[kLower]) && (v<=fBoundsV[kUpper]);
108 // standard constructor prohibited
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
119 class AliHLTTrackPlaneYZ : public AliHLTTrackPlane {
121 AliHLTTrackPlaneYZ(AliHLTUInt32_t id, float alpha, float r)
122 : AliHLTTrackPlane(id, alpha, r, 0.0) {}
123 ~AliHLTTrackPlaneYZ() {}
126 // standard constructor prohibited
127 AliHLTTrackPlaneYZ();
130 struct AliHLTTrackSpacepoint {
131 AliHLTTrackSpacepoint(AliHLTUInt32_t id, float dU=-1000., float dV=-1000.)
132 : fId(id), fdU(dU), fdV(dV) {}
134 int SetResidual(int coordinate, float value) {
135 if (coordinate==0) fdU=value;
136 else if (coordinate==1) fdV=value;
140 float GetResidual(int coordinate) const {
141 if (coordinate==0) return fdU;
142 else if (coordinate==1) return fdV;
146 AliHLTUInt32_t fId; // space point id
147 float fdU; // residual of the spacepoint
148 float fdV; // residual of the spacepoint
151 class AliHLTTrackPoint {
154 AliHLTTrackPoint(AliHLTUInt32_t id, float u, float v)
155 : fId(id), fU(u), fV(v), fSpacePoints() {}
157 AliHLTTrackPoint(const AliHLTTrackPoint& src)
158 : fId(src.fId), fU(src.fU), fV(src.fV), fSpacePoints(src.fSpacePoints) {}
159 // assignment operator
160 AliHLTTrackPoint& operator=(const AliHLTTrackPoint& src) {
161 if (this!=&src) {fId=src.fId; fU=src.fU; fV=src.fV; fSpacePoints=src.fSpacePoints;}
164 ~AliHLTTrackPoint() {}
166 bool operator==(const AliHLTTrackPoint& point) const {
167 return point.fId==fId;
169 bool operator==(AliHLTUInt32_t id) const {
174 AliHLTUInt32_t GetId() const {return fId;}
176 float GetU() const {return fU;}
178 float GetV() const {return fV;}
180 /// check associate space point
181 bool HaveAssociatedSpacePoint() const {
182 return fSpacePoints.size()>0;
185 /// associate a space point
186 int AddAssociatedSpacePoint(AliHLTUInt32_t spacepointId, float dU=-1000., float dV=-1000.) {
187 fSpacePoints.push_back(AliHLTTrackSpacepoint(spacepointId, dU, dV));
191 const vector<AliHLTTrackSpacepoint>& GetSpacepoints() const {return fSpacePoints;}
192 vector<AliHLTTrackSpacepoint>& GetSpacepoints() {return fSpacePoints;}
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);
203 // standard constructor prohibited
206 AliHLTUInt32_t fId; // unique id
207 float fU; // u coordinate
208 float fV; // v coordinate
209 vector<AliHLTTrackSpacepoint> fSpacePoints;
212 // interface to plane description
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;
225 /// calculate the track points, expects the global magnetic field to be initialized
226 virtual int CalculateTrackPoints(const AliHLTExternalTrackParam& track) = 0;
228 /// calculate the track points, expects the global magnetic field to be initialized
229 virtual int CalculateTrackPoints(AliHLTGlobalBarrelTrack& track) = 0;
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);
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;
240 /// register track points in the index grid
241 virtual int RegisterTrackPoints(AliHLTTrackGrid* pGrid) const;
243 /// fill track points to index grid
244 virtual int FillTrackPoints(AliHLTTrackGrid* pGrid) const;
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);
251 /// create a collection of all points
252 virtual AliHLTSpacePointContainer* ConvertToSpacePoints() const {return ConvertToSpacePoints(false);}
253 virtual AliHLTSpacePointContainer* ConvertToSpacePoints(bool bAssociated) const;
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
260 int SetAssociatedSpacePoint(AliHLTUInt32_t planeId, AliHLTUInt32_t spacepointId, int status, float fdU=0.0, float fdV=0.0);
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;
270 int FillResidual(int coordinate, TH2* histo) const;
272 void SetVerbosity(int verbosity) {fVerbosity=verbosity;}
273 int GetVerbosity() const {return fVerbosity;}
275 /// inherited from TObject: clear the object and reset pointer references
276 virtual void Clear(Option_t * /*option*/ ="");
278 /// inherited from TObject
279 virtual void Print(Option_t *option="") const;
281 virtual void Print(ostream& out, Option_t *option="") const;
283 /// Inherited from TObject, draw the track points
284 virtual void Draw(Option_t *option="");
287 int AddTrackPoint(const AliHLTTrackPoint& point, AliHLTUInt32_t selectionMask=kAliHLTVoidDataSpec);
289 const vector<AliHLTTrackPoint>& TrackPoints() const {return fTrackPoints;}
292 vector<AliHLTTrackPoint> fTrackPoints; // list of points
293 vector<AliHLTUInt32_t> fSelectionMasks; // selection masks
295 int fTrackId; // track id
296 int fVerbosity; // verbosity
298 ClassDef(AliHLTTrackGeometry, 0)
301 ostream& operator<<(ostream &out, const AliHLTTrackGeometry& c);