#include <TMath.h>
#include <TH1F.h>
#include <TGeoManager.h>
+#include <TGeoMatrix.h>
#include "AliMagF.h"
#include "AliTracker.h"
#include "AliGeomManager.h"
#include "AliCluster.h"
#include "AliKalmanTrack.h"
+#include "AliGlobalQADataMaker.h"
extern TGeoManager *gGeoManager;
-Bool_t AliTracker::fgUniformField=kTRUE;
-Double_t AliTracker::fgBz=kAlmost0Field;
-const AliMagF *AliTracker::fgkFieldMap=0;
Bool_t AliTracker::fFillResiduals=kFALSE;
-TObjArray *AliTracker::fResiduals=0;
+TObjArray **AliTracker::fResiduals=NULL;
+AliRecoParam::EventSpecie_t AliTracker::fEventSpecie=AliRecoParam::kDefault;
ClassImp(AliTracker)
fZ(0),
fSigmaX(0.005),
fSigmaY(0.005),
- fSigmaZ(0.010)
+ fSigmaZ(0.010),
+ fEventInfo(NULL)
{
//--------------------------------------------------------------------
// The default constructor.
//--------------------------------------------------------------------
- if (!fgkFieldMap) AliWarning("Field map is not set. Call AliTracker::SetFieldMap before creating a tracker!");
+ if (!TGeoGlobalMagField::Instance()->GetField())
+ AliWarning("Field map is not set.");
}
//__________________________________________________________________________
fZ(atr.fZ),
fSigmaX(atr.fSigmaX),
fSigmaY(atr.fSigmaY),
- fSigmaZ(atr.fSigmaZ)
+ fSigmaZ(atr.fSigmaZ),
+ fEventInfo(atr.fEventInfo)
{
//--------------------------------------------------------------------
// The default constructor.
//--------------------------------------------------------------------
- if (!fgkFieldMap) AliWarning("Field map is not set. Call AliTracker::SetFieldMap before creating a tracker!");
+ if (!TGeoGlobalMagField::Instance()->GetField())
+ AliWarning("Field map is not set.");
}
//__________________________________________________________________________
-void AliTracker::SetFieldMap(const AliMagF* map, Bool_t uni) {
- //--------------------------------------------------------------------
- //This passes the field map to the reconstruction.
- //--------------------------------------------------------------------
- if (map==0) AliFatalClass("Can't access the field map !");
+Double_t AliTracker::GetBz()
+{
+ AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+ if (!fld) return 0.5*kAlmost0Field;
+ Double_t bz = fld->SolenoidField();
+ return TMath::Sign(0.5*kAlmost0Field,bz) + bz;
+}
+
+//__________________________________________________________________________
+Double_t AliTracker::GetBz(const Double_t *r) {
+ //------------------------------------------------------------------
+ // Returns Bz (kG) at the point "r" .
+ //------------------------------------------------------------------
+ AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+ if (!fld) return 0.5*kAlmost0Field;
+ Double_t bz = fld->GetBz(r);
+ return TMath::Sign(0.5*kAlmost0Field,bz) + bz;
+}
- if (fgkFieldMap) {
- AliWarningClass("The magnetic field map has been already set !");
+//__________________________________________________________________________
+void AliTracker::GetBxByBz(const Double_t r[3], Double_t b[3]) {
+ //------------------------------------------------------------------
+ // Returns Bx, By and Bz (kG) at the point "r" .
+ //------------------------------------------------------------------
+ AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+ if (!fld) {
+ b[0] = b[1] = 0.;
+ b[2] = 0.5*kAlmost0Field;
return;
}
- fgUniformField=uni;
- fgkFieldMap=map;
+ if (fld->IsUniform()) {
+ b[0] = b[1] = 0.;
+ b[2] = fld->SolenoidField();
+ } else {
+ fld->Field(r,b);
+ }
+ b[2] = (TMath::Sign(0.5*kAlmost0Field,b[2]) + b[2]);
+ return;
+}
- //Float_t r[3]={0.,0.,0.},b[3]; map->Field(r,b);
- //Double_t bz=-b[2];
-
- Double_t bz=-map->SolenoidField();
- fgBz=TMath::Sign(kAlmost0Field,bz) + bz;
+//__________________________________________________________________________
+void AliTracker::FillClusterArray(TObjArray* /*array*/) const
+{
+ // Publishes all pointers to clusters known to the tracker into the
+ // passed object array.
+ // The ownership is not transfered - the caller is not expected to delete
+ // the clusters.
+ AliWarning("should be overriden by a sub-class.");
}
//__________________________________________________________________________
//This function "cooks" a track label. If label<0, this track is fake.
//--------------------------------------------------------------------
Int_t noc=t->GetNumberOfClusters();
+ if (noc<1) return;
Int_t *lb=new Int_t[noc];
Int_t *mx=new Int_t[noc];
AliCluster **clusters=new AliCluster*[noc];
}
}
-Double_t AliTracker::GetBz(Float_t *r) {
- //------------------------------------------------------------------
- // Returns Bz (kG) at the point "r" .
- //------------------------------------------------------------------
- Float_t b[3]; fgkFieldMap->Field(r,b);
- Double_t bz=-Double_t(b[2]);
- return (TMath::Sign(kAlmost0Field,bz) + bz);
-}
-
-Double_t
-AliTracker::MeanMaterialBudget(Double_t *start,Double_t *end,Double_t *mparam)
+Double_t AliTracker::MeanMaterialBudget(const Double_t *start, const Double_t *end, Double_t *mparam)
{
//
// Calculate mean material budget and material properties between
Bool_t
AliTracker::PropagateTrackTo(AliExternalTrackParam *track, Double_t xToGo,
-Double_t mass, Double_t maxStep, Bool_t rotateTo, Double_t maxSnp){
+ Double_t mass, Double_t maxStep, Bool_t rotateTo, Double_t maxSnp, Double_t sign){
//----------------------------------------------------------------
//
// Propagates the track to the plane X=xk (cm) using the magnetic field map
if (!track->PropagateTo(x,bz)) return kFALSE;
MeanMaterialBudget(xyz0,xyz1,param);
- Double_t xrho=param[0]*param[4], xx0=param[1];
+ Double_t xrho=param[0]*param[4]*sign, xx0=param[1];
if (!track->CorrectForMeanMaterial(xx0,xrho,mass)) return kFALSE;
if (rotateTo){
//
Double_t ca=TMath::Cos(alphan-track->GetAlpha()),
sa=TMath::Sin(alphan-track->GetAlpha());
- Double_t sf=track->GetSnp(), cf=TMath::Sqrt(1.- sf*sf);
+ Double_t sf=track->GetSnp(), cf=TMath::Sqrt((1.-sf)*(1.+sf));
+ Double_t sinNew = sf*ca - cf*sa;
+ if (TMath::Abs(sinNew) >= maxSnp) return kFALSE;
+ if (!track->Rotate(alphan)) return kFALSE;
+ }
+ xpos = track->GetX();
+ }
+ return kTRUE;
+}
+
+Bool_t
+AliTracker::PropagateTrackToBxByBz(AliExternalTrackParam *track,
+Double_t xToGo,
+ Double_t mass, Double_t maxStep, Bool_t rotateTo, Double_t maxSnp,Double_t sign){
+ //----------------------------------------------------------------
+ //
+ // Propagates the track to the plane X=xk (cm)
+ // taking into account all the three components of the magnetic field
+ // and correcting for the crossed material.
+ //
+ // mass - mass used in propagation - used for energy loss correction
+ // maxStep - maximal step for propagation
+ //
+ // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
+ //
+ //----------------------------------------------------------------
+ const Double_t kEpsilon = 0.00001;
+ Double_t xpos = track->GetX();
+ Double_t dir = (xpos<xToGo) ? 1.:-1.;
+ //
+ while ( (xToGo-xpos)*dir > kEpsilon){
+ Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep);
+ Double_t x = xpos+step;
+ Double_t xyz0[3],xyz1[3],param[7];
+ track->GetXYZ(xyz0); //starting global position
+
+ Double_t b[3]; GetBxByBz(xyz0,b); // getting the local Bx, By and Bz
+
+ if (!track->GetXYZAt(x,b[2],xyz1)) return kFALSE; // no prolongation
+ xyz1[2]+=kEpsilon; // waiting for bug correction in geo
+
+ if (TMath::Abs(track->GetSnpAt(x,b[2])) >= maxSnp) return kFALSE;
+ if (!track->PropagateToBxByBz(x,b)) return kFALSE;
+
+ MeanMaterialBudget(xyz0,xyz1,param);
+ Double_t xrho=param[0]*param[4]*sign, xx0=param[1];
+
+ if (!track->CorrectForMeanMaterial(xx0,xrho,mass)) return kFALSE;
+ if (rotateTo){
+ if (TMath::Abs(track->GetSnp()) >= maxSnp) return kFALSE;
+ track->GetXYZ(xyz0); // global position
+ Double_t alphan = TMath::ATan2(xyz0[1], xyz0[0]);
+ //
+ Double_t ca=TMath::Cos(alphan-track->GetAlpha()),
+ sa=TMath::Sin(alphan-track->GetAlpha());
+ Double_t sf=track->GetSnp(), cf=TMath::Sqrt((1.-sf)*(1.+sf));
Double_t sinNew = sf*ca - cf*sa;
if (TMath::Abs(sinNew) >= maxSnp) return kFALSE;
if (!track->Rotate(alphan)) return kFALSE;
if (!residuals) return;
TH1F *h=0;
+ Int_t esIndex = AliRecoParam::AConvert(fEventSpecie) ;
AliGeomManager::ELayerID layer=AliGeomManager::VolUIDToLayer(id);
- h=(TH1F*)fResiduals->At(2*layer-2);
+ h=(TH1F*)fResiduals[esIndex]->At(2*layer-2);
h->Fill(residuals[0]);
- h=(TH1F*)fResiduals->At(2*layer-1);
+ h=(TH1F*)fResiduals[esIndex]->At(2*layer-1);
h->Fill(residuals[1]);
+
+ if (layer==5) {
+ if (p[1]<0) { // SSD1 absolute residuals
+ ((TH1F*)fResiduals[esIndex]->At(40))->Fill(t->GetY()-p[0]); //C side
+ ((TH1F*)fResiduals[esIndex]->At(41))->Fill(t->GetZ()-p[1]);
+ } else {
+ ((TH1F*)fResiduals[esIndex]->At(42))->Fill(t->GetY()-p[0]); //A side
+ ((TH1F*)fResiduals[esIndex]->At(43))->Fill(t->GetZ()-p[1]);
+ }
+ }
+ if (layer==6) { // SSD2 absolute residuals
+ if (p[1]<0) {
+ ((TH1F*)fResiduals[esIndex]->At(44))->Fill(t->GetY()-p[0]); //C side
+ ((TH1F*)fResiduals[esIndex]->At(45))->Fill(t->GetZ()-p[1]);
+ } else {
+ ((TH1F*)fResiduals[esIndex]->At(46))->Fill(t->GetY()-p[0]); //A side
+ ((TH1F*)fResiduals[esIndex]->At(47))->Fill(t->GetZ()-p[1]);
+ }
+ }
+
}
+void AliTracker::FillResiduals(const AliExternalTrackParam *t,
+ const AliCluster *c, Bool_t /*updated*/) {
+ //
+ // This function fills the histograms of residuals
+ // The array of these histos is external for this AliTracker class.
+ // Normally, this array belong to AliGlobalQADataMaker class.
+ //
+ // For the moment, the residuals are absolute !
+ //
+
+ if (!fFillResiduals) return;
+ if (!fResiduals) return;
+
+ UShort_t id=c->GetVolumeId();
+ const TGeoHMatrix *matrixT2L=AliGeomManager::GetTracking2LocalMatrix(id);
+
+ // Position of the cluster in the tracking c.s.
+ Double_t clsTrk[3]={c->GetX(), c->GetY(), c->GetZ()};
+ // Position of the cluster in the local module c.s.
+ Double_t clsLoc[3]={0.,0.,0.};
+ matrixT2L->LocalToMaster(clsTrk,clsLoc);
+
+
+ // Position of the intersection point in the tracking c.s.
+ Double_t trkTrk[3]={t->GetX(),t->GetY(),t->GetZ()};
+ // Position of the intersection point in the local module c.s.
+ Double_t trkLoc[3]={0.,0.,0.};
+ matrixT2L->LocalToMaster(trkTrk,trkLoc);
+
+ Double_t residuals[2]={trkLoc[0]-clsLoc[0], trkLoc[2]-clsLoc[2]};
+
+ TH1F *h=0;
+ Int_t esIndex = AliRecoParam::AConvert(fEventSpecie) ;
+ AliGeomManager::ELayerID layer=AliGeomManager::VolUIDToLayer(id);
+ h=(TH1F*)fResiduals[esIndex]->At(2*layer-2);
+ h->Fill(residuals[0]);
+ h=(TH1F*)fResiduals[esIndex]->At(2*layer-1);
+ h->Fill(residuals[1]);
+
+}