Possibility to select only D0 from B + protections (Zaida), added fiducial acc cut...
authordainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 24 Jul 2010 02:58:02 +0000 (02:58 +0000)
committerdainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 24 Jul 2010 02:58:02 +0000 (02:58 +0000)
PWG3/vertexingHF/AliAnalysisTaskSED0Mass.cxx
PWG3/vertexingHF/AliCFHeavyFlavourTaskMultiVarMultiStep.cxx
PWG3/vertexingHF/AliCFHeavyFlavourTaskMultiVarMultiStep.h
PWG3/vertexingHF/macros/AddTaskCFMultiVarMultiStep.C

index b1bb033..75de221 100644 (file)
@@ -604,6 +604,10 @@ void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
   
   // AOD primary vertex
   AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
+  if(!vtx1) { 
+    AliError("There is no primary vertex !"); 
+    return; 
+  }
 
   Bool_t isGoodVtx=kFALSE;
 
index 2232c3c..4409c8f 100644 (file)
@@ -76,6 +76,7 @@ AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep()
        fMinITSClusters(5),
         fAcceptanceUnf(kTRUE),
        fKeepD0fromB(kFALSE),
+       fKeepD0fromBOnly(kFALSE),
        fCuts(0)
 {
        //
@@ -103,6 +104,7 @@ AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep(c
        fMinITSClusters(5),
         fAcceptanceUnf(kTRUE),
        fKeepD0fromB(kFALSE),
+        fKeepD0fromBOnly(kFALSE),
        fCuts(cuts)
 {
        //
@@ -157,6 +159,7 @@ AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep(c
        fMinITSClusters(c.fMinITSClusters),
         fAcceptanceUnf(c.fAcceptanceUnf),
        fKeepD0fromB(c.fKeepD0fromB),
+        fKeepD0fromBOnly(c.fKeepD0fromBOnly),
        fCuts(c.fCuts)
 {
        //
@@ -172,7 +175,7 @@ AliCFHeavyFlavourTaskMultiVarMultiStep::~AliCFHeavyFlavourTaskMultiVarMultiStep(
        if (fCFManager)           delete fCFManager ;
        if (fHistEventsProcessed) delete fHistEventsProcessed ;
         if (fCorrelation) delete fCorrelation ;
-        if (fCuts) delete fCuts ;
+       //        if (fCuts) delete fCuts ;
 }
 
 //_________________________________________________
@@ -197,6 +200,12 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                return;
        }
        
+       // check that the fKeepD0fromB flag is set to true when the fKeepD0fromBOnly flag is true
+       if(fKeepD0fromBOnly) { 
+         fKeepD0fromB=true;   
+         if(fEvents<2) AliInfo(Form("Both fKeepD0fromB and fKeepD0fromBOnly flags are true, looking _ONLY_ at D0 FROM B"));
+       }
+
        fEvents++;
        if (fEvents%10000 ==0) AliDebug(2,Form("Event %d",fEvents));
        AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
@@ -261,6 +270,10 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                
        // AOD primary vertex
        AliAODVertex *vtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex();
+       if(!vtx1) { 
+         AliError("There is no primary vertex !"); 
+         return; 
+       }
        Double_t zPrimVertex = vtx1->GetZ();
        Double_t zMCVertex = mcHeader->GetVtxZ();
        Bool_t vtxFlag = kTRUE;
@@ -285,6 +298,7 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                        AliDebug(2,Form("Particle has a b-meson, or b-baryon mother (pdg code mother = %d )--> not coming from a c-quark, skipping...", pdgGranma));
                        if (!fKeepD0fromB) continue;  // skipping particles that don't come from c quark
                }
+               else { if(fKeepD0fromBOnly) continue; } // skipping particles that don't come from b quark
                
                //              if (TMath::Abs(pdgGranma)!=4) {
 
@@ -304,6 +318,7 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                        containerInputMC[10] = 1.01;    // dummy value, meaningless in MC
                        containerInputMC[11] = vectorMC[6];    // dummy value, meaningless in MC
                        containerInputMC[12] = zMCVertex;    // z of reconstructed of primary vertex
+                       if (!fCuts->IsInFiducialAcceptance(vectorMC[0],vectorMC[1])) continue;
                        if (TMath::Abs(vectorMC[1]) < 0.5) {
                                fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepGeneratedLimAcc);
                        }
@@ -326,6 +341,7 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                        AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughter1));
                        if (!mcPartDaughter0 || !mcPartDaughter1) {
                                AliWarning("At least one Daughter Particle not found in tree, but it should be, this check was already done..."); 
+                               continue;
                        }
                        Double_t eta0 = mcPartDaughter0->Eta();
                        Double_t eta1 = mcPartDaughter1->Eta();
