+
+//______________________________________________________________________________
+Bool_t AliRsnAnalysisPhiKK::IsTruePair(AliRsnDaughter *d1, AliRsnDaughter *d2)
+{
+//
+// Checks if the two daughters in argument come from the same phi resonance
+// and, if they do, check also that they are both kaons
+//
+
+ // constants related to PDG
+ static const Int_t phiPDG = 333;
+ static const Int_t kaonPDG = 321;
+
+ // check #1: is MC present?
+ if (!d1->GetRefMC() || !d2->GetRefMC()) return kFALSE;
+
+ // check #2: same mother?
+ Int_t m1 = -1;
+ Int_t m2 = -2;
+ if (d1->IsESD() && d2->IsESD() )
+ {
+ if (d1->GetRefMCESD() && d2->GetRefMCESD())
+ {
+ m1 = d1->GetRefMCESD()->Particle()->GetFirstMother();
+ m2 = d2->GetRefMCESD()->Particle()->GetFirstMother();
+ }
+ }
+ if (d1->IsAOD() && d2->IsAOD())
+ {
+ if (d1->GetRefMCAOD() && d2->GetRefMCAOD())
+ {
+ m1 = d1->GetRefMCAOD()->GetMother();
+ m2 = d2->GetRefMCAOD()->GetMother();
+ }
+ }
+ if (m1 < 0 || m2 < 0 || (m1 > 0 && m2 > 0 && m1 != m2)) return kFALSE;
+
+ // check #3: is the common mother a phi (PDG = 333)?
+ if (d1->GetMotherPDG() != phiPDG) return kFALSE;
+
+ // check #4: are the two particles a K+K- pair?
+ m1 = d1->GetPDG();
+ m2 = d2->GetPDG();
+ if (m1 == kaonPDG && m2 == -kaonPDG)
+ return kTRUE;
+ else if (m1 == -kaonPDG && m2 == kaonPDG)
+ return kTRUE;
+ else
+ return kFALSE;
+}