]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG3/base/AliPtMothFromPtDaugh.cxx
- complying to changes in the offline code regarding non-linearity corrections.
[u/mrichter/AliRoot.git] / PWG3 / base / AliPtMothFromPtDaugh.cxx
index 123f96d9d0342fe3e535f8b2feb30ff15c86fabb..f9fc3187c0bbc15272c5338e7885f4ff0012c470 100644 (file)
@@ -1,53 +1,56 @@
-/**************************************************************************
- * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
- *                                                                        *
- * Author: The ALICE Off-line Project.                                    *
- * Contributors are mentioned in the code where appropriate.              *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
+/*************************************************************************
+* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
 ////////////////////////////////////////////////////////////////////////////
 //  Class to perform pt-spectra (and ptMin-spectra) extraction of mothers //
-//  particles starting from measured pt-spectra of daughter particle      //
+//  particles starting from measured pt-spectra of daughter particles     //
 //  that come from inclusive decays.                                      // 
 //  E.g.: B->J/psi+X , B->e+X, B->D0+X, etc.                              //
 //                                                                        //
 //  In order to use this class, one first has to run a simulation         // 
-//  (only kinematics)  of the decay channel under study. Standard input   //
-//  of this class is therefore the file galice.root. In order             //
-//  to speed up, a method exhists which reads the Kinematics.root         // 
-//  and produces an ntupla with just the particles of the decay under     //
-//  study                                                                 //
+//  (only kinematics) of the decay channel under study. The analysis      //
+//  can be runned using the class AliAnalysisTaskPtMothFromPtDaugh        //  
+//  which loops on events to create a TNtupla that stores just            // 
+//  kinematics informations for mothers and daughters of the decay        //
+//  under study (this is made in order to speed up).                      //
 //                                                                        //
-//  The second input is the pt spectrum of the daughter particle          //
-//                                                                       //
-//  Output would be the pt spectrum of the mother, based on the           //
-//  correction factors computed from the Kinematics.root file             //
+//  Therefore the standard inputs of this class are:                      //
+//  (1) The TNtupla (created by the task using a TChain of galice.root)   //    
+//  (2) pT-spectrum of the daughter particles                             //
+//                                                                        //
+//  Output would be the pT (and pTMin) spectrum of the mother, based      //
+//  on the correction factors computed from the Kinematics.root files     //
 //                                                                        //
 //                                                                        //  
 //  Authors: Giuseppe E. Bruno           &  Fiorella Fionda               //
 //           (Giuseppe.Bruno@ba.infn.it)    (Fiorella.Fionda@ba.infn.it)  //
 ////////////////////////////////////////////////////////////////////////////
+
 #include "TH1F.h"
 #include "TNtuple.h"
 #include "TFile.h"
 #include "TParticle.h"
 #include "TArrayI.h"
+
 #include "AliPtMothFromPtDaugh.h"
 #include "AliStack.h"
-#include "AliRunLoader.h"
 #include "AliLog.h"
 
 ClassImp(AliPtMothFromPtDaugh)
-//_____________________________________________________________________________________
-AliPtMothFromPtDaugh::AliPtMothFromPtDaugh():
+//________________________________________________________________
+AliPtMothFromPtDaugh::AliPtMothFromPtDaugh() :
+  TNamed("AliPtMoth","AliPtMoth"),
   fDecayKine(0x0), 
   fWij(0x0),
   fFi(0x0),
@@ -58,20 +61,63 @@ AliPtMothFromPtDaugh::AliPtMothFromPtDaugh():
   fHistoPtMinMothers(0x0),
   fMothers(0x0),  
   fDaughter(0), 
-  fReadKine(kFALSE),
   fyMothMax(0),
   fyMothMin(0),
   fyDaughMax(0),
   fyDaughMin(0),
   fUseEta(kFALSE),
   fAnalysisMode(kUserAnalysis)
-   {
-   //Default constructor
-   }
+  {
+  //
+  // Default constructor
+  //
+  }
+
+//________________________________________________________________
+AliPtMothFromPtDaugh::AliPtMothFromPtDaugh(const char* name, const char* title) :
+  TNamed(name,title),
+  fDecayKine(0x0),
+  fWij(0x0),
+  fFi(0x0),
+  fWijMin(0x0),
+  fFiMin(0x0),
+  fHistoPtDaughter(0x0),
+  fHistoPtMothers(0x0),
+  fHistoPtMinMothers(0x0),
+  fMothers(0x0),
+  fDaughter(0),
+  fyMothMax(0),
+  fyMothMin(0),
+  fyDaughMax(0),
+  fyDaughMin(0),
+  fUseEta(kFALSE),
+  fAnalysisMode(kUserAnalysis)
+  {
+  //
+  // Named constructor
+  //
+  }
+
+//________________________________________________________________
+AliPtMothFromPtDaugh::~AliPtMothFromPtDaugh()
+  {
+  //
+  // Default destructor
+  //
+  if(fDecayKine) {delete fDecayKine;}
+   fDecayKine=0;
+   if(fMothers) {delete fMothers;}
+   fMothers=0;
+   if(fHistoPtMothers) { delete fHistoPtMothers; }
+   fHistoPtMothers=0;
+   if(fHistoPtMinMothers) { delete fHistoPtMinMothers;}
+   fHistoPtMinMothers=0;
+   if(fHistoPtDaughter) { delete fHistoPtDaughter; fHistoPtDaughter=0;}
+  }
 
 //______________________________________________________________________________________
 AliPtMothFromPtDaugh::AliPtMothFromPtDaugh(const AliPtMothFromPtDaugh& extraction) :
-  TObject(extraction),
+  TNamed(extraction),
   fDecayKine(0),
   fWij(0),
   fFi(0),
@@ -82,14 +128,13 @@ AliPtMothFromPtDaugh::AliPtMothFromPtDaugh(const AliPtMothFromPtDaugh& extractio
   fHistoPtMinMothers(0),
   fMothers(0),
   fDaughter(extraction.fDaughter),
-  fReadKine(extraction.fReadKine),
   fyMothMax(extraction.fyMothMax),
   fyMothMin(extraction.fyMothMin),
   fyDaughMax(extraction.fyDaughMax),
   fyDaughMin(extraction.fyDaughMin),
   fUseEta(extraction.fUseEta),
   fAnalysisMode(extraction.fAnalysisMode)
-  {
+    {
    // Copy constructor
    if(extraction.fHistoPtDaughter) fHistoPtDaughter =(TH1F*)extraction.fHistoPtDaughter->Clone("fHistoPtDaughter_copy");
    if(extraction.fHistoPtMothers) fHistoPtMothers = (TH1F*)extraction.fHistoPtMothers->Clone("fHistoPtMothers_copy");
@@ -127,8 +172,8 @@ AliPtMothFromPtDaugh::AliPtMothFromPtDaugh(const AliPtMothFromPtDaugh& extractio
 
    if(extraction.fDecayKine) fDecayKine = (TNtuple*)extraction.fDecayKine->CloneTree(); 
 
-   if(extraction.fMothers) fMothers = new TArrayI(*extraction.fMothers);
-   
+   if(extraction.fMothers) fMothers = new TArrayI(*(extraction.fMothers));
+  
    extraction.Copy(*this);
   }
 
@@ -143,23 +188,6 @@ AliPtMothFromPtDaugh& AliPtMothFromPtDaugh::operator=(const AliPtMothFromPtDaugh
     return *this; 
   }
 
-//______________________________________________________________________________________
-AliPtMothFromPtDaugh::~AliPtMothFromPtDaugh()
-  {
-   //Standard destructor
-   if(fDecayKine) {delete fDecayKine;}
-   fDecayKine=0;
-   if(fMothers) {delete fMothers;}
-   fMothers=0;
-   if(fHistoPtMothers) { delete fHistoPtMothers; }
-   fHistoPtMothers=0;
-   if(fHistoPtMinMothers) { delete fHistoPtMinMothers;}
-   fHistoPtMinMothers=0;
-   if(fHistoPtDaughter) { delete fHistoPtDaughter; fHistoPtDaughter=0;}
-   DeleteWeights(); 
-   return;
-  }
-
 //______________________________________________________________________________________
 Bool_t AliPtMothFromPtDaugh::CreateWeights()
   {
@@ -169,19 +197,19 @@ Bool_t AliPtMothFromPtDaugh::CreateWeights()
    // Initialize dimensions for correction factors
 
    DeleteWeights();
-   if(!fMothers)  {AliWarning("Set pdg codes of mothers by SetPdgMothers!\n"); return kFALSE;}
-   if(!fDaughter) {AliWarning("Set pdg code of daughter by SetPdgDaughter!\n"); return kFALSE;}  
-   if(!fHistoPtDaughter) { AliWarning("Daughter histogram doesn't exist! \n"); return kFALSE;} 
+   if(!fMothers)  {AliError("Set pdg codes of mothers by SetPdgMothers!\n"); return kFALSE;}
+   if(!fDaughter) {AliError("Set pdg code of daughter by SetPdgDaughter!\n"); return kFALSE;}  
+   if(!fHistoPtDaughter) { AliError("Daughter histogram doesn't exist! \n"); return kFALSE;} 
    
    //Set Rapidity or Pseudorapidity range for mothers if not
-   if(!fyMothMax || !fyMothMin ){ AliWarning("Set rapidity range or pseudoRapidity range for mothers: use SetYmothers(ymin,ymax) or SetEtaMothers(etamin,etamax)"); return kFALSE;}   
-   if(!fyDaughMax || !fyDaughMin){ AliWarning("Set rapidity range or pseudoRapidity range for daughters:use SetYdaughters(ymin,ymax) or SetEtaDaughters(etamin,etamax)"); return kFALSE;}  
-   if(!fHistoPtMothers) {AliWarning("Call method SetBinsPtMoth to set pT-histogram "); return kFALSE;}
-   if(!fHistoPtMinMothers){AliWarning("Call method SetBinsPtMinMoth to set pTmin-histogram "); return kFALSE;}
+   if(!fyMothMax || !fyMothMin ){ AliError("Set rapidity range or pseudoRapidity range for mothers: use SetYmothers(ymin,ymax) or SetEtaMothers(etamin,etamax)"); return kFALSE;}   
+   if(!fyDaughMax || !fyDaughMin){ AliError("Set rapidity range or pseudoRapidity range for daughters:use SetYdaughters(ymin,ymax) or SetEtaDaughters(etamin,etamax)"); return kFALSE;}  
+   if(!fHistoPtMothers) {AliError("Call method SetBinsPtMoth to set pT-histogram "); return kFALSE;}
+   if(!fHistoPtMinMothers){AliError("Call method SetBinsPtMinMoth to set pTmin-histogram "); return kFALSE;}
 
    Int_t nbinsM=(fHistoPtMothers->GetNbinsX()+2);
    Int_t nbinsD=(fHistoPtDaughter->GetNbinsX()+2);
-   Int_t nbinsM_min=(fHistoPtMinMothers->GetNbinsX()+2);
+   Int_t nbinsMmin=(fHistoPtMinMothers->GetNbinsX()+2);
 
    //Create pointers for weights to reconstruct daughter and mothers pT-spectra 
    fWij=new Double_t*[2*nbinsM];
@@ -189,44 +217,34 @@ Bool_t AliPtMothFromPtDaugh::CreateWeights()
       {*(fWij+i)=new Double_t[nbinsD];}   
    fFi=new Double_t[2*nbinsM];   
     
-   fWijMin=new Double_t*[2*nbinsM_min];
-   for(Int_t i=0;i<2*nbinsM_min;i++) 
+   fWijMin=new Double_t*[2*nbinsMmin];
+   for(Int_t i=0;i<2*nbinsMmin;i++) 
       {*(fWijMin+i)=new Double_t[nbinsD];}
-   fFiMin=new Double_t[2*nbinsM_min];
+   fFiMin=new Double_t[2*nbinsMmin];
    AliInfo(Form("Pt-mothers distribution: pt_min = %f  pt_max=%f  n_bins=%d \n",
            fHistoPtMothers->GetBinLowEdge(1),fHistoPtMothers->GetBinLowEdge(nbinsM-1),nbinsM-2));
    AliInfo(Form("PtMinimum-mothers distribution: pt_min = %f  pt_max=%f  n_bins=%d \n",
-           fHistoPtMinMothers->GetBinLowEdge(1),fHistoPtMinMothers->GetBinLowEdge(nbinsM_min-1),nbinsM_min-2));
+           fHistoPtMinMothers->GetBinLowEdge(1),fHistoPtMinMothers->GetBinLowEdge(nbinsMmin-1),nbinsMmin-2));
    AliInfo(Form("Pt-daughters distribution: pt_min = %f  pt_max=%f n_bins=%d \n",
            fHistoPtDaughter->GetBinLowEdge(1),fHistoPtDaughter->GetBinLowEdge(nbinsD-1),nbinsD-2));
    return kTRUE;
   }  
 
-//______________________________________________________________________________________
-Bool_t AliPtMothFromPtDaugh::ReadHistoPtDaught(TH1F *hist)
-  {
-   //Initialize daughter histograms with hist
-   if(!hist) {AliWarning("Set correct histograms of daughter! It doesn't exist!\n"); return kFALSE;}
-   if(fHistoPtDaughter) delete fHistoPtDaughter;
-   fHistoPtDaughter = (TH1F*)hist->Clone();
-   return kTRUE;
-  }
-
 //______________________________________________________________________________________
 void AliPtMothFromPtDaugh::DeleteWeights()
   {
    //delete correction factors   
    //delete histogram of daughters
-   if(!fHistoPtMothers || !fHistoPtMinMothers) {AliWarning("Mothers histograms don't exist! Cannot delete correction factors"); return;}
+   if(!fHistoPtMothers || !fHistoPtMinMothers) {AliError("Mothers histograms don't exist! Cannot delete correction factors"); return;}
    Int_t nbinsM=fHistoPtMothers->GetNbinsX()+2;
-   Int_t nbinsM_min=fHistoPtMinMothers->GetNbinsX()+2;  
+   Int_t nbinsMmin=fHistoPtMinMothers->GetNbinsX()+2;  
    if(fWij){
      for(Int_t i=0; i<(2*nbinsM); i++) delete fWij[i];
      delete [] fWij; fWij=0;
     }
    if(fFi) { delete fFi; fFi=0;} 
    if(fWijMin){
-     for(Int_t i=0; i<(2*nbinsM_min); i++) delete fWijMin[i];
+     for(Int_t i=0; i<(2*nbinsMmin); i++) delete fWijMin[i];
      delete [] fWijMin; fWijMin=0;
     }
    if(fFiMin) { delete fFiMin; fFiMin=0;}
@@ -234,6 +252,16 @@ void AliPtMothFromPtDaugh::DeleteWeights()
    return;
   }
 
+//______________________________________________________________________________________
+Bool_t AliPtMothFromPtDaugh::ReadHistoPtDaught(const TH1F *hist)
+  {
+   //Initialize daughter histograms with hist
+   if(!hist) {AliError("Set correct histograms of daughter! It doesn't exist!\n"); return kFALSE;}
+   if(fHistoPtDaughter) delete fHistoPtDaughter;
+   fHistoPtDaughter = (TH1F*)hist->Clone();
+   return kTRUE;
+  }
+
 //______________________________________________________________________________________
 Double_t* AliPtMothFromPtDaugh::SetBinsSize(Double_t ptmin, Double_t ptmax,Int_t nbins,Double_t alpha)
   {
@@ -242,7 +270,7 @@ Double_t* AliPtMothFromPtDaugh::SetBinsSize(Double_t ptmin, Double_t ptmax,Int_t
    // alpha = 1 equal binning size
    // alpha < 1 increasing  " 
    // alpha > 1 decreasing  "
-   if(ptmin<0 || ptmax<0 || nbins<=0 || alpha<=0) {AliWarning("Set correct bin-size: ptmin>=0, ptmax>=0, nbins>0, alpha>0! \n"); return 0;}
+   if(ptmin<0 || ptmax<0 || nbins<=0 || alpha<=0) {AliError("Set correct bin-size: ptmin>=0, ptmax>=0, nbins>0, alpha>0! \n"); return 0;}
    Double_t *edgebin = new Double_t[nbins+1];
    Double_t ptmin1=TMath::Power(ptmin,alpha);
    Double_t ptmax1=TMath::Power(ptmax,alpha);
@@ -261,7 +289,7 @@ void AliPtMothFromPtDaugh::SetBinsPtMoth(Double_t ptmin, Double_t ptmax,Int_t nb
    // alpha > 1 decreasing  "
    Double_t* edges = SetBinsSize(ptmin,ptmax,nbins,alpha);
    SetBinsPtMoth(nbins,edges);
-   delete edges;
+   delete [] edges;
    return;
   }
 
@@ -271,7 +299,7 @@ void AliPtMothFromPtDaugh::SetBinsPtMoth(Int_t nbins,Double_t *edgeBins)
    //set bin size given by the pointer edgeBins for pt-spectrum of mothers:
    //the dimension of the pointer edgeBins is nbins+1 and the points
    //has to be written in increasing order 
-   if(nbins<0) {AliWarning("Numbers of bins should be > 0 !\n"); return;}
+   if(nbins<0) {AliError("Numbers of bins should be > 0 !\n"); return;}
    if(fHistoPtMothers) {delete fHistoPtMothers; fHistoPtMothers=0;}
    fHistoPtMothers=new TH1F("fHistoPtMothers","Reconstructed p_{T}(Mothers)-spectrum",nbins,edgeBins);   
    return;
@@ -283,7 +311,7 @@ void AliPtMothFromPtDaugh::SetBinsPtMinMoth(Int_t nbins,Double_t *edgeBins)
    //set bin size given by the pointer edgeBins for ptMin-spectrum of mothers:
    //the dimension of the pointer edgeBins is nbins+1 and the points
    //has to be written in increasing order 
-   if(nbins<0) {AliWarning("Numbers of bins should be > 0 !\n"); return;}
+   if(nbins<0) {AliError("Numbers of bins should be > 0 !\n"); return;}
    if(fHistoPtMinMothers) {delete fHistoPtMinMothers; fHistoPtMinMothers=0;}
    fHistoPtMinMothers = new TH1F("fHistoPtMinMothers","Reconstructed p_{T}^{MIN}(Mothers)-spectrum",nbins,edgeBins);
    return;
@@ -299,7 +327,7 @@ void AliPtMothFromPtDaugh::SetBinsPtMinMoth(Double_t ptmin, Double_t ptmax,Int_t
    // alpha > 1 decreasing  "
    Double_t* edges = SetBinsSize(ptmin,ptmax,nbins,alpha);
    SetBinsPtMinMoth(nbins,edges);
-   delete edges;
+   delete [] edges;
    return;
   }
 
@@ -319,25 +347,26 @@ void AliPtMothFromPtDaugh::SetPdgMothers(Int_t n_mothers,Int_t *pdgM)
    // that the kUserAnalysis is the selected Analysis_mode. 
    // If not print out a message of error. 
    if(fAnalysisMode!=kUserAnalysis) {
-     AliWarning("Nothing done: set the mode to  kUserAnalysis first");
+     AliError("Nothing done: set the mode to  kUserAnalysis first");
      return;
    }
    //Set pdg codes of mothers given by the pointer pdgM for the analysis 
    SetPdgMothersPrivate(n_mothers,pdgM);
    return;
   }
+
 //______________________________________________________________________________________
 void AliPtMothFromPtDaugh::SetBeautyMothers()
   {
    // Set pdg codes of beauty particles:
    // B-mesons (1-24) B-barions (25-59)
-   Int_t PdgBeauty[]={511,521,513,523,10511,10521,10513,10523,20513,
+   Int_t pdgBeauty[]={511,521,513,523,10511,10521,10513,10523,20513,
       20523,515,525,531,10531,533,10533,205433,535,541,10541,543,10543,
       20543,545,5122,5112,5212,5222,5114,5214,5224,5132,5232,5312,5322,
       5314,5324,5332,5334,5142,5242,5412,5422,5414,5424,5342,5432,5434,
       5442,5444,5512,5522,5514,5524,5532,5534,5542,5544,5554};
    Int_t *pdgB=new Int_t[59];
-   for(Int_t i=0;i<59;i++) pdgB[i]=PdgBeauty[i];
+   for(Int_t i=0;i<59;i++) pdgB[i]=pdgBeauty[i];
    SetPdgMothersPrivate(59,pdgB);
   }
 
@@ -392,7 +421,7 @@ Bool_t AliPtMothFromPtDaugh::GetEtaMothers(Double_t &etaMin, Double_t &etaMax) c
    // pseudorapidity edges in etaMin and etaMax   
  
   if(fUseEta == kFALSE){
-        AliWarning("You are using RAPIDITY range! \n"); 
+        AliError("You are using RAPIDITY range! \n"); 
         etaMin = 0.;
         etaMax = 0.;
         return kFALSE;
@@ -410,7 +439,7 @@ Bool_t AliPtMothFromPtDaugh::GetEtaDaughter(Double_t &etaMin, Double_t &etaMax)
    // pseudorapidity edges in etaMin and etaMax   
 
    if(fUseEta == kFALSE){
-        AliWarning("You are using RAPIDITY range! \n"); 
+        AliError("You are using RAPIDITY range! \n"); 
         etaMin = 0.;
         etaMax = 0.; 
         return kFALSE;
@@ -428,7 +457,7 @@ Bool_t AliPtMothFromPtDaugh::GetYMothers(Double_t &yMin, Double_t &yMax) const
    // rapidity edges in yMin and yMax   
 
    if(fUseEta == kTRUE){
-        AliWarning("You are using PSEUDORAPIDITY range! \n"); 
+        AliError("You are using PSEUDORAPIDITY range! \n"); 
         yMin = 0.;
         yMax = 0.;
         return kFALSE;
@@ -446,7 +475,7 @@ Bool_t AliPtMothFromPtDaugh::GetYDaughter(Double_t &yMin, Double_t &yMax) const
    // rapidity edges in yMin and yMax 
 
    if(fUseEta == kTRUE){
-        AliWarning("You are using PSEUDORAPIDITY range! \n"); 
+        AliError("You are using PSEUDORAPIDITY range! \n"); 
         yMin = 0.;
         yMax = 0.;
         return kFALSE;
@@ -456,13 +485,45 @@ Bool_t AliPtMothFromPtDaugh::GetYDaughter(Double_t &yMin, Double_t &yMax) const
    return kTRUE;
   }
 
+
+//______________________________________________________________________________________
+void AliPtMothFromPtDaugh::SetPdgDaugh(Int_t pdgD)
+  { 
+   // Set pdg code for daughter particle. Check 
+   // that the kUserAnalysis is the selected Analysis_mode. 
+   // If not print out a message of error. 
+   switch(fAnalysisMode)
+    {
+    case kUserAnalysis:
+     fDaughter = pdgD;
+     break;
+    case kBtoJPSI:
+     if(pdgD!= 443) {AliError("Nothing done: first change AnalysisMode to kUserAnalysis");}
+     else {fDaughter = pdgD;} 
+     break;
+    case kBtoEle: 
+     if(pdgD!= 11) {AliError("Nothing done: first change AnalysisMode to kUserAnalysis");}
+     else {fDaughter = pdgD;} 
+     break;
+    case kBtoMuon: 
+     if(pdgD!= 13) {AliError("Nothing done: first change AnalysisMode to kUserAnalysis");}
+     else {fDaughter = pdgD;} 
+     break; 
+    case kBtoD0: 
+     if(pdgD!= 421) {AliError("Nothing done: first change AnalysisMode to kUserAnalysis");}
+     else {fDaughter = pdgD;}
+     break;
+    }
+   return;
+  } 
+
 //______________________________________________________________________________________
 Int_t* AliPtMothFromPtDaugh::GetPdgMothers(Int_t &n_mothers) const
   {
    // return the pointer to the array of pdg codes of mothers particles
    // if it exist. Put its dimension in n_mothers   
  
-   if(!fMothers) {AliWarning("Mothers pdg are not defined! \n"); return 0x0;} 
+   if(!fMothers) {AliError("Mothers pdg are not defined! \n"); return 0x0;} 
    n_mothers = fMothers->GetSize(); 
    return fMothers->GetArray();
   }
@@ -474,14 +535,14 @@ Double_t AliPtMothFromPtDaugh::GetW(Int_t i,Int_t j) const
    // j (pt-daughter bin index). Bin 0 is the underflow, bin nbins+1 the overflow. 
    // If Wij don't exist or the indices i or j are out of the variability range return 0 
     
-   if(!fWij) {AliWarning("Correction factors Wij are not been evaluated yet!\n"); return 0;}
-   if(!fHistoPtMothers) {AliWarning("mothers pt-histogram doesn't exist!\n"); return 0;}
-   if(!fHistoPtDaughter) {AliWarning("daughters pt-histogram doesn't exist!\n"); return 0;}
+   if(!fWij) {AliError("Correction factors Wij are not been evaluated yet!\n"); return 0;}
+   if(!fHistoPtMothers) {AliError("mothers pt-histogram doesn't exist!\n"); return 0;}
+   if(!fHistoPtDaughter) {AliError("daughters pt-histogram doesn't exist!\n"); return 0;}
    Int_t nbinsM=fHistoPtMothers->GetNbinsX()+2;
    Int_t nbinsD=fHistoPtDaughter->GetNbinsX()+2;
-   if(i<0 || i>nbinsM-1) {AliWarning(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow ",0,nbinsM-1,nbinsM-1)); return 0;} 
+   if(i<0 || i>nbinsM-1) {AliError(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow ",0,nbinsM-1,nbinsM-1)); return 0;} 
   
-   if(j<0 || j>nbinsD-1) {AliWarning(Form("Index j out of range: %d =< j =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsD-1,nbinsD-1)); return 0;}  
+   if(j<0 || j>nbinsD-1) {AliError(Form("Index j out of range: %d =< j =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsD-1,nbinsD-1)); return 0;}  
    return fWij[i][j];
   } 
 
@@ -493,14 +554,14 @@ Double_t AliPtMothFromPtDaugh::GetStatErrW(Int_t i,Int_t j) const
    // bin nbins+1 the overflow. If Wij don't exist or the indices i or j are out of the 
    // variability range return 0 
   
-   if(!fHistoPtMothers) {AliWarning("mothers pt-histogram doesn't exist!\n"); return 0;}
-   if(!fHistoPtDaughter) {AliWarning("daughters pt-histogram doesn't exist!\n"); return 0;}
+   if(!fHistoPtMothers) {AliError("mothers pt-histogram doesn't exist!\n"); return 0;}
+   if(!fHistoPtDaughter) {AliError("daughters pt-histogram doesn't exist!\n"); return 0;}
  
-   if(!fWij) {AliWarning("Correction factors Wij are not been evaluated yet!\n"); return 0;}
+   if(!fWij) {AliError("Correction factors Wij are not been evaluated yet!\n"); return 0;}
    Int_t nbinsM=fHistoPtMothers->GetNbinsX()+2;
    Int_t nbinsD=fHistoPtDaughter->GetNbinsX()+2;
-   if(i<0 || i>nbinsM-1) {AliWarning(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsM-1,nbinsM-1)); return 0;}
-   if(j<0 || j>nbinsD-1) {AliWarning(Form("Index j out of range: %d =< j =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsD-1,nbinsD-1)); return 0;}
+   if(i<0 || i>nbinsM-1) {AliError(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsM-1,nbinsM-1)); return 0;}
+   if(j<0 || j>nbinsD-1) {AliError(Form("Index j out of range: %d =< j =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsD-1,nbinsD-1)); return 0;}
    return fWij[i+nbinsM][j];
   }
 
@@ -511,10 +572,10 @@ Double_t AliPtMothFromPtDaugh::GetF(Int_t i) const
    // Bin 0 is the underflow, bin nbins+1 the overflow. 
    // If Fi don't exist or the index i is out of the variability range return 0     
   
-   if(!fFi) {AliWarning("Correction factors Fi are not been evaluated yet!\n"); return 0;}
-   if(!fHistoPtMothers) {AliWarning("mothers pt-histogram doesn't exist!\n"); return 0;}
+   if(!fFi) {AliError("Correction factors Fi are not been evaluated yet!\n"); return 0;}
+   if(!fHistoPtMothers) {AliError("mothers pt-histogram doesn't exist!\n"); return 0;}
    Int_t nbinsM=fHistoPtMothers->GetNbinsX()+2;
-   if(i<0 || i>nbinsM-1) {AliWarning(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsM-1,nbinsM-1)); return 0;}
+   if(i<0 || i>nbinsM-1) {AliError(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsM-1,nbinsM-1)); return 0;}
    return fFi[i];
   }
 
@@ -525,14 +586,14 @@ Double_t AliPtMothFromPtDaugh::GetStatErrF(Int_t i) const
    // Bin 0 is the underflow, bin nbins+1 the overflow. 
    // If Fi don't exist or the index i is out of the variability range return 0     
 
-   if(!fFi) {AliWarning("Correction factors Fi are not been evaluated yet!\n"); return 0;}
-   if(!fHistoPtMothers) {AliWarning("mothers pt-histogram doesn't exist!\n"); return 0;}
+   if(!fFi) {AliError("Correction factors Fi are not been evaluated yet!\n"); return 0;}
+   if(!fHistoPtMothers) {AliError("mothers pt-histogram doesn't exist!\n"); return 0;}
    Int_t nbinsM=fHistoPtMothers->GetNbinsX()+2;
-   if(i<0 || i>nbinsM-1) {AliWarning(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsM-1,nbinsM-1)); return 0;}
+   if(i<0 || i>nbinsM-1) {AliError(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsM-1,nbinsM-1)); return 0;}
 
    return fFi[i+nbinsM];
   }
+
 //______________________________________________________________________________________
 Double_t AliPtMothFromPtDaugh::GetWmin(Int_t i,Int_t j) const
   {
@@ -540,13 +601,13 @@ Double_t AliPtMothFromPtDaugh::GetWmin(Int_t i,Int_t j) const
    // j (pt-daughter bin index). Bin 0 is the underflow, bin nbins+1 the overflow. 
    // If Wij_min don't exist or the indices i or j are out of the variability range return 0  
     
-   if(!fWijMin) {AliWarning("Correction factors Wij_min are not been evaluated yet!\n"); return 0;}
-   if(!fHistoPtMinMothers) {AliWarning("mothers ptMin-histogram doesn't exist!\n"); return 0;}
-   if(!fHistoPtDaughter) {AliWarning("daughters pt-histogram doesn't exist!\n"); return 0;}
-   Int_t nbinsM_min=fHistoPtMinMothers->GetNbinsX()+2;
+   if(!fWijMin) {AliError("Correction factors Wij_min are not been evaluated yet!\n"); return 0;}
+   if(!fHistoPtMinMothers) {AliError("mothers ptMin-histogram doesn't exist!\n"); return 0;}
+   if(!fHistoPtDaughter) {AliError("daughters pt-histogram doesn't exist!\n"); return 0;}
+   Int_t nbinsMmin=fHistoPtMinMothers->GetNbinsX()+2;
    Int_t nbinsD=fHistoPtDaughter->GetNbinsX()+2;
-   if(i<0 || i>nbinsM_min-1) {AliWarning(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsM_min-1,nbinsM_min-1)); return 0;}
-   if(j<0 || j>nbinsD-1) {AliWarning(Form("Index j out of range: %d =< j =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsD-1,nbinsD-1)); return 0;}
+   if(i<0 || i>nbinsMmin-1) {AliError(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsMmin-1,nbinsMmin-1)); return 0;}
+   if(j<0 || j>nbinsD-1) {AliError(Form("Index j out of range: %d =< j =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsD-1,nbinsD-1)); return 0;}
    return fWijMin[i][j];
   }
 
@@ -558,15 +619,15 @@ Double_t AliPtMothFromPtDaugh::GetStatErrWmin(Int_t i,Int_t j) const
    // bin nbins+1 the overflow. If Wij_min don't exist or the indices i or j are out of the 
    // variability range return 0 
 
-   if(!fWijMin) {AliWarning("Correction factors Wij_min are not been evaluated yet!\n"); return 0;}
-   if(!fHistoPtMinMothers) {AliWarning("mothers ptMin-histogram doesn't exist!\n"); return 0;}
-   if(!fHistoPtDaughter) {AliWarning("daughters pt-histogram doesn't exist!\n"); return 0;}
-   Int_t nbinsM_min=fHistoPtMinMothers->GetNbinsX()+2;
+   if(!fWijMin) {AliError("Correction factors Wij_min are not been evaluated yet!\n"); return 0;}
+   if(!fHistoPtMinMothers) {AliError("mothers ptMin-histogram doesn't exist!\n"); return 0;}
+   if(!fHistoPtDaughter) {AliError("daughters pt-histogram doesn't exist!\n"); return 0;}
+   Int_t nbinsMmin=fHistoPtMinMothers->GetNbinsX()+2;
    Int_t nbinsD=fHistoPtDaughter->GetNbinsX()+2;
-   if(i<0 || i>nbinsM_min-1) {AliWarning(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsM_min-1,nbinsM_min-1)); return 0;}
-   if(j<0 || j>nbinsD-1) {AliWarning(Form("Index j out of range: %d =< j =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsD-1,nbinsD-1)); return 0;}
+   if(i<0 || i>nbinsMmin-1) {AliError(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsMmin-1,nbinsMmin-1)); return 0;}
+   if(j<0 || j>nbinsD-1) {AliError(Form("Index j out of range: %d =< j =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsD-1,nbinsD-1)); return 0;}
  
-   return fWijMin[i+nbinsM_min][j];
+   return fWijMin[i+nbinsMmin][j];
   }
 
 //______________________________________________________________________________________
@@ -576,10 +637,10 @@ Double_t AliPtMothFromPtDaugh::GetFmin(Int_t i) const
    // Bin 0 is the underflow, bin nbins+1 the overflow. 
    // If Fi_min don't exist or the index i is out of the variability range return 0     
 
-   if(!fFiMin) {AliWarning("Correction factors Fi_min are not been evaluated yet!\n"); return 0;}
-   if(!fHistoPtMinMothers) {AliWarning("mothers ptMin-histogram doesn't exist!\n"); return 0;}
-   Int_t nbinsM_min=fHistoPtMothers->GetNbinsX()+2;
-   if(i<0 || i>nbinsM_min-1) {AliWarning(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsM_min-1,nbinsM_min-1)); return 0;}
+   if(!fFiMin) {AliError("Correction factors Fi_min are not been evaluated yet!\n"); return 0;}
+   if(!fHistoPtMinMothers) {AliError("mothers ptMin-histogram doesn't exist!\n"); return 0;}
+   Int_t nbinsMmin=fHistoPtMothers->GetNbinsX()+2;
+   if(i<0 || i>nbinsMmin-1) {AliError(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsMmin-1,nbinsMmin-1)); return 0;}
    return fFiMin[i];
   }
 
@@ -590,101 +651,12 @@ Double_t AliPtMothFromPtDaugh::GetStatErrFmin(Int_t i) const
    // Bin 0 is the underflow, bin nbins+1 the overflow. 
    // If Fi_min don't exist or the index i is out of the variability range return 0     
 
-   if(!fFiMin) {AliWarning("Correction factors Fi_min are not been evaluated yet!\n"); return 0;}
-   if(!fHistoPtMinMothers) {AliWarning("mothers ptMin-histogram doesn't exist!\n"); return 0;}
-   Int_t nbinsM_min=fHistoPtMothers->GetNbinsX()+2;
-   if(i<0 || i>nbinsM_min-1) {AliWarning(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsM_min-1,nbinsM_min-1)); return 0;}
+   if(!fFiMin) {AliError("Correction factors Fi_min are not been evaluated yet!\n"); return 0;}
+   if(!fHistoPtMinMothers) {AliError("mothers ptMin-histogram doesn't exist!\n"); return 0;}
+   Int_t nbinsMmin=fHistoPtMothers->GetNbinsX()+2;
+   if(i<0 || i>nbinsMmin-1) {AliError(Form("Index i out of range: %d =< i =< %d. Bin 0 is the underflow - bin %d is the overflow.",0,nbinsMmin-1,nbinsMmin-1)); return 0;}
 
-   return fFiMin[i+nbinsM_min];
-  }
-
-//______________________________________________________________________________________
-Bool_t AliPtMothFromPtDaugh::ReadKinematics(const char *pathFileName)
-  {
-      /*Read the kinematic to create the Ntupla and store it in the file DecayKine.root:
-      if it is already created read it from the file DecayKine.root. Input: path of the
-      file galice.root. 
-      TNtupla contains:  pdg of Mothers  
-                          px      "       
-                          py     " 
-                          pz      "
-                        rapidity  "
-                         eta      "
-                          pdg of Daughter
-                          px      "       
-                          py      " 
-                          pz      "
-                        rapidity  "
-                         eta      "                                            */                                           
-    if(fReadKine)   
-     {
-      TFile *f = new TFile("DecayKine.root","READ");
-      if(!f) {AliWarning("File DecayKine.root with TNtupla doesn't exist!"); return kFALSE;}
-      fDecayKine=(TNtuple*)gDirectory->Get("DecayKine");
-      if(!fDecayKine) { AliWarning("The TNtupla doesn't exist!\n"); return kFALSE;}
-      return kTRUE;
-     }
-   if(!fMothers) { AliWarning("Set Pdg codes for mothers before to call ReadKinematic!\n"); return kFALSE;}
-   if(!fDaughter) { AliWarning("Set Pdg codes for daughter before to call ReadKinematic!\n"); return kFALSE;}
-   //declare the out file in which is stored the Ntupla
-   TFile *out = new TFile("DecayKine.root","RECREATE");
-   //create the TNtupla
-   if(fDecayKine) {delete fDecayKine; fDecayKine = 0;}
-   fDecayKine=new TNtuple("DecayKine","Decay kinematics",
-   "pdgM:pxM:pyM:pzM:yM:etaM:pdgD:pxD:pyD:pzD:yD:etaD");   
-   AliRunLoader *RunLoader = AliRunLoader::Open(pathFileName);
-   if(!RunLoader) { AliWarning("File galice.root not found!\n"); return kFALSE;}
-   AliStack *stack=NULL;  
-   RunLoader->LoadHeader();
-   RunLoader->LoadKinematics();
-   float *inf = new float[12]; 
-   Int_t pdg;
-   Int_t nEvents = RunLoader->GetNumberOfEvents();
-   //event loop
-   for(Int_t iEvent = 0; iEvent < nEvents; ++iEvent){
-    RunLoader->GetEvent(iEvent);
-    stack = RunLoader->Stack();
-    Int_t nPrims = stack->GetNprimary();
-    for (Int_t iTrack = 0; iTrack < nPrims; ++iTrack) {
-        TParticle *part = stack->Particle(iTrack);
-        pdg=TMath::Abs(part->GetPdgCode());
-        Double_t y,y2;
-           //check if particle is in mothers list  
-           Int_t labelDaugh; 
-           if(IsMothers(pdg))
-           {
-           //check if mother particle has a selected daugh
-           if(!IsSelectedDaugh(part,labelDaugh,stack)) continue;
-           TParticle *pDaugh=stack->Particle(labelDaugh);
-           Rapidity(part,y);
-           Rapidity(pDaugh,y2);
-
-           inf[0]=part->GetPdgCode();
-           inf[1]=part->Px();
-           inf[2]=part->Py();
-           inf[3]=part->Pz();
-           inf[4]=y;
-           inf[5]=part->Eta();
-           inf[6]=pDaugh->GetPdgCode();
-           inf[7]=pDaugh->Px();
-           inf[8]=pDaugh->Py();
-           inf[9]=pDaugh->Pz();
-           inf[10]=y2;
-           inf[11]=pDaugh->Eta();          
-  
-           fDecayKine->Fill(inf);
-           }//close if statement for mothers particles
-        }//end of tracks loop
-     }//end of events loop
-
-     RunLoader->UnloadHeader();
-     RunLoader->UnloadKinematics();
-     RunLoader->UnloadTrigger();
-     RunLoader->UnloadTrackRefs();
-     delete RunLoader;
-     out->cd();   
-     fDecayKine->Write();
-   return kTRUE;
+   return fFiMin[i+nbinsMmin];
   }
 
 //______________________________________________________________________________________
