]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTrackParam.cxx
+ Modifications of the standard tracking algorithm:
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackParam.cxx
CommitLineData
a9e2aefa 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
88cb7938 16/* $Id$ */
a9e2aefa 17
3831f268 18///////////////////////////////////////////////////
19//
20// Track parameters
21// in
22// ALICE
23// dimuon
24// spectrometer
a9e2aefa 25//
3831f268 26///////////////////////////////////////////////////
a9e2aefa 27
37827b29 28#include <Riostream.h>
208f139e 29#include <TMatrixD.h>
37827b29 30
31#include "AliMUONTrackParam.h"
211c52eb 32#include "AliESDMuonTrack.h"
37827b29 33#include "AliLog.h"
de2cd600 34#include "AliMUONHitForRec.h"
a9e2aefa 35
7945aae7 36/// \cond CLASSIMP
a9e2aefa 37ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
7945aae7 38/// \endcond
a9e2aefa 39
61adb9bd 40 //_________________________________________________________________________
30178c30 41AliMUONTrackParam::AliMUONTrackParam()
54d7ba50 42 : TObject(),
208f139e 43 fNonBendingCoor(0.),
54d7ba50 44 fNonBendingSlope(0.),
54d7ba50 45 fBendingCoor(0.),
208f139e 46 fBendingSlope(0.),
47 fInverseBendingMomentum(0.),
48 fZ(0.),
49 fCovariances(0x0),
de2cd600 50 fHitForRecPtr(0x0)
30178c30 51{
37827b29 52 /// Constructor
30178c30 53}
61adb9bd 54
30178c30 55 //_________________________________________________________________________
de2cd600 56AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam)
57 : TObject(theMUONTrackParam),
208f139e 58 fNonBendingCoor(theMUONTrackParam.fNonBendingCoor),
de2cd600 59 fNonBendingSlope(theMUONTrackParam.fNonBendingSlope),
de2cd600 60 fBendingCoor(theMUONTrackParam.fBendingCoor),
208f139e 61 fBendingSlope(theMUONTrackParam.fBendingSlope),
62 fInverseBendingMomentum(theMUONTrackParam.fInverseBendingMomentum),
63 fZ(theMUONTrackParam.fZ),
64 fCovariances(0x0),
de2cd600 65 fHitForRecPtr(theMUONTrackParam.fHitForRecPtr)
66{
2457f726 67 /// Copy constructor
208f139e 68 if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
de2cd600 69}
70
71 //_________________________________________________________________________
72AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam)
61adb9bd 73{
2457f726 74 /// Asignment operator
30178c30 75 if (this == &theMUONTrackParam)
61adb9bd 76 return *this;
77
30178c30 78 // base class assignement
79 TObject::operator=(theMUONTrackParam);
80
208f139e 81 fNonBendingCoor = theMUONTrackParam.fNonBendingCoor;
82 fNonBendingSlope = theMUONTrackParam.fNonBendingSlope;
83 fBendingCoor = theMUONTrackParam.fBendingCoor;
84 fBendingSlope = theMUONTrackParam.fBendingSlope;
85 fInverseBendingMomentum = theMUONTrackParam.fInverseBendingMomentum;
86 fZ = theMUONTrackParam.fZ;
87
88 if (theMUONTrackParam.fCovariances) {
89 if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances);
90 else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
91 } else if (fCovariances) {
92 delete fCovariances;
93 fCovariances = 0x0;
94 }
95
61adb9bd 96 return *this;
97}
de2cd600 98
99 //__________________________________________________________________________
100AliMUONTrackParam::~AliMUONTrackParam()
61adb9bd 101{
de2cd600 102/// Destructor
103/// Update the number of TrackHit's connected to the attached HitForRec if any
104 if (fHitForRecPtr) fHitForRecPtr->SetNTrackHits(fHitForRecPtr->GetNTrackHits() - 1); // decrement NTrackHits of hit
208f139e 105 DeleteCovariances();
de2cd600 106}
107
108 //__________________________________________________________________________
109void AliMUONTrackParam::SetTrackParam(AliMUONTrackParam& theMUONTrackParam)
110{
208f139e 111 /// Set track parameters from "TrackParam" leaving pointer to fHitForRecPtr and parameter covariances unchanged
112 fNonBendingCoor = theMUONTrackParam.fNonBendingCoor;
113 fNonBendingSlope = theMUONTrackParam.fNonBendingSlope;
114 fBendingCoor = theMUONTrackParam.fBendingCoor;
115 fBendingSlope = theMUONTrackParam.fBendingSlope;
116 fInverseBendingMomentum = theMUONTrackParam.fInverseBendingMomentum;
117 fZ = theMUONTrackParam.fZ;
de2cd600 118}
54d7ba50 119
de2cd600 120 //__________________________________________________________________________
121AliMUONHitForRec* AliMUONTrackParam::GetHitForRecPtr(void) const
122{
123/// return pointer to HitForRec attached to the current TrackParam
124/// this method should not be called when fHitForRecPtr == NULL
208f139e 125 if (!fHitForRecPtr) AliWarning("fHitForRecPtr == NULL");
de2cd600 126 return fHitForRecPtr;
127}
128
129 //__________________________________________________________________________
208f139e 130void AliMUONTrackParam::SetHitForRecPtr(AliMUONHitForRec* hitForRec)
de2cd600 131{
208f139e 132/// set pointeur to associated HitForRec and update the number of TrackHit's connected to it
133 fHitForRecPtr = hitForRec;
134 fHitForRecPtr->SetNTrackHits(fHitForRecPtr->GetNTrackHits() + 1); // increment NTrackHits of hit
61adb9bd 135}
a9e2aefa 136
211c52eb 137 //_________________________________________________________________________
138void AliMUONTrackParam::GetParamFrom(const AliESDMuonTrack& esdMuonTrack)
139{
2457f726 140 /// assigned value form ESD track.
208f139e 141 fInverseBendingMomentum = esdMuonTrack.GetInverseBendingMomentum();
142 fBendingSlope = TMath::Tan(esdMuonTrack.GetThetaY());
143 fNonBendingSlope = TMath::Tan(esdMuonTrack.GetThetaX());
144 fZ = esdMuonTrack.GetZ();
145 fBendingCoor = esdMuonTrack.GetBendingCoor();
146 fNonBendingCoor = esdMuonTrack.GetNonBendingCoor();
211c52eb 147}
148
149 //_________________________________________________________________________
150void AliMUONTrackParam::SetParamFor(AliESDMuonTrack& esdMuonTrack)
151{
2457f726 152 /// assigned value form ESD track.
211c52eb 153 esdMuonTrack.SetInverseBendingMomentum(fInverseBendingMomentum);
154 esdMuonTrack.SetThetaX(TMath::ATan(fNonBendingSlope));
155 esdMuonTrack.SetThetaY(TMath::ATan(fBendingSlope));
156 esdMuonTrack.SetZ(fZ);
157 esdMuonTrack.SetBendingCoor(fBendingCoor);
158 esdMuonTrack.SetNonBendingCoor(fNonBendingCoor);
159}
160
b8dc484b 161 //__________________________________________________________________________
6464217e 162Double_t AliMUONTrackParam::Px() const
b8dc484b 163{
2457f726 164 /// return px from track paramaters
b8dc484b 165 Double_t pYZ, pZ, pX;
166 pYZ = 0;
167 if ( TMath::Abs(fInverseBendingMomentum) > 0 )
168 pYZ = TMath::Abs(1.0 / fInverseBendingMomentum);
169 pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0)
170 pX = pZ * fNonBendingSlope;
171 return pX;
172}
37827b29 173
b8dc484b 174 //__________________________________________________________________________
6464217e 175Double_t AliMUONTrackParam::Py() const
b8dc484b 176{
2457f726 177 /// return px from track paramaters
b8dc484b 178 Double_t pYZ, pZ, pY;
179 pYZ = 0;
180 if ( TMath::Abs(fInverseBendingMomentum) > 0 )
181 pYZ = TMath::Abs(1.0 / fInverseBendingMomentum);
182 pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0)
183 pY = pZ * fBendingSlope;
184 return pY;
185}
37827b29 186
b8dc484b 187 //__________________________________________________________________________
6464217e 188Double_t AliMUONTrackParam::Pz() const
b8dc484b 189{
2457f726 190 /// return px from track paramaters
b8dc484b 191 Double_t pYZ, pZ;
192 pYZ = 0;
193 if ( TMath::Abs(fInverseBendingMomentum) > 0 )
194 pYZ = TMath::Abs(1.0 / fInverseBendingMomentum);
195 pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0)
196 return pZ;
197}
37827b29 198
b8dc484b 199 //__________________________________________________________________________
6464217e 200Double_t AliMUONTrackParam::P() const
b8dc484b 201{
2457f726 202 /// return p from track paramaters
b8dc484b 203 Double_t pYZ, pZ, p;
204 pYZ = 0;
205 if ( TMath::Abs(fInverseBendingMomentum) > 0 )
206 pYZ = TMath::Abs(1.0 / fInverseBendingMomentum);
207 pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0)
208 p = TMath::Abs(pZ) *
209 TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope + fNonBendingSlope * fNonBendingSlope);
210 return p;
211
b45fd22b 212}
4d03a78e 213
208f139e 214 //__________________________________________________________________________
215TMatrixD* AliMUONTrackParam::GetCovariances()
216{
217 /// Return the covariance matrix (create it before if needed)
218 if (!fCovariances) {
219 fCovariances = new TMatrixD(5,5);
220 (*fCovariances) = 0;
221 }
222 return fCovariances;
223 }
224
225 //__________________________________________________________________________
226void AliMUONTrackParam::SetCovariances(TMatrixD* covariances)
227{
228 /// Set the covariance matrix
229 if (covariances == fCovariances) return; // nothing to be done
230 if (fCovariances) *fCovariances = *covariances;
231 else fCovariances = new TMatrixD(*covariances);
232}
233
234 //__________________________________________________________________________
235void AliMUONTrackParam::SetCovariances(Double_t matrix[5][5])
236{
237 /// Set the covariance matrix
238 if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
239 else fCovariances = new TMatrixD(5,5,&(matrix[0][0]));
240}
241
242 //__________________________________________________________________________
243void AliMUONTrackParam::SetVariances(Double_t matrix[5][5])
244{
245 /// Set the diagonal terms of the covariance matrix (variances)
246 if (!fCovariances) fCovariances = new TMatrixD(5,5);
247 (*fCovariances) = 0;
248 for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i];
249}
250
251 //__________________________________________________________________________
252void AliMUONTrackParam::DeleteCovariances()
253{
254 /// Delete the covariance matrix
255 if (fCovariances) delete fCovariances;
256 fCovariances = 0x0;
257}
258
259 //__________________________________________________________________________
260void AliMUONTrackParam::EvalCovariances(AliMUONHitForRec* hit2)
261{
262 /// Evaluate covariances assuming the track is only a straight line
263 /// between the HitForRec attached to the current TrackParam and hit2.
264 /// Nothing can be done on fInverseBendingMomentum (-> 50% err).
265
266 // Allocate memory if needed
267 if (!fCovariances) fCovariances = new TMatrixD(5,5);
268
269 // Reset the covariance matrix
270 (*fCovariances) = 0;
271
272 if (!fHitForRecPtr) {
273 AliWarning("fHitForRecPtr == NULL: cannot calculate TrackParam covariances");
274 return;
275 }
276
277 Double_t dz = fHitForRecPtr->GetZ() - hit2->GetZ();
278
279 // Non bending plane
280 (*fCovariances)(0,0) = fHitForRecPtr->GetNonBendingReso2();
281 (*fCovariances)(0,1) = fHitForRecPtr->GetNonBendingReso2() / dz;
282 (*fCovariances)(1,0) = (*fCovariances)(0,1);
283 (*fCovariances)(1,1) = ( fHitForRecPtr->GetNonBendingReso2() + hit2->GetNonBendingReso2() ) / dz / dz;
284 // Bending plane
285 (*fCovariances)(2,2) = fHitForRecPtr->GetBendingReso2();
286 (*fCovariances)(2,3) = fHitForRecPtr->GetBendingReso2() / dz;
287 (*fCovariances)(3,2) = (*fCovariances)(2,3);
288 (*fCovariances)(3,3) = ( fHitForRecPtr->GetBendingReso2() + hit2->GetBendingReso2() ) / dz / dz;
289 // Inverse bending momentum
290 (*fCovariances)(4,4) = 0.5*fInverseBendingMomentum * 0.5*fInverseBendingMomentum; // error 50%
291
292}
293
294 //__________________________________________________________________________
295Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const
296{
297 /// "Compare" function to sort with decreasing Z (spectro. muon Z <0).
298 /// Returns 1 (0, -1) if Z of current TrackHit
299 /// is smaller than (equal to, larger than) Z of TrackHit
300 if (fHitForRecPtr->GetZ() < ((AliMUONTrackParam*)trackParam)->fHitForRecPtr->GetZ()) return(1);
301 else if (fHitForRecPtr->GetZ() == ((AliMUONTrackParam*)trackParam)->fHitForRecPtr->GetZ()) return(0);
302 else return(-1);
303}
304
6464217e 305//_____________________________________________-
306void AliMUONTrackParam::Print(Option_t* opt) const
307{
2457f726 308 /// Printing TrackParam information
309 /// "full" option for printing all the information about the TrackParam
6464217e 310 TString sopt(opt);
311 sopt.ToUpper();
312
313 if ( sopt.Contains("FULL") ) {
314 cout << "<AliMUONTrackParam> Bending P=" << setw(5) << setprecision(3) << 1./GetInverseBendingMomentum() <<
315 ", NonBendSlope=" << setw(5) << setprecision(3) << GetNonBendingSlope()*180./TMath::Pi() <<
316 ", BendSlope=" << setw(5) << setprecision(3) << GetBendingSlope()*180./TMath::Pi() <<
317 ", (x,y,z)_IP=(" << setw(5) << setprecision(3) << GetNonBendingCoor() <<
318 "," << setw(5) << setprecision(3) << GetBendingCoor() <<
319 "," << setw(5) << setprecision(3) << GetZ() <<
320 ") cm, (px,py,pz)=(" << setw(5) << setprecision(3) << Px() <<
321 "," << setw(5) << setprecision(3) << Py() <<
322 "," << setw(5) << setprecision(3) << Pz() << ") GeV/c" << endl;
323 }
324 else {
325 cout << "<AliMUONTrackParam>" << endl;
326 }
327
328}