1- Storing in the output of the cuts object
authordainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 15 Sep 2010 20:05:23 +0000 (20:05 +0000)
committerdainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 15 Sep 2010 20:05:23 +0000 (20:05 +0000)
   2- Implementation of the candidate selection at the Analysis Cuts level taking into account the reflections, and switching off the PID, and including the modification Andrea mentioned this morning
   3- Implementation of the PID step in the "correct" way (including all the selection levels)
   4- Possibility to fill the container using weights
ChiaraZ

PWG3/vertexingHF/AliCFHeavyFlavourTaskMultiVarMultiStep.cxx
PWG3/vertexingHF/AliCFHeavyFlavourTaskMultiVarMultiStep.h
PWG3/vertexingHF/macros/AddTaskCFMultiVarMultiStep.C

index d4ccbfe..37f0fbb 100644 (file)
@@ -54,6 +54,8 @@
 #include "TChain.h"
 #include "THnSparse.h"
 #include "TH2D.h"
+#include "AliAnalysisDataSlot.h"
+#include "AliAnalysisDataContainer.h"
 
 //__________________________________________________________________________
 AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep() :
@@ -77,7 +79,9 @@ AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep()
         fAcceptanceUnf(kTRUE),
        fKeepD0fromB(kFALSE),
        fKeepD0fromBOnly(kFALSE),
-       fCuts(0)
+       fCuts(0),
+       fUseWeight(kFALSE),
+       fWeight(1.)
 {
        //
        //Default ctor
@@ -105,7 +109,9 @@ AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep(c
         fAcceptanceUnf(kTRUE),
        fKeepD0fromB(kFALSE),
         fKeepD0fromBOnly(kFALSE),
-       fCuts(cuts)
+       fCuts(cuts),
+       fUseWeight(kFALSE),
+       fWeight(1.)
 {
        //
        // Constructor. Initialization of Inputs and Outputs
@@ -118,6 +124,7 @@ AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep(c
        DefineOutput(1,TH1I::Class());
        DefineOutput(2,AliCFContainer::Class());
         DefineOutput(3,THnSparseD::Class());
+        DefineOutput(4,AliRDHFCutsD0toKpi::Class());
 
        fCuts->PrintAll();
 }
@@ -160,7 +167,9 @@ AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep(c
         fAcceptanceUnf(c.fAcceptanceUnf),
        fKeepD0fromB(c.fKeepD0fromB),
         fKeepD0fromBOnly(c.fKeepD0fromBOnly),
-       fCuts(c.fCuts)
+       fCuts(c.fCuts),
+       fUseWeight(c.fUseWeight),
+       fWeight(c.fWeight)
 {
        //
        // Copy Constructor
@@ -178,6 +187,24 @@ AliCFHeavyFlavourTaskMultiVarMultiStep::~AliCFHeavyFlavourTaskMultiVarMultiStep(
        //        if (fCuts) delete fCuts ;
 }
 
+//________________________________________________________________________
+void AliCFHeavyFlavourTaskMultiVarMultiStep::Init(){
+
+       //
+       // Initialization
+       //
+
+       if(fDebug > 1) printf("AliCFHeavyFlavourTaskMultiVarMultiStep::Init() \n");
+       
+       AliRDHFCutsD0toKpi* copyfCuts=new AliRDHFCutsD0toKpi(*fCuts);
+       const char* nameoutput=GetOutputSlot(4)->GetContainer()->GetName();
+       copyfCuts->SetName(nameoutput);
+       // Post the data
+       PostData(4,copyfCuts);
+       
+       return;
+}
+
 //_________________________________________________
 void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
 {
@@ -322,11 +349,13 @@ 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 (fUseWeight) fWeight = GetWeight(vectorMC[0]); // setting the weight according to the function defined in AliCFHeavyFlavourTaskMultiVarMultiStep::GetWeight(Float_t pt)
+                       AliDebug(3,Form("weight = %f",fWeight));
                        if (!fCuts->IsInFiducialAcceptance(vectorMC[0],vectorMC[1])) continue;
                        if (TMath::Abs(vectorMC[1]) < 0.5) {
-                               fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepGeneratedLimAcc);
+                               fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepGeneratedLimAcc,fWeight);
                        }
-                       fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepGenerated);
+                       fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepGenerated,fWeight);
                        icountMC++;
 
                        // check the MC-Acceptance level cuts
@@ -366,14 +395,14 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                                if (!fCFManager->CheckParticleCuts(1, mcPartDaughter1)) {
                                        AliDebug(2,"Inconsistency with CF cut for daughter 1!");
                                } 
-                               fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepAcceptance);
+                               fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepAcceptance,fWeight);
                                icountAcc++;
 
                                // check on the vertex
                                if (fCuts->IsEventSelected(aodEvent)){
                                        AliDebug(2,"Vertex cut passed\n");
                                        // filling the container if the vertex is ok
-                                       fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepVertex) ;
+                                       fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepVertex,fWeight) ;
                                        icountVertex++;
                                        // check on the kTPCrefit and kITSrefit conditions of the daughters
                                        Bool_t refitFlag = kTRUE;
