Selection of prompt or feed-down as in the CF task (Giacomo)
authordainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 6 Jun 2011 11:08:11 +0000 (11:08 +0000)
committerdainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 6 Jun 2011 11:08:11 +0000 (11:08 +0000)
PWG3/vertexingHF/AliAnalysisTaskSESignificance.cxx
PWG3/vertexingHF/AliAnalysisTaskSESignificance.h
PWG3/vertexingHF/macros/AddTaskSignificance.C

index 73a1144..26ec831 100644 (file)
@@ -73,6 +73,7 @@ AliAnalysisTaskSESignificance::AliAnalysisTaskSESignificance():
   fRDCuts(0),
   fNPtBins(0),
   fReadMC(kFALSE),
+  fUseSelBit(kFALSE),
   fBFeedDown(kBoth),
   fDecChannel(0),
   fPDGmother(0),
@@ -100,6 +101,7 @@ AliAnalysisTaskSESignificance::AliAnalysisTaskSESignificance(const char *name, T
   fRDCuts(rdCuts),
   fNPtBins(0),
   fReadMC(kFALSE),
+  fUseSelBit(kFALSE),
   fBFeedDown(kBoth),
   fDecChannel(decaychannel),
   fPDGmother(0),
@@ -516,12 +518,34 @@ void AliAnalysisTaskSESignificance::UserExec(Option_t */*option*/)
     fPDGDStarToD0pi[0] = 421; fPDGDStarToD0pi[1] = 211;
     fPDGD0ToKpi[0] = 321; fPDGD0ToKpi[1] = 211;
 
+    Bool_t isSelBit=kTRUE;
+    if(fUseSelBit){
+      if(fDecChannel==0) {
+       isSelBit=d->HasSelectionBit(AliRDHFCuts::kDplusCuts);
+      }else{ 
+       if(fDecChannel==1) {
+         isSelBit=d->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts);
+       }else{
+         if(fDecChannel==2) {
+           isSelBit=d->HasSelectionBit(AliRDHFCuts::kDstarCuts);
+         }else{
+           if(fDecChannel==3) {
+             isSelBit=d->HasSelectionBit(AliRDHFCuts::kDsCuts);
+           }else{
+             if(fDecChannel==5) isSelBit=d->HasSelectionBit(AliRDHFCuts::kLcCuts);
+           }
+         }
+       }
+      }
+    }
+    if(!isSelBit) continue; 
+
     if (fDecChannel==2) {
       DStarToD0pi = (AliAODRecoCascadeHF*)arrayProng->At(iProng);
       if (!DStarToD0pi->GetSecondaryVtx()) continue;
       D0Particle = (AliAODRecoDecayHF2Prong*)DStarToD0pi->Get2Prong();
       if (!D0Particle) continue;
-      }
+    }
     
     Bool_t isFidAcc = fRDCuts->IsInFiducialAcceptance(d->Pt(),d->Y(fPDGmother));
     Int_t isSelected=fRDCuts->IsSelected(d,fSelectionlevel,aod);
@@ -530,26 +554,22 @@ void AliAnalysisTaskSESignificance::UserExec(Option_t */*option*/)
       Int_t labD = d->MatchToMC(fPDGmother,arrayMC,fNProngs,fPDGdaughters);
       if(labD>=0){
        AliAODMCParticle *partD = (AliAODMCParticle*)arrayMC->At(labD);
-       Int_t label=partD->GetMother();
-       AliAODMCParticle *mot = (AliAODMCParticle*)arrayMC->At(label);
-       while(label>=0){//get first mother
-         mot = (AliAODMCParticle*)arrayMC->At(label);
-         label=mot->GetMother();
-       }
-       Int_t pdgMotCode = mot->GetPdgCode();
-       
-       if(TMath::Abs(pdgMotCode)<=4){
-         fHistNEvents->Fill(6);
-         if(fBFeedDown==kBeautyOnly)isSelected=kFALSE; //from primary charm
-       }else{
+       Int_t pdgGranma = CheckOrigin(partD, arrayMC);
+       Int_t abspdgGranma = TMath::Abs(pdgGranma);
+       if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
+         //feed down particle
+         AliDebug(2,Form("Particle has a b-meson, or b-baryon mother (pdg code mother = %d )--> not coming from a c-quark, skipping...", pdgGranma));
          fHistNEvents->Fill(7);
          if(fBFeedDown==kCharmOnly) isSelected=kFALSE; //from beauty
        }
-       
+       else { 
+         //prompt particle
+         fHistNEvents->Fill(6);
+         if(fBFeedDown==kBeautyOnly)isSelected=kFALSE;
+       } 
       }
     }
     
-
     if(isSelected&&isFidAcc) {
       fHistNEvents->Fill(2); // count selected with loosest cuts
       if(fDebug>1) printf("+++++++Is Selected\n");
@@ -989,4 +1009,30 @@ void AliAnalysisTaskSESignificance::Terminate(Option_t */*option*/)
   
   return;
 }
