]>
Commit | Line | Data |
---|---|---|
83dbc640 | 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 | ||
16 | #include "AliMUONTrackK.h" | |
17 | ||
18 | #include <Riostream.h> | |
19 | #include <TClonesArray.h> | |
20 | #include <TArrayD.h> | |
21 | #include <TMatrixD.h> | |
22 | #include <stdlib.h> // for exit() | |
23 | ||
24 | #include "AliCallf77.h" | |
25 | #include "AliMUON.h" | |
26 | #include "AliMUONChamber.h" | |
27 | #include "AliMUONEventReconstructor.h" | |
28 | #include "AliMUONSegment.h" | |
29 | #include "AliMUONHitForRec.h" | |
30 | #include "AliMUONRawCluster.h" | |
31 | #include "AliMUONTrackParam.h" | |
32 | #include "AliRun.h" | |
33 | #include "AliMagF.h" | |
34 | ||
35 | void mnvertLocalK(Double_t* a, Int_t l, Int_t m, Int_t n, Int_t& ifail); | |
36 | ||
37 | ClassImp(AliMUONTrackK) // Class implementation in ROOT context | |
38 | ||
39 | // A few calls in Fortran or from Fortran (extrap.F). | |
40 | #ifndef WIN32 | |
41 | # define extrap_onestep_helix extrap_onestep_helix_ | |
42 | # define extrap_onestep_helix3 extrap_onestep_helix3_ | |
43 | # define extrap_onestep_rungekutta extrap_onestep_rungekutta_ | |
44 | # define gufld_double gufld_double_ | |
45 | #else | |
46 | # define extrap_onestep_helix EXTRAP_ONESTEP_HELIX | |
47 | # define extrap_onestep_helix3 EXTRAP_ONESTEP_HELIX3 | |
48 | # define extrap_onestep_rungekutta EXTRAP_ONESTEP_RUNGEKUTTA | |
49 | # define gufld_double GUFLD_DOUBLE | |
50 | #endif | |
51 | ||
52 | extern "C" { | |
53 | void type_of_call extrap_onestep_helix | |
54 | (Double_t &Charge, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New); | |
55 | ||
56 | void type_of_call extrap_onestep_helix3 | |
57 | (Double_t &Field, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New); | |
58 | ||
59 | void type_of_call extrap_onestep_rungekutta | |
60 | (Double_t &Charge, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New); | |
61 | ||
62 | void type_of_call gufld_double(Double_t *Position, Double_t *Field); | |
63 | /* void type_of_call gufld_double(Double_t *Position, Double_t *Field) { | |
64 | // interface to "gAlice->Field()->Field" for arguments in double precision | |
65 | Float_t x[3], b[3]; | |
66 | x[0] = Position[0]; x[1] = Position[1]; x[2] = Position[2]; | |
67 | gAlice->Field()->Field(x, b); | |
68 | Field[0] = b[0]; Field[1] = b[1]; Field[2] = b[2]; | |
69 | } | |
70 | */ | |
71 | } | |
72 | ||
73 | Int_t AliMUONTrackK::fgNOfPoints = 0; | |
74 | AliMUON* AliMUONTrackK::fgMUON = NULL; | |
75 | AliMUONEventReconstructor* AliMUONTrackK::fgEventReconstructor = NULL; | |
76 | TClonesArray* AliMUONTrackK::fgHitForRec = NULL; | |
77 | ||
78 | //__________________________________________________________________________ | |
79 | AliMUONTrackK::AliMUONTrackK() | |
80 | { | |
81 | // Default constructor | |
82 | ||
83 | fgEventReconstructor = NULL; // pointer to event reconstructor | |
84 | fgMUON = NULL; // pointer to Muon module | |
85 | fgHitForRec = NULL; // pointer to points | |
86 | fgNOfPoints = 0; // number of points | |
87 | ||
88 | fStartSegment = NULL; | |
89 | fTrackHitsPtr = NULL; | |
90 | fNTrackHits = 0; | |
91 | fTrackPar = NULL; | |
92 | fTrackParNew = NULL; | |
93 | fCovariance = NULL; | |
94 | fWeight = NULL; | |
95 | fSkipHit = NULL; | |
96 | ||
97 | return; | |
98 | } | |
99 | ||
100 | //__________________________________________________________________________ | |
101 | AliMUONTrackK::AliMUONTrackK(AliMUONEventReconstructor *EventReconstructor, TClonesArray *hitForRec) | |
102 | { | |
103 | // Constructor | |
104 | ||
105 | fgEventReconstructor = EventReconstructor; // pointer to event reconstructor | |
106 | fgMUON = (AliMUON*) gAlice->GetModule("MUON"); // pointer to Muon module | |
107 | fgHitForRec = hitForRec; // pointer to points | |
108 | fgNOfPoints = fgHitForRec->GetEntriesFast(); // number of points | |
109 | ||
110 | fStartSegment = NULL; | |
111 | fTrackHitsPtr = NULL; | |
112 | fNTrackHits = 0; | |
113 | fChi2 = 0; | |
114 | fTrackPar = NULL; | |
115 | fTrackParNew = NULL; | |
116 | fCovariance = NULL; | |
117 | fWeight = NULL; | |
118 | fSkipHit = NULL; | |
119 | ||
120 | return; | |
121 | } | |
122 | ||
123 | //__________________________________________________________________________ | |
124 | AliMUONTrackK::AliMUONTrackK(AliMUONSegment *segment) | |
125 | { | |
126 | // Constructor from a segment | |
127 | Double_t dX, dY, dZ; | |
128 | AliMUONHitForRec *hit1, *hit2; | |
129 | AliMUONRawCluster *clus; | |
130 | TClonesArray *rawclusters; | |
131 | ||
132 | fStartSegment = segment; | |
133 | fRecover = 0; | |
134 | // Pointers to hits from the segment | |
135 | hit1 = segment->GetHitForRec1(); | |
136 | hit2 = segment->GetHitForRec2(); | |
137 | hit1->SetNTrackHits(hit1->GetNTrackHits()+1); // mark hit as being on track | |
138 | hit2->SetNTrackHits(hit2->GetNTrackHits()+1); // mark hit as being on track | |
139 | // check sorting in Z | |
140 | if (hit1->GetZ() > hit2->GetZ()) { | |
141 | hit1 = hit2; | |
142 | hit2 = segment->GetHitForRec1(); | |
143 | } | |
144 | // memory allocation for the TObjArray of pointers to reconstructed TrackHit's | |
145 | fTrackHitsPtr = new TObjArray(10); | |
146 | fNTrackHits = 2; | |
147 | fChi2 = 0; | |
148 | fBPFlag = kFALSE; | |
149 | fTrackPar = new TMatrixD(kSize,1); // track parameters | |
150 | fTrackParNew = new TMatrixD(kSize,1); // track parameters | |
151 | fCovariance = new TMatrixD(kSize,kSize); // covariance matrix | |
152 | fWeight = new TMatrixD(kSize,kSize); // weight matrix (inverse of covariance) | |
153 | ||
154 | // Fill array of track parameters | |
155 | if (hit1->GetChamberNumber() > 7) { | |
156 | // last tracking station | |
157 | (*fTrackPar)(0,0) = hit1->GetBendingCoor(); // y | |
158 | (*fTrackPar)(1,0) = hit1->GetNonBendingCoor(); // x | |
159 | fPosition = hit1->GetZ(); // z | |
160 | fTrackHitsPtr->Add((TObjArray*)hit2); // add hit 2 | |
161 | fTrackHitsPtr->Add((TObjArray*)hit1); // add hit 1 | |
162 | fTrackDir = -1; | |
163 | } else { | |
164 | // last but one tracking station | |
165 | (*fTrackPar)(0,0) = hit2->GetBendingCoor(); // y | |
166 | (*fTrackPar)(1,0) = hit2->GetNonBendingCoor(); // x | |
167 | fPosition = hit2->GetZ(); // z | |
168 | fTrackHitsPtr->Add((TObjArray*)hit1); // add hit 1 | |
169 | fTrackHitsPtr->Add((TObjArray*)hit2); // add hit 2 | |
170 | fTrackDir = 1; | |
171 | } | |
172 | dZ = hit2->GetZ() - hit1->GetZ(); | |
173 | dY = hit2->GetBendingCoor() - hit1->GetBendingCoor(); | |
174 | dX = hit2->GetNonBendingCoor() - hit1->GetNonBendingCoor(); | |
175 | (*fTrackPar)(2,0) = TMath::ATan2(dY,dZ); // alpha | |
176 | (*fTrackPar)(3,0) = TMath::ATan2(dX,dZ/TMath::Cos((*fTrackPar)(2,0))); // beta | |
177 | (*fTrackPar)(4,0) = 1/fgEventReconstructor->GetBendingMomentumFromImpactParam(segment->GetBendingImpact()); // 1/Pt | |
178 | (*fTrackPar)(4,0) *= TMath::Cos((*fTrackPar)(3,0)); // 1/p | |
179 | cout << fgEventReconstructor->GetBendingMomentumFromImpactParam(segment->GetBendingImpact()) << " " << 1/(*fTrackPar)(4,0) << " "; | |
180 | if (fgEventReconstructor->GetRecGeantHits()) { | |
181 | // from GEANT hits | |
182 | cout << ((AliMUONHitForRec*)((*fTrackHitsPtr)[0]))->GetTHTrack() << "<-->" << ((AliMUONHitForRec*)((*fTrackHitsPtr)[1]))->GetTHTrack() << endl; | |
183 | } else { | |
184 | // from raw clusters | |
185 | for (Int_t i=0; i<2; i++) { | |
186 | hit1 = (AliMUONHitForRec*) ((*fTrackHitsPtr)[i]); | |
187 | rawclusters = fgMUON->RawClustAddress(hit1->GetChamberNumber()); | |
188 | clus = (AliMUONRawCluster*) rawclusters->UncheckedAt(hit1->GetHitNumber()); | |
189 | cout << clus->fTracks[1]-1; | |
190 | if (clus->fTracks[2] != 0) cout << " " << clus->fTracks[2]-1; | |
191 | if (i == 0) cout << " <--> "; | |
192 | } | |
193 | cout << endl; | |
194 | } | |
195 | // Evaluate covariance (and weight) matrix | |
196 | EvalCovariance(dZ); | |
197 | ||
198 | return; | |
199 | } | |
200 | ||
201 | //__________________________________________________________________________ | |
202 | AliMUONTrackK::~AliMUONTrackK() | |
203 | { | |
204 | // Destructor | |
205 | ||
206 | if (fTrackHitsPtr) { | |
207 | delete fTrackHitsPtr; // delete the TObjArray of pointers to TrackHit's | |
208 | fTrackHitsPtr = NULL; | |
209 | } | |
210 | delete fTrackPar; delete fTrackParNew; delete fCovariance; | |
211 | delete fWeight; | |
212 | } | |
213 | ||
214 | //__________________________________________________________________________ | |
215 | AliMUONTrackK::AliMUONTrackK (const AliMUONTrackK& source) | |
216 | { | |
217 | // Dummy copy constructor | |
218 | } | |
219 | ||
220 | //__________________________________________________________________________ | |
221 | AliMUONTrackK & AliMUONTrackK::operator=(const AliMUONTrackK& source) | |
222 | { | |
223 | // Assignment operator | |
224 | // Members | |
225 | if(&source == this) return *this; | |
226 | fStartSegment = source.fStartSegment; | |
227 | fNTrackHits = source.fNTrackHits; | |
228 | fChi2 = source.fChi2; | |
229 | fPosition = source.fPosition; | |
230 | fPositionNew = source.fPositionNew; | |
231 | fTrackDir = source.fTrackDir; | |
232 | fBPFlag = source.fBPFlag; | |
233 | fRecover = source.fRecover; | |
234 | fSkipHit = source.fSkipHit; | |
235 | ||
236 | // Pointers | |
237 | fTrackHitsPtr = new TObjArray(*source.fTrackHitsPtr); | |
238 | //source.fTrackHitsPtr->Dump(); | |
239 | //fTrackHitsPtr->Dump(); | |
240 | ||
241 | fTrackPar = new TMatrixD(*source.fTrackPar); // track parameters | |
242 | fTrackParNew = new TMatrixD(*source.fTrackParNew); // track parameters | |
243 | fCovariance = new TMatrixD(*source.fCovariance); // covariance matrix | |
244 | fWeight = new TMatrixD(*source.fWeight); // weight matrix (inverse of covariance) | |
245 | ||
246 | return *this; | |
247 | } | |
248 | ||
249 | //__________________________________________________________________________ | |
250 | void AliMUONTrackK::EvalCovariance(Double_t dZ) | |
251 | { | |
252 | // Evaluate covariance (and weight) matrix for track candidate | |
253 | Double_t sigmaB, sigmaNonB, tanA, tanB, dAdY, rad, dBdX, dBdY; | |
254 | ||
255 | sigmaB = fgEventReconstructor->GetBendingResolution(); // bending resolution | |
256 | sigmaNonB = fgEventReconstructor->GetNonBendingResolution(); // non-bending resolution | |
257 | ||
258 | (*fWeight)(0,0) = sigmaB*sigmaB; // <yy> | |
259 | ||
260 | (*fWeight)(1,1) = sigmaNonB*sigmaNonB; // <xx> | |
261 | ||
262 | tanA = TMath::Tan((*fTrackPar)(2,0)); | |
263 | dAdY = 1/(1+tanA*tanA)/dZ; | |
264 | (*fWeight)(2,2) = dAdY*dAdY*(*fWeight)(0,0)*2; // <aa> | |
265 | (*fWeight)(0,2) = dAdY*(*fWeight)(0,0); // <ya> | |
266 | (*fWeight)(2,0) = (*fWeight)(0,2); | |
267 | ||
268 | rad = dZ/TMath::Cos((*fTrackPar)(2,0)); | |
269 | tanB = TMath::Tan((*fTrackPar)(3,0)); | |
270 | dBdX = 1/(1+tanB*tanB)/rad; | |
271 | dBdY = 0; // neglect | |
272 | (*fWeight)(3,3) = dBdX*dBdX*(*fWeight)(1,1)*2; // <bb> | |
273 | (*fWeight)(1,3) = dBdX*(*fWeight)(1,1); // <xb> | |
274 | (*fWeight)(3,1) = (*fWeight)(1,3); | |
275 | ||
276 | //(*fWeight)(4,4) = ((*fTrackPar)(4,0)*0.2)*((*fTrackPar)(4,0)*0.2); // error 20% | |
277 | (*fWeight)(4,4) = ((*fTrackPar)(4,0)*0.5)*((*fTrackPar)(4,0)*0.5); // error 50% | |
278 | ||
279 | // check whether the Invert method returns flag if matrix cannot be inverted, | |
280 | // and do not calculate the Determinant in that case !!!! | |
281 | if (fWeight->Determinant() != 0) { | |
282 | ||
283 | // fWeight->Invert(); | |
284 | ||
285 | Int_t ifailWeight; | |
286 | mnvertLocalK(&((*fWeight)(0,0)), kSize,kSize,kSize,ifailWeight); | |
287 | } else { | |
288 | cout << " ***** Warning in EvalCovariance: Determinant fWeight=0:" << endl; | |
289 | } | |
290 | return; | |
291 | } | |
292 | ||
293 | //__________________________________________________________________________ | |
294 | Bool_t AliMUONTrackK::KalmanFilter(Int_t ichamBeg, Int_t ichamEnd, Bool_t Back, Double_t zDipole1, Double_t zDipole2) | |
295 | { | |
296 | // Follows track through detector stations | |
297 | Bool_t miss, success; | |
298 | Int_t ichamb, iFB, iMin, iMax, dChamb, ichambOK, i; | |
299 | Int_t ihit, firstIndx, lastIndx, currIndx, dChambMiss, iDindx=0; | |
300 | Double_t zEnd, dChi2; | |
301 | AliMUONHitForRec *hitAdd, *firstHit, *lastHit, *hit; | |
302 | AliMUONRawCluster *clus; | |
303 | TClonesArray *rawclusters; | |
304 | hit = 0; clus = 0; rawclusters = 0; | |
305 | ||
306 | miss = kTRUE; | |
307 | success = kTRUE; | |
308 | Int_t endOfProp = 0; | |
309 | iFB = TMath::Sign(1,ichamEnd-ichamBeg); | |
310 | iMin = TMath::Min(ichamEnd,ichamBeg); | |
311 | iMax = TMath::Max(ichamEnd,ichamBeg); | |
312 | ichamb = ichamBeg; | |
313 | ichambOK = ichamb; | |
314 | ||
315 | // Get indices of the 1'st and last hits on the track candidate | |
316 | firstHit = (AliMUONHitForRec*) fTrackHitsPtr->First(); | |
317 | lastHit = (AliMUONHitForRec*) fTrackHitsPtr->Last(); | |
318 | firstIndx = fgHitForRec->IndexOf(firstHit); | |
319 | lastIndx = fgHitForRec->IndexOf(lastHit); | |
320 | currIndx = TMath::Abs (TMath::Max(firstIndx*iFB,lastIndx*iFB)); | |
321 | if (Back) { | |
322 | // backpropagation | |
323 | currIndx = 2; | |
324 | iDindx = 1; | |
325 | if (fRecover != 0) { | |
326 | // find hit with the highest Z | |
327 | Double_t zbeg = 0; | |
328 | for (i=0; i<fNTrackHits; i++) { | |
329 | hitAdd = (AliMUONHitForRec*) ((*fTrackHitsPtr)[i]); | |
330 | zEnd = hitAdd->GetZ(); | |
331 | if (zEnd > zbeg) zbeg = zEnd; | |
332 | else { | |
333 | currIndx = fNTrackHits - i + 2; //??? | |
334 | break; | |
335 | } | |
336 | } //for (Int_t i=0; | |
337 | } | |
338 | } else if (fRecover != 0) { | |
339 | Back = kTRUE; // dirty trick | |
340 | iDindx = -1; | |
341 | if (ichamBeg == 7 || ichamBeg == 8) currIndx = fNTrackHits - 2; | |
342 | else { | |
343 | Double_t zbeg = ((AliMUONHitForRec*)((*fTrackHitsPtr)[0]))->GetZ(); | |
344 | for (i=1; i<fNTrackHits; i++) { | |
345 | hitAdd = (AliMUONHitForRec*) ((*fTrackHitsPtr)[i]); | |
346 | zEnd = hitAdd->GetZ(); | |
347 | if (zEnd < zbeg) break; | |
348 | } //for (Int_t i=1; | |
349 | currIndx = fNTrackHits - i; //??? | |
350 | } | |
351 | } | |
352 | ||
353 | while (ichamb>=iMin && ichamb<=iMax) { | |
354 | // Find the closest hit in Z, not belonging to the current plane | |
355 | if (Back) { | |
356 | // backpropagation | |
357 | hitAdd = (AliMUONHitForRec*) ((*fTrackHitsPtr)[fNTrackHits-currIndx]); | |
358 | zEnd = hitAdd->GetZ(); | |
359 | } else { | |
360 | zEnd = -9999; | |
361 | for (ihit=currIndx+iFB; ihit>=0 && ihit<fgNOfPoints; ihit+=iFB) { | |
362 | hitAdd = (AliMUONHitForRec*) ((*fgHitForRec)[ihit]); | |
363 | //if (TMath::Abs(hitAdd->GetZ()-fPosition) > 0.1) { | |
364 | if (TMath::Abs(hitAdd->GetZ()-fPosition) > 0.5) { | |
365 | zEnd = hitAdd->GetZ(); | |
366 | currIndx = ihit; | |
367 | break; | |
368 | } | |
369 | } | |
370 | } | |
371 | if (zEnd<-999 && ichamb==ichamEnd) endOfProp = 1; // end-of-propagation | |
372 | else { | |
373 | // Check if there is a missing chamber | |
374 | if (zEnd<-999 || TMath::Abs(hitAdd->GetChamberNumber()-ichamb) > 1) { | |
375 | if (!Back && zEnd>-999) currIndx -= iFB; | |
376 | ichamb += iFB; | |
377 | zEnd = (&(fgMUON->Chamber(ichamb)))->Z(); | |
378 | miss = kTRUE; | |
379 | } else { | |
380 | ichamb = hitAdd->GetChamberNumber(); | |
381 | miss = kFALSE; | |
382 | } | |
383 | } | |
384 | if (ichamb<iMin || ichamb>iMax) break; | |
385 | // Check for missing station | |
386 | if (!Back) { | |
387 | dChamb = TMath::Abs(ichamb-ichambOK); | |
388 | if (dChamb > 1) { | |
389 | dChambMiss = endOfProp; | |
390 | //Check if (iFB > 0) dChambMiss++; | |
391 | if (iFB > 0) { | |
392 | if (TMath::Odd(ichambOK)) dChambMiss++; | |
393 | else dChambMiss--; | |
394 | } | |
395 | //cout << dChamb << " " << ichambOK << " " << fgNOfPoints << endl; | |
396 | if (TMath::Odd(ichambOK) && dChamb > 3-dChambMiss) { | |
397 | // missing station - abandon track | |
398 | //cout << dChamb << " " << ichambOK << " " << fgNOfPoints << " " << 1/(*fTrackPar)(4,0) << endl; | |
399 | /* | |
400 | for (Int_t i1=0; i1<fgNOfPoints; i1++) { | |
401 | cout << " Hit #" << ((AliMUONHitForRec*)((*fgHitForRec)[i1]))->GetChamberNumber() << " "; | |
402 | cout << ((AliMUONHitForRec*)((*fgHitForRec)[i1]))->GetBendingCoor() << " "; | |
403 | cout << ((AliMUONHitForRec*)((*fgHitForRec)[i1]))->GetNonBendingCoor() << " "; | |
404 | cout << ((AliMUONHitForRec*)((*fgHitForRec)[i1]))->GetZ() << " " << " "; | |
405 | cout << ((AliMUONHitForRec*)((*fgHitForRec)[i1]))->GetTHTrack() << endl; | |
406 | } | |
407 | //cout << endl; | |
408 | */ | |
409 | /* | |
410 | cout << fNTrackHits << endl; | |
411 | for (Int_t i1=0; i1<fNTrackHits; i1++) { | |
412 | hit = (AliMUONHitForRec*) ((*fTrackHitsPtr)[i1]); | |
413 | printf(" * %d %10.4f %10.4f %10.4f", | |
414 | hit->GetChamberNumber(), hit->GetBendingCoor(), | |
415 | hit->GetNonBendingCoor(), hit->GetZ()); | |
416 | if (fgEventReconstructor->GetRecGeantHits()) { | |
417 | // from GEANT hits | |
418 | printf(" %3d %3d \n", hit->GetGeantSignal(), hit->GetTHTrack()); | |
419 | } else { | |
420 | // from raw clusters | |
421 | rawclusters = fgMUON->RawClustAddress(hit->GetChamberNumber()); | |
422 | clus = (AliMUONRawCluster*) rawclusters->UncheckedAt(hit->GetHitNumber()); | |
423 | printf("%3d", clus->fTracks[1]-1); | |
424 | if (clus->fTracks[2] != 0) printf("%3d \n", clus->fTracks[2]-1); | |
425 | else printf("\n"); | |
426 | } | |
427 | } | |
428 | */ | |
429 | if (fNTrackHits>2 && fRecover==0 && !(ichambOK==((AliMUONHitForRec*)((*fTrackHitsPtr)[0]))->GetChamberNumber())) { | |
430 | // try to recover track later | |
431 | Recover(); | |
432 | } | |
433 | return kFALSE; | |
434 | } | |
435 | //Check else if (TMath::Even(ichambOK) && dChamb > 2-endOfProp) { | |
436 | else if (TMath::Even(ichambOK) && dChamb > 2-dChambMiss) { | |
437 | // missing station - abandon track | |
438 | //cout << dChamb << " " << ichambOK << " " << fgNOfPoints << " " << 1/(*fTrackPar)(4,0) << endl; | |
439 | /* | |
440 | for (Int_t i1=0; i1<fgNOfPoints; i1++) { | |
441 | cout << " Hit #" << ((AliMUONHitForRec*)((*fgHitForRec)[i1]))->GetChamberNumber() << " "; | |
442 | cout << ((AliMUONHitForRec*)((*fgHitForRec)[i1]))->GetBendingCoor() << " "; | |
443 | cout << ((AliMUONHitForRec*)((*fgHitForRec)[i1]))->GetNonBendingCoor() << " "; | |
444 | cout << ((AliMUONHitForRec*)((*fgHitForRec)[i1]))->GetZ() << " " << " "; | |
445 | cout << ((AliMUONHitForRec*)((*fgHitForRec)[i1]))->GetTHTrack() << endl; | |
446 | } | |
447 | //cout << endl; | |
448 | */ | |
449 | /* | |
450 | cout << fNTrackHits << endl; | |
451 | for (Int_t i1=0; i1<fNTrackHits; i1++) { | |
452 | hit = (AliMUONHitForRec*) ((*fTrackHitsPtr)[i1]); | |
453 | printf(" * %d %10.4f %10.4f %10.4f", | |
454 | hit->GetChamberNumber(), hit->GetBendingCoor(), | |
455 | hit->GetNonBendingCoor(), hit->GetZ()); | |
456 | if (fgEventReconstructor->GetRecGeantHits()) { | |
457 | // from GEANT hits | |
458 | printf(" %3d %3d \n", hit->GetGeantSignal(), hit->GetTHTrack()); | |
459 | } else { | |
460 | // from raw clusters | |
461 | rawclusters = fgMUON->RawClustAddress(hit->GetChamberNumber()); | |
462 | clus = (AliMUONRawCluster*) rawclusters->UncheckedAt(hit->GetHitNumber()); | |
463 | printf("%3d", clus->fTracks[1]-1); | |
464 | if (clus->fTracks[2] != 0) printf("%3d \n", clus->fTracks[2]-1); | |
465 | else printf("\n"); | |
466 | } | |
467 | } | |
468 | */ | |
469 | if (fNTrackHits>2 && fRecover==0 && !(ichambOK==((AliMUONHitForRec*)((*fTrackHitsPtr)[0]))->GetChamberNumber())) { | |
470 | // try to recover track later | |
471 | Recover(); | |
472 | } | |
473 | return kFALSE; | |
474 | } | |
475 | } | |
476 | } | |
477 | if (endOfProp != 0) break; | |
478 | ||
479 | // propagate to the found Z | |
480 | ||
481 | // Check if track steps into dipole | |
482 | if (fPosition>zDipole2 && zEnd<zDipole2) { | |
483 | //LinearPropagation(zDipole2-zBeg); | |
484 | ParPropagation(zDipole2); | |
485 | MSThin(1); // multiple scattering in the chamber | |
486 | WeightPropagation(zDipole2); // propagate weight matrix | |
487 | fPosition = fPositionNew; | |
488 | *fTrackPar = *fTrackParNew; | |
489 | //MagnetPropagation(zEnd); | |
490 | ParPropagation(zEnd); | |
491 | WeightPropagation(zEnd); | |
492 | fPosition = fPositionNew; | |
493 | } | |
494 | // Check if track steps out of dipole | |
495 | else if (fPosition>zDipole1 && zEnd<zDipole1) { | |
496 | //MagnetPropagation(zDipole1-zBeg); | |
497 | ParPropagation(zDipole1); | |
498 | MSThin(1); // multiple scattering in the chamber | |
499 | WeightPropagation(zDipole1); | |
500 | fPosition = fPositionNew; | |
501 | *fTrackPar = *fTrackParNew; | |
502 | //LinearPropagation(zEnd-zDipole1); | |
503 | ParPropagation(zEnd); | |
504 | WeightPropagation(zEnd); | |
505 | fPosition = fPositionNew; | |
506 | } else { | |
507 | ParPropagation(zEnd); | |
508 | //MSThin(1); // multiple scattering in the chamber | |
509 | if (TMath::Abs(zEnd-fPosition) > 5) MSThin(1); // multiple scattering in the chamber | |
510 | WeightPropagation(zEnd); | |
511 | fPosition = fPositionNew; | |
512 | } | |
513 | ||
514 | // Add measurement | |
515 | if (fRecover != 0 && hitAdd == fSkipHit && !miss) { | |
516 | // recovered track - remove the hit | |
517 | miss = kTRUE; | |
518 | ichamb = hitAdd->GetChamberNumber(); | |
519 | if (fRecover == 1) { | |
520 | // remove the last hit | |
521 | fTrackHitsPtr->Remove((TObjArray*)hitAdd); // remove hit | |
522 | fNTrackHits --; | |
523 | hitAdd->SetNTrackHits(hitAdd->GetNTrackHits()-1); // unmark hit | |
524 | } else { | |
525 | // remove the hits | |
526 | for (i=fNTrackHits-1; i>1; i--) { | |
527 | hitAdd = (AliMUONHitForRec*)((*fTrackHitsPtr)[i]); | |
528 | fTrackHitsPtr->Remove((TObjArray*)hitAdd); // remove hit | |
529 | hitAdd->SetNTrackHits(hitAdd->GetNTrackHits()-1); // unmark hit | |
530 | fNTrackHits --; | |
531 | if (hitAdd == fSkipHit) break; | |
532 | } // for (i=fNTrackHits-1; | |
533 | } | |
534 | Back = kFALSE; | |
535 | fRecover =0; // ????????? Dec-17-2001 | |
536 | ichambOK = ((AliMUONHitForRec*)((*fTrackHitsPtr)[fNTrackHits-1]))->GetChamberNumber(); | |
537 | currIndx = fgHitForRec->IndexOf(fSkipHit); | |
538 | } | |
539 | ||
540 | if (Back && !miss) { | |
541 | // backward propagator | |
542 | TMatrixD pointWeight(kSize,kSize); | |
543 | TMatrixD point(kSize,1); | |
544 | TMatrixD trackParTmp = point; | |
545 | point(0,0) = hitAdd->GetBendingCoor(); | |
546 | point(1,0) = hitAdd->GetNonBendingCoor(); | |
547 | pointWeight(0,0) = 1/hitAdd->GetBendingReso2(); | |
548 | pointWeight(1,1) = 1/hitAdd->GetNonBendingReso2(); | |
549 | TryPoint(point,pointWeight,trackParTmp,dChi2); | |
550 | *fTrackPar = trackParTmp; | |
551 | *fWeight += pointWeight; | |
552 | fChi2 += dChi2; // Chi2 | |
553 | if (ichamb==ichamEnd) break; | |
554 | currIndx += iDindx; | |
555 | } else { | |
556 | // forward propagator | |
557 | if (miss || !FindPoint(ichamb,zEnd,currIndx,iFB,hitAdd)) { | |
558 | // missing point | |
559 | *fTrackPar = *fTrackParNew; | |
560 | } else { | |
561 | //add point | |
562 | fTrackHitsPtr->Add((TObjArray*)hitAdd); // add hit | |
563 | fNTrackHits ++; | |
564 | hitAdd->SetNTrackHits(hitAdd->GetNTrackHits()+1); // mark hit as being on track | |
565 | ichambOK = ichamb; | |
566 | currIndx = fgHitForRec->IndexOf(hitAdd); // Check | |
567 | } | |
568 | } | |
569 | } // while | |
570 | cout << fNTrackHits << " " << fChi2 << " " << 1/(*fTrackPar)(4,0) << " " << fPosition << endl; | |
571 | return success; | |
572 | } | |
573 | ||
574 | //__________________________________________________________________________ | |
575 | void AliMUONTrackK::ParPropagation(Double_t zEnd) | |
576 | { | |
577 | // Propagation of track parameters to zEnd | |
578 | Int_t iFB, nTries; | |
579 | Double_t dZ, step, distance, charge; | |
580 | Double_t vGeant3[7], vGeant3New[7]; | |
581 | ||
582 | nTries = 0; | |
583 | // First step using linear extrapolation | |
584 | dZ = zEnd - fPosition; | |
585 | iFB = (Int_t)TMath::Sign(Double_t(1.0),dZ); | |
586 | step = dZ/TMath::Cos((*fTrackPar)(2,0))/TMath::Cos((*fTrackPar)(3,0)); // linear estimate | |
587 | charge = iFB*TMath::Sign(Double_t(1.0),(*fTrackPar)(4,0)); | |
588 | fPositionNew = fPosition; | |
589 | *fTrackParNew = *fTrackPar; | |
590 | SetGeantParam(vGeant3,iFB); | |
591 | ||
592 | // Check if overstep | |
593 | do { | |
594 | step = TMath::Abs(step); | |
595 | // Propagate parameters | |
596 | extrap_onestep_rungekutta(charge,step,vGeant3,vGeant3New); | |
597 | distance = zEnd - vGeant3New[2]; | |
598 | step *= dZ/(vGeant3New[2]-fPositionNew); | |
599 | nTries ++; | |
600 | } while (distance*iFB < 0 && TMath::Abs(distance) > kEpsilon); | |
601 | ||
602 | GetFromGeantParam(vGeant3New,iFB); | |
603 | ||
604 | // Position ajustment (until within tolerance) | |
605 | while (TMath::Abs(distance) > kEpsilon) { | |
606 | dZ = zEnd - fPositionNew; | |
607 | iFB = (Int_t)TMath::Sign(Double_t(1.0),dZ); | |
608 | step = dZ/TMath::Cos((*fTrackParNew)(2,0))/TMath::Cos((*fTrackParNew)(3,0)); | |
609 | step = TMath::Abs(step); | |
610 | SetGeantParam(vGeant3,iFB); | |
611 | do { | |
612 | // binary search | |
613 | // Propagate parameters | |
614 | extrap_onestep_rungekutta(charge,step,vGeant3,vGeant3New); | |
615 | distance = zEnd - vGeant3New[2]; | |
616 | step /= 2; | |
617 | nTries ++; | |
618 | if (nTries > kTriesMax) { | |
619 | cout << " ***** ParPropagation: too many tries " << nTries << endl; | |
620 | exit(0); | |
621 | } | |
622 | } while (distance*iFB < 0); | |
623 | ||
624 | GetFromGeantParam(vGeant3New,iFB); | |
625 | } | |
626 | //cout << nTries << endl; | |
627 | return; | |
628 | } | |
629 | /* | |
630 | //__________________________________________________________________________ | |
631 | void AliMUONTrackK::WeightPropagation(void) | |
632 | { | |
633 | // Propagation of the weight matrix | |
634 | // W = DtWD, where D is Jacobian | |
635 | ||
636 | // !!! not implemented TMatrixD weight1(*fJacob,TMatrixD::kAtBA,*fWeight); // DtWD | |
637 | TMatrixD weight1(*fWeight,TMatrixD::kMult,*fJacob); // WD | |
638 | *fWeight = TMatrixD(*fJacob,TMatrixD::kTransposeMult,weight1); // DtWD | |
639 | return; | |
640 | } | |
641 | */ | |
642 | //__________________________________________________________________________ | |
643 | void AliMUONTrackK::WeightPropagation(Double_t zEnd) | |
644 | { | |
645 | // Propagation of the weight matrix | |
646 | // W = DtWD, where D is Jacobian | |
647 | Int_t i, j; | |
648 | Double_t dPar; | |
649 | ||
650 | TMatrixD Jacob(kSize,kSize); | |
651 | Jacob = 0; | |
652 | ||
653 | // Save initial and propagated parameters | |
654 | TMatrixD trackPar0 = *fTrackPar; | |
655 | TMatrixD trackParNew0 = *fTrackParNew; | |
656 | Double_t savePosition = fPositionNew; | |
657 | ||
658 | // Get covariance matrix | |
659 | *fCovariance = *fWeight; | |
660 | // check whether the Invert method returns flag if matrix cannot be inverted, | |
661 | // and do not calculate the Determinant in that case !!!! | |
662 | if (fCovariance->Determinant() != 0) { | |
663 | // fCovariance->Invert(); | |
664 | Int_t ifailCov; | |
665 | mnvertLocalK(&((*fCovariance)(0,0)), kSize,kSize,kSize,ifailCov); | |
666 | } else { | |
667 | cout << " ***** Warning in WeightPropagation: Determinant fCovariance=0:" << endl; | |
668 | } | |
669 | ||
670 | // Loop over parameters to find change of the initial vs propagated ones | |
671 | zEnd = fPosition; | |
672 | fPosition = fPositionNew; | |
673 | for (i=0; i<kSize; i++) { | |
674 | dPar = TMath::Sqrt((*fCovariance)(i,i)); | |
675 | *fTrackPar = trackParNew0; | |
676 | (*fTrackPar)(i,0) += dPar; | |
677 | ParPropagation(zEnd); | |
678 | for (j=0; j<kSize; j++) { | |
679 | Jacob(j,i) = ((*fTrackParNew)(j,0)-trackPar0(j,0))/dPar; | |
680 | } | |
681 | } | |
682 | ||
683 | //Jacob->Print(); | |
684 | //trackParNew0.Print(); | |
685 | //TMatrixD par1(Jacob,TMatrixD::kMult,trackPar0); // | |
686 | //par1.Print(); | |
687 | /* | |
688 | if (Jacob.Determinant() != 0) { | |
689 | // Jacob.Invert(); | |
690 | } else { | |
691 | cout << " ***** Warning in WeightPropagation: Determinant Jacob=0:" << endl; | |
692 | } | |
693 | */ | |
694 | TMatrixD weight1(*fWeight,TMatrixD::kMult,Jacob); // WD | |
695 | *fWeight = TMatrixD(Jacob,TMatrixD::kTransposeMult,weight1); // DtWD | |
696 | //fWeight->Print(); | |
697 | ||
698 | // Restore initial and propagated parameters | |
699 | *fTrackPar = trackPar0; | |
700 | *fTrackParNew = trackParNew0; | |
701 | fPosition = zEnd; | |
702 | fPositionNew = savePosition; | |
703 | return; | |
704 | } | |
705 | ||
706 | //__________________________________________________________________________ | |
707 | Bool_t AliMUONTrackK::FindPoint(Int_t ichamb, Double_t zEnd, Int_t currIndx, Int_t iFB, AliMUONHitForRec *&hitAdd) | |
708 | { | |
709 | // Picks up point within a window for the chamber No ichamb | |
710 | // Split the track if there are more than 1 hit | |
711 | Int_t ihit, nRecTracks; | |
712 | Double_t WindowB, WindowNonB, dChi2Tmp=0, dChi2, y, x, savePosition=0; | |
713 | TClonesArray *trackPtr; | |
714 | AliMUONHitForRec *hit, *hitLoop; | |
715 | AliMUONTrackK *trackK; | |
716 | ||
717 | Bool_t Ok = kFALSE; | |
718 | //sigmaB = fgEventReconstructor->GetBendingResolution(); // bending resolution | |
719 | //sigmaNonB = fgEventReconstructor->GetNonBendingResolution(); // non-bending resolution | |
720 | *fCovariance = *fWeight; | |
721 | // check whether the Invert method returns flag if matrix cannot be inverted, | |
722 | // and do not calculate the Determinant in that case !!!! | |
723 | if (fCovariance->Determinant() != 0) { | |
724 | // fCovariance->Invert(); | |
725 | ||
726 | Int_t ifailCov; | |
727 | mnvertLocalK(&((*fCovariance)(0,0)), kSize,kSize,kSize,ifailCov); | |
728 | } else { | |
729 | cout << " ***** Warning in FindPoint: Determinant fCovariance=0:" << endl; | |
730 | } | |
731 | //WindowB = kNSigma*TMath::Sqrt((*fCovariance)(0,0)+sigmaB*sigmaB); | |
732 | //WindowNonB = kNSigma*TMath::Sqrt((*fCovariance)(1,1)+sigmaNonB*sigmaNonB); | |
733 | // Loop over all hits and take hits from the chamber | |
734 | TMatrixD pointWeight(kSize,kSize); | |
735 | TMatrixD saveWeight = pointWeight; | |
736 | TMatrixD pointWeightTmp = pointWeight; | |
737 | TMatrixD point(kSize,1); | |
738 | TMatrixD trackPar = point; | |
739 | TMatrixD trackParTmp = point; | |
740 | Int_t nHitsOK = 0; | |
741 | ||
742 | for (ihit=currIndx; ihit>=0 && ihit<fgNOfPoints; ihit+=iFB) { | |
743 | hit = (AliMUONHitForRec*) ((*fgHitForRec)[ihit]); | |
744 | if (hit->GetChamberNumber() == ichamb) { | |
745 | //if (TMath::Abs(hit->GetZ()-zEnd) < 0.1) { | |
746 | if (TMath::Abs(hit->GetZ()-zEnd) < 0.5) { | |
747 | if (TMath::Abs(hit->GetZ()-zEnd) > 0.1) { | |
748 | // adjust position: for multiple hits in the chamber | |
749 | // (mostly (only?) for GEANT hits) | |
750 | zEnd = hit->GetZ(); | |
751 | *fTrackPar = *fTrackParNew; | |
752 | ParPropagation(zEnd); | |
753 | WeightPropagation(zEnd); | |
754 | fPosition = fPositionNew; | |
755 | *fTrackPar = *fTrackParNew; | |
756 | // Get covariance | |
757 | *fCovariance = *fWeight; | |
758 | if (fCovariance->Determinant() != 0) { | |
759 | //fCovariance->Invert(); | |
760 | Int_t ifailCov; | |
761 | mnvertLocalK(&((*fCovariance)(0,0)), kSize,kSize,kSize,ifailCov); | |
762 | } else { | |
763 | cout << " ***** Warning in FindPoint: Determinant fCovariance=0:" << endl; | |
764 | } | |
765 | } | |
766 | y = hit->GetBendingCoor(); | |
767 | x = hit->GetNonBendingCoor(); | |
768 | WindowB = kNSigma*TMath::Sqrt((*fCovariance)(0,0)+hit->GetBendingReso2()); | |
769 | WindowNonB = kNSigma*TMath::Sqrt((*fCovariance)(1,1)+hit->GetNonBendingReso2()); | |
770 | if (TMath::Abs((*fTrackParNew)(0,0)-y) <= WindowB && | |
771 | TMath::Abs((*fTrackParNew)(1,0)-x) <= WindowNonB) { | |
772 | // Vector of measurements and covariance matrix | |
773 | point.Zero(); | |
774 | point(0,0) = y; | |
775 | point(1,0) = x; | |
776 | pointWeight(0,0) = 1/hit->GetBendingReso2(); | |
777 | pointWeight(1,1) = 1/hit->GetNonBendingReso2(); | |
778 | TryPoint(point,pointWeight,trackPar,dChi2); | |
779 | if (TMath::Abs(1./(trackPar)(4,0)) < fgEventReconstructor->GetMinBendingMomentum()) continue; // p < p_min - next hit | |
780 | Ok = kTRUE; | |
781 | nHitsOK++; | |
782 | //if (nHitsOK > -1) { | |
783 | if (nHitsOK == 1) { | |
784 | // Save current members | |
785 | saveWeight = *fWeight; | |
786 | savePosition = fPosition; | |
787 | // temporary storage for the current track | |
788 | dChi2Tmp = dChi2; | |
789 | trackParTmp = trackPar; | |
790 | pointWeightTmp = pointWeight; | |
791 | hitAdd = hit; | |
792 | } else { | |
793 | // branching: create a new track | |
794 | trackPtr = fgEventReconstructor->GetRecTracksPtr(); | |
795 | nRecTracks = fgEventReconstructor->GetNRecTracks(); | |
796 | trackK = new ((*trackPtr)[nRecTracks]) | |
797 | AliMUONTrackK(*this); // dummy copy constructor | |
798 | *trackK = *this; | |
799 | fgEventReconstructor->SetNRecTracks(nRecTracks+1); | |
800 | //cout << " ******** New track: " << ichamb << " " << hit->GetTHTrack() << " " << 1/(trackPar)(4,0) << " " << hit->GetBendingCoor() << " " << fNTrackHits << " " << nRecTracks << endl; | |
801 | trackK->fRecover = 0; | |
802 | *(trackK->fTrackPar) = trackPar; | |
803 | *(trackK->fWeight) += pointWeight; | |
804 | trackK->fChi2 += dChi2; | |
805 | // Mark hits as being on 2 tracks | |
806 | for (Int_t i=0; i<fNTrackHits; i++) { | |
807 | hitLoop = (AliMUONHitForRec*) ((*fTrackHitsPtr)[i]); | |
808 | hitLoop->SetNTrackHits(hitLoop->GetNTrackHits()+1); | |
809 | /* | |
810 | cout << " ** "; | |
811 | cout << hitLoop->GetChamberNumber() << " "; | |
812 | cout << hitLoop->GetBendingCoor() << " "; | |
813 | cout << hitLoop->GetNonBendingCoor() << " "; | |
814 | cout << hitLoop->GetZ() << " " << " "; | |
815 | cout << hitLoop->GetGeantSignal() << " " << " "; | |
816 | cout << hitLoop->GetTHTrack() << endl; | |
817 | printf(" ** %d %10.4f %10.4f %10.4f %d %d \n", | |
818 | hitLoop->GetChamberNumber(), hitLoop->GetBendingCoor(), | |
819 | hitLoop->GetNonBendingCoor(), hitLoop->GetZ(), | |
820 | hitLoop->GetGeantSignal(), hitLoop->GetTHTrack()); | |
821 | */ | |
822 | } | |
823 | //add point | |
824 | trackK->fTrackHitsPtr->Add((TObjArray*)hit); // add hit | |
825 | trackK->fNTrackHits ++; | |
826 | hit->SetNTrackHits(hit->GetNTrackHits()+1); // mark hit as being on track | |
827 | if (ichamb == 9) { | |
828 | // the last chamber | |
829 | trackK->fTrackDir = -1; | |
830 | trackK->fBPFlag = kTRUE; | |
831 | } | |
832 | } | |
833 | } | |
834 | } | |
835 | } else break; // different chamber | |
836 | } // for (ihit=currIndx; | |
837 | if (Ok) { | |
838 | *fTrackPar = trackParTmp; | |
839 | *fWeight = saveWeight; | |
840 | *fWeight += pointWeightTmp; | |
841 | fChi2 += dChi2Tmp; // Chi2 | |
842 | // Restore members | |
843 | fPosition = savePosition; | |
844 | } | |
845 | return Ok; | |
846 | } | |
847 | ||
848 | //__________________________________________________________________________ | |
849 | void AliMUONTrackK::TryPoint(TMatrixD &point, const TMatrixD &pointWeight, TMatrixD &trackParTmp, Double_t &dChi2) | |
850 | { | |
851 | // Adds a measurement point (modifies track parameters and computes | |
852 | // change of Chi2) | |
853 | ||
854 | // Solving linear system (W+U)p' = U(m-p) + (W+U)p | |
855 | TMatrixD wu = *fWeight; | |
856 | wu += pointWeight; // W+U | |
857 | trackParTmp = point; | |
858 | trackParTmp -= *fTrackParNew; // m-p | |
859 | TMatrixD right(pointWeight,TMatrixD::kMult,trackParTmp); // U(m-p) | |
860 | TMatrixD right1(wu,TMatrixD::kMult,*fTrackParNew); // (W+U)p | |
861 | right += right1; // U(m-p) + (W+U)p | |
862 | ||
863 | // check whether the Invert method returns flag if matrix cannot be inverted, | |
864 | // and do not calculate the Determinant in that case !!!! | |
865 | if (wu.Determinant() != 0) { | |
866 | ||
867 | // wu.Invert(); | |
868 | Int_t ifailWU; | |
869 | mnvertLocalK(&((wu)(0,0)), kSize,kSize,kSize,ifailWU); | |
870 | } else { | |
871 | cout << " ***** Warning in TryPoint: Determinant wu=0:" << endl; | |
872 | } | |
873 | trackParTmp = TMatrixD(wu,TMatrixD::kMult,right); | |
874 | ||
875 | right1 = trackParTmp; | |
876 | right1 -= point; // p'-m | |
877 | point = trackParTmp; | |
878 | point -= *fTrackParNew; // p'-p | |
879 | right = TMatrixD(*fWeight,TMatrixD::kMult,point); // W(p'-p) | |
880 | TMatrixD value(point,TMatrixD::kTransposeMult,right); // (p'-p)'W(p'-p) | |
881 | dChi2 = value(0,0); | |
882 | right = TMatrixD(pointWeight,TMatrixD::kMult,right1); // U(p'-m) | |
883 | value = TMatrixD(right1,TMatrixD::kTransposeMult,right); // (p'-m)'U(p'-m) | |
884 | dChi2 += value(0,0); | |
885 | return; | |
886 | } | |
887 | ||
888 | //__________________________________________________________________________ | |
889 | void AliMUONTrackK::MSThin(Int_t sign) | |
890 | { | |
891 | // Adds multiple scattering in a thin layer (only angles are affected) | |
892 | Double_t cosAlph, cosBeta, momentum, velo, path, theta0; | |
893 | ||
894 | // check whether the Invert method returns flag if matrix cannot be inverted, | |
895 | // and do not calculate the Determinant in that case !!!! | |
896 | if (fWeight->Determinant() != 0) { | |
897 | //fWeight->Invert(); // covariance | |
898 | ||
899 | Int_t ifailWeight; | |
900 | mnvertLocalK(&((*fWeight)(0,0)), kSize,kSize,kSize,ifailWeight); | |
901 | } else { | |
902 | cout << " ***** Warning in MSThin: Determinant fWeight=0:" << endl; | |
903 | } | |
904 | ||
905 | cosAlph = TMath::Cos((*fTrackParNew)(2,0)); | |
906 | cosBeta = TMath::Cos((*fTrackParNew)(3,0)); | |
907 | momentum = 1/(*fTrackParNew)(4,0); // particle momentum | |
908 | //velo = momentum/TMath::Sqrt(momentum*momentum+muonMass*muonMass); // velocity/c for muon hypothesis | |
909 | velo = 1; // relativistic | |
910 | path = fgEventReconstructor->GetChamberThicknessInX0()/cosAlph/cosBeta; // path length | |
911 | theta0 = 0.0136/velo/momentum*TMath::Sqrt(path)*(1+0.038*TMath::Log(path)); // projected scattering angle | |
912 | ||
913 | (*fWeight)(2,2) += sign*theta0/cosBeta*theta0/cosBeta; // alpha | |
914 | (*fWeight)(3,3) += sign*theta0*theta0; // beta | |
915 | //fWeight->Invert(); // weight | |
916 | ||
917 | Int_t ifailWeight; | |
918 | mnvertLocalK(&((*fWeight)(0,0)), kSize,kSize,kSize,ifailWeight); | |
919 | return; | |
920 | } | |
921 | //__________________________________________________________________________ | |
922 | void AliMUONTrackK::StartBack(void) | |
923 | { | |
924 | // Starts backpropagator | |
925 | ||
926 | fBPFlag = kTRUE; | |
927 | fChi2 = 0; | |
928 | for (Int_t i=0; i<kSize; i++) { | |
929 | for (Int_t j=0; j<kSize; j++) { | |
930 | if (j==i) (*fWeight)(i,i) /= 100; | |
931 | //if (j==i) (*fWeight)(i,i) /= fNTrackHits*fNTrackHits; | |
932 | else (*fWeight)(j,i) = 0; | |
933 | } | |
934 | } | |
935 | } | |
936 | ||
937 | //__________________________________________________________________________ | |
938 | void AliMUONTrackK::SetGeantParam(Double_t *VGeant3, Int_t iFB) | |
939 | { | |
940 | // Set vector of Geant3 parameters pointed to by "VGeant3" | |
941 | // from track parameters | |
942 | ||
943 | VGeant3[0] = (*fTrackParNew)(1,0); // X | |
944 | VGeant3[1] = (*fTrackParNew)(0,0); // Y | |
945 | VGeant3[2] = fPositionNew; // Z | |
946 | VGeant3[3] = iFB*TMath::Sin((*fTrackParNew)(3,0)); // Px/Ptot | |
947 | VGeant3[4] = iFB*TMath::Cos((*fTrackParNew)(3,0))*TMath::Sin((*fTrackParNew)(2,0)); // Py/Ptot | |
948 | VGeant3[5] = iFB*TMath::Sqrt(1.0-VGeant3[3]*VGeant3[3]-VGeant3[4]*VGeant3[4]); // Pz/Ptot | |
949 | VGeant3[6] = 1/TMath::Abs((*fTrackParNew)(4,0)); // Ptot | |
950 | } | |
951 | ||
952 | //__________________________________________________________________________ | |
953 | void AliMUONTrackK::GetFromGeantParam(Double_t *VGeant3, Int_t iFB) | |
954 | { | |
955 | // Get track parameters from vector of Geant3 parameters pointed | |
956 | // to by "VGeant3" | |
957 | ||
958 | fPositionNew = VGeant3[2]; // Z | |
959 | (*fTrackParNew)(0,0) = VGeant3[1]; // Y | |
960 | (*fTrackParNew)(1,0) = VGeant3[0]; // X | |
961 | (*fTrackParNew)(3,0) = TMath::ASin(iFB*VGeant3[3]); // beta | |
962 | (*fTrackParNew)(2,0) = TMath::ASin(iFB*VGeant3[4]/TMath::Cos((*fTrackParNew)(3,0))); // alpha | |
963 | (*fTrackParNew)(4,0) = 1/VGeant3[6]*TMath::Sign(Double_t(1.0),(*fTrackPar)(4,0)); // 1/Ptot | |
964 | } | |
965 | ||
966 | //__________________________________________________________________________ | |
967 | void AliMUONTrackK::SetTrackQuality(Int_t iChi2) | |
968 | { | |
969 | // Computes "track quality" from Chi2 (if iChi2==0) or vice versa | |
970 | ||
971 | if (fChi2 > 250) { | |
972 | cout << " ***** Too high Chi2: " << fChi2 << endl; | |
973 | fChi2 = 250; | |
974 | // exit(0); | |
975 | } | |
976 | if (iChi2 == 0) fChi2 = fNTrackHits + (250.-fChi2)/251; | |
977 | else fChi2 = 250 - (fChi2-fNTrackHits)*251; | |
978 | } | |
979 | ||
980 | //__________________________________________________________________________ | |
981 | Int_t AliMUONTrackK::Compare(const TObject* trackK) const | |
982 | { | |
983 | // "Compare" function to sort with decreasing "track quality". | |
984 | // Returns +1 (0, -1) if quality of current track | |
985 | // is smaller than (equal to, larger than) quality of trackK | |
986 | ||
987 | if (fChi2 < ((AliMUONTrackK*)trackK)->fChi2) return(+1); | |
988 | else if (fChi2 == ((AliMUONTrackK*)trackK)->fChi2) return(0); | |
989 | else return(-1); | |
990 | } | |
991 | ||
992 | //__________________________________________________________________________ | |
993 | Bool_t AliMUONTrackK::KeepTrack(AliMUONTrackK* track0) | |
994 | { | |
995 | // Check whether or not to keep current track | |
996 | // (keep, if it has less than half of common hits with track0) | |
997 | Int_t hitsInCommon, nHits0, i, j, nTrackHits2; | |
998 | AliMUONHitForRec *hit0, *hit1; | |
999 | ||
1000 | hitsInCommon = 0; | |
1001 | nHits0 = track0->fNTrackHits; | |
1002 | nTrackHits2 = fNTrackHits/2; | |
1003 | ||
1004 | for (i=0; i<nHits0; i++) { | |
1005 | // Check if hit belongs to several tracks | |
1006 | hit0 = (AliMUONHitForRec*) (*track0->fTrackHitsPtr)[i]; | |
1007 | if (hit0->GetNTrackHits() == 1) continue; | |
1008 | for (j=0; j<fNTrackHits; j++) { | |
1009 | hit1 = (AliMUONHitForRec*) (*fTrackHitsPtr)[j]; | |
1010 | if (hit1->GetNTrackHits() == 1) continue; | |
1011 | if (hit0 == hit1) { | |
1012 | hitsInCommon++; | |
1013 | if (hitsInCommon >= nTrackHits2) return kFALSE; | |
1014 | break; | |
1015 | } | |
1016 | } // for (j=0; | |
1017 | } // for (i=0; | |
1018 | return kTRUE; | |
1019 | } | |
1020 | ||
1021 | //__________________________________________________________________________ | |
1022 | void AliMUONTrackK::Kill(void) | |
1023 | { | |
1024 | // Kill track candidate | |
1025 | Int_t i; | |
1026 | AliMUONHitForRec *hit; | |
1027 | ||
1028 | if (fTrackHitsPtr) { | |
1029 | // Remove track mark from hits | |
1030 | for (i=0; i<fNTrackHits; i++) { | |
1031 | hit = (AliMUONHitForRec*) (*fTrackHitsPtr)[i]; | |
1032 | hit->SetNTrackHits(hit->GetNTrackHits()-1); | |
1033 | } | |
1034 | } | |
1035 | fgEventReconstructor->GetRecTracksPtr()->Remove(this); | |
1036 | } | |
1037 | ||
1038 | //__________________________________________________________________________ | |
1039 | void AliMUONTrackK::Branson(void) | |
1040 | { | |
1041 | // Propagates track to the vertex thru absorber using Branson correction | |
1042 | // (makes use of the AliMUONTrackParam class) | |
1043 | ||
1044 | AliMUONTrackParam *trackParam = new AliMUONTrackParam(); | |
1045 | trackParam->SetBendingCoor((*fTrackPar)(0,0)); | |
1046 | trackParam->SetNonBendingCoor((*fTrackPar)(1,0)); | |
1047 | trackParam->SetBendingSlope(TMath::Tan((*fTrackPar)(2,0))); | |
1048 | trackParam->SetNonBendingSlope(TMath::Tan((*fTrackPar)(3,0))/TMath::Cos((*fTrackPar)(2,0))); | |
1049 | trackParam->SetInverseBendingMomentum((*fTrackPar)(4,0)/TMath::Cos((*fTrackPar)(3,0))); | |
1050 | trackParam->SetZ(fPosition); | |
1051 | ||
1052 | trackParam->ExtrapToVertex(); | |
1053 | ||
1054 | (*fTrackPar)(0,0) = trackParam->GetBendingCoor(); | |
1055 | (*fTrackPar)(1,0) = trackParam->GetNonBendingCoor(); | |
1056 | (*fTrackPar)(2,0) = TMath::ATan(trackParam->GetBendingSlope()); | |
1057 | (*fTrackPar)(3,0) = TMath::ATan(TMath::Cos((*fTrackPar)(2,0))*trackParam->GetNonBendingSlope()); | |
1058 | (*fTrackPar)(4,0) = TMath::Cos((*fTrackPar)(3,0))*trackParam->GetInverseBendingMomentum(); | |
1059 | fPosition = trackParam->GetZ(); | |
1060 | delete trackParam; | |
1061 | cout << 1/(*fTrackPar)(4,0) << " " << fPosition << " " << (*fTrackPar)(0,0) << endl; | |
1062 | ||
1063 | // Get covariance matrix | |
1064 | *fCovariance = *fWeight; | |
1065 | if (fCovariance->Determinant() != 0) { | |
1066 | // fCovariance->Invert(); | |
1067 | ||
1068 | Int_t ifailCov; | |
1069 | mnvertLocalK(&((*fCovariance)(0,0)), kSize,kSize,kSize,ifailCov); | |
1070 | } else { | |
1071 | cout << " ***** Warning in Branson: Determinant fCovariance=0:" << endl; | |
1072 | } | |
1073 | } | |
1074 | ||
1075 | //__________________________________________________________________________ | |
1076 | void AliMUONTrackK::GoToZ(Double_t zEnd) | |
1077 | { | |
1078 | // Propagates track to given Z | |
1079 | ||
1080 | ParPropagation(zEnd); | |
1081 | MSThin(1); // multiple scattering in the chamber | |
1082 | WeightPropagation(zEnd); | |
1083 | fPosition = fPositionNew; | |
1084 | *fTrackPar = *fTrackParNew; | |
1085 | } | |
1086 | ||
1087 | //__________________________________________________________________________ | |
1088 | void AliMUONTrackK::GoToVertex(void) | |
1089 | { | |
1090 | // Version 3.08 | |
1091 | // Propagates track to the vertex | |
1092 | // All material constants are taken from AliRoot | |
1093 | ||
1094 | static Double_t x01[5] = { 24.282, // C | |
1095 | 24.282, // C | |
1096 | 11.274, // Concrete | |
1097 | 1.758, // Fe | |
1098 | 1.758}; // Fe (cm) | |
1099 | // inner part theta < 3 degrees | |
1100 | static Double_t x02[5] = { 30413, // Air | |
1101 | 24.282, // C | |
1102 | 11.274, // Concrete | |
1103 | 1.758, // Fe | |
1104 | 0.369}; // W (cm) | |
1105 | // z positions of the materials inside the absober outer part theta > 3 degres | |
1106 | static Double_t zPos[10] = {90, 105, 315, 443, 468}; | |
1107 | // R > 1 | |
1108 | // R < 1 | |
1109 | ||
1110 | Double_t dZ, r0Norm, X0, deltaP, dChi2, pTotal, pOld; | |
1111 | AliMUONHitForRec *hit; | |
1112 | AliMUONRawCluster *clus; | |
1113 | TClonesArray *rawclusters; | |
1114 | ||
1115 | // First step to the rear end of the absorber | |
1116 | Double_t zRear = 503; | |
1117 | GoToZ(zRear); | |
1118 | Double_t tan3 = TMath::Tan(3./180*TMath::Pi()); | |
1119 | ||
1120 | // Go through absorber | |
1121 | pOld = 1/(*fTrackPar)(4,0); | |
1122 | Double_t r0Rear = (*fTrackPar)(0,0)*(*fTrackPar)(0,0) + | |
1123 | (*fTrackPar)(1,0)*(*fTrackPar)(1,0); | |
1124 | r0Rear = TMath::Sqrt(r0Rear)/fPosition/tan3; | |
1125 | r0Norm = r0Rear; | |
1126 | for (Int_t i=4; i>=0; i--) { | |
1127 | ParPropagation(zPos[i]); | |
1128 | WeightPropagation(zPos[i]); | |
1129 | dZ = TMath::Abs (fPositionNew-fPosition); | |
1130 | if (r0Norm > 1) X0 = x01[i]; | |
1131 | else X0 = x02[i]; | |
1132 | MSLine(dZ,X0); // multiple scattering in the medium (linear approximation) | |
1133 | fPosition = fPositionNew; | |
1134 | *fTrackPar = *fTrackParNew; | |
1135 | r0Norm = (*fTrackPar)(0,0)*(*fTrackPar)(0,0) + | |
1136 | (*fTrackPar)(1,0)*(*fTrackPar)(1,0); | |
1137 | r0Norm = TMath::Sqrt(r0Norm)/fPosition/tan3; | |
1138 | } | |
1139 | // Correct momentum for energy losses | |
1140 | pTotal = 1/TMath::Abs((*fTrackPar)(4,0)); | |
1141 | Double_t p0 = pTotal; | |
1142 | for (Int_t j=0; j<2; j++) { | |
1143 | /* | |
1144 | if (r0Rear > 1) { | |
1145 | if (p0 < 20) { | |
1146 | deltaP = 2.164 + 0.145e-1*p0 - 0.417e-3*p0*p0; | |
1147 | } else { | |
1148 | deltaP = 2.275 + 0.102e-2*p0 - 0.674e-6*p0*p0; | |
1149 | } | |
1150 | } else { | |
1151 | if (p0 < 20) { | |
1152 | deltaP = 2.581 + 0.188e-1*p0 - 0.398e-3*p0*p0; | |
1153 | } else { | |
1154 | deltaP = 2.727 + 0.356e-2*p0 + 0.242e-5*p0*p0; | |
1155 | } | |
1156 | } | |
1157 | */ | |
1158 | if (r0Rear < 1) { | |
1159 | //W | |
1160 | if (p0<15) { | |
1161 | deltaP = 2.737 + 0.0494*p0 - 0.001123*p0*p0; | |
1162 | } else { | |
1163 | deltaP = 3.0643 + 0.01346*p0; | |
1164 | } | |
1165 | } else { | |
1166 | //Pb | |
1167 | if (p0<15) { | |
1168 | deltaP = 2.1380 + 0.0351*p0 - 0.000853*p0*p0; | |
1169 | } else { | |
1170 | deltaP = 2.407 + 0.00702*p0; | |
1171 | } | |
1172 | } | |
1173 | ||
1174 | p0 = pTotal + deltaP/TMath::Cos((*fTrackPar)(2,0))/TMath::Cos((*fTrackPar)(3,0)); | |
1175 | } | |
1176 | (*fTrackPar)(4,0) = 1/p0*TMath::Sign((Double_t)1.,(*fTrackPar)(4,0)); | |
1177 | ||
1178 | // Go to the vertex | |
1179 | ParPropagation((Double_t)0.); | |
1180 | WeightPropagation((Double_t)0.); | |
1181 | fPosition = fPositionNew; | |
1182 | //*fTrackPar = *fTrackParNew; | |
1183 | // Add vertex as a hit | |
1184 | TMatrixD pointWeight(kSize,kSize); | |
1185 | TMatrixD point(kSize,1); | |
1186 | TMatrixD trackParTmp = point; | |
1187 | point(0,0) = 0; // vertex coordinate - should be taken somewhere | |
1188 | point(1,0) = 0; // vertex coordinate - should be taken somewhere | |
1189 | pointWeight(0,0) = 1/1.e-3/1.e-3; // 10 um error | |
1190 | pointWeight(1,1) = 1/1.e-3/1.e-3; // 10 um error | |
1191 | TryPoint(point,pointWeight,trackParTmp,dChi2); | |
1192 | *fTrackPar = trackParTmp; | |
1193 | *fWeight += pointWeight; | |
1194 | fChi2 += dChi2; // Chi2 | |
1195 | cout << pOld << " " << 1/(*fTrackPar)(4,0) << " " << dChi2 << " " << fChi2 << " " << fNTrackHits << endl; | |
1196 | for (Int_t i1=0; i1<fNTrackHits; i1++) { | |
1197 | hit = (AliMUONHitForRec*) ((*fTrackHitsPtr)[i1]); | |
1198 | printf ("%4d", hit->GetChamberNumber()); | |
1199 | //cout << ((AliMUONHitForRec*)((*fTrackHitsPtr)[i1]))->GetChamberNumber() << " "; | |
1200 | } | |
1201 | cout << endl; | |
1202 | for (Int_t i1=0; i1<fNTrackHits; i1++) { | |
1203 | hit = (AliMUONHitForRec*) ((*fTrackHitsPtr)[i1]); | |
1204 | //cout << ((AliMUONHitForRec*)((*fTrackHitsPtr)[i1]))->GetHitNumber() << " "; | |
1205 | //cout << ((AliMUONHitForRec*)((*fTrackHitsPtr)[i1]))->GetZ() << " "; | |
1206 | printf ("%4d", fgHitForRec->IndexOf(hit)); | |
1207 | //cout << fgHitForRec->IndexOf(((AliMUONHitForRec*)((*fTrackHitsPtr)[i1]))) << " "; | |
1208 | } | |
1209 | cout << endl; | |
1210 | if (fgEventReconstructor->GetRecGeantHits()) { | |
1211 | // from GEANT hits | |
1212 | for (Int_t i1=0; i1<fNTrackHits; i1++) { | |
1213 | hit = (AliMUONHitForRec*) ((*fTrackHitsPtr)[i1]); | |
1214 | cout << hit->GetTHTrack() + hit->GetGeantSignal()*10000 << " "; | |
1215 | } | |
1216 | } else { | |
1217 | // from raw clusters | |
1218 | for (Int_t i1=0; i1<fNTrackHits; i1++) { | |
1219 | hit = (AliMUONHitForRec*) ((*fTrackHitsPtr)[i1]); | |
1220 | rawclusters = fgMUON->RawClustAddress(hit->GetChamberNumber()); | |
1221 | clus = (AliMUONRawCluster*) rawclusters->UncheckedAt(hit->GetHitNumber()); | |
1222 | printf ("%4d", clus->fTracks[1] - 1); | |
1223 | //cout << clus->fTracks[1] - 1 << " "; | |
1224 | } | |
1225 | cout << endl; | |
1226 | for (Int_t i1=0; i1<fNTrackHits; i1++) { | |
1227 | hit = (AliMUONHitForRec*) ((*fTrackHitsPtr)[i1]); | |
1228 | rawclusters = fgMUON->RawClustAddress(hit->GetChamberNumber()); | |
1229 | clus = (AliMUONRawCluster*) rawclusters->UncheckedAt(hit->GetHitNumber()); | |
1230 | if (clus->fTracks[2] != 0) printf ("%4d", clus->fTracks[2] - 1); | |
1231 | else printf ("%4s", " "); | |
1232 | //if (clus->fTracks[2] != 0) cout << clus->fTracks[2] - 1 << " "; | |
1233 | } | |
1234 | } | |
1235 | cout << endl; | |
1236 | for (Int_t i1=0; i1<fNTrackHits; i1++) { | |
1237 | //cout << ((AliMUONHitForRec*)((*fTrackHitsPtr)[i1]))->GetHitNumber() << " "; | |
1238 | cout << ((AliMUONHitForRec*)((*fTrackHitsPtr)[i1]))->GetZ() << " "; | |
1239 | //cout << fgHitForRec->IndexOf(((AliMUONHitForRec*)((*fTrackHitsPtr)[i1]))) << " "; | |
1240 | } | |
1241 | cout << endl; | |
1242 | cout << "---------------------------------------------------" << endl; | |
1243 | ||
1244 | // Get covariance matrix | |
1245 | *fCovariance = *fWeight; | |
1246 | if (fCovariance->Determinant() != 0) { | |
1247 | // fCovariance->Invert(); | |
1248 | ||
1249 | Int_t ifailCov; | |
1250 | mnvertLocalK(&((*fCovariance)(0,0)), kSize,kSize,kSize,ifailCov); | |
1251 | } else { | |
1252 | cout << " ***** Warning in GoToVertex: Determinant fCovariance=0:" << endl; | |
1253 | } | |
1254 | } | |
1255 | ||
1256 | //__________________________________________________________________________ | |
1257 | void AliMUONTrackK::MSLine(Double_t dZ, Double_t X0) | |
1258 | { | |
1259 | // Adds multiple scattering in a thick layer for linear propagation | |
1260 | ||
1261 | Double_t cosAlph = TMath::Cos((*fTrackPar)(2,0)); | |
1262 | Double_t tanAlph = TMath::Tan((*fTrackPar)(2,0)); | |
1263 | Double_t cosBeta = TMath::Cos((*fTrackPar)(3,0)); | |
1264 | Double_t sinBeta; | |
1265 | sinBeta = TMath::Sin((*fTrackPar)(3,0)); | |
1266 | Double_t tanBeta = TMath::Tan((*fTrackPar)(3,0)); | |
1267 | Double_t momentum = 1/(*fTrackPar)(4,0); | |
1268 | Double_t velo = 1; // relativistic velocity | |
1269 | Double_t step = TMath::Abs(dZ)/cosAlph/cosBeta; // step length | |
1270 | ||
1271 | // Projected scattering angle | |
1272 | Double_t theta0 = 0.0136/velo/momentum/TMath::Sqrt(X0)*(1+0.038*TMath::Log(step/X0)); | |
1273 | Double_t theta02 = theta0*theta0; | |
1274 | Double_t dl2 = step*step/2*theta02; | |
1275 | Double_t dl3 = dl2*step*2/3; | |
1276 | ||
1277 | //Derivatives | |
1278 | Double_t dYdT = 1/cosAlph; | |
1279 | Double_t dYdB = 0; //(*fTrackPar)(2,0)*sinBeta/cosAlph; | |
1280 | Double_t dXdT = tanAlph*tanBeta; | |
1281 | //Double_t dXdB = (1+(*fTrackPar)(2,0)*tanAlph*sinBeta*sinBeta)/cosBeta; | |
1282 | Double_t dXdB = 1/cosBeta; | |
1283 | Double_t dAdT = 1/cosBeta; | |
1284 | Double_t dAdB = 0; //(*fTrackPar)(2,0)*tanBeta; | |
1285 | ||
1286 | // Get covariance matrix | |
1287 | *fCovariance = *fWeight; | |
1288 | if (fCovariance->Determinant() != 0) { | |
1289 | // fCovariance->Invert(); | |
1290 | ||
1291 | Int_t ifailCov; | |
1292 | mnvertLocalK(&((*fCovariance)(0,0)), kSize,kSize,kSize,ifailCov); | |
1293 | } else { | |
1294 | cout << " ***** Warning in MSLine: Determinant fCovariance=0:" << endl; | |
1295 | } | |
1296 | ||
1297 | (*fCovariance)(0,0) += dl3*(dYdT*dYdT+dYdB*dYdB); // <yy> | |
1298 | (*fCovariance)(1,1) += dl3*(dXdT*dXdT+dXdB*dXdB); // <xx> | |
1299 | (*fCovariance)(2,2) += theta02*step*(dAdT*dAdT+dAdB*dAdB); // <aa> | |
1300 | (*fCovariance)(3,3) += theta02*step; // <bb> | |
1301 | ||
1302 | (*fCovariance)(0,1) += dl3*(dYdT*dXdT+dYdB*dXdB); // <yx> | |
1303 | (*fCovariance)(1,0) = (*fCovariance)(0,1); | |
1304 | ||
1305 | (*fCovariance)(0,2) += dl2*(dYdT*dAdT+dYdB*dAdB); // <ya> | |
1306 | (*fCovariance)(2,0) = (*fCovariance)(0,2); | |
1307 | ||
1308 | (*fCovariance)(0,3) += dl2*dYdB; // <yb> | |
1309 | (*fCovariance)(3,0) = (*fCovariance)(0,3); | |
1310 | ||
1311 | (*fCovariance)(1,2) += dl2*(dXdT*dAdT+dXdB*dAdB); // <xa> | |
1312 | (*fCovariance)(2,1) = (*fCovariance)(1,2); | |
1313 | ||
1314 | (*fCovariance)(1,3) += dl2*dXdB; // <xb> | |
1315 | (*fCovariance)(3,1) = (*fCovariance)(1,3); | |
1316 | ||
1317 | (*fCovariance)(2,3) += theta02*step*dAdB; // <ab> | |
1318 | (*fCovariance)(3,2) = (*fCovariance)(2,3); | |
1319 | ||
1320 | // Get weight matrix | |
1321 | *fWeight = *fCovariance; | |
1322 | if (fWeight->Determinant() != 0) { | |
1323 | // fWeight->Invert(); | |
1324 | ||
1325 | Int_t ifailWeight; | |
1326 | mnvertLocalK(&((*fWeight)(0,0)), kSize,kSize,kSize,ifailWeight); | |
1327 | } else { | |
1328 | cout << " ***** Warning in MSLine: Determinant fWeight=0:" << endl; | |
1329 | } | |
1330 | } | |
1331 | ||
1332 | //__________________________________________________________________________ | |
1333 | void AliMUONTrackK::Recover(void) | |
1334 | { | |
1335 | // Adds new failed track(s) which can be tried to be recovered | |
1336 | Int_t nRecTracks, ichamb; | |
1337 | TClonesArray *trackPtr; | |
1338 | AliMUONTrackK *trackK; | |
1339 | ||
1340 | //cout << " ******** Enter Recover " << endl; | |
1341 | //return; | |
1342 | trackPtr = fgEventReconstructor->GetRecTracksPtr(); | |
1343 | ||
1344 | // The last hit will be removed | |
1345 | nRecTracks = fgEventReconstructor->GetNRecTracks(); | |
1346 | ||
1347 | // Check if the track candidate doesn't exist yet | |
1348 | for (Int_t i=0; i<nRecTracks; i++) { | |
1349 | trackK = (AliMUONTrackK*) ((*trackPtr)[i]); | |
1350 | if (trackK->fNTrackHits == 2 && trackK->GetRecover() == 0) continue; | |
1351 | if (trackK == this) continue; | |
1352 | //if (trackK->GetRecover() != 1) continue; | |
1353 | if (trackK->fNTrackHits >= fNTrackHits-1) { | |
19b6ceb4 | 1354 | /* |
83dbc640 | 1355 | for (Int_t j=0; j<fNTrackHits-1; j++) { |
1356 | if ((*trackK->fTrackHitsPtr)[j] != ((*fTrackHitsPtr)[j])) break; | |
1357 | return; | |
1358 | } // for (Int_t j=0; | |
19b6ceb4 | 1359 | */ |
1360 | if ((*trackK->fTrackHitsPtr)[0] == ((*fTrackHitsPtr)[0])) return; | |
83dbc640 | 1361 | } |
1362 | } // for (Int_t i=0; | |
1363 | ||
1364 | cout << " ******** Enter Recover " << endl; | |
1365 | trackK = new ((*trackPtr)[nRecTracks]) AliMUONTrackK(fStartSegment); | |
1366 | fgEventReconstructor->SetNRecTracks(nRecTracks+1); | |
1367 | trackK->fRecover = 1; | |
1368 | trackK->fSkipHit = (AliMUONHitForRec*) ((*fTrackHitsPtr)[fNTrackHits-1]); | |
1369 | trackK->fNTrackHits = fNTrackHits; | |
1370 | delete trackK->fTrackHitsPtr; // not efficient ? | |
1371 | trackK->fTrackHitsPtr = new TObjArray(*fTrackHitsPtr); | |
1372 | cout << nRecTracks << " " << trackK->fRecover << endl; | |
1373 | ||
1374 | // The hit before missing chamber will be removed | |
1375 | Int_t ichamBeg = ((AliMUONHitForRec*)((*fTrackHitsPtr)[0]))->GetChamberNumber(); | |
1376 | Int_t indxSkip = -1; | |
1377 | if (ichamBeg == 9) { | |
1378 | // segment in the last station | |
1379 | // look for the missing chamber | |
1380 | for (Int_t i=1; i<fNTrackHits; i++) { | |
1381 | ichamb = ((AliMUONHitForRec*)((*fTrackHitsPtr)[i]))->GetChamberNumber(); | |
1382 | if (TMath::Abs(ichamBeg-ichamb)>1 && i>2) { | |
1383 | indxSkip = i; | |
1384 | break; | |
1385 | } | |
1386 | ichamBeg = ichamb; | |
1387 | } // for (Int_t i=1; | |
1388 | } else { | |
1389 | // in the last but one station | |
1390 | for (Int_t i=1; i<fNTrackHits; i++) { | |
1391 | ichamb = ((AliMUONHitForRec*)((*fTrackHitsPtr)[i]))->GetChamberNumber(); | |
1392 | if (TMath::Abs(ichamBeg-ichamb)>1 && ichamb<4) { | |
1393 | indxSkip = i; | |
1394 | break; | |
1395 | } | |
1396 | ichamBeg = ichamb; | |
1397 | } // for (Int_t i=1; | |
1398 | } | |
1399 | if (indxSkip < 0) return; | |
1400 | ||
1401 | // Check if the track candidate doesn't exist yet | |
1402 | for (Int_t i=0; i<nRecTracks; i++) { | |
1403 | trackK = (AliMUONTrackK*) ((*trackPtr)[i]); | |
1404 | if (trackK->fNTrackHits == 2 && trackK->GetRecover() == 0) continue; | |
1405 | if (trackK == this) continue; | |
1406 | //if (trackK->GetRecover() != 1) continue; | |
1407 | if (trackK->fNTrackHits >= indxSkip-1) { | |
19b6ceb4 | 1408 | /* |
83dbc640 | 1409 | for (Int_t j=0; j<indxSkip-1; j++) { |
1410 | if ((*trackK->fTrackHitsPtr)[j] != ((*fTrackHitsPtr)[j])) break; | |
1411 | return; | |
1412 | } // for (Int_t j=0; | |
19b6ceb4 | 1413 | */ |
1414 | if ((*trackK->fTrackHitsPtr)[0] == ((*fTrackHitsPtr)[0])) return; | |
83dbc640 | 1415 | } |
1416 | } // for (Int_t i=0; | |
1417 | ||
1418 | nRecTracks = fgEventReconstructor->GetNRecTracks(); | |
1419 | trackK = new ((*trackPtr)[nRecTracks]) AliMUONTrackK(fStartSegment); | |
1420 | fgEventReconstructor->SetNRecTracks(nRecTracks+1); | |
1421 | trackK->fRecover = 2; | |
1422 | trackK->fSkipHit = (AliMUONHitForRec*) ((*fTrackHitsPtr)[indxSkip-1]); | |
1423 | trackK->fNTrackHits = fNTrackHits; | |
1424 | delete trackK->fTrackHitsPtr; // not efficient ? | |
1425 | trackK->fTrackHitsPtr = new TObjArray(*fTrackHitsPtr); | |
1426 | cout << nRecTracks << " " << trackK->fRecover << endl; | |
1427 | } | |
1428 | ||
1429 | //______________________________________________________________________________ | |
1430 | void mnvertLocalK(Double_t *a, Int_t l, Int_t, Int_t n, Int_t &ifail) | |
1431 | { | |
1432 | //*-*-*-*-*-*-*-*-*-*-*-*Inverts a symmetric matrix*-*-*-*-*-*-*-*-*-*-*-*-* | |
1433 | //*-* ========================== | |
1434 | //*-* inverts a symmetric matrix. matrix is first scaled to | |
1435 | //*-* have all ones on the diagonal (equivalent to change of units) | |
1436 | //*-* but no pivoting is done since matrix is positive-definite. | |
1437 | //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* | |
1438 | ||
1439 | // taken from TMinuit package of Root (l>=n) | |
1440 | // fVERTs, fVERTq and fVERTpp changed to localVERTs, localVERTq and localVERTpp | |
1441 | // Double_t localVERTs[n], localVERTq[n], localVERTpp[n]; | |
1442 | Double_t * localVERTs = new Double_t[n]; | |
1443 | Double_t * localVERTq = new Double_t[n]; | |
1444 | Double_t * localVERTpp = new Double_t[n]; | |
1445 | // fMaxint changed to localMaxint | |
1446 | Int_t localMaxint = n; | |
1447 | ||
1448 | /* System generated locals */ | |
1449 | Int_t aOffset; | |
1450 | ||
1451 | /* Local variables */ | |
1452 | Double_t si; | |
1453 | Int_t i, j, k, kp1, km1; | |
1454 | ||
1455 | /* Parameter adjustments */ | |
1456 | aOffset = l + 1; | |
1457 | a -= aOffset; | |
1458 | ||
1459 | /* Function Body */ | |
1460 | ifail = 0; | |
1461 | if (n < 1) goto L100; | |
1462 | if (n > localMaxint) goto L100; | |
1463 | //*-*- scale matrix by sqrt of diag elements | |
1464 | for (i = 1; i <= n; ++i) { | |
1465 | si = a[i + i*l]; | |
1466 | if (si <= 0) goto L100; | |
1467 | localVERTs[i-1] = 1 / TMath::Sqrt(si); | |
1468 | } | |
1469 | for (i = 1; i <= n; ++i) { | |
1470 | for (j = 1; j <= n; ++j) { | |
1471 | a[i + j*l] = a[i + j*l]*localVERTs[i-1]*localVERTs[j-1]; | |
1472 | } | |
1473 | } | |
1474 | //*-*- . . . start main loop . . . . | |
1475 | for (i = 1; i <= n; ++i) { | |
1476 | k = i; | |
1477 | //*-*- preparation for elimination step1 | |
1478 | if (a[k + k*l] != 0) localVERTq[k-1] = 1 / a[k + k*l]; | |
1479 | else goto L100; | |
1480 | localVERTpp[k-1] = 1; | |
1481 | a[k + k*l] = 0; | |
1482 | kp1 = k + 1; | |
1483 | km1 = k - 1; | |
1484 | if (km1 < 0) goto L100; | |
1485 | else if (km1 == 0) goto L50; | |
1486 | else goto L40; | |
1487 | L40: | |
1488 | for (j = 1; j <= km1; ++j) { | |
1489 | localVERTpp[j-1] = a[j + k*l]; | |
1490 | localVERTq[j-1] = a[j + k*l]*localVERTq[k-1]; | |
1491 | a[j + k*l] = 0; | |
1492 | } | |
1493 | L50: | |
1494 | if (k - n < 0) goto L51; | |
1495 | else if (k - n == 0) goto L60; | |
1496 | else goto L100; | |
1497 | L51: | |
1498 | for (j = kp1; j <= n; ++j) { | |
1499 | localVERTpp[j-1] = a[k + j*l]; | |
1500 | localVERTq[j-1] = -a[k + j*l]*localVERTq[k-1]; | |
1501 | a[k + j*l] = 0; | |
1502 | } | |
1503 | //*-*- elimination proper | |
1504 | L60: | |
1505 | for (j = 1; j <= n; ++j) { | |
1506 | for (k = j; k <= n; ++k) { a[j + k*l] += localVERTpp[j-1]*localVERTq[k-1]; } | |
1507 | } | |
1508 | } | |
1509 | //*-*- elements of left diagonal and unscaling | |
1510 | for (j = 1; j <= n; ++j) { | |
1511 | for (k = 1; k <= j; ++k) { | |
1512 | a[k + j*l] = a[k + j*l]*localVERTs[k-1]*localVERTs[j-1]; | |
1513 | a[j + k*l] = a[k + j*l]; | |
1514 | } | |
1515 | } | |
1516 | delete localVERTs; | |
1517 | delete localVERTq; | |
1518 | delete localVERTpp; | |
1519 | return; | |
1520 | //*-*- failure return | |
1521 | L100: | |
1522 | delete localVERTs; | |
1523 | delete localVERTq; | |
1524 | delete localVERTpp; | |
1525 | ifail = 1; | |
1526 | } /* mnvertLocal */ |