-
-void AliITStrackerV2::SortTrackHypothesys(Int_t esdindex, Float_t likelihoodlevel)
-{
- //-------------------------------------------------------------------
- // compress array of track hypothesys
- // keep only maxsize best hypothesys
- //-------------------------------------------------------------------
- if (esdindex>fTrackHypothesys.GetEntriesFast()) return;
- if (! (fTrackHypothesys.At(esdindex)) ) return;
- TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex);
- Int_t entries = array->GetEntriesFast();
-
- Float_t * chi2 = new Float_t[entries];
- Float_t * probability = new Float_t[entries];
- Float_t sumprobabilityall=0;
- Int_t * index = new Int_t[entries];
- //
- //
- for (Int_t itrack=0;itrack<array->GetEntriesFast();itrack++){
- AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
- //
- if (track && track->GetNumberOfClusters()>(track->GetNUsed()+track->GetNSkipped())){
- //
- chi2[itrack] = track->GetChi2()/(track->GetNumberOfClusters()-track->GetNUsed()-track->GetNSkipped());
- if (track->GetESDtrack())
- if (track->GetESDtrack()->GetTPCsignal()>80){
- track->CookdEdx();
- if ((track->GetdEdx()/track->GetESDtrack()->GetTPCsignal())<0.4){
- Float_t factor = 2.+10.*(0.6-track->GetdEdx()/track->GetESDtrack()->GetTPCsignal());
- chi2[itrack]*= factor; //mismatch in dEdx
- }
- }
- }
- else
- chi2[itrack] = 10000000.;
- probability[itrack] = 1./(0.3+chi2[itrack]);
- sumprobabilityall+=probability[itrack];
- }
-
- TMath::Sort(entries,chi2,index,kFALSE);
- TObjArray * newarray = new TObjArray();
- Float_t sumprobability = 0.;
- for (Int_t i=0;i<entries;i++){
- AliITStrackV2 * track = (AliITStrackV2*)array->At(index[i]);
- if (!track) break;
- if (chi2[index[i]]<30){
- newarray->AddLast(array->RemoveAt(index[i]));
- track->SetChi2MIP(0,chi2[index[i]]); // base chi 2
- sumprobability+= probability[index[i]]/sumprobabilityall;
- if (sumprobability> likelihoodlevel) break;
- }
- else{
- delete array->RemoveAt(index[i]);
- }
- }
-
- array->Delete();
- delete fTrackHypothesys.RemoveAt(esdindex);
- fTrackHypothesys.AddAt(newarray,esdindex);
-
- delete [] chi2;
- delete [] index;
-
-}
-
-
-void AliITStrackerV2::CompressTrackHypothesys(Int_t esdindex, Float_t likelihoodlevel, Int_t maxsize)
-{
- //
- //
- if (esdindex>fTrackHypothesys.GetEntriesFast()) return;
- if (! (fTrackHypothesys.At(esdindex)) ) return;
- TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex);
- Int_t entries = array->GetEntriesFast();
- //
- if (likelihoodlevel>0.000001){
- Float_t *probability = new Float_t[entries];
- for (Int_t i=0;i<entries;i++) probability[i]=0.;
- Float_t sumprobabilityall=0;
- Int_t *index = new Int_t[entries];
-
- for (Int_t itrack=0;itrack<entries;itrack++){
- AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
- probability[itrack]=0;
- if (!track) continue;
- probability[itrack] = 1./(0.3+track->GetChi2MIP(0));
- sumprobabilityall += probability[itrack];
- //
- }
- if (sumprobabilityall<=0.000000000000001){
- return;
- }
- for (Int_t itrack=0;itrack<entries;itrack++){
- probability[itrack]/=sumprobabilityall;
- }
-
- TMath::Sort(entries, probability, index, kTRUE);
- //
- TObjArray * newarray = new TObjArray();
- Float_t sumprobability = 0.;
- for (Int_t i=0;i<entries;i++){
- AliITStrackV2 * track = (AliITStrackV2*)array->At(index[i]);
- if (!track) continue;
- newarray->AddLast(array->RemoveAt(index[i]));
- sumprobability+= probability[index[i]];
- if (sumprobability> likelihoodlevel) break;
- if (i>maxsize) break;
- }
-
- array->Delete();
- delete fTrackHypothesys.RemoveAt(esdindex);
- fTrackHypothesys.AddAt(newarray,esdindex);
- //
- delete []index;
- delete []probability;
- }
- else{
- array->Delete();
- delete fTrackHypothesys.RemoveAt(esdindex);
- }
-}
-
-
-AliITStrackV2 * AliITStrackerV2::GetBestHypothesys(Int_t esdindex, AliITStrackV2 * original, Int_t checkmax)
-{
- //-------------------------------------------------------------
- // try to find best hypothesy
- // currently - minimal chi2 of track+backpropagated track+matching to the tpc track
- //-------------------------------------------------------------
- if (fTrackHypothesys.GetEntriesFast()<=esdindex) return 0;
- TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex);
- if (!array) return 0;
- Int_t entries = array->GetEntriesFast();
- if (!entries) return 0;
- Float_t minchi2 = 100000;
- Int_t maxn = 3;
- AliITStrackV2 * besttrack=0;
- Int_t accepted =0;
- Int_t maxindex=0;
- //
- Float_t sumz2=0;
- Float_t sumy2=0;
- Float_t sumall=0;
- for (Int_t itrack=0;itrack<entries; itrack++){
- AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
- if (!track) continue;
- sumall++;
- sumz2+=track->GetSigmaZ2();
- sumy2+=track->GetSigmaY2();
- }
- sumz2/=sumall;
- sumy2/=sumall;
-
- Float_t dedxmismatch=1;
- for (Int_t i=0;i<entries;i++){
- maxindex = i;
- AliITStrackV2 * track = (AliITStrackV2*)array->At(i);
- if (!track) continue;
- track->SetChi2MIP(1,1000000);
- track->SetChi2MIP(2,1000000);
-
- if ( (track->GetNumberOfClusters()-track->GetNSkipped()-track->GetNUsed())<2) continue;
- //
- if (track->GetESDtrack())
- if (track->GetESDtrack()->GetTPCsignal()>80){
- track->CookdEdx();
- if ((track->GetdEdx()/track->GetESDtrack()->GetTPCsignal())<0.4){
- //mismatch in dEdx
- dedxmismatch= 2.+ 10.*(0.6-track->GetdEdx()/track->GetESDtrack()->GetTPCsignal());
- }
- }
-
- // track->SetLabel(original->GetLabel());
- //CookLabel(track,0.0);
- //if (track->GetFakeRatio()>0.01) continue;
- //
- //
- // backtrack
- AliITStrackV2 * backtrack = new AliITStrackV2(*track);
- backtrack->ResetCovariance();
- backtrack->ResetClusters();
- Double_t x = original->GetX();
- if (!RefitAt(x,backtrack,track)){
- delete backtrack;
- delete array->RemoveAt(i);
- continue;
- }
- if ( (backtrack->GetChi2() / float(backtrack->GetNumberOfClusters()-track->GetNSkipped()-track->GetNUsed()-0.5))>6)
- {
- delete backtrack;
- delete array->RemoveAt(i);
- continue;
- }
- Double_t deltac = backtrack->GetC()-original->GetC();
- Double_t deltatgl = backtrack->GetTgl()-original->GetTgl();
- //
- Double_t poolc2 = (deltac*deltac)/(original->GetCov44()+backtrack->GetCov44());
- Double_t pooltgl2 = (deltatgl*deltatgl)/(original->GetCov33()+backtrack->GetCov33());
- if ((poolc2+pooltgl2)>32){ //4 sigma
- delete backtrack;
- delete array->RemoveAt(i);
- continue;
- }
- //Double_t bpoolc = (deltac*deltac)/(original->GetCov44());
- //Double_t bpooltgl = (deltatgl*deltatgl)/(original->GetCov33());
-
- //
- //forward track - without constraint
- AliITStrackV2 * forwardtrack = new AliITStrackV2(*original);
- // forwardtrack->ResetCovariance();
- forwardtrack->ResetClusters();
- x = track->GetX();
- if (!RefitAt(x,forwardtrack,track)){
- delete forwardtrack;
- delete backtrack;
- delete array->RemoveAt(i);
- continue;
- }
- if ( (forwardtrack->GetChi2()/float(forwardtrack->GetNumberOfClusters()-track->GetNSkipped()-track->GetNUsed()))>6)
- {
- delete forwardtrack;
- delete array->RemoveAt(i);
- continue;
- }
- //
- accepted++;
- if (accepted>checkmax){
- delete backtrack;
- delete forwardtrack;
- break;
- }
- Double_t chi2 = (backtrack->GetChi2()/(backtrack->GetNumberOfClusters()-1-track->GetNSkipped()-track->GetNUsed())+
- forwardtrack->GetChi2()/(forwardtrack->GetNumberOfClusters()-track->GetNSkipped()-track->GetNUsed()));
- // bpoolc+bpooltgl;
- // chi2 *= (forwardtrack->GetSigmaZ2()/sumz2+forwardtrack->GetSigmaY2()/sumy2);
- chi2 *= dedxmismatch;
- //
- //
- track->SetChi2MIP(1,backtrack->GetChi2()/(backtrack->GetNumberOfClusters()-1-track->GetNSkipped()-track->GetNUsed()));
- track->SetChi2MIP(2,forwardtrack->GetChi2()/(forwardtrack->GetNumberOfClusters()-track->GetNSkipped()-track->GetNUsed()));
- track->SetChi2MIP(3,poolc2+pooltgl2);
- //
-
- if (track->GetNumberOfClusters()>maxn){
- besttrack = new AliITStrackV2(*forwardtrack);
- maxn = track->GetNumberOfClusters();
- minchi2 = chi2;
- delete backtrack;
- delete forwardtrack;
- continue;
- }
- //
- if (chi2 < minchi2){
- besttrack = new AliITStrackV2(*forwardtrack);
- minchi2 = chi2;
- }
- delete backtrack;
- delete forwardtrack;
- }
- //
- //
- if (!besttrack || besttrack->GetNumberOfClusters()<4) {
- return 0;
- }
-
- //
- besttrack->SetLabel(original->GetLabel());
- CookLabel(besttrack,0.0);
- //
- // calculate "weight of the cluster"
- //
-
- {
- //sign usage information for clusters
- Int_t clusterindex[6][100];
- Double_t clusterweight[6][100];
- for (Int_t ilayer=0;ilayer<6;ilayer++)
- for (Int_t icluster=0;icluster<100;icluster++){
- clusterindex[ilayer][icluster] = -1;
- clusterweight[ilayer][icluster] = 0;
- }
- //printf("%d\t%d\n",esdindex, entries);
- //
- Float_t sumchi2=0;
- for (Int_t itrack=0;itrack<entries; itrack++){
- AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
- if (!track) continue;
- if (track->GetChi2MIP(1)>1000) continue; //not accepted
- sumchi2 +=1./(0.3+track->GetChi2MIP(1)+track->GetChi2MIP(2));
- }
- for (Int_t itrack=0;itrack<entries;itrack++){
- AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
- if (!track) continue;
- if (track->GetChi2MIP(1)>1000) continue; //not accepted
- for (Int_t icluster=0;icluster<track->GetNumberOfClusters();icluster++){
- Int_t tindex = track->GetClusterIndex(icluster);
- Int_t ilayer = (tindex & 0xf0000000) >> 28;
- if (tindex<0) continue;
- Int_t cindex =0;
- //
- for (cindex=0;cindex<100;cindex++){
- if (clusterindex[ilayer][cindex]<0) break;
- if (clusterindex[ilayer][cindex]==tindex) break;
- }
- if (cindex>100) break;
- if (clusterindex[ilayer][cindex]!=tindex) clusterindex[ilayer][cindex] = tindex;
- clusterweight[ilayer][cindex]+= (1./(0.3+track->GetChi2MIP(1)+track->GetChi2MIP(2)))* (1./sumchi2);
- Float_t *weight = GetWeight(tindex);
-
- if (weight){
- *weight+= (1./(0.3+track->GetChi2MIP(1)+track->GetChi2MIP(2)))* (1./sumchi2);
- }
- }
- }
-
- if (besttrack->GetChi2()/besttrack->GetNumberOfClusters()>3.5) return besttrack; //don't sign clusters
- Int_t current=0;
- Double_t deltad = besttrack->GetD(GetX(),GetY());
- Double_t deltaz = besttrack->GetZat(GetX()) - GetZ();
- Double_t deltaprim = TMath::Sqrt(deltad*deltad+deltaz*deltaz);
-
- for (Int_t icluster=0;icluster<besttrack->GetNumberOfClusters();icluster++){
- Int_t index = besttrack->GetClusterIndex(icluster);
- Int_t ilayer = (index & 0xf0000000) >> 28;
- AliITSclusterV2 *c = (AliITSclusterV2*)GetCluster(index);
- if (!c) continue;
- //
- for (Int_t icluster=0;icluster<100;icluster++){
- // sign non "doubt" clusters as used
- if (clusterindex[ilayer][icluster]!=index) continue;
- // Float_t * weight = GetWeight(index);
- //if (weight) if (*weight>1){
- // if (c->IsUsed()) continue;
- // c->Use();
- //}
- if ( (ilayer*0.2+0.2)<deltaprim) continue; // secondaries
- if (c->GetNy()>4) continue; // don sign cluster
- if ( (ilayer>1&&clusterweight[ilayer][icluster]>0.7) || (ilayer<2&&clusterweight[ilayer][icluster]>0.8) ){
- current++;
- if (c->IsUsed()) continue;
- c->Use();
- }
- }
- }
- }
-
- //
- return besttrack;
-}
-
-
-AliITStrackV2 * AliITStrackerV2::GetBestHypothesysMIP(Int_t esdindex, AliITStrackV2 * original)
-{
- //-------------------------------------------------------------
- // try to find best hypothesy
- // currently - minimal chi2 of track+backpropagated track+matching to the tpc track
- //-------------------------------------------------------------
- if (fTrackHypothesys.GetEntriesFast()<=esdindex) return 0;
- TObjArray * array = (TObjArray*) fTrackHypothesys.At(esdindex);
- if (!array) return 0;
- Int_t entries = array->GetEntriesFast();
- if (!entries) return 0;
- AliITStrackV2 * besttrack=0;
- //
- //sign usage information for clusters
- Int_t clusterindex[6][100];
- Double_t clusterweight[6][100];
- for (Int_t ilayer=0;ilayer<6;ilayer++)
- for (Int_t icluster=0;icluster<100;icluster++){
- clusterindex[ilayer][icluster] = -1;
- clusterweight[ilayer][icluster] = 0;
- }
- //printf("%d\t%d\n",esdindex, entries);
- //
- Float_t sumchi2=0;
- for (Int_t itrack=0;itrack<entries; itrack++){
- AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
- if (!track) continue;
- if (track->GetChi2MIP(1)>1000) continue; //not accepted - before
- sumchi2 +=1./(0.3+track->GetChi2MIP(1)+track->GetChi2MIP(2));
- }
- //
- // get cluster weight
- for (Int_t itrack=0;itrack<entries;itrack++){
- AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
- if (!track) continue;
- if (track->GetChi2MIP(1)>1000) continue; // track not accepted in previous iterration
- for (Int_t icluster=0;icluster<track->GetNumberOfClusters();icluster++){
- Int_t tindex = track->GetClusterIndex(icluster);
- Int_t ilayer = (tindex & 0xf0000000) >> 28;
- if (tindex<0) continue;
- Int_t cindex =0;
- //
- for (cindex=0;cindex<100;cindex++){
- if (clusterindex[ilayer][cindex]<0) break;
- if (clusterindex[ilayer][cindex]==tindex) break;
- }
- if (cindex>100) break;
- if (clusterindex[ilayer][cindex]!=tindex) clusterindex[ilayer][cindex] = tindex;
- clusterweight[ilayer][cindex]+= (1./(0.3+track->GetChi2MIP(1)+track->GetChi2MIP(2)))* (1./sumchi2);
- }
- }
- //
- // get cluster relative sharing - factor
- //
- //
- for (Int_t ilayer=0;ilayer<6;ilayer++)
- for (Int_t cindex=0;cindex<100;cindex++){
- if (clusterindex[ilayer][cindex]<0) continue;
- Int_t tindex = clusterindex[ilayer][cindex];
- Float_t *weight = GetWeight(tindex);
- if (!weight){
- printf("Problem 1\n"); // not existing track
- continue;
- }
- if (*weight<(clusterweight[ilayer][cindex]-0.00001)){
- printf("Problem 2\n"); // not normalized probability
- continue;
- }
- AliITSclusterV2 *c = (AliITSclusterV2*)GetCluster(tindex);
- if (c->GetNy()<5){
- clusterweight[ilayer][cindex]/= *weight;
- }
- else{
- Float_t weight2 = TMath::Max(*weight-0.5*clusterweight[ilayer][cindex],0.0000001);
- clusterweight[ilayer][cindex]/= weight2;
- if ( clusterweight[ilayer][cindex]>1) clusterweight[ilayer][cindex] =1.;
- }
- }
- //
- //take to the account sharing factor
- //
- Float_t chi2 =10000000;
- Float_t sharefactor=0;
- Float_t minchi2 = 100000000;
- Float_t secchi2 = 100000000;
- Float_t norm=0;
- for (Int_t itrack=0;itrack<entries; itrack++){
- AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
- if (!track) continue;
- if (track->GetChi2MIP(1)>1000) continue; //not accepted - before
- chi2 = track->GetChi2MIP(1);
- Float_t newchi2=0;
- sharefactor=0;
- norm =0;
- //
- for (Int_t icluster=0;icluster<track->GetNumberOfClusters();icluster++){
- Int_t tindex = track->GetClusterIndex(icluster);
- Int_t ilayer = (tindex & 0xf0000000) >> 28;
- if (tindex<0) continue;
- Int_t cindex =0;
- Float_t cchi2 = (track->GetDy(ilayer)*track->GetDy(ilayer))/(track->GetSigmaY(ilayer)*track->GetSigmaY(ilayer)) +
- (track->GetDz(ilayer)*track->GetDz(ilayer))/(track->GetSigmaZ(ilayer)*track->GetSigmaZ(ilayer)) ;
- //
- for (cindex=0;cindex<100;cindex++){
- if (clusterindex[ilayer][cindex]<0) break;
- if (clusterindex[ilayer][cindex]==tindex) break;
- }
- if (cindex>100) continue;
- if (clusterweight[ilayer][cindex]>0.00001){
- sharefactor+= clusterweight[ilayer][cindex];
- cchi2/=clusterweight[ilayer][cindex];
- norm++;
- }
- newchi2+=cchi2;
- }
- newchi2/=(norm-track->GetNSkipped()-track->GetNUsed());
- track->SetChi2MIP(4,newchi2);
- //if (norm>0) sharefactor/=norm;
- //if (sharefactor<0.5) return 0;
- // chi2*=1./(0.5+sharefactor);
- if (newchi2<minchi2){
- besttrack = track;
- minchi2 = newchi2;
- }
- else{
- if (newchi2<secchi2){
- secchi2 = newchi2;
- }
- }
- //
- }
-
- //
- //
- if (!besttrack || besttrack->GetNumberOfClusters()<4) {
- return 0;
- }
- //
- if ((minchi2/secchi2)<0.7){
- //
- //increase the weight for clusters if the probability of other hypothesys is small
- Double_t deltad = besttrack->GetD(GetX(),GetY());
- Double_t deltaz = besttrack->GetZat(GetX()) - GetZ();
- Double_t deltaprim = TMath::Sqrt(deltad*deltad+deltaz*deltaz);
- //
- for (Int_t icluster=0;icluster<besttrack->GetNumberOfClusters();icluster++){
- Int_t index = besttrack->GetClusterIndex(icluster);
- Int_t ilayer = (index & 0xf0000000) >> 28;
- AliITSclusterV2 *c = (AliITSclusterV2*)GetCluster(index);
- if (!c) continue;
- if (c->GetNy()>3) continue;
- if ( (ilayer*0.2+0.2)<deltaprim) continue; // secondaries
- Float_t * weight = GetWeight(index);
- *weight*=2.;
- *weight+=1.;
- }
- }
-
-
- besttrack->SetLabel(original->GetLabel());
- CookLabel(besttrack,0.0);
-
- //
- return besttrack;
-}
-