@@ -692,18 +664,20 @@ Bool_t AliPtMothFromPtDaugh::IsMothers(Int_t pdgCode)
   {
    //return kTRUE if pdgCode is in the list of pdg codes of mothers
    Int_t dim = fMothers->GetSize();
-   for(Int_t i=0;i<dim;i++) { if(pdgCode==fMothers->GetAt(i)) return kTRUE; }
+   for(Int_t i=0;i<dim;i++) { 
+    Int_t pdgMother = (Int_t)fMothers->GetAt(i); 
+    if(pdgCode == pdgMother) return kTRUE; }
    return kFALSE;
   }
 
 //______________________________________________________________________________________
-Bool_t AliPtMothFromPtDaugh::IsSelectedDaugh(const TParticle *part, Int_t &labelDaugh, AliStack *stack)
+Bool_t AliPtMothFromPtDaugh::IsSelectedDaugh(const TParticle *part, Int_t &labelDaugh, AliStack *const stack)
   {
    // return kTRUE if particle part has the selected daughter
    // if yes put the label of the track in labelDaugh  
    TParticle *daugh;
    Int_t nDg=part->GetNDaughters();
-   if(nDg<=0) {AliWarning("I have no daugh!\n"); return kFALSE;}
+   if(nDg<=0) {AliError("I have no daugh!\n"); return kFALSE;}
    for(Int_t i=part->GetFirstDaughter();i<part->GetLastDaughter()+1;i++)
      {
       daugh=stack->Particle(i);
@@ -727,7 +701,7 @@ Bool_t AliPtMothFromPtDaugh::Rapidity(const TParticle *particle, Double_t &y)
   }
 
 //______________________________________________________________________________________
-Int_t AliPtMothFromPtDaugh::GiveBinIndex(Double_t Ptpart,const TH1F *ptHist)
+Int_t AliPtMothFromPtDaugh::GiveBinIndex(Double_t Ptpart,const TH1F *ptHist) const
   {
    // Return the bin index of pt respect to the binning size of ptHist
    // bin 0 is the underflow - nbins+1 is the overflow  
@@ -763,16 +737,16 @@ Bool_t AliPtMothFromPtDaugh::EvaluateWij()
    // ptMinRaw distributions. Statistical errors on those are computed too
   
    if(!fHistoPtMothers || !fHistoPtDaughter || !fHistoPtMinMothers) 
-   {AliWarning("Control mother and daughter histograms!\n"); return kFALSE;}
+   {AliError("Control mother and daughter histograms!\n"); return kFALSE;}
 
    Int_t nbinsM=fHistoPtMothers->GetNbinsX()+2;
    Int_t nbinsD=fHistoPtDaughter->GetNbinsX()+2;
-   Int_t nbinsM_min=fHistoPtMinMothers->GetNbinsX()+2;
+   Int_t nbinsMmin=fHistoPtMinMothers->GetNbinsX()+2;
    Float_t pdgM, pdgD, pxM,pyM,pzM,yM,pxD,pyD,pzD,yD,etaM,etaD,cutVarM,cutVarD;
    Double_t* entries=new Double_t[nbinsD];
    for(Int_t ii=0;ii<nbinsD;ii++) {entries[ii]=0.;}
    Int_t i,j,iMin;
-   if(!fDecayKine) {AliWarning("TNtupla is not defined!\n"); return kFALSE;}
+   if(!fDecayKine) {AliError("TNtupla is not defined!\n"); return kFALSE;}
    fDecayKine->SetBranchAddress("pdgM",&pdgM);
    fDecayKine->SetBranchAddress("pxM",&pxM);
    fDecayKine->SetBranchAddress("pyM",&pyM);
@@ -787,14 +761,14 @@ Bool_t AliPtMothFromPtDaugh::EvaluateWij()
    fDecayKine->SetBranchAddress("etaD",&etaD);
    Double_t ptD,ptM;
    // Initialize correction factors for pT and pTmin if those exist
-   if(!fWij) {AliWarning("Correction factors Wij have not been created!\n"); return kFALSE;}
-   if(!fWijMin) {AliWarning("Correction factors Wij_min have not been created!\n"); return kFALSE;}
+   if(!fWij) {AliError("Correction factors Wij have not been created!\n"); return kFALSE;}
+   if(!fWijMin) {AliError("Correction factors Wij_min have not been created!\n"); return kFALSE;}
    for(Int_t ii=0;ii<(2*nbinsM);ii++){
      for(Int_t jj=0;jj<nbinsD;jj++){
         fWij[ii][jj]=0;
         }
       }
-   for(Int_t ii=0;ii<(2*nbinsM_min);ii++){
+   for(Int_t ii=0;ii<(2*nbinsMmin);ii++){
      for(Int_t jj=0;jj<nbinsD;jj++){
        fWijMin[ii][jj]=0;
       }
@@ -826,7 +800,7 @@ Bool_t AliPtMothFromPtDaugh::EvaluateWij()
    }
   for(Int_t jj=0;jj<nbinsD;jj++){
       for(Int_t ii=0;ii<nbinsM;ii++){
-         if(entries[jj]!=0){
+         if(entries[jj]>0){
            fWij[ii][jj]=fWij[ii][jj]/entries[jj];
            // evaluate statistical errors on fWij
            fWij[ii+nbinsM][jj]=(TMath::Sqrt(fWij[ii][jj]*(1-(fWij[ii][jj]/entries[jj]))))/entries[jj];
@@ -838,24 +812,23 @@ Bool_t AliPtMothFromPtDaugh::EvaluateWij()
            fWij[ii+nbinsM][jj]=999;
            }
          }
-      for(Int_t ii=0;ii<nbinsM_min;ii++){
-         if(entries[jj]!=0){
+      for(Int_t ii=0;ii<nbinsMmin;ii++){
+         if(entries[jj]>0){
             fWijMin[ii][jj]=fWijMin[ii][jj]/entries[jj];
             //evaluate statistical errors on fWijMin
-            fWijMin[ii+nbinsM_min][jj] = (TMath::Sqrt(fWijMin[ii][jj]*(1-(fWijMin[ii][jj]/entries[jj]))))/entries[jj]; 
+            fWijMin[ii+nbinsMmin][jj] = (TMath::Sqrt(fWijMin[ii][jj]*(1-(fWijMin[ii][jj]/entries[jj]))))/entries[jj]; 
             }
              else{
             //if there are no entries set correction factor = -1 and error = -999
             fWijMin[ii][jj]=-1;
-            fWijMin[ii+nbinsM_min][jj]=999;
+            fWijMin[ii+nbinsMmin][jj]=999;
            }
         }
     }
-   delete entries;
+   delete [] entries;
    return kTRUE;
   }
 
-
 //______________________________________________________________________________________
 Bool_t AliPtMothFromPtDaugh::EvaluateFi()
   {  
@@ -863,28 +836,28 @@ Bool_t AliPtMothFromPtDaugh::EvaluateFi()
    // raw distributions. Statistical errors on those are computed too  
 
    if(!fHistoPtMothers || !fHistoPtMinMothers)
-   {AliWarning("Control mother histograms!\n"); return kFALSE;}
+   {AliError("Control mother histograms!\n"); return kFALSE;}
 
    Int_t nbinsM=fHistoPtMothers->GetNbinsX()+2;
-   Int_t nbinsM_min=fHistoPtMinMothers->GetNbinsX()+2;
+   Int_t nbinsMmin=fHistoPtMinMothers->GetNbinsX()+2;
    Double_t* entries=new Double_t[nbinsM];
-   Double_t* entries1=new Double_t[nbinsM_min];
-   if(!fFi) {AliWarning("Correction factors Fi have not been created!\n"); return kFALSE;}
-   if(!fFiMin) {AliWarning("Correction factors Fi_min have not been created!\n"); return kFALSE;}
+   Double_t* entries1=new Double_t[nbinsMmin];
+   if(!fFi) {AliError("Correction factors Fi have not been created!\n"); return kFALSE;}
+   if(!fFiMin) {AliError("Correction factors Fi_min have not been created!\n"); return kFALSE;}
    //initialize the correction factor for pT and pTmin
    for(Int_t ii=0;ii<nbinsM;ii++){
        fFi[ii]=0.; //for correction factors
        fFi[ii+nbinsM]=0.; //for statistical error on correction factors
        entries[ii]=0.;
       }
-   for(Int_t ii=0;ii<nbinsM_min;ii++){
+   for(Int_t ii=0;ii<nbinsMmin;ii++){
        entries1[ii]=0.;
        fFiMin[ii]=0.; //for correction factors
-       fFiMin[ii+nbinsM_min]=0.; //for statistical error on correction factors       
+       fFiMin[ii+nbinsMmin]=0.; //for statistical error on correction factors       
       }
    Float_t pdgM, pdgD, pxM,pyM,pzM,yM,pxD,pyD,pzD,yD,etaM,etaD,cutVarD,cutVarM;
    Int_t i,iMin;
-   if(!fDecayKine) {AliWarning("TNtupla is not defined!\n"); return kFALSE;} 
+   if(!fDecayKine) {AliError("TNtupla is not defined!\n"); return kFALSE;} 
    fDecayKine->SetBranchAddress("pdgM",&pdgM);
    fDecayKine->SetBranchAddress("pxM",&pxM);
    fDecayKine->SetBranchAddress("pyM",&pyM);
@@ -925,26 +898,26 @@ Bool_t AliPtMothFromPtDaugh::EvaluateFi()
     fNcurrent++;
     nb = (Int_t) fDecayKine->GetEvent(fNcurrent);
     }
-    
+
   for(Int_t ii=0;ii<nbinsM;ii++){
-       if(entries[ii]!=0){
+       if(entries[ii]>0){
          fFi[ii]/=entries[ii];
          fFi[ii+nbinsM]=(TMath::Sqrt(fFi[ii]*(1-(fFi[ii]/entries[ii]))))/entries[ii];
         }
       else{
-                fFi[ii]=-1;
-        fFi[ii+nbinsM]=999;
-       }
+         fFi[ii]=-1;
+         fFi[ii+nbinsM]=999;
+        }
       }
-  for(Int_t ii=0;ii<nbinsM_min;ii++){
-     if(entries1[ii]!=0){
-       fFiMin[ii]/=entries1[ii];
-       fFiMin[ii+nbinsM_min]=(TMath::Sqrt(fFiMin[ii]*(1-(fFiMin[ii]/entries1[ii]))))/entries1[ii];
+  for(Int_t ii=0;ii<nbinsMmin;ii++){
+     if(entries1[ii]>0){
+        fFiMin[ii]/=entries1[ii];
+        fFiMin[ii+nbinsMmin]=(TMath::Sqrt(fFiMin[ii]*(1-(fFiMin[ii]/entries1[ii]))))/entries1[ii];
        }
-      else {fFiMin[ii]=-1; fFiMin[ii+nbinsM_min]=999;}
+      else {fFiMin[ii]=-1; fFiMin[ii+nbinsMmin]=999;}
      }
-   delete entries;
-   delete entries1;
+   delete [] entries;
+   delete [] entries1;
    return kTRUE;
   }
 
@@ -955,11 +928,11 @@ Bool_t AliPtMothFromPtDaugh::EvaluatePtMothRaw(TH1F *histoPt, TH1F *histoPtMin)
    //in order to evaluate the pt and ptMin raw distributions for mothers
 
    if(!fHistoPtMothers || !fHistoPtDaughter || !fHistoPtMinMothers)
-   {AliWarning("Control mother and daughter histograms!\n"); return kFALSE;}
+   {AliError("Control mother and daughter histograms!\n"); return kFALSE;}
 
    Int_t nbinsD=fHistoPtDaughter->GetNbinsX()+2;
    Int_t nbinsM=fHistoPtMothers->GetNbinsX()+2;
-   Int_t nbinsM_min=fHistoPtMinMothers->GetNbinsX()+2;
+   Int_t nbinsMmin=fHistoPtMinMothers->GetNbinsX()+2;
    Double_t lowedge=0.;
    Double_t wfill=0.;
    Double_t wMinfill=0.;
@@ -969,7 +942,7 @@ Bool_t AliPtMothFromPtDaugh::EvaluatePtMothRaw(TH1F *histoPt, TH1F *histoPtMin)
          if(fWij[i][j]>=0) wfill=fWij[i][j]*(fHistoPtDaughter->GetBinContent(j));
          histoPt->Fill(lowedge,wfill);
          }
-     for(Int_t i=0;i<nbinsM_min;i++){
+     for(Int_t i=0;i<nbinsMmin;i++){
          lowedge=fHistoPtMinMothers->GetBinLowEdge(i);
          if(fWijMin[i][j]>=0) wMinfill=fWijMin[i][j]*(fHistoPtDaughter->GetBinContent(j));
          histoPtMin->Fill(lowedge,wMinfill);
@@ -987,7 +960,7 @@ Bool_t AliPtMothFromPtDaugh::EvaluateErrPt(Double_t *erStat)
    // sigmaFi: contribution that came from the fFi factors 
 
    if(!fHistoPtMothers || !fHistoPtDaughter)
-   {AliWarning("Control mother(pt) and daughter histograms!\n"); return kFALSE;}
+   {AliError("Control mother(pt) and daughter histograms!\n"); return kFALSE;}
  
    Int_t nbinsM=fHistoPtMothers->GetNbinsX()+2;
    Int_t nbinsD=fHistoPtDaughter->GetNbinsX()+2;
@@ -1021,26 +994,26 @@ Bool_t AliPtMothFromPtDaugh::EvaluateErrPtMin(Double_t *erStat)
    // sigmaMinFi: contribution that came from the fFiMin factors  
    
    if(!fHistoPtDaughter || !fHistoPtMinMothers)
-   {AliWarning("Control mother(ptMin) and daughter histograms!\n"); return kFALSE;}
+   {AliError("Control mother(ptMin) and daughter histograms!\n"); return kFALSE;}
 
    Int_t nbinsD=fHistoPtDaughter->GetNbinsX()+2;
-   Int_t nbinsM_min=fHistoPtMinMothers->GetNbinsX()+2;
+   Int_t nbinsMmin=fHistoPtMinMothers->GetNbinsX()+2;
    Double_t m1=0;
    Double_t sigmaMinX;
    Double_t sigmaMinWij;
    Double_t sigmaMinFi;
-      for(Int_t i=0;i<nbinsM_min;i++){
+      for(Int_t i=0;i<nbinsMmin;i++){
         sigmaMinX=0.;
         sigmaMinWij=0.;
         sigmaMinFi=0.;
            for(Int_t j=0;j<nbinsD;j++){
             if(fWijMin[i][j]>=0){
             sigmaMinX+=(((fWijMin[i][j])*(fWijMin[i][j]))*((fHistoPtDaughter->GetBinError(j))*(fHistoPtDaughter->GetBinError(j))));
-            sigmaMinWij+=((fHistoPtDaughter->GetBinContent(j))*(fHistoPtDaughter->GetBinContent(j)))*(fWijMin[i+nbinsM_min][j]*fWijMin[i+nbinsM_min][j]);
+            sigmaMinWij+=((fHistoPtDaughter->GetBinContent(j))*(fHistoPtDaughter->GetBinContent(j)))*(fWijMin[i+nbinsMmin][j]*fWijMin[i+nbinsMmin][j]);
             sigmaMinFi+=(fWijMin[i][j])*(fHistoPtDaughter->GetBinContent(j));
            }
          }
-    if(fFiMin[i]>0) sigmaMinFi=((sigmaMinFi*sigmaMinFi)*(fFiMin[i+nbinsM_min]*fFiMin[i+nbinsM_min]))/(fFiMin[i]*fFiMin[i]);
+    if(fFiMin[i]>0) sigmaMinFi=((sigmaMinFi*sigmaMinFi)*(fFiMin[i+nbinsMmin]*fFiMin[i+nbinsMmin]))/(fFiMin[i]*fFiMin[i]);
     m1=TMath::Sqrt(sigmaMinX+sigmaMinWij+sigmaMinFi);
     if(fFiMin[i]>0) erStat[i]=(1/fFiMin[i])*m1;
     else erStat[i]=999;
@@ -1068,10 +1041,10 @@ Bool_t AliPtMothFromPtDaugh::EvaluatePtMoth()
    TH1F *histoPtMin=(TH1F*)fHistoPtMinMothers->Clone();
    EvaluatePtMothRaw(histoPt,histoPtMin);
    Int_t nbinsM=fHistoPtMothers->GetNbinsX()+2;
-   Int_t nbinsM_min=fHistoPtMinMothers->GetNbinsX()+2;
+   Int_t nbinsMmin=fHistoPtMinMothers->GetNbinsX()+2;
    Double_t *erPtStat=new Double_t[nbinsM+2];
    EvaluateErrPt(erPtStat);
-   Double_t *erPtMinStat=new Double_t[nbinsM_min+2];
+   Double_t *erPtMinStat=new Double_t[nbinsMmin+2];
    EvaluateErrPtMin(erPtMinStat); 
    Double_t lowedge=0;
    Double_t fwfill;
@@ -1085,7 +1058,7 @@ Bool_t AliPtMothFromPtDaugh::EvaluatePtMoth()
         fHistoPtMothers->SetBinError(i,erPtStat[i]);
        }
       }
-   for(Int_t i=0;i<nbinsM_min;i++){
+   for(Int_t i=0;i<nbinsMmin;i++){
       fMinfill=0.;
       lowedge=fHistoPtMinMothers->GetBinCenter(i);
       if(fFiMin[i]>0){
@@ -1102,9 +1075,9 @@ void AliPtMothFromPtDaugh::WritePtMothHistoToFile(char *fileOutName)
   {
    // Write pt and ptMin histograms of mothers in a file 
    // with name fileOutName. Default name is "Mothers.root".
-   AliWarning(Form("Write mothers histograms in the file %s \n",fileOutName));
-   if(!fHistoPtMothers) {AliWarning("Cannot write pt-mothers histogram! It doesn't exists!"); return;}
-   if(!fHistoPtMinMothers)  { AliWarning("Cannot write ptMin-mothers histogram! It doesn't exists!"); return;} 
+   AliError(Form("Write mothers histograms in the file %s \n",fileOutName));
+   if(!fHistoPtMothers) {AliError("Cannot write pt-mothers histogram! It doesn't exists!"); return;}
+   if(!fHistoPtMinMothers)  { AliError("Cannot write ptMin-mothers histogram! It doesn't exists!"); return;} 
    TFile *outFile = TFile::Open(fileOutName,"RECREATE");
    outFile->cd();
    fHistoPtMothers->Write();
@@ -1112,34 +1085,3 @@ void AliPtMothFromPtDaugh::WritePtMothHistoToFile(char *fileOutName)
    outFile->Close();
    return;  
   }
-
-//______________________________________________________________________________________
-void AliPtMothFromPtDaugh::SetPdgDaugh(Int_t pdgD)
-  { 
-   // Set pdg code for daughter particle. Check 
-   // that the kUserAnalysis is the selected Analysis_mode. 
-   // If not print out a message of error. 
-   switch(fAnalysisMode)
-    {
-    case kUserAnalysis:
-     fDaughter = pdgD;
-     break;
-    case kBtoJPSI:
-     if(pdgD!= 443) {AliWarning("Nothing done: first change AnalysisMode to kUserAnalysis");}
-     else {fDaughter = pdgD;} 
-     break;
-    case kBtoEle: 
-     if(pdgD!= 11) {AliWarning("Nothing done: first change AnalysisMode to kUserAnalysis");}
-     else {fDaughter = pdgD;} 
-     break;
-    case kBtoMuon: 
-     if(pdgD!= 13) {AliWarning("Nothing done: first change AnalysisMode to kUserAnalysis");}
-     else {fDaughter = pdgD;} 
-     break; 
-    case kBtoD0: 
-     if(pdgD!= 421) {AliWarning("Nothing done: first change AnalysisMode to kUserAnalysis");}
-     else {fDaughter = pdgD;}
-     break;
-    }
-   return;
-  }
\ No newline at end of file