New macro "MUONTracker" to make track reconstruction from reference tracks.
[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
82a4bc7b 28#include <stdlib.h> // for exit()
a9e2aefa 29
30178c30 30#include <Riostream.h> // for cout
04b5ea16 31#include <TMath.h>
d0bfce8d 32#include <TMatrixD.h>
8429a5e4 33#include <TObjArray.h>
956019b6 34#include <TVirtualFitter.h>
a9e2aefa 35
36#include "AliMUONEventReconstructor.h"
37#include "AliMUONHitForRec.h"
38#include "AliMUONSegment.h"
3831f268 39#include "AliMUONTrack.h"
a9e2aefa 40#include "AliMUONTrackHit.h"
d837040f 41#include "AliMUONTriggerTrack.h"
42#include "AliMUONConstants.h"
a9e2aefa 43
04b5ea16 44// Functions to be minimized with Minuit
a9e2aefa 45void TrackChi2(Int_t &NParam, Double_t *Gradient, Double_t &Chi2, Double_t *Param, Int_t Flag);
04b5ea16 46void TrackChi2MCS(Int_t &NParam, Double_t *Gradient, Double_t &Chi2, Double_t *Param, Int_t Flag);
47
44f59652 48void mnvertLocal(Double_t* a, Int_t l, Int_t m, Int_t n, Int_t& ifail);
49
04b5ea16 50Double_t MultipleScatteringAngle2(AliMUONTrackHit *TrackHit);
a9e2aefa 51
52ClassImp(AliMUONTrack) // Class implementation in ROOT context
53
956019b6 54TVirtualFitter* AliMUONTrack::fgFitter = NULL;
55
d837040f 56 //__________________________________________________________________________
30178c30 57AliMUONTrack::AliMUONTrack()
58 : TObject()
d837040f 59{
60 // Default constructor
61 fgFitter = 0;
62 fEventReconstructor = 0;
e516b01d 63 fTrackHitsPtr = new TObjArray(10);
d837040f 64 fTrackParamAtHit = new TClonesArray("AliMUONTrackParam",10);
b8dc484b 65 fHitForRecAtHit = new TClonesArray("AliMUONHitForRec",10);
66 fTrackID = 0;
d837040f 67}
68
a9e2aefa 69 //__________________________________________________________________________
70AliMUONTrack::AliMUONTrack(AliMUONSegment* BegSegment, AliMUONSegment* EndSegment, AliMUONEventReconstructor* EventReconstructor)
30178c30 71 : TObject()
a9e2aefa 72{
73 // Constructor from two Segment's
74 fEventReconstructor = EventReconstructor; // link back to EventReconstructor
8429a5e4 75 // memory allocation for the TObjArray of pointers to reconstructed TrackHit's
76 fTrackHitsPtr = new TObjArray(10);
a9e2aefa 77 fNTrackHits = 0;
78 AddSegment(BegSegment); // add hits from BegSegment
79 AddSegment(EndSegment); // add hits from EndSegment
80 fTrackHitsPtr->Sort(); // sort TrackHits according to increasing Z
81 SetTrackParamAtVertex(); // set track parameters at vertex
d837040f 82 fTrackParamAtHit = new TClonesArray("AliMUONTrackParam",10);
b8dc484b 83 fHitForRecAtHit = new TClonesArray("AliMUONHitForRec",10);
8429a5e4 84 // set fit conditions...
04b5ea16 85 fFitMCS = 0;
956019b6 86 fFitNParam = 3;
87 fFitStart = 1;
8429a5e4 88 fFitFMin = -1.0;
d837040f 89 fMatchTrigger = kFALSE;
90 fChi2MatchTrigger = 0;
b8dc484b 91 fTrackID = 0;
a9e2aefa 92 return;
93}
94
95 //__________________________________________________________________________
96AliMUONTrack::AliMUONTrack(AliMUONSegment* Segment, AliMUONHitForRec* HitForRec, AliMUONEventReconstructor* EventReconstructor)
30178c30 97 : TObject()
a9e2aefa 98{
99 // Constructor from one Segment and one HitForRec
100 fEventReconstructor = EventReconstructor; // link back to EventReconstructor
8429a5e4 101 // memory allocation for the TObjArray of pointers to reconstructed TrackHit's
102 fTrackHitsPtr = new TObjArray(10);
a9e2aefa 103 fNTrackHits = 0;
104 AddSegment(Segment); // add hits from Segment
105 AddHitForRec(HitForRec); // add HitForRec
106 fTrackHitsPtr->Sort(); // sort TrackHits according to increasing Z
107 SetTrackParamAtVertex(); // set track parameters at vertex
d837040f 108 fTrackParamAtHit = new TClonesArray("AliMUONTrackParam",10);
b8dc484b 109 fHitForRecAtHit = new TClonesArray("AliMUONHitForRec",10);
8429a5e4 110 // set fit conditions...
04b5ea16 111 fFitMCS = 0;
956019b6 112 fFitNParam = 3;
113 fFitStart = 1;
8429a5e4 114 fFitFMin = -1.0;
d837040f 115 fMatchTrigger = kFALSE;
116 fChi2MatchTrigger = 0;
b8dc484b 117 fTrackID = 0;
a9e2aefa 118 return;
119}
120
8429a5e4 121 //__________________________________________________________________________
122AliMUONTrack::~AliMUONTrack()
123{
124 // Destructor
125 if (fTrackHitsPtr) {
29fc2c86 126 fTrackHitsPtr->Clear();
8429a5e4 127 delete fTrackHitsPtr; // delete the TObjArray of pointers to TrackHit's
128 fTrackHitsPtr = NULL;
129 }
d837040f 130
131 if (fTrackParamAtHit) {
132 // delete the TClonesArray of pointers to TrackParam
29fc2c86 133 fTrackParamAtHit->Clear();
d837040f 134 delete fTrackParamAtHit;
135 fTrackParamAtHit = NULL;
136 }
b8dc484b 137
138 if (fHitForRecAtHit) {
139 // delete the TClonesArray of pointers to HitForRec
29fc2c86 140 fHitForRecAtHit->Clear();
b8dc484b 141 delete fHitForRecAtHit;
142 fHitForRecAtHit = NULL;
143 }
8429a5e4 144}
145
956019b6 146 //__________________________________________________________________________
30178c30 147AliMUONTrack::AliMUONTrack (const AliMUONTrack& theMUONTrack)
148 : TObject(theMUONTrack)
a9e2aefa 149{
30178c30 150 //fEventReconstructor = new AliMUONEventReconstructor(*MUONTrack.fEventReconstructor);
151 // is it right ?
152 // NO, because it would use dummy copy constructor
153 // and AliMUONTrack is not the owner of its EventReconstructor
154 fEventReconstructor = theMUONTrack.fEventReconstructor;
155 fTrackParamAtVertex = theMUONTrack.fTrackParamAtVertex;
e516b01d 156
157 // necessary to make a copy of the objects and not only the pointers in TObjArray.
158 fTrackHitsPtr = new TObjArray(10);
159 for (Int_t index = 0; index < (theMUONTrack.fTrackHitsPtr)->GetEntriesFast(); index++) {
160 AliMUONTrackHit *trackHit = new AliMUONTrackHit(*(AliMUONTrackHit*)(theMUONTrack.fTrackHitsPtr)->At(index));
161 fTrackHitsPtr->Add(trackHit);
162 }
163
164 // necessary to make a copy of the objects and not only the pointers in TClonesArray.
165 fTrackParamAtHit = new TClonesArray("AliMUONTrackParam",10);
166 for (Int_t index = 0; index < (theMUONTrack.fTrackParamAtHit)->GetEntriesFast(); index++) {
167 {new ((*fTrackParamAtHit)[fTrackParamAtHit->GetEntriesFast()])
168 AliMUONTrackParam(*(AliMUONTrackParam*)(theMUONTrack.fTrackParamAtHit)->At(index));}
169 }
170
b8dc484b 171 // necessary to make a copy of the objects and not only the pointers in TClonesArray.
172 fHitForRecAtHit = new TClonesArray("AliMUONHitForRec",10);
173 for (Int_t index = 0; index < (theMUONTrack.fHitForRecAtHit)->GetEntriesFast(); index++) {
174 {new ((*fHitForRecAtHit)[fHitForRecAtHit->GetEntriesFast()])
175 AliMUONHitForRec(*(AliMUONHitForRec*)(theMUONTrack.fHitForRecAtHit)->At(index));}
176 }
177
30178c30 178 fNTrackHits = theMUONTrack.fNTrackHits;
179 fFitMCS = theMUONTrack.fFitMCS;
180 fFitNParam = theMUONTrack.fFitNParam;
181 fFitFMin = theMUONTrack.fFitFMin;
182 fFitStart = theMUONTrack.fFitStart;
183 fMatchTrigger = theMUONTrack.fMatchTrigger;
184 fChi2MatchTrigger = theMUONTrack.fChi2MatchTrigger;
b8dc484b 185 fTrackID = theMUONTrack.fTrackID;
a9e2aefa 186}
187
956019b6 188 //__________________________________________________________________________
30178c30 189AliMUONTrack & AliMUONTrack::operator=(const AliMUONTrack& theMUONTrack)
a9e2aefa 190{
30178c30 191
192 // check assignement to self
193 if (this == &theMUONTrack)
a9e2aefa 194 return *this;
61adb9bd 195
30178c30 196 // base class assignement
197 TObject::operator=(theMUONTrack);
198
199 // fEventReconstructor = new AliMUONEventReconstructor(*MUONTrack.fEventReconstructor); // is it right ?
200 // is it right ? NO because it would use dummy copy constructor
201 fEventReconstructor = theMUONTrack.fEventReconstructor;
202 fTrackParamAtVertex = theMUONTrack.fTrackParamAtVertex;
e516b01d 203
204 // necessary to make a copy of the objects and not only the pointers in TObjArray.
205 fTrackHitsPtr = new TObjArray(10);
206 for (Int_t index = 0; index < (theMUONTrack.fTrackHitsPtr)->GetEntriesFast(); index++) {
207 AliMUONTrackHit *trackHit = new AliMUONTrackHit(*(AliMUONTrackHit*)(theMUONTrack.fTrackHitsPtr)->At(index));
208 fTrackHitsPtr->Add(trackHit);
209 }
210
211 // necessary to make a copy of the objects and not only the pointers in TClonesArray.
212 fTrackParamAtHit = new TClonesArray("AliMUONTrackParam",10);
213 for (Int_t index = 0; index < (theMUONTrack.fTrackParamAtHit)->GetEntriesFast(); index++) {
214 {new ((*fTrackParamAtHit)[fTrackParamAtHit->GetEntriesFast()])
215 AliMUONTrackParam(*(AliMUONTrackParam*)(theMUONTrack.fTrackParamAtHit)->At(index));}
216 }
217
b8dc484b 218 // necessary to make a copy of the objects and not only the pointers in TClonesArray.
219 fHitForRecAtHit = new TClonesArray("AliMUONHitForRec",10);
220 for (Int_t index = 0; index < (theMUONTrack.fHitForRecAtHit)->GetEntriesFast(); index++) {
221 {new ((*fHitForRecAtHit)[fHitForRecAtHit->GetEntriesFast()])
222 AliMUONHitForRec(*(AliMUONHitForRec*)(theMUONTrack.fHitForRecAtHit)->At(index));}
223 }
224
30178c30 225 fNTrackHits = theMUONTrack.fNTrackHits;
226 fFitMCS = theMUONTrack.fFitMCS;
227 fFitNParam = theMUONTrack.fFitNParam;
228 fFitFMin = theMUONTrack.fFitFMin;
229 fFitStart = theMUONTrack.fFitStart;
230 fMatchTrigger = theMUONTrack.fMatchTrigger;
231 fChi2MatchTrigger = theMUONTrack.fChi2MatchTrigger;
b8dc484b 232 fTrackID = theMUONTrack.fTrackID;
30178c30 233
61adb9bd 234 return *this;
a9e2aefa 235}
236
8429a5e4 237 //__________________________________________________________________________
238void AliMUONTrack::Remove()
239{
240 // Remove current track from array of tracks,
241 // and corresponding track hits from array of track hits.
242 // Compress the TClonesArray it belongs to.
243 AliMUONTrackHit *nextTrackHit;
244 AliMUONEventReconstructor *eventRec = this->fEventReconstructor;
245 TClonesArray *trackHitsPtr = eventRec->GetRecTrackHitsPtr();
246 // Loop over all track hits of track
247 AliMUONTrackHit *trackHit = (AliMUONTrackHit*) fTrackHitsPtr->First();
248 while (trackHit) {
249 nextTrackHit = (AliMUONTrackHit*) fTrackHitsPtr->After(trackHit);
250 // Remove TrackHit from event TClonesArray.
251 // Destructor is called,
252 // hence links between HitForRec's and TrackHit's are updated
253 trackHitsPtr->Remove(trackHit);
254 trackHit = nextTrackHit;
255 }
256 // Remove the track from event TClonesArray
257 // Destructor is called,
258 // hence space for TObjArray of pointers to TrackHit's is freed
259 eventRec->GetRecTracksPtr()->Remove(this);
260 // Number of tracks decreased by 1
261 eventRec->SetNRecTracks(eventRec->GetNRecTracks() - 1);
262 // Compress event TClonesArray of Track's:
263 // this is essential to retrieve the TClonesArray afterwards
264 eventRec->GetRecTracksPtr()->Compress();
265 // Compress event TClonesArray of TrackHit's:
266 // this is probably also essential to retrieve the TClonesArray afterwards
267 trackHitsPtr->Compress();
268}
269
04b5ea16 270 //__________________________________________________________________________
271void AliMUONTrack::SetFitMCS(Int_t FitMCS)
272{
956019b6 273 // Set multiple Coulomb scattering option for track fit "fFitMCS"
04b5ea16 274 // from "FitMCS" argument: 0 without, 1 with
956019b6 275 if ((FitMCS == 0) || (FitMCS == 1)) fFitMCS = FitMCS;
04b5ea16 276 // better implementation with enum(with, without) ????
956019b6 277 else {
278 cout << "ERROR in AliMUONTrack::SetFitMCS(FitMCS)" << endl;
279 cout << "FitMCS = " << FitMCS << " is neither 0 nor 1" << endl;
280 exit(0);
281 }
282 return;
283}
284
285 //__________________________________________________________________________
286void AliMUONTrack::SetFitNParam(Int_t FitNParam)
287{
288 // Set number of parameters for track fit "fFitNParam" from "FitNParam":
289 // 3 for momentum, 5 for momentum and position
290 if ((FitNParam == 3) || (FitNParam == 5)) fFitNParam = FitNParam;
291 else {
292 cout << "ERROR in AliMUONTrack::SetFitNParam(FitNParam)" << endl;
293 cout << "FitNParam = " << FitNParam << " is neither 3 nor 5" << endl;
294 exit(0);
295 }
296 return;
297}
298
299 //__________________________________________________________________________
300void AliMUONTrack::SetFitStart(Int_t FitStart)
301{
302 // Set multiple Coulomb scattering option for track fit "fFitStart"
303 // from "FitStart" argument: 0 without, 1 with
304 if ((FitStart == 0) || (FitStart == 1)) fFitStart = FitStart;
305 // better implementation with enum(vertex, firstHit) ????
306 else {
307 cout << "ERROR in AliMUONTrack::SetFitStart(FitStart)" << endl;
308 cout << "FitStart = " << FitStart << " is neither 0 nor 1" << endl;
309 exit(0);
310 }
04b5ea16 311 return;
312}
313
956019b6 314 //__________________________________________________________________________
3831f268 315AliMUONTrackParam* AliMUONTrack::GetTrackParamAtFirstHit(void) const {
a9e2aefa 316 // Get pointer to TrackParamAtFirstHit
317 return ((AliMUONTrackHit*) (fTrackHitsPtr->First()))->GetTrackParam();}
a9e2aefa 318
319 //__________________________________________________________________________
3831f268 320void AliMUONTrack::RecursiveDump(void) const
a9e2aefa 321{
322 // Recursive dump of AliMUONTrack, i.e. with dump of TrackHit's and HitForRec's
323 AliMUONTrackHit *trackHit;
324 AliMUONHitForRec *hitForRec;
325 cout << "Recursive dump of Track: " << this << endl;
326 // Track
327 this->Dump();
328 for (Int_t trackHitIndex = 0; trackHitIndex < fNTrackHits; trackHitIndex++) {
329 trackHit = (AliMUONTrackHit*) ((*fTrackHitsPtr)[trackHitIndex]);
330 // TrackHit
331 cout << "TrackHit: " << trackHit << " (index: " << trackHitIndex << ")" << endl;
332 trackHit->Dump();
333 hitForRec = trackHit->GetHitForRecPtr();
334 // HitForRec
335 cout << "HitForRec: " << hitForRec << endl;
336 hitForRec->Dump();
337 }
338 return;
339}
b8dc484b 340
341 //__________________________________________________________________________
342Bool_t* AliMUONTrack::CompatibleTrack(AliMUONTrack * Track, Double_t Sigma2Cut) const
343{
344 // Return kTRUE/kFALSE for each chamber if hit is compatible or not
345 TClonesArray *hitArray, *thisHitArray;
346 AliMUONHitForRec *hit, *thisHit;
347 Int_t chamberNumber;
348 Float_t deltaZ;
349 Float_t deltaZMax = 1.; // 1 cm
350 Float_t chi2 = 0;
351 Bool_t *nCompHit = new Bool_t[AliMUONConstants::NTrackingCh()];
352
353 for ( Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ch++) {
354 nCompHit[ch] = kFALSE;
355 }
356
357 thisHitArray = this->GetHitForRecAtHit();
358
359 hitArray = Track->GetHitForRecAtHit();
360
361 for (Int_t iHthis = 0; iHthis < thisHitArray->GetEntriesFast(); iHthis++) {
362 thisHit = (AliMUONHitForRec*) thisHitArray->At(iHthis);
363 chamberNumber = thisHit->GetChamberNumber();
364 if (chamberNumber < 0 || chamberNumber > AliMUONConstants::NTrackingCh()) continue;
365 nCompHit[chamberNumber] = kFALSE;
366 for (Int_t iH = 0; iH < hitArray->GetEntriesFast(); iH++) {
367 hit = (AliMUONHitForRec*) hitArray->At(iH);
368 deltaZ = TMath::Abs(thisHit->GetZ() - hit->GetZ());
369 chi2 = thisHit->NormalizedChi2WithHitForRec(hit,Sigma2Cut); // set cut to 4 sigmas
370 if (chi2 < 3. && deltaZ < deltaZMax) {
371 nCompHit[chamberNumber] = kTRUE;
372 break;
373 }
374 }
375 }
376
377 return nCompHit;
378}
a9e2aefa 379
8429a5e4 380 //__________________________________________________________________________
30178c30 381Int_t AliMUONTrack::HitsInCommon(AliMUONTrack* Track) const
8429a5e4 382{
383 // Returns the number of hits in common
384 // between the current track ("this")
385 // and the track pointed to by "Track".
386 Int_t hitsInCommon = 0;
387 AliMUONTrackHit *trackHit1, *trackHit2;
388 // Loop over hits of first track
389 trackHit1 = (AliMUONTrackHit*) this->GetTrackHitsPtr()->First();
390 while (trackHit1) {
391 // Loop over hits of second track
392 trackHit2 = (AliMUONTrackHit*) Track->GetTrackHitsPtr()->First();
393 while (trackHit2) {
394 // Increment "hitsInCommon" if both TrackHits point to the same HitForRec
395 if ( (trackHit1->GetHitForRecPtr()) ==
396 (trackHit2->GetHitForRecPtr()) ) hitsInCommon++;
397 trackHit2 = (AliMUONTrackHit*) Track->GetTrackHitsPtr()->After(trackHit2);
398 } // trackHit2
399 trackHit1 = (AliMUONTrackHit*) this->GetTrackHitsPtr()->After(trackHit1);
400 } // trackHit1
401 return hitsInCommon;
402}
403
d837040f 404 //__________________________________________________________________________
405void AliMUONTrack::MatchTriggerTrack(TClonesArray *triggerTrackArray)
406{
407 // Match this track with one trigger track if possible
2c3dd8cd 408 AliMUONTrackParam trackParam;
d837040f 409 AliMUONTriggerTrack *triggerTrack;
410 Double_t xTrack, yTrack, ySlopeTrack, dTrigTrackMin2, dTrigTrack2;
411 Double_t nSigmaCut2;
412
413 Double_t distSigma[3]={1,1,0.02}; // sigma of distributions (trigger-track) X,Y,slopeY
414 Double_t distTriggerTrack[3] = {0,0,0};
415
416 fMatchTrigger = kFALSE;
417 fChi2MatchTrigger = 0;
418
2c3dd8cd 419 trackParam = *((AliMUONTrackParam*) fTrackParamAtHit->Last());
420 trackParam.ExtrapToZ(AliMUONConstants::DefaultChamberZ(10)); // extrap to 1st trigger chamber
d837040f 421
422 nSigmaCut2 = fEventReconstructor->GetMaxSigma2Distance(); // nb of sigma**2 for cut
2c3dd8cd 423 xTrack = trackParam.GetNonBendingCoor();
424 yTrack = trackParam.GetBendingCoor();
425 ySlopeTrack = trackParam.GetBendingSlope();
d837040f 426 dTrigTrackMin2 = 999;
427
428 triggerTrack = (AliMUONTriggerTrack*) triggerTrackArray->First();
429 while(triggerTrack){
430 distTriggerTrack[0] = (triggerTrack->GetX11()-xTrack)/distSigma[0];
431 distTriggerTrack[1] = (triggerTrack->GetY11()-yTrack)/distSigma[1];
432 distTriggerTrack[2] = (TMath::Tan(triggerTrack->GetThetay())-ySlopeTrack)/distSigma[2];
433 dTrigTrack2 = 0;
434 for (Int_t iVar = 0; iVar < 3; iVar++)
435 dTrigTrack2 += distTriggerTrack[iVar]*distTriggerTrack[iVar];
436 if (dTrigTrack2 < dTrigTrackMin2 && dTrigTrack2 < nSigmaCut2) {
437 dTrigTrackMin2 = dTrigTrack2;
438 fMatchTrigger = kTRUE;
439 fChi2MatchTrigger = dTrigTrack2/3.; // Normalized Chi2, 3 variables (X,Y,slopeY)
440 }
441 triggerTrack = (AliMUONTriggerTrack*) triggerTrackArray->After(triggerTrack);
442 }
443
444}
a9e2aefa 445 //__________________________________________________________________________
956019b6 446void AliMUONTrack::Fit()
a9e2aefa 447{
448 // Fit the current track ("this"),
956019b6 449 // with or without multiple Coulomb scattering according to "fFitMCS",
450 // with the number of parameters given by "fFitNParam"
451 // (3 if one keeps X and Y fixed in "TrackParam", 5 if one lets them vary),
452 // starting, according to "fFitStart",
453 // with track parameters at vertex or at the first TrackHit.
454 // "fFitMCS", "fFitNParam" and "fFitStart" have to be set before
455 // by calling the corresponding Set methods.
a9e2aefa 456 Double_t arg[1], benC, errorParam, invBenP, lower, nonBenC, upper, x, y;
956019b6 457 char parName[50];
458 AliMUONTrackParam *trackParam;
459 // Check if Minuit is initialized...
460 fgFitter = TVirtualFitter::Fitter(this); // add 3 or 5 for the maximum number of parameters ???
461 fgFitter->Clear(); // necessary ???? probably yes
462 // how to reset the printout number at every fit ????
463 // is there any risk to leave it like that ????
a9e2aefa 464 // how to go faster ???? choice of Minuit parameters like EDM ????
04b5ea16 465 // choice of function to be minimized according to fFitMCS
956019b6 466 if (fFitMCS == 0) fgFitter->SetFCN(TrackChi2);
467 else fgFitter->SetFCN(TrackChi2MCS);
3a416225 468 // Switch off printout
d0bfce8d 469 arg[0] = -1;
956019b6 470 fgFitter->ExecuteCommand("SET PRINT", arg, 1); // More printing !!!!
19dd5b2f 471 // No warnings
472 fgFitter->ExecuteCommand("SET NOW", arg, 0);
956019b6 473 // Parameters according to "fFitStart"
474 // (should be a function to be used at every place where needed ????)
475 if (fFitStart == 0) trackParam = &fTrackParamAtVertex;
476 else trackParam = this->GetTrackParamAtFirstHit();
477 // set first 3 Minuit parameters
04b5ea16 478 // could be tried with no limits for the search (min=max=0) ????
956019b6 479 fgFitter->SetParameter(0, "InvBenP",
480 trackParam->GetInverseBendingMomentum(),
481 0.003, -0.4, 0.4);
482 fgFitter->SetParameter(1, "BenS",
483 trackParam->GetBendingSlope(),
484 0.001, -0.5, 0.5);
485 fgFitter->SetParameter(2, "NonBenS",
486 trackParam->GetNonBendingSlope(),
487 0.001, -0.5, 0.5);
488 if (fFitNParam == 5) {
d0bfce8d 489 // set last 2 Minuit parameters
490 // mandatory limits in Bending to avoid NaN values of parameters
956019b6 491 fgFitter->SetParameter(3, "X",
492 trackParam->GetNonBendingCoor(),
d0bfce8d 493 0.03, -500.0, 500.0);
494 // mandatory limits in non Bending to avoid NaN values of parameters
956019b6 495 fgFitter->SetParameter(4, "Y",
496 trackParam->GetBendingCoor(),
d0bfce8d 497 0.10, -500.0, 500.0);
a9e2aefa 498 }
499 // search without gradient calculation in the function
956019b6 500 fgFitter->ExecuteCommand("SET NOGRADIENT", arg, 0);
a9e2aefa 501 // minimization
956019b6 502 fgFitter->ExecuteCommand("MINIMIZE", arg, 0);
a9e2aefa 503 // exit from Minuit
17235410 504 // fgFitter->ExecuteCommand("EXIT", arg, 0); // necessary ????
956019b6 505 // get results into "invBenP", "benC", "nonBenC" ("x", "y")
506 fgFitter->GetParameter(0, parName, invBenP, errorParam, lower, upper);
507 fgFitter->GetParameter(1, parName, benC, errorParam, lower, upper);
508 fgFitter->GetParameter(2, parName, nonBenC, errorParam, lower, upper);
509 if (fFitNParam == 5) {
510 fgFitter->GetParameter(3, parName, x, errorParam, lower, upper);
511 fgFitter->GetParameter(4, parName, y, errorParam, lower, upper);
a9e2aefa 512 }
513 // result of the fit into track parameters
956019b6 514 trackParam->SetInverseBendingMomentum(invBenP);
515 trackParam->SetBendingSlope(benC);
516 trackParam->SetNonBendingSlope(nonBenC);
517 if (fFitNParam == 5) {
518 trackParam->SetNonBendingCoor(x);
519 trackParam->SetBendingCoor(y);
a9e2aefa 520 }
8429a5e4 521 // global result of the fit
522 Double_t fedm, errdef;
523 Int_t npari, nparx;
524 fgFitter->GetStats(fFitFMin, fedm, errdef, npari, nparx);
a9e2aefa 525}
526
527 //__________________________________________________________________________
528void AliMUONTrack::AddSegment(AliMUONSegment* Segment)
529{
8429a5e4 530 // Add Segment to the track
a9e2aefa 531 AddHitForRec(Segment->GetHitForRec1()); // 1st hit
532 AddHitForRec(Segment->GetHitForRec2()); // 2nd hit
533}
534
535 //__________________________________________________________________________
536void AliMUONTrack::AddHitForRec(AliMUONHitForRec* HitForRec)
537{
8429a5e4 538 // Add HitForRec to the track:
539 // actual TrackHit into TClonesArray of TrackHit's for the event;
540 // pointer to actual TrackHit in TObjArray of pointers to TrackHit's for the track
541 TClonesArray *recTrackHitsPtr = this->fEventReconstructor->GetRecTrackHitsPtr();
542 Int_t eventTrackHits = this->fEventReconstructor->GetNRecTrackHits();
543 // event
544 AliMUONTrackHit* trackHit =
545 new ((*recTrackHitsPtr)[eventTrackHits]) AliMUONTrackHit(HitForRec);
546 this->fEventReconstructor->SetNRecTrackHits(eventTrackHits + 1);
547 // track
548 fTrackHitsPtr->Add(trackHit);
a9e2aefa 549 fNTrackHits++;
550}
551
552 //__________________________________________________________________________
3831f268 553void AliMUONTrack::SetTrackParamAtHit(Int_t indexHit, AliMUONTrackParam *TrackParam) const
a9e2aefa 554{
555 // Set track parameters at TrackHit with index "indexHit"
556 // from the track parameters pointed to by "TrackParam".
2682e810 557 //PH AliMUONTrackHit* trackHit = (AliMUONTrackHit*) ((*fTrackHitsPtr)[indexHit]);
558 AliMUONTrackHit* trackHit = (AliMUONTrackHit*) (fTrackHitsPtr->At(indexHit));
a9e2aefa 559 trackHit->SetTrackParam(TrackParam);
560}
561
562 //__________________________________________________________________________
563void AliMUONTrack::SetTrackParamAtVertex()
564{
565 // Set track parameters at vertex.
566 // TrackHit's are assumed to be only in stations(1..) 4 and 5,
567 // and sorted according to increasing Z..
568 // Parameters are calculated from information in HitForRec's
569 // of first and last TrackHit's.
570 AliMUONTrackParam *trackParam =
571 &fTrackParamAtVertex; // pointer to track parameters
572 // Pointer to HitForRec of first TrackHit
573 AliMUONHitForRec *firstHit =
574 ((AliMUONTrackHit*) (fTrackHitsPtr->First()))->GetHitForRecPtr();
575 // Pointer to HitForRec of last TrackHit
576 AliMUONHitForRec *lastHit =
577 ((AliMUONTrackHit*) (fTrackHitsPtr->Last()))->GetHitForRecPtr();
578 // Z difference between first and last hits
579 Double_t deltaZ = firstHit->GetZ() - lastHit->GetZ();
580 // bending slope in stations(1..) 4 and 5
581 Double_t bendingSlope =
582 (firstHit->GetBendingCoor() - lastHit->GetBendingCoor()) / deltaZ;
583 trackParam->SetBendingSlope(bendingSlope);
584 // impact parameter
585 Double_t impactParam =
586 firstHit->GetBendingCoor() - bendingSlope * firstHit->GetZ(); // same if from firstHit and lastHit ????
587 // signed bending momentum
588 Double_t signedBendingMomentum =
589 fEventReconstructor->GetBendingMomentumFromImpactParam(impactParam);
590 trackParam->SetInverseBendingMomentum(1.0 / signedBendingMomentum);
591 // bending slope at vertex
592 trackParam->
593 SetBendingSlope(bendingSlope +
594 impactParam / fEventReconstructor->GetSimpleBPosition());
595 // non bending slope
596 Double_t nonBendingSlope =
597 (firstHit->GetNonBendingCoor() - lastHit->GetNonBendingCoor()) / deltaZ;
598 trackParam->SetNonBendingSlope(nonBendingSlope);
599 // vertex coordinates at (0,0,0)
600 trackParam->SetZ(0.0);
601 trackParam->SetBendingCoor(0.0);
602 trackParam->SetNonBendingCoor(0.0);
603}
604
605 //__________________________________________________________________________
d9a3473d 606void TrackChi2(Int_t &NParam, Double_t * /*Gradient*/, Double_t &Chi2, Double_t *Param, Int_t /*Flag*/)
a9e2aefa 607{
608 // Return the "Chi2" to be minimized with Minuit for track fitting,
609 // with "NParam" parameters
610 // and their current values in array pointed to by "Param".
611 // Assumes that the track hits are sorted according to increasing Z.
612 // Track parameters at each TrackHit are updated accordingly.
04b5ea16 613 // Multiple Coulomb scattering is not taken into account
956019b6 614 AliMUONTrack *trackBeingFitted;
a9e2aefa 615 AliMUONTrackHit* hit;
616 AliMUONTrackParam param1;
617 Int_t hitNumber;
618 Double_t zHit;
619 Chi2 = 0.0; // initialize Chi2
620 // copy of track parameters to be fitted
956019b6 621 trackBeingFitted = (AliMUONTrack*) AliMUONTrack::Fitter()->GetObjectFit();
622 if (trackBeingFitted->GetFitStart() == 0)
623 param1 = *(trackBeingFitted->GetTrackParamAtVertex());
624 else param1 = *(trackBeingFitted->GetTrackParamAtFirstHit());
a9e2aefa 625 // Minuit parameters to be fitted into this copy
626 param1.SetInverseBendingMomentum(Param[0]);
627 param1.SetBendingSlope(Param[1]);
628 param1.SetNonBendingSlope(Param[2]);
629 if (NParam == 5) {
630 param1.SetNonBendingCoor(Param[3]);
631 param1.SetBendingCoor(Param[4]);
632 }
633 // Follow track through all planes of track hits
634 for (hitNumber = 0; hitNumber < trackBeingFitted->GetNTrackHits(); hitNumber++) {
635 hit = (AliMUONTrackHit*) (*(trackBeingFitted->GetTrackHitsPtr()))[hitNumber];
636 zHit = hit->GetHitForRecPtr()->GetZ();
637 // do something special if 2 hits with same Z ????
638 // security against infinite loop ????
639 (&param1)->ExtrapToZ(zHit); // extrapolation
640 hit->SetTrackParam(&param1);
641 // Increment Chi2
642 // done hit per hit, with hit resolution,
643 // and not with point and angle like in "reco_muon.F" !!!!
644 // Needs to add multiple scattering contribution ????
645 Double_t dX =
646 hit->GetHitForRecPtr()->GetNonBendingCoor() - (&param1)->GetNonBendingCoor();
647 Double_t dY =
648 hit->GetHitForRecPtr()->GetBendingCoor() - (&param1)->GetBendingCoor();
649 Chi2 =
650 Chi2 +
651 dX * dX / hit->GetHitForRecPtr()->GetNonBendingReso2() +
652 dY * dY / hit->GetHitForRecPtr()->GetBendingReso2();
653 }
654}
04b5ea16 655
656 //__________________________________________________________________________
d9a3473d 657void TrackChi2MCS(Int_t &NParam, Double_t * /*Gradient*/, Double_t &Chi2, Double_t *Param, Int_t /*Flag*/)
04b5ea16 658{
659 // Return the "Chi2" to be minimized with Minuit for track fitting,
660 // with "NParam" parameters
661 // and their current values in array pointed to by "Param".
662 // Assumes that the track hits are sorted according to increasing Z.
663 // Track parameters at each TrackHit are updated accordingly.
664 // Multiple Coulomb scattering is taken into account with covariance matrix.
956019b6 665 AliMUONTrack *trackBeingFitted;
04b5ea16 666 AliMUONTrackParam param1;
667 Chi2 = 0.0; // initialize Chi2
668 // copy of track parameters to be fitted
956019b6 669 trackBeingFitted = (AliMUONTrack*) AliMUONTrack::Fitter()->GetObjectFit();
670 if (trackBeingFitted->GetFitStart() == 0)
671 param1 = *(trackBeingFitted->GetTrackParamAtVertex());
672 else param1 = *(trackBeingFitted->GetTrackParamAtFirstHit());
04b5ea16 673 // Minuit parameters to be fitted into this copy
674 param1.SetInverseBendingMomentum(Param[0]);
675 param1.SetBendingSlope(Param[1]);
676 param1.SetNonBendingSlope(Param[2]);
677 if (NParam == 5) {
678 param1.SetNonBendingCoor(Param[3]);
679 param1.SetBendingCoor(Param[4]);
680 }
681
956019b6 682 AliMUONTrackHit *hit;
bbe35c23 683 Int_t chCurrent, chPrev = 0, hitNumber, hitNumber1, hitNumber2, hitNumber3;
eb9c9dab 684 Double_t z, z1, z2, z3;
685 AliMUONTrackHit *hit1, *hit2, *hit3;
686 Double_t hbc1, hbc2, pbc1, pbc2;
687 Double_t hnbc1, hnbc2, pnbc1, pnbc2;
688 Int_t numberOfHit = trackBeingFitted->GetNTrackHits();
d0bfce8d 689 TMatrixD *covBending = new TMatrixD(numberOfHit, numberOfHit);
690 TMatrixD *covNonBending = new TMatrixD(numberOfHit, numberOfHit);
eb9c9dab 691 Double_t *msa2 = new Double_t[numberOfHit];
04b5ea16 692
693 // Predicted coordinates and multiple scattering angles are first calculated
694 for (hitNumber = 0; hitNumber < numberOfHit; hitNumber++) {
695 hit = (AliMUONTrackHit*) (*(trackBeingFitted->GetTrackHitsPtr()))[hitNumber];
eb9c9dab 696 z = hit->GetHitForRecPtr()->GetZ();
04b5ea16 697 // do something special if 2 hits with same Z ????
698 // security against infinite loop ????
eb9c9dab 699 (&param1)->ExtrapToZ(z); // extrapolation
04b5ea16 700 hit->SetTrackParam(&param1);
eb9c9dab 701 // square of multiple scattering angle at current hit, with one chamber
702 msa2[hitNumber] = MultipleScatteringAngle2(hit);
703 // correction for eventual missing hits or multiple hits in a chamber,
704 // according to the number of chambers
705 // between the current hit and the previous one
706 chCurrent = hit->GetHitForRecPtr()->GetChamberNumber();
707 if (hitNumber > 0) msa2[hitNumber] = msa2[hitNumber] * (chCurrent - chPrev);
708 chPrev = chCurrent;
04b5ea16 709 }
710
711 // Calculates the covariance matrix
eb9c9dab 712 for (hitNumber1 = 0; hitNumber1 < numberOfHit; hitNumber1++) {
713 hit1 = (AliMUONTrackHit*) (*(trackBeingFitted->GetTrackHitsPtr()))[hitNumber1];
714 z1 = hit1->GetHitForRecPtr()->GetZ();
04b5ea16 715 for (hitNumber2 = hitNumber1; hitNumber2 < numberOfHit; hitNumber2++) {
eb9c9dab 716 hit2 = (AliMUONTrackHit*) (*(trackBeingFitted->GetTrackHitsPtr()))[hitNumber2];
717 z2 = hit2->GetHitForRecPtr()->GetZ();
956019b6 718 // initialization to 0 (diagonal plus upper triangular part)
719 (*covBending)(hitNumber2, hitNumber1) = 0.0;
720 // contribution from multiple scattering in bending plane:
721 // loop over upstream hits
722 for (hitNumber3 = 0; hitNumber3 < hitNumber1; hitNumber3++) {
eb9c9dab 723 hit3 = (AliMUONTrackHit*)
724 (*(trackBeingFitted->GetTrackHitsPtr()))[hitNumber3];
725 z3 = hit3->GetHitForRecPtr()->GetZ();
04b5ea16 726 (*covBending)(hitNumber2, hitNumber1) =
727 (*covBending)(hitNumber2, hitNumber1) +
eb9c9dab 728 ((z1 - z3) * (z2 - z3) * msa2[hitNumber3]);
956019b6 729 }
730 // equal contribution from multiple scattering in non bending plane
04b5ea16 731 (*covNonBending)(hitNumber2, hitNumber1) =
732 (*covBending)(hitNumber2, hitNumber1);
956019b6 733 if (hitNumber1 == hitNumber2) {
734 // Diagonal elements: add contribution from position measurements
735 // in bending plane
736 (*covBending)(hitNumber2, hitNumber1) =
eb9c9dab 737 (*covBending)(hitNumber2, hitNumber1) +
738 hit1->GetHitForRecPtr()->GetBendingReso2();
956019b6 739 // and in non bending plane
04b5ea16 740 (*covNonBending)(hitNumber2, hitNumber1) =
eb9c9dab 741 (*covNonBending)(hitNumber2, hitNumber1) +
742 hit1->GetHitForRecPtr()->GetNonBendingReso2();
956019b6 743 }
744 else {
745 // Non diagonal elements: symmetrization
746 // for bending plane
747 (*covBending)(hitNumber1, hitNumber2) =
748 (*covBending)(hitNumber2, hitNumber1);
749 // and non bending plane
750 (*covNonBending)(hitNumber1, hitNumber2) =
751 (*covNonBending)(hitNumber2, hitNumber1);
752 }
753 } // for (hitNumber2 = hitNumber1;...
754 } // for (hitNumber1 = 0;...
d0bfce8d 755
44f59652 756 // Inversion of covariance matrices
757 // with "mnvertLocal", local "mnvert" function of Minuit.
758 // One cannot use directly "mnvert" since "TVirtualFitter" does not know it.
759 // One will have to replace this local function by the right inversion function
760 // from a specialized Root package for symmetric positive definite matrices,
761 // when available!!!!
762 Int_t ifailBending;
763 mnvertLocal(&((*covBending)(0,0)), numberOfHit, numberOfHit, numberOfHit,
764 ifailBending);
765 Int_t ifailNonBending;
766 mnvertLocal(&((*covNonBending)(0,0)), numberOfHit, numberOfHit, numberOfHit,
767 ifailNonBending);
956019b6 768
769 // It would be worth trying to calculate the inverse of the covariance matrix
770 // only once per fit, since it cannot change much in principle,
771 // and it would save a lot of computing time !!!!
04b5ea16 772
773 // Calculates Chi2
44f59652 774 if ((ifailBending == 0) && (ifailNonBending == 0)) {
eb9c9dab 775 // with Multiple Scattering if inversion correct
776 for (hitNumber1 = 0; hitNumber1 < numberOfHit ; hitNumber1++) {
777 hit1 = (AliMUONTrackHit*) (*(trackBeingFitted->GetTrackHitsPtr()))[hitNumber1];
778 hbc1 = hit1->GetHitForRecPtr()->GetBendingCoor();
779 pbc1 = hit1->GetTrackParam()->GetBendingCoor();
780 hnbc1 = hit1->GetHitForRecPtr()->GetNonBendingCoor();
781 pnbc1 = hit1->GetTrackParam()->GetNonBendingCoor();
782 for (hitNumber2 = 0; hitNumber2 < numberOfHit; hitNumber2++) {
783 hit2 = (AliMUONTrackHit*)
784 (*(trackBeingFitted->GetTrackHitsPtr()))[hitNumber2];
785 hbc2 = hit2->GetHitForRecPtr()->GetBendingCoor();
786 pbc2 = hit2->GetTrackParam()->GetBendingCoor();
787 hnbc2 = hit2->GetHitForRecPtr()->GetNonBendingCoor();
788 pnbc2 = hit2->GetTrackParam()->GetNonBendingCoor();
04b5ea16 789 Chi2 = Chi2 +
eb9c9dab 790 ((*covBending)(hitNumber2, hitNumber1) *
791 (hbc1 - pbc1) * (hbc2 - pbc2)) +
04b5ea16 792 ((*covNonBending)(hitNumber2, hitNumber1) *
eb9c9dab 793 (hnbc1 - pnbc1) * (hnbc2 - pnbc2));
04b5ea16 794 }
795 }
eb9c9dab 796 } else {
797 // without Multiple Scattering if inversion impossible
798 for (hitNumber1 = 0; hitNumber1 < numberOfHit ; hitNumber1++) {
799 hit1 = (AliMUONTrackHit*) (*(trackBeingFitted->GetTrackHitsPtr()))[hitNumber1];
800 hbc1 = hit1->GetHitForRecPtr()->GetBendingCoor();
801 pbc1 = hit1->GetTrackParam()->GetBendingCoor();
802 hnbc1 = hit1->GetHitForRecPtr()->GetNonBendingCoor();
803 pnbc1 = hit1->GetTrackParam()->GetNonBendingCoor();
804 Chi2 = Chi2 +
805 ((hbc1 - pbc1) * (hbc1 - pbc1) /
806 hit1->GetHitForRecPtr()->GetBendingReso2()) +
807 ((hnbc1 - pnbc1) * (hnbc1 - pnbc1) /
808 hit1->GetHitForRecPtr()->GetNonBendingReso2());
04b5ea16 809 }
810 }
811
812 delete covBending;
813 delete covNonBending;
eb9c9dab 814 delete [] msa2;
04b5ea16 815}
816
817Double_t MultipleScatteringAngle2(AliMUONTrackHit *TrackHit)
818{
819 // Returns square of multiple Coulomb scattering angle
820 // at TrackHit pointed to by "TrackHit"
821 Double_t slopeBending, slopeNonBending, radiationLength, inverseBendingMomentum2, inverseTotalMomentum2;
822 Double_t varMultipleScatteringAngle;
956019b6 823 AliMUONTrack *trackBeingFitted = (AliMUONTrack*) AliMUONTrack::Fitter()->GetObjectFit();
04b5ea16 824 AliMUONTrackParam *param = TrackHit->GetTrackParam();
956019b6 825 // Better implementation in AliMUONTrack class ????
04b5ea16 826 slopeBending = param->GetBendingSlope();
827 slopeNonBending = param->GetNonBendingSlope();
828 // thickness in radiation length for the current track,
829 // taking local angle into account
830 radiationLength =
831 trackBeingFitted->GetEventReconstructor()->GetChamberThicknessInX0() *
832 TMath::Sqrt(1.0 +
833 slopeBending * slopeBending + slopeNonBending * slopeNonBending);
834 inverseBendingMomentum2 =
835 param->GetInverseBendingMomentum() * param->GetInverseBendingMomentum();
836 inverseTotalMomentum2 =
956019b6 837 inverseBendingMomentum2 * (1.0 + slopeBending * slopeBending) /
04b5ea16 838 (1.0 + slopeBending *slopeBending + slopeNonBending * slopeNonBending);
839 varMultipleScatteringAngle = 0.0136 * (1.0 + 0.038 * TMath::Log(radiationLength));
956019b6 840 // The velocity is assumed to be 1 !!!!
04b5ea16 841 varMultipleScatteringAngle = inverseTotalMomentum2 * radiationLength *
842 varMultipleScatteringAngle * varMultipleScatteringAngle;
843 return varMultipleScatteringAngle;
844}
44f59652 845
846//______________________________________________________________________________
847 void mnvertLocal(Double_t *a, Int_t l, Int_t, Int_t n, Int_t &ifail)
848{
849//*-*-*-*-*-*-*-*-*-*-*-*Inverts a symmetric matrix*-*-*-*-*-*-*-*-*-*-*-*-*
850//*-* ==========================
851//*-* inverts a symmetric matrix. matrix is first scaled to
852//*-* have all ones on the diagonal (equivalent to change of units)
853//*-* but no pivoting is done since matrix is positive-definite.
854//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
855
856 // taken from TMinuit package of Root (l>=n)
857 // fVERTs, fVERTq and fVERTpp changed to localVERTs, localVERTq and localVERTpp
e804eb46 858 // Double_t localVERTs[n], localVERTq[n], localVERTpp[n];
859 Double_t * localVERTs = new Double_t[n];
860 Double_t * localVERTq = new Double_t[n];
861 Double_t * localVERTpp = new Double_t[n];
44f59652 862 // fMaxint changed to localMaxint
863 Int_t localMaxint = n;
864
865 /* System generated locals */
3831f268 866 Int_t aOffset;
44f59652 867
868 /* Local variables */
869 Double_t si;
870 Int_t i, j, k, kp1, km1;
871
872 /* Parameter adjustments */
3831f268 873 aOffset = l + 1;
874 a -= aOffset;
44f59652 875
876 /* Function Body */
877 ifail = 0;
878 if (n < 1) goto L100;
879 if (n > localMaxint) goto L100;
880//*-*- scale matrix by sqrt of diag elements
881 for (i = 1; i <= n; ++i) {
882 si = a[i + i*l];
883 if (si <= 0) goto L100;
884 localVERTs[i-1] = 1 / TMath::Sqrt(si);
885 }
886 for (i = 1; i <= n; ++i) {
887 for (j = 1; j <= n; ++j) {
888 a[i + j*l] = a[i + j*l]*localVERTs[i-1]*localVERTs[j-1];
889 }
890 }
891//*-*- . . . start main loop . . . .
892 for (i = 1; i <= n; ++i) {
893 k = i;
894//*-*- preparation for elimination step1
895 if (a[k + k*l] != 0) localVERTq[k-1] = 1 / a[k + k*l];
896 else goto L100;
897 localVERTpp[k-1] = 1;
898 a[k + k*l] = 0;
899 kp1 = k + 1;
900 km1 = k - 1;
901 if (km1 < 0) goto L100;
902 else if (km1 == 0) goto L50;
903 else goto L40;
904L40:
905 for (j = 1; j <= km1; ++j) {
906 localVERTpp[j-1] = a[j + k*l];
907 localVERTq[j-1] = a[j + k*l]*localVERTq[k-1];
908 a[j + k*l] = 0;
909 }
910L50:
911 if (k - n < 0) goto L51;
912 else if (k - n == 0) goto L60;
913 else goto L100;
914L51:
915 for (j = kp1; j <= n; ++j) {
916 localVERTpp[j-1] = a[k + j*l];
917 localVERTq[j-1] = -a[k + j*l]*localVERTq[k-1];
918 a[k + j*l] = 0;
919 }
920//*-*- elimination proper
921L60:
922 for (j = 1; j <= n; ++j) {
923 for (k = j; k <= n; ++k) { a[j + k*l] += localVERTpp[j-1]*localVERTq[k-1]; }
924 }
925 }
926//*-*- elements of left diagonal and unscaling
927 for (j = 1; j <= n; ++j) {
928 for (k = 1; k <= j; ++k) {
929 a[k + j*l] = a[k + j*l]*localVERTs[k-1]*localVERTs[j-1];
930 a[j + k*l] = a[k + j*l];
931 }
932 }
78da3b63 933 delete [] localVERTs;
934 delete [] localVERTq;
935 delete [] localVERTpp;
44f59652 936 return;
937//*-*- failure return
938L100:
78da3b63 939 delete [] localVERTs;
940 delete [] localVERTq;
941 delete [] localVERTpp;
44f59652 942 ifail = 1;
943} /* mnvertLocal */
944