#include <TGeoManager.h>
#include <TGeoMatrix.h>
+#include "AliLog.h"
#include "AliMagF.h"
#include "AliTracker.h"
#include "AliGeomManager.h"
#include "AliCluster.h"
#include "AliKalmanTrack.h"
+#include "AliGlobalQADataMaker.h"
extern TGeoManager *gGeoManager;
fZ(0),
fSigmaX(0.005),
fSigmaY(0.005),
- fSigmaZ(0.010)
+ fSigmaZ(0.010),
+ fEventInfo(NULL)
{
//--------------------------------------------------------------------
// The default constructor.
fZ(atr.fZ),
fSigmaX(atr.fSigmaX),
fSigmaY(atr.fSigmaY),
- fSigmaZ(atr.fSigmaZ)
+ fSigmaZ(atr.fSigmaZ),
+ fEventInfo(atr.fEventInfo)
{
//--------------------------------------------------------------------
// The default constructor.
Double_t AliTracker::GetBz()
{
AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
- if (!fld) return kAlmost0Field;
+ if (!fld) return 0.5*kAlmost0Field;
Double_t bz = fld->SolenoidField();
- return TMath::Sign(kAlmost0Field,bz) + bz;
+ return TMath::Sign(0.5*kAlmost0Field,bz) + bz;
}
//__________________________________________________________________________
// Returns Bz (kG) at the point "r" .
//------------------------------------------------------------------
AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
- if (!fld) return kAlmost0Field;
+ if (!fld) return 0.5*kAlmost0Field;
Double_t bz = fld->GetBz(r);
- return TMath::Sign(kAlmost0Field,bz) + bz;
+ return TMath::Sign(0.5*kAlmost0Field,bz) + bz;
+}
+
+//__________________________________________________________________________
+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;
+ }
+
+ 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;
}
//__________________________________________________________________________
for (Int_t i=0;i<6;i++) bparam[i]=0;
if (!gGeoManager) {
- printf("ERROR: no TGeo\n");
+ AliErrorClass("No TGeo\n");
return 0.;
}
//
// Initialize start point and direction
TGeoNode *currentnode = 0;
TGeoNode *startnode = gGeoManager->InitTrack(start, dir);
- //printf("%s length=%f\n",gGeoManager->GetPath(),length);
if (!startnode) {
AliErrorClass(Form("start point out of geometry: x %f, y %f, z %f",
start[0],start[1],start[2]));
if (nzero>3) {
// This means navigation has problems on one boundary
// Try to cross by making a small step
- printf("ERROR: cannot cross boundary\n");
+ AliErrorClass("Cannot cross boundary\n");
mparam[0] = bparam[0]/step;
mparam[1] = bparam[1];
mparam[2] = bparam[2]/step;
if (snext>=length) break;
if (!currentnode) break;
length -= snext;
- //printf("%s snext=%f length=%f\n", currentnode->GetName(),snext,length);
material = currentnode->GetVolume()->GetMedium()->GetMaterial();
lparam[0] = material->GetDensity();
lparam[1] = material->GetRadLen();
lparam[2] = material->GetA();
lparam[3] = material->GetZ();
- //printf(" %f %f %f %f\n",lparam[0],lparam[1],lparam[2],lparam[3]);
lparam[5] = lparam[3]/lparam[2];
if (material->IsMixture()) {
TGeoMixture * mixture = (TGeoMixture*)material;
}
gGeoManager->FindNextBoundaryAndStep(length, kFALSE);
snext = gGeoManager->GetStep();
- //printf("snext %f\n",snext);
}
mparam[0] = bparam[0]/step;
mparam[1] = bparam[1];
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){
+ 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;
+ }
+ 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 (!residuals) return;
TH1F *h=0;
+ Int_t esIndex = AliRecoParam::AConvert(fEventSpecie) ;
AliGeomManager::ELayerID layer=AliGeomManager::VolUIDToLayer(id);
- h=(TH1F*)fResiduals[fEventSpecie]->At(2*layer-2);
- h->Fill(residuals[0]);
- h=(TH1F*)fResiduals[fEventSpecie]->At(2*layer-1);
- h->Fill(residuals[1]);
+ h=(TH1F*)fResiduals[esIndex]->At(2*layer-2);
+ if (h) h->Fill(residuals[0]);
+ h=(TH1F*)fResiduals[esIndex]->At(2*layer-1);
+ if (h) h->Fill(residuals[1]);
if (layer==5) {
if (p[1]<0) { // SSD1 absolute residuals
- ((TH1F*)fResiduals[fEventSpecie]->At(40))->Fill(t->GetY()-p[0]); //C side
- ((TH1F*)fResiduals[fEventSpecie]->At(41))->Fill(t->GetZ()-p[1]);
+ h = (TH1F*)fResiduals[esIndex]->At(40);
+ if (h) h->Fill(t->GetY()-p[0]); //C side
+ h = (TH1F*)fResiduals[esIndex]->At(41);
+ if (h) h->Fill(t->GetZ()-p[1]);
} else {
- ((TH1F*)fResiduals[fEventSpecie]->At(42))->Fill(t->GetY()-p[0]); //A side
- ((TH1F*)fResiduals[fEventSpecie]->At(43))->Fill(t->GetZ()-p[1]);
+ h = (TH1F*)fResiduals[esIndex]->At(42);
+ if (h) h->Fill(t->GetY()-p[0]); //A side
+ h = (TH1F*)fResiduals[esIndex]->At(43);
+ if (h) h->Fill(t->GetZ()-p[1]);
}
}
if (layer==6) { // SSD2 absolute residuals
if (p[1]<0) {
- ((TH1F*)fResiduals[fEventSpecie]->At(44))->Fill(t->GetY()-p[0]); //C side
- ((TH1F*)fResiduals[fEventSpecie]->At(45))->Fill(t->GetZ()-p[1]);
+ h = (TH1F*)fResiduals[esIndex]->At(44);
+ if (h) h->Fill(t->GetY()-p[0]); //C side
+ h = (TH1F*)fResiduals[esIndex]->At(45);
+ if (h) h->Fill(t->GetZ()-p[1]);
} else {
- ((TH1F*)fResiduals[fEventSpecie]->At(46))->Fill(t->GetY()-p[0]); //A side
- ((TH1F*)fResiduals[fEventSpecie]->At(47))->Fill(t->GetZ()-p[1]);
+ h = (TH1F*)fResiduals[esIndex]->At(46);
+ if (h) h->Fill(t->GetY()-p[0]); //A side
+ h = (TH1F*)fResiduals[esIndex]->At(47);
+ if (h) h->Fill(t->GetZ()-p[1]);
}
}
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[fEventSpecie]->At(2*layer-2);
- h->Fill(residuals[0]);
- h=(TH1F*)fResiduals[fEventSpecie]->At(2*layer-1);
- h->Fill(residuals[1]);
+ h=(TH1F*)fResiduals[esIndex]->At(2*layer-2);
+ if (h) h->Fill(residuals[0]);
+ h=(TH1F*)fResiduals[esIndex]->At(2*layer-1);
+ if (h) h->Fill(residuals[1]);
+
+}
+
+Double_t AliTracker::GetTrackPredictedChi2(AliExternalTrackParam *track,
+ Double_t mass, Double_t step,
+ const AliExternalTrackParam *backup) {
+ //
+ // This function brings the "track" with particle "mass" [GeV]
+ // to the same local coord. system and the same reference plane as
+ // of the "backup", doing it in "steps" [cm].
+ // Then, it calculates the 5D predicted Chi2 for these two tracks
+ //
+ Double_t chi2=kVeryBig;
+ Double_t alpha=backup->GetAlpha();
+ if (!track->Rotate(alpha)) return chi2;
+
+ Double_t xb=backup->GetX();
+ Double_t sign=(xb < track->GetX()) ? 1. : -1.;
+ if (!PropagateTrackTo(track,xb,mass,step,kFALSE,kAlmost1,sign)) return chi2;
+
+ chi2=track->GetPredictedChi2(backup);
+ return chi2;
}