+
+
+//------------------------------------------------------------------------
+void AliITStrackerMI::CookLabel(AliITStrackMI *track,Float_t wrong) const {
+ //--------------------------------------------------------------------
+ //This function "cooks" a track label. If label<0, this track is fake.
+ //--------------------------------------------------------------------
+ const int kMaxLbPerCl = 3;
+ int lbID[36],lbStat[36];
+ Int_t nLab=0, nCl = track->GetNumberOfClusters();
+ //
+ // track->SetLabel(-1);
+ // track->SetFakeRatio(0);
+ //
+ for (Int_t i=0;i<nCl;i++) { // fill all labels
+ Int_t cindex = track->GetClusterIndex(i);
+ // Int_t l=(cindex & 0xf0000000) >> 28;
+ AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(cindex);
+ //
+ for (int imc=0;imc<kMaxLbPerCl;imc++) { // labels within single cluster
+ int trLb = cl->GetLabel(imc);
+ if (trLb<0) break;
+ // search this mc track in already accounted ones
+ int iLab;
+ for (iLab=0;iLab<nLab;iLab++) if (lbID[iLab]==trLb) break;
+ if (iLab<nLab) lbStat[iLab]++;
+ else {
+ lbID[nLab] = trLb;
+ lbStat[nLab++] = 1;
+ }
+ } // loop over given cluster's labels
+ } // loop over clusters
+ //
+ if (nLab<1) return; // no labels at all
+ //
+ Int_t tpcLabel=-1;
+ if (track->GetESDtrack() && track->GetESDtrack()->IsOn(AliESDtrack::kTPCin)){
+ tpcLabel = TMath::Abs(track->GetESDtrack()->GetTPCLabel());
+ }
+ //
+ // find majority label
+ if (nCl && nLab) {
+ int maxLab=0,tpcLabID=-1;
+ for (int ilb=nLab;ilb--;) {
+ int st = lbStat[ilb];
+ if (lbStat[maxLab]<st) maxLab = ilb;
+ if (lbID[ilb] == tpcLabel) tpcLabID = ilb;
+ }
+ // if there is an equal choice, prefer ITS label consistent with TPC label
+ if (tpcLabel>0 && (tpcLabID!=maxLab) && lbStat[maxLab]==lbStat[tpcLabID]) maxLab=tpcLabID;
+
+ track->SetFakeRatio(1.-float(lbStat[maxLab])/nCl);
+ track->SetLabel( lbStat[maxLab]>=nCl-wrong ? lbID[maxLab] : -lbID[maxLab]);
+ }
+ //
+}
+
+/*