]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/MUON/AliHLTMUONTrack.h
Fixing potencial null pointer bug.
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONTrack.h
1 #ifndef ALIHLTMUONTRACK_H
2 #define ALIHLTMUONTRACK_H
3 /* This file is property of and copyright by the ALICE HLT Project        *
4  * ALICE Experiment at CERN, All rights reserved.                         *
5  * See cxx source for full Copyright notice                               */
6
7 ///
8 /// @file   AliHLTMUONTrack.h
9 /// @author Indranil Das <indra.ehep@gmail.com> and Artur Szostak <artursz@iafrica.com>
10 /// @date   10 March 2010
11 /// @brief  Declaration of the track class used to store converted dHLT track data.
12 ///
13
14 #include "TObject.h"
15 #include "TVector3.h"
16
17 class AliHLTMUONTriggerRecord;
18 class AliHLTMUONRecHit;
19
20 /**
21  * AliHLTMUONTrack stores converted dHLT raw track data from HLT raw data blocks
22  * as a ROOT object. This class is mainly for testing or as a helper object for
23  * dHLT specific analysis, since it is sometimes easier to store and handle ROOT
24  * objects than the raw data blocks.
25  */
26 class AliHLTMUONTrack : public TObject
27 {
28         /**
29          * Stream operator for usage with std::ostream classes.
30          * Allows usage such as:
31          *   AliHLTMUONTrack t; std::cout << t;
32          */
33         friend std::ostream& operator << (
34                         std::ostream& stream,
35                         const AliHLTMUONTrack& track
36                 );
37
38 public:
39
40         /**
41          * Constructor for creating a new track object.
42          * \note this class does not take ownership of the hit or trigger record
43          * objects and will not attempt to delete them. This must be done by the
44          * caller.
45          * @param id       The track ID number which must be unique for any event.
46          * @param sign     The particle's sign: -1, 1 or 0 if unknown.
47          * @param px       X component of the particle's momentum (GeV/c).
48          * @param py       Y component of the particle's momentum (GeV/c).
49          * @param pz       Z component of the particle's momentum (GeV/c).
50          * @param invmom   Inverse bending momentum (GeV/c).
51          * @param thetaX   The non-bending plane slope of the fitted track.
52          * @param thetaY   The bending plane slope of the fitted track.
53          * @param x        X coordinate of the particle's distance of closest
54          *                 approach (DCA) position (cm).
55          * @param y        Y coordinate of the particle's DCA position (cm).
56          * @param z        Z coordinate of the particle's DCA position (cm).
57          * @param chi2     The chi squared of the track fit.
58          * @param trigrec  Corresponding trigger record used as a seed to find
59          *                 this track.
60          * @param hits     The array of 16 hit coordinates found for the track.
61          *                 If NULL then then all hit coordinates are set to empty.
62          */
63         AliHLTMUONTrack(
64                         Int_t id = -1, Int_t sign = 0,
65                         Float_t px = 0, Float_t py = 0, Float_t pz = 0,
66                         Float_t invmom = 0, Float_t thetaX = 0, Float_t thetaY = 0,
67                         Float_t x = 0, Float_t y = 0, Float_t z = 0,
68                         Float_t chi2 = -1,
69                         const AliHLTMUONTriggerRecord* trigrec = NULL,
70                         const AliHLTMUONRecHit* hits[16] = NULL
71                 );
72         
73         /**
74          * Default destructor.
75          */
76         virtual ~AliHLTMUONTrack() {}
77
78         /**
79          * Returns the track ID number, which should be unique for an event.
80          */
81         Int_t Id() const { return fId; }
82         
83         /**
84          * Returns the sign of the particle: -1, 1 or 0 if the sign is unknown.
85          */
86         Int_t Sign() const { return fSign; }
87         
88         /**
89          * Returns the inverse momentum in the bending plane, i.e. 1/p_yz, in units c/GeV.
90          */
91         Float_t InverseBendingMomentum() const { return fInverseBendingMomentum; }
92         
93         /**
94          * Returns the slope of the fitted track in the non-bending plane.
95          */
96         Float_t ThetaX() const { return fThetaX; }
97         
98         /**
99          * Returns the slope of the fitted track in the bending plane.
100          */
101         Float_t ThetaY() const { return fThetaY; }
102
103         /**
104          * Returns the momentum vector with components in GeV/c.
105          */
106         const TVector3& Momentum() const { return fMomentum; }
107
108         /**
109          * Returns the X component of the particle's momentum in GeV/c.
110          */
111         Double_t Px() const { return fMomentum.Px(); }
112
113         /**
114          * Returns the Y component of the particle's momentum in GeV/c.
115          */
116         Double_t Py() const { return fMomentum.Py(); }
117
118         /**
119          * Returns the Z component of the particle's momentum in GeV/c.
120          */
121         Double_t Pz() const { return fMomentum.Pz(); }
122
123         /**
124          * Returns the momentum magnitude of the particle in GeV/c.
125          */
126         Double_t P() const { return fMomentum.Mag(); }
127
128         /**
129          * Returns the transverse momentum of the particle in GeV/c.
130          */
131         Double_t Pt() const { return fMomentum.Pt(); }
132
133         /**
134          * Returns the polar angle of the momentum vector in radians.
135          */
136         Double_t Polar() const { return fMomentum.Theta(); }
137
138         /**
139          * Returns the azimuthal angle of the transverse momentum in radians.
140          */
141         Double_t Phi() const { return fMomentum.Phi(); }
142
143         /**
144          * Returns the distance of closest approach (DCA) position in centimetres.
145          */
146         const TVector3& VertexDCA() const { return fVertexDCA; }
147
148         /**
149          * Returns the non-bending plane coordinate for the distance of closest approach (DCA) in cm.
150          */
151         Double_t X() const { return fVertexDCA.X(); }
152
153         /**
154          * Returns the bending plane coordinate for the distance of closest approach (DCA) in cm.
155          */
156         Double_t Y() const { return fVertexDCA.Y(); }
157
158         /**
159          * Returns the z coordinate for the distance of closest approach (DCA) in cm.
160          */
161         Double_t Z() const { return fVertexDCA.Z(); }
162
163         /**
164          * Returns the chi squared of the track fit, indicating the quality of
165          * the fit.
166          */
167         Float_t Chi2() const { return fChi2; }
168
169         /**
170          * Returns the trigger record corresponding to this track.
171          * If NULL is returned then no trigger record was found or associated
172          * with the track.
173          */
174         const AliHLTMUONTriggerRecord* TriggerRecord() const { return fTrigRec; }
175
176         /**
177          * Returns the i'th hit set for this track.
178          * If NULL is returned then no hit was found or set for that hit position.
179          * @param i  Specifies the number of the hit to return.
180          *           Valid values are in the range [0..15].
181          */
182         const AliHLTMUONRecHit* Hit(Int_t i) const;
183
184         /**
185          * Returns the first hit found on the specified tracking chamber.
186          * If NULL is returned then no hit was found or set for that chamber.
187          * @param chamber  Specifies the chamber for which to return the hit.
188          *                 Valid values are in the range [1..14].
189          */
190         const AliHLTMUONRecHit* HitByChamber(Int_t chamber) const;
191         
192         /**
193          * Prints the details of the track.
194          * @param option  A case sensitive string that can contain one of the
195          *     following strings:
196          *       "compact" - Prints just the momentum, sign and ID of the track
197          *                   in a terse format.
198          *       "detail" - Prints also the hit information.
199          *       "all" - Prints all known information about this track.
200          *     If the string contains an empty option or NULL then the default is
201          *     to print compactly.
202          */
203         virtual void Print(Option_t* option = NULL) const;
204         
205         // Methods inherited from TObject
206         virtual Bool_t IsSortable() const { return kTRUE; }
207         Int_t Compare(const TObject* obj) const;
208
209         // Implement comparison operators.
210         bool operator == (const AliHLTMUONTrack& track) const;
211
212         bool operator != (const AliHLTMUONTrack& track) const
213         {
214                 return not this->operator == (track);
215         }
216
217 private:
218
219         // Do not allow copying of this class.
220         AliHLTMUONTrack(const AliHLTMUONTrack& track);
221         AliHLTMUONTrack& operator = (const AliHLTMUONTrack& track);
222         
223         Int_t fId; ///< Track ID number which is unique for a particular event.
224         Int_t fSign;  ///< The sign of the particle.
225         Float_t fInverseBendingMomentum; ///< One over the momentum of the fitted track in GeV/c.
226         Float_t fThetaX; ///< The slope of the fitted track in the non-bending plane.
227         Float_t fThetaY; ///< The slope of the fitted track in the bending plane.
228         TVector3 fMomentum; ///< Momentum vector of the particle in GeV/c.
229         TVector3 fVertexDCA; ///< The position for the distance of closest approach to the vertex in cm.
230         Float_t fChi2; ///< Chi squared of fit.
231         const AliHLTMUONTriggerRecord* fTrigRec;  ///< Corresponding trigger record.
232         const AliHLTMUONRecHit* fHit[16];   ///< Particle hits on tracking chambers.
233
234         ClassDef(AliHLTMUONTrack, 1); // Track object containing data converted from a dHLT internal track structure.
235 };
236
237 #endif // ALIHLTMUONTRACK_H