]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGLF/RESONANCES/AliRsnEvent.cxx
Merge branch 'flatdev' of https://git.cern.ch/reps/AliRoot into flatdev
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnEvent.cxx
index c5eeb0715a2771b6d530ce9a2cc3f12fd143de43..51f343b79bda090126f9d6a6e6bfe1a77c88be46 100644 (file)
@@ -70,6 +70,7 @@ AliRsnEvent &AliRsnEvent::operator= (const AliRsnEvent &event)
 //
 // Works in the same way as the copy constructor.
 //
+
    TObject::operator=(event);
    if (this == &event)
       return *this;
@@ -110,37 +111,38 @@ void AliRsnEvent::SetDaughter(AliRsnDaughter &out, Int_t index, Bool_t fromMC)
    if (!InputOK()) return;
    Bool_t inputESD = IsESD();
 
-
-   Int_t trueIndex;
-   AliRsnDaughter::ERefType type;
-   if (!ConvertAbsoluteIndex(index, trueIndex, type)) {
-      AliError(Form("Failed to convert absolute index %d", index));
-      return;
-   }
-   switch (type) {
-      case AliRsnDaughter::kTrack:
-         if (inputESD) {
-            SetDaughterESDtrack(out, trueIndex);
-
-         } else {
-            SetDaughterAODtrack(out, trueIndex);
-         }
-         break;
-      case AliRsnDaughter::kV0:
-         if (inputESD) SetDaughterESDv0(out, trueIndex); else SetDaughterAODv0(out, trueIndex);
-         break;
-      case AliRsnDaughter::kCascade:
-         if (inputESD) SetDaughterESDcascade(out, trueIndex); else SetDaughterAODcascade(out, trueIndex);
-         break;
-      default:
-         AliError("Unrecognized daughter type");
-         return;
-   }
-
    // if it is pure MC, the index tells what particle
    // to be read in the stack of MC particles, otherwise
    // it is converted into a real collection index
-   if (fromMC) out.SetRef(out.GetRefMC());
+   if (fromMC) {
+      out.SetLabel(index);
+      Bool_t ok = (inputESD ? SetMCInfoESD(out) : SetMCInfoAOD(out));
+      if (ok) {
+         out.SetGood();
+         out.SetRef(out.GetRefMC());
+      }
+   } else {
+      Int_t trueIndex;
+      AliRsnDaughter::ERefType type;
+      if (!ConvertAbsoluteIndex(index, trueIndex, type)) {
+         AliError(Form("Failed to convert absolute index %d", index));
+         return;
+      }
+      switch (type) {
+         case AliRsnDaughter::kTrack:
+            if (inputESD) SetDaughterESDtrack(out, trueIndex); else SetDaughterAODtrack(out, trueIndex);
+            break;
+         case AliRsnDaughter::kV0:
+            if (inputESD) SetDaughterESDv0(out, trueIndex); else SetDaughterAODv0(out, trueIndex);
+            break;
+         case AliRsnDaughter::kCascade:
+            if (inputESD) SetDaughterESDcascade(out, trueIndex); else SetDaughterAODcascade(out, trueIndex);
+            break;
+         default:
+            AliError("Unrecognized daughter type");
+            return;
+      }
+   }
 }
 
 //_____________________________________________________________________________
@@ -250,6 +252,12 @@ void AliRsnEvent::SetDaughterESDv0(AliRsnDaughter &out, Int_t i)
                   // otherwise label remains '-1' --> fake V0
                   if (pp->GetFirstMother() == pn->GetFirstMother() && pp->GetFirstMother() >= 0) {
                      out.SetLabel(pp->GetFirstMother());
+                     //patch for k0s/k0l
+                     TParticle *mom = mc->Stack()->Particle(pn->GetFirstMother());
+                     if(mom->GetPdgCode() == 310) {
+                        //take the mother of the k0s which is a k0 (311)
+                        out.SetLabel(mom->GetFirstMother());
+                     }
                      SetMCInfoESD(out);
                   }
                }
@@ -384,7 +392,7 @@ Bool_t AliRsnEvent::SetMCInfoESD(AliRsnDaughter &out)
    if (imum >= 0 && imum < nMC) {
       AliMCParticle *mcMother = (AliMCParticle *)mc->GetTrack(imum);
       if (mcMother) {
-         out.SetMotherPDG(TMath::Abs(mcMother->Particle()->GetPdgCode()));
+         out.SetMotherPDG(mcMother->Particle()->GetPdgCode());
       } else {
          AliWarning(Form("Stack discontinuity: label mother %d refers to a NULL object", imum));
       }
@@ -435,7 +443,7 @@ Bool_t AliRsnEvent::SetMCInfoAOD(AliRsnDaughter &out)
    if (imum >= 0 && imum < nMC) {
       AliAODMCParticle *mcMother = (AliAODMCParticle *)mcArray->At(imum);
       if (mcMother) {
-         out.SetMotherPDG(TMath::Abs(mcMother->GetPdgCode()));
+         out.SetMotherPDG(mcMother->GetPdgCode());
       } else {
          AliWarning(Form("Stack discontinuity: label mother %d refers to a NULL object", imum));
       }