Added possibility to write to AOD the MC-matched signal candidates w/o reconstruction...
authordainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 6 Jul 2011 11:56:33 +0000 (11:56 +0000)
committerdainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 6 Jul 2011 11:56:33 +0000 (11:56 +0000)
PWG3/vertexingHF/AliAnalysisVertexingHF.cxx
PWG3/vertexingHF/AliAnalysisVertexingHF.h
PWG3/vertexingHF/AliRDHFCuts.cxx
PWG3/vertexingHF/AliRDHFCuts.h
PWG3/vertexingHF/AliRDHFCutsD0toKpi.cxx
PWG3/vertexingHF/AliRDHFCutsDplustoKpipi.cxx
PWG3/vertexingHF/AliRDHFCutsDstoKKpi.cxx
PWG3/vertexingHF/AliRDHFCutsLctopKpi.cxx

index d6cdcb9..9c74c00 100644 (file)
@@ -100,7 +100,9 @@ fFindVertexForCascades(kTRUE),
 fMassCutBeforeVertexing(kFALSE),
 fMassCalc2(0),
 fMassCalc3(0),
-fMassCalc4(0)
+fMassCalc4(0),
+fnTrksTotal(0),
+fnSeleTrksTotal(0)
 {
   // Default constructor
 
@@ -145,7 +147,9 @@ fFindVertexForCascades(source.fFindVertexForCascades),
 fMassCutBeforeVertexing(source.fMassCutBeforeVertexing),
 fMassCalc2(source.fMassCalc2),
 fMassCalc3(source.fMassCalc3),
-fMassCalc4(source.fMassCalc4)
+fMassCalc4(source.fMassCalc4),
+fnTrksTotal(0),
+fnSeleTrksTotal(0)
 {
   //
   // Copy constructor
@@ -403,6 +407,7 @@ void AliAnalysisVertexingHF::FindCandidates(AliVEvent *event,
 
   trkEntries = (Int_t)event->GetNumberOfTracks();
   AliDebug(1,Form(" Number of tracks: %d",trkEntries));
+  fnTrksTotal += trkEntries;
 
   nv0 = (Int_t)event->GetNumberOfV0s();
   AliDebug(1,Form(" Number of V0s: %d",nv0));
@@ -425,6 +430,7 @@ void AliAnalysisVertexingHF::FindCandidates(AliVEvent *event,
   SelectTracksAndCopyVertex(event,trkEntries,seleTrksArray,nSeleTrks,seleFlags,evtNumber);
     
   AliDebug(1,Form(" Selected tracks: %d",nSeleTrks));
+  fnSeleTrksTotal += nSeleTrks;
     
   TObjArray *twoTrackArray1    = new TObjArray(2);
   TObjArray *twoTrackArray2    = new TObjArray(2);
@@ -1160,6 +1166,8 @@ void AliAnalysisVertexingHF::FindCandidates(AliVEvent *event,
     if(fAODMap) { delete fAODMap; fAODMap=NULL; }
   }
 
+  //printf("Trks: total %d  sele %d\n",fnTrksTotal,fnSeleTrksTotal);
+
   return;
 }
 //----------------------------------------------------------------------------
@@ -1461,9 +1469,13 @@ AliAODRecoDecayHF2Prong *AliAnalysisVertexingHF::Make2Prong(
 
  
   if(postrack->Charge()!=0 && negtrack->Charge()!=0) { // don't apply these cuts if it's a Dstar 
+
+    // Add daughter references already here
+    if(fInputAOD) AddDaughterRefs(secVert,(AliAODEvent*)event,twoTrackArray);
+
     // select D0->Kpi
     if(fD0toKpi)   {
-      okD0 = (Bool_t)fCutsD0toKpi->IsSelected(the2Prong,AliRDHFCuts::kCandidate);
+      okD0 = (Bool_t)fCutsD0toKpi->IsSelected(the2Prong,AliRDHFCuts::kCandidate,(AliAODEvent*)event);
       if(okD0) the2Prong->SetSelectionBit(AliRDHFCuts::kD0toKpiCuts);
     }
     //if(fDebug && fD0toKpi) printf("   %d\n",(Int_t)okD0);
@@ -1572,19 +1584,22 @@ AliAODRecoDecayHF3Prong* AliAnalysisVertexingHF::Make3Prong(
 
   delete primVertexAOD; primVertexAOD=NULL;
 
+  // Add daughter references already here
+  if(fInputAOD) AddDaughterRefs(secVert,(AliAODEvent*)event,threeTrackArray);
+
   // select D+->Kpipi, Ds->KKpi, Lc->pKpi
   if(f3Prong) {
     ok3Prong = kFALSE;
     
-    if(fCutsDplustoKpipi->IsSelected(the3Prong,AliRDHFCuts::kCandidate)) {
+    if(fCutsDplustoKpipi->IsSelected(the3Prong,AliRDHFCuts::kCandidate,(AliAODEvent*)event)) {
       ok3Prong = kTRUE;
       the3Prong->SetSelectionBit(AliRDHFCuts::kDplusCuts);
     }
-    if(fCutsDstoKKpi->IsSelected(the3Prong,AliRDHFCuts::kCandidate)) {
+    if(fCutsDstoKKpi->IsSelected(the3Prong,AliRDHFCuts::kCandidate,(AliAODEvent*)event)) {
       ok3Prong = kTRUE;
       the3Prong->SetSelectionBit(AliRDHFCuts::kDsCuts);
     }
-    if(fCutsLctopKpi->IsSelected(the3Prong,AliRDHFCuts::kCandidate)) {
+    if(fCutsLctopKpi->IsSelected(the3Prong,AliRDHFCuts::kCandidate,(AliAODEvent*)event)) {
       ok3Prong = kTRUE;
       the3Prong->SetSelectionBit(AliRDHFCuts::kLcCuts);
     } 
index 46d2884..d86659a 100644 (file)
@@ -172,6 +172,10 @@ class AliAnalysisVertexingHF : public TNamed {
   AliAODRecoDecay *fMassCalc2; // for 2 prong
   AliAODRecoDecay *fMassCalc3; // for 3 prong
   AliAODRecoDecay *fMassCalc4; // for 4 prong
+
+  Int_t fnTrksTotal;
+  Int_t fnSeleTrksTotal;
+
   //
   void AddRefs(AliAODVertex *v,AliAODRecoDecayHF *rd,const AliVEvent *event,
               const TObjArray *trkArray) const;
index 4cd1b0e..4070086 100644 (file)
@@ -83,7 +83,8 @@ fFixRefs(kFALSE),
 fIsSelectedCuts(0),
 fIsSelectedPID(0),
 fMinPtCand(-1.),
-fMaxPtCand(100000.)
+fMaxPtCand(100000.),
+fKeepSignalMC(kFALSE)
 {
   //
   // Default Constructor
@@ -127,7 +128,8 @@ AliRDHFCuts::AliRDHFCuts(const AliRDHFCuts &source) :
   fIsSelectedCuts(source.fIsSelectedCuts),
   fIsSelectedPID(source.fIsSelectedPID),
   fMinPtCand(source.fMinPtCand),
-  fMaxPtCand(source.fMaxPtCand)
+  fMaxPtCand(source.fMaxPtCand),
+  fKeepSignalMC(source.fKeepSignalMC)
 {
   //
   // Copy constructor
@@ -181,6 +183,7 @@ AliRDHFCuts &AliRDHFCuts::operator=(const AliRDHFCuts &source)
   fIsSelectedPID=source.fIsSelectedPID;
   fMinPtCand=source.fMinPtCand;
   fMaxPtCand=source.fMaxPtCand;
+  fKeepSignalMC=source.fKeepSignalMC;
 
   if(source.GetTrackCuts()) AddTrackCuts(source.GetTrackCuts());
   if(source.fPtBinLimits) SetPtBins(source.fnPtBinLimits,source.fPtBinLimits);
@@ -941,6 +944,29 @@ void AliRDHFCuts::CleanOwnPrimaryVtx(AliAODRecoDecayHF *d,
   }
   return;
 }
+//--------------------------------------------------------------------------
+Bool_t AliRDHFCuts::IsSignalMC(AliAODRecoDecay *d,AliAODEvent *aod,Int_t pdg) const 
+{
+  //
+  // Checks if this candidate is matched to MC signal
+  // 
+
+  if(!aod) return kFALSE;
+
+  // get the MC array
+  TClonesArray *mcArray = (TClonesArray*)((AliAODEvent*)aod)->GetList()->FindObject(AliAODMCParticle::StdBranchName());
 
+  if(!mcArray) return kFALSE;
+
+  // try to match  
+  Int_t label = d->MatchToMC(pdg,mcArray);
+  
+  if(label>=0) {
+    //printf("MATCH!\n");
+    return kTRUE;
+  }
+
+  return kFALSE;
+}
 
 
index 907d664..84731c0 100644 (file)
@@ -165,12 +165,14 @@ class AliRDHFCuts : public AliAnalysisCuts
   Bool_t CountEventForNormalization() const 
   { if(fWhyRejection==0) {return kTRUE;} else {return kFALSE;} }
 
+  void SetKeepSignalMC() {fKeepSignalMC=kTRUE; return;}
 
  protected:
 
   void SetNPtBins(Int_t nptBins){fnPtBins=nptBins;}
   void SetNVars(Int_t nVars){fnVars=nVars;}
 
+  Bool_t IsSignalMC(AliAODRecoDecay *d,AliAODEvent *aod,Int_t pdg) const;
 
   // cuts on the event
   Int_t fMinVtxType; // 0: not cut; 1: SPDZ; 2: SPD3D; 3: Tracks
@@ -215,8 +217,9 @@ class AliRDHFCuts : public AliAnalysisCuts
   Int_t  fIsSelectedPID;  // outcome of PID selection
   Double_t fMinPtCand; // minimum pt of the candidate
   Double_t fMaxPtCand; // minimum pt of the candidate
+  Bool_t  fKeepSignalMC; // IsSelected returns always kTRUE for MC signal
 
-  ClassDef(AliRDHFCuts,16);  // base class for cuts on AOD reconstructed heavy-flavour decays
+  ClassDef(AliRDHFCuts,17);  // base class for cuts on AOD reconstructed heavy-flavour decays
 };
 
 #endif
index 5729b60..899f8df 100644 (file)
@@ -246,6 +246,8 @@ Int_t AliRDHFCutsD0toKpi::IsSelected(TObject* obj,Int_t selectionLevel,AliAODEve
     return 0;
   }
 
+  if(fKeepSignalMC) if(IsSignalMC(d,aod,421)) return 3;
+
   Double_t ptD=d->Pt();
   if(ptD<fMinPtCand) return 0;
   if(ptD>fMaxPtCand) return 0;
index a098c24..29625a4 100644 (file)
@@ -352,6 +352,8 @@ Int_t AliRDHFCutsDplustoKpipi::IsSelected(TObject* obj,Int_t selectionLevel, Ali
     return 0;
   }
 
+  if(fKeepSignalMC) if(IsSignalMC(d,aod,411)) return 3;
+
   // PID selection
   Int_t returnvaluePID=3;
   Int_t returnvalueCuts=3;
index f7c09f5..a26d046 100644 (file)
@@ -373,6 +373,8 @@ Int_t AliRDHFCutsDstoKKpi::IsSelected(TObject* obj,Int_t selectionLevel, AliAODE
     return 0;
   }
  
+  if(fKeepSignalMC) if(IsSignalMC(d,aod,431)) return 3;
+
   Double_t ptD=d->Pt();
   if(ptD<fMinPtCand) return 0;
   if(ptD>fMaxPtCand) return 0;
index 2bf3334..06c3dfd 100644 (file)
@@ -247,6 +247,7 @@ Int_t AliRDHFCutsLctopKpi::IsSelected(TObject* obj,Int_t selectionLevel,AliAODEv
   }
 
 
+  if(fKeepSignalMC) if(IsSignalMC(d,aod,4122)) return 3;
 
   Int_t returnvalue=3;
   Int_t returnvaluePID=3;