@@ -400,10 +429,11 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                                                                break;
                                                        }
                                                }
+                                               if (foundDaughters != 2) refitFlag = kFALSE;
                                        }
                                        if (refitFlag){
-                                               printf("Refit cut passed\n");
-                                               fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepRefit);
+                                               AliDebug(3,"Refit cut passed\n");
+                                               fCFManager->GetParticleContainer()->Fill(containerInputMC,kStepRefit,fWeight);
                                                icountRefit++;
                                        }
                                        else{
@@ -438,6 +468,7 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
        AliDebug(2, Form("Found %d vertices",arrayD0toKpi->GetEntriesFast()));
 
        Int_t pdgDgD0toKpi[2]={321,211};
+       Int_t isD0D0bar=1;// 1 for D0, 2 for D0bar, to be used for the PPR and PID selection steps
 
        for (Int_t iD0toKpi = 0; iD0toKpi<arrayD0toKpi->GetEntriesFast(); iD0toKpi++) {
                
@@ -462,6 +493,9 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                                AliWarning("Could not find associated MC in AOD MC tree");
                                continue;
                        }
+                       if(mcVtxHF->GetPdgCode()==421)isD0D0bar=1;
+                       else if(mcVtxHF->GetPdgCode()==-421)isD0D0bar=2;
+                       else continue;
                        // check whether the daughters have kTPCrefit and kITSrefit set
                        AliAODTrack *track0 = (AliAODTrack*)d0tokpi->GetDaughter(0);
                        AliAODTrack *track1 = (AliAODTrack*)d0tokpi->GetDaughter(1);
@@ -578,8 +612,8 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
 
                        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);
-                       fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed) ;   
+                       AliDebug(2,Form("%d: filling RECO step\n",iD0toKpi));
+                       fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed,fWeight) ;   
 
                        // cut in acceptance
                        Float_t etaCutMin, etaCutMax, ptCutMin, ptCutMax;
