Fix
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliCFVertexingHFCascade.cxx
index 6c9e16c..8772af7 100644 (file)
@@ -30,6 +30,7 @@
 #include "AliAODRecoCascadeHF.h"
 #include "AliCFVertexingHFCascade.h"
 #include "AliCFContainer.h"
+#include "AliCFTaskVertexingHF.h"
 
 ClassImp(AliCFVertexingHFCascade)
 
@@ -96,7 +97,17 @@ Bool_t AliCFVertexingHFCascade::SetRecoCandidateParam(AliAODRecoDecayHF *recoCan
  
   Int_t mcLabel =  dstarD0pi->MatchToMC(413,421,pdgDgDStartoD0pi,pdgDgD0toKpi,fmcArray); 
   
-  if (mcLabel < 0) return bSignAssoc;
+  if (mcLabel == -1) return bSignAssoc;
+
+  if (fRecoCandidate->NumberOfFakeDaughters()>0){
+         fFake = 0;    // fake candidate
+         if (fFakeSelection==1) return bSignAssoc;
+  }
+  if (fRecoCandidate->NumberOfFakeDaughters()==0){
+         fFake = 2;    // non-fake candidate
+         if (fFakeSelection==2) return bSignAssoc;
+  }
+  
   SetMCLabel(mcLabel);
   fmcPartCandidate = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fmcLabel)); 
 
@@ -126,6 +137,8 @@ Bool_t AliCFVertexingHFCascade::GetGeneratedValuesFromMCParticle(Double_t* vecto
        AliAODMCParticle* mcPartDaughterD0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0ds));
        AliAODMCParticle* mcPartDaughterPis = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1ds));
 
+       if(!mcPartDaughterD0 || !mcPartDaughterPis) return kFALSE;
+
        Double_t vtx1[3] = {0,0,0};   // primary vertex         
        Double_t vtx2daughter0[3] = {0,0,0};   // secondary vertex from daughter 0
        Double_t vtx2daughter1[3] = {0,0,0};   // secondary vertex from daughter 1
@@ -138,6 +151,8 @@ Bool_t AliCFVertexingHFCascade::GetGeneratedValuesFromMCParticle(Double_t* vecto
        AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0)); //D0
        AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1)); //pis
 
+       if(!mcPartDaughter0 || !mcPartDaughter1) return kFALSE;
+
        // getting vertex from daughters
        mcPartDaughter0->XvYvZv(vtx2daughter0);  // cm
        mcPartDaughter1->XvYvZv(vtx2daughter1);  //cm
@@ -207,20 +222,36 @@ Bool_t AliCFVertexingHFCascade::GetGeneratedValuesFromMCParticle(Double_t* vecto
        }
 
        
-       vectorMC[0] = fmcPartCandidate->Pt();
-       vectorMC[1] = fmcPartCandidate->Y() ;
-       vectorMC[2] = cosThetaStar ;
-       vectorMC[3] = vectorD0[0]; 
-       vectorMC[4] = vectorD0[1];
-       vectorMC[5] = cT*1.E4 ;  // in micron
-       vectorMC[6] = 0.;   // dummy value, meaningless in MC
-       vectorMC[7] = 0.;   // dummy value, meaningless in MC, in micron
-       vectorMC[8] = 0.;   // dummy value, meaningless in MC, in micron
-       vectorMC[9] = -100000.; // dummy value, meaningless in MC, in micron^2
-       vectorMC[10] = 1.01;    // dummy value, meaningless in MC
-       vectorMC[11] = fmcPartCandidate->Phi(); 
-       vectorMC[12] = fzMCVertex;    // z of reconstructed of primary vertex
-       vectorMC[13] = fCentValue; // reconstructed centrality
+       switch (fConfiguration){
+       case AliCFTaskVertexingHF::kSnail:
+               vectorMC[0] = fmcPartCandidate->Pt();
+               vectorMC[1] = fmcPartCandidate->Y() ;
+               vectorMC[2] = cosThetaStar ;
+               vectorMC[3] = vectorD0[0]; 
+               vectorMC[4] = vectorD0[1];
+               vectorMC[5] = cT*1.E4 ;  // in micron
+               vectorMC[6] = 0.;   // dummy value, meaningless in MC
+               vectorMC[7] = -100000.; // dummy value, meaningless in MC, in micron^2
+               vectorMC[8] = 1.01;    // dummy value, meaningless in MC
+               vectorMC[9] = fmcPartCandidate->Phi(); 
+               vectorMC[10] = fzMCVertex;    // z of reconstructed of primary vertex
+               vectorMC[11] = fCentValue; // reconstructed centrality
+               vectorMC[12] = 1.;           // always filling with 1 at MC level 
+               vectorMC[13] = 1.01; // dummy value for cosPointingXY  multiplicity
+               vectorMC[14] = 0.; // dummy value for NormalizedDecayLengthXY multiplicity
+               vectorMC[15] = fMultiplicity; // reconstructed multiplicity
+               break;
+       case AliCFTaskVertexingHF::kCheetah:
+               vectorMC[0] = fmcPartCandidate->Pt();
+               vectorMC[1] = fmcPartCandidate->Y() ;
+               vectorMC[2] = cT*1.E4; // in micron
+               vectorMC[3] = fmcPartCandidate->Phi();
+               vectorMC[4] = fzMCVertex;
+               vectorMC[5] = fCentValue;   // dummy value for dca, meaningless in MC
+               vectorMC[6] = 1. ;  // fake: always filling with 1 at MC level 
+               vectorMC[7] = fMultiplicity;   // dummy value for d0pi, meaningless in MC, in micron
+               break;
+       }
 
        delete decay;
        bGenValues = kTRUE;
