#include "AliITSUTrackHyp.h"
+#include "AliESDtrack.h"
+#include "AliCluster.h"
ClassImp(AliITSUTrackHyp)
//__________________________________________________________________
AliITSUTrackHyp::AliITSUTrackHyp(Int_t nlr)
: fNLayers(nlr)
- ,fESDSeed(0)
+ ,fESDTrack(0)
,fLayerSeeds(0)
{
// def. c-tor
//__________________________________________________________________
AliITSUTrackHyp::AliITSUTrackHyp(const AliITSUTrackHyp &src)
- : TObject(src)
+ : AliKalmanTrack(src)
, fNLayers(src.fNLayers)
- , fESDSeed(src.fESDSeed)
+ , fESDTrack(src.fESDTrack)
, fLayerSeeds(0)
{
// copy c-tor
printf("Track Hyp.#%4d. NSeeds:",GetUniqueID());
for (int i=0;i<fNLayers;i++) printf(" (%d) %3d",i,GetNSeeds(i)); printf("\n");
}
+
+//__________________________________________________________________
+AliITSUSeed* AliITSUTrackHyp::GetWinner() const
+{
+ // Get best candidate
+ return fLayerSeeds[0].GetEntriesFast()>0 ? GetSeed(0,0) : 0;
+}
+
+//__________________________________________________________________
+void AliITSUTrackHyp::DefineWinner(int lr, int id)
+{
+ // assign best candidate
+ AliITSUSeed* winner = GetSeed(lr,id);
+ this->AliExternalTrackParam::operator=(*winner);
+ SetChi2(winner->GetChi2GloNrm());
+ SetNumberOfClusters(winner->GetNLayersHit());
+}
+
+//__________________________________________________________________
+void AliITSUTrackHyp::UpdateESD()
+{
+ // update ESD track
+ AliESDtrack* esdTr = GetESDTrack();
+ if (!esdTr) return;
+ AliITSUSeed* win = GetWinner();
+ if (!win) return;
+ esdTr->UpdateTrackParams(this,AliESDtrack::kITSin);
+}
+
+
+
+//__________________________________________________________________
+Double_t AliITSUTrackHyp::GetPredictedChi2(const AliCluster */*c*/) const
+{
+ // NA
+ AliFatal("Not to be used");
+ return 0;
+}
+
+//__________________________________________________________________
+Bool_t AliITSUTrackHyp::PropagateTo(Double_t /*xr*/, Double_t /*x0*/, Double_t /*rho*/)
+{
+ // NA
+ AliFatal("Not to be used");
+ return 0;
+}
+
+//__________________________________________________________________
+Bool_t AliITSUTrackHyp::Update(const AliCluster* /*c*/, Double_t /*chi2*/, Int_t /*index*/)
+{
+ // NA
+ AliFatal("Not to be used");
+ return kFALSE;
+}
#include <TObject.h>
#include <TObjArray.h>
+#include "AliKalmanTrack.h"
#include "AliITSUSeed.h"
-
+class AliESDtrack;
+class AliCluster;
// Container for track hypotheses
-class AliITSUTrackHyp: public TObject
+class AliITSUTrackHyp: public AliKalmanTrack
{
public:
AliITSUTrackHyp(Int_t nlr=0);
virtual ~AliITSUTrackHyp();
//
Int_t GetNLayers() const {return fNLayers;}
- Int_t GetNSeeds(Int_t lr) const {return lr<fNLayers ? fLayerSeeds[lr].GetEntriesFast() : 1;}
- AliITSUSeed* GetSeed(Int_t lr, Int_t id) const;
- AliITSUSeed* GetESDSeed() const {return fESDSeed;}
+ Int_t GetNSeeds(Int_t lr) const {return fLayerSeeds[lr].GetEntriesFast();}
+ AliITSUSeed* GetSeed(Int_t lr, Int_t id) const {return (AliITSUSeed*)fLayerSeeds[lr].UncheckedAt(id);}
+ AliITSUSeed* GetWinner() const;
+ AliESDtrack* GetESDTrack() const {return fESDTrack;}
+ void DefineWinner(Int_t lr, Int_t id);
const TObjArray* GetLayerSeeds(Int_t lr) const {return lr<fNLayers ? &fLayerSeeds[lr] : 0;}
- void AddSeed(AliITSUSeed* seed, Int_t lr);
- void SetESDSeed(AliITSUSeed* seed) {fESDSeed = seed;}
+ void AddSeed(AliITSUSeed* seed, Int_t lr) {fLayerSeeds[lr].AddLast(seed);}
+ void SetESDTrack(AliESDtrack* esdtr) {fESDTrack = esdtr;}
+ void UpdateESD();
+ //
+ void SetChi2(Double_t chi2) {fChi2 = chi2;}
//
-
+ virtual Double_t GetPredictedChi2(const AliCluster *c) const;
+ virtual Bool_t PropagateTo(Double_t xr, Double_t x0, Double_t rho);
+ virtual Bool_t Update(const AliCluster* c, Double_t chi2, Int_t index);
+ virtual Int_t GetClusterIndex(Int_t) const { return -1;}
+ virtual Int_t GetNumberOfTracklets() const { return 0;}
+ virtual Int_t GetTrackletIndex(Int_t) const { return -1;}
+ virtual Double_t GetPIDsignal() const { return 0;}
//
virtual void Print(Option_t* option = "") const;
//
protected:
UChar_t fNLayers; // number of layers
- AliITSUSeed* fESDSeed; // bare esd (TPC) seed
+ AliESDtrack* fESDTrack; // reference esd track
TObjArray* fLayerSeeds; // seeds of given layer
//
ClassDef(AliITSUTrackHyp,1)
};
-//___________________________________________________________________
-inline AliITSUSeed* AliITSUTrackHyp::GetSeed(Int_t lr, Int_t id) const
-{
- //return requested seed of given layer, no check is done on seed index
- return lr<fNLayers ? (AliITSUSeed*)fLayerSeeds[lr].UncheckedAt(id) : fESDSeed;
-}
-
-//___________________________________________________________________
-inline void AliITSUTrackHyp::AddSeed(AliITSUSeed* seed, Int_t lr)
-{
- //return requested seed of given layer, no check is done
- if (lr<fNLayers) fLayerSeeds[lr].AddLast(seed);
- else fESDSeed = seed;
-}
#endif
//
printf("Hypotheses for current event (N seeds in pool: %d, size: %d)\n",fSeedsPool.GetEntriesFast(),fSeedsPool.GetSize());
fHypStore.Print();
+ FinalizeHypotheses();
//
return 0;
}
{
// find prolongaion candidates finding for single seed
//
+ AliITSUSeed seedUC; // copy of the seed from the upper layer
+ AliITSUSeed seedT; // transient seed between the seedUC and new prolongation hypothesis
+ //
if (!NeedToProlong(esdTr)) return; // are we interested in this track?
- if (!InitSeed(esdTr,esdID)) return; // initialize prolongations hypotheses tree
+ if (!InitHypothesis(esdTr,esdID)) return; // initialize prolongations hypotheses tree
//
AliITSURecoSens *hitSens[AliITSURecoSens::kNNeighbors+1];
- AliITSUSeed seedUC; // copy of the seed from the upper layer
- AliITSUSeed seedT; // transient seed between the seedUC and new prolongation hypothesis
//
TObjArray clArr; // container for transfer of clusters matching to seed
//
- for (int ila=fITS->GetNLayersActive();ila--;) {
+ int nLrActive = fITS->GetNLayersActive();
+ for (int ila=nLrActive;ila--;) {
int ilaUp = ila+1; // prolong seeds from layer above
- int nSeedsUp = fCurrHyp->GetNSeeds(ilaUp);
+ //
+ // for the outermost layer the seed is created from the ESD track
+ int nSeedsUp = (ilaUp==nLrActive) ? 1 : fCurrHyp->GetNSeeds(ilaUp);
+ //
for (int isd=0;isd<nSeedsUp;isd++) {
- AliITSUSeed* seedU = fCurrHyp->GetSeed(ilaUp,isd); // seed on prev.active layer to prolong
- seedUC = *seedU; // its copy will be prolonged
- seedUC.SetParent(seedU);
+ AliITSUSeed* seedU;
+ if (ilaUp==nLrActive) {
+ seedU = 0;
+ seedUC.InitFromESDTrack(esdTr);
+ }
+ else {
+ seedU = fCurrHyp->GetSeed(ilaUp,isd); // seed on prev.active layer to prolong
+ seedUC = *seedU; // its copy will be prolonged
+ seedUC.SetParent(seedU);
+ }
seedUC.ResetFMatrix(); // reset the matrix for propagation to next layer
// go till next active layer
AliInfo(Form("working on Lr:%d Seed:%d of %d",ila,isd,nSeedsUp));
//
AliInfo("Transport failed");
// Check if the seed satisfies to track definition
- if (NeedToKill(&seedUC,kTransportFailed)) seedU->Kill();
+ if (NeedToKill(&seedUC,kTransportFailed) && seedU) seedU->Kill();
continue; // RS TODO: decide what to do with tracks stopped on higher layers w/o killing
}
AliITSURecoLayer* lrA = fITS->GetLayerActive(ila);
if (!GetRoadWidth(&seedUC, ila)) { // failed to find road width on the layer
- if (NeedToKill(&seedUC,kRWCheckFailed)) seedU->Kill();
+ if (NeedToKill(&seedUC,kRWCheckFailed) && seedU) seedU->Kill();
continue;
}
int nsens = lrA->FindSensors(&fTrImpData[kTrPhi0], hitSens); // find detectors which may be hit by the track
}
//_________________________________________________________________________
-Bool_t AliITSUTrackerGlo::InitSeed(AliESDtrack *esdTr, Int_t esdID)
+Bool_t AliITSUTrackerGlo::InitHypothesis(AliESDtrack *esdTr, Int_t esdID)
{
// init prolongaion candidates finding for single seed
fCurrHyp = GetTrackHyp(esdID);
fCurrESDtrack = esdTr;
if (fCurrMass<kPionMass*0.9) fCurrMass = kPionMass; // don't trust to mu, e identification from TPCin
//
- AliITSUSeed* seed = NewSeedFromPool();
- seed->SetLr(fITS->GetNLayersActive()); // fake layer
- seed->AliExternalTrackParam::operator=(*esdTr);
- seed->SetParent(esdTr);
- int nl = fITS->GetNLayersActive();
- fCurrHyp = new AliITSUTrackHyp(nl);
- fCurrHyp->SetESDSeed(seed);
- AddProlongationHypothesis(seed,nl);
+ fCurrHyp = new AliITSUTrackHyp(fITS->GetNLayersActive());
+ fCurrHyp->SetESDTrack(esdTr);
fCurrHyp->SetUniqueID(esdID);
SetTrackHyp(fCurrHyp,esdID);
+ //
return kTRUE;
// TO DO
}
//
}
+//_________________________________________________________________________
+Bool_t AliITSUTrackerGlo::TransportToLayer(AliExternalTrackParam* seed, Int_t lFrom, Int_t lTo)
+{
+ // transport track from layerFrom to the entrance of layerTo
+ //
+ const double kToler = 1e-6; // tolerance for layer on-surface check
+ //
+ int dir = lTo > lFrom ? 1:-1;
+ AliITSURecoLayer* lrFr = fITS->GetLayer(lFrom); // this can be 0 when extrapolation from TPC to ITS is requested
+ Bool_t checkFirst = kTRUE;
+ while(lFrom!=lTo) {
+ double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius
+ if (lrFr) {
+ Bool_t doLayer = kTRUE;
+ double xToGo = dir>0 ? lrFr->GetRMax() : lrFr->GetRMin();
+ if (checkFirst) { // do we need to track till the surface of the current layer ?
+ checkFirst = kFALSE;
+ if (dir>0) { if (curR2-xToGo*xToGo>kToler) doLayer = kFALSE; } // on the surface or outside of the layer
+ else if (dir<0) { if (xToGo*xToGo-curR2>kToler) doLayer = kFALSE; } // on the surface or outside of the layer
+ }
+ if (doLayer) {
+ if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE;
+ // go via layer to its boundary, applying material correction.
+ if (!PropagateSeed(seed,xToGo,fCurrMass, lrFr->GetMaxStep())) return kFALSE;
+ }
+ }
+ AliITSURecoLayer* lrTo = fITS->GetLayer( (lFrom+=dir) );
+ if (!lrTo) AliFatal(Form("Layer %d does not exist",lFrom));
+ //
+ // go the entrance of the layer, assuming no materials in between
+ double xToGo = dir>0 ? lrTo->GetRMin() : lrTo->GetRMax();
+ if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE;
+ if (!PropagateSeed(seed,xToGo,fCurrMass,100, kFALSE )) return kFALSE;
+ lrFr = lrTo;
+ }
+ return kTRUE;
+ //
+}
+
//_________________________________________________________________________
Bool_t AliITSUTrackerGlo::GetRoadWidth(AliITSUSeed* seed, int ilrA)
{
return kTRUE;
}
+//______________________________________________________________________________
+Bool_t AliITSUTrackerGlo::PropagateSeed(AliExternalTrackParam *seed, Double_t xToGo, Double_t mass, Double_t maxStep, Bool_t matCorr)
+{
+ // propagate seed to given x applying material correction if requested
+ const Double_t kEpsilon = 1e-5;
+ Double_t xpos = seed->GetX();
+ Int_t dir = (xpos<xToGo) ? 1:-1;
+ Double_t xyz0[3],xyz1[3],param[7];
+ //
+ Bool_t updTime = dir>0 && seed->IsStartedTimeIntegral();
+ if (matCorr || updTime) seed->GetXYZ(xyz1); //starting global position
+ while ( (xToGo-xpos)*dir > kEpsilon){
+ Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep);
+ Double_t x = xpos+step;
+ Double_t bz=GetBz(); // getting the local Bz
+ if (!seed->PropagateTo(x,bz)) return kFALSE;
+ double ds = 0;
+ if (matCorr || updTime) {
+ xyz0[0]=xyz1[0]; // global pos at the beginning of step
+ xyz0[1]=xyz1[1];
+ xyz0[2]=xyz1[2];
+ seed->GetXYZ(xyz1); // // global pos at the end of step
+ //
+ if (matCorr) {
+ MeanMaterialBudget(xyz0,xyz1,param);
+ Double_t xrho=param[0]*param[4], xx0=param[1];
+ if (dir>0) xrho = -xrho; // outward should be negative
+ if (!seed->CorrectForMeanMaterial(xx0,xrho,mass)) return kFALSE;
+ ds = param[4];
+ }
+ else { // matCorr is not requested but time integral is
+ double d0 = xyz1[0]-xyz0[0];
+ double d1 = xyz1[1]-xyz0[1];
+ double d2 = xyz1[2]-xyz0[2];
+ ds = TMath::Sqrt(d0*d0+d1*d1+d2*d2);
+ }
+ }
+ if (updTime) seed->AddTimeStep(ds);
+ //
+ xpos = seed->GetX();
+ }
+ return kTRUE;
+}
+
//______________________________________________________________________________
void AliITSUTrackerGlo::SaveCurrentTrackHypotheses()
{
// TODO
}
+
+//______________________________________________________________________________
+void AliITSUTrackerGlo::FinalizeHypotheses()
+{
+ // select winner for each hypothesis, remove cl. sharing conflicts
+ AliInfo("TODO");
+ //
+ int nh = fHypStore.GetEntriesFast();
+ for (int ih=0;ih<nh;ih++) {
+ AliITSUTrackHyp* hyp = (AliITSUTrackHyp*) fHypStore.UncheckedAt(ih);
+ if (!hyp) continue;
+ hyp->UpdateESD();
+ }
+
+}