@@ -589,7 +623,7 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                        Bool_t acceptanceProng1 = (d0tokpi->EtaProng(1)>etaCutMin && d0tokpi->EtaProng(1)<etaCutMax && d0tokpi->PtProng(1) > ptCutMin && d0tokpi->PtProng(1) < ptCutMax);
                        if (acceptanceProng0 && acceptanceProng1) {
                                AliDebug(2,"D0 reco daughters in acceptance");
-                               fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoAcceptance) ;
+                               fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoAcceptance,fWeight) ;
                                icountRecoAcc++; 
                                
                                if(fAcceptanceUnf){
@@ -616,12 +650,17 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                                        icountRecoITSClusters++;   
                                        AliDebug(2,Form("pT = %f, dca = %f, cosThetaStar = %f, pTpi = %f, pTK = %f, d0pi = %f, d0K = %f, d0xd0 = %f, cosPointingAngle = %f", pt, dca, cosThetaStar,pTpi, pTK, d0pi*1E4, d0K*1E4, d0xd0*1E8, cosPointingAngle));
                                        AliInfo(Form("pT = %f, dca = %f, cosThetaStar = %f, pTpi = %f, pTK = %f, d0pi = %f, d0K = %f, d0xd0 = %f, cosPointingAngle = %f", pt, dca, cosThetaStar,pTpi, pTK, d0pi, d0K, d0xd0, cosPointingAngle));
+               
+                                       // setting the use of the PID cut when applying the selection to FALSE - whatever it was. Keeping track of the original value
+                                       Bool_t iscutusingpid=fCuts->GetIsUsePID();
+                                       Int_t isselcuts=-1,isselpid=-1;
+                                       fCuts->SetUsePID(kFALSE);       
 
-                                                                       
-                                       if (fCuts->IsSelected(d0tokpi,AliRDHFCuts::kCandidate)>0){
+                                       isselcuts = fCuts->IsSelected(d0tokpi,AliRDHFCuts::kCandidate,aodEvent);
+                                       if (isselcuts == 3 || isselcuts == isD0D0bar){
                                                AliInfo(Form("Particle passed PPR cuts (actually cuts for D0 analysis!) with pt = %f",containerInput[0]));
                                                AliDebug(2,"Particle passed PPR cuts (actually cuts for D0 analysis!)");
-                                               fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoPPR) ;   
+                                               fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoPPR,fWeight) ;   
                                                icountRecoPPR++;
                                                
                                                if(!fAcceptanceUnf){ // unfolding
@@ -641,10 +680,13 @@ void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
                                                        fCorrelation->Fill(fill);
                                                        
                                                }
-                                               if (fCuts->IsSelected(d0tokpi,AliRDHFCuts::kPID)>0){
+
+                                               fCuts->SetUsePID(iscutusingpid); // restoring usage of the PID from the cuts object
+                                               isselpid = fCuts->IsSelected(d0tokpi,AliRDHFCuts::kPID);
+                                               if((fCuts->CombineSelectionLevels(3,isselcuts,isselpid)==isD0D0bar)||(fCuts->CombineSelectionLevels(3,isselcuts,isselpid)==3)){
                                                        AliInfo(Form("Particle passed PID cuts with pt = %f",containerInput[0]));
                                                        AliDebug(2,"Particle passed PID cuts");
-                                                       fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoPID) ;   
+                                                       fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoPID,fWeight) ;   
                                                        icountRecoPID++;
                                                }
                                        }
@@ -1435,3 +1477,55 @@ Int_t AliCFHeavyFlavourTaskMultiVarMultiStep::CheckOrigin(AliAODMCParticle* mcPa
        }
        return pdgGranma;
 }
