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