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