/*
$Log$
+Revision 1.13 2001/05/03 08:11:31 hristov
+stdlib.h included to define exit()
+
+Revision 1.12 2001/04/25 14:50:42 gosset
+Corrections to violations of coding conventions
+
+Revision 1.11 2001/04/23 12:33:17 hristov
+Arrays with variable size created by new and deleted at the end
+
+Revision 1.10 2001/04/09 12:25:09 gosset
+Inversion of covariance matrices with local copy of TMinuit::mnvert,
+for symmetric positive definite matrices, instead of TMatrixD::Invert
+
+Revision 1.9 2001/01/17 20:59:24 hristov
+chPrev initialised
+
+Revision 1.8 2001/01/08 11:01:02 gosset
+Modifications used for addendum to Dimuon TDR (JP Cussonneau):
+*. MaxBendingMomentum to make both a segment and a track (default 500)
+*. MaxChi2 per degree of freedom to make a track (default 100)
+*. MinBendingMomentum used also to make a track
+ and not only a segment (default 3)
+*. wider roads for track search in stations 1 to 3
+*. extrapolation to actual Z instead of Z(chamber) in FollowTracks
+*. in track fit:
+ - limits on parameters X and Y (+/-500)
+ - covariance matrices in double precision
+ - normalization of covariance matrices before inversion
+ - suppression of Minuit printouts
+*. correction against memory leak (delete extrapHit) in FollowTracks
+*. RMax to 10 degrees with Z(chamber) instead of fixed values;
+ RMin and Rmax cuts suppressed in NewHitForRecFromGEANT,
+ because useless with realistic geometry
+
+Revision 1.7 2000/09/19 15:50:46 gosset
+TrackChi2MCS function: covariance matrix better calculated,
+taking into account missing planes...
+
Revision 1.6 2000/07/20 12:45:27 gosset
New "EventReconstructor..." structure,
hopefully more adapted to tree/streamer.
Addition of files for track reconstruction in C++
*/
-//__________________________________________________________________________
+///////////////////////////////////////////////////
//
-// Reconstructed track in ALICE dimuon spectrometer
-//__________________________________________________________________________
-
-#include "AliMUONTrack.h"
+// Reconstructed track
+// in
+// ALICE
+// dimuon
+// spectrometer
+//
+///////////////////////////////////////////////////
-#include <iostream.h>
+#include <iostream.h> // for cout
+#include <stdlib.h> // for exit()
#include <TClonesArray.h>
#include <TMath.h>
-#include <TMatrix.h>
+#include <TMatrixD.h>
#include <TObjArray.h>
#include <TVirtualFitter.h>
#include "AliMUONEventReconstructor.h"
#include "AliMUONHitForRec.h"
#include "AliMUONSegment.h"
+#include "AliMUONTrack.h"
#include "AliMUONTrackHit.h"
-#include <stdlib.h>
-
// Functions to be minimized with Minuit
void TrackChi2(Int_t &NParam, Double_t *Gradient, Double_t &Chi2, Double_t *Param, Int_t Flag);
void TrackChi2MCS(Int_t &NParam, Double_t *Gradient, Double_t &Chi2, Double_t *Param, Int_t Flag);
+void mnvertLocal(Double_t* a, Int_t l, Int_t m, Int_t n, Int_t& ifail);
+
Double_t MultipleScatteringAngle2(AliMUONTrackHit *TrackHit);
ClassImp(AliMUONTrack) // Class implementation in ROOT context
}
//__________________________________________________________________________
-AliMUONTrackParam* AliMUONTrack::GetTrackParamAtFirstHit(void) {
+AliMUONTrackParam* AliMUONTrack::GetTrackParamAtFirstHit(void) const {
// Get pointer to TrackParamAtFirstHit
return ((AliMUONTrackHit*) (fTrackHitsPtr->First()))->GetTrackParam();}
//__________________________________________________________________________
-void AliMUONTrack::RecursiveDump(void)
+void AliMUONTrack::RecursiveDump(void) const
{
// Recursive dump of AliMUONTrack, i.e. with dump of TrackHit's and HitForRec's
AliMUONTrackHit *trackHit;
// choice of function to be minimized according to fFitMCS
if (fFitMCS == 0) fgFitter->SetFCN(TrackChi2);
else fgFitter->SetFCN(TrackChi2MCS);
- arg[0] = 1;
+ arg[0] = -1;
fgFitter->ExecuteCommand("SET PRINT", arg, 1); // More printing !!!!
// Parameters according to "fFitStart"
// (should be a function to be used at every place where needed ????)
trackParam->GetNonBendingSlope(),
0.001, -0.5, 0.5);
if (fFitNParam == 5) {
- // set last 2 Minuit parameters (no limits for the search: min=max=0)
+ // set last 2 Minuit parameters
+ // mandatory limits in Bending to avoid NaN values of parameters
fgFitter->SetParameter(3, "X",
trackParam->GetNonBendingCoor(),
- 0.03, 0.0, 0.0);
+ 0.03, -500.0, 500.0);
+ // mandatory limits in non Bending to avoid NaN values of parameters
fgFitter->SetParameter(4, "Y",
trackParam->GetBendingCoor(),
- 0.10, 0.0, 0.0);
+ 0.10, -500.0, 500.0);
}
// search without gradient calculation in the function
fgFitter->ExecuteCommand("SET NOGRADIENT", arg, 0);
}
//__________________________________________________________________________
-void AliMUONTrack::SetTrackParamAtHit(Int_t indexHit, AliMUONTrackParam *TrackParam)
+void AliMUONTrack::SetTrackParamAtHit(Int_t indexHit, AliMUONTrackParam *TrackParam) const
{
// Set track parameters at TrackHit with index "indexHit"
// from the track parameters pointed to by "TrackParam".
- AliMUONTrackHit* trackHit = (AliMUONTrackHit*) ((*fTrackHitsPtr)[indexHit]);
+ //PH AliMUONTrackHit* trackHit = (AliMUONTrackHit*) ((*fTrackHitsPtr)[indexHit]);
+ AliMUONTrackHit* trackHit = (AliMUONTrackHit*) (fTrackHitsPtr->At(indexHit));
trackHit->SetTrackParam(TrackParam);
}
}
AliMUONTrackHit *hit;
- Bool_t goodDeterminant;
- Int_t chCurrent, chPrev, hitNumber, hitNumber1, hitNumber2, hitNumber3;
+ Int_t chCurrent, chPrev = 0, hitNumber, hitNumber1, hitNumber2, hitNumber3;
Double_t z, z1, z2, z3;
AliMUONTrackHit *hit1, *hit2, *hit3;
Double_t hbc1, hbc2, pbc1, pbc2;
Double_t hnbc1, hnbc2, pnbc1, pnbc2;
Int_t numberOfHit = trackBeingFitted->GetNTrackHits();
- TMatrix *covBending = new TMatrix(numberOfHit, numberOfHit);
- TMatrix *covNonBending = new TMatrix(numberOfHit, numberOfHit);
+ TMatrixD *covBending = new TMatrixD(numberOfHit, numberOfHit);
+ TMatrixD *covNonBending = new TMatrixD(numberOfHit, numberOfHit);
Double_t *msa2 = new Double_t[numberOfHit];
// Predicted coordinates and multiple scattering angles are first calculated
}
} // for (hitNumber2 = hitNumber1;...
} // for (hitNumber1 = 0;...
-
- // Inverts covariance matrix
- goodDeterminant = kTRUE;
- // check whether the Invert method returns flag if matrix cannot be inverted,
- // and do not calculate the Determinant in that case !!!!
- if (covBending->Determinant() != 0) {
- covBending->Invert();
- } else {
- goodDeterminant = kFALSE;
- cout << "Warning in ChiMCS Determinant Bending=0: " << endl;
- }
- if (covNonBending->Determinant() != 0) {
- covNonBending->Invert();
- } else {
- goodDeterminant = kFALSE;
- cout << "Warning in ChiMCS Determinant non Bending=0: " << endl;
- }
+
+ // Inversion of covariance matrices
+ // with "mnvertLocal", local "mnvert" function of Minuit.
+ // One cannot use directly "mnvert" since "TVirtualFitter" does not know it.
+ // One will have to replace this local function by the right inversion function
+ // from a specialized Root package for symmetric positive definite matrices,
+ // when available!!!!
+ Int_t ifailBending;
+ mnvertLocal(&((*covBending)(0,0)), numberOfHit, numberOfHit, numberOfHit,
+ ifailBending);
+ Int_t ifailNonBending;
+ mnvertLocal(&((*covNonBending)(0,0)), numberOfHit, numberOfHit, numberOfHit,
+ ifailNonBending);
// It would be worth trying to calculate the inverse of the covariance matrix
// only once per fit, since it cannot change much in principle,
// and it would save a lot of computing time !!!!
// Calculates Chi2
- if (goodDeterminant) {
+ if ((ifailBending == 0) && (ifailNonBending == 0)) {
// with Multiple Scattering if inversion correct
for (hitNumber1 = 0; hitNumber1 < numberOfHit ; hitNumber1++) {
hit1 = (AliMUONTrackHit*) (*(trackBeingFitted->GetTrackHitsPtr()))[hitNumber1];
varMultipleScatteringAngle * varMultipleScatteringAngle;
return varMultipleScatteringAngle;
}
+
+//______________________________________________________________________________
+ void mnvertLocal(Double_t *a, Int_t l, Int_t, Int_t n, Int_t &ifail)
+{
+//*-*-*-*-*-*-*-*-*-*-*-*Inverts a symmetric matrix*-*-*-*-*-*-*-*-*-*-*-*-*
+//*-* ==========================
+//*-* inverts a symmetric matrix. matrix is first scaled to
+//*-* have all ones on the diagonal (equivalent to change of units)
+//*-* but no pivoting is done since matrix is positive-definite.
+//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
+
+ // taken from TMinuit package of Root (l>=n)
+ // fVERTs, fVERTq and fVERTpp changed to localVERTs, localVERTq and localVERTpp
+ // Double_t localVERTs[n], localVERTq[n], localVERTpp[n];
+ Double_t * localVERTs = new Double_t[n];
+ Double_t * localVERTq = new Double_t[n];
+ Double_t * localVERTpp = new Double_t[n];
+ // fMaxint changed to localMaxint
+ Int_t localMaxint = n;
+
+ /* System generated locals */
+ Int_t aOffset;
+
+ /* Local variables */
+ Double_t si;
+ Int_t i, j, k, kp1, km1;
+
+ /* Parameter adjustments */
+ aOffset = l + 1;
+ a -= aOffset;
+
+ /* Function Body */
+ ifail = 0;
+ if (n < 1) goto L100;
+ if (n > localMaxint) goto L100;
+//*-*- scale matrix by sqrt of diag elements
+ for (i = 1; i <= n; ++i) {
+ si = a[i + i*l];
+ if (si <= 0) goto L100;
+ localVERTs[i-1] = 1 / TMath::Sqrt(si);
+ }
+ for (i = 1; i <= n; ++i) {
+ for (j = 1; j <= n; ++j) {
+ a[i + j*l] = a[i + j*l]*localVERTs[i-1]*localVERTs[j-1];
+ }
+ }
+//*-*- . . . start main loop . . . .
+ for (i = 1; i <= n; ++i) {
+ k = i;
+//*-*- preparation for elimination step1
+ if (a[k + k*l] != 0) localVERTq[k-1] = 1 / a[k + k*l];
+ else goto L100;
+ localVERTpp[k-1] = 1;
+ a[k + k*l] = 0;
+ kp1 = k + 1;
+ km1 = k - 1;
+ if (km1 < 0) goto L100;
+ else if (km1 == 0) goto L50;
+ else goto L40;
+L40:
+ for (j = 1; j <= km1; ++j) {
+ localVERTpp[j-1] = a[j + k*l];
+ localVERTq[j-1] = a[j + k*l]*localVERTq[k-1];
+ a[j + k*l] = 0;
+ }
+L50:
+ if (k - n < 0) goto L51;
+ else if (k - n == 0) goto L60;
+ else goto L100;
+L51:
+ for (j = kp1; j <= n; ++j) {
+ localVERTpp[j-1] = a[k + j*l];
+ localVERTq[j-1] = -a[k + j*l]*localVERTq[k-1];
+ a[k + j*l] = 0;
+ }
+//*-*- elimination proper
+L60:
+ for (j = 1; j <= n; ++j) {
+ for (k = j; k <= n; ++k) { a[j + k*l] += localVERTpp[j-1]*localVERTq[k-1]; }
+ }
+ }
+//*-*- elements of left diagonal and unscaling
+ for (j = 1; j <= n; ++j) {
+ for (k = 1; k <= j; ++k) {
+ a[k + j*l] = a[k + j*l]*localVERTs[k-1]*localVERTs[j-1];
+ a[j + k*l] = a[k + j*l];
+ }
+ }
+ delete localVERTs;
+ delete localVERTq;
+ delete localVERTpp;
+ return;
+//*-*- failure return
+L100:
+ delete localVERTs;
+ delete localVERTq;
+ delete localVERTpp;
+ ifail = 1;
+} /* mnvertLocal */
+