//
///////////////////////////////////////////////////
-#include <Riostream.h>
-
-#include "AliCallf77.h"
-#include "AliMUON.h"
-#include "AliMUONTrackParam.h"
-#include "AliMUONChamber.h"
-#include "AliRun.h"
-#include "AliMagF.h"
-#include "AliLog.h"
-
-ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
+#include "AliMUONTrackParam.h"
+#include "AliMUONHitForRec.h"
- // A few calls in Fortran or from Fortran (extrap.F).
- // Needed, instead of calls to Geant subroutines,
- // because double precision is necessary for track fit converging with Minuit.
- // The "extrap" functions should be translated into C++ ????
-#ifndef WIN32
-# define extrap_onestep_helix extrap_onestep_helix_
-# define extrap_onestep_helix3 extrap_onestep_helix3_
-# define extrap_onestep_rungekutta extrap_onestep_rungekutta_
-# define gufld_double gufld_double_
-#else
-# define extrap_onestep_helix EXTRAP_ONESTEP_HELIX
-# define extrap_onestep_helix3 EXTRAP_ONESTEP_HELIX3
-# define extrap_onestep_rungekutta EXTRAP_ONESTEP_RUNGEKUTTA
-# define gufld_double GUFLD_DOUBLE
-#endif
+#include "AliESDMuonTrack.h"
+#include "AliLog.h"
-extern "C" {
- void type_of_call extrap_onestep_helix
- (Double_t &Charge, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New);
-
- void type_of_call extrap_onestep_helix3
- (Double_t &Field, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New);
-
- void type_of_call extrap_onestep_rungekutta
- (Double_t &Charge, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New);
+#include <Riostream.h>
+#include <TMath.h>
+#include <TMatrixD.h>
- void type_of_call gufld_double(Double_t *Position, Double_t *Field) {
- // 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];
- }
-}
+/// \cond CLASSIMP
+ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
+/// \endcond
//_________________________________________________________________________
AliMUONTrackParam::AliMUONTrackParam()
- : TObject()
+ : TObject(),
+ fNonBendingCoor(0.),
+ fNonBendingSlope(0.),
+ fBendingCoor(0.),
+ fBendingSlope(0.),
+ fInverseBendingMomentum(0.),
+ fZ(0.),
+ fCovariances(0x0),
+ fHitForRecPtr(0x0)
{
-// Constructor
+ /// Constructor
+}
- fInverseBendingMomentum = 0;
- fBendingSlope = 0;
- fNonBendingSlope = 0;
- fZ = 0;
- fBendingCoor = 0;
- fNonBendingCoor = 0;
+ //_________________________________________________________________________
+AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam)
+ : TObject(theMUONTrackParam),
+ fNonBendingCoor(theMUONTrackParam.fNonBendingCoor),
+ fNonBendingSlope(theMUONTrackParam.fNonBendingSlope),
+ fBendingCoor(theMUONTrackParam.fBendingCoor),
+ fBendingSlope(theMUONTrackParam.fBendingSlope),
+ fInverseBendingMomentum(theMUONTrackParam.fInverseBendingMomentum),
+ fZ(theMUONTrackParam.fZ),
+ fCovariances(0x0),
+ fHitForRecPtr(theMUONTrackParam.fHitForRecPtr)
+{
+ /// Copy constructor
+ if (theMUONTrackParam.fCovariances) fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
}
//_________________________________________________________________________
-AliMUONTrackParam&
-AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam)
+AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& theMUONTrackParam)
{
+ /// 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;
-
+ fNonBendingCoor = theMUONTrackParam.fNonBendingCoor;
+ fNonBendingSlope = theMUONTrackParam.fNonBendingSlope;
+ fBendingCoor = theMUONTrackParam.fBendingCoor;
+ fBendingSlope = theMUONTrackParam.fBendingSlope;
+ fInverseBendingMomentum = theMUONTrackParam.fInverseBendingMomentum;
+ fZ = theMUONTrackParam.fZ;
+
+ if (theMUONTrackParam.fCovariances) {
+ if (fCovariances) *fCovariances = *(theMUONTrackParam.fCovariances);
+ else fCovariances = new TMatrixD(*(theMUONTrackParam.fCovariances));
+ } else if (fCovariances) {
+ delete fCovariances;
+ fCovariances = 0x0;
+ }
+
return *this;
}
- //_________________________________________________________________________
-AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& theMUONTrackParam)
- : TObject(theMUONTrackParam)
+
+ //__________________________________________________________________________
+AliMUONTrackParam::~AliMUONTrackParam()
{
- fInverseBendingMomentum = theMUONTrackParam.fInverseBendingMomentum;
- fBendingSlope = theMUONTrackParam.fBendingSlope;
- fNonBendingSlope = theMUONTrackParam.fNonBendingSlope;
- fZ = theMUONTrackParam.fZ;
- fBendingCoor = theMUONTrackParam.fBendingCoor;
- fNonBendingCoor = theMUONTrackParam.fNonBendingCoor;
+/// Destructor
+ DeleteCovariances();
}
//__________________________________________________________________________
-void AliMUONTrackParam::ExtrapToZ(Double_t Z)
+void AliMUONTrackParam::SetTrackParam(AliMUONTrackParam& theMUONTrackParam)
{
- // 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 ????
- // extrap_onestep_rungekutta(chargeExtrap, stepLength, vGeant3, vGeant3New);
- extrap_onestep_helix(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];}
- }
- // check maxStepNumber ????
- // Interpolation back to exact Z (2nd order)
- // should be in function ???? using TArray ????
- Double_t dZ12 = vGeant3New[2] - vGeant3[2]; // 1->2
- 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
- // Track parameters from Geant3 parameters,
- // with charge back for forward motion
- GetFromGeant3Parameters(vGeant3, chargeExtrap * forwardBackward);
+ /// Set track parameters from "TrackParam" leaving pointer to fHitForRecPtr and parameter covariances unchanged
+ fNonBendingCoor = theMUONTrackParam.fNonBendingCoor;
+ fNonBendingSlope = theMUONTrackParam.fNonBendingSlope;
+ fBendingCoor = theMUONTrackParam.fBendingCoor;
+ fBendingSlope = theMUONTrackParam.fBendingSlope;
+ fInverseBendingMomentum = theMUONTrackParam.fInverseBendingMomentum;
+ fZ = theMUONTrackParam.fZ;
}
//__________________________________________________________________________
-void AliMUONTrackParam::SetGeant3Parameters(Double_t *VGeant3, Double_t ForwardBackward)
+AliMUONHitForRec* AliMUONTrackParam::GetHitForRecPtr(void) 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 pointer to HitForRec attached to the current TrackParam
+/// this method should not be called when fHitForRecPtr == NULL
+ if (!fHitForRecPtr) AliWarning("fHitForRecPtr == NULL");
+ return fHitForRecPtr;
}
- //__________________________________________________________________________
-void AliMUONTrackParam::GetFromGeant3Parameters(Double_t *VGeant3, Double_t Charge)
+ //_________________________________________________________________________
+void AliMUONTrackParam::GetParamFrom(const AliESDMuonTrack& esdMuonTrack)
{
- // 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];
+ /// assigned value form ESD track.
+ fInverseBendingMomentum = esdMuonTrack.GetInverseBendingMomentum();
+ fBendingSlope = TMath::Tan(esdMuonTrack.GetThetaY());
+ fNonBendingSlope = TMath::Tan(esdMuonTrack.GetThetaX());
+ fZ = esdMuonTrack.GetZ();
+ fBendingCoor = esdMuonTrack.GetBendingCoor();
+ fNonBendingCoor = esdMuonTrack.GetNonBendingCoor();
}
- //__________________________________________________________________________
-void AliMUONTrackParam::ExtrapToStation(Int_t Station, AliMUONTrackParam *TrackParam)
+ //_________________________________________________________________________
+void AliMUONTrackParam::SetParamFor(AliESDMuonTrack& esdMuonTrack)
{
- // 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
- AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON"); // necessary ????
- // range of Station to be checked ????
- z1 = (&(pMUON->Chamber(2 * Station)))->Z(); // Z of first chamber
- z2 = (&(pMUON->Chamber(2 * Station + 1)))->Z(); // Z of second chamber
- // 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;
+ /// assigned value form ESD track.
+ esdMuonTrack.SetInverseBendingMomentum(fInverseBendingMomentum);
+ esdMuonTrack.SetThetaX(TMath::ATan(fNonBendingSlope));
+ esdMuonTrack.SetThetaY(TMath::ATan(fBendingSlope));
+ esdMuonTrack.SetZ(fZ);
+ esdMuonTrack.SetBendingCoor(fBendingCoor);
+ esdMuonTrack.SetNonBendingCoor(fNonBendingCoor);
}
- //__________________________________________________________________________
-void AliMUONTrackParam::ExtrapToVertex()
+ //_________________________________________________________________________
+void AliMUONTrackParam::GetParamFromUncorrected(const AliESDMuonTrack& esdMuonTrack)
{
- // 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();
- // Makes a simple magnetic field correction through the absorber
- FieldCorrection(zAbsorber);
+ /// assigned value form ESD track.
+ fInverseBendingMomentum = esdMuonTrack.GetInverseBendingMomentumUncorrected();
+ fBendingSlope = TMath::Tan(esdMuonTrack.GetThetaYUncorrected());
+ fNonBendingSlope = TMath::Tan(esdMuonTrack.GetThetaXUncorrected());
+ fZ = esdMuonTrack.GetZUncorrected();
+ fBendingCoor = esdMuonTrack.GetBendingCoorUncorrected();
+ fNonBendingCoor = esdMuonTrack.GetNonBendingCoorUncorrected();
}
+ //_________________________________________________________________________
+void AliMUONTrackParam::SetParamForUncorrected(AliESDMuonTrack& esdMuonTrack)
+{
+ /// assigned value form ESD track.
+ esdMuonTrack.SetInverseBendingMomentumUncorrected(fInverseBendingMomentum);
+ esdMuonTrack.SetThetaXUncorrected(TMath::ATan(fNonBendingSlope));
+ esdMuonTrack.SetThetaYUncorrected(TMath::ATan(fBendingSlope));
+ esdMuonTrack.SetZUncorrected(fZ);
+ esdMuonTrack.SetBendingCoorUncorrected(fBendingCoor);
+ esdMuonTrack.SetNonBendingCoorUncorrected(fNonBendingCoor);
+}
-// 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;
+Double_t AliMUONTrackParam::Px() const
+{
+ /// return p_x from track parameters
+ 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;
+}
-// if (radiusEndAbsorber2 > rLimit*rLimit) {
-// zEndAbsorber = z1[9];
-// zBP = zBP1;
-// } else {
-// zEndAbsorber = z2[3];
-// zBP = zBP2;
-// }
+ //__________________________________________________________________________
+Double_t AliMUONTrackParam::Py() const
+{
+ /// return p_y from track parameters
+ 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;
+}
-// xBP = xEndAbsorber - (pX / pZ) * (zEndAbsorber - zBP);
-// yBP = yEndAbsorber - (pY / pZ) * (zEndAbsorber - zBP);
+ //__________________________________________________________________________
+Double_t AliMUONTrackParam::Pz() const
+{
+ /// return p_z from track parameters
+ 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;
+}
-// // 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;
+ //__________________________________________________________________________
+Double_t AliMUONTrackParam::P() const
+{
+ /// return p from track parameters
+ 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;
-// 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()
+ //__________________________________________________________________________
+TMatrixD* AliMUONTrackParam::GetCovariances()
{
- // 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 ????
- 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;
+ /// Return the covariance matrix (create it before if needed)
+ if (!fCovariances) {
+ fCovariances = new TMatrixD(5,5);
+ (*fCovariances) = 0;
}
-
- pYZ = TMath::Abs(1.0 / fInverseBendingMomentum);
- sign = 1;
- if (fInverseBendingMomentum < 0) sign = -1;
- pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro (z<0)
- 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) {
- zBP = zBP1;
- } else {
- zBP = zBP2;
+ return fCovariances;
}
- 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 / TMath::Sqrt(xBP * xBP + yBP * yBP + zSmear * zSmear);
- pX = pZ * xBP / zSmear;
- pY = pZ * yBP / zSmear;
- 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);
+ //__________________________________________________________________________
+void AliMUONTrackParam::SetCovariances(TMatrixD* covariances)
+{
+ /// Set the covariance matrix
+ if (covariances == fCovariances) return; // nothing to be done
+ if (fCovariances) *fCovariances = *covariances;
+ else fCovariances = new TMatrixD(*covariances);
+}
- fInverseBendingMomentum = (sign / pTotal) *
- TMath::Sqrt(1.0 +
- fBendingSlope * fBendingSlope +
- fNonBendingSlope * fNonBendingSlope) /
- TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope);
+ //__________________________________________________________________________
+void AliMUONTrackParam::SetCovariances(Double_t matrix[5][5])
+{
+ /// Set the covariance matrix
+ if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
+ else fCovariances = new TMatrixD(5,5,&(matrix[0][0]));
+}
- // vertex position at (0,0,0)
- // should be taken from vertex measurement ???
- fBendingCoor = 0.0;
- fNonBendingCoor = 0;
- fZ= 0;
+ //__________________________________________________________________________
+void AliMUONTrackParam::SetVariances(Double_t matrix[5][5])
+{
+ /// Set the diagonal terms of the covariance matrix (variances)
+ if (!fCovariances) fCovariances = new TMatrixD(5,5);
+ (*fCovariances) = 0;
+ for (Int_t i=0; i<5; i++) (*fCovariances)(i,i) = matrix[i][i];
}
//__________________________________________________________________________
-Double_t AliMUONTrackParam::TotalMomentumEnergyLoss(Double_t thetaLimit, Double_t pTotal, Double_t theta)
+void AliMUONTrackParam::DeleteCovariances()
{
- // 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;
+ /// Delete the covariance matrix
+ if (fCovariances) delete fCovariances;
+ fCovariances = 0x0;
+}
- // 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;
- }
- } else {
- if (pTotal < 20) {
- deltaP = 2.1207 + 0.05478 * pTotal - 0.00145079 * pTotal * pTotal;
- } else {
- deltaP = 2.6069 + 0.0051705 * pTotal;
- }
+ //__________________________________________________________________________
+void AliMUONTrackParam::EvalCovariances(AliMUONHitForRec* hit2)
+{
+ /// Evaluate covariances assuming the track is only a straight line
+ /// between the HitForRec attached to the current TrackParam and hit2.
+ /// Nothing can be done on fInverseBendingMomentum (-> 50% err).
+
+ // Allocate memory if needed
+ if (!fCovariances) fCovariances = new TMatrixD(5,5);
+
+ // Reset the covariance matrix
+ (*fCovariances) = 0;
+
+ if (!fHitForRecPtr) {
+ AliWarning("fHitForRecPtr == NULL: cannot calculate TrackParam covariances");
+ return;
}
- pTotalCorrected = pTotal + deltaP / TMath::Cos(theta);
- return pTotalCorrected;
+
+ Double_t dz = fHitForRecPtr->GetZ() - hit2->GetZ();
+
+ // Non bending plane
+ (*fCovariances)(0,0) = fHitForRecPtr->GetNonBendingReso2();
+ (*fCovariances)(0,1) = fHitForRecPtr->GetNonBendingReso2() / dz;
+ (*fCovariances)(1,0) = (*fCovariances)(0,1);
+ (*fCovariances)(1,1) = ( fHitForRecPtr->GetNonBendingReso2() + hit2->GetNonBendingReso2() ) / dz / dz;
+ // Bending plane
+ (*fCovariances)(2,2) = fHitForRecPtr->GetBendingReso2();
+ (*fCovariances)(2,3) = fHitForRecPtr->GetBendingReso2() / dz;
+ (*fCovariances)(3,2) = (*fCovariances)(2,3);
+ (*fCovariances)(3,3) = ( fHitForRecPtr->GetBendingReso2() + hit2->GetBendingReso2() ) / dz / dz;
+ // Inverse bending momentum
+ (*fCovariances)(4,4) = 0.5*fInverseBendingMomentum * 0.5*fInverseBendingMomentum; // error 50%
+
}
//__________________________________________________________________________
-void AliMUONTrackParam::FieldCorrection(Double_t Z)
+Int_t AliMUONTrackParam::Compare(const TObject* trackParam) const
{
- //
- // 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 = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0)
- pX = pZ * fNonBendingSlope;
- pY = pZ * fBendingSlope;
- 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;
+ /// "Compare" function to sort with decreasing Z (spectro. muon Z <0).
+ /// Returns 1 (0, -1) if Z of current TrackHit
+ /// is smaller than (equal to, larger than) Z of TrackHit
+ if (fHitForRecPtr) {
+ if (fHitForRecPtr->GetZ() != fZ)
+ AliWarning("track parameters are given at a different z position than the one of the corresponding hit");
+ }
+ if (fZ < ((AliMUONTrackParam*)trackParam)->GetZ()) return(1);
+ else if (fZ == ((AliMUONTrackParam*)trackParam)->GetZ()) return(0);
+ else return(-1);
+}
- // 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);
+//_____________________________________________-
+void AliMUONTrackParam::Print(Option_t* opt) const
+{
+ /// Printing TrackParam information
+ /// "full" option for printing all the information about the TrackParam
+ TString sopt(opt);
+ sopt.ToUpper();
+ if ( sopt.Contains("FULL") ) {
+ cout << "<AliMUONTrackParam> 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() <<
+ ") cm, (px,py,pz)=(" << setw(5) << setprecision(3) << Px() <<
+ "," << setw(5) << setprecision(3) << Py() <<
+ "," << setw(5) << setprecision(3) << Pz() << ") GeV/c" << endl;
+ }
+ else {
+ cout << "<AliMUONTrackParam>" << endl;
+ }
+
}