+
+ // Check if this is a primary particle
+ Bool_t isPrimary = kTRUE;
+ Int_t trackno = -1;
+ if (fStack) {
+ trackno = fmdHit->Track();
+ AliFMDDebug(10, ("Will get track # %d/%d from entry # %d",
+ trackno, fStack->GetNtrack(), track));
+ if (fStack->GetNtrack() < trackno) {
+ AliError(Form("Track number %d/%d out of bounds",
+ trackno, fStack->GetNtrack()));
+ continue;
+ }
+#if 1
+ isPrimary = fStack->IsPhysicalPrimary(trackno);
+#else // This is our hand-crafted code. We use the ALICE definition
+ TParticle* part = fStack->Particle(trackno);
+ isPrimary = part->IsPrimary();
+ if (!isPrimary) {
+ // Extended testing of mother status - this is for Pythia6.
+ Int_t mother1 = part->GetFirstMother();
+ TParticle* mother = fStack->Particle(mother1);
+ if (!mother || mother->GetStatusCode() > 1)
+ isPrimary = kTRUE;
+ AliFMDDebug(15,
+ ("Track %d secondary, mother: %d - %s - status %d: %s",
+ trackno, mother1,
+ (mother ? "found" : "not found"),
+ (mother ? mother->GetStatusCode() : -1),
+ (isPrimary ? "primary" : "secondary")));
+ }
+#endif
+ }
+