@@ -422,6 +438,7 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
        for (Int_t iD0toKpi = 0; iD0toKpi<arrayD0toKpi->GetEntriesFast(); iD0toKpi++) {
                
                AliAODRecoDecayHF2Prong* d0tokpi = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->At(iD0toKpi);
+               if(!d0tokpi) continue;
                Bool_t unsetvtx=kFALSE;
                if(!d0tokpi->GetOwnPrimaryVtx()) {
                  d0tokpi->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
@@ -433,6 +450,7 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                if (mcLabel == -1) 
                        {
                                AliDebug(2,"No MC particle found");
+                               continue;
                        }
                else {
                        AliAODMCParticle* mcVtxHF = (AliAODMCParticle*)mcArray->At(mcLabel);
@@ -443,6 +461,10 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                        // check whether the daughters have kTPCrefit and kITSrefit set
                        AliAODTrack *track0 = (AliAODTrack*)d0tokpi->GetDaughter(0);
                        AliAODTrack *track1 = (AliAODTrack*)d0tokpi->GetDaughter(1);
+                       if( !track0 || !track1 ) {
+                         AliWarning("Could not find associated MC daughter tracks in AOD MC tree");
+                         continue;
+                       }
                        if ((trackCuts->GetRequireTPCRefit() && (!(track0->GetStatus()&AliESDtrack::kTPCrefit) || !(track1->GetStatus()&AliESDtrack::kTPCrefit))) || 
                            (trackCuts->GetRequireITSRefit() && (!(track0->GetStatus()&AliESDtrack::kITSrefit) || !(track1->GetStatus()&AliESDtrack::kITSrefit)))){
                                // skipping if at least one daughter does not have kTPCrefit or kITSrefit, if they were required
@@ -473,6 +495,7 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                                AliDebug(2,Form("At Reco level, from MC info: Particle has a b-meson, or b-baryon mother (pdg code mother = %d )--> not coming from a c-quark, skipping...", pdgGranma));
                                if (!fKeepD0fromB) continue;  // skipping particles that don't come from c quark
                        }
+                       else { if(fKeepD0fromBOnly) continue; } // skipping particles that don't come from b quark
 
                        // fill the container...
                        Double_t pt = d0tokpi->Pt();
@@ -547,6 +570,8 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                                }
                        }
 
+                       if (!fCuts->IsInFiducialAcceptance(containerInput[0],containerInput[1])) continue; // fiducial region
+
                        AliDebug(2, Form("Filling the container with pt = %f, rapidity = %f, cosThetaStar = %f, pTpi = %f, pTK = %f, cT = %f", containerInput[0], containerInput[1], containerInput[2], containerInput[3], containerInput[4], containerInput[5]));
                        icountReco++;
                        printf("%d: filling RECO step\n",iD0toKpi);
@@ -1053,7 +1078,11 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::Terminate(Option_t*)
         corr2->Draw("text");
       
 
-       TFile* file_projection = new TFile("CFtaskHFprojection.root","RECREATE");
+       TString projection_filename="CFtaskHFprojection";
+       if(fKeepD0fromBOnly) projection_filename+="_KeepD0fromBOnly";
+       else if(fKeepD0fromB) projection_filename+="_KeepD0fromB";
+       projection_filename+=".root";
+       TFile* file_projection = new TFile(projection_filename.Data(),"RECREATE");
 
         corr1->Write();
         corr2->Write();
index 7d53f34..0c5b11f 100644 (file)
@@ -83,6 +83,7 @@ class AliCFHeavyFlavourTaskMultiVarMultiStep : public AliAnalysisTaskSE {
   Int_t    CheckOrigin(AliAODMCParticle* mcPart, TClonesArray* mcArray) const;
 
   void SetKeepD0fromB(Bool_t keepD0fromB){fKeepD0fromB=keepD0fromB;}
+  void SetKeepD0fromBOnly(Bool_t keepD0fromBOnly){ fKeepD0fromBOnly=keepD0fromBOnly; }
 
  protected:
   Int_t           fPDG;         //  PDG code of searched V0's
@@ -105,9 +106,10 @@ class AliCFHeavyFlavourTaskMultiVarMultiStep : public AliAnalysisTaskSE {
   Bool_t fAcceptanceUnf;        //  flag for unfolding before or after cuts.
 
   Bool_t fKeepD0fromB;          // flag to consider also D0 coming from B
+  Bool_t fKeepD0fromBOnly;      // flag to consider _only_ D0 coming from B
   AliRDHFCutsD0toKpi* fCuts;    // cuts
   
-  ClassDef(AliCFHeavyFlavourTaskMultiVarMultiStep,4); // class for HF corrections as a function of many variables
+  ClassDef(AliCFHeavyFlavourTaskMultiVarMultiStep,5); // class for HF corrections as a function of many variables
 };
 
 #endif
index 8fe49b6..73d7995 100644 (file)
@@ -35,37 +35,41 @@ const Int_t    minITSClusters = 5;
 
 //----------------------------------------------------
 
-AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* cutFile = "../cut_files/D0toKpiCutsTGH.root",Bool_t isKeepD0fromB=kFALSE)
+AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* cutFile = "./D0toKpiCuts.root",Bool_t isKeepD0fromB=kFALSE, Bool_t isKeepD0fromBOnly=kFALSE)
 {
-       printf("Addig CF task using cuts from file %s\n",cutFile);
-
-       TFile* fileCuts = new TFile(cutFile);
-       AliRDHFCutsD0toKpi *cutsD0toKpi = (AliRDHFCutsD0toKpi*)fileCuts->Get("D0toKpiCuts");
-
-       /*
-         Double_t ptmin_0_4;
-         Double_t ptmax_0_4;
-         Double_t ptmin_4_8;
-         Double_t ptmax_4_8;
-         Double_t ptmin_8_10;
-         Double_t ptmax_8_10;
-         
-         if(!isKeepD0fromB){
-         ptmin_0_4 =  0.0 ;
-         ptmax_0_4 =  4.0 ;
-         ptmin_4_8 =  4.0 ;
-         ptmax_4_8 =  8.0 ;
-         ptmin_8_10 =  8.0 ;
-         ptmax_8_10 =  10.0 ;
-         } else{
-         ptmin_0_4 =  0.0 ;
-         ptmax_0_4 =  3.0 ;
-         ptmin_4_8 =  3.0 ;
-         ptmax_4_8 =  5.0 ;
-         ptmin_8_10 =  5.0 ;
-         ptmax_8_10 =  10.0 ;
-         }
-       */
+  printf("Adding CF task using cuts from file %s\n",cutFile);
+  
+  TFile* fileCuts = new TFile(cutFile);
+  AliRDHFCutsD0toKpi *cutsD0toKpi = (AliRDHFCutsD0toKpi*)fileCuts->Get("D0toKpiCuts");
+
+  // check that the fKeepD0fromB flag is set to true when the fKeepD0fromBOnly flag is true
+  //  for now the binning is the same than for all D's
+  if(isKeepD0fromBOnly) isKeepD0fromB = true;
+
+  /*
+    Double_t ptmin_0_4;
+    Double_t ptmax_0_4;
+    Double_t ptmin_4_8;
+    Double_t ptmax_4_8;
+    Double_t ptmin_8_10;
+    Double_t ptmax_8_10;
+    
+    if(!isKeepD0fromB){
+    ptmin_0_4 =  0.0 ;
+    ptmax_0_4 =  4.0 ;
+    ptmin_4_8 =  4.0 ;
+    ptmax_4_8 =  8.0 ;
+    ptmin_8_10 =  8.0 ;
+    ptmax_8_10 =  10.0 ;
+    } else{
+    ptmin_0_4 =  0.0 ;
+    ptmax_0_4 =  3.0 ;
+    ptmin_4_8 =  3.0 ;
+    ptmax_4_8 =  5.0 ;
+    ptmin_8_10 =  5.0 ;
+    ptmax_8_10 =  10.0 ;
+    }
+  */
 
        //CONTAINER DEFINITION
        Info("AliCFHeavyFlavourTaskMultiVarMultiStep","SETUP CONTAINER");
@@ -266,6 +270,9 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
        if(!isKeepD0fromB) {
          nameContainer="CFHFccontainer0";
        }
+       else if(isKeepD0fromBOnly){
+         nameContainer="CFHFccontainer0D0fromB";
+       }
        else  {
          nameContainer="CFHFccontainer0allD0";
 
@@ -309,7 +316,7 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
         container -> SetStepTitle(6, "RecoAcc");
        container -> SetStepTitle(7, "RecoITSCluster");
        container -> SetStepTitle(8, "RecoCuts");
-       container -> SetStepTitle(8, "RecoPID");
+       container -> SetStepTitle(9, "RecoPID");
 
         container -> SetVarTitle(ipt,"pt");
        container -> SetVarTitle(iy,"y");
@@ -396,6 +403,7 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
        task->SetMinITSClusters(minITSClusters);
        task->SetCFManager(man); //here is set the CF manager
        task->SetKeepD0fromB(isKeepD0fromB);
+       task->SetKeepD0fromBOnly(isKeepD0fromBOnly);
        
         //-----------------------------------------------------------//
         //   create correlation matrix for unfolding - only eta-pt   //
@@ -417,6 +425,9 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
        if(!isKeepD0fromB) {
          nameCorr="CFHFcorr0";
        }
+       else if(isKeepD0fromBOnly){
+         nameCorr= "CFHFcorr0KeepD0fromBOnly";
+       }
        else  {
          nameCorr="CFHFcorr0allD0";
 
@@ -458,6 +469,10 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
          outputfile += ":PWG3_D2H_CFtaskD0toKpi";
          output1name="CFHFchist0";
        }
+       else if(isKeepD0fromBOnly){
+         outputfile += ":PWG3_D2H_CFtaskD0toKpiKeepD0fromBOnly";
+         output1name="CFHFchist0D0fromB";
+       }
        else  {
          outputfile += ":PWG3_D2H_CFtaskD0toKpiKeepD0fromB";
          output1name="CFHFchist0allD0";