+//__________________________________________________________________________________________________
+Double_t AliCFHeavyFlavourTaskMultiVarMultiStep::GetWeight(Float_t pt){
+
+       //
+       // calculating the weight to fill the container
+       //
+
+       // FNOLL central:
+       // p0 = 0.2149
+       // p1 = 2.433
+       // p2 = 2.102
+       // p3 = 2.5
+
+       // FNOLL min:
+       // p0 = 0.06947
+       // p1 = 4.795
+       // p2 = 2.878
+       // p3 = 2.5
+
+       // FNOLL max:
+       // p0 = 0.2739
+       // p1 = 2.136
+       // p2 = 2.066
+       // p3 = 2.5
+
+       // PYTHIA
+       // p0 = 3.63832E-2
+       // p1 = 1.88238
+       // p2 = 1.34854
+       // p3 = 2.5
+
+       Double_t func1[4] = {0.2149,2.433,2.102,2.5};
+       Double_t func2[4] = {3.63832E-2,1.88238,1.34854,2.5};
+
+       Double_t dndpt_func1 = dNdptFit(pt,func1);
+       Double_t dndpt_func2 = dNdptFit(pt,func2);
+       AliDebug(2,Form("pt = %f, FONLL = %f, Pythia = %f, ratio = %f",pt,dndpt_func1,dndpt_func2,dndpt_func1/dndpt_func2));
+       return dndpt_func1/dndpt_func2;
+}
+
+//__________________________________________________________________________________________________
+Double_t AliCFHeavyFlavourTaskMultiVarMultiStep::dNdptFit(Float_t pt, Double_t* par){
+
+       // 
+       // calculating dNdpt
+       //
+
+       Double_t denom =  TMath::Power((pt/par[1]), par[3] );
+       Double_t dNdpt = par[0]*pt/TMath::Power(1.+denom, par[2]);
+       
+       return dNdpt;
+}
index 0c5b11f..627ba13 100644 (file)
@@ -60,6 +60,8 @@ class AliCFHeavyFlavourTaskMultiVarMultiStep : public AliAnalysisTaskSE {
   // ANALYSIS FRAMEWORK STUFF to loop on data and fill output objects
   void     UserCreateOutputObjects();
   void     UserExec(Option_t *option);
+  void     Init();
+  void     LocalInit() {Init();}
   void     Terminate(Option_t *);
 
  // UNFOLDING
@@ -84,6 +86,10 @@ class AliCFHeavyFlavourTaskMultiVarMultiStep : public AliAnalysisTaskSE {
 
   void SetKeepD0fromB(Bool_t keepD0fromB){fKeepD0fromB=keepD0fromB;}
   void SetKeepD0fromBOnly(Bool_t keepD0fromBOnly){ fKeepD0fromBOnly=keepD0fromBOnly; }
+  void SetUseWeight(Bool_t useWeight){fUseWeight=useWeight;}
+  Bool_t GetUseWeight() const {return fUseWeight;}
+  Double_t GetWeight(Float_t pt);
+  Double_t dNdptFit(Float_t pt, Double_t* par);
 
  protected:
   Int_t           fPDG;         //  PDG code of searched V0's
@@ -108,8 +114,10 @@ class AliCFHeavyFlavourTaskMultiVarMultiStep : public AliAnalysisTaskSE {
   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
+  Bool_t fUseWeight;            // flag to decide whether to use weights != 1 when filling the container or not
+  Double_t fWeight;             // weight used to fill the container
   
-  ClassDef(AliCFHeavyFlavourTaskMultiVarMultiStep,5); // class for HF corrections as a function of many variables
+  ClassDef(AliCFHeavyFlavourTaskMultiVarMultiStep,6); // class for HF corrections as a function of many variables
 };
 
 #endif
index 73d7995..55ad9b7 100644 (file)
@@ -37,39 +37,38 @@ const Int_t    minITSClusters = 5;
 
 AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* cutFile = "./D0toKpiCuts.root",Bool_t isKeepD0fromB=kFALSE, Bool_t isKeepD0fromBOnly=kFALSE)
 {
-  printf("Adding CF task using cuts from file %s\n",cutFile);
+       printf("Adding CF task using cuts from file %s\n",cutFile);
+       
+       TFile* fileCuts = new TFile(cutFile);
+       AliRDHFCutsD0toKpi *cutsD0toKpi = (AliRDHFCutsD0toKpi*)fileCuts->Get("D0toKpiCutsStandard");
+       
+       // 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 ;
+       }
   
-  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");
@@ -87,40 +86,99 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
        UInt_t ipointing  = 10;
        UInt_t iphi  = 11;
        UInt_t iz  = 12;
-
+       
        const Double_t phimax = 2*TMath::Pi();
-
+       
        //Setting up the container grid... 
        UInt_t nstep = 10; //number of selection steps: MC with limited acceptance, MC, Acceptance, Vertex, Refit, Reco (no cuts), RecoAcceptance, RecoITSClusters (RecoAcceptance included), RecoPPR (RecoAcceptance+RecoITSCluster included), RecoPID 
        const Int_t nvar   = 13 ; //number of variables on the grid:pt, y, cosThetaStar, pTpi, pTk, cT, dca, d0pi, d0K, d0xd0, cosPointingAngle, phi 
-//     const Int_t nbin0_0_4  = 8 ; //bins in pt from 0 to 4 GeV
-//     const Int_t nbin0_4_8  = 4 ; //bins in pt from 4 to 8 GeV
-//     const Int_t nbin0_8_10  = 1 ; //bins in pt from 8 to 10 GeV
 
-/*
+       //Setting the bins: pt, ptPi, and ptK are considered seprately because for them you can either define the binning by hand, or using the cuts file
+
+       //arrays for the number of bins in each dimension
+       Int_t iBin[nvar];
+
+       //OPTION 1: defining the pt, ptPi, ptK bins by hand...          
        Int_t nbin0_0_4;
        Int_t nbin0_4_8;
        Int_t nbin0_8_10;
        if (!isKeepD0fromB){
-         nbin0_0_4  = 8 ; //bins in pt from 0 to 4 GeV
-         nbin0_4_8  = 4 ; //bins in pt from 4 to 8 GeV
-         nbin0_8_10  = 1 ; //bins in pt from 8 to 10 GeV
+               nbin0_0_4  = 8 ; //bins in pt from 0 to 4 GeV
+               nbin0_4_8  = 4 ; //bins in pt from 4 to 8 GeV
+               nbin0_8_10  = 1 ; //bins in pt from 8 to 10 GeV
        }else{
-         nbin0_0_4  = 3 ; //bins in pt from 0 to 3 GeV
-         nbin0_4_8  = 1 ; //bins in pt from 3 to 5 GeV
-         nbin0_8_10  = 1 ; //bins in pt from 5 to 10 GeV
+               nbin0_0_4  = 3 ; //bins in pt from 0 to 3 GeV
+               nbin0_4_8  = 1 ; //bins in pt from 3 to 5 GeV
+               nbin0_8_10  = 1 ; //bins in pt from 5 to 10 GeV
        }
-*/
-       const Int_t nbin0 = cutsD0toKpi->GetNPtBins(); // bins in pT
-       printf("pT: nbin (from cuts file) = %d\n",nbin0);
-       const Int_t nbin1  = 42 ; //bins in y
-       const Int_t nbin2  = 42 ; //bins in cosThetaStar 
        const Int_t nbin3_0_4  = 8 ; //bins in ptPi from 0 to 4 GeV
        const Int_t nbin3_4_8  = 4 ; //bins in ptPi from 4 to 8 GeV
        const Int_t nbin3_8_10  = 1 ; //bins in ptPi from 8 to 10 GeV
        const Int_t nbin4_0_4  = 8 ; //bins in ptKa from 0 to 4 GeV
        const Int_t nbin4_4_8  = 4 ; //bins in ptKa from 4 to 8 GeV
        const Int_t nbin4_8_10  = 1 ; //bins in ptKa from 8 to 10 GeV
+       iBin[0]=nbin0_0_4+nbin0_4_8+nbin0_8_10;
+       iBin[3]=nbin3_0_4+nbin3_4_8+nbin3_8_10;
+       iBin[4]=nbin4_0_4+nbin4_4_8+nbin4_8_10;
+       Double_t *binLim0=new Double_t[iBin[0]+1];
+       Double_t *binLim3=new Double_t[iBin[3]+1];
+       Double_t *binLim4=new Double_t[iBin[4]+1];
+
+       // values for bin lower bounds
+       // pt
+       for(Int_t i=0; i<=nbin0_0_4; i++) binLim0[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbin0_0_4*(Double_t)i ; 
+       if (binLim0[nbin0_0_4] != ptmin_4_8)  {
+               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 1st range - differs from expected!\n");
+       }
+       for(Int_t i=0; i<=nbin0_4_8; i++) binLim0[i+nbin0_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbin0_4_8*(Double_t)i ; 
+       if (binLim0[nbin0_0_4+nbin0_4_8] != ptmin_8_10)  {
+               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 2nd range - differs from expected!\n");
+       }
+       for(Int_t i=0; i<=nbin0_8_10; i++) binLim0[i+nbin0_0_4+nbin0_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbin0_8_10*(Double_t)i ; 
+       // ptPi
+       for(Int_t i=0; i<=nbin3_0_4; i++) binLim3[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbin3_0_4*(Double_t)i ; 
+       if (binLim3[nbin3_0_4] != ptmin_4_8)  {
+               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptPi - 1st range - differs from expected!");
+       }
+       for(Int_t i=0; i<=nbin3_4_8; i++) binLim3[i+nbin3_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbin3_4_8*(Double_t)i ; 
+       if (binLim3[nbin3_0_4+nbin3_4_8] != ptmin_8_10)  {
+               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptPi - 2nd range - differs from expected!\n");
+       }
+       for(Int_t i=0; i<=nbin3_8_10; i++) binLim3[i+nbin3_0_4+nbin3_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbin3_8_10*(Double_t)i ; 
+
+       // ptKa
+       for(Int_t i=0; i<=nbin4_0_4; i++) binLim4[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbin4_0_4*(Double_t)i ; 
+       if (binLim4[nbin4_0_4] != ptmin_4_8)  {
+               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptKa - 1st range - differs from expected!");
+       }
+       for(Int_t i=0; i<=nbin4_4_8; i++) binLim4[i+nbin4_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbin4_4_8*(Double_t)i ; 
+       if (binLim4[nbin4_0_4+nbin4_4_8] != ptmin_8_10)  {
+               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptKa - 2nd range - differs from expected!\n");
+       }
+       for(Int_t i=0; i<=nbin4_8_10; i++) binLim4[i+nbin4_0_4+nbin4_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbin4_8_10*(Double_t)i ; 
+       
+       
+       //OPTION 2: ...or from the cuts file
+
+       //const Int_t nbin0 = cutsD0toKpi->GetNPtBins(); // bins in pT
+       //iBin[0]=nbin0;
+       //iBin[3]=nbin0;
+       //iBin[4]=nbin0;
+       // values for bin lower bounds
+       //Float_t* floatbinLim0 = cutsD0toKpi->GetPtBinLimits();
+       //for (Int_t ibin0 = 0 ; ibin0<iBin[0]+1; ibin0++){
+       //      binLim0[ibin0] = (Double_t)floatbinLim0[ibin0];
+       //      binLim3[ibin0] = (Double_t)floatbinLim0[ibin0];
+       //      binLim4[ibin0] = (Double_t)floatbinLim0[ibin0];
+       //}
+       //for(Int_t i=0; i<=nbin0; i++) printf("binLim0[%d]=%f\n",i,binLim0[i]);  
+
+       //printf("pT: nbin (from cuts file) = %d\n",nbin0);
+
+       // defining now the binning for the other variables:
+
+       const Int_t nbin1  = 42 ; //bins in y
+       const Int_t nbin2  = 42 ; //bins in cosThetaStar 
        const Int_t nbin5  = 24 ; //bins in cT
        const Int_t nbin6  = 24 ; //bins in dca
        const Int_t nbin7  = 100 ; //bins in d0pi
@@ -130,16 +188,8 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
        const Int_t nbin11  = 20 ; //bins in Phi
        const Int_t nbin12  = 60 ; //bins in z vertex
 
-       //arrays for the number of bins in each dimension
-       Int_t iBin[nvar];
-       //iBin[0]=nbin0_0_4+nbin0_4_8+nbin0_8_10;
-       iBin[0]=nbin0;
        iBin[1]=nbin1;
        iBin[2]=nbin2;
-       //      iBin[3]=nbin3_0_4+nbin3_4_8+nbin3_8_10;
-       //iBin[4]=nbin4_0_4+nbin4_4_8+nbin4_8_10;
-       iBin[3]=nbin0;
-       iBin[4]=nbin0;
        iBin[5]=nbin5;
        iBin[6]=nbin6;
        iBin[7]=nbin7;
@@ -150,11 +200,8 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
        iBin[12]=nbin12;
        
        //arrays for lower bounds :
-       Double_t *binLim0=new Double_t[iBin[0]+1];
        Double_t *binLim1=new Double_t[iBin[1]+1];
        Double_t *binLim2=new Double_t[iBin[2]+1];
-       Double_t *binLim3=new Double_t[iBin[3]+1];
-       Double_t *binLim4=new Double_t[iBin[4]+1];
        Double_t *binLim5=new Double_t[iBin[5]+1];
        Double_t *binLim6=new Double_t[iBin[6]+1];
        Double_t *binLim7=new Double_t[iBin[7]+1];
@@ -164,66 +211,12 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
        Double_t *binLim11=new Double_t[iBin[11]+1];
        Double_t *binLim12=new Double_t[iBin[12]+1];
 
-       // checking limits
-       /*
-       if (ptmax_0_4 != ptmin_4_8) {
-               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","max lim 1st range != min lim 2nd range, please check!");
-       }
-       if (ptmax_4_8 != ptmin_8_10) {
-               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","max lim 2nd range != min lim 3rd range, please check!");
-       }
-       */
-       // values for bin lower bounds
-       // pt
-       Float_t* floatbinLim0 = cutsD0toKpi->GetPtBinLimits();
-       for (Int_t ibin0 = 0 ; ibin0<iBin[0]+1; ibin0++){
-               binLim0[ibin0] = (Double_t)floatbinLim0[ibin0];
-               binLim3[ibin0] = (Double_t)floatbinLim0[ibin0];
-               binLim4[ibin0] = (Double_t)floatbinLim0[ibin0];
-       }
-       for(Int_t i=0; i<=nbin0; i++) printf("binLim0[%d]=%f\n",i,binLim0[i]);  
-
-       /*
-       for(Int_t i=0; i<=nbin0_0_4; i++) binLim0[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbin0_0_4*(Double_t)i ; 
-       if (binLim0[nbin0_0_4] != ptmin_4_8)  {
-               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 1st range - differs from expected!\n");
-       }
-       for(Int_t i=0; i<=nbin0_4_8; i++) binLim0[i+nbin0_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbin0_4_8*(Double_t)i ; 
-       if (binLim0[nbin0_0_4+nbin0_4_8] != ptmin_8_10)  {
-               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 2nd range - differs from expected!\n");
-       }
-       for(Int_t i=0; i<=nbin0_8_10; i++) binLim0[i+nbin0_0_4+nbin0_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbin0_8_10*(Double_t)i ; 
-       */
-
        // y
        for(Int_t i=0; i<=nbin1; i++) binLim1[i]=(Double_t)ymin  + (ymax-ymin)  /nbin1*(Double_t)i ;
 
        // cosThetaStar
        for(Int_t i=0; i<=nbin2; i++) binLim2[i]=(Double_t)cosmin  + (cosmax-cosmin)  /nbin2*(Double_t)i ;
-
-       /*
-       // ptPi
-       for(Int_t i=0; i<=nbin3_0_4; i++) binLim3[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbin3_0_4*(Double_t)i ; 
-       if (binLim3[nbin3_0_4] != ptmin_4_8)  {
-               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptPi - 1st range - differs from expected!");
-       }
-       for(Int_t i=0; i<=nbin3_4_8; i++) binLim3[i+nbin3_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbin3_4_8*(Double_t)i ; 
-       if (binLim3[nbin3_0_4+nbin3_4_8] != ptmin_8_10)  {
-               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptPi - 2nd range - differs from expected!\n");
-       }
-       for(Int_t i=0; i<=nbin3_8_10; i++) binLim3[i+nbin3_0_4+nbin3_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbin3_8_10*(Double_t)i ; 
-
-       // ptKa
-       for(Int_t i=0; i<=nbin4_0_4; i++) binLim4[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbin4_0_4*(Double_t)i ; 
-       if (binLim4[nbin4_0_4] != ptmin_4_8)  {
-               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptKa - 1st range - differs from expected!");
-       }
-       for(Int_t i=0; i<=nbin4_4_8; i++) binLim4[i+nbin4_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbin4_4_8*(Double_t)i ; 
-       if (binLim4[nbin4_0_4+nbin4_4_8] != ptmin_8_10)  {
-               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptKa - 2nd range - differs from expected!\n");
-       }
-       for(Int_t i=0; i<=nbin4_8_10; i++) binLim4[i+nbin4_0_4+nbin4_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbin4_8_10*(Double_t)i ; 
-       */
+       
        // cT
        for(Int_t i=0; i<=nbin5; i++) binLim5[i]=(Double_t)cTmin  + (cTmax-cTmin)  /nbin5*(Double_t)i ;
 
@@ -251,20 +244,6 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
                //              Info("AliCFHeavyFlavourTaskMultiVarMultiStep",Form("i-th bin, lower limit = %f", binLim12[i]));
        }
 
-       // debugging printings
-       //Info("AliCFHeavyFlavourTaskMultiVarMultiStep","Printing lower limits for bins in pt");
-       //for (Int_t i =0; i<= iBin[0]; i++){
-       //      Info("AliCFHeavyFlavourTaskMultiVarMultiStep",Form("i-th bin, lower limit = %f", binLim0[i]));
-       //}
-       //Info("Printing lower limits for bins in ptPi");
-       //for (Int_t i =0; i<= iBin[3]; i++){
-       //      Info("AliCFHeavyFlavourTaskMultiVarMultiStep",Form("i-th bin, lower limit = %f", binLim3[i]));
-       //}
-       //Info("Printing lower limits for bins in ptKa");
-       //for (Int_t i =0; i<= iBin[4]; i++){
-       //      Info("AliCFHeavyFlavourTaskMultiVarMultiStep",Form("i-th bin, lower limit = %f", binLim4[i]));
-       //      }
-
        //one "container" for MC
        TString nameContainer="";
        if(!isKeepD0fromB) {
@@ -376,6 +355,7 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
        //CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK
        printf("CREATE INTERFACE AND CUTS\n");
        AliCFManager* man = new AliCFManager() ;
+       AliLog::SetClassDebugLevel("AliCFManager",AliLog::kError);
        man->SetParticleContainer     (container);
        man->SetParticleCutsList(0 , mcList); // MC, Limited Acceptance
        man->SetParticleCutsList(1 , mcList); // MC
@@ -404,7 +384,8 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
        task->SetCFManager(man); //here is set the CF manager
        task->SetKeepD0fromB(isKeepD0fromB);
        task->SetKeepD0fromBOnly(isKeepD0fromBOnly);
-       
+       task->SetUseWeight(kFALSE);  // set to true if you want to filled a weight CF   
+
         //-----------------------------------------------------------//
         //   create correlation matrix for unfolding - only eta-pt   //
         //-----------------------------------------------------------//
@@ -462,7 +443,7 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
        // ----- output data -----
        
        TString outputfile = AliAnalysisManager::GetCommonFileName();
-       TString output1name="", output2name="", output3name="";
+       TString output1name="", output2name="", output3name="", output4name="";
        output2name=nameContainer;
        output3name=nameCorr;
        if(!isKeepD0fromB) {
@@ -478,6 +459,7 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
          output1name="CFHFchist0allD0";
 
        }
+       output4name="Cuts";
 
        //now comes user's output objects :
        // output TH1I for event counting
@@ -486,6 +468,7 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
        AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(output2name, AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
        // Unfolding - correlation matrix
         AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(output3name, THnSparseD::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
+        AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(output4name, AliRDHFCutsD0toKpi::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
 
        mgr->AddTask(task);
        
@@ -493,6 +476,7 @@ AliCFHeavyFlavourTaskMultiVarMultiStep *AddTaskCFMultiVarMultiStep(const char* c
        mgr->ConnectOutput(task,1,coutput1);
        mgr->ConnectOutput(task,2,coutput2);
         mgr->ConnectOutput(task,3,coutput3);
+        mgr->ConnectOutput(task,4,coutput4);
        return task;
 }