1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////
26 ///////////////////////////////////////////////////
28 #include <Riostream.h>
31 #include "AliMUONTrackParam.h"
32 #include "AliESDMuonTrack.h"
34 #include "AliMUONHitForRec.h"
37 ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
40 //_________________________________________________________________________
41 AliMUONTrackParam::AliMUONTrackParam()
47 fInverseBendingMomentum(0.),
55 //_________________________________________________________________________
56 AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam)
57 : TObject(theMUONTrackParam),
58 fNonBendingCoor(theMUONTrackParam.fNonBendingCoor),
59 fNonBendingSlope(theMUONTrackParam.fNonBendingSlope),
60 fBendingCoor(theMUONTrackParam.fBendingCoor),
61 fBendingSlope(theMUONTrackParam.fBendingSlope),
62 fInverseBendingMomentum(theMUONTrackParam.fInverseBendingMomentum),
63 fZ(theMUONTrackParam.fZ),
65 fHitForRecPtr(theMUONTrackParam.fHitForRecPtr)
68 if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
71 //_________________________________________________________________________
72 AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam)
74 /// Asignment operator
75 if (this == &theMUONTrackParam)
78 // base class assignement
79 TObject::operator=(theMUONTrackParam);
81 fNonBendingCoor = theMUONTrackParam.fNonBendingCoor;
82 fNonBendingSlope = theMUONTrackParam.fNonBendingSlope;
83 fBendingCoor = theMUONTrackParam.fBendingCoor;
84 fBendingSlope = theMUONTrackParam.fBendingSlope;
85 fInverseBendingMomentum = theMUONTrackParam.fInverseBendingMomentum;
86 fZ = theMUONTrackParam.fZ;
88 if (theMUONTrackParam.fCovariances) {
89 if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances);
90 else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
91 } else if (fCovariances) {
99 //__________________________________________________________________________
100 AliMUONTrackParam::~AliMUONTrackParam()
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
108 //__________________________________________________________________________
109 void AliMUONTrackParam::SetTrackParam(AliMUONTrackParam& theMUONTrackParam)
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;
120 //__________________________________________________________________________
121 AliMUONHitForRec* AliMUONTrackParam::GetHitForRecPtr(void) const
123 /// return pointer to HitForRec attached to the current TrackParam
124 /// this method should not be called when fHitForRecPtr == NULL
125 if (!fHitForRecPtr) AliWarning("fHitForRecPtr == NULL");
126 return fHitForRecPtr;
129 //__________________________________________________________________________
130 void AliMUONTrackParam::SetHitForRecPtr(AliMUONHitForRec* hitForRec)
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
137 //_________________________________________________________________________
138 void AliMUONTrackParam::GetParamFrom(const AliESDMuonTrack& esdMuonTrack)
140 /// assigned value form ESD track.
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();
149 //_________________________________________________________________________
150 void AliMUONTrackParam::SetParamFor(AliESDMuonTrack& esdMuonTrack)
152 /// assigned value form ESD track.
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);
161 //__________________________________________________________________________
162 Double_t AliMUONTrackParam::Px() const
164 /// return px from track paramaters
165 Double_t pYZ, pZ, pX;
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;
174 //__________________________________________________________________________
175 Double_t AliMUONTrackParam::Py() const
177 /// return px from track paramaters
178 Double_t pYZ, pZ, pY;
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;
187 //__________________________________________________________________________
188 Double_t AliMUONTrackParam::Pz() const
190 /// return px from track paramaters
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)
199 //__________________________________________________________________________
200 Double_t AliMUONTrackParam::P() const
202 /// return p from track paramaters
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)
209 TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope + fNonBendingSlope * fNonBendingSlope);
214 //__________________________________________________________________________
215 TMatrixD* AliMUONTrackParam::GetCovariances()
217 /// Return the covariance matrix (create it before if needed)
219 fCovariances = new TMatrixD(5,5);
225 //__________________________________________________________________________
226 void AliMUONTrackParam::SetCovariances(TMatrixD* covariances)
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);
234 //__________________________________________________________________________
235 void AliMUONTrackParam::SetCovariances(Double_t matrix[5][5])
237 /// Set the covariance matrix
238 if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
239 else fCovariances = new TMatrixD(5,5,&(matrix[0][0]));
242 //__________________________________________________________________________
243 void AliMUONTrackParam::SetVariances(Double_t matrix[5][5])
245 /// Set the diagonal terms of the covariance matrix (variances)
246 if (!fCovariances) fCovariances = new TMatrixD(5,5);
248 for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i];
251 //__________________________________________________________________________
252 void AliMUONTrackParam::DeleteCovariances()
254 /// Delete the covariance matrix
255 if (fCovariances) delete fCovariances;
259 //__________________________________________________________________________
260 void AliMUONTrackParam::EvalCovariances(AliMUONHitForRec* hit2)
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).
266 // Allocate memory if needed
267 if (!fCovariances) fCovariances = new TMatrixD(5,5);
269 // Reset the covariance matrix
272 if (!fHitForRecPtr) {
273 AliWarning("fHitForRecPtr == NULL: cannot calculate TrackParam covariances");
277 Double_t dz = fHitForRecPtr->GetZ() - hit2->GetZ();
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;
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%
294 //__________________________________________________________________________
295 Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const
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);
305 //_____________________________________________-
306 void AliMUONTrackParam::Print(Option_t* opt) const
308 /// Printing TrackParam information
309 /// "full" option for printing all the information about the TrackParam
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;
325 cout << "<AliMUONTrackParam>" << endl;