-//-------------------------------------------
+//_________________________________________________________________________________________________
+Int_t AliAnalysisTaskSESignificance::CheckOrigin(const AliAODMCParticle* mcPart, const TClonesArray* mcArray)const{
+
+       //
+       // checking whether the very mother of the D0 is a charm or a bottom quark
+       //
+
+       Int_t pdgGranma = 0;
+       Int_t mother = 0;
+       mother = mcPart->GetMother();
+       Int_t istep = 0;
+       while (mother >0 ){
+               istep++;
+               AliDebug(2,Form("mother at step %d = %d", istep, mother));
+               AliAODMCParticle* mcGranma = dynamic_cast<AliAODMCParticle*>(mcArray->At(mother));
+               if(!mcGranma) break;
+               pdgGranma = mcGranma->GetPdgCode();
+               AliDebug(2,Form("Pdg mother at step %d = %d", istep, pdgGranma));
+               Int_t abspdgGranma = TMath::Abs(pdgGranma);
+               if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
+                       break;
+               }
+               mother = mcGranma->GetMother();
+       }
+       return pdgGranma;
+}
+//_________________________________________________________________________________________________
index a4df84f..7a7d6c0 100644 (file)
@@ -44,6 +44,7 @@ class AliAnalysisTaskSESignificance : public AliAnalysisTaskSE
   void SetNBins(Int_t nbins){fNBins=nbins;}
   void SetFillWithPartAntiPartBoth(Int_t value){fPartOrAndAntiPart=value;}
   void SetDsChannel(Int_t chan){fDsChannel=chan;}
+  void SetUseSelBit(Bool_t selBit=kTRUE){fUseSelBit=selBit;}
 
   //void SetMultiVector(const AliMultiDimVector *MultiDimVec){fMultiDimVec->CopyStructure(MultiDimVec);}
   Float_t GetUpperMassLimit()const {return fUpmasslimit;}
@@ -52,6 +53,7 @@ class AliAnalysisTaskSESignificance : public AliAnalysisTaskSE
   Int_t GetFillWithPartAntiPartBoth()const {return fPartOrAndAntiPart;}
   Int_t GetBFeedDown()const {return fBFeedDown;}
   Int_t GetDsChannel()const {return fDsChannel;}
+  Bool_t GetUseSelBit()const {return fUseSelBit;}
 
   // Implementation of interface methods
   virtual void UserCreateOutputObjects();
@@ -81,7 +83,7 @@ class AliAnalysisTaskSESignificance : public AliAnalysisTaskSE
   Int_t GetSignalHistoIndex(Int_t iPtBin) const { return iPtBin*3+1;}
   Int_t GetBackgroundHistoIndex(Int_t iPtBin) const { return iPtBin*3+2;}
   Int_t GetLSHistoIndex(Int_t iPtBin)const { return iPtBin*5;}
-
+  Int_t CheckOrigin(const AliAODMCParticle* mcPart, const TClonesArray* mcArray) const;
 
   void FillDplus(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index,Int_t isSel);
   void FillD02p(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index, Int_t isSel);
@@ -109,6 +111,7 @@ class AliAnalysisTaskSESignificance : public AliAnalysisTaskSE
   AliRDHFCuts *fRDCuts;//prong cut values
   Int_t fNPtBins; //number of pt bins
   Bool_t fReadMC;    //flag for access to MC
+  Bool_t fUseSelBit;    //flag to use selection bit (speed up candidates selection)
   FeedDownEnum fBFeedDown; //flag to search for D from B decays
   Int_t fDecChannel; //decay channel identifier
   Int_t fPDGmother;  // PDG code of D meson
@@ -124,7 +127,7 @@ class AliAnalysisTaskSESignificance : public AliAnalysisTaskSE
   Int_t fPDGDStarToD0pi[2]; //PDG codes for the particles in the D* -> pi + D0 decay
   Int_t fPDGD0ToKpi[2];    //PDG codes for the particles in the D0 -> K + pi decay
 
-  ClassDef(AliAnalysisTaskSESignificance,4); // AliAnalysisTaskSE for the MC association of heavy-flavour decay candidates
+  ClassDef(AliAnalysisTaskSESignificance,5); // AliAnalysisTaskSE for the MC association of heavy-flavour decay candidates
 };
 
 #endif
index fbf3db4..f0ba8eb 100644 (file)
@@ -123,10 +123,10 @@ AliAnalysisTaskSESignificance *AddTaskSignificance(TString filename="cuts4Signif
   
   AliAnalysisTaskSESignificance *sigTask = new AliAnalysisTaskSESignificance("SignificanceAnalysis",listMDV,analysiscuts,decCh,AliRDHFCuts::kAll);//AliRDHFCuts::kCandidate
   sigTask->SetReadMC(readMC);
-  //sigTask->SetDoLikeSign(kTRUE);
   sigTask->SetBFeedDown(fromcb);
-  sigTask->SetDebugLevel(3);
+  sigTask->SetDebugLevel(0);
   sigTask->SetFillWithPartAntiPartBoth(flagOPartAntiPart);
+  sigTask->SetUseSelBit(kTRUE);
   mgr->AddTask(sigTask);
 
   TString contname=Form("cinputSig%s",suffix.Data());