]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGHF/vertexingHF/AliCFVertexingHFCascade.cxx
consolidate zero-length arrays (aka struct hack)
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliCFVertexingHFCascade.cxx
index b502744f96b82cfea06dbfb009bc79531656f45f..ff1aa134321ce0abe9c288b94981c264c8ece955 100644 (file)
@@ -195,10 +195,12 @@ Bool_t AliCFVertexingHFCascade::GetGeneratedValuesFromMCParticle(Double_t* vecto
        }
        else{
          AliWarning("There are problems!! particle was expected to be either a D0 or a D0bar, check...");
+         delete decay;
          return vectorMC;
        }
        if (cosThetaStar < -1 || cosThetaStar > 1) {
          AliWarning("Invalid value for cosine Theta star, returning");
+         delete decay;
          return bGenValues;
        }
        
@@ -207,6 +209,7 @@ Bool_t AliCFVertexingHFCascade::GetGeneratedValuesFromMCParticle(Double_t* vecto
        // evaluate the correct cascade
        if (!EvaluateIfD0toKpi(mcPartDaughterD0,vectorD0)) {
          AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!");
+         delete decay;
          return bGenValues;  
        }       
 
@@ -422,6 +425,19 @@ Bool_t AliCFVertexingHFCascade::EvaluateIfD0toKpi(AliAODMCParticle* neutralDaugh
     return isHadronic;  
   }
   
+  Double_t sumPxDau=mcPartDaughterD00->Px()+mcPartDaughterD01->Px();
+  Double_t sumPyDau=mcPartDaughterD00->Py()+mcPartDaughterD01->Py();
+  Double_t sumPzDau=mcPartDaughterD00->Pz()+mcPartDaughterD01->Pz();
+  Double_t pxMother=neutralDaugh->Px();
+  Double_t pyMother=neutralDaugh->Py();
+  Double_t pzMother=neutralDaugh->Pz();
+  if(TMath::Abs(pxMother-sumPxDau)/(TMath::Abs(pxMother)+1.e-13)>0.00001 ||
+     TMath::Abs(pyMother-sumPyDau)/(TMath::Abs(pyMother)+1.e-13)>0.00001 ||
+     TMath::Abs(pzMother-sumPzDau)/(TMath::Abs(pzMother)+1.e-13)>0.00001){
+    AliDebug(2, "Momentum conservation violated, skipping!!");
+    return isHadronic;  
+  }
+
   Double_t pTD0pi = 0;
   Double_t pTD0K = 0;