@@ -253,6 +284,8 @@ Bool_t AliCFVertexingHFCascade::GetRecoValuesFromCandidate(Double_t *vectorReco)
   Double_t d0xd0 = d0toKpi->Prodd0d0();
   Double_t cosPointingAngle = d0toKpi->CosPointingAngle();
   Double_t phi = dstarD0pi->Phi();
+  Double_t cosPointingAngleXY = d0toKpi->CosPointingAngleXY();
+  Double_t normDecayLengthXY = d0toKpi->NormalizedDecayLengthXY();
 
   Int_t pdgCode = fmcPartCandidate->GetPdgCode();
  
@@ -275,23 +308,39 @@ Bool_t AliCFVertexingHFCascade::GetRecoValuesFromCandidate(Double_t *vectorReco)
   
   Double_t cT = d0toKpi->CtD0();
   
-  vectorReco[0] = pt;
-  vectorReco[1] = rapidity;
-  vectorReco[2] = cosThetaStar;
-  vectorReco[3] = pTpi;
-  vectorReco[4] = pTK;
-  vectorReco[5] = cT*1.E4;  // in micron
-  vectorReco[6] = dca*1.E4;  // in micron
-  vectorReco[7] = d0pi*1.E4;  // in micron
-  vectorReco[8] = d0K*1.E4;  // in micron
-  vectorReco[9] = d0xd0*1.E8;  // in micron^2
-  vectorReco[10] = cosPointingAngle;  // in micron
-  vectorReco[11] = phi;  
-  vectorReco[12] = fzPrimVertex;    // z of reconstructed of primary vertex
-  vectorReco[13] = fCentValue;
-
-  bFillRecoValues = kTRUE;
+       switch (fConfiguration){
+       case AliCFTaskVertexingHF::kSnail:
+               vectorReco[0] = pt;
+               vectorReco[1] = rapidity;
+               vectorReco[2] = cosThetaStar;
+               vectorReco[3] = pTpi;
+               vectorReco[4] = pTK;
+               vectorReco[5] = cT*1.E4;  // in micron
+               vectorReco[6] = dca*1.E4;  // in micron
+               vectorReco[7] = d0xd0*1.E8;  // in micron^2
+               vectorReco[8] = cosPointingAngle;  // in micron
+               vectorReco[9] = phi;  
+               vectorReco[10] = fzPrimVertex;    // z of reconstructed of primary vertex
+               vectorReco[11] = fCentValue;
+               vectorReco[12] = fFake;      // whether the reconstructed candidate was a fake (fFake = 0) or not (fFake = 2) 
+               vectorReco[13] = cosPointingAngleXY; 
+               vectorReco[14] = normDecayLengthXY; // in cm
+               vectorReco[15] = fMultiplicity; // reconstructed multiplicity
+               break;
+       case AliCFTaskVertexingHF::kCheetah:
+               vectorReco[0] = pt;
+               vectorReco[1] = rapidity ;
+               vectorReco[2] = cT*1.E4; // in micron
+               vectorReco[3] = phi; 
+               vectorReco[4] = fzPrimVertex;
+               vectorReco[5] = fCentValue;   
+               vectorReco[6] = fFake ; 
+               vectorReco[7] = fMultiplicity;  
+               break;
+       }
 
