]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGLF/RESONANCES/AliRsnEvent.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnEvent.cxx
index c5eeb0715a2771b6d530ce9a2cc3f12fd143de43..0e101afad3058403007b5572b7a3d1ed76728613 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;
+      }
+   }
 }
 
 //_____________________________________________________________________________
@@ -200,7 +202,8 @@ void AliRsnEvent::SetDaughterAODtrack(AliRsnDaughter &out, Int_t i)
    AliAODEvent *aod = (AliAODEvent *)fRef;
 
    if (i >= 0 && i < aod->GetNumberOfTracks()) {
-      AliAODTrack *track = aod->GetTrack(i);
+      AliAODTrack *track = dynamic_cast<AliAODTrack*>(aod->GetTrack(i));
+      if(!track) AliFatal("Not a standard AOD");
       if (track) {
          out.SetRef(track);
          out.SetGood();
@@ -250,6 +253,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);
                   }
                }
@@ -363,7 +372,7 @@ Bool_t AliRsnEvent::SetMCInfoESD(AliRsnDaughter &out)
 
    // if label too large --> failed
    if (label >= nMC) {
-      AliWarning(Form("Stack overflow: track label = %d -- stack maximum = %d", label, nMC));
+     AliDebug(4, Form("Stack overflow: track label = %d -- stack maximum = %d", label, nMC));
       return kFALSE;
    }
 
@@ -384,12 +393,12 @@ 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));
       }
    } else {
-      AliWarning(Form("Stack overflow: mother label = %d -- stack maximum = %d", imum, nMC));
+     AliDebug(4, Form("Stack overflow: mother label = %d -- stack maximum = %d", imum, nMC));
    }
 
    return kTRUE;
@@ -417,7 +426,7 @@ Bool_t AliRsnEvent::SetMCInfoAOD(AliRsnDaughter &out)
 
    // if label too large --> failed
    if (label >= nMC) {
-      AliWarning(Form("Stack overflow: track label = %d -- stack maximum = %d", label, nMC));
+     AliDebug(4, Form("Stack overflow: track label = %d -- stack maximum = %d", label, nMC));
       return kFALSE;
    }
 
@@ -435,12 +444,12 @@ 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));
       }
    } else if (imum >= nMC) {
-      AliWarning(Form("Stack overflow: mother label = %d -- stack maximum = %d", imum, nMC));
+     AliDebug(4, Form("Stack overflow: mother label = %d -- stack maximum = %d", imum, nMC));
    }
 
    return kTRUE;