+//__________________________________________________________________________
+void AliMUONTrack::FindMCLabel()
+{
+ /// Determine the MC label from the label of the attached clusters and fill fMCLabel data member:
+ /// More than 50% of clusters, including 1 before and 1 after the dipole, must share the same label
+
+ Int_t nClusters = GetNClusters();
+ Int_t halfCluster = nClusters/2;
+
+ // reset MC label
+ fTrackID = -1;
+
+ // loop over first clusters (if nClusters left < (nClusters-halfCluster) the conditions cannot be fulfilled)
+ for (Int_t iCluster1 = 0; iCluster1 < nClusters-halfCluster; iCluster1++) {
+ AliMUONVCluster* cluster1 = ((AliMUONTrackParam*) fTrackParamAtCluster->UncheckedAt(iCluster1))->GetClusterPtr();
+
+ // if the first cluster is not on station 1 or 2 the conditions cannot be fulfilled
+ if (cluster1->GetChamberId() > 3) return;
+
+ Int_t label1 = cluster1->GetMCLabel();
+ if (label1 < 0) continue;
+
+ Int_t nIdenticalLabel = 1;
+
+ // Loop over next clusters
+ for (Int_t iCluster2 = iCluster1+1; iCluster2 < nClusters; iCluster2++) {
+ AliMUONVCluster* cluster2 = ((AliMUONTrackParam*) fTrackParamAtCluster->UncheckedAt(iCluster2))->GetClusterPtr();
+
+ if (cluster2->GetMCLabel() != label1) continue;
+
+ nIdenticalLabel++;
+
+ // stop as soon as conditions are fulfilled
+ if (nIdenticalLabel > halfCluster && cluster2->GetChamberId() > 5) {
+ fTrackID = label1;
+ return;
+ }
+
+ }
+
+ }
+