X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONTrackParam.cxx;h=045920c93069f568bd8bead7fd9706bcb1dee982;hb=04c8191369d4d40386e5675fc51aa49f619a190c;hp=01beb2eb5aeb4ab252f73c457779fe65279b4e6b;hpb=6464217e9cb563b9fc37cdae477bac161ccf135f;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONTrackParam.cxx b/MUON/AliMUONTrackParam.cxx index 01beb2eb5ae..045920c9306 100644 --- a/MUON/AliMUONTrackParam.cxx +++ b/MUON/AliMUONTrackParam.cxx @@ -15,1010 +15,459 @@ /* $Id$ */ -/////////////////////////////////////////////////// -// -// Track parameters -// in -// ALICE -// dimuon -// spectrometer -// -/////////////////////////////////////////////////// +//----------------------------------------------------------------------------- +// Class AliMUONTrackParam +//------------------------- +// Track parameters in ALICE dimuon spectrometer +//----------------------------------------------------------------------------- -//#include -#include "AliMUON.h" -#include "AliMUONTrackParam.h" -#include "AliMUONConstants.h" -#include "AliRun.h" -#include "AliMagF.h" -#include "AliLog.h" +#include "AliMUONTrackParam.h" +#include "AliMUONVCluster.h" +#include "AliLog.h" + +#include + +#include + +/// \cond CLASSIMP ClassImp(AliMUONTrackParam) // Class implementation in ROOT context +/// \endcond //_________________________________________________________________________ AliMUONTrackParam::AliMUONTrackParam() - : TObject() + : TObject(), + fZ(0.), + fParameters(5,1), + fCovariances(0x0), + fPropagator(0x0), + fExtrapParameters(0x0), + fExtrapCovariances(0x0), + fSmoothParameters(0x0), + fSmoothCovariances(0x0), + fClusterPtr(0x0), + fOwnCluster(kFALSE), + fRemovable(kFALSE), + fTrackChi2(0.), + fLocalChi2(0.) { -// Constructor + /// Constructor +} - fInverseBendingMomentum = 0; - fBendingSlope = 0; - fNonBendingSlope = 0; - fZ = 0; - fBendingCoor = 0; - fNonBendingCoor = 0; + //_________________________________________________________________________ +AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam) + : TObject(theMUONTrackParam), + fZ(theMUONTrackParam.fZ), + fParameters(theMUONTrackParam.fParameters), + fCovariances(0x0), + fPropagator(0x0), + fExtrapParameters(0x0), + fExtrapCovariances(0x0), + fSmoothParameters(0x0), + fSmoothCovariances(0x0), + fClusterPtr(0x0), + fOwnCluster(theMUONTrackParam.fOwnCluster), + fRemovable(theMUONTrackParam.fRemovable), + fTrackChi2(theMUONTrackParam.fTrackChi2), + fLocalChi2(theMUONTrackParam.fLocalChi2) +{ + /// Copy constructor + if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances)); + if (theMUONTrackParam.fPropagator) fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator)); + if (theMUONTrackParam.fExtrapParameters) fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters)); + if (theMUONTrackParam.fExtrapCovariances) fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances)); + if (theMUONTrackParam.fSmoothParameters) fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters)); + if (theMUONTrackParam.fSmoothCovariances) fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances)); + + if(fOwnCluster) fClusterPtr = static_cast(theMUONTrackParam.fClusterPtr->Clone()); + else fClusterPtr = theMUONTrackParam.fClusterPtr; } //_________________________________________________________________________ -AliMUONTrackParam& -AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam) +AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam) { - // Asignment operator + /// Asignment operator if (this == &theMUONTrackParam) return *this; // base class assignement TObject::operator=(theMUONTrackParam); - fInverseBendingMomentum = theMUONTrackParam.fInverseBendingMomentum; - fBendingSlope = theMUONTrackParam.fBendingSlope; - fNonBendingSlope = theMUONTrackParam.fNonBendingSlope; - fZ = theMUONTrackParam.fZ; - fBendingCoor = theMUONTrackParam.fBendingCoor; - fNonBendingCoor = theMUONTrackParam.fNonBendingCoor; - + fZ = theMUONTrackParam.fZ; + + fParameters = theMUONTrackParam.fParameters; + + if (theMUONTrackParam.fCovariances) { + if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances); + else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances)); + } else { + delete fCovariances; + fCovariances = 0x0; + } + + if (theMUONTrackParam.fPropagator) { + if (fPropagator) *fPropagator = *(theMUONTrackParam.fPropagator); + else fPropagator = new TMatrixD(*(theMUONTrackParam.fPropagator)); + } else { + delete fPropagator; + fPropagator = 0x0; + } + + if (theMUONTrackParam.fExtrapParameters) { + if (fExtrapParameters) *fExtrapParameters = *(theMUONTrackParam.fExtrapParameters); + else fExtrapParameters = new TMatrixD(*(theMUONTrackParam.fExtrapParameters)); + } else { + delete fExtrapParameters; + fExtrapParameters = 0x0; + } + + if (theMUONTrackParam.fExtrapCovariances) { + if (fExtrapCovariances) *fExtrapCovariances = *(theMUONTrackParam.fExtrapCovariances); + else fExtrapCovariances = new TMatrixD(*(theMUONTrackParam.fExtrapCovariances)); + } else { + delete fExtrapCovariances; + fExtrapCovariances = 0x0; + } + + if (theMUONTrackParam.fSmoothParameters) { + if (fSmoothParameters) *fSmoothParameters = *(theMUONTrackParam.fSmoothParameters); + else fSmoothParameters = new TMatrixD(*(theMUONTrackParam.fSmoothParameters)); + } else { + delete fSmoothParameters; + fSmoothParameters = 0x0; + } + + if (theMUONTrackParam.fSmoothCovariances) { + if (fSmoothCovariances) *fSmoothCovariances = *(theMUONTrackParam.fSmoothCovariances); + else fSmoothCovariances = new TMatrixD(*(theMUONTrackParam.fSmoothCovariances)); + } else { + delete fSmoothCovariances; + fSmoothCovariances = 0x0; + } + + if (fOwnCluster) delete fClusterPtr; + fOwnCluster = theMUONTrackParam.fOwnCluster; + if(fOwnCluster) fClusterPtr = static_cast(theMUONTrackParam.fClusterPtr->Clone()); + else fClusterPtr = theMUONTrackParam.fClusterPtr; + + fRemovable = theMUONTrackParam.fRemovable; + + fTrackChi2 = theMUONTrackParam.fTrackChi2; + fLocalChi2 = theMUONTrackParam.fLocalChi2; + return *this; } - //_________________________________________________________________________ -AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam) - : TObject(theMUONTrackParam) + + //__________________________________________________________________________ +AliMUONTrackParam::~AliMUONTrackParam() { - // Copy constructor - fInverseBendingMomentum = theMUONTrackParam.fInverseBendingMomentum; - fBendingSlope = theMUONTrackParam.fBendingSlope; - fNonBendingSlope = theMUONTrackParam.fNonBendingSlope; - fZ = theMUONTrackParam.fZ; - fBendingCoor = theMUONTrackParam.fBendingCoor; - fNonBendingCoor = theMUONTrackParam.fNonBendingCoor; +/// Destructor + DeleteCovariances(); + delete fPropagator; + delete fExtrapParameters; + delete fExtrapCovariances; + delete fSmoothParameters; + delete fSmoothCovariances; + if(fOwnCluster) delete fClusterPtr; } //__________________________________________________________________________ -void AliMUONTrackParam::ExtrapToZ(Double_t Z) +void +AliMUONTrackParam::Clear(Option_t* /*opt*/) { - // Track parameter extrapolation to the plane at "Z". - // On return, the track parameters resulting from the extrapolation - // replace the current track parameters. - if (this->fZ == Z) return; // nothing to be done if same Z - Double_t forwardBackward; // +1 if forward, -1 if backward - if (Z < this->fZ) forwardBackward = 1.0; // spectro. z<0 - else forwardBackward = -1.0; - Double_t vGeant3[7], vGeant3New[7]; // 7 in parameter ???? - Int_t iGeant3, stepNumber; - Int_t maxStepNumber = 5000; // in parameter ???? - // For safety: return kTRUE or kFALSE ???? - // Parameter vector for calling EXTRAP_ONESTEP - SetGeant3Parameters(vGeant3, forwardBackward); - // sign of charge (sign of fInverseBendingMomentum if forward motion) - // must be changed if backward extrapolation - Double_t chargeExtrap = forwardBackward * - TMath::Sign(Double_t(1.0), this->fInverseBendingMomentum); - Double_t stepLength = 6.0; // in parameter ???? - // Extrapolation loop - stepNumber = 0; - while (((-forwardBackward * (vGeant3[2] - Z)) <= 0.0) && // spectro. z<0 - (stepNumber < maxStepNumber)) { - stepNumber++; - // Option for switching between helix and Runge-Kutta ???? - //ExtrapOneStepRungekutta(chargeExtrap, stepLength, vGeant3, vGeant3New); - ExtrapOneStepHelix(chargeExtrap, stepLength, vGeant3, vGeant3New); - if ((-forwardBackward * (vGeant3New[2] - Z)) > 0.0) break; // one is beyond Z spectro. z<0 - // better use TArray ???? - for (iGeant3 = 0; iGeant3 < 7; iGeant3++) - {vGeant3[iGeant3] = vGeant3New[iGeant3];} + /// clear memory + DeleteCovariances(); + delete fPropagator; fPropagator = 0x0; + delete fExtrapParameters; fExtrapParameters = 0x0; + delete fExtrapCovariances; fExtrapCovariances = 0x0; + delete fSmoothParameters; fSmoothParameters = 0x0; + delete fSmoothCovariances; fSmoothCovariances = 0x0; + if(fOwnCluster) { + delete fClusterPtr; fClusterPtr = 0x0; } - // check maxStepNumber ???? - // Interpolation back to exact Z (2nd order) - // should be in function ???? using TArray ???? - Double_t dZ12 = vGeant3New[2] - vGeant3[2]; // 1->2 - if (TMath::Abs(dZ12) > 0) { - Double_t dZ1i = Z - vGeant3[2]; // 1-i - Double_t dZi2 = vGeant3New[2] - Z; // i->2 - Double_t xPrime = (vGeant3New[0] - vGeant3[0]) / dZ12; - Double_t xSecond = - ((vGeant3New[3] / vGeant3New[5]) - (vGeant3[3] / vGeant3[5])) / dZ12; - Double_t yPrime = (vGeant3New[1] - vGeant3[1]) / dZ12; - Double_t ySecond = - ((vGeant3New[4] / vGeant3New[5]) - (vGeant3[4] / vGeant3[5])) / dZ12; - vGeant3[0] = vGeant3[0] + xPrime * dZ1i - 0.5 * xSecond * dZ1i * dZi2; // X - vGeant3[1] = vGeant3[1] + yPrime * dZ1i - 0.5 * ySecond * dZ1i * dZi2; // Y - vGeant3[2] = Z; // Z - Double_t xPrimeI = xPrime - 0.5 * xSecond * (dZi2 - dZ1i); - Double_t yPrimeI = yPrime - 0.5 * ySecond * (dZi2 - dZ1i); - // (PX, PY, PZ)/PTOT assuming forward motion - vGeant3[5] = - 1.0 / TMath::Sqrt(1.0 + xPrimeI * xPrimeI + yPrimeI * yPrimeI); // PZ/PTOT - vGeant3[3] = xPrimeI * vGeant3[5]; // PX/PTOT - vGeant3[4] = yPrimeI * vGeant3[5]; // PY/PTOT - } else { - AliWarning(Form("Extrap. to Z not reached, Z = %f",Z)); - } - // Track parameters from Geant3 parameters, - // with charge back for forward motion - GetFromGeant3Parameters(vGeant3, chargeExtrap * forwardBackward); } //__________________________________________________________________________ -void AliMUONTrackParam::SetGeant3Parameters(Double_t *VGeant3, Double_t ForwardBackward) +Double_t AliMUONTrackParam::Px() const { - // Set vector of Geant3 parameters pointed to by "VGeant3" - // from track parameters in current AliMUONTrackParam. - // Since AliMUONTrackParam is only geometry, one uses "ForwardBackward" - // to know whether the particle is going forward (+1) or backward (-1). - VGeant3[0] = this->fNonBendingCoor; // X - VGeant3[1] = this->fBendingCoor; // Y - VGeant3[2] = this->fZ; // Z - Double_t pYZ = TMath::Abs(1.0 / this->fInverseBendingMomentum); - Double_t pZ = - pYZ / TMath::Sqrt(1.0 + this->fBendingSlope * this->fBendingSlope); - VGeant3[6] = - TMath::Sqrt(pYZ * pYZ + - pZ * pZ * this->fNonBendingSlope * this->fNonBendingSlope); // PTOT - VGeant3[5] = -ForwardBackward * pZ / VGeant3[6]; // PZ/PTOT spectro. z<0 - VGeant3[3] = this->fNonBendingSlope * VGeant3[5]; // PX/PTOT - VGeant3[4] = this->fBendingSlope * VGeant3[5]; // PY/PTOT + /// return p_x from track parameters + Double_t pZ; + if (TMath::Abs(fParameters(4,0)) > 0) { + Double_t pYZ = (TMath::Abs(fParameters(4,0)) > 0) ? TMath::Abs(1.0 / fParameters(4,0)) : FLT_MAX; + pZ = - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0) + } else { + pZ = - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0)); + } + return pZ * fParameters(1,0); } //__________________________________________________________________________ -void AliMUONTrackParam::GetFromGeant3Parameters(Double_t *VGeant3, Double_t Charge) +Double_t AliMUONTrackParam::Py() const { - // Get track parameters in current AliMUONTrackParam - // from Geant3 parameters pointed to by "VGeant3", - // assumed to be calculated for forward motion in Z. - // "InverseBendingMomentum" is signed with "Charge". - this->fNonBendingCoor = VGeant3[0]; // X - this->fBendingCoor = VGeant3[1]; // Y - this->fZ = VGeant3[2]; // Z - Double_t pYZ = VGeant3[6] * TMath::Sqrt(1.0 - VGeant3[3] * VGeant3[3]); - this->fInverseBendingMomentum = Charge / pYZ; - this->fBendingSlope = VGeant3[4] / VGeant3[5]; - this->fNonBendingSlope = VGeant3[3] / VGeant3[5]; + /// return p_y from track parameters + Double_t pZ; + if (TMath::Abs(fParameters(4,0)) > 0) { + Double_t pYZ = (TMath::Abs(fParameters(4,0)) > 0) ? TMath::Abs(1.0 / fParameters(4,0)) : FLT_MAX; + pZ = - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0) + } else { + pZ = - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0)); + } + return pZ * fParameters(3,0); } //__________________________________________________________________________ -void AliMUONTrackParam::ExtrapToStation(Int_t Station, AliMUONTrackParam *TrackParam) +Double_t AliMUONTrackParam::Pz() const { - // Track parameters extrapolated from current track parameters ("this") - // to both chambers of the station(0..) "Station" - // are returned in the array (dimension 2) of track parameters - // pointed to by "TrackParam" (index 0 and 1 for first and second chambers). - Double_t extZ[2], z1, z2; - Int_t i1 = -1, i2 = -1; // = -1 to avoid compilation warnings - // range of Station to be checked ???? - z1 = AliMUONConstants::DefaultChamberZ(2 * Station); - z2 = AliMUONConstants::DefaultChamberZ(2 * Station + 1); - // First and second Z to extrapolate at - if ((z1 > this->fZ) && (z2 > this->fZ)) {i1 = 0; i2 = 1;} - else if ((z1 < this->fZ) && (z2 < this->fZ)) {i1 = 1; i2 = 0;} - else { - AliError(Form("Starting Z (%f) in between z1 (%f) and z2 (%f) of station(0..)%d",this->fZ,z1,z2,Station)); -// cout << "ERROR in AliMUONTrackParam::CreateExtrapSegmentInStation" << endl; -// cout << "Starting Z (" << this->fZ << ") in between z1 (" << z1 << -// ") and z2 (" << z2 << ") of station(0..) " << Station << endl; - } - extZ[i1] = z1; - extZ[i2] = z2; - // copy of track parameters - TrackParam[i1] = *this; - // first extrapolation - (&(TrackParam[i1]))->ExtrapToZ(extZ[0]); - TrackParam[i2] = TrackParam[i1]; - // second extrapolation - (&(TrackParam[i2]))->ExtrapToZ(extZ[1]); - return; + /// return p_z from track parameters + if (TMath::Abs(fParameters(4,0)) > 0) { + Double_t pYZ = TMath::Abs(1.0 / fParameters(4,0)); + return - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0) + } else return - FLT_MAX / TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0)); } //__________________________________________________________________________ -void AliMUONTrackParam::ExtrapToVertex(Double_t xVtx, Double_t yVtx, Double_t zVtx) +Double_t AliMUONTrackParam::P() const { - // Extrapolation to the vertex. - // Returns the track parameters resulting from the extrapolation, - // in the current TrackParam. - // Changes parameters according to Branson correction through the absorber - - Double_t zAbsorber = -503.0; // to be coherent with the Geant absorber geometry !!!! - // spectro. (z<0) - // Extrapolates track parameters upstream to the "Z" end of the front absorber - ExtrapToZ(zAbsorber); // !!! - // Makes Branson correction (multiple scattering + energy loss) - BransonCorrection(xVtx,yVtx,zVtx); - // Makes a simple magnetic field correction through the absorber - FieldCorrection(zAbsorber); + /// return p from track parameters + if (TMath::Abs(fParameters(4,0)) > 0) { + Double_t pYZ = TMath::Abs(1.0 / fParameters(4,0)); + Double_t pZ = - pYZ / (TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0))); // spectro. (z<0) + return - pZ * TMath::Sqrt(1.0 + fParameters(3,0) * fParameters(3,0) + fParameters(1,0) * fParameters(1,0)); + } else return FLT_MAX; } - -// Keep this version for future developments //__________________________________________________________________________ -// void AliMUONTrackParam::BransonCorrection() -// { -// // Branson correction of track parameters -// // the entry parameters have to be calculated at the end of the absorber -// Double_t zEndAbsorber, zBP, xBP, yBP; -// Double_t pYZ, pX, pY, pZ, pTotal, xEndAbsorber, yEndAbsorber, radiusEndAbsorber2, pT, theta; -// Int_t sign; -// // Would it be possible to calculate all that from Geant configuration ???? -// // and to get the Branson parameters from a function in ABSO module ???? -// // with an eventual contribution from other detectors like START ???? -// // Radiation lengths outer part theta > 3 degres -// static Double_t x01[9] = { 18.8, // C (cm) -// 10.397, // Concrete (cm) -// 0.56, // Plomb (cm) -// 47.26, // Polyethylene (cm) -// 0.56, // Plomb (cm) -// 47.26, // Polyethylene (cm) -// 0.56, // Plomb (cm) -// 47.26, // Polyethylene (cm) -// 0.56 }; // Plomb (cm) -// // inner part theta < 3 degres -// static Double_t x02[3] = { 18.8, // C (cm) -// 10.397, // Concrete (cm) -// 0.35 }; // W (cm) -// // z positions of the materials inside the absober outer part theta > 3 degres -// static Double_t z1[10] = { 90, 315, 467, 472, 477, 482, 487, 492, 497, 502 }; -// // inner part theta < 3 degres -// static Double_t z2[4] = { 90, 315, 467, 503 }; -// static Bool_t first = kTRUE; -// static Double_t zBP1, zBP2, rLimit; -// // Calculates z positions of the Branson's planes: zBP1 for outer part and zBP2 for inner part (only at the first call) -// if (first) { -// first = kFALSE; -// Double_t aNBP = 0.0; -// Double_t aDBP = 0.0; -// Int_t iBound; - -// for (iBound = 0; iBound < 9; iBound++) { -// aNBP = aNBP + -// (z1[iBound+1] * z1[iBound+1] * z1[iBound+1] - -// z1[iBound] * z1[iBound] * z1[iBound] ) / x01[iBound]; -// aDBP = aDBP + -// (z1[iBound+1] * z1[iBound+1] - z1[iBound] * z1[iBound] ) / x01[iBound]; -// } -// zBP1 = (2.0 * aNBP) / (3.0 * aDBP); -// aNBP = 0.0; -// aDBP = 0.0; -// for (iBound = 0; iBound < 3; iBound++) { -// aNBP = aNBP + -// (z2[iBound+1] * z2[iBound+1] * z2[iBound+1] - -// z2[iBound] * z2[iBound ] * z2[iBound] ) / x02[iBound]; -// aDBP = aDBP + -// (z2[iBound+1] * z2[iBound+1] - z2[iBound] * z2[iBound]) / x02[iBound]; -// } -// zBP2 = (2.0 * aNBP) / (3.0 * aDBP); -// rLimit = z2[3] * TMath::Tan(3.0 * (TMath::Pi()) / 180.); -// } - -// pYZ = TMath::Abs(1.0 / fInverseBendingMomentum); -// sign = 1; -// if (fInverseBendingMomentum < 0) sign = -1; -// pZ = pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); -// pX = pZ * fNonBendingSlope; -// pY = pZ * fBendingSlope; -// pTotal = TMath::Sqrt(pYZ *pYZ + pX * pX); -// xEndAbsorber = fNonBendingCoor; -// yEndAbsorber = fBendingCoor; -// radiusEndAbsorber2 = xEndAbsorber * xEndAbsorber + yEndAbsorber * yEndAbsorber; - -// if (radiusEndAbsorber2 > rLimit*rLimit) { -// zEndAbsorber = z1[9]; -// zBP = zBP1; -// } else { -// zEndAbsorber = z2[3]; -// zBP = zBP2; -// } - -// xBP = xEndAbsorber - (pX / pZ) * (zEndAbsorber - zBP); -// yBP = yEndAbsorber - (pY / pZ) * (zEndAbsorber - zBP); - -// // new parameters after Branson and energy loss corrections -// pZ = pTotal * zBP / TMath::Sqrt(xBP * xBP + yBP * yBP + zBP * zBP); -// pX = pZ * xBP / zBP; -// pY = pZ * yBP / zBP; -// fBendingSlope = pY / pZ; -// fNonBendingSlope = pX / pZ; - -// pT = TMath::Sqrt(pX * pX + pY * pY); -// theta = TMath::ATan2(pT, pZ); -// pTotal = -// TotalMomentumEnergyLoss(rLimit, pTotal, theta, xEndAbsorber, yEndAbsorber); - -// fInverseBendingMomentum = (sign / pTotal) * -// TMath::Sqrt(1.0 + -// fBendingSlope * fBendingSlope + -// fNonBendingSlope * fNonBendingSlope) / -// TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope); - -// // vertex position at (0,0,0) -// // should be taken from vertex measurement ??? -// fBendingCoor = 0.0; -// fNonBendingCoor = 0; -// fZ= 0; -// } - -void AliMUONTrackParam::BransonCorrection(Double_t xVtx,Double_t yVtx,Double_t zVtx) +const TMatrixD& AliMUONTrackParam::GetCovariances() const { - // Branson correction of track parameters - // the entry parameters have to be calculated at the end of the absorber - // simplified version: the z positions of Branson's planes are no longer calculated - // but are given as inputs. One can use the macros MUONTestAbso.C and DrawTestAbso.C - // to test this correction. - // Would it be possible to calculate all that from Geant configuration ???? - // and to get the Branson parameters from a function in ABSO module ???? - // with an eventual contribution from other detectors like START ???? - //change to take into account the vertex postition (real, reconstruct,....) - - Double_t zBP, xBP, yBP; - Double_t pYZ, pX, pY, pZ, pTotal, xEndAbsorber, yEndAbsorber, radiusEndAbsorber2, pT, theta; - Int_t sign; - static Bool_t first = kTRUE; - static Double_t zBP1, zBP2, rLimit, thetaLimit, zEndAbsorber; - // zBP1 for outer part and zBP2 for inner part (only at the first call) - if (first) { - first = kFALSE; - - zEndAbsorber = -503; // spectro (z<0) - thetaLimit = 3.0 * (TMath::Pi()) / 180.; - rLimit = TMath::Abs(zEndAbsorber) * TMath::Tan(thetaLimit); - zBP1 = -450; // values close to those calculated with EvalAbso.C - zBP2 = -480; - } - - pYZ = TMath::Abs(1.0 / fInverseBendingMomentum); - sign = 1; - if (fInverseBendingMomentum < 0) sign = -1; - pZ = Pz(); - pX = Px(); - pY = Py(); - pTotal = TMath::Sqrt(pYZ *pYZ + pX * pX); - xEndAbsorber = fNonBendingCoor; - yEndAbsorber = fBendingCoor; - radiusEndAbsorber2 = xEndAbsorber * xEndAbsorber + yEndAbsorber * yEndAbsorber; - - if (radiusEndAbsorber2 > rLimit*rLimit) { - zBP = zBP1; - } else { - zBP = zBP2; + /// Return the covariance matrix (create it before if needed) + if (!fCovariances) { + fCovariances = new TMatrixD(5,5); + fCovariances->Zero(); } - - xBP = xEndAbsorber - (pX / pZ) * (zEndAbsorber - zBP); - yBP = yEndAbsorber - (pY / pZ) * (zEndAbsorber - zBP); - - // new parameters after Branson and energy loss corrections -// Float_t zSmear = zBP - gRandom->Gaus(0.,2.); // !!! possible smearing of Z vertex position - - Float_t zSmear = zBP ; - - pZ = pTotal * (zSmear-zVtx) / TMath::Sqrt((xBP-xVtx) * (xBP-xVtx) + (yBP-yVtx) * (yBP-yVtx) +( zSmear-zVtx) * (zSmear-zVtx) ); - pX = pZ * (xBP - xVtx)/ (zSmear-zVtx); - pY = pZ * (yBP - yVtx) / (zSmear-zVtx); - fBendingSlope = pY / pZ; - fNonBendingSlope = pX / pZ; - - - pT = TMath::Sqrt(pX * pX + pY * pY); - theta = TMath::ATan2(pT, TMath::Abs(pZ)); - pTotal = TotalMomentumEnergyLoss(thetaLimit, pTotal, theta); - - fInverseBendingMomentum = (sign / pTotal) * - TMath::Sqrt(1.0 + - fBendingSlope * fBendingSlope + - fNonBendingSlope * fNonBendingSlope) / - TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope); - - // vertex position at (0,0,0) - // should be taken from vertex measurement ??? - - fBendingCoor = xVtx; - fNonBendingCoor = yVtx; - fZ= zVtx; - + return *fCovariances; } //__________________________________________________________________________ -Double_t AliMUONTrackParam::TotalMomentumEnergyLoss(Double_t thetaLimit, Double_t pTotal, Double_t theta) +void AliMUONTrackParam::SetCovariances(const TMatrixD& covariances) { - // Returns the total momentum corrected from energy loss in the front absorber - // One can use the macros MUONTestAbso.C and DrawTestAbso.C - // to test this correction. - // Momentum energy loss behaviour evaluated with the simulation of single muons (april 2002) - Double_t deltaP, pTotalCorrected; - - // Parametrization to be redone according to change of absorber material ???? - // See remark in function BransonCorrection !!!! - // The name is not so good, and there are many arguments !!!! - if (theta < thetaLimit ) { - if (pTotal < 20) { - deltaP = 2.5938 + 0.0570 * pTotal - 0.001151 * pTotal * pTotal; - } else { - deltaP = 3.0714 + 0.011767 *pTotal; - } - deltaP *= 0.75; // AZ - } else { - if (pTotal < 20) { - deltaP = 2.1207 + 0.05478 * pTotal - 0.00145079 * pTotal * pTotal; - } else { - deltaP = 2.6069 + 0.0051705 * pTotal; - } - deltaP *= 0.9; // AZ - } - pTotalCorrected = pTotal + deltaP / TMath::Cos(theta); - return pTotalCorrected; + /// Set the covariance matrix + if (fCovariances) *fCovariances = covariances; + else fCovariances = new TMatrixD(covariances); } //__________________________________________________________________________ -void AliMUONTrackParam::FieldCorrection(Double_t Z) +void AliMUONTrackParam::SetCovariances(const Double_t matrix[5][5]) { - // - // Correction of the effect of the magnetic field in the absorber - // Assume a constant field along Z axis. - - Float_t b[3],x[3]; - Double_t bZ; - Double_t pYZ,pX,pY,pZ,pT; - Double_t pXNew,pYNew; - Double_t c; - - pYZ = TMath::Abs(1.0 / fInverseBendingMomentum); - c = TMath::Sign(1.0,fInverseBendingMomentum); // particle charge - - pZ = Pz(); - pX = Px(); - pY = Py(); - pT = TMath::Sqrt(pX*pX+pY*pY); - - if (TMath::Abs(pZ) <= 0) return; - x[2] = Z/2; - x[0] = x[2]*fNonBendingSlope; - x[1] = x[2]*fBendingSlope; - - // Take magn. field value at position x. - gAlice->Field()->Field(x, b); - bZ = b[2]; - - // Transverse momentum rotation - // Parameterized with the study of DeltaPhi = phiReco - phiGen as a function of pZ. - Double_t phiShift = c*0.436*0.0003*bZ*Z/pZ; - // Rotate momentum around Z axis. - pXNew = pX*TMath::Cos(phiShift) - pY*TMath::Sin(phiShift); - pYNew = pX*TMath::Sin(phiShift) + pY*TMath::Cos(phiShift); - - fBendingSlope = pYNew / pZ; - fNonBendingSlope = pXNew / pZ; - - fInverseBendingMomentum = c / TMath::Sqrt(pYNew*pYNew+pZ*pZ); - + /// Set the covariance matrix + if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0])); + else fCovariances = new TMatrixD(5,5,&(matrix[0][0])); } + //__________________________________________________________________________ -Double_t AliMUONTrackParam::Px() const +void AliMUONTrackParam::SetVariances(const Double_t matrix[5][5]) { - // return px from track paramaters - Double_t pYZ, pZ, pX; - pYZ = 0; - if ( TMath::Abs(fInverseBendingMomentum) > 0 ) - pYZ = TMath::Abs(1.0 / fInverseBendingMomentum); - pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0) - pX = pZ * fNonBendingSlope; - return pX; + /// Set the diagonal terms of the covariance matrix (variances) + if (!fCovariances) fCovariances = new TMatrixD(5,5); + fCovariances->Zero(); + for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i]; } + //__________________________________________________________________________ -Double_t AliMUONTrackParam::Py() const +void AliMUONTrackParam::DeleteCovariances() { - // return px from track paramaters - Double_t pYZ, pZ, pY; - pYZ = 0; - if ( TMath::Abs(fInverseBendingMomentum) > 0 ) - pYZ = TMath::Abs(1.0 / fInverseBendingMomentum); - pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0) - pY = pZ * fBendingSlope; - return pY; + /// Delete the covariance matrix + delete fCovariances; + fCovariances = 0x0; } + //__________________________________________________________________________ -Double_t AliMUONTrackParam::Pz() const +const TMatrixD& AliMUONTrackParam::GetPropagator() const { - // return px from track paramaters - Double_t pYZ, pZ; - pYZ = 0; - if ( TMath::Abs(fInverseBendingMomentum) > 0 ) - pYZ = TMath::Abs(1.0 / fInverseBendingMomentum); - pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0) - return pZ; + /// Return the propagator (create it before if needed) + if (!fPropagator) { + fPropagator = new TMatrixD(5,5); + fPropagator->UnitMatrix(); + } + return *fPropagator; } + //__________________________________________________________________________ -Double_t AliMUONTrackParam::P() const +void AliMUONTrackParam::ResetPropagator() { - // return p from track paramaters - Double_t pYZ, pZ, p; - pYZ = 0; - if ( TMath::Abs(fInverseBendingMomentum) > 0 ) - pYZ = TMath::Abs(1.0 / fInverseBendingMomentum); - pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0) - p = TMath::Abs(pZ) * - TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope + fNonBendingSlope * fNonBendingSlope); - return p; - + /// Reset the propagator + if (fPropagator) fPropagator->UnitMatrix(); } - //__________________________________________________________________________ -void AliMUONTrackParam::ExtrapOneStepHelix(Double_t charge, Double_t step, - Double_t *vect, Double_t *vout) const -{ -// ****************************************************************** -// * * -// * Performs the tracking of one step in a magnetic field * -// * The trajectory is assumed to be a helix in a constant field * -// * taken at the mid point of the step. * -// * Parameters: * -// * input * -// * STEP =arc length of the step asked * -// * VECT =input vector (position,direction cos and momentum) * -// * CHARGE= electric charge of the particle * -// * output * -// * VOUT = same as VECT after completion of the step * -// * * -// * ==>Called by : , GUSWIM * -// * Author m.hansroul ********* * -// * modified s.egli, s.v.levonian * -// * modified v.perevoztchikov -// * * -// ****************************************************************** -// - -// modif: everything in double precision - - Double_t xyz[3], h[4], hxp[3]; - Double_t h2xy, hp, rho, tet; - Double_t sint, sintt, tsint, cos1t; - Double_t f1, f2, f3, f4, f5, f6; - - const Int_t kix = 0; - const Int_t kiy = 1; - const Int_t kiz = 2; - const Int_t kipx = 3; - const Int_t kipy = 4; - const Int_t kipz = 5; - const Int_t kipp = 6; - - const Double_t kec = 2.9979251e-4; - // - // ------------------------------------------------------------------ - // - // units are kgauss,centimeters,gev/c - // - vout[kipp] = vect[kipp]; - if (TMath::Abs(charge) < 0.00001) { - for (Int_t i = 0; i < 3; i++) { - vout[i] = vect[i] + step * vect[i+3]; - vout[i+3] = vect[i+3]; - } - return; - } - xyz[0] = vect[kix] + 0.5 * step * vect[kipx]; - xyz[1] = vect[kiy] + 0.5 * step * vect[kipy]; - xyz[2] = vect[kiz] + 0.5 * step * vect[kipz]; - //cmodif: call gufld (xyz, h) changed into: - GetField (xyz, h); - - h2xy = h[0]*h[0] + h[1]*h[1]; - h[3] = h[2]*h[2]+ h2xy; - if (h[3] < 1.e-12) { - for (Int_t i = 0; i < 3; i++) { - vout[i] = vect[i] + step * vect[i+3]; - vout[i+3] = vect[i+3]; - } - return; - } - if (h2xy < 1.e-12*h[3]) { - ExtrapOneStepHelix3(charge*h[2], step, vect, vout); - return; - } - h[3] = TMath::Sqrt(h[3]); - h[0] /= h[3]; - h[1] /= h[3]; - h[2] /= h[3]; - h[3] *= kec; - - hxp[0] = h[1]*vect[kipz] - h[2]*vect[kipy]; - hxp[1] = h[2]*vect[kipx] - h[0]*vect[kipz]; - hxp[2] = h[0]*vect[kipy] - h[1]*vect[kipx]; - - hp = h[0]*vect[kipx] + h[1]*vect[kipy] + h[2]*vect[kipz]; - - rho = -charge*h[3]/vect[kipp]; - tet = rho * step; - - if (TMath::Abs(tet) > 0.15) { - sint = TMath::Sin(tet); - sintt = (sint/tet); - tsint = (tet-sint)/tet; - cos1t = 2.*(TMath::Sin(0.5*tet))*(TMath::Sin(0.5*tet))/tet; - } else { - tsint = tet*tet/36.; - sintt = (1. - tsint); - sint = tet*sintt; - cos1t = 0.5*tet; - } - - f1 = step * sintt; - f2 = step * cos1t; - f3 = step * tsint * hp; - f4 = -tet*cos1t; - f5 = sint; - f6 = tet * cos1t * hp; - - vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0] + f3*h[0]; - vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1] + f3*h[1]; - vout[kiz] = vect[kiz] + f1*vect[kipz] + f2*hxp[2] + f3*h[2]; - - vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0] + f6*h[0]; - vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1] + f6*h[1]; - vout[kipz] = vect[kipz] + f4*vect[kipz] + f5*hxp[2] + f6*h[2]; - - return; + //__________________________________________________________________________ +void AliMUONTrackParam::UpdatePropagator(const TMatrixD& propagator) +{ + /// Update the propagator + if (fPropagator) *fPropagator = TMatrixD(propagator,TMatrixD::kMult,*fPropagator); + else fPropagator = new TMatrixD(propagator); } - //__________________________________________________________________________ -void AliMUONTrackParam::ExtrapOneStepHelix3(Double_t field, Double_t step, - Double_t *vect, Double_t *vout) const + //__________________________________________________________________________ +const TMatrixD& AliMUONTrackParam::GetExtrapParameters() const { -// -// ****************************************************************** -// * * -// * Tracking routine in a constant field oriented * -// * along axis 3 * -// * Tracking is performed with a conventional * -// * helix step method * -// * * -// * ==>Called by : , GUSWIM * -// * Authors R.Brun, M.Hansroul ********* * -// * Rewritten V.Perevoztchikov -// * * -// ****************************************************************** -// - - Double_t hxp[3]; - Double_t h4, hp, rho, tet; - Double_t sint, sintt, tsint, cos1t; - Double_t f1, f2, f3, f4, f5, f6; - - const Int_t kix = 0; - const Int_t kiy = 1; - const Int_t kiz = 2; - const Int_t kipx = 3; - const Int_t kipy = 4; - const Int_t kipz = 5; - const Int_t kipp = 6; - - const Double_t kec = 2.9979251e-4; + /// Return extrapolated parameters (create it before if needed) + if (!fExtrapParameters) { + fExtrapParameters = new TMatrixD(5,1); + fExtrapParameters->Zero(); + } + return *fExtrapParameters; + } -// -// ------------------------------------------------------------------ -// -// units are kgauss,centimeters,gev/c -// - vout[kipp] = vect[kipp]; - h4 = field * kec; + //__________________________________________________________________________ +void AliMUONTrackParam::SetExtrapParameters(const TMatrixD& extrapParameters) +{ + /// Set extrapolated parameters + if (fExtrapParameters) *fExtrapParameters = extrapParameters; + else fExtrapParameters = new TMatrixD(extrapParameters); +} - hxp[0] = - vect[kipy]; - hxp[1] = + vect[kipx]; - - hp = vect[kipz]; + //__________________________________________________________________________ +const TMatrixD& AliMUONTrackParam::GetExtrapCovariances() const +{ + /// Return the extrapolated covariance matrix (create it before if needed) + if (!fExtrapCovariances) { + fExtrapCovariances = new TMatrixD(5,5); + fExtrapCovariances->Zero(); + } + return *fExtrapCovariances; + } - rho = -h4/vect[kipp]; - tet = rho * step; - if (TMath::Abs(tet) > 0.15) { - sint = TMath::Sin(tet); - sintt = (sint/tet); - tsint = (tet-sint)/tet; - cos1t = 2.* TMath::Sin(0.5*tet) * TMath::Sin(0.5*tet)/tet; - } else { - tsint = tet*tet/36.; - sintt = (1. - tsint); - sint = tet*sintt; - cos1t = 0.5*tet; - } + //__________________________________________________________________________ +void AliMUONTrackParam::SetExtrapCovariances(const TMatrixD& extrapCovariances) +{ + /// Set the extrapolated covariance matrix + if (fExtrapCovariances) *fExtrapCovariances = extrapCovariances; + else fExtrapCovariances = new TMatrixD(extrapCovariances); +} - f1 = step * sintt; - f2 = step * cos1t; - f3 = step * tsint * hp; - f4 = -tet*cos1t; - f5 = sint; - f6 = tet * cos1t * hp; - - vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0]; - vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1]; - vout[kiz] = vect[kiz] + f1*vect[kipz] + f3; - - vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0]; - vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1]; - vout[kipz] = vect[kipz] + f4*vect[kipz] + f6; + //__________________________________________________________________________ +const TMatrixD& AliMUONTrackParam::GetSmoothParameters() const +{ + /// Return the smoothed parameters (create it before if needed) + if (!fSmoothParameters) { + fSmoothParameters = new TMatrixD(5,1); + fSmoothParameters->Zero(); + } + return *fSmoothParameters; + } - return; + //__________________________________________________________________________ +void AliMUONTrackParam::SetSmoothParameters(const TMatrixD& smoothParameters) +{ + /// Set the smoothed parameters + if (fSmoothParameters) *fSmoothParameters = smoothParameters; + else fSmoothParameters = new TMatrixD(smoothParameters); } - //__________________________________________________________________________ -void AliMUONTrackParam::ExtrapOneStepRungekutta(Double_t charge, Double_t step, - Double_t* vect, Double_t* vout) const + + //__________________________________________________________________________ +const TMatrixD& AliMUONTrackParam::GetSmoothCovariances() const { -// -// ****************************************************************** -// * * -// * Runge-Kutta method for tracking a particle through a magnetic * -// * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of * -// * Standards, procedure 25.5.20) * -// * * -// * Input parameters * -// * CHARGE Particle charge * -// * STEP Step size * -// * VECT Initial co-ords,direction cosines,momentum * -// * Output parameters * -// * VOUT Output co-ords,direction cosines,momentum * -// * User routine called * -// * CALL GUFLD(X,F) * -// * * -// * ==>Called by : , GUSWIM * -// * Authors R.Brun, M.Hansroul ********* * -// * V.Perevoztchikov (CUT STEP implementation) * -// * * -// * * -// ****************************************************************** -// + /// Return the smoothed covariance matrix (create it before if needed) + if (!fSmoothCovariances) { + fSmoothCovariances = new TMatrixD(5,5); + fSmoothCovariances->Zero(); + } + return *fSmoothCovariances; + } - Double_t h2, h4, f[4]; - Double_t xyzt[3], a, b, c, ph,ph2; - Double_t secxs[4],secys[4],seczs[4],hxp[3]; - Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt; - Double_t est, at, bt, ct, cba; - Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost; - - Double_t x; - Double_t y; - Double_t z; - - Double_t xt; - Double_t yt; - Double_t zt; + //__________________________________________________________________________ +void AliMUONTrackParam::SetSmoothCovariances(const TMatrixD& smoothCovariances) +{ + /// Set the smoothed covariance matrix + if (fSmoothCovariances) *fSmoothCovariances = smoothCovariances; + else fSmoothCovariances = new TMatrixD(smoothCovariances); +} - Double_t maxit = 1992; - Double_t maxcut = 11; +//__________________________________________________________________________ +void AliMUONTrackParam::SetClusterPtr(AliMUONVCluster* cluster, Bool_t owner) +{ + /// set pointeur to associated cluster + if (fOwnCluster) delete fClusterPtr; + fClusterPtr = cluster; + fOwnCluster = owner; +} - const Double_t kdlt = 1e-4; - const Double_t kdlt32 = kdlt/32.; - const Double_t kthird = 1./3.; - const Double_t khalf = 0.5; - const Double_t kec = 2.9979251e-4; + //__________________________________________________________________________ +Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const +{ + /// "Compare" function to sort with decreasing Z (spectro. muon Z <0). + /// Returns 1 (0, -1) if the current Z + /// is smaller than (equal to, larger than) Z of trackParam + if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1); + else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0); + else return(-1); +} - const Double_t kpisqua = 9.86960440109; - const Int_t kix = 0; - const Int_t kiy = 1; - const Int_t kiz = 2; - const Int_t kipx = 3; - const Int_t kipy = 4; - const Int_t kipz = 5; + //__________________________________________________________________________ +Bool_t AliMUONTrackParam::CompatibleTrackParam(const AliMUONTrackParam &trackParam, Double_t sigma2Cut, Double_t &chi2) const +{ + /// Return kTRUE if the two set of track parameters are compatible within sigma2Cut + /// Set chi2 to the compatible chi2 value + /// Note that parameter covariances must exist for at least one set of parameters + /// Note also that if parameters are not given at the same Z, results will be meaningless - // *. - // *. ------------------------------------------------------------------ - // *. - // * this constant is for units cm,gev/c and kgauss - // * - Int_t iter = 0; - Int_t ncut = 0; - for(Int_t j = 0; j < 7; j++) - vout[j] = vect[j]; - - Double_t pinv = kec * charge / vect[6]; - Double_t tl = 0.; - Double_t h = step; - Double_t rest; - - - do { - rest = step - tl; - if (TMath::Abs(h) > TMath::Abs(rest)) h = rest; - //cmodif: call gufld(vout,f) changed into: - - GetField(vout,f); - - // * - // * start of integration - // * - x = vout[0]; - y = vout[1]; - z = vout[2]; - a = vout[3]; - b = vout[4]; - c = vout[5]; - - h2 = khalf * h; - h4 = khalf * h2; - ph = pinv * h; - ph2 = khalf * ph; - secxs[0] = (b * f[2] - c * f[1]) * ph2; - secys[0] = (c * f[0] - a * f[2]) * ph2; - seczs[0] = (a * f[1] - b * f[0]) * ph2; - ang2 = (secxs[0]*secxs[0] + secys[0]*secys[0] + seczs[0]*seczs[0]); - if (ang2 > kpisqua) break; - - dxt = h2 * a + h4 * secxs[0]; - dyt = h2 * b + h4 * secys[0]; - dzt = h2 * c + h4 * seczs[0]; - xt = x + dxt; - yt = y + dyt; - zt = z + dzt; - // * - // * second intermediate point - // * - - est = TMath::Abs(dxt) + TMath::Abs(dyt) + TMath::Abs(dzt); - if (est > h) { - if (ncut++ > maxcut) break; - h *= khalf; - continue; - } - - xyzt[0] = xt; - xyzt[1] = yt; - xyzt[2] = zt; - - //cmodif: call gufld(xyzt,f) changed into: - GetField(xyzt,f); - - at = a + secxs[0]; - bt = b + secys[0]; - ct = c + seczs[0]; - - secxs[1] = (bt * f[2] - ct * f[1]) * ph2; - secys[1] = (ct * f[0] - at * f[2]) * ph2; - seczs[1] = (at * f[1] - bt * f[0]) * ph2; - at = a + secxs[1]; - bt = b + secys[1]; - ct = c + seczs[1]; - secxs[2] = (bt * f[2] - ct * f[1]) * ph2; - secys[2] = (ct * f[0] - at * f[2]) * ph2; - seczs[2] = (at * f[1] - bt * f[0]) * ph2; - dxt = h * (a + secxs[2]); - dyt = h * (b + secys[2]); - dzt = h * (c + seczs[2]); - xt = x + dxt; - yt = y + dyt; - zt = z + dzt; - at = a + 2.*secxs[2]; - bt = b + 2.*secys[2]; - ct = c + 2.*seczs[2]; - - est = TMath::Abs(dxt)+TMath::Abs(dyt)+TMath::Abs(dzt); - if (est > 2.*TMath::Abs(h)) { - if (ncut++ > maxcut) break; - h *= khalf; - continue; - } - - xyzt[0] = xt; - xyzt[1] = yt; - xyzt[2] = zt; - - //cmodif: call gufld(xyzt,f) changed into: - GetField(xyzt,f); - - z = z + (c + (seczs[0] + seczs[1] + seczs[2]) * kthird) * h; - y = y + (b + (secys[0] + secys[1] + secys[2]) * kthird) * h; - x = x + (a + (secxs[0] + secxs[1] + secxs[2]) * kthird) * h; - - secxs[3] = (bt*f[2] - ct*f[1])* ph2; - secys[3] = (ct*f[0] - at*f[2])* ph2; - seczs[3] = (at*f[1] - bt*f[0])* ph2; - a = a+(secxs[0]+secxs[3]+2. * (secxs[1]+secxs[2])) * kthird; - b = b+(secys[0]+secys[3]+2. * (secys[1]+secys[2])) * kthird; - c = c+(seczs[0]+seczs[3]+2. * (seczs[1]+seczs[2])) * kthird; - - est = TMath::Abs(secxs[0]+secxs[3] - (secxs[1]+secxs[2])) - + TMath::Abs(secys[0]+secys[3] - (secys[1]+secys[2])) - + TMath::Abs(seczs[0]+seczs[3] - (seczs[1]+seczs[2])); - - if (est > kdlt && TMath::Abs(h) > 1.e-4) { - if (ncut++ > maxcut) break; - h *= khalf; - continue; - } - - ncut = 0; - // * if too many iterations, go to helix - if (iter++ > maxit) break; - - tl += h; - if (est < kdlt32) - h *= 2.; - cba = 1./ TMath::Sqrt(a*a + b*b + c*c); - vout[0] = x; - vout[1] = y; - vout[2] = z; - vout[3] = cba*a; - vout[4] = cba*b; - vout[5] = cba*c; - rest = step - tl; - if (step < 0.) rest = -rest; - if (rest < 1.e-5*TMath::Abs(step)) return; - - } while(1); - - // angle too big, use helix - - f1 = f[0]; - f2 = f[1]; - f3 = f[2]; - f4 = TMath::Sqrt(f1*f1+f2*f2+f3*f3); - rho = -f4*pinv; - tet = rho * step; - - hnorm = 1./f4; - f1 = f1*hnorm; - f2 = f2*hnorm; - f3 = f3*hnorm; - - hxp[0] = f2*vect[kipz] - f3*vect[kipy]; - hxp[1] = f3*vect[kipx] - f1*vect[kipz]; - hxp[2] = f1*vect[kipy] - f2*vect[kipx]; - - hp = f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz]; - - rho1 = 1./rho; - sint = TMath::Sin(tet); - cost = 2.*TMath::Sin(khalf*tet)*TMath::Sin(khalf*tet); - - g1 = sint*rho1; - g2 = cost*rho1; - g3 = (tet-sint) * hp*rho1; - g4 = -cost; - g5 = sint; - g6 = cost * hp; - - vout[kix] = vect[kix] + g1*vect[kipx] + g2*hxp[0] + g3*f1; - vout[kiy] = vect[kiy] + g1*vect[kipy] + g2*hxp[1] + g3*f2; - vout[kiz] = vect[kiz] + g1*vect[kipz] + g2*hxp[2] + g3*f3; - - vout[kipx] = vect[kipx] + g4*vect[kipx] + g5*hxp[0] + g6*f1; - vout[kipy] = vect[kipy] + g4*vect[kipy] + g5*hxp[1] + g6*f2; - vout[kipz] = vect[kipz] + g4*vect[kipz] + g5*hxp[2] + g6*f3; - - return; + // reset chi2 value + chi2 = 0.; + + // ckeck covariance matrices + if (!fCovariances && !trackParam.fCovariances) { + AliError("Covariance matrix must exist for at least one set of parameters"); + return kFALSE; + } + + Double_t maxChi2 = 5. * sigma2Cut * sigma2Cut; // 5 degrees of freedom + + // check Z parameters + if (fZ != trackParam.fZ) + AliWarning(Form("Parameters are given at different Z position (%le : %le): results are meaningless", fZ, trackParam.fZ)); + + // compute the parameter residuals + TMatrixD deltaParam(fParameters, TMatrixD::kMinus, trackParam.fParameters); + + // build the error matrix + TMatrixD weight(5,5); + if (fCovariances) weight += *fCovariances; + if (trackParam.fCovariances) weight += *(trackParam.fCovariances); + + // invert the error matrix to get the parameter weights if possible + if (weight.Determinant() == 0) { + AliError("Cannot compute the compatibility chi2"); + return kFALSE; + } + weight.Invert(); + + // compute the compatibility chi2 + TMatrixD tmp(deltaParam, TMatrixD::kTransposeMult, weight); + TMatrixD mChi2(tmp, TMatrixD::kMult, deltaParam); + + // set chi2 value + chi2 = mChi2(0,0); + + // check compatibility + if (chi2 > maxChi2) return kFALSE; + + return kTRUE; } -//___________________________________________________________ - void AliMUONTrackParam::GetField(Double_t *Position, Double_t *Field) const -{ - // interface to "gAlice->Field()->Field" for arguments in double precision - - Float_t x[3], b[3]; - - x[0] = Position[0]; x[1] = Position[1]; x[2] = Position[2]; - gAlice->Field()->Field(x, b); - Field[0] = b[0]; Field[1] = b[1]; Field[2] = b[2]; - - return; - } -//_____________________________________________- + //__________________________________________________________________________ void AliMUONTrackParam::Print(Option_t* opt) const { -// - // Printing TrackParam information - // "full" option for printing all the information about the TrackParam - // + /// Printing TrackParam information + /// "full" option for printing all the information about the TrackParam TString sopt(opt); sopt.ToUpper(); if ( sopt.Contains("FULL") ) { - cout << " Bending P=" << setw(5) << setprecision(3) << 1./GetInverseBendingMomentum() << - ", NonBendSlope=" << setw(5) << setprecision(3) << GetNonBendingSlope()*180./TMath::Pi() << - ", BendSlope=" << setw(5) << setprecision(3) << GetBendingSlope()*180./TMath::Pi() << - ", (x,y,z)_IP=(" << setw(5) << setprecision(3) << GetNonBendingCoor() << - "," << setw(5) << setprecision(3) << GetBendingCoor() << - "," << setw(5) << setprecision(3) << GetZ() << + cout << " Bending P=" << setw(5) << setprecision(3) << 1./fParameters(4,0) << + ", NonBendSlope=" << setw(5) << setprecision(3) << fParameters(1,0)*180./TMath::Pi() << + ", BendSlope=" << setw(5) << setprecision(3) << fParameters(3,0)*180./TMath::Pi() << + ", (x,y,z)_IP=(" << setw(5) << setprecision(3) << fParameters(0,0) << + "," << setw(5) << setprecision(3) << fParameters(2,0) << + "," << setw(5) << setprecision(3) << fZ << ") cm, (px,py,pz)=(" << setw(5) << setprecision(3) << Px() << "," << setw(5) << setprecision(3) << Py() << "," << setw(5) << setprecision(3) << Pz() << ") GeV/c" << endl;