-
-
-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->fChi2MIP[1] = 1000000;
- track->fChi2MIP[2] = 1000000;
-
- if ( (track->GetNumberOfClusters()-track->fNSkipped-track->fNUsed)<2) continue;
- //
- if (track->fESDtrack)
- if (track->fESDtrack->GetTPCsignal()>80){
- track->CookdEdx();
- if ((track->GetdEdx()/track->fESDtrack->GetTPCsignal())<0.4){
- //mismatch in dEdx
- dedxmismatch= 2.+ 10.*(0.6-track->GetdEdx()/track->fESDtrack->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->fNSkipped-track->fNUsed-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->fC44+backtrack->fC44);
- Double_t pooltgl2 = (deltatgl*deltatgl)/(original->fC33+backtrack->fC33);
- if ((poolc2+pooltgl2)>32){ //4 sigma
- delete backtrack;
- delete array->RemoveAt(i);
- continue;
- }
- //Double_t bpoolc = (deltac*deltac)/(original->fC44);
- //Double_t bpooltgl = (deltatgl*deltatgl)/(original->fC33);
-
- //
- //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->fNSkipped-track->fNUsed))>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->fNSkipped-track->fNUsed)+
- forwardtrack->GetChi2()/(forwardtrack->GetNumberOfClusters()-track->fNSkipped-track->fNUsed));
- // bpoolc+bpooltgl;
- // chi2 *= (forwardtrack->GetSigmaZ2()/sumz2+forwardtrack->GetSigmaY2()/sumy2);
- chi2 *= dedxmismatch;
- //
- //
- track->fChi2MIP[1] = backtrack->GetChi2()/(backtrack->GetNumberOfClusters()-1-track->fNSkipped-track->fNUsed);
- track->fChi2MIP[2] = forwardtrack->GetChi2()/(forwardtrack->GetNumberOfClusters()-track->fNSkipped-track->fNUsed);
- track->fChi2MIP[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->fChi2MIP[1]>1000) continue; //not accepted
- sumchi2 +=1./(0.3+track->fChi2MIP[1]+track->fChi2MIP[2]);
- }
- for (Int_t itrack=0;itrack<entries;itrack++){
- AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
- if (!track) continue;
- if (track->fChi2MIP[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->fChi2MIP[1]+track->fChi2MIP[2]))* (1./sumchi2);
- Float_t *weight = GetWeight(tindex);
-
- if (weight){
- *weight+= (1./(0.3+track->fChi2MIP[1]+track->fChi2MIP[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->fChi2MIP[1]>1000) continue; //not accepted - before
- sumchi2 +=1./(0.3+track->fChi2MIP[1]+track->fChi2MIP[2]);
- }
- //
- // get cluster weight
- for (Int_t itrack=0;itrack<entries;itrack++){
- AliITStrackV2 * track = (AliITStrackV2*)array->At(itrack);
- if (!track) continue;
- if (track->fChi2MIP[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->fChi2MIP[1]+track->fChi2MIP[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->fChi2MIP[1]>1000) continue; //not accepted - before
- chi2 = track->fChi2MIP[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->fDy[ilayer]*track->fDy[ilayer])/(track->fSigmaY[ilayer]*track->fSigmaY[ilayer]) +
- (track->fDz[ilayer]*track->fDz[ilayer])/(track->fSigmaZ[ilayer]*track->fSigmaZ[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->fNSkipped-track->fNUsed);
- track->fChi2MIP[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;
-}
-