+       bFillRecoValues = kTRUE;
+               
   return bFillRecoValues;
 }
 
@@ -455,21 +504,67 @@ void AliCFVertexingHFCascade::SetAccCut()
        //
        // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
        //
-
-       AliAODMCParticle* mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(2)); // should be the soft pion...  
-       if (TMath::Abs(fLabelArray[0]-fLabelArray[1] != 1) || TMath::Abs(fLabelArray[1]-fLabelArray[2] == 1) || TMath::Abs(fLabelArray[0]-fLabelArray[2] == 1) || TMath::Abs(mcPartDaughter->GetPdgCode())){
-               AliFatal("Apparently the soft pion is not in the third position, causing a crash!!");
-       }
-       if (fProngs>0){
-               for (Int_t iP=0; iP<fProngs-1; iP++){
-                       fPtAccCut[iP]=0.1;
-                       fEtaAccCut[iP]=0.9;
-               }
-               fPtAccCut[3]=0.;  // soft pion
-               fEtaAccCut[3]=0.9;  // soft pion
-       }
-       return;
+  
+  AliAODMCParticle* mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[2]));  // should be the soft pion...  
+  if(!mcPartDaughter) return;
+  Int_t mother =  mcPartDaughter->GetMother();
+  AliAODMCParticle* mcMother = dynamic_cast<AliAODMCParticle*>(fmcArray->At(mother)); 
+  if(!mcMother) return;
+
+  if (TMath::Abs(mcPartDaughter->GetPdgCode())!= 211 || TMath::Abs(mcMother->GetPdgCode())!=413){
+    AliFatal("Apparently the soft pion is not in the third position, causing a crash!!");
+  }             
+  if (fProngs>0){
+    for (Int_t iP=0; iP<fProngs-1; iP++){
+      fPtAccCut[iP]=0.1;
+      fEtaAccCut[iP]=0.9;
+    }
+    fPtAccCut[2]=0.06;  // soft pion
+    fEtaAccCut[2]=0.9;  // soft pion
+  }
+  return;
 }              
 
+//_____________________________________________________________
+Double_t AliCFVertexingHFCascade::GetEtaProng(Int_t iProng) const 
+{
+       //
+       // getting eta of the prong - overload the mother class method
+       //
 
-
+ if (fRecoCandidate){
+   
+   AliAODRecoCascadeHF* dstarD0pi = (AliAODRecoCascadeHF*)fRecoCandidate;
+
+   Double_t etaProng =-9999;
+    if(iProng==0) etaProng =dstarD0pi->Get2Prong()->EtaProng(0);
+    if(iProng==1) etaProng =dstarD0pi->Get2Prong()->EtaProng(1);
+    if(iProng==2) etaProng =dstarD0pi->EtaProng(1);
+    
+    return etaProng;
+    
+  }
+  return 999999;    
+}
+//_____________________________________________________________
+Double_t AliCFVertexingHFCascade::GetPtProng(Int_t iProng) const 
+{
+       //
+       // getting pt of the prong
+       //
+  
+  if (fRecoCandidate){
+
+    AliAODRecoCascadeHF* dstarD0pi = (AliAODRecoCascadeHF*)fRecoCandidate;
+    Double_t ptProng= -9999;
+    if(iProng==0) ptProng =dstarD0pi->Get2Prong()->PtProng(0);
+    if(iProng==1) ptProng =dstarD0pi->Get2Prong()->PtProng(1);
+    if(iProng==2) ptProng =dstarD0pi->PtProng(1);
+    
+    // Double_t ptProng = fRecoCandidate->PtProng(iProng);  
+    return ptProng;
+    
+  }
+  return 999999;  
+  
+}