]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTrack.cxx
No effective C++ option for compilation of C files
[u/mrichter/AliRoot.git] / MUON / AliMUONTrack.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///////////////////////////////////////////////////
a9e2aefa 19//
3831f268 20// Reconstructed track
21// in
22// ALICE
23// dimuon
24// spectrometer
25//
26///////////////////////////////////////////////////
a9e2aefa 27
2457f726 28#include <stdlib.h> // for exit()
29#include <Riostream.h>
208f139e 30#include <TMatrixD.h>
2457f726 31
63ed9c6b 32#include "AliMUONTrack.h"
34f1bfa0 33
de2cd600 34#include "AliMUONTrackParam.h"
a9e2aefa 35#include "AliMUONHitForRec.h"
d837040f 36#include "AliMUONConstants.h"
208f139e 37#include "AliMUONTrackExtrap.h"
a9e2aefa 38
63ed9c6b 39#include "AliLog.h"
40
63ed9c6b 41#include <TMath.h>
63ed9c6b 42
7945aae7 43/// \cond CLASSIMP
63ed9c6b 44ClassImp(AliMUONTrack) // Class implementation in ROOT context
7945aae7 45/// \endcond
63ed9c6b 46
208f139e 47const Double_t AliMUONTrack::fgkMaxTrackingDistanceBending = 2.;
48const Double_t AliMUONTrack::fgkMaxTrackingDistanceNonBending = 2.;
49
63ed9c6b 50//__________________________________________________________________________
30178c30 51AliMUONTrack::AliMUONTrack()
54d7ba50 52 : TObject(),
54d7ba50 53 fTrackParamAtVertex(),
54 fTrackParamAtHit(0x0),
55 fHitForRecAtHit(0x0),
54d7ba50 56 fNTrackHits(0),
208f139e 57 fExtrapTrackParam(),
58 fFitWithVertex(kFALSE),
59 fVertex(0x0),
54d7ba50 60 fFitFMin(-1.),
61 fMatchTrigger(kFALSE),
62 fChi2MatchTrigger(0.),
63 fTrackID(0)
d837040f 64{
2457f726 65 /// Default constructor
d837040f 66}
67
a9e2aefa 68 //__________________________________________________________________________
208f139e 69AliMUONTrack::AliMUONTrack(AliMUONHitForRec* hitForRec1, AliMUONHitForRec* hitForRec2)
54d7ba50 70 : TObject(),
54d7ba50 71 fTrackParamAtVertex(),
72 fTrackParamAtHit(0x0),
73 fHitForRecAtHit(0x0),
54d7ba50 74 fNTrackHits(0),
208f139e 75 fExtrapTrackParam(),
76 fFitWithVertex(kFALSE),
77 fVertex(0x0),
54d7ba50 78 fFitFMin(-1.),
79 fMatchTrigger(kFALSE),
80 fChi2MatchTrigger(0.),
81 fTrackID(0)
a9e2aefa 82{
208f139e 83 /// Constructor from thw hitForRec's
54d7ba50 84
d837040f 85 fTrackParamAtHit = new TClonesArray("AliMUONTrackParam",10);
b8dc484b 86 fHitForRecAtHit = new TClonesArray("AliMUONHitForRec",10);
de2cd600 87
208f139e 88 if (!hitForRec1) return; //AZ
89
90 // Add hits to the track
91 AddTrackParamAtHit(0,hitForRec1);
92 AddTrackParamAtHit(0,hitForRec2);
93
94 // sort TrackParamAtHit according to increasing -Z
95 fTrackParamAtHit->Sort();
96
97 // Set track parameters at first track hit
98 AliMUONTrackParam* trackParamAtFirstHit = (AliMUONTrackParam*) fTrackParamAtHit->First();
99 AliMUONHitForRec* firstHit = trackParamAtFirstHit->GetHitForRecPtr();
100 AliMUONHitForRec* lastHit = ((AliMUONTrackParam*) fTrackParamAtHit->Last())->GetHitForRecPtr();
847cbaef 101 Double_t dZ = firstHit->GetZ() - lastHit->GetZ();
208f139e 102 // Non bending plane
103 Double_t nonBendingCoor = firstHit->GetNonBendingCoor();
104 trackParamAtFirstHit->SetNonBendingCoor(nonBendingCoor);
105 trackParamAtFirstHit->SetNonBendingSlope((nonBendingCoor - lastHit->GetNonBendingCoor()) / dZ);
106 // Bending plane
107 Double_t bendingCoor = firstHit->GetBendingCoor();
108 trackParamAtFirstHit->SetBendingCoor(bendingCoor);
109 Double_t bendingSlope = (bendingCoor - lastHit->GetBendingCoor()) / dZ;
110 trackParamAtFirstHit->SetBendingSlope(bendingSlope);
111 // Inverse bending momentum
847cbaef 112 Double_t bendingImpact = bendingCoor - firstHit->GetZ() * bendingSlope;
208f139e 113 Double_t inverseBendingMomentum = 1. / AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(bendingImpact);
114 trackParamAtFirstHit->SetInverseBendingMomentum(inverseBendingMomentum);
115
116 // Evaluate covariances
117 TMatrixD *paramCov = trackParamAtFirstHit->GetCovariances();
118 (*paramCov) = 0;
119 // Non bending plane
120 (*paramCov)(0,0) = firstHit->GetNonBendingReso2();
121 (*paramCov)(0,1) = firstHit->GetNonBendingReso2() / dZ;
122 (*paramCov)(1,0) = (*paramCov)(0,1);
123 (*paramCov)(1,1) = ( firstHit->GetNonBendingReso2() + lastHit->GetNonBendingReso2() ) / dZ / dZ;
124 // Bending plane
125 (*paramCov)(2,2) = firstHit->GetBendingReso2();
126 (*paramCov)(2,3) = firstHit->GetBendingReso2() / dZ;
127 (*paramCov)(3,2) = (*paramCov)(2,3);
128 (*paramCov)(3,3) = ( firstHit->GetBendingReso2() + lastHit->GetBendingReso2() ) / dZ / dZ;
129 // Inverse bending momentum (50% error)
130 (*paramCov)(4,4) = 0.5*inverseBendingMomentum * 0.5*inverseBendingMomentum;
de2cd600 131
a9e2aefa 132}
133
8429a5e4 134 //__________________________________________________________________________
135AliMUONTrack::~AliMUONTrack()
136{
2457f726 137 /// Destructor
d837040f 138 if (fTrackParamAtHit) {
139 // delete the TClonesArray of pointers to TrackParam
140 delete fTrackParamAtHit;
208f139e 141 fTrackParamAtHit = 0x0;
d837040f 142 }
b8dc484b 143
144 if (fHitForRecAtHit) {
145 // delete the TClonesArray of pointers to HitForRec
146 delete fHitForRecAtHit;
208f139e 147 fHitForRecAtHit = 0x0;
148 }
149
150 if (fVertex) {
151 // delete the vertex used during the tracking procedure
152 delete fVertex;
153 fVertex = 0x0;
b8dc484b 154 }
8429a5e4 155}
156
956019b6 157 //__________________________________________________________________________
30178c30 158AliMUONTrack::AliMUONTrack (const AliMUONTrack& theMUONTrack)
54d7ba50 159 : TObject(theMUONTrack),
54d7ba50 160 fTrackParamAtVertex(theMUONTrack.fTrackParamAtVertex),
161 fTrackParamAtHit(0x0),
162 fHitForRecAtHit(0x0),
54d7ba50 163 fNTrackHits(theMUONTrack.fNTrackHits),
208f139e 164 fExtrapTrackParam(theMUONTrack.fExtrapTrackParam),
165 fFitWithVertex(theMUONTrack.fFitWithVertex),
166 fVertex(0x0),
54d7ba50 167 fFitFMin(theMUONTrack.fFitFMin),
168 fMatchTrigger(theMUONTrack.fMatchTrigger),
169 fChi2MatchTrigger(theMUONTrack.fChi2MatchTrigger),
170 fTrackID(theMUONTrack.fTrackID)
a9e2aefa 171{
2457f726 172 ///copy constructor
de2cd600 173 Int_t maxIndex = 0;
174
e516b01d 175 // necessary to make a copy of the objects and not only the pointers in TClonesArray.
a8865299 176 if (theMUONTrack.fTrackParamAtHit) {
de2cd600 177 maxIndex = (theMUONTrack.fTrackParamAtHit)->GetEntriesFast();
208f139e 178 fTrackParamAtHit = new TClonesArray("AliMUONTrackParam",maxIndex);
de2cd600 179 for (Int_t index = 0; index < maxIndex; index++) {
180 new ((*fTrackParamAtHit)[index]) AliMUONTrackParam(*(AliMUONTrackParam*)theMUONTrack.fTrackParamAtHit->At(index));
a8865299 181 }
208f139e 182 }
183
b8dc484b 184 // necessary to make a copy of the objects and not only the pointers in TClonesArray.
a8865299 185 if (theMUONTrack.fHitForRecAtHit) {
de2cd600 186 maxIndex = (theMUONTrack.fHitForRecAtHit)->GetEntriesFast();
208f139e 187 fHitForRecAtHit = new TClonesArray("AliMUONHitForRec",maxIndex);
de2cd600 188 for (Int_t index = 0; index < maxIndex; index++) {
189 new ((*fHitForRecAtHit)[index]) AliMUONHitForRec(*(AliMUONHitForRec*)theMUONTrack.fHitForRecAtHit->At(index));
a8865299 190 }
208f139e 191 }
192
193 // copy vertex used during the tracking procedure if any
194 if (theMUONTrack.fVertex) fVertex = new AliMUONHitForRec(*(theMUONTrack.fVertex));
195
a9e2aefa 196}
197
956019b6 198 //__________________________________________________________________________
30178c30 199AliMUONTrack & AliMUONTrack::operator=(const AliMUONTrack& theMUONTrack)
a9e2aefa 200{
2457f726 201 /// Asignment operator
30178c30 202 // check assignement to self
203 if (this == &theMUONTrack)
a9e2aefa 204 return *this;
61adb9bd 205
30178c30 206 // base class assignement
207 TObject::operator=(theMUONTrack);
208
de2cd600 209 fTrackParamAtVertex = theMUONTrack.fTrackParamAtVertex;
e516b01d 210
de2cd600 211 Int_t maxIndex = 0;
212
e516b01d 213 // necessary to make a copy of the objects and not only the pointers in TClonesArray.
a8865299 214 if (theMUONTrack.fTrackParamAtHit) {
208f139e 215 if (fTrackParamAtHit) fTrackParamAtHit->Clear();
216 else fTrackParamAtHit = new TClonesArray("AliMUONTrackParam",10);
de2cd600 217 maxIndex = (theMUONTrack.fTrackParamAtHit)->GetEntriesFast();
218 for (Int_t index = 0; index < maxIndex; index++) {
219 new ((*fTrackParamAtHit)[fTrackParamAtHit->GetEntriesFast()])
220 AliMUONTrackParam(*(AliMUONTrackParam*)(theMUONTrack.fTrackParamAtHit)->At(index));
a8865299 221 }
208f139e 222 } else if (fTrackParamAtHit) {
223 delete fTrackParamAtHit;
224 fTrackParamAtHit = 0x0;
225 }
e516b01d 226
b8dc484b 227 // necessary to make a copy of the objects and not only the pointers in TClonesArray.
de2cd600 228 if (theMUONTrack.fHitForRecAtHit) {
208f139e 229 if (fHitForRecAtHit) fHitForRecAtHit->Clear();
230 else fHitForRecAtHit = new TClonesArray("AliMUONHitForRec",10);
de2cd600 231 maxIndex = (theMUONTrack.fHitForRecAtHit)->GetEntriesFast();
232 for (Int_t index = 0; index < maxIndex; index++) {
233 new ((*fHitForRecAtHit)[fHitForRecAtHit->GetEntriesFast()])
234 AliMUONHitForRec(*(AliMUONHitForRec*)(theMUONTrack.fHitForRecAtHit)->At(index));
a8865299 235 }
208f139e 236 } else if (fHitForRecAtHit) {
237 delete fHitForRecAtHit;
238 fHitForRecAtHit = 0x0;
239 }
240
241 // copy vertex used during the tracking procedure if any.
242 if (theMUONTrack.fVertex) {
243 if (fVertex) *fVertex = *(theMUONTrack.fVertex);
244 else fVertex = new AliMUONHitForRec(*(theMUONTrack.fVertex));
245 } else if (fVertex) {
246 delete fVertex;
247 fVertex = 0x0;
248 }
249
250 fExtrapTrackParam = theMUONTrack.fExtrapTrackParam;
de2cd600 251
30178c30 252 fNTrackHits = theMUONTrack.fNTrackHits;
208f139e 253 fFitWithVertex = theMUONTrack.fFitWithVertex;
30178c30 254 fFitFMin = theMUONTrack.fFitFMin;
30178c30 255 fMatchTrigger = theMUONTrack.fMatchTrigger;
256 fChi2MatchTrigger = theMUONTrack.fChi2MatchTrigger;
b8dc484b 257 fTrackID = theMUONTrack.fTrackID;
30178c30 258
61adb9bd 259 return *this;
a9e2aefa 260}
261
8429a5e4 262 //__________________________________________________________________________
de2cd600 263void AliMUONTrack::AddTrackParamAtHit(AliMUONTrackParam *trackParam, AliMUONHitForRec *hitForRec)
8429a5e4 264{
847cbaef 265 /// Add TrackParamAtHit if "trackParam" != NULL
266 /// else create empty TrackParamAtHit and set the z position to the one of "hitForRec" if any
2457f726 267 /// Update link to HitForRec if "hitForRec" != NULL
de2cd600 268 if (!fTrackParamAtHit) {
269 fTrackParamAtHit = new TClonesArray("AliMUONTrackParam",10);
270 fNTrackHits = 0;
956019b6 271 }
2457f726 272 AliMUONTrackParam* trackParamAtHit;
847cbaef 273 if (trackParam) {
274 trackParamAtHit = new ((*fTrackParamAtHit)[fNTrackHits]) AliMUONTrackParam(*trackParam);
275 if (hitForRec) {
276 if (hitForRec->GetZ() != trackParam->GetZ())
277 AliWarning("Added track parameters at a different z position than the one of the attached hit");
278 }
279 } else {
280 trackParamAtHit = new ((*fTrackParamAtHit)[fNTrackHits]) AliMUONTrackParam();
281 if (hitForRec) ((AliMUONTrackParam*) fTrackParamAtHit->UncheckedAt(fNTrackHits))->SetZ(hitForRec->GetZ());
282 }
2457f726 283 if (hitForRec) trackParamAtHit->SetHitForRecPtr(hitForRec);
de2cd600 284 fNTrackHits++;
956019b6 285}
286
287 //__________________________________________________________________________
de2cd600 288void AliMUONTrack::AddHitForRecAtHit(const AliMUONHitForRec *hitForRec)
956019b6 289{
2457f726 290 /// Add hitForRec to the array of hitForRec at hit
de2cd600 291 if (!fHitForRecAtHit)
292 fHitForRecAtHit = new TClonesArray("AliMUONHitForRec",10);
293
294 if (!hitForRec)
295 AliFatal("AliMUONTrack::AddHitForRecAtHit: hitForRec == NULL");
296
297 new ((*fHitForRecAtHit)[fHitForRecAtHit->GetEntriesFast()]) AliMUONHitForRec(*hitForRec);
04b5ea16 298}
299
b8dc484b 300 //__________________________________________________________________________
208f139e 301void AliMUONTrack::SetVertex(AliMUONHitForRec* vertex)
302{
303 /// Set the vertex used during the tracking procedure
304 if (!fVertex) fVertex = new AliMUONHitForRec(*vertex);
305 else *fVertex = *vertex;
306}
307
308 //__________________________________________________________________________
309Int_t AliMUONTrack::HitsInCommon(AliMUONTrack* track) const
310{
311 /// Returns the number of hits in common between the current track ("this")
312 /// and the track pointed to by "track".
313 Int_t hitsInCommon = 0;
314 AliMUONTrackParam *trackParamAtHit1, *trackParamAtHit2;
315 // Loop over hits of first track
316 trackParamAtHit1 = (AliMUONTrackParam*) this->fTrackParamAtHit->First();
317 while (trackParamAtHit1) {
318 // Loop over hits of second track
319 trackParamAtHit2 = (AliMUONTrackParam*) track->fTrackParamAtHit->First();
320 while (trackParamAtHit2) {
321 // Increment "hitsInCommon" if both TrackParamAtHits point to the same HitForRec
322 if ((trackParamAtHit1->GetHitForRecPtr()) == (trackParamAtHit2->GetHitForRecPtr())) {
323 hitsInCommon++;
324 break;
325 }
326 trackParamAtHit2 = (AliMUONTrackParam*) track->fTrackParamAtHit->After(trackParamAtHit2);
327 } // trackParamAtHit2
328 trackParamAtHit1 = (AliMUONTrackParam*) this->fTrackParamAtHit->After(trackParamAtHit1);
329 } // trackParamAtHit1
330 return hitsInCommon;
331}
332
333 //__________________________________________________________________________
334Bool_t* AliMUONTrack::CompatibleTrack(AliMUONTrack * track, Double_t sigma2Cut) const
b8dc484b 335{
2457f726 336 /// Return kTRUE/kFALSE for each chamber if hit is compatible or not
b8dc484b 337 TClonesArray *hitArray, *thisHitArray;
338 AliMUONHitForRec *hit, *thisHit;
339 Int_t chamberNumber;
340 Float_t deltaZ;
341 Float_t deltaZMax = 1.; // 1 cm
342 Float_t chi2 = 0;
343 Bool_t *nCompHit = new Bool_t[AliMUONConstants::NTrackingCh()];
344
345 for ( Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++) {
346 nCompHit[ch] = kFALSE;
347 }
348
349 thisHitArray = this->GetHitForRecAtHit();
350
208f139e 351 hitArray = track->GetHitForRecAtHit();
b8dc484b 352
353 for (Int_t iHthis = 0; iHthis < thisHitArray->GetEntriesFast(); iHthis++) {
354 thisHit = (AliMUONHitForRec*) thisHitArray->At(iHthis);
355 chamberNumber = thisHit->GetChamberNumber();
356 if (chamberNumber < 0 || chamberNumber > AliMUONConstants::NTrackingCh()) continue;
357 nCompHit[chamberNumber] = kFALSE;
358 for (Int_t iH = 0; iH < hitArray->GetEntriesFast(); iH++) {
359 hit = (AliMUONHitForRec*) hitArray->At(iH);
360 deltaZ = TMath::Abs(thisHit->GetZ() - hit->GetZ());
208f139e 361 chi2 = thisHit->NormalizedChi2WithHitForRec(hit,sigma2Cut); // set cut to 4 sigmas
b8dc484b 362 if (chi2 < 3. && deltaZ < deltaZMax) {
363 nCompHit[chamberNumber] = kTRUE;
364 break;
365 }
366 }
367 }
368
369 return nCompHit;
370}
a9e2aefa 371
8429a5e4 372 //__________________________________________________________________________
208f139e 373Double_t AliMUONTrack::TryOneHitForRec(AliMUONHitForRec* hitForRec)
8429a5e4 374{
208f139e 375/// Test the compatibility between the track and the hitForRec:
376/// return the corresponding Chi2
377
378 // Get track parameters and their covariances at the z position of hitForRec
379 AliMUONTrackParam extrapTrackParam(fExtrapTrackParam);
380 AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParam, hitForRec->GetZ());
381
382 // Set differences between trackParam and hitForRec in the bending and non bending directions
383 TMatrixD dPos(2,1);
384 dPos(0,0) = hitForRec->GetNonBendingCoor() - extrapTrackParam.GetNonBendingCoor();
385 dPos(1,0) = hitForRec->GetBendingCoor() - extrapTrackParam.GetBendingCoor();
386
387 // quick test of hitForRec compatibility within a wide road of x*y = 10*1 cm2 to save computing time
388 if (TMath::Abs(dPos(0,0)) > fgkMaxTrackingDistanceNonBending ||
389 TMath::Abs(dPos(1,0)) > fgkMaxTrackingDistanceBending) return 1.e10;
390
391 // Set the error matrix from trackParam covariances and hitForRec resolution
392 TMatrixD* paramCov = extrapTrackParam.GetCovariances();
393 TMatrixD error(2,2);
394 error(0,0) = (*paramCov)(0,0) + hitForRec->GetNonBendingReso2();
395 error(0,1) = (*paramCov)(0,2);
396 error(1,0) = (*paramCov)(2,0);
397 error(1,1) = (*paramCov)(2,2) + hitForRec->GetBendingReso2();
398
399 // Invert the error matrix for Chi2 calculation
400 if (error.Determinant() != 0) {
401 error.Invert();
402 } else {
403 AliWarning(" Determinant error=0");
404 return 1.e10;
405 }
406
407 // Compute the Chi2 value
408 TMatrixD tmp(error,TMatrixD::kMult,dPos);
409 TMatrixD result(dPos,TMatrixD::kTransposeMult,tmp);
410
411 return result(0,0);
412
413}
414
415 //__________________________________________________________________________
416Double_t AliMUONTrack::TryTwoHitForRec(AliMUONHitForRec* hitForRec1, AliMUONHitForRec* hitForRec2)
417{
418/// Test the compatibility between the track and the 2 hitForRec together:
419/// return the corresponding Chi2 accounting for covariances between the 2 hitForRec
420
421 // Get track parameters and their covariances at the z position of the first hitForRec
422 AliMUONTrackParam extrapTrackParam1(fExtrapTrackParam);
423 AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParam1, hitForRec1->GetZ());
424
425 // Get track parameters at second hitForRec
426 AliMUONTrackParam extrapTrackParam2(extrapTrackParam1);
427 AliMUONTrackExtrap::ExtrapToZ(&extrapTrackParam2, hitForRec2->GetZ());
428
429 // Set differences between track and the 2 hitForRec in the bending and non bending directions
430 TMatrixD dPos(4,1);
431 dPos(0,0) = hitForRec1->GetNonBendingCoor() - extrapTrackParam1.GetNonBendingCoor();
432 dPos(1,0) = hitForRec1->GetBendingCoor() - extrapTrackParam1.GetBendingCoor();
433 dPos(2,0) = hitForRec2->GetNonBendingCoor() - extrapTrackParam2.GetNonBendingCoor();
434 dPos(3,0) = hitForRec2->GetBendingCoor() - extrapTrackParam2.GetBendingCoor();
435
436 // quick tests of hitForRec compatibility within a wide road of x*y = 1*1 cm2 to save computing time
437 if (TMath::Abs(dPos(0,0)) > fgkMaxTrackingDistanceNonBending ||
438 TMath::Abs(dPos(1,0)) > fgkMaxTrackingDistanceBending ||
439 TMath::Abs(dPos(2,0)) > fgkMaxTrackingDistanceNonBending ||
440 TMath::Abs(dPos(3,0)) > fgkMaxTrackingDistanceBending) return 1.e10;
441
442 // Calculate the error matrix from the track parameter covariances at first hitForRec
443 TMatrixD error(4,4);
444 error = 0.;
445 if (extrapTrackParam1.CovariancesExist()) {
446 // Get the pointer to the parameter covariance matrix at first hitForRec
447 TMatrixD* paramCov = extrapTrackParam1.GetCovariances();
448
449 // Save track parameters at first hitForRec
450 AliMUONTrackParam extrapTrackParam1Save(extrapTrackParam1);
451 Double_t nonBendingCoor1 = extrapTrackParam1Save.GetNonBendingCoor();
452 Double_t nonBendingSlope1 = extrapTrackParam1Save.GetNonBendingSlope();
453 Double_t bendingCoor1 = extrapTrackParam1Save.GetBendingCoor();
454 Double_t bendingSlope1 = extrapTrackParam1Save.GetBendingSlope();
455 Double_t inverseBendingMomentum1 = extrapTrackParam1Save.GetInverseBendingMomentum();
456 Double_t z1 = extrapTrackParam1Save.GetZ();
457
458 // Save track coordinates at second hitForRec
459 Double_t nonBendingCoor2 = extrapTrackParam2.GetNonBendingCoor();
460 Double_t bendingCoor2 = extrapTrackParam2.GetBendingCoor();
461
462 // Calculate the jacobian related to the transformation between track parameters
463 // at first hitForRec and track coordinates at the 2 hitForRec z-position
464 TMatrixD jacob(4,5);
465 jacob = 0.;
466 // first derivative at the first hitForRec:
467 jacob(0,0) = 1.; // dx1/dx
468 jacob(1,2) = 1.; // dy1/dy
469 // first derivative at the second hitForRec:
470 Double_t dParam[5];
471 for (Int_t i=0; i<5; i++) {
472 // Skip jacobian calculation for parameters with no associated error
473 if ((*paramCov)(i,i) == 0.) continue;
474 // Small variation of parameter i only
475 for (Int_t j=0; j<5; j++) {
476 if (j==i) {
477 dParam[j] = TMath::Sqrt((*paramCov)(i,i));
478 if (j == 4) dParam[j] *= TMath::Sign(1.,-inverseBendingMomentum1); // variation always in the same direction
479 } else dParam[j] = 0.;
480 }
481 // Set new track parameters at first hitForRec
482 extrapTrackParam1Save.SetNonBendingCoor (nonBendingCoor1 + dParam[0]);
483 extrapTrackParam1Save.SetNonBendingSlope (nonBendingSlope1 + dParam[1]);
484 extrapTrackParam1Save.SetBendingCoor (bendingCoor1 + dParam[2]);
485 extrapTrackParam1Save.SetBendingSlope (bendingSlope1 + dParam[3]);
486 extrapTrackParam1Save.SetInverseBendingMomentum(inverseBendingMomentum1 + dParam[4]);
487 extrapTrackParam1Save.SetZ (z1);
488 // Extrapolate new track parameters to the z position of the second hitForRec
489 AliMUONTrackExtrap::ExtrapToZ(&extrapTrackParam1Save,hitForRec2->GetZ());
490 // Calculate the jacobian
491 jacob(2,i) = (extrapTrackParam1Save.GetNonBendingCoor() - nonBendingCoor2) / dParam[i]; // dx2/dParami
492 jacob(3,i) = (extrapTrackParam1Save.GetBendingCoor() - bendingCoor2 ) / dParam[i]; // dy2/dParami
493 }
494
495 // Calculate the error matrix
496 TMatrixD tmp((*paramCov),TMatrixD::kMultTranspose,jacob);
497 error = TMatrixD(jacob,TMatrixD::kMult,tmp);
498 }
499
500 // Add hitForRec resolution to the error matrix
501 error(0,0) += hitForRec1->GetNonBendingReso2();
502 error(1,1) += hitForRec1->GetBendingReso2();
503 error(2,2) += hitForRec2->GetNonBendingReso2();
504 error(3,3) += hitForRec2->GetBendingReso2();
505
506 // invert the error matrix for Chi2 calculation
507 if (error.Determinant() != 0) {
508 error.Invert();
509 } else {
510 AliWarning(" Determinant error=0");
511 return 1.e10;
512 }
513
514 // Compute the Chi2 value
515 TMatrixD tmp2(error,TMatrixD::kMult,dPos);
516 TMatrixD result(dPos,TMatrixD::kTransposeMult,tmp2);
517
518 return result(0,0);
519
8429a5e4 520}
521
d837040f 522 //__________________________________________________________________________
de2cd600 523void AliMUONTrack::RecursiveDump(void) const
a9e2aefa 524{
2457f726 525 /// Recursive dump of AliMUONTrack, i.e. with dump of TrackParamAtHit's and attached HitForRec's
de2cd600 526 AliMUONTrackParam *trackParamAtHit;
527 AliMUONHitForRec *hitForRec;
528 cout << "Recursive dump of Track: " << this << endl;
529 // Track
530 this->Dump();
531 for (Int_t trackHitIndex = 0; trackHitIndex < fNTrackHits; trackHitIndex++) {
532 trackParamAtHit = (AliMUONTrackParam*) ((*fTrackParamAtHit)[trackHitIndex]);
533 // TrackHit
534 cout << "TrackParamAtHit: " << trackParamAtHit << " (index: " << trackHitIndex << ")" << endl;
535 trackParamAtHit->Dump();
536 hitForRec = trackParamAtHit->GetHitForRecPtr();
537 // HitForRec
538 cout << "HitForRec: " << hitForRec << endl;
539 hitForRec->Dump();
a9e2aefa 540 }
de2cd600 541 return;
a9e2aefa 542}
04b5ea16 543
6464217e 544//_____________________________________________-
545void AliMUONTrack::Print(Option_t* opt) const
546{
2457f726 547 /// Printing Track information
548 /// "full" option for printing all the information about the track
6464217e 549 TString sopt(opt);
550 sopt.ToUpper();
551
552 if ( sopt.Contains("FULL") ) {
553 cout << "<AliMUONTrack> No.Clusters=" << setw(2) << GetNTrackHits() <<
554 // ", Bending P="<< setw(8) << setprecision(5) << 1./GetInverseBendingMomentum() <<
555 //", NonBendSlope=" << setw(8) << setprecision(5) << GetNonBendingSlope()*180./TMath::Pi() <<
556 //", BendSlope=" << setw(8) << setprecision(5) << GetBendingSlope()*180./TMath::Pi() <<
557 ", Match2Trig=" << setw(1) << GetMatchTrigger() <<
558 ", Chi2-tracking-trigger=" << setw(8) << setprecision(5) << GetChi2MatchTrigger() << endl ;
559 GetTrackParamAtHit()->First()->Print("full");
560 }
561 else {
562 cout << "<AliMUONTrack>";
563 GetTrackParamAtHit()->First()->Print("");
564
565 }
566
567}