X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITStrackerMI.cxx;h=fc0d275b1b72354310c29dcd03c91bc449de2b2a;hb=12d3cd377dc08ab5d3f78f9281c07b8536b010ab;hp=507241f33f8a083fc068d4ef0eeb4daabf58ddf2;hpb=67c1e97925a8196f5b019d7d23d3cdab2e8207a6;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITStrackerMI.cxx b/ITS/AliITStrackerMI.cxx index 507241f33f8..fc0d275b1b7 100644 --- a/ITS/AliITStrackerMI.cxx +++ b/ITS/AliITStrackerMI.cxx @@ -1,5 +1,5 @@ /************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * @@ -12,59 +12,148 @@ * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ - /* $Id$ */ //------------------------------------------------------------------------- // Implementation of the ITS tracker class -// It reads AliITSclusterV2 clusters and creates AliITStrackMI tracks +// It reads AliITSRecPoint clusters and creates AliITStrackMI tracks // and fills with them the ESD // Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch -// dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch -// +// Current support and development: +// Andrea Dainese, andrea.dainese@lnl.infn.it +// dE/dx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch +// Params moved to AliITSRecoParam by: Andrea Dainese, INFN +// Material budget from TGeo by: Ludovic Gaudichet & Andrea Dainese, INFN //------------------------------------------------------------------------- #include #include +#include +#include +#include #include -#include -#include "AliESD.h" -#include "AliESDV0MI.h" + +#include "AliLog.h" +#include "AliITSPlaneEff.h" +#include "AliITSCalibrationSPD.h" +#include "AliITSCalibrationSDD.h" +#include "AliITSCalibrationSSD.h" +#include "AliCDBEntry.h" +#include "AliCDBManager.h" +#include "AliAlignObj.h" +#include "AliTrackPointArray.h" +#include "AliESDVertex.h" +#include "AliESDEvent.h" +#include "AliESDtrack.h" +#include "AliV0.h" #include "AliHelix.h" -#include "AliITSclusterV2.h" -#include "AliITSgeom.h" +#include "AliITSChannelStatus.h" +#include "AliITSDetTypeRec.h" +#include "AliITSRecPoint.h" +#include "AliITSgeomTGeo.h" +#include "AliITSReconstructor.h" +#include "AliITSClusterParam.h" +#include "AliITSsegmentation.h" +#include "AliITSCalibration.h" +#include "AliITSPlaneEffSPD.h" +#include "AliITSPlaneEffSDD.h" +#include "AliITSPlaneEffSSD.h" +#include "AliITSV0Finder.h" #include "AliITStrackerMI.h" ClassImp(AliITStrackerMI) - - -AliITStrackerMI::AliITSlayer AliITStrackerMI::fgLayers[kMaxLayer]; // ITS layers - -AliITStrackerMI::AliITStrackerMI(const AliITSgeom *geom) : AliTracker() { +AliITStrackerMI::AliITSlayer AliITStrackerMI::fgLayers[AliITSgeomTGeo::kNLayers]; // ITS layers + +AliITStrackerMI::AliITStrackerMI():AliTracker(), +fI(0), +fBestTrack(), +fTrackToFollow(), +fTrackHypothesys(), +fBestHypothesys(), +fOriginal(), +fCurrentEsdTrack(), +fPass(0), +fAfterV0(kFALSE), +fLastLayerToTrackTo(0), +fCoefficients(0), +fEsd(0), +fTrackingPhase("Default"), +fUseTGeo(3), +fNtracks(0), +fxOverX0Pipe(-1.), +fxTimesRhoPipe(-1.), +fxOverX0PipeTrks(0), +fxTimesRhoPipeTrks(0), +fxOverX0ShieldTrks(0), +fxTimesRhoShieldTrks(0), +fxOverX0LayerTrks(0), +fxTimesRhoLayerTrks(0), +fDebugStreamer(0), +fITSChannelStatus(0), +fkDetTypeRec(0), +fPlaneEff(0) { + //Default constructor + Int_t i; + for(i=0;i<4;i++) fSPDdetzcentre[i]=0.; + for(i=0;i<2;i++) {fxOverX0Shield[i]=-1.;fxTimesRhoShield[i]=-1.;} + for(i=0;i<6;i++) {fxOverX0Layer[i]=-1.;fxTimesRhoLayer[i]=-1.;} +} +//------------------------------------------------------------------------ +AliITStrackerMI::AliITStrackerMI(const Char_t *geom) : AliTracker(), +fI(AliITSgeomTGeo::GetNLayers()), +fBestTrack(), +fTrackToFollow(), +fTrackHypothesys(), +fBestHypothesys(), +fOriginal(), +fCurrentEsdTrack(), +fPass(0), +fAfterV0(kFALSE), +fLastLayerToTrackTo(AliITSRecoParam::GetLastLayerToTrackTo()), +fCoefficients(0), +fEsd(0), +fTrackingPhase("Default"), +fUseTGeo(3), +fNtracks(0), +fxOverX0Pipe(-1.), +fxTimesRhoPipe(-1.), +fxOverX0PipeTrks(0), +fxTimesRhoPipeTrks(0), +fxOverX0ShieldTrks(0), +fxTimesRhoShieldTrks(0), +fxOverX0LayerTrks(0), +fxTimesRhoLayerTrks(0), +fDebugStreamer(0), +fITSChannelStatus(0), +fkDetTypeRec(0), +fPlaneEff(0) { //-------------------------------------------------------------------- //This is the AliITStrackerMI constructor //-------------------------------------------------------------------- - fCoeficients = 0; + if (geom) { + AliWarning("\"geom\" is actually a dummy argument !"); + } + + fCoefficients = 0; fAfterV0 = kFALSE; - AliITSgeom *g=(AliITSgeom*)geom; - Float_t x,y,z; - Int_t i; - for (i=1; iGetNladders(i); - Int_t ndet=g->GetNdetectors(i); - g->GetTrans(i,1,1,x,y,z); - Double_t r=TMath::Sqrt(x*x + y*y); + for (Int_t i=1; iGetTrans(i,1,2,x,y,z); + AliITSgeomTGeo::GetOrigTranslation(i,1,2,xyz); r += TMath::Sqrt(x*x + y*y); - g->GetTrans(i,2,1,x,y,z); + AliITSgeomTGeo::GetOrigTranslation(i,2,1,xyz); r += TMath::Sqrt(x*x + y*y); - g->GetTrans(i,2,2,x,y,z); + AliITSgeomTGeo::GetOrigTranslation(i,2,2,xyz); r += TMath::Sqrt(x*x + y*y); r*=0.25; @@ -72,115 +161,261 @@ AliITStrackerMI::AliITStrackerMI(const AliITSgeom *geom) : AliTracker() { for (Int_t j=1; jGetTrans(i,j,k,x,y,zshift); - Double_t rot[9]; g->GetRotMatrix(i,j,k,rot); - - Double_t phi=TMath::ATan2(rot[1],rot[0])+TMath::Pi(); - phi+=TMath::Pi()/2; - if (i==1) phi+=TMath::Pi(); - Double_t cp=TMath::Cos(phi), sp=TMath::Sin(phi); - Double_t r=x*cp+y*sp; + TGeoHMatrix m; AliITSgeomTGeo::GetOrigMatrix(i,j,k,m); + const TGeoHMatrix *tm=AliITSgeomTGeo::GetTracking2LocalMatrix(i,j,k); + m.Multiply(tm); + Double_t txyz[3]={0.}; + xyz[0]=0.;xyz[1]=0.;xyz[2]=0.; + m.LocalToMaster(txyz,xyz); + r=TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]); + Double_t phi=TMath::ATan2(xyz[1],xyz[0]); + + if (phi<0) phi+=TMath::TwoPi(); + else if (phi>=TMath::TwoPi()) phi-=TMath::TwoPi(); AliITSdetector &det=fgLayers[i-1].GetDetector((j-1)*ndet + k-1); new(&det) AliITSdetector(r,phi); - } - } + // compute the real radius (with misalignment) + TGeoHMatrix mmisal(*(AliITSgeomTGeo::GetMatrix(i,j,k))); + mmisal.Multiply(tm); + xyz[0]=0.;xyz[1]=0.;xyz[2]=0.; + mmisal.LocalToMaster(txyz,xyz); + Double_t rmisal=TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]); + det.SetRmisal(rmisal); + + } // end loop on detectors + } // end loop on ladders + } // end loop on layers - } - fI=kMaxLayer; + fI=AliITSgeomTGeo::GetNLayers(); fPass=0; fConstraint[0]=1; fConstraint[1]=0; - Double_t xyz[]={kXV,kYV,kZV}, ers[]={kSigmaXV,kSigmaYV,kSigmaZV}; - SetVertex(xyz,ers); + Double_t xyzVtx[]={AliITSReconstructor::GetRecoParam()->GetXVdef(), + AliITSReconstructor::GetRecoParam()->GetYVdef(), + AliITSReconstructor::GetRecoParam()->GetZVdef()}; + Double_t ersVtx[]={AliITSReconstructor::GetRecoParam()->GetSigmaXVdef(), + AliITSReconstructor::GetRecoParam()->GetSigmaYVdef(), + AliITSReconstructor::GetRecoParam()->GetSigmaZVdef()}; + SetVertex(xyzVtx,ersVtx); - for (Int_t i=0; iGetUseTGeoInTracker(); + if(AliITSReconstructor::GetRecoParam()->GetExtendedEtaAcceptance() && fUseTGeo!=1 && fUseTGeo!=3) { + AliWarning("fUseTGeo changed to 3 because fExtendedEtaAcceptance is kTRUE"); + fUseTGeo = 3; + } + + for(Int_t i=0;i<2;i++) {fxOverX0Shield[i]=-1.;fxTimesRhoShield[i]=-1.;} + for(Int_t i=0;i<6;i++) {fxOverX0Layer[i]=-1.;fxTimesRhoLayer[i]=-1.;} + fDebugStreamer = new TTreeSRedirector("ITSdebug.root"); + // only for plane efficiency evaluation + if (AliITSReconstructor::GetRecoParam()->GetComputePlaneEff() && + AliITSReconstructor::GetRecoParam()->GetIPlanePlaneEff()>=0) { + Int_t iplane=AliITSReconstructor::GetRecoParam()->GetIPlanePlaneEff(); + if(!AliITSReconstructor::GetRecoParam()->GetLayersToSkip(iplane)==1) + AliWarning(Form("Evaluation of Plane Eff for layer %d will be attempted without removing it from tracker",iplane)); + if (iplane<2) fPlaneEff = new AliITSPlaneEffSPD(); + else if (iplane<4) fPlaneEff = new AliITSPlaneEffSDD(); + else fPlaneEff = new AliITSPlaneEffSSD(); + if(AliITSReconstructor::GetRecoParam()->GetReadPlaneEffFromOCDB()) + if(!fPlaneEff->ReadFromCDB()) {AliWarning("AliITStrackerMI reading of AliITSPlaneEff from OCDB failed") ;} + if(AliITSReconstructor::GetRecoParam()->GetHistoPlaneEff()) fPlaneEff->SetCreateHistos(kTRUE); + } } - +//------------------------------------------------------------------------ +AliITStrackerMI::AliITStrackerMI(const AliITStrackerMI &tracker):AliTracker(tracker), +fI(tracker.fI), +fBestTrack(tracker.fBestTrack), +fTrackToFollow(tracker.fTrackToFollow), +fTrackHypothesys(tracker.fTrackHypothesys), +fBestHypothesys(tracker.fBestHypothesys), +fOriginal(tracker.fOriginal), +fCurrentEsdTrack(tracker.fCurrentEsdTrack), +fPass(tracker.fPass), +fAfterV0(tracker.fAfterV0), +fLastLayerToTrackTo(tracker.fLastLayerToTrackTo), +fCoefficients(tracker.fCoefficients), +fEsd(tracker.fEsd), +fTrackingPhase(tracker.fTrackingPhase), +fUseTGeo(tracker.fUseTGeo), +fNtracks(tracker.fNtracks), +fxOverX0Pipe(tracker.fxOverX0Pipe), +fxTimesRhoPipe(tracker.fxTimesRhoPipe), +fxOverX0PipeTrks(0), +fxTimesRhoPipeTrks(0), +fxOverX0ShieldTrks(0), +fxTimesRhoShieldTrks(0), +fxOverX0LayerTrks(0), +fxTimesRhoLayerTrks(0), +fDebugStreamer(tracker.fDebugStreamer), +fITSChannelStatus(tracker.fITSChannelStatus), +fkDetTypeRec(tracker.fkDetTypeRec), +fPlaneEff(tracker.fPlaneEff) { + //Copy constructor + Int_t i; + for(i=0;i<4;i++) { + fSPDdetzcentre[i]=tracker.fSPDdetzcentre[i]; + } + for(i=0;i<6;i++) { + fxOverX0Layer[i]=tracker.fxOverX0Layer[i]; + fxTimesRhoLayer[i]=tracker.fxTimesRhoLayer[i]; + } + for(i=0;i<2;i++) { + fxOverX0Shield[i]=tracker.fxOverX0Shield[i]; + fxTimesRhoShield[i]=tracker.fxTimesRhoShield[i]; + } +} +//------------------------------------------------------------------------ +AliITStrackerMI & AliITStrackerMI::operator=(const AliITStrackerMI &tracker){ + //Assignment operator + this->~AliITStrackerMI(); + new(this) AliITStrackerMI(tracker); + return *this; +} +//------------------------------------------------------------------------ AliITStrackerMI::~AliITStrackerMI() { // //destructor // - if (fCoeficients) delete []fCoeficients; + if (fCoefficients) delete [] fCoefficients; + DeleteTrksMaterialLUT(); if (fDebugStreamer) { //fDebugStreamer->Close(); delete fDebugStreamer; } + if(fITSChannelStatus) delete fITSChannelStatus; + if(fPlaneEff) delete fPlaneEff; } - -void AliITStrackerMI::SetLayersNotToSkip(Int_t *l) { +//------------------------------------------------------------------------ +void AliITStrackerMI::SetLayersNotToSkip(const Int_t *l) { //-------------------------------------------------------------------- //This function set masks of the layers which must be not skipped //-------------------------------------------------------------------- - for (Int_t i=0; iGetUseBadZonesFromOCDB()) return; + + Info("ReadBadFromDetTypeRec","Reading info about bad ITS detectors and channels"); + + if(!fkDetTypeRec) Error("ReadBadFromDetTypeRec","AliITSDetTypeRec nof found!\n"); + + // ITS channels map + if(fITSChannelStatus) delete fITSChannelStatus; + fITSChannelStatus = new AliITSChannelStatus(fkDetTypeRec); + + // ITS detectors and chips + Int_t i=0,j=0,k=0,ndet=0; + for (i=1; iGetBranch("Clusters"); + TBranch *branch=cTree->GetBranch("ITSRecPoints"); if (!branch) { Error("LoadClusters"," can't get the branch !\n"); return 1; } - TClonesArray dummy("AliITSclusterV2",10000), *clusters=&dummy; + static TClonesArray dummy("AliITSRecPoint",10000), *clusters=&dummy; branch->SetAddress(&clusters); - Int_t j=0; + Int_t i=0,j=0,ndet=0; Int_t detector=0; - for (Int_t i=0; iGetEvent(j)) continue; Int_t ncl=clusters->GetEntriesFast(); SignDeltas(clusters,GetZ()); + while (ncl--) { - AliITSclusterV2 *c=(AliITSclusterV2*)clusters->UncheckedAt(ncl); - detector = c->GetDetectorIndex(); - fgLayers[i].InsertCluster(new AliITSclusterV2(*c)); + AliITSRecPoint *c=(AliITSRecPoint*)clusters->UncheckedAt(ncl); + detector=c->GetDetectorIndex(); + + if (!c->Misalign()) AliWarning("Can't misalign this cluster !"); + + fgLayers[i].InsertCluster(new AliITSRecPoint(*c)); } clusters->Delete(); - //add dead zone virtual "cluster" - if (i<2){ - for (Float_t ydead = 0; ydead < 1.31 ; ydead+=(i+1.)*0.018){ - Int_t lab[4] = {0,0,0,detector}; - Int_t info[3] = {0,0,0}; - Float_t hit[5]={0,0,0.004/12.,0.001/12.,0}; - if (i==0) hit[0] =ydead-0.4; - if (i==1) hit[0]=ydead-3.75; - hit[1] =-0.04; - if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<2.) - fgLayers[i].InsertCluster(new AliITSclusterV2(lab, hit, info)); - hit[1]=-7.05; - if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<2.) - fgLayers[i].InsertCluster(new AliITSclusterV2(lab, hit, info)); - hit[1]=-7.15; - if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<2.) - fgLayers[i].InsertCluster(new AliITSclusterV2(lab, hit, info)); - hit[1] =0.06; - if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<2.) - fgLayers[i].InsertCluster(new AliITSclusterV2(lab, hit, info)); - hit[1]=7.05; - if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<2.) - fgLayers[i].InsertCluster(new AliITSclusterV2(lab, hit, info)); - hit[1]=7.25; - if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<2.) - fgLayers[i].InsertCluster(new AliITSclusterV2(lab, hit, info)); + // add dead zone "virtual" cluster in SPD, if there is a cluster within + // zwindow cm from the dead zone + if (i<2 && AliITSReconstructor::GetRecoParam()->GetAddVirtualClustersInDeadZone()) { + for (Float_t xdead = 0; xdead < AliITSRecoParam::GetSPDdetxlength(); xdead += (i+1.)*AliITSReconstructor::GetRecoParam()->GetXPassDeadZoneHits()) { + Int_t lab[4] = {0,0,0,detector}; + Int_t info[3] = {0,0,i}; + Float_t q = 0.; // this identifies virtual clusters + Float_t hit[5] = {xdead, + 0., + AliITSReconstructor::GetRecoParam()->GetSigmaXDeadZoneHit2(), + AliITSReconstructor::GetRecoParam()->GetSigmaZDeadZoneHit2(), + q}; + Bool_t local = kTRUE; + Double_t zwindow = AliITSReconstructor::GetRecoParam()->GetZWindowDeadZone(); + hit[1] = fSPDdetzcentre[0]+0.5*AliITSRecoParam::GetSPDdetzlength(); + if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])AddLast(cl); + } + } + + return; +} +//------------------------------------------------------------------------ +Int_t AliITStrackerMI::CorrectForTPCtoITSDeadZoneMaterial(AliITStrackMI *t) { //-------------------------------------------------------------------- // Correction for the material between the TPC and the ITS - // (should it belong to the TPC code ?) - //-------------------------------------------------------------------- - Double_t riw=80., diw=0.0053, x0iw=30; // TPC inner wall ? - Double_t rcd=61., dcd=0.0053, x0cd=30; // TPC "central drum" ? - Double_t yr=12.8, dr=0.03; // rods ? - Double_t zm=0.2, dm=0.40; // membrane - //Double_t rr=52., dr=0.19, x0r=24., yyr=7.77; //rails - Double_t rs=50., ds=0.001; // something belonging to the ITS (screen ?) - - if (t->GetX() > riw) { - if (!t->PropagateTo(riw,diw,x0iw)) return 1; - if (TMath::Abs(t->GetY())>yr) t->CorrectForMaterial(dr); - if (TMath::Abs(t->GetZ())CorrectForMaterial(dm); - if (!t->PropagateTo(rcd,dcd,x0cd)) return 1; - //Double_t x,y,z; t->GetGlobalXYZat(rr,x,y,z); - //if (TMath::Abs(y)PropagateTo(rr,dr,x0r); - if (!t->PropagateTo(rs,ds)) return 1; - } else if (t->GetX() < rs) { - if (!t->PropagateTo(rs,-ds)) return 1; - //Double_t x,y,z; t->GetGlobalXYZat(rr,x,y,z); - //if (TMath::Abs(y)PropagateTo(rr,-dr,x0r); - if (!t->PropagateTo(rcd,-dcd,x0cd)) return 1; - if (!t->PropagateTo(riw+0.001,-diw,x0iw)) return 1; + //-------------------------------------------------------------------- + if (t->GetX() > AliITSRecoParam::Getriw()) { // inward direction + if (!t->PropagateToTGeo(AliITSRecoParam::Getriw(),1)) return 0;// TPC inner wall + if (!t->PropagateToTGeo(AliITSRecoParam::Getrcd(),1)) return 0;// TPC central drum + if (!t->PropagateToTGeo(AliITSRecoParam::Getrs(),1)) return 0;// ITS screen + } else if (t->GetX() < AliITSRecoParam::Getrs()) { // outward direction + if (!t->PropagateToTGeo(AliITSRecoParam::Getrs(),1)) return 0;// ITS screen + if (!t->PropagateToTGeo(AliITSRecoParam::Getrcd(),1)) return 0;// TPC central drum + if (!t->PropagateToTGeo(AliITSRecoParam::Getriw()+0.001,1)) return 0;// TPC inner wall } else { - ::Error("CorrectForDeadZoneMaterial","track is already in the dead zone !"); - return 1; + printf("CorrectForTPCtoITSDeadZoneMaterial: Track is already in the dead zone !\n"); + return 0; } - return 0; + return 1; } - -Int_t AliITStrackerMI::Clusters2Tracks(AliESD *event) { +//------------------------------------------------------------------------ +Int_t AliITStrackerMI::Clusters2Tracks(AliESDEvent *event) { //-------------------------------------------------------------------- // This functions reconstructs ITS tracks // The clusters must be already loaded ! //-------------------------------------------------------------------- + + + fTrackingPhase="Clusters2Tracks"; + TObjArray itsTracks(15000); fOriginal.Clear(); fEsd = event; // store pointer to the esd + + // temporary (for cosmics) + if(event->GetVertex()) { + TString title = event->GetVertex()->GetTitle(); + if(title.Contains("cosmics")) { + Double_t xyz[3]={GetX(),GetY(),GetZ()}; + Double_t exyz[3]={0.1,0.1,0.1}; + SetVertex(xyz,exyz); + } + } + // temporary + {/* Read ESD tracks */ + Double_t pimass = TDatabasePDG::Instance()->GetParticle(211)->Mass(); Int_t nentr=event->GetNumberOfTracks(); Info("Clusters2Tracks", "Number of ESD tracks: %d\n", nentr); while (nentr--) { AliESDtrack *esd=event->GetTrack(nentr); + // ---- for debugging: + //if(TMath::Abs(esd->GetX()-83.65)<0.1) { FILE *f=fopen("tpc.dat","a"); fprintf(f,"%f %f %f %f %f %f\n",(Float_t)event->GetEventNumberInFile(),(Float_t)TMath::Abs(esd->GetLabel()),(Float_t)esd->GetX(),(Float_t)esd->GetY(),(Float_t)esd->GetZ(),(Float_t)esd->Pt()); fclose(f); } if ((esd->GetStatus()&AliESDtrack::kTPCin)==0) continue; if (esd->GetStatus()&AliESDtrack::kTPCout) continue; @@ -258,39 +518,36 @@ Int_t AliITStrackerMI::Clusters2Tracks(AliESD *event) { delete t; continue; } - t->fD[0] = t->GetD(GetX(),GetY()); - t->fD[1] = t->GetZat(GetX())-GetZ(); - Double_t vdist = TMath::Sqrt(t->fD[0]*t->fD[0]+t->fD[1]*t->fD[1]); - if (t->GetMass()<0.13) t->SetMass(0.13957); // MI look to the esd - mass hypothesys !!!!!!!!!!! + t->GetDZ(GetX(),GetY(),GetZ(),t->GetDP()); //I.B. + Double_t vdist = TMath::Sqrt(t->GetD(0)*t->GetD(0)+t->GetD(1)*t->GetD(1)); + + + // look at the ESD mass hypothesys ! + if (t->GetMass()<0.9*pimass) t->SetMass(pimass); // write expected q - t->fExpQ = TMath::Max(0.8*t->fESDtrack->GetTPCsignal(),30.); + t->SetExpQ(TMath::Max(0.8*t->GetESDtrack()->GetTPCsignal(),30.)); - if (esd->GetV0Index(0)>0 && t->fD[0]<30){ + if (esd->GetV0Index(0)>0 && t->GetD(0)GetMaxDforV0dghtrForProlongation()){ //track - can be V0 according to TPC - } - else{ - if (TMath::Abs(t->fD[0])>10) { + } else { + if (TMath::Abs(t->GetD(0))>AliITSReconstructor::GetRecoParam()->GetMaxDForProlongation()) { delete t; continue; - } - - if (TMath::Abs(vdist)>20) { + } + if (TMath::Abs(vdist)>AliITSReconstructor::GetRecoParam()->GetMaxDZForProlongation()) { delete t; continue; } - if (TMath::Abs(1/t->Get1Pt())<0.120) { + if (t->Pt()GetMinPtForProlongation()) { delete t; continue; } - - if (CorrectForDeadZoneMaterial(t)!=0) { - //Warning("Clusters2Tracks", - // "failed to correct for the material in the dead zone !\n"); + if (!CorrectForTPCtoITSDeadZoneMaterial(t)) { delete t; continue; } } - t->fReconstructed = kFALSE; + t->SetReconstructed(kFALSE); itsTracks.AddLast(t); fOriginal.AddLast(t); } @@ -301,63 +558,60 @@ Int_t AliITStrackerMI::Clusters2Tracks(AliESD *event) { Int_t nentr=itsTracks.GetEntriesFast(); fTrackHypothesys.Expand(nentr); fBestHypothesys.Expand(nentr); - MakeCoeficients(nentr); + MakeCoefficients(nentr); + if(fUseTGeo==3 || fUseTGeo==4) MakeTrksMaterialLUT(event->GetNumberOfTracks()); Int_t ntrk=0; + // THE TWO TRACKING PASSES for (fPass=0; fPass<2; fPass++) { Int_t &constraint=fConstraint[fPass]; if (constraint<0) continue; - for (Int_t i=0; ifReconstructed&&(t->fNUsed<1.5)) continue; //this track was already "succesfully" reconstructed - if ( (TMath::Abs(t->GetD(GetX(),GetY())) >3.) && fConstraint[fPass]) continue; - if ( (TMath::Abs(t->GetZat(GetX())-GetZ())>3.) && fConstraint[fPass]) continue; + //cout<<"========== "<GetReconstructed()&&(t->GetNUsed()<1.5)) continue; //this track was already "succesfully" reconstructed + Float_t dz[2]; t->GetDZ(GetX(),GetY(),GetZ(),dz); //I.B. + if (fConstraint[fPass]) { + if (TMath::Abs(dz[0])>AliITSReconstructor::GetRecoParam()->GetMaxDZToUseConstraint() || + TMath::Abs(dz[1])>AliITSReconstructor::GetRecoParam()->GetMaxDZToUseConstraint()) continue; + } Int_t tpcLabel=t->GetLabel(); //save the TPC track label + AliDebug(2,Form("LABEL %d pass %d",tpcLabel,fPass)); fI = 6; ResetTrackToFollow(*t); ResetBestTrack(); - FollowProlongationTree(t,i,fConstraint[fPass]); + + FollowProlongationTree(t,fCurrentEsdTrack,fConstraint[fPass]); + SortTrackHypothesys(fCurrentEsdTrack,20,0); //MI change // - AliITStrackMI * besttrack = GetBestHypothesys(fCurrentEsdTrack,t,15); + AliITStrackMI *besttrack = GetBestHypothesys(fCurrentEsdTrack,t,15); if (!besttrack) continue; besttrack->SetLabel(tpcLabel); // besttrack->CookdEdx(); CookdEdx(besttrack); - besttrack->fFakeRatio=1.; + besttrack->SetFakeRatio(1.); CookLabel(besttrack,0.); //For comparison only UpdateESDtrack(besttrack,AliESDtrack::kITSin); - /* - if ( besttrack->GetNumberOfClusters()<6 && fConstraint[fPass]) { - continue; - } - if (besttrack->fChi2MIP[0]+besttrack->fNUsed>3.5) continue; - if ( (TMath::Abs(besttrack->fD[0]*besttrack->fD[0]+besttrack->fD[1]*besttrack->fD[1])>0.1) && fConstraint[fPass]) continue; - //delete itsTracks.RemoveAt(i); - */ if (fConstraint[fPass]&&(!besttrack->IsGoldPrimary())) continue; //to be tracked also without vertex constrain - - t->fReconstructed = kTRUE; - ntrk++; + t->SetReconstructed(kTRUE); + ntrk++; + AliDebug(2,Form("TRACK! (label %d) ncls %d",besttrack->GetLabel(),besttrack->GetNumberOfClusters())); } GetBestHypothesysMIP(itsTracks); - } + } // end loop on the two tracking passes - //GetBestHypothesysMIP(itsTracks); - UpdateTPCV0(event); - FindV02(event); + if(event->GetNumberOfV0s()>0) AliITSV0Finder::UpdateTPCV0(event,this); + if(AliITSReconstructor::GetRecoParam()->GetFindV0s()) AliITSV0Finder::FindV02(event,this); fAfterV0 = kTRUE; - //GetBestHypothesysMIP(itsTracks); // itsTracks.Delete(); // Int_t entries = fTrackHypothesys.GetEntriesFast(); - for (Int_t ientry=0;ientryDelete(); delete fTrackHypothesys.RemoveAt(ientry); @@ -366,19 +620,23 @@ Int_t AliITStrackerMI::Clusters2Tracks(AliESD *event) { fTrackHypothesys.Delete(); fBestHypothesys.Delete(); fOriginal.Clear(); - delete []fCoeficients; - fCoeficients=0; + delete [] fCoefficients; + fCoefficients=0; + DeleteTrksMaterialLUT(); + Info("Clusters2Tracks","Number of prolonged tracks: %d\n",ntrk); + + fTrackingPhase="Default"; return 0; } - - -Int_t AliITStrackerMI::PropagateBack(AliESD *event) { +//------------------------------------------------------------------------ +Int_t AliITStrackerMI::PropagateBack(AliESDEvent *event) { //-------------------------------------------------------------------- // This functions propagates reconstructed ITS tracks back // The clusters must be loaded ! //-------------------------------------------------------------------- + fTrackingPhase="PropagateBack"; Int_t nentr=event->GetNumberOfTracks(); Info("PropagateBack", "Number of ESD tracks: %d\n", nentr); @@ -397,24 +655,32 @@ Int_t AliITStrackerMI::PropagateBack(AliESD *event) { delete t; continue; } - t->fExpQ = TMath::Max(0.8*t->fESDtrack->GetTPCsignal(),30.); + t->SetExpQ(TMath::Max(0.8*t->GetESDtrack()->GetTPCsignal(),30.)); ResetTrackToFollow(*t); - - // propagete to vertex [SR, GSI 17.02.2003] + /* + // propagate to vertex [SR, GSI 17.02.2003] // Start Time measurement [SR, GSI 17.02.2003], corrected by I.Belikov - if (fTrackToFollow.PropagateTo(3.,0.0028,65.19)) { - if (fTrackToFollow.PropagateToVertex()) { - fTrackToFollow.StartTimeIntegral(); - } - fTrackToFollow.PropagateTo(3.,-0.0028,65.19); + if (CorrectForPipeMaterial(&fTrackToFollow,"inward")) { + if (fTrackToFollow.PropagateToVertex(event->GetVertex())) + fTrackToFollow.StartTimeIntegral(); + // from vertex to outside pipe + CorrectForPipeMaterial(&fTrackToFollow,"outward"); + }*/ + // Start time integral and add distance from current position to vertex + Double_t xyzTrk[3],xyzVtx[3]={GetX(),GetY(),GetZ()}; + fTrackToFollow.GetXYZ(xyzTrk); + Double_t dst2 = 0.; + for (Int_t icoord=0; icoord<3; icoord++) { + Double_t di = xyzTrk[icoord] - xyzVtx[icoord]; + dst2 += di*di; } + fTrackToFollow.StartTimeIntegral(); + fTrackToFollow.AddTimeStep(TMath::Sqrt(dst2)); - fTrackToFollow.ResetCovariance(); fTrackToFollow.ResetClusters(); - if (RefitAt(49.,&fTrackToFollow,t)) { - if (CorrectForDeadZoneMaterial(&fTrackToFollow)!=0) { - //Warning("PropagateBack", - // "failed to correct for the material in the dead zone !\n"); + fTrackToFollow.ResetCovariance(10.); fTrackToFollow.ResetClusters(); + if (RefitAt(AliITSRecoParam::GetrInsideITSscreen(),&fTrackToFollow,t)) { + if (!CorrectForTPCtoITSDeadZoneMaterial(&fTrackToFollow)) { delete t; continue; } @@ -430,16 +696,21 @@ Int_t AliITStrackerMI::PropagateBack(AliESD *event) { Info("PropagateBack","Number of back propagated ITS tracks: %d\n",ntrk); + fTrackingPhase="Default"; + return 0; } - -Int_t AliITStrackerMI::RefitInward(AliESD *event) { +//------------------------------------------------------------------------ +Int_t AliITStrackerMI::RefitInward(AliESDEvent *event) { //-------------------------------------------------------------------- // This functions refits ITS tracks using the // "inward propagated" TPC tracks // The clusters must be loaded ! //-------------------------------------------------------------------- - RefitV02(event); + fTrackingPhase="RefitInward"; + + if(AliITSReconstructor::GetRecoParam()->GetFindV0s()) AliITSV0Finder::RefitV02(event,this); + Int_t nentr=event->GetNumberOfTracks(); Info("RefitInward", "Number of ESD tracks: %d\n", nentr); @@ -460,10 +731,8 @@ Int_t AliITStrackerMI::RefitInward(AliESD *event) { delete t; continue; } - t->fExpQ = TMath::Max(0.8*t->fESDtrack->GetTPCsignal(),30.); - if (CorrectForDeadZoneMaterial(t)!=0) { - //Warning("RefitInward", - // "failed to correct for the material in the dead zone !\n"); + t->SetExpQ(TMath::Max(0.8*t->GetESDtrack()->GetTPCsignal(),30.)); + if (!CorrectForTPCtoITSDeadZoneMaterial(t)) { delete t; continue; } @@ -472,47 +741,31 @@ Int_t AliITStrackerMI::RefitInward(AliESD *event) { fTrackToFollow.ResetClusters(); if ((esd->GetStatus()&AliESDtrack::kTPCin)==0) - fTrackToFollow.ResetCovariance(); + fTrackToFollow.ResetCovariance(10.); //Refitting... - if (RefitAt(3.7, &fTrackToFollow, t)) { + Bool_t pe=(AliITSReconstructor::GetRecoParam()->GetComputePlaneEff() && + AliITSReconstructor::GetRecoParam()->GetIPlanePlaneEff()>=0); + + AliDebug(2,Form("Refit LABEL %d %d",t->GetLabel(),t->GetNumberOfClusters())); + if (RefitAt(AliITSRecoParam::GetrInsideSPD1(),&fTrackToFollow,t,kTRUE,pe)) { + AliDebug(2," refit OK"); fTrackToFollow.SetLabel(t->GetLabel()); // fTrackToFollow.CookdEdx(); CookdEdx(&fTrackToFollow); CookLabel(&fTrackToFollow,0.0); //For comparison only - if (fTrackToFollow.PropagateTo(3.,0.0028,65.19)) {//The beam pipe - Double_t a=fTrackToFollow.GetAlpha(); - Double_t cs=TMath::Cos(a),sn=TMath::Sin(a); - Double_t xv= GetX()*cs + GetY()*sn; - Double_t yv=-GetX()*sn + GetY()*cs; - - Double_t c=fTrackToFollow.GetC(), snp=fTrackToFollow.GetSnp(); - Double_t x=fTrackToFollow.GetX(), y=fTrackToFollow.GetY(); - Double_t tgfv=-(c*(x-xv)-snp)/(c*(y-yv) + TMath::Sqrt(1.-snp*snp)); - Double_t fv=TMath::ATan(tgfv); - - cs=TMath::Cos(fv); sn=TMath::Sin(fv); - x = xv*cs + yv*sn; - yv=-xv*sn + yv*cs; xv=x; - - if (fTrackToFollow.Propagate(fv+a,xv)) { - fTrackToFollow.UpdateESDtrack(AliESDtrack::kITSrefit); - //UseClusters(&fTrackToFollow); - { - AliITSclusterV2 c; c.SetY(yv); c.SetZ(GetZ()); - c.SetSigmaY2(GetSigmaY()*GetSigmaY()); - c.SetSigmaZ2(GetSigmaZ()*GetSigmaZ()); - Double_t chi2=fTrackToFollow.GetPredictedChi2(&c); - //Double_t chi2=GetPredictedChi2MI(&fTrackToFollow,&c,fI); - if (chi2GetITSModuleIndex(0)); + //esdTrack->UpdateTrackParams(&fTrackToFollow,AliESDtrack::kITSrefit); //original line + Double_t r[3]={0.,0.,0.}; + Double_t maxD=3.; + esdTrack->RelateToVertex(event->GetVertex(),GetBz(r),maxD); + ntrk++; } } delete t; @@ -520,9 +773,11 @@ Int_t AliITStrackerMI::RefitInward(AliESD *event) { Info("RefitInward","Number of refitted tracks: %d\n",ntrk); + fTrackingPhase="Default"; + return 0; } - +//------------------------------------------------------------------------ AliCluster *AliITStrackerMI::GetCluster(Int_t index) const { //-------------------------------------------------------------------- // Return pointer to a given cluster @@ -531,32 +786,154 @@ AliCluster *AliITStrackerMI::GetCluster(Int_t index) const { Int_t c=(index & 0x0fffffff) >> 00; return fgLayers[l].GetCluster(c); } +//------------------------------------------------------------------------ +Bool_t AliITStrackerMI::GetTrackPoint(Int_t index, AliTrackPoint& p) const { + //-------------------------------------------------------------------- + // Get track space point with index i + //-------------------------------------------------------------------- + Int_t l=(index & 0xf0000000) >> 28; + Int_t c=(index & 0x0fffffff) >> 00; + AliITSRecPoint *cl = fgLayers[l].GetCluster(c); + Int_t idet = cl->GetDetectorIndex(); + + Float_t xyz[3]; + Float_t cov[6]; + cl->GetGlobalXYZ(xyz); + cl->GetGlobalCov(cov); + p.SetXYZ(xyz, cov); + p.SetCharge(cl->GetQ()); + p.SetDriftTime(cl->GetDriftTime()); + p.SetChargeRatio(cl->GetChargeRatio()); + AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; + switch (l) { + case 0: + iLayer = AliGeomManager::kSPD1; + break; + case 1: + iLayer = AliGeomManager::kSPD2; + break; + case 2: + iLayer = AliGeomManager::kSDD1; + break; + case 3: + iLayer = AliGeomManager::kSDD2; + break; + case 4: + iLayer = AliGeomManager::kSSD1; + break; + case 5: + iLayer = AliGeomManager::kSSD2; + break; + default: + AliWarning(Form("Wrong layer index in ITS (%d) !",l)); + break; + }; + UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,idet); + p.SetVolumeID((UShort_t)volid); + return kTRUE; +} +//------------------------------------------------------------------------ +Bool_t AliITStrackerMI::GetTrackPointTrackingError(Int_t index, + AliTrackPoint& p, const AliESDtrack *t) { + //-------------------------------------------------------------------- + // Get track space point with index i + // (assign error estimated during the tracking) + //-------------------------------------------------------------------- + Int_t l=(index & 0xf0000000) >> 28; + Int_t c=(index & 0x0fffffff) >> 00; + const AliITSRecPoint *cl = fgLayers[l].GetCluster(c); + Int_t idet = cl->GetDetectorIndex(); + + const AliITSdetector &det=fgLayers[l].GetDetector(idet); + + // tgphi and tglambda of the track in tracking frame with alpha=det.GetPhi + Float_t detxy[2]; + detxy[0] = det.GetR()*TMath::Cos(det.GetPhi()); + detxy[1] = det.GetR()*TMath::Sin(det.GetPhi()); + Double_t alpha = t->GetAlpha(); + Double_t xdetintrackframe = detxy[0]*TMath::Cos(alpha)+detxy[1]*TMath::Sin(alpha); + Float_t phi = TMath::ASin(t->GetSnpAt(xdetintrackframe,GetBz())); + phi += alpha-det.GetPhi(); + Float_t tgphi = TMath::Tan(phi); + + Float_t tgl = t->GetTgl(); // tgl about const along track + Float_t expQ = TMath::Max(0.8*t->GetTPCsignal(),30.); + + Float_t errtrky,errtrkz,covyz; + Bool_t addMisalErr=kFALSE; + AliITSClusterParam::GetError(l,cl,tgl,tgphi,expQ,errtrky,errtrkz,covyz,addMisalErr); + + Float_t xyz[3]; + Float_t cov[6]; + cl->GetGlobalXYZ(xyz); + // cl->GetGlobalCov(cov); + Float_t pos[3] = {0.,0.,0.}; + AliCluster tmpcl((UShort_t)cl->GetVolumeId(),pos[0],pos[1],pos[2],errtrky*errtrky,errtrkz*errtrkz,covyz); + tmpcl.GetGlobalCov(cov); + + p.SetXYZ(xyz, cov); + p.SetCharge(cl->GetQ()); + p.SetDriftTime(cl->GetDriftTime()); + p.SetChargeRatio(cl->GetChargeRatio()); + + AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; + switch (l) { + case 0: + iLayer = AliGeomManager::kSPD1; + break; + case 1: + iLayer = AliGeomManager::kSPD2; + break; + case 2: + iLayer = AliGeomManager::kSDD1; + break; + case 3: + iLayer = AliGeomManager::kSDD2; + break; + case 4: + iLayer = AliGeomManager::kSSD1; + break; + case 5: + iLayer = AliGeomManager::kSSD2; + break; + default: + AliWarning(Form("Wrong layer index in ITS (%d) !",l)); + break; + }; + UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,idet); + + p.SetVolumeID((UShort_t)volid); + return kTRUE; +} +//------------------------------------------------------------------------ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdindex, Bool_t constrain) { //-------------------------------------------------------------------- // Follow prolongation tree //-------------------------------------------------------------------- // - AliESDtrack * esd = otrack->fESDtrack; - if (esd->GetV0Index(0)>0){ - // + Double_t xyzVtx[]={GetX(),GetY(),GetZ()}; + Double_t ersVtx[]={GetSigmaX(),GetSigmaY(),GetSigmaZ()}; + + + AliESDtrack * esd = otrack->GetESDtrack(); + if (esd->GetV0Index(0)>0) { // TEMPORARY SOLLUTION: map V0 indexes to point to proper track - // mapping of esd track is different as its track in Containers + // mapping of ESD track is different as ITS track in Containers // Need something more stable - // Indexes are set back againg to the ESD track indexes in UpdateTPCV0 + // Indexes are set back again to the ESD track indexes in UpdateTPCV0 for (Int_t i=0;i<3;i++){ Int_t index = esd->GetV0Index(i); if (index==0) break; - AliESDV0MI * vertex = fEsd->GetV0MI(index); + AliESDv0 * vertex = fEsd->GetV0(index); if (vertex->GetStatus()<0) continue; // rejected V0 // if (esd->GetSign()>0) { - vertex->SetIndex(0,esdindex); - } - else{ - vertex->SetIndex(1,esdindex); + vertex->SetIndex(0,esdindex); + } else { + vertex->SetIndex(1,esdindex); } } } @@ -578,265 +955,393 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin Int_t nindexes[7][100]; Float_t normalizedchi2[100]; for (Int_t ilayer=0;ilayer<6;ilayer++) ntracks[ilayer]=0; - otrack->fNSkipped=0; + otrack->SetNSkipped(0); new (&(tracks[6][0])) AliITStrackMI(*otrack); ntracks[6]=1; for (Int_t i=0;i<7;i++) nindexes[i][0]=0; + Int_t modstatus = 1; // found + Float_t xloc,zloc; // // // follow prolongations - for (Int_t ilayer=5;ilayer>=0;ilayer--){ + for (Int_t ilayer=5; ilayer>=0; ilayer--) { + AliDebug(2,Form("FollowProlongationTree: layer %d",ilayer)); + fI = ilayer; // - AliITSlayer &layer=fgLayers[ilayer]; - Double_t r=layer.GetR(); + AliITSlayer &layer=fgLayers[ilayer]; + Double_t r = layer.GetR(); ntracks[ilayer]=0; // // - Int_t nskipped=0; + Int_t nskipped=0; Float_t nused =0; - for (Int_t itrack =0;itrack=100) break; - if (tracks[ilayer+1][nindexes[ilayer+1][itrack]].fNSkipped>0) nskipped++; - if (tracks[ilayer+1][nindexes[ilayer+1][itrack]].fNUsed>2.) nused++; + if (tracks[ilayer+1][nindexes[ilayer+1][itrack]].GetNSkipped()>0) nskipped++; + if (tracks[ilayer+1][nindexes[ilayer+1][itrack]].GetNUsed()>2.) nused++; if (ntracks[ilayer]>15+ilayer){ - if (itrack>1&&tracks[ilayer+1][nindexes[ilayer+1][itrack]].fNSkipped>0 && nskipped>4+ilayer) continue; - if (itrack>1&&tracks[ilayer+1][nindexes[ilayer+1][itrack]].fNUsed>2. && nused>3) continue; + if (itrack>1&&tracks[ilayer+1][nindexes[ilayer+1][itrack]].GetNSkipped()>0 && nskipped>4+ilayer) continue; + if (itrack>1&&tracks[ilayer+1][nindexes[ilayer+1][itrack]].GetNUsed()>2. && nused>3) continue; } new(¤ttrack1) AliITStrackMI(tracks[ilayer+1][nindexes[ilayer+1][itrack]]); - if (ilayer==3 || ilayer==1) { - Double_t rs=0.5*(fgLayers[ilayer+1].GetR() + r); - Double_t d=0.0034, x0=38.6; - if (ilayer==1) {rs=9.; d=0.0097; x0=42;} - if (!currenttrack1.PropagateTo(rs,d,x0)) { - continue; - } - } - // - //find intersection with layer - Double_t x,y,z; - if (!currenttrack1.GetGlobalXYZat(r,x,y,z)) { - continue; - } - Double_t phi=TMath::ATan2(y,x); + + // material between SSD and SDD, SDD and SPD + if (ilayer==3) + if(!CorrectForShieldMaterial(¤ttrack1,"SDD","inward")) continue; + if (ilayer==1) + if(!CorrectForShieldMaterial(¤ttrack1,"SPD","inward")) continue; + + // detector number + Double_t phi,z; + if (!currenttrack1.GetPhiZat(r,phi,z)) continue; Int_t idet=layer.FindDetectorIndex(phi,z); - if (idet<0) { + + Double_t trackGlobXYZ1[3]; + if (!currenttrack1.GetXYZ(trackGlobXYZ1)) continue; + + // Get the budget to the primary vertex for the current track being prolonged + Double_t budgetToPrimVertex = GetEffectiveThickness(); + + // check if we allow a prolongation without point + Int_t skip = CheckSkipLayer(¤ttrack1,ilayer,idet); + if (skip) { + AliITStrackMI* vtrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(currenttrack1); + // propagate to the layer radius + Double_t xToGo; if (!vtrack->GetLocalXat(r,xToGo)) continue; + if(!vtrack->Propagate(xToGo)) continue; + // apply correction for material of the current layer + CorrectForLayerMaterial(vtrack,ilayer,trackGlobXYZ1,"inward"); + vtrack->SetNDeadZone(vtrack->GetNDeadZone()+1); + vtrack->SetDeadZoneProbability(ilayer,1.); // no penalty for missing cluster + vtrack->SetClIndex(ilayer,-1); + modstatus = (skip==1 ? 3 : 4); // skipped : out in z + if(LocalModuleCoord(ilayer,idet,vtrack,xloc,zloc)) { // local module coords + vtrack->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc); + } + if(constrain) vtrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx); + ntracks[ilayer]++; continue; } - //propagate to the intersection + + // track outside layer acceptance in z + if (idet<0) continue; + + //propagate to the intersection with the detector plane const AliITSdetector &det=layer.GetDetector(idet); - phi=det.GetPhi(); new(¤ttrack2) AliITStrackMI(currenttrack1); - if (!currenttrack1.Propagate(phi,det.GetR())) { - continue; - } - currenttrack2.Propagate(phi,det.GetR()); // + if (!currenttrack1.Propagate(det.GetPhi(),det.GetR())) continue; + if (!currenttrack2.Propagate(det.GetPhi(),det.GetR())) continue; currenttrack1.SetDetectorIndex(idet); currenttrack2.SetDetectorIndex(idet); - - // - // - Double_t dz=7.5*TMath::Sqrt(currenttrack1.GetSigmaZ2() + 16.*kSigmaZ2[ilayer]); - Double_t dy=7.5*TMath::Sqrt(currenttrack1.GetSigmaY2() + 16.*kSigmaY2[ilayer]); + if(!LocalModuleCoord(ilayer,idet,¤ttrack1,xloc,zloc)) continue; // local module coords + + //*************** + // DEFINITION OF SEARCH ROAD AND CLUSTERS SELECTION // - Bool_t isBoundary=kFALSE; - if (currenttrack1.GetY()-dy< det.GetYmin()+0.2) isBoundary = kTRUE; - if (currenttrack1.GetY()+dy> det.GetYmax()-0.2) isBoundary = kTRUE; - if (currenttrack1.GetZ()-dz< det.GetZmin()+0.2) isBoundary = kTRUE; - if (currenttrack1.GetZ()+dz> det.GetZmax()-0.2) isBoundary = kTRUE; - - if (isBoundary){ // track at boundary between detectors - Float_t maxtgl = TMath::Abs(currenttrack1.GetTgl()); - if (maxtgl>1) maxtgl=1; - dz = TMath::Sqrt(dz*dz+0.25*maxtgl*maxtgl); - // - Float_t maxsnp = TMath::Abs(currenttrack1.GetSnp()); - if (maxsnp>0.95) continue; - //if (maxsnp>0.5) maxsnp=0.5; - dy=TMath::Sqrt(dy*dy+0.25*maxsnp*maxsnp); - } - - Double_t zmin=currenttrack1.GetZ() - dz; - Double_t zmax=currenttrack1.GetZ() + dz; - Double_t ymin=currenttrack1.GetY() + r*phi - dy; - Double_t ymax=currenttrack1.GetY() + r*phi + dy; + // road in global (rphi,z) [i.e. in tracking ref. system] + Double_t zmin,zmax,ymin,ymax; + if (!ComputeRoad(¤ttrack1,ilayer,idet,zmin,zmax,ymin,ymax)) continue; + + // select clusters in road layer.SelectClusters(zmin,zmax,ymin,ymax); + //******************** + + // Define criteria for track-cluster association + Double_t msz = currenttrack1.GetSigmaZ2() + + AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()* + AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()* + AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer); + Double_t msy = currenttrack1.GetSigmaY2() + + AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()* + AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()* + AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilayer); + if (constrain) { + msz *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadZC(); + msy *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadYC(); + } else { + msz *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadZNonC(); + msy *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadYNonC(); + } + msz = 1./msz; // 1/RoadZ^2 + msy = 1./msy; // 1/RoadY^2 + // - // loop over all possible prolongations // - Double_t msz=1./((currenttrack1.GetSigmaZ2() + 16.*kSigmaZ2[ilayer])); - Double_t msy=1./((currenttrack1.GetSigmaY2() + 16.*kSigmaY2[ilayer])); - if (constrain){ - msy/=60; msz/=60.; - } - else{ - msy/=50; msz/=50.; - } + // LOOP OVER ALL POSSIBLE TRACK PROLONGATIONS ON THIS LAYER // - const AliITSclusterV2 *c=0; Int_t ci=-1; - Double_t chi2=12345.; - Int_t deadzone=0; + const AliITSRecPoint *cl=0; + Int_t clidx=-1; + Double_t chi2trkcl=AliITSReconstructor::GetRecoParam()->GetMaxChi2(); // init with big value + Bool_t deadzoneSPD=kFALSE; currenttrack = ¤ttrack1; - while ((c=layer.GetNextCluster(ci))!=0) { + + // check if the road contains a dead zone + Bool_t noClusters = kFALSE; + if (!layer.GetNextCluster(clidx,kTRUE)) noClusters=kTRUE; + if (noClusters) AliDebug(2,"no clusters in road"); + Double_t dz=0.5*(zmax-zmin); + Double_t dy=0.5*(ymax-ymin); + Int_t dead = CheckDeadZone(¤ttrack1,ilayer,idet,dz,dy,noClusters); + if(dead) AliDebug(2,Form("DEAD (%d)\n",dead)); + // create a prolongation without clusters (check also if there are no clusters in the road) + if (dead || + (noClusters && + AliITSReconstructor::GetRecoParam()->GetAllowProlongationWithEmptyRoad())) { + AliITStrackMI * updatetrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(*currenttrack); + updatetrack->SetClIndex(ilayer,-1); + if (dead==0) { + modstatus = 5; // no cls in road + } else if (dead==1) { + modstatus = 7; // holes in z in SPD + } else if (dead==2 || dead==3 || dead==4) { + modstatus = 2; // dead from OCDB + } + updatetrack->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc); + // apply correction for material of the current layer + CorrectForLayerMaterial(updatetrack,ilayer,trackGlobXYZ1,"inward"); + if (constrain) { // apply vertex constrain + updatetrack->SetConstrain(constrain); + Bool_t isPrim = kTRUE; + if (ilayer<4) { // check that it's close to the vertex + updatetrack->GetDZ(GetX(),GetY(),GetZ(),updatetrack->GetDP()); //I.B. + if (TMath::Abs(updatetrack->GetD(0)/(1.+ilayer)) > // y + AliITSReconstructor::GetRecoParam()->GetMaxDZforPrimTrk() || + TMath::Abs(updatetrack->GetD(1)/(1.+ilayer)) > // z + AliITSReconstructor::GetRecoParam()->GetMaxDZforPrimTrk()) isPrim=kFALSE; + } + if (isPrim) updatetrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx); + } + updatetrack->SetNDeadZone(updatetrack->GetNDeadZone()+1); + if (dead) { + if (dead==1) { // dead zone at z=0,+-7cm in SPD + updatetrack->SetDeadZoneProbability(ilayer,GetSPDDeadZoneProbability(updatetrack->GetZ(),TMath::Sqrt(updatetrack->GetSigmaZ2()))); + deadzoneSPD=kTRUE; + } else if (dead==2 || dead==3) { // dead module or chip from OCDB + updatetrack->SetDeadZoneProbability(ilayer,1.); + } else if (dead==4) { // at least a single dead channel from OCDB + updatetrack->SetDeadZoneProbability(ilayer,0.); + } + } + ntracks[ilayer]++; + } + + clidx=-1; + // loop over clusters in the road + while ((cl=layer.GetNextCluster(clidx))!=0) { if (ntracks[ilayer]>95) break; //space for skipped clusters - Bool_t change =kFALSE; - if (c->GetQ()==0 && (deadzone==1)) continue; - Int_t idet=c->GetDetectorIndex(); - if (currenttrack->GetDetectorIndex()!=idet) { - const AliITSdetector &det=layer.GetDetector(idet); - Double_t y,z; - if (!currenttrack2.GetProlongationFast(det.GetPhi(),det.GetR(),y,z)) continue; - Float_t pz = (z - c->GetZ()) , py=(y - c->GetY()); - if (pz*pz*msz+py*py*msy>1.) continue; + Bool_t changedet =kFALSE; + if (cl->GetQ()==0 && deadzoneSPD==kTRUE) continue; + Int_t idetc=cl->GetDetectorIndex(); + + if (currenttrack->GetDetectorIndex()==idetc) { // track already on the cluster's detector + // take into account misalignment (bring track to real detector plane) + Double_t xTrOrig = currenttrack->GetX(); + if (!currenttrack->Propagate(xTrOrig+cl->GetX())) continue; + // a first cut on track-cluster distance + if ( (currenttrack->GetZ()-cl->GetZ())*(currenttrack->GetZ()-cl->GetZ())*msz + + (currenttrack->GetY()-cl->GetY())*(currenttrack->GetY()-cl->GetY())*msy > 1. ) + { // cluster not associated to track + AliDebug(2,"not associated"); + continue; + } + // bring track back to ideal detector plane + if (!currenttrack->Propagate(xTrOrig)) continue; + } else { // have to move track to cluster's detector + const AliITSdetector &detc=layer.GetDetector(idetc); + // a first cut on track-cluster distance + Double_t y; + if (!currenttrack2.GetProlongationFast(detc.GetPhi(),detc.GetR()+cl->GetX(),y,z)) continue; + if ( (z-cl->GetZ())*(z-cl->GetZ())*msz + + (y-cl->GetY())*(y-cl->GetY())*msy > 1. ) + continue; // cluster not associated to track // new (&backuptrack) AliITStrackMI(currenttrack2); - change = kTRUE; + changedet = kTRUE; currenttrack =¤ttrack2; - if (!currenttrack->Propagate(det.GetPhi(),det.GetR())) { + if (!currenttrack->Propagate(detc.GetPhi(),detc.GetR())) { new (currenttrack) AliITStrackMI(backuptrack); - change = kFALSE; + changedet = kFALSE; continue; } - currenttrack->SetDetectorIndex(idet); - } - else{ - Float_t pz = (currenttrack->GetZ() - c->GetZ()) , py=(currenttrack->GetY() - c->GetY()); - if (pz*pz*msz+py*py*msy>1.) continue; + currenttrack->SetDetectorIndex(idetc); + // Get again the budget to the primary vertex + // for the current track being prolonged, if had to change detector + //budgetToPrimVertex = GetEffectiveThickness();// not needed at the moment because anyway we take a mean material for this correction } - chi2=GetPredictedChi2MI(currenttrack,c,ilayer); - if (chi2GetQ()==0) deadzone=1; // take dead zone only once + // calculate track-clusters chi2 + chi2trkcl = GetPredictedChi2MI(currenttrack,cl,ilayer); + // chi2 cut + AliDebug(2,Form("chi2 %f max %f",chi2trkcl,AliITSReconstructor::GetRecoParam()->GetMaxChi2s(ilayer))); + if (chi2trkcl < AliITSReconstructor::GetRecoParam()->GetMaxChi2s(ilayer)) { + if (cl->GetQ()==0) deadzoneSPD=kTRUE; // only 1 prolongation with virtual cluster if (ntracks[ilayer]>=100) continue; AliITStrackMI * updatetrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(*currenttrack); - updatetrack->fClIndex[ilayer]=0; - if (change){ - new (¤ttrack2) AliITStrackMI(backuptrack); + updatetrack->SetClIndex(ilayer,-1); + if (changedet) new (¤ttrack2) AliITStrackMI(backuptrack); + + if (cl->GetQ()!=0) { // real cluster + if (!UpdateMI(updatetrack,cl,chi2trkcl,(ilayer<<28)+clidx)) { + AliDebug(2,"update failed"); + continue; + } + updatetrack->SetSampledEdx(cl->GetQ(),ilayer-2); + modstatus = 1; // found + } else { // virtual cluster in dead zone + updatetrack->SetNDeadZone(updatetrack->GetNDeadZone()+1); + updatetrack->SetDeadZoneProbability(ilayer,GetSPDDeadZoneProbability(updatetrack->GetZ(),TMath::Sqrt(updatetrack->GetSigmaZ2()))); + modstatus = 7; // holes in z in SPD } - if (c->GetQ()!=0){ - if (!UpdateMI(updatetrack,c,chi2,(ilayer<<28)+ci)) continue; - updatetrack->SetSampledEdx(c->GetQ(),updatetrack->GetNumberOfClusters()-1); //b.b. - } - else { - updatetrack->fNDeadZone++; - updatetrack->fDeadZoneProbability=GetDeadZoneProbability(updatetrack->GetZ(),TMath::Sqrt(updatetrack->GetSigmaZ2())); - } - if (c->IsUsed()){ - updatetrack->fNUsed++; + + if (changedet) { + Float_t xlocnewdet,zlocnewdet; + if(LocalModuleCoord(ilayer,idet,updatetrack,xlocnewdet,zlocnewdet)) { // local module coords + updatetrack->SetModuleIndexInfo(ilayer,idet,modstatus,xlocnewdet,zlocnewdet); + } + } else { + updatetrack->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc); } - Double_t x0; - Double_t d=layer.GetThickness(updatetrack->GetY(),updatetrack->GetZ(),x0); - updatetrack->CorrectForMaterial(d,x0); - if (constrain) { - updatetrack->fConstrain = constrain; - fI = ilayer; - Double_t d=GetEffectiveThickness(0,0); //Think of this !!!! - Double_t xyz[]={GetX(),GetY(),GetZ()}; - Double_t ptfactor = 1; - Double_t ers[]={GetSigmaX()*ptfactor,GetSigmaY()*ptfactor,GetSigmaZ()}; + if (cl->IsUsed()) updatetrack->IncrementNUsed(); + + // apply correction for material of the current layer + CorrectForLayerMaterial(updatetrack,ilayer,trackGlobXYZ1,"inward"); + + if (constrain) { // apply vertex constrain + updatetrack->SetConstrain(constrain); Bool_t isPrim = kTRUE; - if (ilayer<4){ - updatetrack->fD[0] = updatetrack->GetD(GetX(),GetY()); - updatetrack->fD[1] = updatetrack->GetZat(GetX())-GetZ(); - if ( TMath::Abs(updatetrack->fD[0]/(1.+ilayer))>0.4 || TMath::Abs(updatetrack->fD[1]/(1.+ilayer))>0.4) isPrim=kFALSE; + if (ilayer<4) { // check that it's close to the vertex + updatetrack->GetDZ(GetX(),GetY(),GetZ(),updatetrack->GetDP()); //I.B. + if (TMath::Abs(updatetrack->GetD(0)/(1.+ilayer)) > // y + AliITSReconstructor::GetRecoParam()->GetMaxDZforPrimTrk() || + TMath::Abs(updatetrack->GetD(1)/(1.+ilayer)) > // z + AliITSReconstructor::GetRecoParam()->GetMaxDZforPrimTrk()) isPrim=kFALSE; } - if (isPrim) updatetrack->Improve(d,xyz,ers); + if (isPrim) updatetrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx); } //apply vertex constrain ntracks[ilayer]++; - } // create new hypothesy - } // loop over possible cluster prolongation - // if (constrain&&itrack<2&¤ttrack1.fNSkipped==0 && deadzone==0){ - if (constrain&&itrack<2&¤ttrack1.fNSkipped==0 && deadzone==0&&ntracks[ilayer]<100){ + } // create new hypothesis + else { + AliDebug(2,"chi2 too large"); + } + + } // loop over possible prolongations + + // allow one prolongation without clusters + if (constrain && itrack<=1 && currenttrack1.GetNSkipped()==0 && deadzoneSPD==kFALSE && ntracks[ilayer]<100) { AliITStrackMI* vtrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(currenttrack1); - vtrack->fClIndex[ilayer]=0; - fI = ilayer; - Double_t d=GetEffectiveThickness(0,0); //Think of this !!!! - Double_t xyz[]={GetX(),GetY(),GetZ()}; - Double_t ers[]={GetSigmaX(),GetSigmaY(),GetSigmaZ()}; - vtrack->Improve(d,xyz,ers); - vtrack->fNSkipped++; + // apply correction for material of the current layer + CorrectForLayerMaterial(vtrack,ilayer,trackGlobXYZ1,"inward"); + vtrack->SetClIndex(ilayer,-1); + modstatus = 3; // skipped + vtrack->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc); + vtrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx); + vtrack->IncrementNSkipped(); ntracks[ilayer]++; } - if (constrain&&itrack<1&&TMath::Abs(currenttrack1.fP3)>1.1){ //big theta -- for low mult. runs + // allow one prolongation without clusters for tracks with |tgl|>1.1 + if (constrain && itrack==0 && TMath::Abs(currenttrack1.GetTgl())>1.1) { //big theta - for low flux AliITStrackMI* vtrack = new (&tracks[ilayer][ntracks[ilayer]]) AliITStrackMI(currenttrack1); - vtrack->fClIndex[ilayer]=0; - fI = ilayer; - Double_t d=GetEffectiveThickness(0,0); //Think of this !!!! - Double_t xyz[]={GetX(),GetY(),GetZ()}; - Double_t ers[]={GetSigmaX(),GetSigmaY(),GetSigmaZ()}; - vtrack->Improve(d,xyz,ers); - vtrack->fNDeadZone++; + // apply correction for material of the current layer + CorrectForLayerMaterial(vtrack,ilayer,trackGlobXYZ1,"inward"); + vtrack->SetClIndex(ilayer,-1); + modstatus = 3; // skipped + vtrack->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc); + vtrack->Improve(budgetToPrimVertex,xyzVtx,ersVtx); + vtrack->SetNDeadZone(vtrack->GetNDeadZone()+1); ntracks[ilayer]++; } - } //loop over track candidates + } // loop over tracks in layer ilayer+1 + + //loop over track candidates for the current layer // // Int_t accepted=0; - Int_t golds=0; + Int_t golden=0; for (Int_t itrack=0;itrack4) accepted++; - else{ - if ( constrain && normalizedchi2[itrack]GetMaxNormChi2ForGolden(ilayer)) golden++; + if (ilayer>4) { + accepted++; + } else { + if (constrain) { // constrain + if (normalizedchi2[itrack]GetMaxNormChi2C(ilayer)+1) + accepted++; + } else { // !constrain + if (normalizedchi2[itrack]GetMaxNormChi2NonC(ilayer)+1) + accepted++; + } } } - TMath::Sort(ntracks[ilayer],normalizedchi2,nindexes[ilayer],kFALSE); + // sort tracks by increasing normalized chi2 + TMath::Sort(ntracks[ilayer],normalizedchi2,nindexes[ilayer],kFALSE); ntracks[ilayer] = TMath::Min(accepted,7+2*ilayer); - if (ntracks[ilayer]90) ntracks[ilayer]=90; - } //loop over layers - //printf("%d\t%d\t%d\t%d\t%d\t%d\n",ntracks[0],ntracks[1],ntracks[2],ntracks[3],ntracks[4],ntracks[5]); - Int_t max = constrain? 20: 5; + } // end loop over layers + + + // + // Now select tracks to be kept + // + Int_t max = constrain ? 20 : 5; - for (Int_t i=0;i7.)continue; + if (!constrain && track.GetNormChi2(0) > + AliITSReconstructor::GetRecoParam()->GetMaxNormChi2NonCForHypothesis()) { + continue; + } AddTrackHypothesys(new AliITStrackMI(track), esdindex); } + + // tracks that reach layer 1 (SPD outer) for (Int_t i=0;i7.)continue; - if (constrain) track.fNSkipped+=1; + if (!constrain && track.GetNormChi2(1) > + AliITSReconstructor::GetRecoParam()->GetMaxNormChi2NonCForHypothesis()) continue; + if (constrain) track.IncrementNSkipped(); if (!constrain) { - track.fD[0] = track.GetD(GetX(),GetY()); - track.fNSkipped+=4./(4.+8.*TMath::Abs(track.fD[0])); - if (track.fN+track.fNDeadZone+track.fNSkipped>6) { - track.fNSkipped = 6-track.fN+track.fNDeadZone; + track.SetD(0,track.GetD(GetX(),GetY())); + track.SetNSkipped(track.GetNSkipped()+4./(4.+8.*TMath::Abs(track.GetD(0)))); + if (track.GetNumberOfClusters()+track.GetNDeadZone()+track.GetNSkipped()>6) { + track.SetNSkipped(6-track.GetNumberOfClusters()+track.GetNDeadZone()); } } AddTrackHypothesys(new AliITStrackMI(track), esdindex); } - //} - + + // tracks that reach layer 2 (SDD inner), only during non-constrained pass if (!constrain){ for (Int_t i=0;i7.)continue; - if (constrain) track.fNSkipped+=2; + if (!constrain && track.GetNormChi2(2) > + AliITSReconstructor::GetRecoParam()->GetMaxNormChi2NonCForHypothesis()) continue; + if (constrain) track.SetNSkipped(track.GetNSkipped()+2); if (!constrain){ - track.fD[0] = track.GetD(GetX(),GetY()); - track.fNSkipped+= 7./(7.+8.*TMath::Abs(track.fD[0])); - if (track.fN+track.fNDeadZone+track.fNSkipped>6) { - track.fNSkipped = 6-track.fN+track.fNDeadZone; + track.SetD(0,track.GetD(GetX(),GetY())); + track.SetNSkipped(track.GetNSkipped()+7./(7.+8.*TMath::Abs(track.GetD(0)))); + if (track.GetNumberOfClusters()+track.GetNDeadZone()+track.GetNSkipped()>6) { + track.SetNSkipped(6-track.GetNumberOfClusters()+track.GetNDeadZone()); } } AddTrackHypothesys(new AliITStrackMI(track), esdindex); } } - if (!constrain){ + if (!constrain) { // - // register best tracks - important for V0 finder + // register best track of each layer - important for V0 finder // for (Int_t ilayer=0;ilayer<5;ilayer++){ if (ntracks[ilayer]==0) continue; @@ -849,22 +1354,23 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin // // update TPC V0 information // - if (otrack->fESDtrack->GetV0Index(0)>0){ + if (otrack->GetESDtrack()->GetV0Index(0)>0){ Float_t fprimvertex[3]={GetX(),GetY(),GetZ()}; for (Int_t i=0;i<3;i++){ - Int_t index = otrack->fESDtrack->GetV0Index(i); + Int_t index = otrack->GetESDtrack()->GetV0Index(i); if (index==0) break; - AliESDV0MI * vertex = fEsd->GetV0MI(index); + AliV0 *vertex = (AliV0*)fEsd->GetV0(index); if (vertex->GetStatus()<0) continue; // rejected V0 // - if (otrack->fP4>0) { + if (otrack->GetSign()>0) { vertex->SetIndex(0,esdindex); } else{ vertex->SetIndex(1,esdindex); } //find nearest layer with track info - Int_t nearestold = GetNearestLayer(vertex->GetXrp()); + Double_t xrp[3]; vertex->GetXYZ(xrp[0],xrp[1],xrp[2]); //I.B. + Int_t nearestold = GetNearestLayer(xrp); //I.B. Int_t nearest = nearestold; for (Int_t ilayer =nearest;ilayer<8;ilayer++){ if (ntracks[nearest]==0){ @@ -874,38 +1380,29 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin // AliITStrackMI & track= tracks[nearest][nindexes[nearest][0]]; if (nearestold<5&&nearest<5){ - Bool_t accept = track.fNormChi2[nearest]<10; + Bool_t accept = track.GetNormChi2(nearest)<10; if (accept){ - if (track.fP4>0) { - vertex->SetP(track); + if (track.GetSign()>0) { + vertex->SetParamP(track); vertex->Update(fprimvertex); - // vertex->SetIndex(0,track.fESDtrack->GetID()); + //vertex->SetIndex(0,track.fESDtrack->GetID()); if (track.GetNumberOfClusters()>2) AddTrackHypothesys(new AliITStrackMI(track), esdindex); }else{ - vertex->SetM(track); + vertex->SetParamN(track); vertex->Update(fprimvertex); //vertex->SetIndex(1,track.fESDtrack->GetID()); if (track.GetNumberOfClusters()>2) AddTrackHypothesys(new AliITStrackMI(track), esdindex); } vertex->SetStatus(vertex->GetStatus()+1); }else{ - // vertex->SetStatus(-2); // reject V0 - not enough clusters + //vertex->SetStatus(-2); // reject V0 - not enough clusters } } - // if (nearestold>3){ -// Int_t indexlayer = (ntracks[0]>0)? 0:1; -// if (ntracks[indexlayer]>0){ -// AliITStrackMI & track= tracks[indexlayer][nindexes[indexlayer][0]]; -// if (track.GetNumberOfClusters()>4&&track.fNormChi2[indexlayer]<4){ -// vertex->SetStatus(-1); // reject V0 - clusters before -// } -// } -// } } - } + } + } - - +//------------------------------------------------------------------------ AliITStrackerMI::AliITSlayer & AliITStrackerMI::GetLayer(Int_t layer) const { //-------------------------------------------------------------------- @@ -913,15 +1410,41 @@ AliITStrackerMI::AliITSlayer & AliITStrackerMI::GetLayer(Int_t layer) const // return fgLayers[layer]; } -AliITStrackerMI::AliITSlayer::AliITSlayer() { +//------------------------------------------------------------------------ +AliITStrackerMI::AliITSlayer::AliITSlayer(): +fR(0), +fPhiOffset(0), +fNladders(0), +fZOffset(0), +fNdetectors(0), +fDetectors(0), +fN(0), +fDy5(0), +fDy10(0), +fDy20(0), +fClustersCs(0), +fClusterIndexCs(0), +fYcs(0), +fZcs(0), +fNcs(0), +fCurrentSlice(-1), +fZmin(0), +fZmax(0), +fYmin(0), +fYmax(0), +fI(0), +fImax(0), +fSkip(0), +fAccepted(0), +fRoad(0), +fMaxSigmaClY(0), +fMaxSigmaClZ(0), +fNMaxSigmaCl(3) +{ //-------------------------------------------------------------------- //default AliITSlayer constructor //-------------------------------------------------------------------- - fN=0; - fDetectors=0; - fSkip = 0; - fCurrentSlice=-1; - for (Int_t i=0; iIsUsed()) cl->Use(); } } - +//------------------------------------------------------------------------ void AliITStrackerMI::AliITSlayer::ResetRoad() { //-------------------------------------------------------------------- // This function calculates the road defined by the cluster density @@ -1003,42 +1581,55 @@ void AliITStrackerMI::AliITSlayer::ResetRoad() { for (Int_t i=0; iGetZ())1) fRoad=2*fR*TMath::Sqrt(3.14/n); - if (n>1) fRoad=2*fR*TMath::Sqrt(3.14/n); + if (n>1) fRoad=2*fR*TMath::Sqrt(TMath::Pi()/n); } - - -Int_t AliITStrackerMI::AliITSlayer::InsertCluster(AliITSclusterV2 *c) { +//------------------------------------------------------------------------ +Int_t AliITStrackerMI::AliITSlayer::InsertCluster(AliITSRecPoint *cl) { //-------------------------------------------------------------------- //This function adds a cluster to this layer //-------------------------------------------------------------------- - if (fN==kMaxClusterPerLayer) { + if (fN==AliITSRecoParam::GetMaxClusterPerLayer()) { ::Error("InsertCluster","Too many clusters !\n"); return 1; } fCurrentSlice=-1; - fClusters[fN]=c; + fClusters[fN]=cl; fN++; - AliITSdetector &det=GetDetector(c->GetDetectorIndex()); - if (c->GetY()GetY()); - if (c->GetY()>det.GetYmax()) det.SetYmax(c->GetY()); - if (c->GetZ()GetZ()); - if (c->GetZ()>det.GetZmax()) det.SetZmax(c->GetZ()); - + AliITSdetector &det=GetDetector(cl->GetDetectorIndex()); + //AD + Double_t nSigmaY=fNMaxSigmaCl*TMath::Sqrt(cl->GetSigmaY2()); + Double_t nSigmaZ=fNMaxSigmaCl*TMath::Sqrt(cl->GetSigmaZ2()); + if (cl->GetY()-nSigmaYGetY()-nSigmaY); + if (cl->GetY()+nSigmaY>det.GetYmax()) det.SetYmax(cl->GetY()+nSigmaY); + if (cl->GetZ()-nSigmaZGetZ()-nSigmaZ); + if (cl->GetZ()+nSigmaZ>det.GetZmax()) det.SetZmax(cl->GetZ()+nSigmaZ); + //AD + /* + if (cl->GetY()GetY()); + if (cl->GetY()>det.GetYmax()) det.SetYmax(cl->GetY()); + if (cl->GetZ()GetZ()); + if (cl->GetZ()>det.GetZmax()) det.SetZmax(cl->GetZ()); + */ return 0; } - +//------------------------------------------------------------------------ void AliITStrackerMI::AliITSlayer::SortClusters() { // //sort clusters // - AliITSclusterV2 **clusters = new AliITSclusterV2*[fN]; + AliITSRecPoint **clusters = new AliITSRecPoint*[fN]; Float_t *z = new Float_t[fN]; Int_t * index = new Int_t[fN]; // + fMaxSigmaClY=0.; //AD + fMaxSigmaClZ=0.; //AD + for (Int_t i=0;iGetZ(); + // save largest errors in y and z for this layer + fMaxSigmaClY=TMath::Max(fMaxSigmaClY,TMath::Sqrt(fClusters[i]->GetSigmaY2())); + fMaxSigmaClZ=TMath::Max(fMaxSigmaClZ,TMath::Sqrt(fClusters[i]->GetSigmaZ2())); } TMath::Sort(fN,z,index,kFALSE); for (Int_t i=0;ifZ[i+1]){ - printf("Bugg\n"); + printf("Bug\n"); } } // for (Int_t slice=0;slice<21;slice++) for (Int_t i=0;ifZ20[slice][i+1]){ - printf("Bugg\n"); + printf("Bug\n"); } } } - - +//------------------------------------------------------------------------ Int_t AliITStrackerMI::AliITSlayer::FindClusterIndex(Float_t z) const { //-------------------------------------------------------------------- // This function returns the index of the nearest cluster @@ -1158,8 +1748,59 @@ Int_t AliITStrackerMI::AliITSlayer::FindClusterIndex(Float_t z) const { } return m; } +//------------------------------------------------------------------------ +Bool_t AliITStrackerMI::ComputeRoad(AliITStrackMI* track,Int_t ilayer,Int_t idet,Double_t &zmin,Double_t &zmax,Double_t &ymin,Double_t &ymax) const { + //-------------------------------------------------------------------- + // This function computes the rectangular road for this track + //-------------------------------------------------------------------- + + + AliITSdetector &det = fgLayers[ilayer].GetDetector(idet); + // take into account the misalignment: propagate track to misaligned detector plane + if (!track->Propagate(det.GetPhi(),det.GetRmisal())) return kFALSE; + + Double_t dz=AliITSReconstructor::GetRecoParam()->GetNSigmaRoadZ()* + TMath::Sqrt(track->GetSigmaZ2() + + AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()* + AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()* + AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer)); + Double_t dy=AliITSReconstructor::GetRecoParam()->GetNSigmaRoadY()* + TMath::Sqrt(track->GetSigmaY2() + + AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()* + AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()* + AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilayer)); + + // track at boundary between detectors, enlarge road + Double_t boundaryWidth=AliITSRecoParam::GetBoundaryWidth(); + if ( (track->GetY()-dy < det.GetYmin()+boundaryWidth) || + (track->GetY()+dy > det.GetYmax()-boundaryWidth) || + (track->GetZ()-dz < det.GetZmin()+boundaryWidth) || + (track->GetZ()+dz > det.GetZmax()-boundaryWidth) ) { + Float_t tgl = TMath::Abs(track->GetTgl()); + if (tgl > 1.) tgl=1.; + Double_t deltaXNeighbDets=AliITSRecoParam::GetDeltaXNeighbDets(); + dz = TMath::Sqrt(dz*dz+deltaXNeighbDets*deltaXNeighbDets*tgl*tgl); + Float_t snp = TMath::Abs(track->GetSnp()); + if (snp > AliITSReconstructor::GetRecoParam()->GetMaxSnp()) return kFALSE; + dy = TMath::Sqrt(dy*dy+deltaXNeighbDets*deltaXNeighbDets*snp*snp); + } // boundary + + // add to the road a term (up to 2-3 mm) to deal with misalignments + dy = TMath::Sqrt(dy*dy + AliITSReconstructor::GetRecoParam()->GetRoadMisal()*AliITSReconstructor::GetRecoParam()->GetRoadMisal()); + dz = TMath::Sqrt(dz*dz + AliITSReconstructor::GetRecoParam()->GetRoadMisal()*AliITSReconstructor::GetRecoParam()->GetRoadMisal()); + + Double_t r = fgLayers[ilayer].GetR(); + zmin = track->GetZ() - dz; + zmax = track->GetZ() + dz; + ymin = track->GetY() + r*det.GetPhi() - dy; + ymax = track->GetY() + r*det.GetPhi() + dy; + // bring track back to idead detector plane + if (!track->Propagate(det.GetPhi(),det.GetR())) return kFALSE; + return kTRUE; +} +//------------------------------------------------------------------------ void AliITStrackerMI::AliITSlayer:: SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin, Double_t ymax) { //-------------------------------------------------------------------- @@ -1167,12 +1808,24 @@ SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin, Double_t ymax) { //-------------------------------------------------------------------- Double_t circle=2*TMath::Pi()*fR; - fYmin = ymin; fYmax =ymax; + fYmin = ymin; + fYmax = ymax; + fZmin = zmin; + fZmax = zmax; + // AD + // enlarge road in y by maximum cluster error on this layer (3 sigma) + fYmin -= fNMaxSigmaCl*fMaxSigmaClY; + fYmax += fNMaxSigmaCl*fMaxSigmaClY; + fZmin -= fNMaxSigmaCl*fMaxSigmaClZ; + fZmax += fNMaxSigmaCl*fMaxSigmaClZ; + Float_t ymiddle = (fYmin+fYmax)*0.5; - if (ymiddlefYB[1]) {fYmin-=circle; fYmax-=circle;ymiddle-=circle;} + if (ymiddlefYB[1]) { + fYmin-=circle; fYmax-=circle; ymiddle-=circle; } + // fCurrentSlice =-1; // defualt take all @@ -1220,7 +1873,7 @@ SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin, Double_t ymax) { if (slice<0) slice=0; if (slice>5) slice=5; Bool_t isOK = (fYmin>fBy5[slice][0]&&fYmax= 2*TMath::Pi()) dphi -= 2*TMath::Pi(); Int_t np=Int_t(dphi*fNladders*0.5/TMath::Pi()+0.5); if (np>=fNladders) np-=fNladders; if (np<0) np+=fNladders; + Double_t dz=fZOffset-z; - Int_t nz=Int_t(dz*(fNdetectors-1)*0.5/fZOffset+0.5); + Double_t nnz = dz*(fNdetectors-1)*0.5/fZOffset+0.5; + Int_t nz = (nnz<0 ? -1 : (Int_t)nnz); if (nz>=fNdetectors) return -1; if (nz<0) return -1; - return np*fNdetectors + nz; -} + // ad hoc correction for 3rd ladder of SDD inner layer, + // which is reversed (rotated by pi around local y) + // this correction is OK only from AliITSv11Hybrid onwards + if (GetR()>12. && GetR()<20.) { // SDD inner + if(np==2) { // 3rd ladder + nz = (fNdetectors-1) - nz; + } + } + //printf("ndet %d phi %f z %f np %d nz %d\n",fNdetectors,phi,z,np,nz); -const AliITSclusterV2 *AliITStrackerMI::AliITSlayer::GetNextCluster(Int_t &ci){ + return np*fNdetectors + nz; +} +//------------------------------------------------------------------------ +const AliITSRecPoint *AliITStrackerMI::AliITSlayer::GetNextCluster(Int_t &ci,Bool_t test) +{ //-------------------------------------------------------------------- // This function returns clusters within the "window" //-------------------------------------------------------------------- - if (fCurrentSlice<0){ + if (fCurrentSlice<0) { Double_t rpi2 = 2.*fR*TMath::Pi(); for (Int_t i=fI; iy) y += rpi2; if (yfYmax) continue; + // AD + // skip clusters that are in "extended" road but they + // 3sigma error does not touch the original road + if (z+fNMaxSigmaCl*TMath::Sqrt(fClusters[i]->GetSigmaZ2())GetSigmaZ2())>fZmax-fNMaxSigmaCl*fMaxSigmaClZ) continue; + // if (fClusters[i]->GetQ()==0&&fSkip==2) continue; ci=i; - fI=i+1; + if (!test) fI=i+1; return fClusters[i]; } - } - else{ + } else { for (Int_t i=fI; ifYmax) continue; if (fClustersCs[i]->GetQ()==0&&fSkip==2) continue; ci=fClusterIndexCs[i]; - fI=i+1; + if (!test) fI=i+1; return fClustersCs[i]; } } return 0; } - - - +//------------------------------------------------------------------------ Double_t AliITStrackerMI::AliITSlayer::GetThickness(Double_t y,Double_t z,Double_t &x0) const { //-------------------------------------------------------------------- - //This function returns the layer thickness at this point (units X0) + // This function returns the layer thickness at this point (units X0) //-------------------------------------------------------------------- Double_t d=0.0085; - x0=21.82; + x0=AliITSRecoParam::GetX0Air(); if (430.5) d+=dd; - //if (TMath::Abs(y-3.08)>0.45) d+=dd; - if (TMath::Abs(y-3.03)<0.10) {d+=0.014;} + if (TMath::Abs(y-3.03)<0.10) d+=0.014; } else if (30.6) d+=dd; - //if (TMath::Abs(y+0.21)>0.45) d+=dd; - if (TMath::Abs(y+0.10)<0.10) {d+=0.014;} + if (TMath::Abs(y+0.10)<0.10) d+=0.014; } return d; } +//------------------------------------------------------------------------ +AliITStrackerMI::AliITSdetector::AliITSdetector(const AliITSdetector& det): +fR(det.fR), +fRmisal(det.fRmisal), +fPhi(det.fPhi), +fSinPhi(det.fSinPhi), +fCosPhi(det.fCosPhi), +fYmin(det.fYmin), +fYmax(det.fYmax), +fZmin(det.fZmin), +fZmax(det.fZmax), +fIsBad(det.fIsBad), +fNChips(det.fNChips), +fChipIsBad(det.fChipIsBad) +{ + //Copy constructor +} +//------------------------------------------------------------------------ +void AliITStrackerMI::AliITSdetector::ReadBadDetectorAndChips(Int_t ilayer,Int_t idet, + const AliITSDetTypeRec *detTypeRec) +{ + //-------------------------------------------------------------------- + // Read bad detectors and chips from calibration objects in AliITSDetTypeRec + //-------------------------------------------------------------------- + + // In AliITSDetTypeRec, detector numbers go from 0 to 2197 + // while in the tracker they start from 0 for each layer + for(Int_t il=0; ilGetCalibrationModel(idet); + calib->SetModuleIndex(idet); + AliITSCalibration *calibSPDdead = 0; + if(detType==0) calibSPDdead = (AliITSCalibration*)detTypeRec->GetSPDDeadModel(idet); // TEMPORARY + if (calib->IsBad() || + (detType==0 && calibSPDdead->IsBad())) // TEMPORARY + { + SetBad(); + // printf("lay %d bad %d\n",ilayer,idet); + } + + // Get segmentation from AliITSDetTypeRec + AliITSsegmentation *segm = (AliITSsegmentation*)detTypeRec->GetSegmentationModel(detType); + + // Read info about bad chips + fNChips = segm->GetMaximumChipIndex()+1; + //printf("ilayer %d detType %d idet %d fNChips %d %d GetNumberOfChips %d\n",ilayer,detType,idet,fNChips,segm->GetMaximumChipIndex(),segm->GetNumberOfChips()); + if(fChipIsBad) { delete [] fChipIsBad; fChipIsBad=NULL; } + fChipIsBad = new Bool_t[fNChips]; + for (Int_t iCh=0;iChIsChipBad(iCh); + if (detType==0 && calibSPDdead->IsChipBad(iCh)) fChipIsBad[iCh] = kTRUE; // TEMPORARY + //if(fChipIsBad[iCh]) {printf("lay %d det %d bad chip %d\n",ilayer,idet,iCh);} + } -Double_t AliITStrackerMI::GetEffectiveThickness(Double_t y,Double_t z) const + return; +} +//------------------------------------------------------------------------ +Double_t AliITStrackerMI::GetEffectiveThickness() { //-------------------------------------------------------------------- - //Returns the thickness between the current layer and the vertex (units X0) + // Returns the thickness between the current layer and the vertex (units X0) //-------------------------------------------------------------------- - Double_t d=0.0028*3*3; //beam pipe - Double_t x0=0; + if(fUseTGeo!=0) { + if(fxOverX0Layer[0]<0) BuildMaterialLUT("Layers"); + if(fxOverX0Shield[0]<0) BuildMaterialLUT("Shields"); + if(fxOverX0Pipe<0) BuildMaterialLUT("Pipe"); + } + + // beam pipe + Double_t dPipe = (fUseTGeo==0 ? AliITSRecoParam::GetdPipe() : fxOverX0Pipe); + Double_t d=dPipe*AliITSRecoParam::GetrPipe()*AliITSRecoParam::GetrPipe(); + + // layers + Double_t x0=0; Double_t xn=fgLayers[fI].GetR(); for (Int_t i=0; i1) { - Double_t xi=9.; - d+=0.0097*xi*xi; + Double_t dshieldSPD = (fUseTGeo==0 ? AliITSRecoParam::Getdshield(0) : fxOverX0Shield[0]); + d+=dshieldSPD*AliITSRecoParam::GetrInsideShield(0)*AliITSRecoParam::GetrInsideShield(0); } - if (fI>3) { - Double_t xi=0.5*(fgLayers[3].GetR()+fgLayers[4].GetR()); - d+=0.0034*xi*xi; + Double_t dshieldSDD = (fUseTGeo==0 ? AliITSRecoParam::Getdshield(1) : fxOverX0Shield[1]); + d+=dshieldSDD*AliITSRecoParam::GetrInsideShield(1)*AliITSRecoParam::GetrInsideShield(1); } - return d/(xn*xn); } - +//------------------------------------------------------------------------ Int_t AliITStrackerMI::AliITSlayer::InRoad() const { - //-------------------------------------------------------------------- + //------------------------------------------------------------------- // This function returns number of clusters within the "window" //-------------------------------------------------------------------- Int_t ncl=0; for (Int_t i=fI; iGetZ() > fZmax) break; if (c->IsUsed()) continue; const AliITSdetector &det=GetDetector(c->GetDetectorIndex()); @@ -1442,285 +2195,216 @@ Int_t AliITStrackerMI::AliITSlayer::InRoad() const { } return ncl; } - -Bool_t -AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,const AliITStrackMI *c) { +//------------------------------------------------------------------------ +Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *track, + const AliITStrackMI *clusters,Bool_t extra, Bool_t planeeff) +{ //-------------------------------------------------------------------- - // This function refits the track "t" at the position "x" using - // the clusters from "c" + // This function refits the track "track" at the position "x" using + // the clusters from "clusters" + // If "extra"==kTRUE, + // the clusters from overlapped modules get attached to "track" + // If "planeff"==kTRUE, + // special approach for plane efficiency evaluation is applyed //-------------------------------------------------------------------- - Int_t index[kMaxLayer]; + + Int_t index[AliITSgeomTGeo::kNLayers]; Int_t k; - for (k=0; kGetNumberOfClusters(); + for (k=0; kGetNumberOfClusters(); for (k=0; kGetClusterIndex(k),nl=(idx&0xf0000000)>>28; - index[nl]=idx; - } - - Int_t from, to, step; - if (xx > t->GetX()) { - from=0; to=kMaxLayer; - step=+1; - } else { - from=kMaxLayer-1; to=-1; - step=-1; + Int_t idx=clusters->GetClusterIndex(k); + Int_t ilayer=(idx&0xf0000000)>>28; + index[ilayer]=idx; } - for (Int_t i=from; i != to; i += step) { - AliITSlayer &layer=fgLayers[i]; - Double_t r=layer.GetR(); - - { - Double_t hI=i-0.5*step; - if (TMath::Abs(hI-1.5)<0.01 || TMath::Abs(hI-3.5)<0.01) { - Double_t rs=0.5*(fgLayers[i-step].GetR() + r); - Double_t d=0.0034, x0=38.6; - if (TMath::Abs(hI-1.5)<0.01) {rs=9.; d=0.0097; x0=42;} - if (!t->PropagateTo(rs,-step*d,x0)) { - return kFALSE; - } - } - } - - // remember old position [SR, GSI 18.02.2003] - Double_t oldX=0., oldY=0., oldZ=0.; - if (t->IsStartedTimeIntegral() && step==1) { - t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ); - } - // - - Double_t x,y,z; - if (!t->GetGlobalXYZat(r,x,y,z)) { - return kFALSE; - } - Double_t phi=TMath::ATan2(y,x); - Int_t idet=layer.FindDetectorIndex(phi,z); - if (idet<0) { - return kFALSE; - } - const AliITSdetector &det=layer.GetDetector(idet); - phi=det.GetPhi(); - if (!t->Propagate(phi,det.GetR())) { - return kFALSE; - } - t->SetDetectorIndex(idet); - - const AliITSclusterV2 *cl=0; - Double_t maxchi2=1000.*kMaxChi2; - - Int_t idx=index[i]; - if (idx>0) { - const AliITSclusterV2 *c=(AliITSclusterV2 *)GetCluster(idx); - if (c){ - if (idet != c->GetDetectorIndex()) { - idet=c->GetDetectorIndex(); - const AliITSdetector &det=layer.GetDetector(idet); - if (!t->Propagate(det.GetPhi(),det.GetR())) { - return kFALSE; - } - t->SetDetectorIndex(idet); - } - //Double_t chi2=t->GetPredictedChi2(c); - Int_t layer = (idx & 0xf0000000) >> 28;; - Double_t chi2=GetPredictedChi2MI(t,c,layer); - if (chi2GetNumberOfClusters()>2) { - Double_t dz=4*TMath::Sqrt(t->GetSigmaZ2()+kSigmaZ2[i]); - Double_t dy=4*TMath::Sqrt(t->GetSigmaY2()+kSigmaY2[i]); - Double_t zmin=t->GetZ() - dz; - Double_t zmax=t->GetZ() + dz; - Double_t ymin=t->GetY() + phi*r - dy; - Double_t ymax=t->GetY() + phi*r + dy; - layer.SelectClusters(zmin,zmax,ymin,ymax); - - const AliITSclusterV2 *c=0; Int_t ci=-1; - while ((c=layer.GetNextCluster(ci))!=0) { - if (idet != c->GetDetectorIndex()) continue; - Double_t chi2=t->GetPredictedChi2(c); - if (chi2Update(cl,maxchi2,idx)) { - if (!UpdateMI(t,cl,maxchi2,idx)) { - return kFALSE; - } - t->SetSampledEdx(cl->GetQ(),t->GetNumberOfClusters()-1); - } - - { - Double_t x0; - Double_t d=layer.GetThickness(t->GetY(),t->GetZ(),x0); - t->CorrectForMaterial(-step*d,x0); - } - - // track time update [SR, GSI 17.02.2003] - if (t->IsStartedTimeIntegral() && step==1) { - Double_t newX, newY, newZ; - t->GetGlobalXYZat(t->GetX(),newX,newY,newZ); - Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) + - (oldZ-newZ)*(oldZ-newZ); - t->AddTimeStep(TMath::Sqrt(dL2)); - } - // - - } - - if (!t->PropagateTo(xx,0.,0.)) return kFALSE; - return kTRUE; + return RefitAt(xx,track,index,extra,planeeff); // call the method below } - - -Bool_t -AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,const Int_t *clindex) { +//------------------------------------------------------------------------ +Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *track, + const Int_t *clusters,Bool_t extra, Bool_t planeeff) +{ //-------------------------------------------------------------------- - // This function refits the track "t" at the position "x" using + // This function refits the track "track" at the position "x" using // the clusters from array + // If "extra"==kTRUE, + // the clusters from overlapped modules get attached to "track" + // If "planeff"==kTRUE, + // special approach for plane efficiency evaluation is applyed //-------------------------------------------------------------------- - Int_t index[kMaxLayer]; + Int_t index[AliITSgeomTGeo::kNLayers]; Int_t k; - for (k=0; kGetD(0.,0.)); + for(innermostlayer=0; innermostlayer t->GetX()) { - from=0; to=kMaxLayer; + if (xx > track->GetX()) { + from=innermostlayer; to=AliITSgeomTGeo::GetNLayers(); step=+1; } else { - from=kMaxLayer-1; to=-1; + from=AliITSgeomTGeo::GetNLayers()-1; to=innermostlayer-1; step=-1; } + TString dir = (step>0 ? "outward" : "inward"); - for (Int_t i=from; i != to; i += step) { - AliITSlayer &layer=fgLayers[i]; + for (Int_t ilayer = from; ilayer != to; ilayer += step) { + AliITSlayer &layer=fgLayers[ilayer]; Double_t r=layer.GetR(); - if (step<0 && xx>r) break; // - { - Double_t hI=i-0.5*step; - if (TMath::Abs(hI-1.5)<0.01 || TMath::Abs(hI-3.5)<0.01) { - Double_t rs=0.5*(fgLayers[i-step].GetR() + r); - Double_t d=0.0034, x0=38.6; - if (TMath::Abs(hI-1.5)<0.01) {rs=9.; d=0.0097; x0=42;} - if (!t->PropagateTo(rs,-step*d,x0)) { - return kFALSE; - } - } - } + if (step<0 && xx>r) break; - // remember old position [SR, GSI 18.02.2003] - Double_t oldX=0., oldY=0., oldZ=0.; - if (t->IsStartedTimeIntegral() && step==1) { - t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ); - } - // + // material between SSD and SDD, SDD and SPD + Double_t hI=ilayer-0.5*step; + if (TMath::Abs(hI-3.5)<0.01) // SDDouter + if(!CorrectForShieldMaterial(track,"SDD",dir)) return kFALSE; + if (TMath::Abs(hI-1.5)<0.01) // SPDouter + if(!CorrectForShieldMaterial(track,"SPD",dir)) return kFALSE; + + + Double_t oldGlobXYZ[3]; + if (!track->GetXYZ(oldGlobXYZ)) return kFALSE; + + // continue if we are already beyond this layer + Double_t oldGlobR = TMath::Sqrt(oldGlobXYZ[0]*oldGlobXYZ[0]+oldGlobXYZ[1]*oldGlobXYZ[1]); + if(step>0 && oldGlobR > r) continue; // going outward + if(step<0 && oldGlobR < r) continue; // going inward + + Double_t phi,z; + if (!track->GetPhiZat(r,phi,z)) return kFALSE; - Double_t x,y,z; - if (!t->GetGlobalXYZat(r,x,y,z)) { - return kFALSE; - } - Double_t phi=TMath::ATan2(y,x); Int_t idet=layer.FindDetectorIndex(phi,z); - if (idet<0) { - return kFALSE; + + // check if we allow a prolongation without point for large-eta tracks + Int_t skip = CheckSkipLayer(track,ilayer,idet); + if (skip==2) { + modstatus = 4; // out in z + if(LocalModuleCoord(ilayer,idet,track,xloc,zloc)) { // local module coords + track->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc); + } + // cross layer + // apply correction for material of the current layer + // add time if going outward + CorrectForLayerMaterial(track,ilayer,oldGlobXYZ,dir); + continue; } + + if (idet<0) return kFALSE; + const AliITSdetector &det=layer.GetDetector(idet); - phi=det.GetPhi(); - if (!t->Propagate(phi,det.GetR())) { - return kFALSE; - } - t->SetDetectorIndex(idet); - - const AliITSclusterV2 *cl=0; - Double_t maxchi2=1000.*kMaxChi2; - - Int_t idx=index[i]; - if (idx>0) { - const AliITSclusterV2 *c=(AliITSclusterV2 *)GetCluster(idx); - if (c){ - if (idet != c->GetDetectorIndex()) { - idet=c->GetDetectorIndex(); - const AliITSdetector &det=layer.GetDetector(idet); - if (!t->Propagate(det.GetPhi(),det.GetR())) { - return kFALSE; - } - t->SetDetectorIndex(idet); - } - //Double_t chi2=t->GetPredictedChi2(c); - Int_t layer = (idx & 0xf0000000) >> 28;; - Double_t chi2=GetPredictedChi2MI(t,c,layer); - if (chi2GetNumberOfClusters()>2) { - Double_t dz=4*TMath::Sqrt(t->GetSigmaZ2()+kSigmaZ2[i]); - Double_t dy=4*TMath::Sqrt(t->GetSigmaY2()+kSigmaY2[i]); - Double_t zmin=t->GetZ() - dz; - Double_t zmax=t->GetZ() + dz; - Double_t ymin=t->GetY() + phi*r - dy; - Double_t ymax=t->GetY() + phi*r + dy; - layer.SelectClusters(zmin,zmax,ymin,ymax); - - const AliITSclusterV2 *c=0; Int_t ci=-1; - while ((c=layer.GetNextCluster(ci))!=0) { - if (idet != c->GetDetectorIndex()) continue; - Double_t chi2=t->GetPredictedChi2(c); - if (chi2Update(cl,maxchi2,idx)) { - if (!UpdateMI(t,cl,maxchi2,idx)) { - return kFALSE; + if (!track->Propagate(det.GetPhi(),det.GetR())) return kFALSE; + + track->SetDetectorIndex(idet); + if(!LocalModuleCoord(ilayer,idet,track,xloc,zloc)) return kFALSE; // local module coords + + Double_t dz,zmin,zmax,dy,ymin,ymax; + + const AliITSRecPoint *clAcc=0; + Double_t maxchi2=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2(); + + Int_t idx=index[ilayer]; + if (idx>=0) { // cluster in this layer + modstatus = 6; // no refit + const AliITSRecPoint *cl=(AliITSRecPoint *)GetCluster(idx); + if (cl) { + if (idet != cl->GetDetectorIndex()) { + idet=cl->GetDetectorIndex(); + const AliITSdetector &detc=layer.GetDetector(idet); + if (!track->Propagate(detc.GetPhi(),detc.GetR())) return kFALSE; + track->SetDetectorIndex(idet); + if(!LocalModuleCoord(ilayer,idet,track,xloc,zloc)) return kFALSE; // local module coords + } + Int_t cllayer = (idx & 0xf0000000) >> 28;; + Double_t chi2=GetPredictedChi2MI(track,cl,cllayer); + if (chi2GetIPlanePlaneEff()) { + if (IsOKForPlaneEff(track,clusters,ilayer)) // only adequate track for plane eff. evaluation + UseTrackForPlaneEff(track,ilayer); + } + } else { + modstatus = 5; // no cls in road + // check dead + if (!ComputeRoad(track,ilayer,idet,zmin,zmax,ymin,ymax)) return kFALSE; + dz = 0.5*(zmax-zmin); + dy = 0.5*(ymax-ymin); + Int_t dead = CheckDeadZone(track,ilayer,idet,dz,dy,kTRUE); + if (dead==1) modstatus = 7; // holes in z in SPD + if (dead==2 || dead==3 || dead==4) modstatus = 2; // dead from OCDB } - t->SetSampledEdx(cl->GetQ(),t->GetNumberOfClusters()-1); } - - { - Double_t x0; - Double_t d=layer.GetThickness(t->GetY(),t->GetZ(),x0); - t->CorrectForMaterial(-step*d,x0); + + if (clAcc) { + if (!UpdateMI(track,clAcc,maxchi2,idx)) return kFALSE; + track->SetSampledEdx(clAcc->GetQ(),ilayer-2); } + track->SetModuleIndexInfo(ilayer,idet,modstatus,xloc,zloc); + + + if (extra) { // search for extra clusters in overlapped modules + AliITStrackV2 tmp(*track); + if (!ComputeRoad(track,ilayer,idet,zmin,zmax,ymin,ymax)) return kFALSE; + layer.SelectClusters(zmin,zmax,ymin,ymax); + + const AliITSRecPoint *clExtra=0; Int_t ci=-1,cci=-1; + Int_t idetExtra=-1; + maxchi2=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2(); + Double_t tolerance=0.1; + while ((clExtra=layer.GetNextCluster(ci))!=0) { + // only clusters in another module! (overlaps) + idetExtra = clExtra->GetDetectorIndex(); + if (idet == idetExtra) continue; + + const AliITSdetector &detx=layer.GetDetector(idetExtra); + + if (!tmp.Propagate(detx.GetPhi(),detx.GetR()+clExtra->GetX())) continue; + if (TMath::Abs(tmp.GetZ() - clExtra->GetZ()) > tolerance) continue; + if (TMath::Abs(tmp.GetY() - clExtra->GetY()) > tolerance) continue; + if (!tmp.Propagate(detx.GetPhi(),detx.GetR())) continue; + + Double_t chi2=tmp.GetPredictedChi2(clExtra); + if (chi2=0) { + track->SetExtraCluster(ilayer,(ilayer<<28)+cci); + track->SetExtraModule(ilayer,idetExtra); + } + } // end search for extra clusters in overlapped modules + + // Correct for material of the current layer + // cross material + // add time if going outward + if(!CorrectForLayerMaterial(track,ilayer,oldGlobXYZ,dir)) return kFALSE; - // track time update [SR, GSI 17.02.2003] - if (t->IsStartedTimeIntegral() && step==1) { - Double_t newX, newY, newZ; - t->GetGlobalXYZat(t->GetX(),newX,newY,newZ); - Double_t dL2 = (oldX-newX)*(oldX-newX) + (oldY-newY)*(oldY-newY) + - (oldZ-newZ)*(oldZ-newZ); - t->AddTimeStep(TMath::Sqrt(dL2)); - } - // + } // end loop on layers - } + if (!track->PropagateTo(xx,0.,0.)) return kFALSE; - if (!t->PropagateTo(xx,0.,0.)) return kFALSE; return kTRUE; } - - - +//------------------------------------------------------------------------ Double_t AliITStrackerMI::GetNormalizedChi2(AliITStrackMI * track, Int_t mode) { // @@ -1734,16 +2418,16 @@ Double_t AliITStrackerMI::GetNormalizedChi2(AliITStrackMI * track, Int_t mode) Float_t *ny = GetNy(fCurrentEsdTrack), *nz = GetNz(fCurrentEsdTrack); if (mode<100){ for (Int_t i = 0;i<6;i++){ - if (track->fClIndex[i]>0){ + if (track->GetClIndex(i)>=0){ Float_t cerry, cerrz; if (ny[i]>0) {cerry = erry[i]; cerrz=errz[i];} else - { cerry= track->fSigmaY[i]; cerrz = track->fSigmaZ[i];} + { cerry= track->GetSigmaY(i); cerrz = track->GetSigmaZ(i);} cerry*=cerry; cerrz*=cerrz; - Float_t cchi2 = (track->fDy[i]*track->fDy[i]/cerry)+(track->fDz[i]*track->fDz[i]/cerrz); - if (i>1){ - Float_t ratio = track->fNormQ[i]/track->fExpQ; + Float_t cchi2 = (track->GetDy(i)*track->GetDy(i)/cerry)+(track->GetDz(i)*track->GetDz(i)/cerrz); + if (i>1 && AliITSReconstructor::GetRecoParam()->GetUseAmplitudeInfo(i)) { + Float_t ratio = track->GetNormQ(i)/track->GetExpQ(); if (ratio<0.5) { cchi2+=(0.5-ratio)*10.; //track->fdEdxMismatch+=(0.5-ratio)*10.; @@ -1751,7 +2435,7 @@ Double_t AliITStrackerMI::GetNormalizedChi2(AliITStrackMI * track, Int_t mode) } } if (i<2 ||i>3){ - AliITSclusterV2 * cl = (AliITSclusterV2*)GetCluster( track->fClIndex[i]); + AliITSRecPoint * cl = (AliITSRecPoint*)GetCluster( track->GetClIndex(i)); Double_t delta = cl->GetNy()+cl->GetNz()-ny[i]-nz[i]; if (delta>1) chi2 +=0.5*TMath::Min(delta/2,2.); if (i<2) chi2+=2*cl->GetDeltaProbability(); @@ -1760,43 +2444,43 @@ Double_t AliITStrackerMI::GetNormalizedChi2(AliITStrackMI * track, Int_t mode) sum++; } } - if (TMath::Abs(track->fdEdxMismatch-dedxmismatch)>0.0001){ - track->fdEdxMismatch = dedxmismatch; + if (TMath::Abs(track->GetdEdxMismatch()-dedxmismatch)>0.0001){ + track->SetdEdxMismatch(dedxmismatch); } } else{ for (Int_t i = 0;i<4;i++){ - if (track->fClIndex[i]>0){ + if (track->GetClIndex(i)>=0){ Float_t cerry, cerrz; if (ny[i]>0) {cerry = erry[i]; cerrz=errz[i];} - else { cerry= track->fSigmaY[i]; cerrz = track->fSigmaZ[i];} + else { cerry= track->GetSigmaY(i); cerrz = track->GetSigmaZ(i);} cerry*=cerry; cerrz*=cerrz; - chi2+= (track->fDy[i]*track->fDy[i]/cerry); - chi2+= (track->fDz[i]*track->fDz[i]/cerrz); + chi2+= (track->GetDy(i)*track->GetDy(i)/cerry); + chi2+= (track->GetDz(i)*track->GetDz(i)/cerrz); sum++; } } for (Int_t i = 4;i<6;i++){ - if (track->fClIndex[i]>0){ + if (track->GetClIndex(i)>=0){ Float_t cerry, cerrz; if (ny[i]>0) {cerry = erry[i]; cerrz=errz[i];} - else { cerry= track->fSigmaY[i]; cerrz = track->fSigmaZ[i];} + else { cerry= track->GetSigmaY(i); cerrz = track->GetSigmaZ(i);} cerry*=cerry; cerrz*=cerrz; Float_t cerryb, cerrzb; if (ny[i+6]>0) {cerryb = erry[i+6]; cerrzb=errz[i+6];} - else { cerryb= track->fSigmaY[i+6]; cerrzb = track->fSigmaZ[i+6];} + else { cerryb= track->GetSigmaY(i+6); cerrzb = track->GetSigmaZ(i+6);} cerryb*=cerryb; cerrzb*=cerrzb; - chi2+= TMath::Min((track->fDy[i+6]*track->fDy[i+6]/cerryb),track->fDy[i]*track->fDy[i]/cerry); - chi2+= TMath::Min((track->fDz[i+6]*track->fDz[i+6]/cerrzb),track->fDz[i]*track->fDz[i]/cerrz); + chi2+= TMath::Min((track->GetDy(i+6)*track->GetDy(i+6)/cerryb),track->GetDy(i)*track->GetDy(i)/cerry); + chi2+= TMath::Min((track->GetDz(i+6)*track->GetDz(i+6)/cerrzb),track->GetDz(i)*track->GetDz(i)/cerrz); sum++; } } } - if (track->fESDtrack->GetTPCsignal()>85){ - Float_t ratio = track->fdEdx/track->fESDtrack->GetTPCsignal(); + if (track->GetESDtrack()->GetTPCsignal()>85){ + Float_t ratio = track->GetdEdx()/track->GetESDtrack()->GetTPCsignal(); if (ratio<0.5) { chi2+=(0.5-ratio)*5.; } @@ -1805,84 +2489,114 @@ Double_t AliITStrackerMI::GetNormalizedChi2(AliITStrackMI * track, Int_t mode) } } // - Double_t match = TMath::Sqrt(track->fChi22); - if (track->fConstrain) match/=track->GetNumberOfClusters(); - if (!track->fConstrain) match/=track->GetNumberOfClusters()-2.; + Double_t match = TMath::Sqrt(track->GetChi22()); + if (track->GetConstrain()) match/=track->GetNumberOfClusters(); + if (!track->GetConstrain()) { + if (track->GetNumberOfClusters()>2) { + match/=track->GetNumberOfClusters()-2.; + } else { + match=0; + } + } if (match<0) match=0; - Float_t deadzonefactor = (track->fNDeadZone>0) ? 3*(1.1-track->fDeadZoneProbability):0.; - Double_t normchi2 = 2*track->fNSkipped+match+deadzonefactor+(1+(2*track->fNSkipped+deadzonefactor)/track->GetNumberOfClusters())* - (chi2)/TMath::Max(double(sum-track->fNSkipped), - 1./(1.+track->fNSkipped)); + + // penalty factor for missing points (NDeadZone>0), but no penalty + // for layer with deadZoneProb close to 1 (either we wanted to skip layer + // or there is a dead from OCDB) + Float_t deadzonefactor = 0.; + if (track->GetNDeadZone()>0.) { + Float_t sumDeadZoneProbability=0; + for(Int_t ilay=0;ilay<6;ilay++) sumDeadZoneProbability+=track->GetDeadZoneProbability(ilay); + Float_t nDeadZoneWithProbNot1=(Float_t)(track->GetNDeadZone())-sumDeadZoneProbability; + if(nDeadZoneWithProbNot1>0.) { + Float_t deadZoneProbability = sumDeadZoneProbability - (Float_t)((Int_t)sumDeadZoneProbability); + deadZoneProbability /= nDeadZoneWithProbNot1; + deadzonefactor = 3.*(1.1-deadZoneProbability); + } + } + + Double_t normchi2 = 2*track->GetNSkipped()+match+deadzonefactor+(1+(2*track->GetNSkipped()+deadzonefactor)/track->GetNumberOfClusters())* + (chi2)/TMath::Max(double(sum-track->GetNSkipped()), + 1./(1.+track->GetNSkipped())); return normchi2; } - - -Double_t AliITStrackerMI::GetMatchingChi2(AliITStrackMI * track1, AliITStrackMI * track2) +//------------------------------------------------------------------------ +Double_t AliITStrackerMI::GetMatchingChi2(const AliITStrackMI * track1,const AliITStrackMI * track2) { // // return matching chi2 between two tracks + Double_t largeChi2=1000.; + AliITStrackMI track3(*track2); - track3.Propagate(track1->GetAlpha(),track1->GetX()); + if (!track3.Propagate(track1->GetAlpha(),track1->GetX())) return largeChi2; TMatrixD vec(5,1); - vec(0,0)=track1->fP0-track3.fP0; - vec(1,0)=track1->fP1-track3.fP1; - vec(2,0)=track1->fP2-track3.fP2; - vec(3,0)=track1->fP3-track3.fP3; - vec(4,0)=track1->fP4-track3.fP4; + vec(0,0)=track1->GetY() - track3.GetY(); + vec(1,0)=track1->GetZ() - track3.GetZ(); + vec(2,0)=track1->GetSnp() - track3.GetSnp(); + vec(3,0)=track1->GetTgl() - track3.GetTgl(); + vec(4,0)=track1->GetSigned1Pt() - track3.GetSigned1Pt(); // TMatrixD cov(5,5); - cov(0,0) = track1->fC00+track3.fC00; - cov(1,1) = track1->fC11+track3.fC11; - cov(2,2) = track1->fC22+track3.fC22; - cov(3,3) = track1->fC33+track3.fC33; - cov(4,4) = track1->fC44+track3.fC44; + cov(0,0) = track1->GetSigmaY2()+track3.GetSigmaY2(); + cov(1,1) = track1->GetSigmaZ2()+track3.GetSigmaZ2(); + cov(2,2) = track1->GetSigmaSnp2()+track3.GetSigmaSnp2(); + cov(3,3) = track1->GetSigmaTgl2()+track3.GetSigmaTgl2(); + cov(4,4) = track1->GetSigma1Pt2()+track3.GetSigma1Pt2(); - cov(0,1)=cov(1,0) = track1->fC10+track3.fC10; - cov(0,2)=cov(2,0) = track1->fC20+track3.fC20; - cov(0,3)=cov(3,0) = track1->fC30+track3.fC30; - cov(0,4)=cov(4,0) = track1->fC40+track3.fC40; + cov(0,1)=cov(1,0) = track1->GetSigmaZY()+track3.GetSigmaZY(); + cov(0,2)=cov(2,0) = track1->GetSigmaSnpY()+track3.GetSigmaSnpY(); + cov(0,3)=cov(3,0) = track1->GetSigmaTglY()+track3.GetSigmaTglY(); + cov(0,4)=cov(4,0) = track1->GetSigma1PtY()+track3.GetSigma1PtY(); // - cov(1,2)=cov(2,1) = track1->fC21+track3.fC21; - cov(1,3)=cov(3,1) = track1->fC31+track3.fC31; - cov(1,4)=cov(4,1) = track1->fC41+track3.fC41; + cov(1,2)=cov(2,1) = track1->GetSigmaSnpZ()+track3.GetSigmaSnpZ(); + cov(1,3)=cov(3,1) = track1->GetSigmaTglZ()+track3.GetSigmaTglZ(); + cov(1,4)=cov(4,1) = track1->GetSigma1PtZ()+track3.GetSigma1PtZ(); // - cov(2,3)=cov(3,2) = track1->fC32+track3.fC32; - cov(2,4)=cov(4,2) = track1->fC42+track3.fC42; + cov(2,3)=cov(3,2) = track1->GetSigmaTglSnp()+track3.GetSigmaTglSnp(); + cov(2,4)=cov(4,2) = track1->GetSigma1PtSnp()+track3.GetSigma1PtSnp(); // - cov(3,4)=cov(4,3) = track1->fC43+track3.fC43; + cov(3,4)=cov(4,3) = track1->GetSigma1PtTgl()+track3.GetSigma1PtTgl(); cov.Invert(); TMatrixD vec2(cov,TMatrixD::kMult,vec); TMatrixD chi2(vec2,TMatrixD::kTransposeMult,vec); return chi2(0,0); } - -Double_t AliITStrackerMI::GetDeadZoneProbability(Double_t zpos, Double_t zerr) +//------------------------------------------------------------------------ +Double_t AliITStrackerMI::GetSPDDeadZoneProbability(Double_t zpos, Double_t zerr) const { // - // return probability that given point - characterized by z position and error is in dead zone + // return probability that given point (characterized by z position and error) + // is in SPD dead zone // - Double_t probability =0; + Double_t probability = 0.; Double_t absz = TMath::Abs(zpos); - Double_t nearestz = (absz<2)? 0.:7.1; - if (TMath::Abs(absz-nearestz)>0.25+3*zerr) return 0; - Double_t zmin=0, zmax=0; - if (zpos<-6.){ - zmin = -7.25; zmax = -6.95; - } - if (zpos>6){ - zmin = 7.0; zmax =7.3; - } - if (absz<2){ - zmin = -0.75; zmax = 1.5; + Double_t nearestz = (absz<2.) ? 0.5*(fSPDdetzcentre[1]+fSPDdetzcentre[2]) : + 0.5*(fSPDdetzcentre[2]+fSPDdetzcentre[3]); + if (TMath::Abs(absz-nearestz)>0.25+3.*zerr) return probability; + Double_t zmin, zmax; + if (zpos<-6.) { // dead zone at z = -7 + zmin = fSPDdetzcentre[0] + 0.5*AliITSRecoParam::GetSPDdetzlength(); + zmax = fSPDdetzcentre[1] - 0.5*AliITSRecoParam::GetSPDdetzlength(); + } else if (zpos>6.) { // dead zone at z = +7 + zmin = fSPDdetzcentre[2] + 0.5*AliITSRecoParam::GetSPDdetzlength(); + zmax = fSPDdetzcentre[3] - 0.5*AliITSRecoParam::GetSPDdetzlength(); + } else if (absz<2.) { // dead zone at z = 0 + zmin = fSPDdetzcentre[1] + 0.5*AliITSRecoParam::GetSPDdetzlength(); + zmax = fSPDdetzcentre[2] - 0.5*AliITSRecoParam::GetSPDdetzlength(); + } else { + zmin = 0.; + zmax = 0.; } - probability = (TMath::Erf((zpos-zmin)/zerr) - TMath::Erf((zpos-zmax)/zerr))*0.5; + // probability that the true z is in the range [zmin,zmax] (i.e. inside + // dead zone) + probability = 0.5*( TMath::Erf((zpos-zmin)/zerr/TMath::Sqrt(2.)) - + TMath::Erf((zpos-zmax)/zerr/TMath::Sqrt(2.)) ); return probability; } - - -Double_t AliITStrackerMI::GetTruncatedChi2(AliITStrackMI * track, Float_t fac) +//------------------------------------------------------------------------ +Double_t AliITStrackerMI::GetTruncatedChi2(const AliITStrackMI * track, Float_t fac) { // // calculate normalized chi2 @@ -1890,9 +2604,9 @@ Double_t AliITStrackerMI::GetTruncatedChi2(AliITStrackMI * track, Float_t fac) Float_t *erry = GetErrY(fCurrentEsdTrack), *errz = GetErrZ(fCurrentEsdTrack); Float_t ncl = 0; for (Int_t i = 0;i<6;i++){ - if (TMath::Abs(track->fDy[i])>0){ - chi2[i]= (track->fDy[i]/erry[i])*(track->fDy[i]/erry[i]); - chi2[i]+= (track->fDz[i]/errz[i])*(track->fDz[i]/errz[i]); + if (TMath::Abs(track->GetDy(i))>0){ + chi2[i]= (track->GetDy(i)/erry[i])*(track->GetDy(i)/erry[i]); + chi2[i]+= (track->GetDz(i)/errz[i])*(track->GetDz(i)/errz[i]); ncl++; } else{chi2[i]=10000;} @@ -1909,9 +2623,8 @@ Double_t AliITStrackerMI::GetTruncatedChi2(AliITStrackMI * track, Float_t fac) Double_t normchi2 = sumchi/sumweight; return normchi2; } - - -Double_t AliITStrackerMI::GetInterpolatedChi2(AliITStrackMI * forwardtrack, AliITStrackMI * backtrack) +//------------------------------------------------------------------------ +Double_t AliITStrackerMI::GetInterpolatedChi2(const AliITStrackMI * forwardtrack,const AliITStrackMI * backtrack) { // // calculate normalized chi2 @@ -1919,15 +2632,15 @@ Double_t AliITStrackerMI::GetInterpolatedChi2(AliITStrackMI * forwardtrack, AliI Int_t npoints = 0; Double_t res =0; for (Int_t i=0;i<6;i++){ - if ( (backtrack->fSigmaY[i]<0.000000001) || (forwardtrack->fSigmaY[i]<0.000000001)) continue; - Double_t sy1 = forwardtrack->fSigmaY[i]; - Double_t sz1 = forwardtrack->fSigmaZ[i]; - Double_t sy2 = backtrack->fSigmaY[i]; - Double_t sz2 = backtrack->fSigmaZ[i]; + if ( (backtrack->GetSigmaY(i)<0.000000001) || (forwardtrack->GetSigmaY(i)<0.000000001)) continue; + Double_t sy1 = forwardtrack->GetSigmaY(i); + Double_t sz1 = forwardtrack->GetSigmaZ(i); + Double_t sy2 = backtrack->GetSigmaY(i); + Double_t sz2 = backtrack->GetSigmaZ(i); if (i<2){ sy2=1000.;sz2=1000;} // - Double_t dy0 = (forwardtrack->fDy[i]/(sy1*sy1) +backtrack->fDy[i]/(sy2*sy2))/(1./(sy1*sy1)+1./(sy2*sy2)); - Double_t dz0 = (forwardtrack->fDz[i]/(sz1*sz1) +backtrack->fDz[i]/(sz2*sz2))/(1./(sz1*sz1)+1./(sz2*sz2)); + Double_t dy0 = (forwardtrack->GetDy(i)/(sy1*sy1) +backtrack->GetDy(i)/(sy2*sy2))/(1./(sy1*sy1)+1./(sy2*sy2)); + Double_t dz0 = (forwardtrack->GetDz(i)/(sz1*sz1) +backtrack->GetDz(i)/(sz2*sz2))/(1./(sz1*sz1)+1./(sz2*sz2)); // Double_t nz0 = dz0*TMath::Sqrt((1./(sz1*sz1)+1./(sz2*sz2))); Double_t ny0 = dy0*TMath::Sqrt((1./(sy1*sy1)+1./(sy2*sy2))); @@ -1936,17 +2649,13 @@ Double_t AliITStrackerMI::GetInterpolatedChi2(AliITStrackMI * forwardtrack, AliI npoints++; } if (npoints>1) return - TMath::Max(TMath::Abs(0.3*forwardtrack->Get1Pt())-0.5,0.)+ + TMath::Max(0.3*forwardtrack->OneOverPt()-0.5,0.)+ //2*forwardtrack->fNUsed+ - res/TMath::Max(double(npoints-forwardtrack->fNSkipped), - 1./(1.+forwardtrack->fNSkipped)); + res/TMath::Max(double(npoints-forwardtrack->GetNSkipped()), + 1./(1.+forwardtrack->GetNSkipped())); return 1000; } - - - - - +//------------------------------------------------------------------------ Float_t *AliITStrackerMI::GetWeight(Int_t index) { //-------------------------------------------------------------------- // Return pointer to a given cluster @@ -1955,29 +2664,30 @@ Float_t *AliITStrackerMI::GetWeight(Int_t index) { Int_t c=(index & 0x0fffffff) >> 00; return fgLayers[l].GetWeight(c); } - -void AliITStrackerMI::RegisterClusterTracks(AliITStrackMI* track,Int_t id) +//------------------------------------------------------------------------ +void AliITStrackerMI::RegisterClusterTracks(const AliITStrackMI* track,Int_t id) { //--------------------------------------------- // register track to the list // - if (track->fESDtrack->GetKinkIndex(0)!=0) return; //don't register kink tracks + if (track->GetESDtrack()->GetKinkIndex(0)!=0) return; //don't register kink tracks // // for (Int_t icluster=0;iclusterGetNumberOfClusters();icluster++){ Int_t index = track->GetClusterIndex(icluster); Int_t l=(index & 0xf0000000) >> 28; Int_t c=(index & 0x0fffffff) >> 00; - if (c>fgLayers[l].fN) continue; + if (c>fgLayers[l].GetNumberOfClusters()) continue; for (Int_t itrack=0;itrack<4;itrack++){ - if (fgLayers[l].fClusterTracks[itrack][c]<0){ - fgLayers[l].fClusterTracks[itrack][c]=id; + if (fgLayers[l].GetClusterTracks(itrack,c)<0){ + fgLayers[l].SetClusterTracks(itrack,c,id); break; } } } } -void AliITStrackerMI::UnRegisterClusterTracks(AliITStrackMI* track, Int_t id) +//------------------------------------------------------------------------ +void AliITStrackerMI::UnRegisterClusterTracks(const AliITStrackMI* track, Int_t id) { //--------------------------------------------- // unregister track from the list @@ -1985,15 +2695,16 @@ void AliITStrackerMI::UnRegisterClusterTracks(AliITStrackMI* track, Int_t id) Int_t index = track->GetClusterIndex(icluster); Int_t l=(index & 0xf0000000) >> 28; Int_t c=(index & 0x0fffffff) >> 00; - if (c>fgLayers[l].fN) continue; + if (c>fgLayers[l].GetNumberOfClusters()) continue; for (Int_t itrack=0;itrack<4;itrack++){ - if (fgLayers[l].fClusterTracks[itrack][c]==id){ - fgLayers[l].fClusterTracks[itrack][c]=-1; + if (fgLayers[l].GetClusterTracks(itrack,c)==id){ + fgLayers[l].SetClusterTracks(itrack,c,-1); } } } } -Float_t AliITStrackerMI::GetNumberOfSharedClusters(AliITStrackMI* track,Int_t id, Int_t list[6], AliITSclusterV2 *clist[6]) +//------------------------------------------------------------------------ +Float_t AliITStrackerMI::GetNumberOfSharedClusters(AliITStrackMI* track,Int_t id, Int_t list[6], AliITSRecPoint *clist[6]) { //------------------------------------------------------------- //get number of shared clusters @@ -2008,16 +2719,17 @@ Float_t AliITStrackerMI::GetNumberOfSharedClusters(AliITStrackMI* track,Int_t id Int_t index = track->GetClusterIndex(icluster); Int_t l=(index & 0xf0000000) >> 28; Int_t c=(index & 0x0fffffff) >> 00; - if (c>fgLayers[l].fN) continue; + if (c>fgLayers[l].GetNumberOfClusters()) continue; if (ny[l]==0){ printf("problem\n"); } - AliITSclusterV2 *cl = (AliITSclusterV2*)GetCluster(index); + AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(index); Float_t weight=1; // Float_t deltan = 0; if (l>3&&cl->GetNy()+cl->GetNz()>6) continue; - if (l>2&&track->fNormQ[l]/track->fExpQ>3.5) continue; + if (l>2&&AliITSReconstructor::GetRecoParam()->GetUseAmplitudeInfo(l)) + if (track->GetNormQ(l)/track->GetExpQ()>3.5) continue; if (l<2 || l>3){ deltan = (cl->GetNy()+cl->GetNz()-ny[l]-nz[l]); } @@ -2028,19 +2740,19 @@ Float_t AliITStrackerMI::GetNumberOfSharedClusters(AliITStrackMI* track,Int_t id weight = 2./TMath::Max(3.+deltan,2.); // for (Int_t itrack=0;itrack<4;itrack++){ - if (fgLayers[l].fClusterTracks[itrack][c]>=0 && fgLayers[l].fClusterTracks[itrack][c]!=id){ + if (fgLayers[l].GetClusterTracks(itrack,c)>=0 && fgLayers[l].GetClusterTracks(itrack,c)!=id){ list[l]=index; - clist[l] = (AliITSclusterV2*)GetCluster(index); + clist[l] = (AliITSRecPoint*)GetCluster(index); shared+=weight; break; } } } - track->fNUsed=shared; + track->SetNUsed(shared); return shared; } - -Int_t AliITStrackerMI::GetOverlapTrack(AliITStrackMI *track, Int_t trackID, Int_t &shared, Int_t clusterlist[6],Int_t overlist[6]) +//------------------------------------------------------------------------ +Int_t AliITStrackerMI::GetOverlapTrack(const AliITStrackMI *track, Int_t trackID, Int_t &shared, Int_t clusterlist[6],Int_t overlist[6]) { // // find first shared track @@ -2061,13 +2773,14 @@ Int_t AliITStrackerMI::GetOverlapTrack(AliITStrackMI *track, Int_t trackID, Int_ if (ny[l]==0){ printf("problem\n"); } - if (c>fgLayers[l].fN) continue; + if (c>fgLayers[l].GetNumberOfClusters()) continue; //if (l>3) continue; - AliITSclusterV2 *cl = (AliITSclusterV2*)GetCluster(index); + AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(index); // Float_t deltan = 0; if (l>3&&cl->GetNy()+cl->GetNz()>6) continue; - if (l>2&&track->fNormQ[l]/track->fExpQ>3.5) continue; + if (l>2&&AliITSReconstructor::GetRecoParam()->GetUseAmplitudeInfo(l)) + if (track->GetNormQ(l)/track->GetExpQ()>3.5) continue; if (l<2 || l>3){ deltan = (cl->GetNy()+cl->GetNz()-ny[l]-nz[l]); } @@ -2077,9 +2790,9 @@ Int_t AliITStrackerMI::GetOverlapTrack(AliITStrackMI *track, Int_t trackID, Int_ if (deltan>2.0) continue; // extended - highly probable shared cluster // for (Int_t itrack=3;itrack>=0;itrack--){ - if (fgLayers[l].fClusterTracks[itrack][c]<0) continue; - if (fgLayers[l].fClusterTracks[itrack][c]!=trackID){ - tracks[trackindex] = fgLayers[l].fClusterTracks[itrack][c]; + if (fgLayers[l].GetClusterTracks(itrack,c)<0) continue; + if (fgLayers[l].GetClusterTracks(itrack,c)!=trackID){ + tracks[trackindex] = fgLayers[l].GetClusterTracks(itrack,c); trackindex++; } } @@ -2091,13 +2804,13 @@ Int_t AliITStrackerMI::GetOverlapTrack(AliITStrackMI *track, Int_t trackID, Int_ if (trackindex==2) sharedtrack =TMath::Min(tracks[0],tracks[1]); else{ // - Int_t track[24], cluster[24]; - for (Int_t i=0;imax) { - sharedtrack=track[index]; + sharedtrack=tracks2[index]; max=cluster[index]; } } @@ -2127,8 +2840,8 @@ Int_t AliITStrackerMI::GetOverlapTrack(AliITStrackMI *track, Int_t trackID, Int_ Int_t index = clusterlist[icluster]; Int_t l=(index & 0xf0000000) >> 28; Int_t c=(index & 0x0fffffff) >> 00; - if (c>fgLayers[l].fN) continue; - AliITSclusterV2 *cl = (AliITSclusterV2*)GetCluster(index); + if (c>fgLayers[l].GetNumberOfClusters()) continue; + AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(index); if (l==0 || l==1){ if (cl->GetNy()>2) continue; if (cl->GetNz()>2) continue; @@ -2139,8 +2852,8 @@ Int_t AliITStrackerMI::GetOverlapTrack(AliITStrackMI *track, Int_t trackID, Int_ } // for (Int_t itrack=3;itrack>=0;itrack--){ - if (fgLayers[l].fClusterTracks[itrack][c]<0) continue; - if (fgLayers[l].fClusterTracks[itrack][c]==sharedtrack){ + if (fgLayers[l].GetClusterTracks(itrack,c)<0) continue; + if (fgLayers[l].GetClusterTracks(itrack,c)==sharedtrack){ overlist[l]=index; shared++; } @@ -2148,8 +2861,7 @@ Int_t AliITStrackerMI::GetOverlapTrack(AliITStrackMI *track, Int_t trackID, Int_ } return sharedtrack; } - - +//------------------------------------------------------------------------ AliITStrackMI * AliITStrackerMI::GetBest2Tracks(Int_t trackID1, Int_t trackID2, Float_t th0, Float_t th1){ // // try to find track hypothesys without conflicts @@ -2163,7 +2875,7 @@ AliITStrackMI * AliITStrackerMI::GetBest2Tracks(Int_t trackID1, Int_t trackID2, // AliITStrackMI * track10=(AliITStrackMI*) arr1->UncheckedAt(0); AliITStrackMI * track20=(AliITStrackMI*) arr2->UncheckedAt(0); - if (TMath::Abs(1./track10->Get1Pt())>0.5+TMath::Abs(1/track20->Get1Pt())) return track10; + if (track10->Pt()>0.5+track20->Pt()) return track10; for (Int_t itrack=0;itrackUncheckedAt(itrack); @@ -2183,7 +2895,7 @@ AliITStrackMI * AliITStrackerMI::GetBest2Tracks(Int_t trackID1, Int_t trackID2, Double_t w1,w2; Int_t list1[6],list2[6]; - AliITSclusterV2 *clist1[6], *clist2[6] ; + AliITSRecPoint *clist1[6], *clist2[6] ; RegisterClusterTracks(track10,trackID1); RegisterClusterTracks(track20,trackID2); Float_t conflict1 = GetNumberOfSharedClusters(track10,trackID1,list1,clist1); @@ -2204,14 +2916,14 @@ AliITStrackMI * AliITStrackerMI::GetBest2Tracks(Int_t trackID1, Int_t trackID2, nerry[i] = TMath::Max(erry1[i],erry2[i]); nerrz[i] = TMath::Max(errz1[i],errz2[i]); } - if (TMath::Abs(track10->fDy[i])>0.000000000000001){ - chi21 += track10->fDy[i]*track10->fDy[i]/(nerry[i]*nerry[i]); - chi21 += track10->fDz[i]*track10->fDz[i]/(nerrz[i]*nerrz[i]); + if (TMath::Abs(track10->GetDy(i))>0.000000000000001){ + chi21 += track10->GetDy(i)*track10->GetDy(i)/(nerry[i]*nerry[i]); + chi21 += track10->GetDz(i)*track10->GetDz(i)/(nerrz[i]*nerrz[i]); ncl1++; } - if (TMath::Abs(track20->fDy[i])>0.000000000000001){ - chi22 += track20->fDy[i]*track20->fDy[i]/(nerry[i]*nerry[i]); - chi22 += track20->fDz[i]*track20->fDz[i]/(nerrz[i]*nerrz[i]); + if (TMath::Abs(track20->GetDy(i))>0.000000000000001){ + chi22 += track20->GetDy(i)*track20->GetDy(i)/(nerry[i]*nerry[i]); + chi22 += track20->GetDz(i)*track20->GetDz(i)/(nerrz[i]*nerrz[i]); ncl2++; } } @@ -2219,18 +2931,18 @@ AliITStrackMI * AliITStrackerMI::GetBest2Tracks(Int_t trackID1, Int_t trackID2, chi22/=ncl2; // // - Float_t d1 = TMath::Sqrt(track10->fD[0]*track10->fD[0]+track10->fD[1]*track10->fD[1])+0.1; - Float_t d2 = TMath::Sqrt(track20->fD[0]*track20->fD[0]+track20->fD[1]*track20->fD[1])+0.1; + Float_t d1 = TMath::Sqrt(track10->GetD(0)*track10->GetD(0)+track10->GetD(1)*track10->GetD(1))+0.1; + Float_t d2 = TMath::Sqrt(track20->GetD(0)*track20->GetD(0)+track20->GetD(1)*track20->GetD(1))+0.1; Float_t s1 = TMath::Sqrt(track10->GetSigmaY2()*track10->GetSigmaZ2()); Float_t s2 = TMath::Sqrt(track20->GetSigmaY2()*track20->GetSigmaZ2()); // w1 = (d2/(d1+d2)+ 2*s2/(s1+s2)+ +s2/(s1+s2)*0.5*(chi22+2.)/(chi21+chi22+4.) - +1.*TMath::Abs(1./track10->Get1Pt())/(TMath::Abs(1./track10->Get1Pt())+TMath::Abs(1./track20->Get1Pt())) + +1.*track10->Pt()/(track10->Pt()+track20->Pt()) ); w2 = (d1/(d1+d2)+ 2*s1/(s1+s2)+ s1/(s1+s2)*0.5*(chi21+2.)/(chi21+chi22+4.) - +1.*TMath::Abs(1./track20->Get1Pt())/(TMath::Abs(1./track10->Get1Pt())+TMath::Abs(1./track20->Get1Pt())) + +1.*track20->Pt()/(track10->Pt()+track20->Pt()) ); Double_t sumw = w1+w2; @@ -2259,14 +2971,12 @@ AliITStrackMI * AliITStrackerMI::GetBest2Tracks(Int_t trackID1, Int_t trackID2, //if (track2->fFakeRatio>0) continue; Float_t nskipped=0; RegisterClusterTracks(track2,trackID2); - Int_t list1[6],list2[6]; - AliITSclusterV2 *clist1[6], *clist2[6] ; Float_t cconflict1 = GetNumberOfSharedClusters(track1,trackID1,list1,clist1); Float_t cconflict2 = GetNumberOfSharedClusters(track2,trackID2,list2,clist2); UnRegisterClusterTracks(track2,trackID2); // - if (track1->fConstrain) nskipped+=w1*track1->fNSkipped; - if (track2->fConstrain) nskipped+=w2*track2->fNSkipped; + if (track1->GetConstrain()) nskipped+=w1*track1->GetNSkipped(); + if (track2->GetConstrain()) nskipped+=w2*track2->GetNSkipped(); if (nskipped>0.5) continue; // //if ( w1*conflict1+w2*conflict2>maxconflicts0) continue; @@ -2316,32 +3026,32 @@ AliITStrackMI * AliITStrackerMI::GetBest2Tracks(Int_t trackID1, Int_t trackID2, } } // - Double_t chi21=0,chi22=0; - if (TMath::Abs(track1->fDy[i])>0.) { - chi21 = (track1->fDy[i]/track1->fSigmaY[i])*(track1->fDy[i]/track1->fSigmaY[i])+ - (track1->fDz[i]/track1->fSigmaZ[i])*(track1->fDz[i]/track1->fSigmaZ[i]); + chi21=0;chi22=0; + if (TMath::Abs(track1->GetDy(i))>0.) { + chi21 = (track1->GetDy(i)/track1->GetSigmaY(i))*(track1->GetDy(i)/track1->GetSigmaY(i))+ + (track1->GetDz(i)/track1->GetSigmaZ(i))*(track1->GetDz(i)/track1->GetSigmaZ(i)); //chi21 = (track1->fDy[i]*track1->fDy[i])/(nerry[i]*nerry[i])+ - // (track1->fDz[i]*track1->fDz[i])/(nerrz[i]*nerrz[i]); + // (track1->GetDz(i)*track1->GetDz(i))/(nerrz[i]*nerrz[i]); }else{ - if (TMath::Abs(track1->fSigmaY[i]>0.)) c1=1; + if (TMath::Abs(track1->GetSigmaY(i)>0.)) c1=1; } // - if (TMath::Abs(track2->fDy[i])>0.) { - chi22 = (track2->fDy[i]/track2->fSigmaY[i])*(track2->fDy[i]/track2->fSigmaY[i])+ - (track2->fDz[i]/track2->fSigmaZ[i])*(track2->fDz[i]/track2->fSigmaZ[i]); + if (TMath::Abs(track2->GetDy(i))>0.) { + chi22 = (track2->GetDy(i)/track2->GetSigmaY(i))*(track2->GetDy(i)/track2->GetSigmaY(i))+ + (track2->GetDz(i)/track2->GetSigmaZ(i))*(track2->GetDz(i)/track2->GetSigmaZ(i)); //chi22 = (track2->fDy[i]*track2->fDy[i])/(nerry[i]*nerry[i])+ // (track2->fDz[i]*track2->fDz[i])/(nerrz[i]*nerrz[i]); } else{ - if (TMath::Abs(track2->fSigmaY[i]>0.)) c2=1; + if (TMath::Abs(track2->GetSigmaY(i)>0.)) c2=1; } sumchi2+=w1*(1.+c1)*(1+c1)*(chi21+c1)+w2*(1.+c2)*(1+c2)*(chi22+c2); if (chi21>0) sum+=w1; if (chi22>0) sum+=w2; conflict+=(c1+c2); } - Double_t norm = sum-w1*track1->fNSkipped-w2*track2->fNSkipped; - if (norm<0) norm =1/(w1*track1->fNSkipped+w2*track2->fNSkipped); + Double_t norm = sum-w1*track1->GetNSkipped()-w2*track2->GetNSkipped(); + if (norm<0) norm =1/(w1*track1->GetNSkipped()+w2*track2->GetNSkipped()); Double_t normchi2 = 2*conflict+sumchi2/sum; if ( normchi2 fFakeRatio*track10->GetNumberOfClusters(); + Float_t orig = track10->GetFakeRatio()*track10->GetNumberOfClusters(); AliITStrackMI* track1=(AliITStrackMI*) arr1->UncheckedAt(index1); - track1->fChi2MIP[5] = maxconflicts; - track1->fChi2MIP[6] = maxchi2; - track1->fChi2MIP[7] = 0.01+orig-(track1->fFakeRatio*track1->GetNumberOfClusters()); + track1->SetChi2MIP(5,maxconflicts); + track1->SetChi2MIP(6,maxchi2); + track1->SetChi2MIP(7,0.01+orig-(track1->GetFakeRatio()*track1->GetNumberOfClusters())); // track1->UpdateESDtrack(AliESDtrack::kITSin); - track1->fChi2MIP[8] = index1; + track1->SetChi2MIP(8,index1); fBestTrackIndex[trackID1] =index1; UpdateESDtrack(track1, AliESDtrack::kITSin); } - else if (track10->fChi2MIP[0]fChi2MIP[5] = maxconflicts; - track10->fChi2MIP[6] = maxchi2; + else if (track10->GetChi2MIP(0)SetChi2MIP(5,maxconflicts); + track10->SetChi2MIP(6,maxchi2); // track10->UpdateESDtrack(AliESDtrack::kITSin); UpdateESDtrack(track10,AliESDtrack::kITSin); } @@ -2382,45 +3092,45 @@ AliITStrackMI * AliITStrackerMI::GetBest2Tracks(Int_t trackID1, Int_t trackID2, UnRegisterClusterTracks(track,trackID2); } - if (track10->fConstrain&&track10->fChi2MIP[0]fChi2MIP[1]fChi2MIP[2]fChi2MIP[3]fChi2MIP[0]fChi2MIP[1]fChi2MIP[2]fChi2MIP[3]GetConstrain()&&track10->GetChi2MIP(0)GetMaxChi2PerCluster(0)&&track10->GetChi2MIP(1)GetMaxChi2PerCluster(1) + &&track10->GetChi2MIP(2)GetMaxChi2PerCluster(2)&&track10->GetChi2MIP(3)GetMaxChi2PerCluster(3)){ + // if (track10->fChi2MIP[0]GetMaxChi2PerCluster(0)&&track10->fChi2MIP[1]GetMaxChi2PerCluster(1) + // &&track10->fChi2MIP[2]GetMaxChi2PerCluster(2)&&track10->fChi2MIP[3]GetMaxChi2PerCluster(3)){ RegisterClusterTracks(track10,trackID1); } - if (track20->fConstrain&&track20->fChi2MIP[0]fChi2MIP[1]fChi2MIP[2]fChi2MIP[3]fChi2MIP[0]fChi2MIP[1]fChi2MIP[2]fChi2MIP[3]GetConstrain()&&track20->GetChi2MIP(0)GetMaxChi2PerCluster(0)&&track20->GetChi2MIP(1)GetMaxChi2PerCluster(1) + &&track20->GetChi2MIP(2)GetMaxChi2PerCluster(2)&&track20->GetChi2MIP(3)GetMaxChi2PerCluster(3)){ + //if (track20->fChi2MIP[0]GetMaxChi2PerCluster(0)&&track20->fChi2MIP[1]GetMaxChi2PerCluster(1) + // &&track20->fChi2MIP[2]GetMaxChi2PerCluster(2)&&track20->fChi2MIP[3]GetMaxChi2PerCluster(3)){ RegisterClusterTracks(track20,trackID2); } return track10; } - +//------------------------------------------------------------------------ void AliITStrackerMI::UseClusters(const AliKalmanTrack *t, Int_t from) const { //-------------------------------------------------------------------- // This function marks clusters assigned to the track //-------------------------------------------------------------------- AliTracker::UseClusters(t,from); - AliITSclusterV2 *c=(AliITSclusterV2 *)GetCluster(t->GetClusterIndex(0)); + AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(t->GetClusterIndex(0)); //if (c->GetQ()>2) c->Use(); if (c->GetSigmaZ2()>0.1) c->Use(); - c=(AliITSclusterV2 *)GetCluster(t->GetClusterIndex(1)); + c=(AliITSRecPoint *)GetCluster(t->GetClusterIndex(1)); //if (c->GetQ()>2) c->Use(); if (c->GetSigmaZ2()>0.1) c->Use(); } - - +//------------------------------------------------------------------------ void AliITStrackerMI::AddTrackHypothesys(AliITStrackMI * track, Int_t esdindex) { //------------------------------------------------------------------ // add track to the list of hypothesys //------------------------------------------------------------------ - if (esdindex>=fTrackHypothesys.GetEntriesFast()) fTrackHypothesys.Expand(esdindex*2+10); + if (esdindex>=fTrackHypothesys.GetEntriesFast()) + fTrackHypothesys.Expand(TMath::Max(fTrackHypothesys.GetSize(),esdindex*2+10)); // TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex); if (!array) { @@ -2429,7 +3139,7 @@ void AliITStrackerMI::AddTrackHypothesys(AliITStrackMI * track, Int_t esdindex) } array->AddLast(track); } - +//------------------------------------------------------------------------ void AliITStrackerMI::SortTrackHypothesys(Int_t esdindex, Int_t maxcut, Int_t mode) { //------------------------------------------------------------------- @@ -2450,14 +3160,14 @@ void AliITStrackerMI::SortTrackHypothesys(Int_t esdindex, Int_t maxcut, Int_t mo if (!track) continue; Float_t chi2 = NormalizedChi2(track,0); // - Int_t tpcLabel=track->fESDtrack->GetTPCLabel(); + Int_t tpcLabel=track->GetESDtrack()->GetTPCLabel(); track->SetLabel(tpcLabel); CookdEdx(track); - track->fFakeRatio=1.; + track->SetFakeRatio(1.); CookLabel(track,0.); //For comparison only // - //if (chi2fFakeRatio==0){ - if (chi2GetMaxChi2PerCluster(0)&&track->fFakeRatio==0){ + if (chi2GetMaxChi2PerCluster(0)){ if (track->GetNumberOfClusters()GetNumberOfClusters(); if (chi2fConstrain || track->fN>5){ //keep best short tracks - without vertex constrain + if (track->GetConstrain() || track->GetNumberOfClusters()>5){ //keep best short tracks - without vertex constrain delete array->RemoveAt(itrack); } } @@ -2477,12 +3187,12 @@ void AliITStrackerMI::SortTrackHypothesys(Int_t esdindex, Int_t maxcut, Int_t mo //take errors of best track as a reference Float_t *erry = GetErrY(esdindex), *errz = GetErrZ(esdindex); Float_t *ny = GetNy(esdindex), *nz = GetNz(esdindex); - for (Int_t i=0;i<6;i++) { - if (besttrack->fClIndex[i]>0){ - erry[i] = besttrack->fSigmaY[i]; erry[i+6] = besttrack->fSigmaY[i+6]; - errz[i] = besttrack->fSigmaZ[i]; errz[i+6] = besttrack->fSigmaZ[i+6]; - ny[i] = besttrack->fNy[i]; - nz[i] = besttrack->fNz[i]; + for (Int_t j=0;j<6;j++) { + if (besttrack->GetClIndex(j)>=0){ + erry[j] = besttrack->GetSigmaY(j); erry[j+6] = besttrack->GetSigmaY(j+6); + errz[j] = besttrack->GetSigmaZ(j); errz[j+6] = besttrack->GetSigmaZ(j+6); + ny[j] = besttrack->GetNy(j); + nz[j] = besttrack->GetNz(j); } } // @@ -2494,11 +3204,11 @@ void AliITStrackerMI::SortTrackHypothesys(Int_t esdindex, Int_t maxcut, Int_t mo for (Int_t itrack=0;itrackAt(itrack); if (track){ - track->fChi2MIP[0] = GetNormalizedChi2(track, mode); - if (track->fChi2MIP[0]fChi2MIP[0]; + track->SetChi2MIP(0,GetNormalizedChi2(track, mode)); + if (track->GetChi2MIP(0)GetMaxChi2PerCluster(0)) + chi2[itrack] = track->GetChi2MIP(0); else{ - if (track->fConstrain || track->fN>5){ //keep best short tracks - without vertex constrain + if (track->GetConstrain() || track->GetNumberOfClusters()>5){ //keep best short tracks - without vertex constrain delete array->RemoveAt(itrack); } } @@ -2507,13 +3217,13 @@ void AliITStrackerMI::SortTrackHypothesys(Int_t esdindex, Int_t maxcut, Int_t mo // TMath::Sort(entries,chi2,index,kFALSE); besttrack = (AliITStrackMI*)array->At(index[0]); - if (besttrack&&besttrack->fChi2MIP[0]fClIndex[i]>0){ - erry[i] = besttrack->fSigmaY[i]; erry[i+6] = besttrack->fSigmaY[i+6]; - errz[i] = besttrack->fSigmaZ[i]; erry[i+6] = besttrack->fSigmaY[i+6]; - ny[i] = besttrack->fNy[i]; - nz[i] = besttrack->fNz[i]; + if (besttrack&&besttrack->GetChi2MIP(0)GetMaxChi2PerCluster(0)){ + for (Int_t j=0;j<6;j++){ + if (besttrack->GetClIndex(j)>=0){ + erry[j] = besttrack->GetSigmaY(j); erry[j+6] = besttrack->GetSigmaY(j+6); + errz[j] = besttrack->GetSigmaZ(j); erry[j+6] = besttrack->GetSigmaY(j+6); + ny[j] = besttrack->GetNy(j); + nz[j] = besttrack->GetNz(j); } } } @@ -2523,12 +3233,12 @@ void AliITStrackerMI::SortTrackHypothesys(Int_t esdindex, Int_t maxcut, Int_t mo for (Int_t itrack=0;itrackAt(itrack); if (track){ - track->fChi2MIP[0] = GetNormalizedChi2(track,mode); - if (track->fChi2MIP[0]fChi2MIP[0]-0*(track->GetNumberOfClusters()+track->fNDeadZone); + track->SetChi2MIP(0,GetNormalizedChi2(track,mode)); + if (track->GetChi2MIP(0)GetMaxChi2PerCluster(0)) + chi2[itrack] = track->GetChi2MIP(0)-0*(track->GetNumberOfClusters()+track->GetNDeadZone()); else { - if (track->fConstrain || track->fN>5){ //keep best short tracks - without vertex constrain + if (track->GetConstrain() || track->GetNumberOfClusters()>5){ //keep best short tracks - without vertex constrain delete array->RemoveAt(itrack); } } @@ -2543,40 +3253,40 @@ void AliITStrackerMI::SortTrackHypothesys(Int_t esdindex, Int_t maxcut, Int_t mo besttrack = (AliITStrackMI*)array->At(index[0]); if (besttrack){ // - for (Int_t i=0;i<6;i++){ - if (besttrack->fNz[i]>0&&besttrack->fNy[i]>0){ - erry[i] = besttrack->fSigmaY[i]; erry[i+6] = besttrack->fSigmaY[i+6]; - errz[i] = besttrack->fSigmaZ[i]; errz[i+6] = besttrack->fSigmaZ[i+6]; - ny[i] = besttrack->fNy[i]; - nz[i] = besttrack->fNz[i]; + for (Int_t j=0;j<6;j++){ + if (besttrack->GetNz(j)>0&&besttrack->GetNy(j)>0){ + erry[j] = besttrack->GetSigmaY(j); erry[j+6] = besttrack->GetSigmaY(j+6); + errz[j] = besttrack->GetSigmaZ(j); errz[j+6] = besttrack->GetSigmaZ(j+6); + ny[j] = besttrack->GetNy(j); + nz[j] = besttrack->GetNz(j); } } - besttrack->fChi2MIP[0] = GetNormalizedChi2(besttrack,mode); - Float_t minchi2 = TMath::Min(besttrack->fChi2MIP[0]+5.+besttrack->fNUsed, double(kMaxChi2PerCluster[0])); + besttrack->SetChi2MIP(0,GetNormalizedChi2(besttrack,mode)); + minchi2 = TMath::Min(besttrack->GetChi2MIP(0)+5.+besttrack->GetNUsed(), double(AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(0))); Float_t minn = besttrack->GetNumberOfClusters()-3; Int_t accepted=0; for (Int_t i=0;iAt(index[i]); if (!track) continue; if (accepted>maxcut) break; - track->fChi2MIP[0] = GetNormalizedChi2(track,mode); - if (track->fConstrain || track->fN>5){ //keep best short tracks - without vertex constrain - if (track->GetNumberOfClusters()<6 && (track->fChi2MIP[0]+track->fNUsed>minchi2)){ + track->SetChi2MIP(0,GetNormalizedChi2(track,mode)); + if (track->GetConstrain() || track->GetNumberOfClusters()>5){ //keep best short tracks - without vertex constrain + if (track->GetNumberOfClusters()<6 && (track->GetChi2MIP(0)+track->GetNUsed()>minchi2)){ delete array->RemoveAt(index[i]); continue; } } - Bool_t shortbest = !track->fConstrain && track->fN<6; - if ((track->fChi2MIP[0]+track->fNUsedGetNumberOfClusters()>=minn) ||shortbest){ + Bool_t shortbest = !track->GetConstrain() && track->GetNumberOfClusters()<6; + if ((track->GetChi2MIP(0)+track->GetNUsed()GetNumberOfClusters()>=minn) ||shortbest){ if (!shortbest) accepted++; // newarray->AddLast(array->RemoveAt(index[i])); - for (Int_t i=0;i<6;i++){ - if (nz[i]==0){ - erry[i] = track->fSigmaY[i]; erry[i+6] = track->fSigmaY[i+6]; - errz[i] = track->fSigmaZ[i]; errz[i] = track->fSigmaZ[i+6]; - ny[i] = track->fNy[i]; - nz[i] = track->fNz[i]; + for (Int_t j=0;j<6;j++){ + if (nz[j]==0){ + erry[j] = track->GetSigmaY(j); erry[j+6] = track->GetSigmaY(j+6); + errz[j] = track->GetSigmaZ(j); errz[j] = track->GetSigmaZ(j+6); + ny[j] = track->GetNy(j); + nz[j] = track->GetNz(j); } } } @@ -2596,9 +3306,7 @@ void AliITStrackerMI::SortTrackHypothesys(Int_t esdindex, Int_t maxcut, Int_t mo delete [] chi2; delete [] index; } - - - +//------------------------------------------------------------------------ AliITStrackMI * AliITStrackerMI::GetBestHypothesys(Int_t esdindex, AliITStrackMI * original, Int_t checkmax) { //------------------------------------------------------------- @@ -2615,107 +3323,102 @@ AliITStrackMI * AliITStrackerMI::GetBestHypothesys(Int_t esdindex, AliITStrackMI // AliITStrackMI * backtrack = new AliITStrackMI(*original); AliITStrackMI * forwardtrack = new AliITStrackMI(*original); - Double_t xyzv[]={GetX(),GetY(),GetZ()}; - Double_t ersv[]={GetSigmaX()/3.,GetSigmaY()/3.,GetSigmaZ()/3.}; + Double_t xyzVtx[]={GetX(),GetY(),GetZ()}; + Double_t ersVtx[]={GetSigmaX()/3.,GetSigmaY()/3.,GetSigmaZ()/3.}; // for (Int_t i=0;iAt(i); if (!track) continue; Float_t sigmarfi,sigmaz; GetDCASigma(track,sigmarfi,sigmaz); - track->fDnorm[0] = sigmarfi; - track->fDnorm[1] = sigmaz; + track->SetDnorm(0,sigmarfi); + track->SetDnorm(1,sigmaz); // - track->fChi2MIP[1] = 1000000; - track->fChi2MIP[2] = 1000000; - track->fChi2MIP[3] = 1000000; + track->SetChi2MIP(1,1000000); + track->SetChi2MIP(2,1000000); + track->SetChi2MIP(3,1000000); // // backtrack backtrack = new(backtrack) AliITStrackMI(*track); - if (track->fConstrain){ - if (!backtrack->PropagateTo(3.,0.0028,65.19)) continue; - if (!backtrack->Improve(0,xyzv,ersv)) continue; - if (!backtrack->PropagateTo(2.,0.0028,0)) continue; - if (!backtrack->Improve(0,xyzv,ersv)) continue; - if (!backtrack->PropagateTo(1.,0.0028,0)) continue; - if (!backtrack->Improve(0,xyzv,ersv)) continue; - if (!backtrack->PropagateToVertex()) continue; - backtrack->ResetCovariance(); - if (!backtrack->Improve(0,xyzv,ersv)) continue; + if (track->GetConstrain()) { + if (!CorrectForPipeMaterial(backtrack,"inward")) continue; + if (!backtrack->Improve(0,xyzVtx,ersVtx)) continue; + backtrack->ResetCovariance(10.); }else{ - backtrack->ResetCovariance(); + backtrack->ResetCovariance(10.); } backtrack->ResetClusters(); Double_t x = original->GetX(); if (!RefitAt(x,backtrack,track)) continue; // - track->fChi2MIP[1] = NormalizedChi2(backtrack,0); + track->SetChi2MIP(1,NormalizedChi2(backtrack,0)); //for (Int_t i=2;i<6;i++){track->fDy[i]+=backtrack->fDy[i]; track->fDz[i]+=backtrack->fDz[i];} - if (track->fChi2MIP[1]>kMaxChi2PerCluster[1]*6.) continue; - track->fChi22 = GetMatchingChi2(backtrack,original); + if (track->GetChi2MIP(1)>AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(1)*6.) continue; + track->SetChi22(GetMatchingChi2(backtrack,original)); - if ((track->fConstrain) && track->fChi22>90.) continue; - if ((!track->fConstrain) && track->fChi22>30.) continue; - if ( track->fChi22/track->GetNumberOfClusters()>11.) continue; + if ((track->GetConstrain()) && track->GetChi22()>90.) continue; + if ((!track->GetConstrain()) && track->GetChi22()>30.) continue; + if ( track->GetChi22()/track->GetNumberOfClusters()>11.) continue; - if (!(track->fConstrain)&&track->fChi2MIP[1]>kMaxChi2PerCluster[1]) continue; - Bool_t isOK=kTRUE; - if(!isOK) continue; + if (!(track->GetConstrain())&&track->GetChi2MIP(1)>AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(1)) continue; // //forward track - without constraint forwardtrack = new(forwardtrack) AliITStrackMI(*original); forwardtrack->ResetClusters(); x = track->GetX(); RefitAt(x,forwardtrack,track); - track->fChi2MIP[2] = NormalizedChi2(forwardtrack,0); - if (track->fChi2MIP[2]>kMaxChi2PerCluster[2]*6.0) continue; - if (!(track->fConstrain)&&track->fChi2MIP[2]>kMaxChi2PerCluster[2]) continue; + track->SetChi2MIP(2,NormalizedChi2(forwardtrack,0)); + if (track->GetChi2MIP(2)>AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(2)*6.0) continue; + if (!(track->GetConstrain())&&track->GetChi2MIP(2)>AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(2)) continue; - track->fD[0] = forwardtrack->GetD(GetX(),GetY()); - track->fD[1] = forwardtrack->GetZat(GetX())-GetZ(); - forwardtrack->fD[0] = track->fD[0]; - forwardtrack->fD[1] = track->fD[1]; + //track->fD[0] = forwardtrack->GetD(GetX(),GetY()); + //track->fD[1] = forwardtrack->GetZat(GetX())-GetZ(); + forwardtrack->GetDZ(GetX(),GetY(),GetZ(),track->GetDP()); //I.B. + forwardtrack->SetD(0,track->GetD(0)); + forwardtrack->SetD(1,track->GetD(1)); { Int_t list[6]; - AliITSclusterV2* clist[6]; - track->fChi2MIP[4] = GetNumberOfSharedClusters(track,esdindex,list,clist); - if ( (!track->fConstrain) && track->fChi2MIP[4]>1.0) continue; + AliITSRecPoint* clist[6]; + track->SetChi2MIP(4,GetNumberOfSharedClusters(track,esdindex,list,clist)); + if ( (!track->GetConstrain()) && track->GetChi2MIP(4)>1.0) continue; } - track->fChi2MIP[3] = GetInterpolatedChi2(forwardtrack,backtrack); - if ( (track->fChi2MIP[3]>6.*kMaxChi2PerCluster[3])) continue; - if ( (!track->fConstrain) && (track->fChi2MIP[3]>2*kMaxChi2PerCluster[3])) { - track->fChi2MIP[3]=1000; + track->SetChi2MIP(3,GetInterpolatedChi2(forwardtrack,backtrack)); + if ( (track->GetChi2MIP(3)>6.*AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(3))) continue; + if ( (!track->GetConstrain()) && (track->GetChi2MIP(3)>2*AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(3))) { + track->SetChi2MIP(3,1000); continue; } - Double_t chi2 = track->fChi2MIP[0]+track->fNUsed; + Double_t chi2 = track->GetChi2MIP(0)+track->GetNUsed(); // for (Int_t ichi=0;ichi<5;ichi++){ - forwardtrack->fChi2MIP[ichi] = track->fChi2MIP[ichi]; + forwardtrack->SetChi2MIP(ichi, track->GetChi2MIP(ichi)); } if (chi2 < minchi2){ //besttrack = new AliITStrackMI(*forwardtrack); besttrack = track; besttrack->SetLabel(track->GetLabel()); - besttrack->fFakeRatio = track->fFakeRatio; + besttrack->SetFakeRatio(track->GetFakeRatio()); minchi2 = chi2; - original->fD[0] = forwardtrack->GetD(GetX(),GetY()); - original->fD[1] = forwardtrack->GetZat(GetX())-GetZ(); + //original->fD[0] = forwardtrack->GetD(GetX(),GetY()); + //original->fD[1] = forwardtrack->GetZat(GetX())-GetZ(); + forwardtrack->GetDZ(GetX(),GetY(),GetZ(),original->GetDP()); //I.B. } } delete backtrack; delete forwardtrack; Int_t accepted=0; for (Int_t i=0;iAt(i); + AliITStrackMI * track = (AliITStrackMI*)array->At(i); + if (!track) continue; - if (accepted>checkmax || track->fChi2MIP[3]>kMaxChi2PerCluster[3]*6. || + if (accepted>checkmax || track->GetChi2MIP(3)>AliITSReconstructor::GetRecoParam()->GetMaxChi2PerCluster(3)*6. || (track->GetNumberOfClusters()GetNumberOfClusters()-1.)|| - track->fChi2MIP[0]>besttrack->fChi2MIP[0]+2.*besttrack->fNUsed+3.){ - if (track->fConstrain || track->fN>5){ //keep best short tracks - without vertex constrain + track->GetChi2MIP(0)>besttrack->GetChi2MIP(0)+2.*besttrack->GetNUsed()+3.){ + if (track->GetConstrain() || track->GetNumberOfClusters()>5){ //keep best short tracks - without vertex constrain delete array->RemoveAt(i); continue; } @@ -2727,31 +3430,33 @@ AliITStrackMI * AliITStrackerMI::GetBestHypothesys(Int_t esdindex, AliITStrackMI // array->Compress(); SortTrackHypothesys(esdindex,checkmax,1); + array = (TObjArray*) fTrackHypothesys.At(esdindex); + if (!array) return 0; // PH What can be the reason? Check SortTrackHypothesys besttrack = (AliITStrackMI*)array->At(0); if (!besttrack) return 0; - besttrack->fChi2MIP[8]=0; + besttrack->SetChi2MIP(8,0); fBestTrackIndex[esdindex]=0; entries = array->GetEntriesFast(); AliITStrackMI *longtrack =0; minchi2 =1000; - Float_t minn=besttrack->GetNumberOfClusters()+besttrack->fNDeadZone; - for (Int_t itrack=entries-1;itrack>0;itrack--){ + Float_t minn=besttrack->GetNumberOfClusters()+besttrack->GetNDeadZone(); + for (Int_t itrack=entries-1;itrack>0;itrack--) { AliITStrackMI * track = (AliITStrackMI*)array->At(itrack); - if (!track->fConstrain) continue; - if (track->GetNumberOfClusters()+track->fNDeadZonefChi2MIP[0]-besttrack->fChi2MIP[0]>0.0) continue; - if (track->fChi2MIP[0]>4.) continue; - minn = track->GetNumberOfClusters()+track->fNDeadZone; + if (!track->GetConstrain()) continue; + if (track->GetNumberOfClusters()+track->GetNDeadZone()GetChi2MIP(0)-besttrack->GetChi2MIP(0)>0.0) continue; + if (track->GetChi2MIP(0)>4.) continue; + minn = track->GetNumberOfClusters()+track->GetNDeadZone(); longtrack =track; } //if (longtrack) besttrack=longtrack; Int_t list[6]; - AliITSclusterV2 * clist[6]; + AliITSRecPoint * clist[6]; Float_t shared = GetNumberOfSharedClusters(besttrack,esdindex,list,clist); - if (besttrack->fConstrain&&besttrack->fChi2MIP[0]fChi2MIP[1]fChi2MIP[2]fChi2MIP[3]GetConstrain()&&besttrack->GetChi2MIP(0)GetMaxChi2PerCluster(0)&&besttrack->GetChi2MIP(1)GetMaxChi2PerCluster(1) + &&besttrack->GetChi2MIP(2)GetMaxChi2PerCluster(2)&&besttrack->GetChi2MIP(3)GetMaxChi2PerCluster(3)){ RegisterClusterTracks(besttrack,esdindex); } // @@ -2776,7 +3481,7 @@ AliITStrackMI * AliITStrackerMI::GetBestHypothesys(Int_t esdindex, AliITStrackMI // Don't sign clusters if not gold track // if (!besttrack->IsGoldPrimary()) return besttrack; - if (besttrack->fESDtrack->GetKinkIndex(0)!=0) return besttrack; //track belong to kink + if (besttrack->GetESDtrack()->GetKinkIndex(0)!=0) return besttrack; //track belong to kink // if (fConstraint[fPass]){ // @@ -2784,40 +3489,39 @@ AliITStrackMI * AliITStrackerMI::GetBestHypothesys(Int_t esdindex, AliITStrackMI // Float_t *ny = GetNy(esdindex), *nz = GetNz(esdindex); for (Int_t i=0;i<6;i++){ - Int_t index = besttrack->fClIndex[i]; - if (index<=0) continue; + Int_t index = besttrack->GetClIndex(i); + if (index<0) continue; Int_t ilayer = (index & 0xf0000000) >> 28; - if (besttrack->fSigmaY[ilayer]<0.00000000001) continue; - AliITSclusterV2 *c = (AliITSclusterV2*)GetCluster(index); + if (besttrack->GetSigmaY(ilayer)<0.00000000001) continue; + AliITSRecPoint *c = (AliITSRecPoint*)GetCluster(index); if (!c) continue; if (ilayer>3&&c->GetNy()+c->GetNz()>6) continue; if ( (c->GetNy()+c->GetNz() )> ny[i]+nz[i]+0.7) continue; //shared track if ( c->GetNz()> nz[i]+0.7) continue; //shared track - if ( ilayer>2&& besttrack->fNormQ[ilayer]/besttrack->fExpQ>1.5) continue; + if ( ilayer>2&& AliITSReconstructor::GetRecoParam()->GetUseAmplitudeInfo(ilayer)) + if (besttrack->GetNormQ(ilayer)/besttrack->GetExpQ()>1.5) continue; //if ( c->GetNy()> ny[i]+0.7) continue; //shared track Bool_t cansign = kTRUE; for (Int_t itrack=0;itrackAt(i); if (!track) continue; - if (track->fChi2MIP[0]>besttrack->fChi2MIP[0]+2.*shared+1.) break; - if ( (track->fClIndex[ilayer]>0) && (track->fClIndex[ilayer]!=besttrack->fClIndex[ilayer])){ + if (track->GetChi2MIP(0)>besttrack->GetChi2MIP(0)+2.*shared+1.) break; + if ( (track->GetClIndex(ilayer)>=0) && (track->GetClIndex(ilayer)!=besttrack->GetClIndex(ilayer))){ cansign = kFALSE; break; } } if (cansign){ - if (TMath::Abs(besttrack->fDy[ilayer]/besttrack->fSigmaY[ilayer])>3.) continue; - if (TMath::Abs(besttrack->fDz[ilayer]/besttrack->fSigmaZ[ilayer])>3.) continue; + if (TMath::Abs(besttrack->GetDy(ilayer)/besttrack->GetSigmaY(ilayer))>3.) continue; + if (TMath::Abs(besttrack->GetDz(ilayer)/besttrack->GetSigmaZ(ilayer))>3.) continue; if (!c->IsUsed()) c->Use(); } } } return besttrack; } - - - +//------------------------------------------------------------------------ void AliITStrackerMI::GetBestHypothesysMIP(TObjArray &itsTracks) { // @@ -2836,23 +3540,23 @@ void AliITStrackerMI::GetBestHypothesysMIP(TObjArray &itsTracks) Float_t minn=0; Float_t maxchi2=1000; for (Int_t j=0;jGetEntriesFast();j++){ - AliITStrackMI* track = (AliITStrackMI*)array->At(j); - if (!track) continue; - if (track->fGoldV0) { - longtrack = track; //gold V0 track taken + AliITStrackMI* trackHyp = (AliITStrackMI*)array->At(j); + if (!trackHyp) continue; + if (trackHyp->GetGoldV0()) { + longtrack = trackHyp; //gold V0 track taken break; } - if (track->GetNumberOfClusters()+track->fNDeadZonefChi2MIP[0]; + if (trackHyp->GetNumberOfClusters()+trackHyp->GetNDeadZone()GetChi2MIP(0); if (fAfterV0){ - if (!track->fGoldV0&&track->fConstrain==kFALSE) chi2+=5; + if (!trackHyp->GetGoldV0()&&trackHyp->GetConstrain()==kFALSE) chi2+=5; } - if (track->GetNumberOfClusters()+track->fNDeadZone>minn) maxchi2 = track->fChi2MIP[0]; + if (trackHyp->GetNumberOfClusters()+trackHyp->GetNDeadZone()>minn) maxchi2 = trackHyp->GetChi2MIP(0); // if (chi2 > maxchi2) continue; - minn= track->GetNumberOfClusters()+track->fNDeadZone; + minn= trackHyp->GetNumberOfClusters()+trackHyp->GetNDeadZone(); maxchi2 = chi2; - longtrack=track; + longtrack=trackHyp; } // // @@ -2861,382 +3565,201 @@ void AliITStrackerMI::GetBestHypothesysMIP(TObjArray &itsTracks) if (!longtrack) {longtrack = besttrack;} else besttrack= longtrack; // - if (besttrack){ + if (besttrack) { Int_t list[6]; - AliITSclusterV2 * clist[6]; + AliITSRecPoint * clist[6]; Float_t shared = GetNumberOfSharedClusters(longtrack,i,list,clist); // - track->fNUsed = shared; - track->fNSkipped = besttrack->fNSkipped; - track->fChi2MIP[0] = besttrack->fChi2MIP[0]; - if (shared>0){ + track->SetNUsed(shared); + track->SetNSkipped(besttrack->GetNSkipped()); + track->SetChi2MIP(0,besttrack->GetChi2MIP(0)); + if (shared>0) { + if(!AliITSReconstructor::GetRecoParam()->GetAllowSharedClusters()) continue; Int_t nshared; Int_t overlist[6]; // Int_t sharedtrack = GetOverlapTrack(longtrack, i, nshared, list, overlist); //if (sharedtrack==-1) sharedtrack=0; - if (sharedtrack>=0){ + if (sharedtrack>=0) { besttrack = GetBest2Tracks(i,sharedtrack,10,5.5); } } - if (besttrack&&fAfterV0){ + if (besttrack&&fAfterV0) { UpdateESDtrack(besttrack,AliESDtrack::kITSin); } if (besttrack&&fConstraint[fPass]) UpdateESDtrack(besttrack,AliESDtrack::kITSin); - //if (besttrack&&besttrack->fConstrain) - // UpdateESDtrack(besttrack,AliESDtrack::kITSin); - if (besttrack->fChi2MIP[0]+besttrack->fNUsed>1.5){ - if ( (TMath::Abs(besttrack->fD[0])>0.1) && fConstraint[fPass]) { - track->fReconstructed= kFALSE; - } - if ( (TMath::Abs(besttrack->fD[1])>0.1) && fConstraint[fPass]){ - track->fReconstructed= kFALSE; - } + if (besttrack->GetChi2MIP(0)+besttrack->GetNUsed()>1.5 && fConstraint[fPass]) { + if ( TMath::Abs(besttrack->GetD(0))>0.1 || + TMath::Abs(besttrack->GetD(1))>0.1 ) track->SetReconstructed(kFALSE); } } } } - - +//------------------------------------------------------------------------ void AliITStrackerMI::CookLabel(AliITStrackMI *track,Float_t wrong) const { //-------------------------------------------------------------------- //This function "cooks" a track label. If label<0, this track is fake. //-------------------------------------------------------------------- Int_t tpcLabel=-1; - if ( track->fESDtrack) tpcLabel = TMath::Abs(track->fESDtrack->GetTPCLabel()); + if ( track->GetESDtrack()) tpcLabel = TMath::Abs(track->GetESDtrack()->GetTPCLabel()); - track->fChi2MIP[9]=0; + track->SetChi2MIP(9,0); Int_t nwrong=0; for (Int_t i=0;iGetNumberOfClusters();i++){ Int_t cindex = track->GetClusterIndex(i); Int_t l=(cindex & 0xf0000000) >> 28; - AliITSclusterV2 *cl = (AliITSclusterV2*)GetCluster(cindex); + AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(cindex); Int_t isWrong=1; for (Int_t ind=0;ind<3;ind++){ if (tpcLabel>0) if (cl->GetLabel(ind)==tpcLabel) isWrong=0; + AliDebug(2,Form("icl %d ilab %d lab %d",i,ind,cl->GetLabel(ind))); } - track->fChi2MIP[9]+=isWrong*(2<SetChi2MIP(9,track->GetChi2MIP(9)+isWrong*(2<fFakeRatio = double(nwrong)/double(track->GetNumberOfClusters()); + Int_t nclusters = track->GetNumberOfClusters(); + if (nclusters > 0) //PH Some tracks don't have any cluster + track->SetFakeRatio(double(nwrong)/double(nclusters)); if (tpcLabel>0){ - if (track->fFakeRatio>wrong) track->fLab = -tpcLabel; + if (track->GetFakeRatio()>wrong) track->SetLabel(-tpcLabel); else - track->fLab = tpcLabel; + track->SetLabel(tpcLabel); } + AliDebug(2,Form(" nls %d wrong %d label %d tpcLabel %d\n",nclusters,nwrong,track->GetLabel(),tpcLabel)); } - - - +//------------------------------------------------------------------------ void AliITStrackerMI::CookdEdx(AliITStrackMI* track) { // - // - // Int_t list[6]; - //AliITSclusterV2 * clist[6]; - // Int_t shared = GetNumberOfSharedClusters(track,index,list,clist); - Float_t dedx[4]; - Int_t accepted=0; - track->fChi2MIP[9]=0; + track->SetChi2MIP(9,0); for (Int_t i=0;iGetNumberOfClusters();i++){ Int_t cindex = track->GetClusterIndex(i); Int_t l=(cindex & 0xf0000000) >> 28; - AliITSclusterV2 *cl = (AliITSclusterV2*)GetCluster(cindex); - Int_t lab = TMath::Abs(track->fESDtrack->GetTPCLabel()); + AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(cindex); + Int_t lab = TMath::Abs(track->GetESDtrack()->GetTPCLabel()); Int_t isWrong=1; for (Int_t ind=0;ind<3;ind++){ if (cl->GetLabel(ind)==lab) isWrong=0; } - track->fChi2MIP[9]+=isWrong*(2<3 && (cl->GetNy()>4) || (cl->GetNz()>4)) continue; //shared track - //if (l>3&& !(cl->GetType()==1||cl->GetType()==10)) continue; - //if (l<4&& !(cl->GetType()==1)) continue; - dedx[accepted]= track->fdEdxSample[i]; - //dedx[accepted]= track->fNormQ[l]; - accepted++; - } - if (accepted<1) { - track->SetdEdx(0); - return; + track->SetChi2MIP(9,track->GetChi2MIP(9)+isWrong*(2<nu-1) weight = TMath::Max(nu-i,0.); - sumamp+= dedx[indexes[i]]*weight; - sumweight+=weight; - } - track->SetdEdx(sumamp/sumweight); + track->CookdEdx(low,up); } - - -void AliITStrackerMI::MakeCoeficients(Int_t ntracks){ +//------------------------------------------------------------------------ +void AliITStrackerMI::MakeCoefficients(Int_t ntracks){ // + // Create some arrays // - if (fCoeficients) delete []fCoeficients; - fCoeficients = new Float_t[ntracks*48]; - for (Int_t i=0;iGetTgl(); Float_t phi = track->GetSnp(); - phi = TMath::Sqrt(phi*phi/(1.-phi*phi)); - GetError(layer,cluster,theta,phi,track->fExpQ,erry,errz); - Double_t chi2 = track->GetPredictedChi2MI(cluster->GetY(),cluster->GetZ(),erry,errz); + phi = TMath::Abs(phi)*TMath::Sqrt(1./((1.-phi)*(1.+phi))); + AliITSClusterParam::GetError(layer,cluster,theta,phi,track->GetExpQ(),erry,errz,covyz); + AliDebug(2,Form(" chi2: tr-cl %f %f tr X %f cl X %f",track->GetY()-cluster->GetY(),track->GetZ()-cluster->GetZ(),track->GetX(),cluster->GetX())); + // Take into account the mis-alignment (bring track to cluster plane) + Double_t xTrOrig=track->GetX(); + if (!track->Propagate(xTrOrig+cluster->GetX())) return 1000.; + AliDebug(2,Form(" chi2: tr-cl %f %f tr X %f cl X %f",track->GetY()-cluster->GetY(),track->GetZ()-cluster->GetZ(),track->GetX(),cluster->GetX())); + Double_t chi2 = track->GetPredictedChi2MI(cluster->GetY(),cluster->GetZ(),erry,errz,covyz); + // Bring the track back to detector plane in ideal geometry + // [mis-alignment will be accounted for in UpdateMI()] + if (!track->Propagate(xTrOrig)) return 1000.; Float_t ny,nz; - GetNTeor(layer,cluster, theta,phi,ny,nz); + AliITSClusterParam::GetNTeor(layer,cluster,theta,phi,ny,nz); Double_t delta = cluster->GetNy()+cluster->GetNz()-nz-ny; if (delta>1){ chi2+=0.5*TMath::Min(delta/2,2.); chi2+=2.*cluster->GetDeltaProbability(); } // - track->fNy[layer] =ny; - track->fNz[layer] =nz; - track->fSigmaY[layer] = erry; - track->fSigmaZ[layer] = errz; + track->SetNy(layer,ny); + track->SetNz(layer,nz); + track->SetSigmaY(layer,erry); + track->SetSigmaZ(layer, errz); + track->SetSigmaYZ(layer,covyz); //track->fNormQ[layer] = cluster->GetQ()/TMath::Sqrt(1+theta*theta+phi*phi); - track->fNormQ[layer] = cluster->GetQ()/TMath::Sqrt((1.+ track->fP3*track->fP3)/(1.- track->fP2*track->fP2)); + track->SetNormQ(layer,cluster->GetQ()/TMath::Sqrt((1.+ track->GetTgl()*track->GetTgl())/((1.-track->GetSnp())*(1.+track->GetSnp())))); return chi2; } - -Int_t AliITStrackerMI::UpdateMI(AliITStrackMI* track, const AliITSclusterV2* cl,Double_t chi2,Int_t index) const +//------------------------------------------------------------------------ +Int_t AliITStrackerMI::UpdateMI(AliITStrackMI* track, const AliITSRecPoint* cl,Double_t chi2,Int_t index) const { // - // + // Update ITS track // Int_t layer = (index & 0xf0000000) >> 28; - track->fClIndex[layer] = index; - if ( (layer>1) &&track->fNormQ[layer]/track->fExpQ<0.5 ) { - chi2+= (0.5-track->fNormQ[layer]/track->fExpQ)*10.; - track->fdEdxMismatch+=(0.5-track->fNormQ[layer]/track->fExpQ)*10.; - } - return track->UpdateMI(cl->GetY(),cl->GetZ(),track->fSigmaY[layer],track->fSigmaZ[layer],chi2,index); -} - -void AliITStrackerMI::GetNTeor(Int_t layer, const AliITSclusterV2* /*cl*/, Float_t theta, Float_t phi, Float_t &ny, Float_t &nz) -{ - // - //get "mean shape" - // - if (layer==0){ - ny = 1.+TMath::Abs(phi)*3.2; - nz = 1.+TMath::Abs(theta)*0.34; - return; - } - if (layer==1){ - ny = 1.+TMath::Abs(phi)*3.2; - nz = 1.+TMath::Abs(theta)*0.28; - return; - } - - if (layer>3){ - ny = 2.02+TMath::Abs(phi)*1.95; - nz = 2.02+TMath::Abs(phi)*2.35; - return; - } - ny = 6.6-2.7*TMath::Abs(phi); - nz = 2.8-3.11*TMath::Abs(phi)+0.45*TMath::Abs(theta); -} - - - -Int_t AliITStrackerMI::GetError(Int_t layer, const AliITSclusterV2*cl, Float_t theta, Float_t phi,Float_t expQ, Float_t &erry, Float_t &errz) -{ - //calculate cluster position error - // - Float_t nz,ny; - GetNTeor(layer, cl,theta,phi,ny,nz); - erry = TMath::Sqrt(cl->GetSigmaY2()); - errz = TMath::Sqrt(cl->GetSigmaZ2()); - // - // PIXELS - if (layer<2){ - - if (TMath::Abs(ny-cl->GetNy())>0.6) { - if (nyGetNy()){ - erry*=0.4+TMath::Abs(ny-cl->GetNy()); - errz*=0.4+TMath::Abs(ny-cl->GetNy()); - }else{ - erry*=0.7+0.5*TMath::Abs(ny-cl->GetNy()); - errz*=0.7+0.5*TMath::Abs(ny-cl->GetNy()); - } - } - if (TMath::Abs(nz-cl->GetNz())>1.) { - erry*=TMath::Abs(nz-cl->GetNz()); - errz*=TMath::Abs(nz-cl->GetNz()); + track->SetClIndex(layer, index); + if (layer>1&&AliITSReconstructor::GetRecoParam()->GetUseAmplitudeInfo(layer)) { + if (track->GetNormQ(layer)/track->GetExpQ()<0.5 ) { + chi2+= (0.5-track->GetNormQ(layer)/track->GetExpQ())*10.; + track->SetdEdxMismatch(track->GetdEdxMismatch()+(0.5-track->GetNormQ(layer)/track->GetExpQ())*10.); } - erry*=0.85; - errz*=0.85; - erry= TMath::Min(erry,float(0.005)); - errz= TMath::Min(errz,float(0.03)); - return 10; } -//STRIPS - if (layer>3){ - //factor 1.8 appears in new simulation - // - Float_t scale=1.8; - if (cl->GetNy()==100||cl->GetNz()==100){ - erry = 0.004*scale; - errz = 0.2*scale; - return 100; - } - if (cl->GetNy()+cl->GetNz()>12){ - erry = 0.06*scale; - errz = 0.57*scale; - return 100; - } - Float_t normq = cl->GetQ()/(TMath::Sqrt(1+theta*theta+phi*phi)); - Float_t chargematch = TMath::Max(double(normq/expQ),2.); - // - if (cl->GetType()==1 || cl->GetType()==10 ){ - if (chargematch<1.0 || (cl->GetNy()+cl->GetNz()GetNy()+cl->GetNz()GetNy()+cl->GetNz()-nz+ny),0.15)*scale; - return 103; - } - if (cl->GetType()==2 || cl->GetType()==11 ){ - erry = TMath::Min(0.0010*(1+chargematch+cl->GetNy()+cl->GetNz()-nz+ny),0.05)*scale; - errz = TMath::Min(0.025*(1+chargematch+cl->GetNy()+cl->GetNz()-nz+ny),0.5)*scale; - return 104; - } - - if (cl->GetType()>100 ){ - if ((chargematch+cl->GetNy()+cl->GetNz()-nz-ny<1.5)){ - errz = 0.05*scale; - erry = 0.00096*scale; - return 105; - } - if (cl->GetNy()+cl->GetNz()-nz-ny<1){ - errz = 0.10*scale; - erry = 0.0025*scale; - return 106; - } + if (cl->GetQ()<=0) return 0; // ingore the "virtual" clusters - errz = TMath::Min(0.05*(chargematch+cl->GetNy()+cl->GetNz()-nz-ny),0.4)*scale; - erry = TMath::Min(0.003*(chargematch+cl->GetNy()+cl->GetNz()-nz-ny),0.05)*scale; - return 107; - } - Float_t diff = cl->GetNy()+cl->GetNz()-ny-nz; - if (diff<1) diff=1; - if (diff>4) diff=4; - - if (cl->GetType()==5||cl->GetType()==6||cl->GetType()==7||cl->GetType()==8){ - errz = 0.14*diff; - erry = 0.003*diff; - return 108; - } - erry = 0.04*diff; - errz = 0.06*diff; - return 109; - } - //DRIFTS - Float_t normq = cl->GetQ()/(TMath::Sqrt(1+theta*theta+phi*phi)); - Float_t chargematch = normq/expQ; - Float_t factorz=1; - Int_t cnz = cl->GetNz()%10; - //charge match - if (cl->GetType()==1){ - if (chargematch<1.25){ - erry = 0.0028*(1.+6./cl->GetQ()); // gold clusters - } - else{ - erry = 0.003*chargematch; - if (cl->GetNz()==3) erry*=1.5; - } - if (chargematch<1.0){ - errz = 0.0011*(1.+6./cl->GetQ()); - } - else{ - errz = 0.002*(1+2*(chargematch-1.)); - } - if (cnz>nz+0.6) { - erry*=(cnz-nz+0.5); - errz*=1.4*(cnz-nz+0.5); - } - } - if (cl->GetType()>1){ - if (chargematch<1){ - erry = 0.00385*(1.+6./cl->GetQ()); // gold clusters - errz = 0.0016*(1.+6./cl->GetQ()); - } - else{ - errz = 0.0014*(1+3*(chargematch-1.)); - erry = 0.003*(1+3*(chargematch-1.)); - } - if (cnz>nz+0.6) { - erry*=(cnz-nz+0.5); - errz*=1.4*(cnz-nz+0.5); - } - } - if (TMath::Abs(cl->GetY())>2.5){ - factorz*=1+2*(TMath::Abs(cl->GetY())-2.5); - } - if (TMath::Abs(cl->GetY())<1){ - factorz*=1.+0.5*TMath::Abs(TMath::Abs(cl->GetY())-1.); - } - factorz= TMath::Min(factorz,float(4.)); - errz*=factorz; + // Take into account the mis-alignment (bring track to cluster plane) + Double_t xTrOrig=track->GetX(); + Float_t clxyz[3]; cl->GetGlobalXYZ(clxyz);Double_t trxyz[3]; track->GetXYZ(trxyz); + AliDebug(2,Form("gtr %f %f %f",trxyz[0],trxyz[1],trxyz[2])); + AliDebug(2,Form("gcl %f %f %f",clxyz[0],clxyz[1],clxyz[2])); + AliDebug(2,Form(" xtr %f xcl %f",track->GetX(),cl->GetX())); - erry= TMath::Min(erry,float(0.05)); - errz= TMath::Min(errz,float(0.05)); - return 200; -} + if (!track->Propagate(xTrOrig+cl->GetX())) return 0; + + AliCluster c(*cl); + c.SetSigmaY2(track->GetSigmaY(layer)*track->GetSigmaY(layer)); + c.SetSigmaZ2(track->GetSigmaZ(layer)*track->GetSigmaZ(layer)); + c.SetSigmaYZ(track->GetSigmaYZ(layer)); + Int_t updated = track->UpdateMI(&c,chi2,index); + // Bring the track back to detector plane in ideal geometry + if (!track->Propagate(xTrOrig)) return 0; + + if(!updated) AliDebug(2,"update failed"); + return updated; +} -void AliITStrackerMI::GetDCASigma(AliITStrackMI* track, Float_t & sigmarfi, Float_t &sigmaz) +//------------------------------------------------------------------------ +void AliITStrackerMI::GetDCASigma(const AliITStrackMI* track, Float_t & sigmarfi, Float_t &sigmaz) { // //DCA sigmas parameterization //to be paramterized using external parameters in future // // - sigmarfi = 0.004+1.4 *TMath::Abs(track->fP4)+332.*track->fP4*track->fP4; - sigmaz = 0.011+4.37*TMath::Abs(track->fP4); + sigmarfi = 0.0040+1.4 *TMath::Abs(track->GetC())+332.*track->GetC()*track->GetC(); + sigmaz = 0.0110+4.37*TMath::Abs(track->GetC()); } - - -void AliITStrackerMI::SignDeltas( TObjArray *ClusterArray, Float_t vz) +//------------------------------------------------------------------------ +void AliITStrackerMI::SignDeltas(const TObjArray *clusterArray, Float_t vz) { // + // Clusters from delta electrons? // - Int_t entries = ClusterArray->GetEntriesFast(); + Int_t entries = clusterArray->GetEntriesFast(); if (entries<4) return; - AliITSclusterV2* cluster = (AliITSclusterV2*)ClusterArray->At(0); + AliITSRecPoint* cluster = (AliITSRecPoint*)clusterArray->At(0); Int_t layer = cluster->GetLayer(); if (layer>1) return; Int_t index[10000]; @@ -3244,7 +3767,7 @@ void AliITStrackerMI::SignDeltas( TObjArray *ClusterArray, Float_t vz) Float_t r = (layer>0)? 7:4; // for (Int_t i=0;iAt(i); + AliITSRecPoint* cl0 = (AliITSRecPoint*)clusterArray->At(i); Float_t nz = 1+TMath::Abs((cl0->GetZ()-vz)/r); if (cl0->GetNy()+cl0->GetNz()<=5+2*layer+nz) continue; index[ncandidates] = i; //candidate to belong to delta electron track @@ -3257,7 +3780,7 @@ void AliITStrackerMI::SignDeltas( TObjArray *ClusterArray, Float_t vz) // // for (Int_t i=0;iAt(index[i]); + AliITSRecPoint* cl0 = (AliITSRecPoint*)clusterArray->At(index[i]); if (cl0->GetDeltaProbability()>0.8) continue; // Int_t ncl = 0; @@ -3265,7 +3788,7 @@ void AliITStrackerMI::SignDeltas( TObjArray *ClusterArray, Float_t vz) sumy=sumz=sumy2=sumyz=sumw=0.0; for (Int_t j=0;jAt(index[j]); + AliITSRecPoint* cl1 = (AliITSRecPoint*)clusterArray->At(index[j]); // Float_t dz = cl0->GetZ()-cl1->GetZ(); Float_t dy = cl0->GetY()-cl1->GetY(); @@ -3298,26 +3821,24 @@ void AliITStrackerMI::SignDeltas( TObjArray *ClusterArray, Float_t vz) } } } - - +//------------------------------------------------------------------------ void AliITStrackerMI::UpdateESDtrack(AliITStrackMI* track, ULong_t flags) const { // + // Update ESD track // track->UpdateESDtrack(flags); - AliITStrackMI * oldtrack = (AliITStrackMI*)(track->fESDtrack->GetITStrack()); + AliITStrackMI * oldtrack = (AliITStrackMI*)(track->GetESDtrack()->GetITStrack()); if (oldtrack) delete oldtrack; - track->fESDtrack->SetITStrack(new AliITStrackMI(*track)); - if (TMath::Abs(track->fDnorm[1])<0.000000001){ + track->GetESDtrack()->SetITStrack(new AliITStrackMI(*track)); + if (TMath::Abs(track->GetDnorm(1))<0.000000001){ printf("Problem\n"); } } - - - +//------------------------------------------------------------------------ Int_t AliITStrackerMI::GetNearestLayer(const Double_t *xr) const{ // - //Get nearest upper layer close to the point xr. + // Get nearest upper layer close to the point xr. // rough approximation // const Float_t kRadiuses[6]={4,6.5,15.03,24.,38.5,43.7}; @@ -3331,764 +3852,867 @@ Int_t AliITStrackerMI::GetNearestLayer(const Double_t *xr) const{ } return res; } +//------------------------------------------------------------------------ +void AliITStrackerMI::BuildMaterialLUT(TString material) { + //-------------------------------------------------------------------- + // Fill a look-up table with mean material + //-------------------------------------------------------------------- + Int_t n=1000; + Double_t mparam[7]; + Double_t point1[3],point2[3]; + Double_t phi,cosphi,sinphi,z; + // 0-5 layers, 6 pipe, 7-8 shields + Double_t rmin[9]={ 3.5, 5.5,13.0,22.0,35.0,41.0, 2.0, 8.0,25.0}; + Double_t rmax[9]={ 5.5, 8.0,17.0,26.0,41.0,47.0, 3.0,10.5,30.0}; + + Int_t ifirst=0,ilast=0; + if(material.Contains("Pipe")) { + ifirst=6; ilast=6; + } else if(material.Contains("Shields")) { + ifirst=7; ilast=8; + } else if(material.Contains("Layers")) { + ifirst=0; ilast=5; + } else { + Error("BuildMaterialLUT","Wrong layer name\n"); + } -void AliITStrackerMI::UpdateTPCV0(AliESD *event){ - // - //try to update, or reject TPC V0s - // - Int_t nv0s = event->GetNumberOfV0MIs(); - Int_t nitstracks = fTrackHypothesys.GetEntriesFast(); - - for (Int_t i=0;iGetV0MI(i); - Int_t ip = vertex->GetIndex(0); - Int_t im = vertex->GetIndex(1); - // - TObjArray * arrayp = (ipAt(0):0; - AliITStrackMI * trackm = (arraym!=0) ? (AliITStrackMI*)arraym->At(0):0; - // - // - if (trackp){ - if (trackp->fN+trackp->fNDeadZone>5.5){ - if (trackp->fConstrain&&trackp->fChi2MIP[0]<3) vertex->SetStatus(-100); - if (!trackp->fConstrain&&trackp->fChi2MIP[0]<2) vertex->SetStatus(-100); - } - } - - if (trackm){ - if (trackm->fN+trackm->fNDeadZone>5.5){ - if (trackm->fConstrain&&trackm->fChi2MIP[0]<3) vertex->SetStatus(-100); - if (!trackm->fConstrain&&trackm->fChi2MIP[0]<2) vertex->SetStatus(-100); - } + for(Int_t imat=ifirst; imat<=ilast; imat++) { + Double_t param[5]={0.,0.,0.,0.,0.}; + for (Int_t i=0; iRndm(); + cosphi = TMath::Cos(phi); sinphi = TMath::Sin(phi); + z = 14.*(-1.+2.*gRandom->Rndm()); // SPD barrel + point1[0] = rmin[imat]*cosphi; + point1[1] = rmin[imat]*sinphi; + point1[2] = z; + point2[0] = rmax[imat]*cosphi; + point2[1] = rmax[imat]*sinphi; + point2[2] = z; + AliTracker::MeanMaterialBudget(point1,point2,mparam); + for(Int_t j=0;j<5;j++) param[j]+=mparam[j]; } - if (vertex->GetStatus()==-100) continue; - // - Int_t clayer = GetNearestLayer(vertex->GetXrp()); - vertex->SetNBefore(clayer); // - vertex->SetChi2Before(9*clayer); // - vertex->SetNAfter(6-clayer); // - vertex->SetChi2After(0); // - // - if (clayer >1 ){ // calculate chi2 before vertex - Float_t chi2p = 0, chi2m=0; - // - if (trackp){ - for (Int_t ilayer=0;ilayerfClIndex[ilayer]>0){ - chi2p+=trackp->fDy[ilayer]*trackp->fDy[ilayer]/(trackp->fSigmaY[ilayer]*trackp->fSigmaY[ilayer])+ - trackp->fDz[ilayer]*trackp->fDz[ilayer]/(trackp->fSigmaZ[ilayer]*trackp->fSigmaZ[ilayer]); - } - else{ - chi2p+=9; - } - } - }else{ - chi2p = 9*clayer; - } - // - if (trackm){ - for (Int_t ilayer=0;ilayerfClIndex[ilayer]>0){ - chi2m+=trackm->fDy[ilayer]*trackm->fDy[ilayer]/(trackm->fSigmaY[ilayer]*trackm->fSigmaY[ilayer])+ - trackm->fDz[ilayer]*trackm->fDz[ilayer]/(trackm->fSigmaZ[ilayer]*trackm->fSigmaZ[ilayer]); - } - else{ - chi2m+=9; - } - } - }else{ - chi2m = 9*clayer; - } - vertex->SetChi2Before(TMath::Min(chi2p,chi2m)); - if (TMath::Min(chi2p,chi2m)/Float_t(clayer)<4) vertex->SetStatus(-10); // track exist before vertex - } - - if (clayer < 5 ){ // calculate chi2 after vertex - Float_t chi2p = 0, chi2m=0; - // - if (trackp&&TMath::Abs(trackp->fP3)<1.){ - for (Int_t ilayer=clayer;ilayer<6;ilayer++){ - if (trackp->fClIndex[ilayer]>0){ - chi2p+=trackp->fDy[ilayer]*trackp->fDy[ilayer]/(trackp->fSigmaY[ilayer]*trackp->fSigmaY[ilayer])+ - trackp->fDz[ilayer]*trackp->fDz[ilayer]/(trackp->fSigmaZ[ilayer]*trackp->fSigmaZ[ilayer]); - } - else{ - chi2p+=9; - } - } - }else{ - chi2p = 0; - } - // - if (trackm&&TMath::Abs(trackm->fP3)<1.){ - for (Int_t ilayer=clayer;ilayer<6;ilayer++){ - if (trackm->fClIndex[ilayer]>0){ - chi2m+=trackm->fDy[ilayer]*trackm->fDy[ilayer]/(trackm->fSigmaY[ilayer]*trackm->fSigmaY[ilayer])+ - trackm->fDz[ilayer]*trackm->fDz[ilayer]/(trackm->fSigmaZ[ilayer]*trackm->fSigmaZ[ilayer]); - } - else{ - chi2m+=9; - } - } - }else{ - chi2m = 0; - } - vertex->SetChi2After(TMath::Max(chi2p,chi2m)); - if (TMath::Max(chi2m,chi2p)/Float_t(6-clayer)>9) vertex->SetStatus(-20); // track not found in ITS + for(Int_t j=0;j<5;j++) param[j]/=(Float_t)n; + if(imat<=5) { + fxOverX0Layer[imat] = param[1]; + fxTimesRhoLayer[imat] = param[0]*param[4]; + } else if(imat==6) { + fxOverX0Pipe = param[1]; + fxTimesRhoPipe = param[0]*param[4]; + } else if(imat==7) { + fxOverX0Shield[0] = param[1]; + fxTimesRhoShield[0] = param[0]*param[4]; + } else if(imat==8) { + fxOverX0Shield[1] = param[1]; + fxTimesRhoShield[1] = param[0]*param[4]; } } - // + /* + printf("%s\n",material.Data()); + printf("%f %f\n",fxOverX0Pipe,fxTimesRhoPipe); + printf("%f %f\n",fxOverX0Shield[0],fxTimesRhoShield[0]); + printf("%f %f\n",fxOverX0Shield[1],fxTimesRhoShield[1]); + printf("%f %f\n",fxOverX0Layer[0],fxTimesRhoLayer[0]); + printf("%f %f\n",fxOverX0Layer[1],fxTimesRhoLayer[1]); + printf("%f %f\n",fxOverX0Layer[2],fxTimesRhoLayer[2]); + printf("%f %f\n",fxOverX0Layer[3],fxTimesRhoLayer[3]); + printf("%f %f\n",fxOverX0Layer[4],fxTimesRhoLayer[4]); + printf("%f %f\n",fxOverX0Layer[5],fxTimesRhoLayer[5]); + */ + return; } +//------------------------------------------------------------------------ +Int_t AliITStrackerMI::CorrectForPipeMaterial(AliITStrackMI *t, + TString direction) { + //------------------------------------------------------------------- + // Propagate beyond beam pipe and correct for material + // (material budget in different ways according to fUseTGeo value) + // Add time if going outward (PropagateTo or PropagateToTGeo) + //------------------------------------------------------------------- + // Define budget mode: + // 0: material from AliITSRecoParam (hard coded) + // 1: material from TGeo in one step (on the fly) + // 2: material from lut + // 3: material from TGeo in one step (same for all hypotheses) + Int_t mode; + switch(fUseTGeo) { + case 0: + mode=0; + break; + case 1: + mode=1; + break; + case 2: + mode=2; + break; + case 3: + if(fTrackingPhase.Contains("Clusters2Tracks")) + { mode=3; } else { mode=1; } + break; + case 4: + if(fTrackingPhase.Contains("Clusters2Tracks")) + { mode=3; } else { mode=2; } + break; + default: + mode=0; + break; + } + if(fTrackingPhase.Contains("Default")) mode=0; + + Int_t index=fCurrentEsdTrack; + + Float_t dir = (direction.Contains("inward") ? 1. : -1.); + Double_t rToGo=(dir>0 ? AliITSRecoParam::GetrInsidePipe() : AliITSRecoParam::GetrOutsidePipe()); + Double_t xToGo; + if (!t->GetLocalXat(rToGo,xToGo)) return 0; + + Double_t xOverX0,x0,lengthTimesMeanDensity; + + switch(mode) { + case 0: + xOverX0 = AliITSRecoParam::GetdPipe(); + x0 = AliITSRecoParam::GetX0Be(); + lengthTimesMeanDensity = xOverX0*x0; + lengthTimesMeanDensity *= dir; + if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0; + break; + case 1: + if (!t->PropagateToTGeo(xToGo,1)) return 0; + break; + case 2: + if(fxOverX0Pipe<0) BuildMaterialLUT("Pipe"); + xOverX0 = fxOverX0Pipe; + lengthTimesMeanDensity = fxTimesRhoPipe; + lengthTimesMeanDensity *= dir; + if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0; + break; + case 3: + if(!fxOverX0PipeTrks || index<0 || index>=fNtracks) Error("CorrectForPipeMaterial","Incorrect usage of UseTGeo option!\n"); + if(fxOverX0PipeTrks[index]<0) { + if (!t->PropagateToTGeo(xToGo,1,xOverX0,lengthTimesMeanDensity)) return 0; + Double_t angle=TMath::Sqrt((1.+t->GetTgl()*t->GetTgl())/ + ((1.-t->GetSnp())*(1.+t->GetSnp()))); + fxOverX0PipeTrks[index] = TMath::Abs(xOverX0)/angle; + fxTimesRhoPipeTrks[index] = TMath::Abs(lengthTimesMeanDensity)/angle; + return 1; + } + xOverX0 = fxOverX0PipeTrks[index]; + lengthTimesMeanDensity = fxTimesRhoPipeTrks[index]; + lengthTimesMeanDensity *= dir; + if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0; + break; + } + return 1; +} +//------------------------------------------------------------------------ +Int_t AliITStrackerMI::CorrectForShieldMaterial(AliITStrackMI *t, + TString shield, + TString direction) { + //------------------------------------------------------------------- + // Propagate beyond SPD or SDD shield and correct for material + // (material budget in different ways according to fUseTGeo value) + // Add time if going outward (PropagateTo or PropagateToTGeo) + //------------------------------------------------------------------- -void AliITStrackerMI::FindV02(AliESD *event) -{ - // - // V0 finder - // - // Cuts on DCA - R dependent - // max distance DCA between 2 tracks cut - // maxDist = TMath::Min(kMaxDist,kMaxDist0+pvertex->GetRr()*kMaxDist); - // - const Float_t kMaxDist0 = 0.1; - const Float_t kMaxDist1 = 0.1; - const Float_t kMaxDist = 1; - const Float_t kMinPointAngle = 0.85; - const Float_t kMinPointAngle2 = 0.99; - const Float_t kMinR = 0.5; - const Float_t kMaxR = 220; - //const Float_t kCausality0Cut = 0.19; - //const Float_t kLikelihood01Cut = 0.25; - //const Float_t kPointAngleCut = 0.9996; - const Float_t kCausality0Cut = 0.19; - const Float_t kLikelihood01Cut = 0.45; - const Float_t kLikelihood1Cut = 0.5; - const Float_t kCombinedCut = 0.55; - - // - // - TTreeSRedirector &cstream = *fDebugStreamer; - Int_t ntracks = event->GetNumberOfTracks(); - Int_t nitstracks = fTrackHypothesys.GetEntriesFast(); - fOriginal.Expand(ntracks); - fTrackHypothesys.Expand(ntracks); - fBestHypothesys.Expand(ntracks); - // - AliHelix * helixes = new AliHelix[ntracks+2]; - TObjArray trackarray(ntracks+2); //array with tracks - with vertex constrain - TObjArray trackarrayc(ntracks+2); //array of "best tracks" - without vertex constrain - TObjArray trackarrayl(ntracks+2); //array of "longest tracks" - without vertex constrain - Bool_t * forbidden = new Bool_t [ntracks+2]; - Int_t *itsmap = new Int_t [ntracks+2]; - Float_t *dist = new Float_t[ntracks+2]; - Float_t *normdist0 = new Float_t[ntracks+2]; - Float_t *normdist1 = new Float_t[ntracks+2]; - Float_t *normdist = new Float_t[ntracks+2]; - Float_t *norm = new Float_t[ntracks+2]; - Float_t *maxr = new Float_t[ntracks+2]; - Float_t *minr = new Float_t[ntracks+2]; - Float_t *minPointAngle= new Float_t[ntracks+2]; - // - AliESDV0MI *pvertex = new AliESDV0MI; - AliITStrackMI * dummy= new AliITStrackMI; - dummy->SetLabel(0); - AliITStrackMI trackat0; //temporary track for DCA calculation - // - Float_t primvertex[3]={GetX(),GetY(),GetZ()}; - // - // make its - esd map - // - for (Int_t itrack=0;itrackfESDtrack->GetID(); - itsmap[esdindex] = itrack; - } - // - // create its tracks from esd tracks if not done before - // - for (Int_t itrack=0;itrack=0) continue; - AliITStrackMI * tpctrack = new AliITStrackMI(*(event->GetTrack(itrack))); - tpctrack->fD[0] = tpctrack->GetD(GetX(),GetY()); - tpctrack->fD[1] = tpctrack->GetZat(GetX())-GetZ(); - if (tpctrack->fD[0]<20 && tpctrack->fD[1]<20){ - // tracks which can reach inner part of ITS - // propagate track to outer its volume - with correction for material - CorrectForDeadZoneMaterial(tpctrack); - } - itsmap[itrack] = nitstracks; - fOriginal.AddAt(tpctrack,nitstracks); - nitstracks++; - } - // - // fill temporary arrays - // - for (Int_t itrack=0;itrackGetTrack(itrack); - Int_t itsindex = itsmap[itrack]; - AliITStrackMI *original = (AliITStrackMI*)fOriginal.At(itsmap[itrack]); - if (!original) continue; - AliITStrackMI *bestConst = 0; - AliITStrackMI *bestLong = 0; - AliITStrackMI *best = 0; - // - // - TObjArray * array = (TObjArray*) fTrackHypothesys.At(itsindex); - Int_t hentries = (array==0) ? 0 : array->GetEntriesFast(); - // Get best track with vertex constrain - for (Int_t ih=0;ihAt(ih); - if (!trackh->fConstrain) continue; - if (!bestConst) bestConst = trackh; - if (trackh->fN>5.0){ - bestConst = trackh; // full track - with minimal chi2 - break; - } - if (trackh->fN+trackh->fNDeadZone<=bestConst->fN+bestConst->fNDeadZone) continue; - bestConst = trackh; - break; - } - // Get best long track without vertex constrain and best track without vertex constrain - for (Int_t ih=0;ihAt(ih); - if (trackh->fConstrain) continue; - if (!best) best = trackh; - if (!bestLong) bestLong = trackh; - if (trackh->fN>5.0){ - bestLong = trackh; // full track - with minimal chi2 - break; - } - if (trackh->fN+trackh->fNDeadZone<=bestLong->fN+bestLong->fNDeadZone) continue; - bestLong = trackh; - } - if (!best) { - best = original; - bestLong = original; - } - trackat0 = *bestLong; - Double_t xx,yy,zz,alpha; - bestLong->GetGlobalXYZat(bestLong->GetX(),xx,yy,zz); - alpha = TMath::ATan2(yy,xx); - trackat0.Propagate(alpha,0); - // calculate normalized distances to the vertex - // - if ( bestLong->fN>3 ){ - dist[itsindex] = trackat0.fP0; - norm[itsindex] = TMath::Sqrt(trackat0.fC00); - normdist0[itsindex] = TMath::Abs(trackat0.fP0/norm[itsindex]); - normdist1[itsindex] = TMath::Abs((trackat0.fP1-primvertex[2])/TMath::Sqrt(trackat0.fC11)); - normdist[itsindex] = TMath::Sqrt(normdist0[itsindex]*normdist0[itsindex]+normdist1[itsindex]*normdist1[itsindex]); - } - else{ - if (bestConst&&bestConst->fN+bestConst->fNDeadZone>4.5){ - dist[itsindex] = bestConst->fD[0]; - norm[itsindex] = bestConst->fDnorm[0]; - normdist0[itsindex] = TMath::Abs(bestConst->fD[0]/norm[itsindex]); - normdist1[itsindex] = TMath::Abs(bestConst->fD[0]/norm[itsindex]); - normdist[itsindex] = TMath::Sqrt(normdist0[itsindex]*normdist0[itsindex]+normdist1[itsindex]*normdist1[itsindex]); - }else{ - dist[itsindex] = trackat0.fP0; - norm[itsindex] = TMath::Sqrt(trackat0.fC00); - normdist0[itsindex] = TMath::Abs(trackat0.fP0/norm[itsindex]); - normdist1[itsindex] = TMath::Abs((trackat0.fP1-primvertex[2])/TMath::Sqrt(trackat0.fC11)); - normdist[itsindex] = TMath::Sqrt(normdist0[itsindex]*normdist0[itsindex]+normdist1[itsindex]*normdist1[itsindex]); - if (TMath::Abs(trackat0.fP3)>1.05){ - if (normdist[itsindex]<3) forbidden[itsindex]=kTRUE; - if (normdist[itsindex]>3) { - minr[itsindex] = TMath::Max(Float_t(40.),minr[itsindex]); - } - } - } - } - // - //----------------------------------------------------------- - //Forbid primary track candidates - - // - //treetr->SetAlias("forbidden0","Tr0.fN<4&&Tr1.fN+Tr1.fNDeadZone>4.5"); - //treetr->SetAlias("forbidden1","ND<3&&Tr1.fN+Tr1.fNDeadZone>5.5"); - //treetr->SetAlias("forbidden2","ND<2&&Tr1.fClIndex[0]>0&&Tr1.fClIndex[0]>0"); - //treetr->SetAlias("forbidden3","ND<1&&Tr1.fClIndex[0]>0"); - //treetr->SetAlias("forbidden4","ND<4&&Tr1.fNormChi2[0]<2"); - //treetr->SetAlias("forbidden5","ND<5&&Tr1.fNormChi2[0]<1"); - //----------------------------------------------------------- - if (bestConst){ - if (bestLong->fN<4 && bestConst->fN+bestConst->fNDeadZone>4.5) forbidden[itsindex]=kTRUE; - if (normdist[itsindex]<3 && bestConst->fN+bestConst->fNDeadZone>5.5) forbidden[itsindex]=kTRUE; - if (normdist[itsindex]<2 && bestConst->fClIndex[0]>0 && bestConst->fClIndex[1]>0 ) forbidden[itsindex]=kTRUE; - if (normdist[itsindex]<1 && bestConst->fClIndex[0]>0) forbidden[itsindex]=kTRUE; - if (normdist[itsindex]<4 && bestConst->fNormChi2[0]<2) forbidden[itsindex]=kTRUE; - if (normdist[itsindex]<5 && bestConst->fNormChi2[0]<1) forbidden[itsindex]=kTRUE; - if (bestConst->fNormChi2[0]<2.5) { - minPointAngle[itsindex]= 0.9999; - maxr[itsindex] = 10; - } - } - // - //forbid daughter kink candidates - // - if (esdtrack->GetKinkIndex(0)>0) forbidden[itsindex] = kTRUE; - Bool_t isElectron = kTRUE; - Double_t pid[5]; - esdtrack->GetESDpid(pid); - for (Int_t i=1;i<5;i++){ - if (pid[0]0 ? AliITSRecoParam::GetrInsideShield(1) : AliITSRecoParam::GetrOutsideShield(1)); + shieldindex=1; + } else if (shield.Contains("SPD")) { // SPDouter + rToGo=(dir>0 ? AliITSRecoParam::GetrInsideShield(0) : AliITSRecoParam::GetrOutsideShield(0)); + shieldindex=0; + } else { + Error("CorrectForShieldMaterial"," Wrong shield name\n"); + return 0; + } + + // do nothing if we are already beyond the shield + Double_t rTrack = TMath::Sqrt(t->GetX()*t->GetX()+t->GetY()*t->GetY()); + if(dir<0 && rTrack > rToGo) return 1; // going outward + if(dir>0 && rTrack < rToGo) return 1; // going inward + + + Double_t xToGo; + if (!t->GetLocalXat(rToGo,xToGo)) return 0; + + Int_t index=2*fCurrentEsdTrack+shieldindex; + + Double_t xOverX0,x0,lengthTimesMeanDensity; + Int_t nsteps=1; + + switch(mode) { + case 0: + xOverX0 = AliITSRecoParam::Getdshield(shieldindex); + x0 = AliITSRecoParam::GetX0shield(shieldindex); + lengthTimesMeanDensity = xOverX0*x0; + lengthTimesMeanDensity *= dir; + if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0; + break; + case 1: + nsteps= (Int_t)(TMath::Abs(t->GetX()-xToGo)/AliITSReconstructor::GetRecoParam()->GetStepSizeTGeo())+1; + if (!t->PropagateToTGeo(xToGo,nsteps)) return 0; // cross the material and apply correction + break; + case 2: + if(fxOverX0Shield[shieldindex]<0) BuildMaterialLUT("Shields"); + xOverX0 = fxOverX0Shield[shieldindex]; + lengthTimesMeanDensity = fxTimesRhoShield[shieldindex]; + lengthTimesMeanDensity *= dir; + if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0; + break; + case 3: + if(!fxOverX0ShieldTrks || index<0 || index>=2*fNtracks) Error("CorrectForShieldMaterial","Incorrect usage of UseTGeo option!\n"); + if(fxOverX0ShieldTrks[index]<0) { + if (!t->PropagateToTGeo(xToGo,1,xOverX0,lengthTimesMeanDensity)) return 0; + Double_t angle=TMath::Sqrt((1.+t->GetTgl()*t->GetTgl())/ + ((1.-t->GetSnp())*(1.+t->GetSnp()))); + fxOverX0ShieldTrks[index] = TMath::Abs(xOverX0)/angle; + fxTimesRhoShieldTrks[index] = TMath::Abs(lengthTimesMeanDensity)/angle; + return 1; } - // - // Causality cuts in TPC volume - // - if (esdtrack->GetTPCdensity(0,10) >0.6) maxr[itsindex] = TMath::Min(Float_t(110),maxr[itsindex]); - if (esdtrack->GetTPCdensity(10,30)>0.6) maxr[itsindex] = TMath::Min(Float_t(120),maxr[itsindex]); - if (esdtrack->GetTPCdensity(20,40)>0.6) maxr[itsindex] = TMath::Min(Float_t(130),maxr[itsindex]); - if (esdtrack->GetTPCdensity(30,50)>0.6) maxr[itsindex] = TMath::Min(Float_t(140),maxr[itsindex]); - // - if (esdtrack->GetTPCdensity(0,60)<0.4&&bestLong->fN<3) minr[itsindex]=100; - // - // - if (0){ - cstream<<"Track"<< - "Tr0.="<PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0; + break; + } + + return 1; +} +//------------------------------------------------------------------------ +Int_t AliITStrackerMI::CorrectForLayerMaterial(AliITStrackMI *t, + Int_t layerindex, + Double_t oldGlobXYZ[3], + TString direction) { + //------------------------------------------------------------------- + // Propagate beyond layer and correct for material + // (material budget in different ways according to fUseTGeo value) + // Add time if going outward (PropagateTo or PropagateToTGeo) + //------------------------------------------------------------------- + + // Define budget mode: + // 0: material from AliITSRecoParam (hard coded) + // 1: material from TGeo in stepsof X cm (on the fly) + // X = AliITSRecoParam::GetStepSizeTGeo() + // 2: material from lut + // 3: material from TGeo in one step (same for all hypotheses) + Int_t mode; + switch(fUseTGeo) { + case 0: + mode=0; + break; + case 1: + mode=1; + break; + case 2: + mode=2; + break; + case 3: + if(fTrackingPhase.Contains("Clusters2Tracks")) + { mode=3; } else { mode=1; } + break; + case 4: + if(fTrackingPhase.Contains("Clusters2Tracks")) + { mode=3; } else { mode=2; } + break; + default: + mode=0; + break; + } + if(fTrackingPhase.Contains("Default")) mode=0; + + Float_t dir = (direction.Contains("inward") ? 1. : -1.); + + Double_t r=fgLayers[layerindex].GetR(); + Double_t deltar=(layerindex<2 ? 0.10*r : 0.05*r); + + Double_t rToGo=TMath::Sqrt(t->GetX()*t->GetX()+t->GetY()*t->GetY())-deltar*dir; + Double_t xToGo; + if (!t->GetLocalXat(rToGo,xToGo)) return 0; + + Int_t index=6*fCurrentEsdTrack+layerindex; + + + Double_t xOverX0=0.0,x0=0.0,lengthTimesMeanDensity=0.0; + Int_t nsteps=1; + + // back before material (no correction) + Double_t rOld,xOld; + rOld=TMath::Sqrt(oldGlobXYZ[0]*oldGlobXYZ[0]+oldGlobXYZ[1]*oldGlobXYZ[1]); + if (!t->GetLocalXat(rOld,xOld)) return 0; + if (!t->Propagate(xOld)) return 0; + + switch(mode) { + case 0: + xOverX0 = fgLayers[layerindex].GetThickness(t->GetY(),t->GetZ(),x0); + lengthTimesMeanDensity = xOverX0*x0; + lengthTimesMeanDensity *= dir; + // Bring the track beyond the material + if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0; + break; + case 1: + nsteps = (Int_t)(TMath::Abs(xOld-xToGo)/AliITSReconstructor::GetRecoParam()->GetStepSizeTGeo())+1; + if (!t->PropagateToTGeo(xToGo,nsteps)) return 0; // cross the material and apply correction + break; + case 2: + if(fxOverX0Layer[layerindex]<0) BuildMaterialLUT("Layers"); + xOverX0 = fxOverX0Layer[layerindex]; + lengthTimesMeanDensity = fxTimesRhoLayer[layerindex]; + lengthTimesMeanDensity *= dir; + // Bring the track beyond the material + if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0; + break; + case 3: + if(!fxOverX0LayerTrks || index<0 || index>=6*fNtracks) Error("CorrectForLayerMaterial","Incorrect usage of UseTGeo option!\n"); + if(fxOverX0LayerTrks[index]<0) { + nsteps = (Int_t)(TMath::Abs(xOld-xToGo)/AliITSReconstructor::GetRecoParam()->GetStepSizeTGeo())+1; + if (!t->PropagateToTGeo(xToGo,nsteps,xOverX0,lengthTimesMeanDensity)) return 0; + Double_t angle=TMath::Sqrt((1.+t->GetTgl()*t->GetTgl())/ + ((1.-t->GetSnp())*(1.+t->GetSnp()))); + fxOverX0LayerTrks[index] = TMath::Abs(xOverX0)/angle; + fxTimesRhoLayerTrks[index] = TMath::Abs(lengthTimesMeanDensity)/angle; + return 1; } - trackarray.AddAt(best,itsindex); - trackarrayc.AddAt(bestConst,itsindex); - trackarrayl.AddAt(bestLong,itsindex); - new (&helixes[itsindex]) AliHelix(*best); + xOverX0 = fxOverX0LayerTrks[index]; + lengthTimesMeanDensity = fxTimesRhoLayerTrks[index]; + lengthTimesMeanDensity *= dir; + if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0; + break; } - // - // - // - // first iterration of V0 finder - // - for (Int_t iesd0=0;iesd0fP4>0) continue; - AliITStrackMI *trackc0 = (AliITStrackMI*)trackarrayc.At(itrack0); - // - for (Int_t iesd1=0;iesd1fP4<0) continue; - Bool_t isGold = kFALSE; - if (TMath::Abs(TMath::Abs(btrack0->GetLabel())-TMath::Abs(btrack1->GetLabel()))==1){ - isGold = kTRUE; - } - AliITStrackMI *trackc1 = (AliITStrackMI*)trackarrayc.At(itrack1); - AliHelix &h1 = helixes[itrack0]; - AliHelix &h2 = helixes[itrack1]; - // - // find linear distance - Double_t rmin =0; - // - // - // - Double_t phase[2][2],radius[2]; - Int_t points = h1.GetRPHIintersections(h2, phase, radius); - if (points==0) continue; - Double_t delta[2]={1000,1000}; - rmin = radius[0]; - h1.ParabolicDCA(h2,phase[0][0],phase[0][1],radius[0],delta[0]); - if (points==2){ - if (radius[1]TMath::Min(maxr[itrack0],maxr[itrack1])) continue; - Float_t maxDist = TMath::Min(kMaxDist,Float_t(kMaxDist0+radiusC*kMaxDist1)); - if (distance>maxDist) continue; - Float_t pointAngle = h1.GetPointAngle(h2,phase[iphase],primvertex); - if (pointAnglemaxDist) continue; - // if (pvertex->GetRr()GetRr()>kMaxR) continue; - AliITStrackMI * track0=btrack0; - AliITStrackMI * track1=btrack1; - // if (pvertex->GetRr()<3.5){ - if (radiusC<3.5){ - //use longest tracks inside the pipe - track0 = (AliITStrackMI*)trackarrayl.At(itrack0); - track1 = (AliITStrackMI*)trackarrayl.At(itrack1); - } - // - // - pvertex->SetM(*track0); - pvertex->SetP(*track1); - pvertex->Update(primvertex); - pvertex->SetClusters(track0->fClIndex,track1->fClIndex); // register clusters - - if (pvertex->GetRr()GetRr()>kMaxR) continue; - if (pvertex->GetPointAngle()GetDist2()>maxDist) continue; - pvertex->SetLab(0,track0->GetLabel()); - pvertex->SetLab(1,track1->GetLabel()); - pvertex->SetIndex(0,track0->fESDtrack->GetID()); - pvertex->SetIndex(1,track1->fESDtrack->GetID()); - - // - AliITStrackMI * htrackc0 = trackc0 ? trackc0:dummy; - AliITStrackMI * htrackc1 = trackc1 ? trackc1:dummy; - // - // - TObjArray * array0b = (TObjArray*)fBestHypothesys.At(itrack0); - if (!array0b&&pvertex->GetRr()<40 && TMath::Abs(track0->fP3)<1.1) - FollowProlongationTree((AliITStrackMI*)fOriginal.At(itrack0),itrack0, kFALSE); - TObjArray * array1b = (TObjArray*)fBestHypothesys.At(itrack1); - if (!array1b&&pvertex->GetRr()<40 && TMath::Abs(track1->fP3)<1.1) - FollowProlongationTree((AliITStrackMI*)fOriginal.At(itrack1),itrack1, kFALSE); - // - AliITStrackMI * track0b = (AliITStrackMI*)fOriginal.At(itrack0); - AliITStrackMI * track1b = (AliITStrackMI*)fOriginal.At(itrack1); - AliITStrackMI * track0l = (AliITStrackMI*)fOriginal.At(itrack0); - AliITStrackMI * track1l = (AliITStrackMI*)fOriginal.At(itrack1); - - Float_t minchi2before0=16; - Float_t minchi2before1=16; - Float_t minchi2after0 =16; - Float_t minchi2after1 =16; - Int_t maxLayer = GetNearestLayer(pvertex->GetXrp()); - - if (array0b) for (Int_t i=0;i<5;i++){ - // best track after vertex - AliITStrackMI * btrack = (AliITStrackMI*)array0b->At(i); - if (!btrack) continue; - if (btrack->fN>track0l->fN) track0l = btrack; - if (btrack->fXGetRr()-2) { - if (maxLayer>i+2 && btrack->fN==(6-i)&&i<2){ - Float_t sumchi2= 0; - Float_t sumn = 0; - for (Int_t ilayer=i;ilayerfClIndex[ilayer]){ - sumchi2+=25; - continue; - }else{ - sumchi2+=btrack->fDy[ilayer]*btrack->fDy[ilayer]/(btrack->fSigmaY[ilayer]*btrack->fSigmaY[ilayer]); - sumchi2+=btrack->fDz[ilayer]*btrack->fDz[ilayer]/(btrack->fSigmaZ[ilayer]*btrack->fSigmaZ[ilayer]); - } - } - sumchi2/=sumn; - if (sumchi2fNormChi2[i]; - break; - } - if (array1b) for (Int_t i=0;i<5;i++){ - // best track after vertex - AliITStrackMI * btrack = (AliITStrackMI*)array1b->At(i); - if (!btrack) continue; - if (btrack->fN>track1l->fN) track1l = btrack; - if (btrack->fXGetRr()-2){ - if (maxLayer>i+2&&btrack->fN==(6-i)&&(i<2)){ - Float_t sumchi2= 0; - Float_t sumn = 0; - for (Int_t ilayer=i;ilayerfClIndex[ilayer]){ - sumchi2+=30; - continue; - }else{ - sumchi2+=btrack->fDy[ilayer]*btrack->fDy[ilayer]/(btrack->fSigmaY[ilayer]*btrack->fSigmaY[ilayer]); - sumchi2+=btrack->fDz[ilayer]*btrack->fDz[ilayer]/(btrack->fSigmaZ[ilayer]*btrack->fSigmaZ[ilayer]); - } - } - sumchi2/=sumn; - if (sumchi2fNormChi2[i]; - break; - } - // - // position resolution - used for DCA cut - Float_t sigmad = track0b->fC00+track0b->fC11+track1b->fC00+track1b->fC11+ - (track0b->fX-pvertex->GetRr())*(track0b->fX-pvertex->GetRr())*(track0b->fC22+track0b->fC33)+ - (track1b->fX-pvertex->GetRr())*(track1b->fX-pvertex->GetRr())*(track1b->fC22+track1b->fC33); - sigmad =TMath::Sqrt(sigmad)+0.04; - if (pvertex->GetRr()>50){ - Double_t cov0[15],cov1[15]; - track0b->fESDtrack->GetInnerExternalCovariance(cov0); - track1b->fESDtrack->GetInnerExternalCovariance(cov1); - sigmad = cov0[0]+cov0[2]+cov1[0]+cov1[2]+ - (80.-pvertex->GetRr())*(80.-pvertex->GetRr())*(cov0[5]+cov0[9])+ - (80.-pvertex->GetRr())*(80.-pvertex->GetRr())*(cov1[5]+cov1[9]); - sigmad =TMath::Sqrt(sigmad)+0.05; - } - // - AliESDV0MI vertex2; - vertex2.SetM(*track0b); - vertex2.SetP(*track1b); - vertex2.Update(primvertex); - if (vertex2.GetDist2()<=pvertex->GetDist2()&&(vertex2.GetPointAngle()>=pvertex->GetPointAngle())){ - pvertex->SetM(*track0b); - pvertex->SetP(*track1b); - pvertex->Update(primvertex); - pvertex->SetClusters(track0b->fClIndex,track1b->fClIndex); // register clusters - pvertex->SetIndex(0,track0->fESDtrack->GetID()); - pvertex->SetIndex(1,track1->fESDtrack->GetID()); - } - pvertex->SetDistSigma(sigmad); - pvertex->SetDistNorm(pvertex->GetDist2()/sigmad); - // - // define likelihhod and causalities - // - Float_t pa0=1, pa1=1, pb0=0.26, pb1=0.26; - if (maxLayer<2){ - if (pvertex->GetAnglep()[2]>0.2){ - pb0 = TMath::Exp(-TMath::Min(normdist[itrack0],Float_t(16.))/12.); - pb1 = TMath::Exp(-TMath::Min(normdist[itrack1],Float_t(16.))/12.); - } - pvertex->SetChi2Before(normdist[itrack0]); - pvertex->SetChi2After(normdist[itrack1]); - pvertex->SetNAfter(0); - pvertex->SetNBefore(0); - }else{ - pvertex->SetChi2Before(minchi2before0); - pvertex->SetChi2After(minchi2before1); - if (pvertex->GetAnglep()[2]>0.2){ - pb0 = TMath::Exp(-TMath::Min(minchi2before0,Float_t(16))/12.); - pb1 = TMath::Exp(-TMath::Min(minchi2before1,Float_t(16))/12.); - } - pvertex->SetNAfter(maxLayer); - pvertex->SetNBefore(maxLayer); - } - if (pvertex->GetRr()<90){ - pa0 *= TMath::Min(track0->fESDtrack->GetTPCdensity(0,60),Float_t(1.)); - pa1 *= TMath::Min(track1->fESDtrack->GetTPCdensity(0,60),Float_t(1.)); - } - if (pvertex->GetRr()<20){ - pa0 *= (0.2+TMath::Exp(-TMath::Min(minchi2after0,Float_t(16))/8.))/1.2; - pa1 *= (0.2+TMath::Exp(-TMath::Min(minchi2after1,Float_t(16))/8.))/1.2; - } - // - pvertex->SetCausality(pb0,pb1,pa0,pa1); - // - // Likelihood calculations - apply cuts - // - Bool_t v0OK = kTRUE; - Float_t p12 = pvertex->GetParamP()->GetParameter()[4]*pvertex->GetParamP()->GetParameter()[4]; - p12 += pvertex->GetParamM()->GetParameter()[4]*pvertex->GetParamM()->GetParameter()[4]; - p12 = TMath::Sqrt(p12); // "mean" momenta - Float_t sigmap0 = 0.0001+0.001/(0.1+pvertex->GetRr()); - Float_t sigmap = 0.5*sigmap0*(0.6+0.4*p12); // "resolution: of point angle - as a function of radius and momenta - - Float_t causalityA = (1.0-pvertex->GetCausalityP()[0])*(1.0-pvertex->GetCausalityP()[1]); - Float_t causalityB = TMath::Sqrt(TMath::Min(pvertex->GetCausalityP()[2],Float_t(0.7))* - TMath::Min(pvertex->GetCausalityP()[3],Float_t(0.7))); - // - Float_t likelihood0 = (TMath::Exp(-pvertex->GetDistNorm())+0.1) *(pvertex->GetDist2()<0.5)*(pvertex->GetDistNorm()<5); - Float_t likelihood1 = TMath::Exp(-(1.0001-pvertex->GetPointAngle())/sigmap)+ - 0.4*TMath::Exp(-(1.0001-pvertex->GetPointAngle())/(4.*sigmap))+ - 0.4*TMath::Exp(-(1.0001-pvertex->GetPointAngle())/(8.*sigmap))+ - 0.1*TMath::Exp(-(1.0001-pvertex->GetPointAngle())/0.01); - // - if (causalityAGetLabel())-TMath::Abs(track1->GetLabel()))==1; - cstream<<"It0"<< - "Tr0.="<SetStatus(0); - // if (rejectBase) { - // pvertex->SetStatus(-100); - //} - if (pvertex->GetPointAngle()>kMinPointAngle2) { - pvertex->SetESDindexes(track0->fESDtrack->GetID(),track1->fESDtrack->GetID()); - if (v0OK){ - // AliV0vertex vertexjuri(*track0,*track1); - // vertexjuri.SetESDindexes(track0->fESDtrack->GetID(),track1->fESDtrack->GetID()); - // event->AddV0(&vertexjuri); - pvertex->SetStatus(100); - } - event->AddV0MI(pvertex); - } + return 1; +} +//------------------------------------------------------------------------ +void AliITStrackerMI::MakeTrksMaterialLUT(Int_t ntracks) { + //----------------------------------------------------------------- + // Initialize LUT for storing material for each prolonged track + //----------------------------------------------------------------- + fxOverX0PipeTrks = new Float_t[ntracks]; + fxTimesRhoPipeTrks = new Float_t[ntracks]; + fxOverX0ShieldTrks = new Float_t[ntracks*2]; + fxTimesRhoShieldTrks = new Float_t[ntracks*2]; + fxOverX0LayerTrks = new Float_t[ntracks*6]; + fxTimesRhoLayerTrks = new Float_t[ntracks*6]; + + for(Int_t i=0; i 0: + // return 1: the user requested to skip a layer + // return 2: track outside z acceptance of SSD/SDD and will cross both SPD + //----------------------------------------------------------------- + + if (AliITSReconstructor::GetRecoParam()->GetLayersToSkip(ilayer)) return 1; + + if (idet<0 && ilayer>1 && AliITSReconstructor::GetRecoParam()->GetExtendedEtaAcceptance()) { + // check if track will cross SPD outer layer + Double_t phiAtSPD2,zAtSPD2; + if (track->GetPhiZat(fgLayers[1].GetR(),phiAtSPD2,zAtSPD2)) { + if (TMath::Abs(zAtSPD2)<2.*AliITSRecoParam::GetSPDdetzlength()) return 2; } } - // - // - // delete temporary arrays - // - delete[] minPointAngle; - delete[] maxr; - delete[] minr; - delete[] norm; - delete[] normdist; - delete[] normdist1; - delete[] normdist0; - delete[] dist; - delete[] itsmap; - delete[] helixes; - delete pvertex; + + return 0; } +//------------------------------------------------------------------------ +Int_t AliITStrackerMI::CheckDeadZone(AliITStrackMI *track, + Int_t ilayer,Int_t idet, + Double_t dz,Double_t dy, + Bool_t noClusters) const { + //----------------------------------------------------------------- + // This method is used to decide whether to allow a prolongation + // without clusters, because there is a dead zone in the road. + // In this case the return value is > 0: + // return 1: dead zone at z=0,+-7cm in SPD + // return 2: all road is "bad" (dead or noisy) from the OCDB + // return 3: at least a chip is "bad" (dead or noisy) from the OCDB + // return 4: at least a single channel is "bad" (dead or noisy) from the OCDB + //----------------------------------------------------------------- + + // check dead zones at z=0,+-7cm in the SPD + if (ilayer<2 && !AliITSReconstructor::GetRecoParam()->GetAddVirtualClustersInDeadZone()) { + Double_t zmindead[3]={fSPDdetzcentre[0] + 0.5*AliITSRecoParam::GetSPDdetzlength(), + fSPDdetzcentre[1] + 0.5*AliITSRecoParam::GetSPDdetzlength(), + fSPDdetzcentre[2] + 0.5*AliITSRecoParam::GetSPDdetzlength()}; + Double_t zmaxdead[3]={fSPDdetzcentre[1] - 0.5*AliITSRecoParam::GetSPDdetzlength(), + fSPDdetzcentre[2] - 0.5*AliITSRecoParam::GetSPDdetzlength(), + fSPDdetzcentre[3] - 0.5*AliITSRecoParam::GetSPDdetzlength()}; + for (Int_t i=0; i<3; i++) + if (track->GetZ()-dzGetZ()+dz>zmindead[i]) { + AliDebug(2,Form("crack SPD %d",ilayer)); + return 1; + } + } + // check bad zones from OCDB + if (!AliITSReconstructor::GetRecoParam()->GetUseBadZonesFromOCDB()) return 0; -void AliITStrackerMI::RefitV02(AliESD *event) -{ - // - //try to refit V0s in the third path of the reconstruction - // - TTreeSRedirector &cstream = *fDebugStreamer; - // - Int_t nv0s = event->GetNumberOfV0MIs(); - Float_t primvertex[3]={GetX(),GetY(),GetZ()}; - AliESDV0MI v0temp; - for (Int_t iv0 = 0; iv0GetV0MI(iv0); - if (!v0mi) continue; - Int_t itrack0 = v0mi->GetIndex(0); - Int_t itrack1 = v0mi->GetIndex(1); - AliESDtrack *esd0 = event->GetTrack(itrack0); - AliESDtrack *esd1 = event->GetTrack(itrack1); - if (!esd0||!esd1) continue; - AliITStrackMI tpc0(*esd0); - AliITStrackMI tpc1(*esd1); - Double_t alpha =TMath::ATan2(v0mi->GetXr(1),v0mi->GetXr(0)); - if (v0mi->GetRr()>85){ - if (tpc0.Propagate(alpha,v0mi->GetRr())&&tpc1.Propagate(alpha,v0mi->GetRr())){ - v0temp.SetM(tpc0); - v0temp.SetP(tpc1); - v0temp.Update(primvertex); - cstream<<"Refit"<< - "V0.="<GetDist2() || v0temp.GetPointAngle()>v0mi->GetPointAngle()){ - v0mi->SetM(tpc0); - v0mi->SetP(tpc1); - v0mi->Update(primvertex); - } - } - continue; + if (idet<0) return 0; + + AliITSdetector &det=fgLayers[ilayer].GetDetector(idet); + + Int_t detType=-1; + Float_t detSizeFactorX=0.0001,detSizeFactorZ=0.0001; + if (ilayer==0 || ilayer==1) { // ---------- SPD + detType = 0; + } else if (ilayer==2 || ilayer==3) { // ---------- SDD + detType = 1; + detSizeFactorX *= 2.; + } else if (ilayer==4 || ilayer==5) { // ---------- SSD + detType = 2; + } + AliITSsegmentation *segm = (AliITSsegmentation*)fkDetTypeRec->GetSegmentationModel(detType); + if (detType==2) segm->SetLayer(ilayer+1); + Float_t detSizeX = detSizeFactorX*segm->Dx(); + Float_t detSizeZ = detSizeFactorZ*segm->Dz(); + + // check if the road overlaps with bad chips + Float_t xloc,zloc; + LocalModuleCoord(ilayer,idet,track,xloc,zloc); + Float_t zlocmin = zloc-dz; + Float_t zlocmax = zloc+dz; + Float_t xlocmin = xloc-dy; + Float_t xlocmax = xloc+dy; + Int_t chipsInRoad[100]; + + // check if road goes out of detector + Bool_t touchNeighbourDet=kFALSE; + if (TMath::Abs(xlocmin)>0.5*detSizeX) {xlocmin=-0.5*detSizeX; touchNeighbourDet=kTRUE;} + if (TMath::Abs(xlocmax)>0.5*detSizeX) {xlocmax=+0.5*detSizeX; touchNeighbourDet=kTRUE;} + if (TMath::Abs(zlocmin)>0.5*detSizeZ) {zlocmin=-0.5*detSizeZ; touchNeighbourDet=kTRUE;} + if (TMath::Abs(zlocmax)>0.5*detSizeZ) {zlocmax=+0.5*detSizeZ; touchNeighbourDet=kTRUE;} + AliDebug(2,Form("layer %d det %d zmim zmax %f %f xmin xmax %f %f %f %f",ilayer,idet,zlocmin,zlocmax,xlocmin,xlocmax,detSizeZ,detSizeX)); + + // check if this detector is bad + if (det.IsBad()) { + AliDebug(2,Form("lay %d bad detector %d",ilayer,idet)); + if(!touchNeighbourDet) { + return 2; // all detectors in road are bad + } else { + return 3; // at least one is bad } - if (v0mi->GetRr()>35){ - CorrectForDeadZoneMaterial(&tpc0); - CorrectForDeadZoneMaterial(&tpc1); - if (tpc0.Propagate(alpha,v0mi->GetRr())&&tpc1.Propagate(alpha,v0mi->GetRr())){ - v0temp.SetM(tpc0); - v0temp.SetP(tpc1); - v0temp.Update(primvertex); - cstream<<"Refit"<< - "V0.="<GetDist2() || v0temp.GetPointAngle()>v0mi->GetPointAngle()){ - v0mi->SetM(tpc0); - v0mi->SetP(tpc1); - v0mi->Update(primvertex); - } - } - continue; + } + + Int_t nChipsInRoad = segm->GetChipsInLocalWindow(chipsInRoad,zlocmin,zlocmax,xlocmin,xlocmax); + AliDebug(2,Form("lay %d nChipsInRoad %d",ilayer,nChipsInRoad)); + if (!nChipsInRoad) return 0; + + Bool_t anyBad=kFALSE,anyGood=kFALSE; + for (Int_t iCh=0; iChdet.GetNChips()-1) continue; + AliDebug(2,Form(" chip %d bad %d",chipsInRoad[iCh],(Int_t)det.IsChipBad(chipsInRoad[iCh]))); + if (det.IsChipBad(chipsInRoad[iCh])) { + anyBad=kTRUE; + } else { + anyGood=kTRUE; + } + } + + if (!anyGood) { + if(!touchNeighbourDet) { + AliDebug(2,"all bad in road"); + return 2; // all chips in road are bad + } else { + return 3; // at least a bad chip in road } - CorrectForDeadZoneMaterial(&tpc0); - CorrectForDeadZoneMaterial(&tpc1); - // if (tpc0.Propagate(alpha,v0mi->GetRr())&&tpc1.Propagate(alpha,v0mi->GetRr())){ - if (RefitAt(v0mi->GetRr(),&tpc0, v0mi->GetClusters(0)) && RefitAt(v0mi->GetRr(),&tpc1, v0mi->GetClusters(1))){ - v0temp.SetM(tpc0); - v0temp.SetP(tpc1); - v0temp.Update(primvertex); - cstream<<"Refit"<< - "V0.="<GetDist2() || v0temp.GetPointAngle()>v0mi->GetPointAngle()){ - v0mi->SetM(tpc0); - v0mi->SetP(tpc1); - v0mi->Update(primvertex); - } - } } + + if (anyBad) { + AliDebug(2,"at least a bad in road"); + return 3; // at least a bad chip in road + } + + + if (!AliITSReconstructor::GetRecoParam()->GetUseSingleBadChannelsFromOCDB() + || !noClusters) return 0; + + // There are no clusters in road: check if there is at least + // a bad SPD pixel or SDD anode or SSD strips on both sides + + Int_t idetInITS=idet; + for(Int_t l=0;lAnyBadInRoad(idetInITS,zlocmin,zlocmax,xlocmin,xlocmax)) { + AliDebug(2,Form("Bad channel in det %d of layer %d\n",idet,ilayer)); + return 4; + } + //if (fITSChannelStatus->FractionOfBadInRoad(idet,zlocmin,zlocmax,xlocmin,xlocmax) > AliITSReconstructor::GetRecoParam()->GetMinFractionOfBadInRoad()) return 3; + + return 0; } +//------------------------------------------------------------------------ +Bool_t AliITStrackerMI::LocalModuleCoord(Int_t ilayer,Int_t idet, + const AliITStrackMI *track, + Float_t &xloc,Float_t &zloc) const { + //----------------------------------------------------------------- + // Gives position of track in local module ref. frame + //----------------------------------------------------------------- + + xloc=0.; + zloc=0.; + if(idet<0) return kFALSE; + Int_t ndet=AliITSgeomTGeo::GetNDetectors(ilayer+1); // layers from 1 to 6 + Int_t lad = Int_t(idet/ndet) + 1; + Int_t det = idet - (lad-1)*ndet + 1; + Double_t xyzGlob[3],xyzLoc[3]; + AliITSdetector &detector = fgLayers[ilayer].GetDetector(idet); + // take into account the misalignment: xyz at real detector plane + if(!track->GetXYZAt(detector.GetRmisal(),GetBz(),xyzGlob)) return kFALSE; + if(!AliITSgeomTGeo::GlobalToLocal(ilayer+1,lad,det,xyzGlob,xyzLoc)) return kFALSE; + + xloc = (Float_t)xyzLoc[0]; + zloc = (Float_t)xyzLoc[2]; + + return kTRUE; +} +//------------------------------------------------------------------------ +Bool_t AliITStrackerMI::IsOKForPlaneEff(const AliITStrackMI* track, const Int_t *clusters, Int_t ilayer) const { +// +// Method to be optimized further: +// Aim: decide whether a track can be used for PlaneEff evaluation +// the decision is taken based on the track quality at the layer under study +// no information on the clusters on this layer has to be used +// The criterium is to reject tracks at boundaries between basic block (e.g. SPD chip) +// the cut is done on number of sigmas from the boundaries +// +// Input: Actual track, layer [0,5] under study +// Output: none +// Return: kTRUE if this is a good track +// +// it will apply a pre-selection to obtain good quality tracks. +// Here also you will have the possibility to put a control on the +// impact point of the track on the basic block, in order to exclude border regions +// this will be done by calling a proper method of the AliITSPlaneEff class. +// +// input: AliITStrackMI* track, ilayer= layer number [0,5] +// return: Bool_t -> kTRUE if usable track, kFALSE if not usable. +// + Int_t index[AliITSgeomTGeo::kNLayers]; + Int_t k; + for (k=0; kilayer;lay--) { + AliDebug(2,Form("trak=%d lay=%d ; index=%d ESD label= %d",tmp.GetLabel(),lay, + tmp.GetClIndex(lay),((AliESDtrack*)tmp.GetESDtrack())->GetLabel())) ; + if (tmp.GetClIndex(lay)>=0) ncl++; + } + Bool_t nextout = kFALSE; + if(ilayer==AliITSgeomTGeo::kNLayers-1) nextout=kTRUE; // you are already on the outermost layer + else nextout = ((tmp.GetClIndex(ilayer+1)>=0)? kTRUE : kFALSE ); + Bool_t nextin = kFALSE; + if(ilayer==0) nextin=kTRUE; // you are already on the innermost layer + else nextin = ((index[ilayer-1]>=0)? kTRUE : kFALSE ); + if(nclGetMaxMissingClustersPlaneEff()) + return kFALSE; + if(AliITSReconstructor::GetRecoParam()->GetRequireClusterInOuterLayerPlaneEff() && !nextout) return kFALSE; + if(AliITSReconstructor::GetRecoParam()->GetRequireClusterInInnerLayerPlaneEff() && !nextin) return kFALSE; + if(tmp.Pt() < AliITSReconstructor::GetRecoParam()->GetMinPtPlaneEff()) return kFALSE; + // if(AliITSReconstructor::GetRecoParam()->GetOnlyConstraintPlaneEff() && !tmp.GetConstrain()) return kFALSE; + +// detector number + Double_t phi,z; + if (!tmp.GetPhiZat(r,phi,z)) return kFALSE; + Int_t idet=layer.FindDetectorIndex(phi,z); + if(idet<0) { AliInfo(Form("cannot find detector")); + return kFALSE;} + + // here check if it has good Chi Square. + + //propagate to the intersection with the detector plane + const AliITSdetector &det=layer.GetDetector(idet); + if (!tmp.Propagate(det.GetPhi(),det.GetR())) return kFALSE; + + Float_t locx; // + Float_t locz; // + if(!LocalModuleCoord(ilayer,idet,&tmp,locx,locz)) return kFALSE; + UInt_t key=fPlaneEff->GetKeyFromDetLocCoord(ilayer,idet,locx,locz); + if(key>fPlaneEff->Nblock()) return kFALSE; + Float_t blockXmn,blockXmx,blockZmn,blockZmx; + if (!fPlaneEff->GetBlockBoundaries(key,blockXmn,blockXmx,blockZmn,blockZmx)) return kFALSE; + //*************** + // DEFINITION OF SEARCH ROAD FOR accepting a track + // + //For the time being they are hard-wired, later on from AliITSRecoParam + // Double_t nsigx=AliITSRecoParam::GetNSigXFarFromBoundary(); + // Double_t nsigz=AliITSRecoParam::GetNSigZFarFromBoundary(); + Double_t nsigz=4; + Double_t nsigx=4; + Double_t dx=nsigx*TMath::Sqrt(tmp.GetSigmaY2()); // those are precisions in the tracking reference system + Double_t dz=nsigz*TMath::Sqrt(tmp.GetSigmaZ2()); // Use it also for the module reference system, as it is + // done for RecPoints + + // exclude tracks at boundary between detectors + //Double_t boundaryWidth=AliITSRecoParam::GetBoundaryWidthPlaneEff(); + Double_t boundaryWidth=0; // for the time being hard-wired, later on from AliITSRecoParam + AliDebug(2,Form("Tracking: track impact x=%f, y=%f, z=%f",tmp.GetX(), tmp.GetY(), tmp.GetZ())); + AliDebug(2,Form("Local: track impact x=%f, z=%f",locx,locz)); + AliDebug(2,Form("Search Road. Tracking: dy=%f , dz=%f",dx,dz)); + + if ( (locx-dx < blockXmn+boundaryWidth) || + (locx+dx > blockXmx-boundaryWidth) || + (locz-dz < blockZmn+boundaryWidth) || + (locz+dz > blockZmx-boundaryWidth) ) return kFALSE; + return kTRUE; +} +//------------------------------------------------------------------------ +void AliITStrackerMI::UseTrackForPlaneEff(const AliITStrackMI* track, Int_t ilayer) { +// +// This Method has to be optimized! For the time-being it uses the same criteria +// as those used in the search of extra clusters for overlapping modules. +// +// Method Purpose: estabilish whether a track has produced a recpoint or not +// in the layer under study (For Plane efficiency) +// +// inputs: AliITStrackMI* track (pointer to a usable track) +// outputs: none +// side effects: update (by 1 count) the Plane Efficiency statistics of the basic block +// traversed by this very track. In details: +// - if a cluster can be associated to the track then call +// AliITSPlaneEff::UpDatePlaneEff(key,kTRUE); +// - if not, the AliITSPlaneEff::UpDatePlaneEff(key,kFALSE) is called +// + if(!fPlaneEff) + {AliWarning("UseTrackForPlaneEff: null pointer to AliITSPlaneEff"); return;} + AliITSlayer &layer=fgLayers[ilayer]; + Double_t r=layer.GetR(); + AliITStrackMI tmp(*track); + +// detector number + Double_t phi,z; + if (!tmp.GetPhiZat(r,phi,z)) return; + Int_t idet=layer.FindDetectorIndex(phi,z); + + if(idet<0) { AliInfo(Form("cannot find detector")); + return;} + + +//propagate to the intersection with the detector plane + const AliITSdetector &det=layer.GetDetector(idet); + if (!tmp.Propagate(det.GetPhi(),det.GetR())) return; + + +//*************** +// DEFINITION OF SEARCH ROAD FOR CLUSTERS SELECTION +// + Double_t dz=AliITSReconstructor::GetRecoParam()->GetNSigmaRoadZ()* + TMath::Sqrt(tmp.GetSigmaZ2() + + AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()* + AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()* + AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer)); + Double_t dy=AliITSReconstructor::GetRecoParam()->GetNSigmaRoadY()* + TMath::Sqrt(tmp.GetSigmaY2() + + AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()* + AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()* + AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilayer)); + +// road in global (rphi,z) [i.e. in tracking ref. system] + Double_t zmin = tmp.GetZ() - dz; + Double_t zmax = tmp.GetZ() + dz; + Double_t ymin = tmp.GetY() + r*det.GetPhi() - dy; + Double_t ymax = tmp.GetY() + r*det.GetPhi() + dy; + +// select clusters in road + layer.SelectClusters(zmin,zmax,ymin,ymax); + +// Define criteria for track-cluster association + Double_t msz = tmp.GetSigmaZ2() + + AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()* + AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()* + AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer); + Double_t msy = tmp.GetSigmaY2() + + AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()* + AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()* + AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilayer); + if (tmp.GetConstrain()) { + msz *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadZC(); + msy *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadYC(); + } else { + msz *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadZNonC(); + msy *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadYNonC(); + } + msz = 1./msz; // 1/RoadZ^2 + msy = 1./msy; // 1/RoadY^2 +// + + const AliITSRecPoint *cl=0; Int_t clidx=-1, ci=-1; + Int_t idetc=-1; + Double_t chi2trkcl=1000.*AliITSReconstructor::GetRecoParam()->GetMaxChi2(); + //Double_t tolerance=0.2; + /*while ((cl=layer.GetNextCluster(clidx))!=0) { + idetc = cl->GetDetectorIndex(); + if(idet!=idetc) continue; + //Int_t ilay = cl->GetLayer(); + + if (TMath::Abs(tmp.GetZ() - cl->GetZ()) > tolerance) continue; + if (TMath::Abs(tmp.GetY() - cl->GetY()) > tolerance) continue; + + Double_t chi2=tmp.GetPredictedChi2(cl); + if (chi2GetKeyFromDetLocCoord(ilayer,idet,locx,locz); + if(key>fPlaneEff->Nblock()) return; + Bool_t found=kFALSE; + //if (ci>=0) { + Double_t chi2; + while ((cl=layer.GetNextCluster(clidx))!=0) { + idetc = cl->GetDetectorIndex(); + if(idet!=idetc) continue; + // here real control to see whether the cluster can be associated to the track. + // cluster not associated to track + if ( (tmp.GetZ()-cl->GetZ())*(tmp.GetZ()-cl->GetZ())*msz + + (tmp.GetY()-cl->GetY())*(tmp.GetY()-cl->GetY())*msy > 1. ) continue; + // calculate track-clusters chi2 + chi2 = GetPredictedChi2MI(&tmp,cl,ilayer); // note that this method change track tmp + // in particular, the error associated to the cluster + //Double_t chi2 = tmp.GetPredictedChi(cl); // this method does not change track tmp + // chi2 cut + if (chi2 > AliITSReconstructor::GetRecoParam()->GetMaxChi2s(ilayer)) continue; + found=kTRUE; + if (chi2SetExtraCluster(ilayer,(ilayer<<28)+ci); + // track->SetExtraModule(ilayer,idetExtra); + } + if(!fPlaneEff->UpDatePlaneEff(found,key)) + AliWarning(Form("UseTrackForPlaneEff: cannot UpDate PlaneEff for key=%d",key)); + if(fPlaneEff->GetCreateHistos()&& AliITSReconstructor::GetRecoParam()->GetHistoPlaneEff()) { + Float_t tr[4]={99999.,99999.,9999.,9999.}; // initialize to high values + Float_t clu[4]={-99999.,-99999.,9999.,9999.}; // (in some cases GetCov fails) + Int_t cltype[2]={-999,-999}; + + tr[0]=locx; + tr[1]=locz; + tr[2]=TMath::Sqrt(tmp.GetSigmaY2()); // those are precisions in the tracking reference system + tr[3]=TMath::Sqrt(tmp.GetSigmaZ2()); // Use it also for the module reference system, as it is + + if (found){ + clu[0]=layer.GetCluster(ci)->GetDetLocalX(); + clu[1]=layer.GetCluster(ci)->GetDetLocalZ(); + cltype[0]=layer.GetCluster(ci)->GetNy(); + cltype[1]=layer.GetCluster(ci)->GetNz(); + + // Without the following 6 lines you would retrieve the nominal error of a cluster (e.g. for the SPD: + // X->50/sqrt(12)=14 micron Z->450/sqrt(12)= 120 micron) + // Within AliTrackerMI/AliTrackMI the error on the cluster is associated to the AliITStrackMI (fSigmaY,Z) + // It is computed properly by calling the method + // AliITStrackerMI::GetPredictedChi2MI(AliITStrackMI* track, const AliITSRecPoint *cluster,Int_t layer) + // T + //Double_t x=0.5*(tmp.GetX()+layer.GetCluster(ci)->GetX()); // Take into account the mis-alignment + //if (tmp.PropagateTo(x,0.,0.)) { + chi2=GetPredictedChi2MI(&tmp,layer.GetCluster(ci),ilayer); + AliCluster c(*layer.GetCluster(ci)); + c.SetSigmaY2(tmp.GetSigmaY(ilayer)*tmp.GetSigmaY(ilayer)); + c.SetSigmaZ2(tmp.GetSigmaZ(ilayer)*tmp.GetSigmaZ(ilayer)); + //if (layer.GetCluster(ci)->GetGlobalCov(cov)) // by using this, instead, you got nominal cluster errors + clu[2]=TMath::Sqrt(c.GetSigmaY2()); + clu[3]=TMath::Sqrt(c.GetSigmaZ2()); + //} + } + fPlaneEff->FillHistos(key,found,tr,clu,cltype); + } +return; +}