further mods to include AliCFGridSparse, now included in compilation, and fixup for...
authorarcelli <arcelli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Jan 2008 19:29:29 +0000 (19:29 +0000)
committerarcelli <arcelli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Jan 2008 19:29:29 +0000 (19:29 +0000)
20 files changed:
CORRFW/AliCFContainer.cxx
CORRFW/AliCFContainer.h
CORRFW/AliCFDataGrid.cxx
CORRFW/AliCFDataGrid.h
CORRFW/AliCFEventClassCuts.cxx
CORRFW/AliCFEventRecCuts.cxx
CORRFW/AliCFGrid.cxx
CORRFW/AliCFGrid.h
CORRFW/AliCFGridSparse.cxx [new file with mode: 0755]
CORRFW/AliCFGridSparse.h [new file with mode: 0755]
CORRFW/AliCFTrackIsPrimaryCuts.cxx
CORRFW/AliCFTrackIsPrimaryCuts.h
CORRFW/AliCFTrackKineCuts.cxx
CORRFW/AliCFTrackKineCuts.h
CORRFW/AliCFTrackQualityCuts.cxx
CORRFW/AliCFTrackQualityCuts.h
CORRFW/AliCFVGrid.h
CORRFW/CORRFWLinkDef.h
CORRFW/libCORRFW.pkg
CORRFW/test/testCFContainers.C

index fad6919..7979f74 100644 (file)
@@ -26,7 +26,7 @@
 //
 #include <AliLog.h>
 #include "AliCFGrid.h"
-//#include "AliCFGridSparse.h"
+#include "AliCFGridSparse.h"
 #include "AliCFContainer.h"
 
 //____________________________________________________________________
@@ -52,7 +52,7 @@ AliCFContainer::AliCFContainer(const Char_t* name, const Char_t* title) :
 }
 
 //____________________________________________________________________
-AliCFContainer::AliCFContainer(const Char_t* name, const Char_t* title,const Int_t nSelSteps, const Int_t nVarIn, const Int_t * nBinIn, const Double_t *binLimitsIn) :  
+AliCFContainer::AliCFContainer(const Char_t* name, const Char_t* title,const Int_t nSelSteps, const Int_t nVarIn, const Int_t * nBinIn, const Double_t *binLimitsIn, const Bool_t useSparse) :  
   AliCFFrame(name,title,nVarIn,nBinIn,binLimitsIn),
   fNStep(0),
   fGrid(0x0)
@@ -69,8 +69,12 @@ AliCFContainer::AliCFContainer(const Char_t* name, const Char_t* title,const Int
   char gname[30];
   for(Int_t istep=0;istep<fNStep;istep++){
     sprintf(gname,"%s%s%i",GetName(),"_SelStep", istep);
-    fGrid[istep] = new AliCFGrid(gname,title,nVarIn,nBinIn,binLimitsIn); 
-    //fGrid[istep] = new AliCFGridSparse(gname,title,nVarIn,nBinIn,binLimitsIn); 
+    if(!useSparse){
+      fGrid[istep] = new AliCFGrid(gname,title,nVarIn,nBinIn,binLimitsIn); 
+      }
+    else{
+      fGrid[istep] = new AliCFGridSparse(gname,title,nVarIn,nBinIn,binLimitsIn); 
+    }
     fGrid[istep]->SumW2(); 
   }
 }
@@ -234,13 +238,6 @@ Float_t AliCFContainer::GetOverFlows( Int_t ivar, Int_t istep) const {
   return fGrid[istep]->GetOverFlows(ivar);
 } 
 //____________________________________________________________________
-Float_t AliCFContainer::GetOverFlows( Int_t istep) const {
-  //
-  // Get overflows in variable var at selection level istep
-  //
-  return fGrid[istep]->GetOverFlows();
-} 
-//____________________________________________________________________
 Float_t AliCFContainer::GetUnderFlows( Int_t ivar, Int_t istep) const {
   //
   // Get overflows in variable var at selection level istep
@@ -248,13 +245,6 @@ Float_t AliCFContainer::GetUnderFlows( Int_t ivar, Int_t istep) const {
   return fGrid[istep]->GetUnderFlows(ivar);
 } 
 //____________________________________________________________________
-Float_t AliCFContainer::GetUnderFlows( Int_t istep) const {
-  //
-  // Get overflows in variable var at selection level istep
-  //
-  return fGrid[istep]->GetUnderFlows();
-} 
-//____________________________________________________________________
 Float_t AliCFContainer::GetEntries( Int_t istep) const {
   //
   // Get overflows in variable var at selection level istep
index 47e91f1..c765714 100644 (file)
@@ -22,7 +22,7 @@ class AliCFContainer : public AliCFFrame
  public:
   AliCFContainer();
   AliCFContainer(const Char_t* name,const Char_t* title);
-  AliCFContainer(const Char_t* name, const Char_t* title,const Int_t nSelStep, const Int_t nVarIn, const Int_t* nBinIn, const Double_t  *binLimitsIn=0);
+  AliCFContainer(const Char_t* name, const Char_t* title,const Int_t nSelStep, const Int_t nVarIn, const Int_t* nBinIn, const Double_t  *binLimitsIn=0, const Bool_t useSparse = kFALSE);
   AliCFContainer(const AliCFContainer& c);
   
   virtual ~AliCFContainer();
@@ -33,8 +33,6 @@ class AliCFContainer : public AliCFFrame
 
   virtual Float_t GetOverFlows(Int_t var,Int_t istep) const;
   virtual Float_t GetUnderFlows(Int_t var,Int_t istep)const ;
-  virtual Float_t GetOverFlows(Int_t istep)const ;
-  virtual Float_t GetUnderFlows(Int_t istep)const ;
   virtual Float_t GetEntries(Int_t istep)const ;
   virtual Int_t   GetEmptyBins(Int_t istep)const ;
   virtual Int_t   GetEmptyBins(Int_t istep, Double_t *varMin,Double_t *varMax) const ;
index 95fd2d5..5a80f84 100644 (file)
@@ -205,7 +205,6 @@ void AliCFDataGrid::ApplyBGCorrection(const AliCFDataGrid &c)
       
   }
 }
-
 //____________________________________________________________________
 void AliCFDataGrid::Copy(TObject& eff) const
 {
index 20c669a..690aa7f 100644 (file)
@@ -39,7 +39,6 @@ class AliCFDataGrid : public AliCFGrid
   virtual void  ApplyEffCorrection(const AliCFEffGrid &eff);
   virtual void  ApplyBGCorrection(const AliCFDataGrid &c);
   virtual void  SetContainer(const AliCFContainer &c) {fContainer=&c;};
-
   //basic operations
   virtual void   Copy(TObject& data) const;
  
index 0011494..23f6f45 100644 (file)
@@ -400,43 +400,43 @@ void AliCFEventClassCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t *b
 
   switch(index){
   case kTrigger:
-    fhNBinsTrigger=nbins;
+    fhNBinsTrigger=nbins+1;
     fhBinLimTrigger=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimTrigger[i]=bins[i];
     break;
     
   case kZDCEnergyN1:
-    fhNBinsZDCEnN1=nbins;
+    fhNBinsZDCEnN1=nbins+1;
     fhBinLimZDCEnN1=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimZDCEnN1[i]=bins[i];
     break;
 
   case kZDCEnergyP1:
-    fhNBinsZDCEnP1=nbins;
+    fhNBinsZDCEnP1=nbins+1;
     fhBinLimZDCEnP1=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimZDCEnP1[i]=bins[i];
     break;
 
   case kZDCEnergyN2:
-    fhNBinsZDCEnN2=nbins;
+    fhNBinsZDCEnN2=nbins+1;
     fhBinLimZDCEnN2=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimZDCEnN2[i]=bins[i];
     break;
 
   case kZDCEnergyP2:
-    fhNBinsZDCEnP2=nbins;
+    fhNBinsZDCEnP2=nbins+1;
     fhBinLimZDCEnP2=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimZDCEnP2[i]=bins[i];
     break;
 
   case kZDCEnergyEM1:
-    fhNBinsZDCEnEM1=nbins;
+    fhNBinsZDCEnEM1=nbins+1;
     fhBinLimZDCEnEM1=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimZDCEnEM1[i]=bins[i];
     break;
 
   case kZDCEnergyEM2:
-    fhNBinsZDCEnEM2=nbins;
+    fhNBinsZDCEnEM2=nbins+1;
     fhBinLimZDCEnEM2=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimZDCEnEM2[i]=bins[i];
     break;
@@ -454,43 +454,43 @@ void AliCFEventClassCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xm
   //
   switch(index){
   case kTrigger:
-    fhNBinsTrigger=nbins;
+    fhNBinsTrigger=nbins+1;
     fhBinLimTrigger=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimTrigger[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
     
   case kZDCEnergyN1:
-    fhNBinsZDCEnN1=nbins;
+    fhNBinsZDCEnN1=nbins+1;
     fhBinLimZDCEnN1=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimZDCEnN1[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kZDCEnergyP1:
-    fhNBinsZDCEnP1=nbins;
+    fhNBinsZDCEnP1=nbins+1;
     fhBinLimZDCEnP1=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimZDCEnP1[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kZDCEnergyN2:
-    fhNBinsZDCEnN2=nbins;
+    fhNBinsZDCEnN2=nbins+1;
     fhBinLimZDCEnN2=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimZDCEnN2[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kZDCEnergyP2:
-    fhNBinsZDCEnP2=nbins;
+    fhNBinsZDCEnP2=nbins+1;
     fhBinLimZDCEnP2=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimZDCEnP2[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kZDCEnergyEM1:
-    fhNBinsZDCEnEM1=nbins;
+    fhNBinsZDCEnEM1=nbins+1;
     fhBinLimZDCEnEM1=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimZDCEnEM1[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kZDCEnergyEM2:
-    fhNBinsZDCEnEM2=nbins;
+    fhNBinsZDCEnEM2=nbins+1;
     fhBinLimZDCEnEM2=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimZDCEnEM2[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
@@ -516,13 +516,13 @@ void AliCFEventClassCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xm
     if (i==0) sprintf(str," ");
     else sprintf(str,"_cut");
 
-    fhQA[kTrigger][i]  = new  TH1F(Form("%s_TriggerBits%s",GetName(),str),                     "",fhNBinsTrigger,fhBinLimTrigger);
-    fhQA[kZDCEnergyN1][i]      = new  TH1F(Form("%s_ZDC_Energy_N1%s",GetName(),str),           "",fhNBinsZDCEnN1,fhBinLimZDCEnN1);
-    fhQA[kZDCEnergyP1][i]      = new  TH1F(Form("%s_ZDC_Energy_P1%s",GetName(),str),           "",fhNBinsZDCEnP1,fhBinLimZDCEnP1);
-    fhQA[kZDCEnergyN2][i]      = new  TH1F(Form("%s_ZDC_Energy_N2%s",GetName(),str),           "",fhNBinsZDCEnN2,fhBinLimZDCEnN2);
-    fhQA[kZDCEnergyP2][i]      = new  TH1F(Form("%s_ZDC_Energy_P2%s",GetName(),str),           "",fhNBinsZDCEnP2,fhBinLimZDCEnP2);
-    fhQA[kZDCEnergyEM1][i]     = new  TH1F(Form("%s_ZDC_Energy_EM1%s",GetName(),str),          "",fhNBinsZDCEnEM1,fhBinLimZDCEnEM1);
-    fhQA[kZDCEnergyEM2][i]     = new  TH1F(Form("%s_ZDC_Energy_EM2%s",GetName(),str),          "",fhNBinsZDCEnEM2,fhBinLimZDCEnEM2);
+    fhQA[kTrigger][i]  = new  TH1F(Form("%s_TriggerBits%s",GetName(),str),                     "",fhNBinsTrigger-1,fhBinLimTrigger);
+    fhQA[kZDCEnergyN1][i]      = new  TH1F(Form("%s_ZDC_Energy_N1%s",GetName(),str),           "",fhNBinsZDCEnN1-1,fhBinLimZDCEnN1);
+    fhQA[kZDCEnergyP1][i]      = new  TH1F(Form("%s_ZDC_Energy_P1%s",GetName(),str),           "",fhNBinsZDCEnP1-1,fhBinLimZDCEnP1);
+    fhQA[kZDCEnergyN2][i]      = new  TH1F(Form("%s_ZDC_Energy_N2%s",GetName(),str),           "",fhNBinsZDCEnN2-1,fhBinLimZDCEnN2);
+    fhQA[kZDCEnergyP2][i]      = new  TH1F(Form("%s_ZDC_Energy_P2%s",GetName(),str),           "",fhNBinsZDCEnP2-1,fhBinLimZDCEnP2);
+    fhQA[kZDCEnergyEM1][i]     = new  TH1F(Form("%s_ZDC_Energy_EM1%s",GetName(),str),          "",fhNBinsZDCEnEM1-1,fhBinLimZDCEnEM1);
+    fhQA[kZDCEnergyEM2][i]     = new  TH1F(Form("%s_ZDC_Energy_EM2%s",GetName(),str),          "",fhNBinsZDCEnEM2-1,fhBinLimZDCEnEM2);
 
 
     fhQA[kTrigger][i]          ->SetXTitle("Trigger Bits");
index 9796c99..469dbda 100644 (file)
@@ -394,37 +394,37 @@ void AliCFEventRecCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t *bin
 
   switch(index){
   case kNTracks:
-    fhNBinsNTracks=nbins;
+    fhNBinsNTracks=nbins+1;
     fhBinLimNTracks=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimNTracks[i]=bins[i];
     break;
   case kVtxPosX:
-    fhNBinsVtxPosX=nbins;
+    fhNBinsVtxPosX=nbins+1;
     fhBinLimVtxPosX=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimVtxPosX[i]=bins[i];
     break;
   case kVtxPosY:
-    fhNBinsVtxPosY=nbins;
+    fhNBinsVtxPosY=nbins+1;
     fhBinLimVtxPosY=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimVtxPosY[i]=bins[i];
     break;
   case kVtxPosZ:
-    fhNBinsVtxPosZ=nbins;
+    fhNBinsVtxPosZ=nbins+1;
     fhBinLimVtxPosZ=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimVtxPosZ[i]=bins[i];
     break;
   case kVtxResX:
-    fhNBinsVtxResX=nbins;
+    fhNBinsVtxResX=nbins+1;
     fhBinLimVtxResX=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimVtxResX[i]=bins[i];
     break;
   case kVtxResY:
-    fhNBinsVtxResY=nbins;
+    fhNBinsVtxResY=nbins+1;
     fhBinLimVtxResY=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimVtxResY[i]=bins[i];
     break;
   case kVtxResZ:
-    fhNBinsVtxResZ=nbins;
+    fhNBinsVtxResZ=nbins+1;
     fhBinLimVtxResZ=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimVtxResZ[i]=bins[i];
     break;
@@ -441,37 +441,37 @@ void AliCFEventRecCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmin
   //
   switch(index){
   case kNTracks:
-    fhNBinsNTracks=nbins;
+    fhNBinsNTracks=nbins+1;
     fhBinLimNTracks=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimNTracks[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
   case kVtxPosX:
-    fhNBinsVtxPosX=nbins;
+    fhNBinsVtxPosX=nbins+1;
     fhBinLimVtxPosX=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimVtxPosX[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
   case kVtxPosY:
-    fhNBinsVtxPosY=nbins;
+    fhNBinsVtxPosY=nbins+1;
     fhBinLimVtxPosY=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimVtxPosY[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
   case kVtxPosZ:
-    fhNBinsVtxPosZ=nbins;
+    fhNBinsVtxPosZ=nbins+1;
     fhBinLimVtxPosZ=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimVtxPosZ[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
   case kVtxResX:
-    fhNBinsVtxResX=nbins;
+    fhNBinsVtxResX=nbins+1;
     fhBinLimVtxResX=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimVtxResX[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
   case kVtxResY:
-    fhNBinsVtxResY=nbins;
+    fhNBinsVtxResY=nbins+1;
     fhBinLimVtxResY=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimVtxResY[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
   case kVtxResZ:
-    fhNBinsVtxResZ=nbins;
+    fhNBinsVtxResZ=nbins+1;
     fhBinLimVtxResZ=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimVtxResZ[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
@@ -497,14 +497,14 @@ void AliCFEventRecCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmin
     if (i==0) sprintf(str," ");
     else sprintf(str,"_cut");
 
-    fhQA[kNTracks][i]  = new  TH1F(Form("%s_NTracks%s",GetName(),str),                 "",fhNBinsNTracks,fhBinLimNTracks);
-    fhQA[kVtxPosX][i]  = new  TH1F(Form("%s_Vtx_Pos_X%s",GetName(),str),               "",fhNBinsVtxPosX,fhBinLimVtxPosX);
-    fhQA[kVtxPosY][i]  = new  TH1F(Form("%s_Vtx_Pos_Y%s",GetName(),str),               "",fhNBinsVtxPosY,fhBinLimVtxPosY);
-    fhQA[kVtxPosZ][i]  = new  TH1F(Form("%s_Vtx_Pos_Z%s",GetName(),str),               "",fhNBinsVtxPosZ,fhBinLimVtxPosZ);
+    fhQA[kNTracks][i]  = new  TH1F(Form("%s_NTracks%s",GetName(),str),                 "",fhNBinsNTracks-1,fhBinLimNTracks);
+    fhQA[kVtxPosX][i]  = new  TH1F(Form("%s_Vtx_Pos_X%s",GetName(),str),               "",fhNBinsVtxPosX-1,fhBinLimVtxPosX);
+    fhQA[kVtxPosY][i]  = new  TH1F(Form("%s_Vtx_Pos_Y%s",GetName(),str),               "",fhNBinsVtxPosY-1,fhBinLimVtxPosY);
+    fhQA[kVtxPosZ][i]  = new  TH1F(Form("%s_Vtx_Pos_Z%s",GetName(),str),               "",fhNBinsVtxPosZ-1,fhBinLimVtxPosZ);
 
-    fhQA[kVtxResX][i]  = new  TH1F(Form("%s_Vtx_Res_X%s",GetName(),str),               "",fhNBinsVtxResX,fhBinLimVtxResX);
-    fhQA[kVtxResY][i]  = new  TH1F(Form("%s_Vtx_Res_Y%s",GetName(),str),               "",fhNBinsVtxResY,fhBinLimVtxResY);
-    fhQA[kVtxResZ][i]  = new  TH1F(Form("%s_Vtx_Res_Z%s",GetName(),str),               "",fhNBinsVtxResZ,fhBinLimVtxResZ);
+    fhQA[kVtxResX][i]  = new  TH1F(Form("%s_Vtx_Res_X%s",GetName(),str),               "",fhNBinsVtxResX-1,fhBinLimVtxResX);
+    fhQA[kVtxResY][i]  = new  TH1F(Form("%s_Vtx_Res_Y%s",GetName(),str),               "",fhNBinsVtxResY-1,fhBinLimVtxResY);
+    fhQA[kVtxResZ][i]  = new  TH1F(Form("%s_Vtx_Res_Z%s",GetName(),str),               "",fhNBinsVtxResZ-1,fhBinLimVtxResZ);
  
     fhQA[kNTracks][i]  ->SetXTitle("Number of ESD tracks");
     fhQA[kVtxPosX][i]  ->SetXTitle("Vertex Position X (cm)");
index d92c750..17f16dc 100644 (file)
@@ -41,8 +41,6 @@ ClassImp(AliCFGrid)
 //____________________________________________________________________
 AliCFGrid::AliCFGrid() : 
   AliCFVGrid(),
-  fNunflTot(0),
-  fNovflTot(0),
   fNentriesTot(0),
   fNunfl(0x0),
   fNovfl(0x0),
@@ -54,8 +52,6 @@ AliCFGrid::AliCFGrid() :
 //____________________________________________________________________
 AliCFGrid::AliCFGrid(const Char_t* name, const Char_t* title) : 
   AliCFVGrid(name,title),
-  fNunflTot(0),
-  fNovflTot(0),
   fNentriesTot(0),
   fNunfl(0x0),
   fNovfl(0x0),
@@ -68,8 +64,6 @@ AliCFGrid::AliCFGrid(const Char_t* name, const Char_t* title) :
 //____________________________________________________________________
 AliCFGrid::AliCFGrid(const Char_t* name, const Char_t* title, const Int_t nVarIn, const Int_t * nBinIn, const Double_t *binLimitsIn) :  
   AliCFVGrid(name,title,nVarIn,nBinIn,binLimitsIn),
-  fNunflTot(0),
-  fNovflTot(0),
   fNentriesTot(0),
   fNunfl(0x0),
   fNovfl(0x0),
@@ -86,8 +80,6 @@ AliCFGrid::AliCFGrid(const Char_t* name, const Char_t* title, const Int_t nVarIn
 
 
   //Initialization
-  fNunflTot =0;
-  fNovflTot =0;
   fNentriesTot =0;
   for(Int_t j=0;j<fNVar;j++){
     fNunfl[j] =0;
@@ -106,8 +98,6 @@ AliCFGrid::AliCFGrid(const Char_t* name, const Char_t* title, const Int_t nVarIn
 //____________________________________________________________________
 AliCFGrid::AliCFGrid(const AliCFGrid& c) : 
   AliCFVGrid(c),
-  fNunflTot(0),
-  fNovflTot(0),
   fNentriesTot(0),
   fNunfl(0x0),
   fNovfl(0x0),
@@ -462,8 +452,6 @@ void AliCFGrid::Fill(Double_t *var, Double_t weight)
   // Total number of entries, overflows and underflows
 
   fNentriesTot++;
-  if(isunfl)fNunflTot++;
-  if(isovfl)fNovflTot++;
 
   //if not ovfl/unfl, fill the element  
 
@@ -481,13 +469,6 @@ Float_t AliCFGrid::GetOverFlows( Int_t ivar) const {
   return fNovfl[ivar];
 } 
 //____________________________________________________________________
-Float_t AliCFGrid::GetOverFlows() const {
-  //
-  // Get overflows 
-  //
-  return fNovflTot;
-} 
-//____________________________________________________________________
 Float_t AliCFGrid::GetUnderFlows( Int_t ivar) const {
   //
   // Get overflows in variable var 
@@ -495,13 +476,6 @@ Float_t AliCFGrid::GetUnderFlows( Int_t ivar) const {
   return fNunfl[ivar];
 } 
 //____________________________________________________________________
-Float_t AliCFGrid::GetUnderFlows() const {
-  //
-  // Get overflows 
-  //
-  return fNunflTot;
-} 
-//____________________________________________________________________
 Float_t AliCFGrid::GetEntries( ) const {
   //
   // Get total entries (in grid + over/underflows) 
@@ -863,11 +837,9 @@ void AliCFGrid::Add(AliCFVGrid* aGrid, Double_t c)
   //Add entries, overflows and underflows
 
   fNentriesTot+= c*aGrid->GetEntries();
-  fNunflTot+= c*aGrid->GetUnderFlows();
-  fNovflTot+= c*aGrid->GetOverFlows();
   for(Int_t j=0;j<fNVar;j++){
     fNunfl[j]+= c*aGrid->GetUnderFlows(j);
-    fNovfl[j]+= c*aGrid->GetUnderFlows(j);
+    fNovfl[j]+= c*aGrid->GetOverFlows(j);
   }
 }
 //____________________________________________________________________
@@ -904,11 +876,9 @@ void AliCFGrid::Add(AliCFVGrid* aGrid1, AliCFVGrid* aGrid2, Double_t c1,Double_t
   //Add entries, overflows and underflows
 
   fNentriesTot= c1*aGrid1->GetEntries()+c2*aGrid2->GetEntries();
-  fNunflTot= c1*aGrid1->GetUnderFlows()+c2*aGrid2->GetUnderFlows();
-  fNovflTot= c1*aGrid1->GetOverFlows()+c2*aGrid2->GetOverFlows();
   for(Int_t j=0;j<fNVar;j++){
     fNunfl[j]= c1*aGrid1->GetUnderFlows(j)+c2*aGrid2->GetUnderFlows(j);
-    fNovfl[j]= c1*aGrid1->GetUnderFlows(j)+c2*aGrid2->GetUnderFlows(j);
+    fNovfl[j]= c1*aGrid1->GetOverFlows(j)+c2*aGrid2->GetOverFlows(j);
   }
 }
 //____________________________________________________________________
@@ -945,11 +915,9 @@ void AliCFGrid::Multiply(AliCFVGrid* aGrid, Double_t c)
   //Set entries to the number of bins, preserve original overflows and underflows
 
   fNentriesTot=fNDim;
-  fNunflTot=GetUnderFlows();
-  fNovflTot=GetOverFlows();
   for(Int_t j=0;j<fNVar;j++){
     fNunfl[j]= GetUnderFlows(j);
-    fNovfl[j]= GetUnderFlows(j);
+    fNovfl[j]= GetOverFlows(j);
   }
 }
 //____________________________________________________________________
@@ -985,11 +953,9 @@ void AliCFGrid::Multiply(AliCFVGrid* aGrid1, AliCFVGrid* aGrid2, Double_t c1, Do
   //Set entries to the number of bins, preserve original overflows and underflows
 
   fNentriesTot=fNDim;
-  fNunflTot=GetUnderFlows();
-  fNovflTot=GetOverFlows();
   for(Int_t j=0;j<fNVar;j++){
     fNunfl[j]= GetUnderFlows(j);
-    fNovfl[j]= GetUnderFlows(j);
+    fNovfl[j]= GetOverFlows(j);
   }
 }
 //____________________________________________________________________
@@ -1029,11 +995,9 @@ void AliCFGrid::Divide(AliCFVGrid* aGrid, Double_t c)
   //Set entries to the number of bins, preserve original overflows and underflows
 
   fNentriesTot=fNDim;
-  fNunflTot=GetUnderFlows();
-  fNovflTot=GetOverFlows();
   for(Int_t j=0;j<fNVar;j++){
     fNunfl[j]= GetUnderFlows(j);
-    fNovfl[j]= GetUnderFlows(j);
+    fNovfl[j]= GetOverFlows(j);
   }
 }
 //____________________________________________________________________
@@ -1086,11 +1050,9 @@ void AliCFGrid::Divide(AliCFVGrid* aGrid1, AliCFVGrid* aGrid2, Double_t c1,Doubl
   //Set entries to the number of bins, preserve original overflows and underflows
 
   fNentriesTot=fNDim;
-  fNunflTot=GetUnderFlows();
-  fNovflTot=GetOverFlows();
   for(Int_t j=0;j<fNVar;j++){
     fNunfl[j]= GetUnderFlows(j);
-    fNovfl[j]= GetUnderFlows(j);
+    fNovfl[j]= GetOverFlows(j);
   }
 }
 //____________________________________________________________________
@@ -1117,8 +1079,6 @@ void AliCFGrid::Copy(TObject& c) const
   //
   AliCFGrid& target = (AliCFGrid &) c;
 
-  target.fNunflTot = fNunflTot;
-  target.fNovflTot = fNovflTot;
   target.fNentriesTot = fNentriesTot;
   if (fNunfl)
     target.fNunfl = fNunfl;
index 5722d6c..ac77ed3 100644 (file)
@@ -30,8 +30,6 @@ class AliCFGrid : public AliCFVGrid
 
   virtual Float_t GetOverFlows(Int_t var) const;
   virtual Float_t GetUnderFlows(Int_t var)const ;
-  virtual Float_t GetOverFlows()const ;
-  virtual Float_t GetUnderFlows()const ;
   virtual Float_t GetEntries()const ;
 
   virtual Float_t GetElement(Int_t iel)const; 
@@ -66,8 +64,6 @@ class AliCFGrid : public AliCFVGrid
   
  protected:
 
-  Float_t  fNunflTot;//Total number of underflows
-  Float_t  fNovflTot;//Total number of underflows
   Float_t  fNentriesTot;//Total number of entries 
   Float_t  *fNunfl;//[fNVar] underflows in each dimension
   Float_t  *fNovfl;//[fNVar] overflows in each dimension
@@ -75,7 +71,7 @@ class AliCFGrid : public AliCFVGrid
   Float_t  *fErr2;//[fNDim] The squared weights Container (only with SumW2)
 
   
-  ClassDef(AliCFGrid,2);
+  ClassDef(AliCFGrid,4);
 };
     
 #endif
diff --git a/CORRFW/AliCFGridSparse.cxx b/CORRFW/AliCFGridSparse.cxx
new file mode 100755 (executable)
index 0000000..33a0e52
--- /dev/null
@@ -0,0 +1,599 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+//--------------------------------------------------------------------//
+//                                                                    //
+// AliCFGridSparse Class                                              //
+// Class to accumulate data on an N-dimensional grid, to be used      //
+// as input to get corrections for Reconstruction & Trigger efficiency// 
+// Based on root THnSparse                                            //
+// -- Author : S.Arcelli                                              //
+// Still to be done:                                                  //
+// --Interpolate among bins in a range                                // 
+//--------------------------------------------------------------------//
+//
+//
+#include "AliCFGridSparse.h"
+#include "THnSparse.h"
+#include "AliLog.h"
+#include "TMath.h"
+#include "TROOT.h"
+#include "TH1D.h"
+#include "TH2D.h"
+#include "TH3D.h"
+#include "TAxis.h"
+
+//____________________________________________________________________
+ClassImp(AliCFGridSparse)
+
+//____________________________________________________________________
+AliCFGridSparse::AliCFGridSparse() : 
+  AliCFVGrid(),
+  fExcludeOffEntries(kTRUE),
+  fData(0x0)
+{
+  // default constructor
+}
+//____________________________________________________________________
+AliCFGridSparse::AliCFGridSparse(const Char_t* name, const Char_t* title) : 
+  AliCFVGrid(name,title),
+  fExcludeOffEntries(kTRUE),
+  fData(0x0)
+{
+  // default constructor
+}
+//____________________________________________________________________
+AliCFGridSparse::AliCFGridSparse(const Char_t* name, const Char_t* title, const Int_t nVarIn, const Int_t * nBinIn, const Double_t *binLimitsIn) :  
+  AliCFVGrid(name,title,nVarIn,nBinIn,binLimitsIn),
+  fExcludeOffEntries(kTRUE),
+  fData(0x0)
+{
+  //
+  // main constructor
+  //
+
+  fData=new THnSparseF(name,title,fNVar,fNVarBins);
+  
+  if(binLimitsIn){
+    for(Int_t ivar=0;ivar<fNVar;ivar++){    
+      Int_t nbins=fNVarBins[ivar]+1;
+      Double_t *array= new Double_t[nbins];
+      for(Int_t i=0;i<nbins;i++){
+       array[i]=fVarBinLimits[fOffset[ivar]+i];
+      } 
+      fData->SetBinEdges(ivar, array);
+      delete array;
+    }
+  }
+}
+//____________________________________________________________________
+AliCFGridSparse::AliCFGridSparse(const AliCFGridSparse& c) : 
+  AliCFVGrid(c),
+  fExcludeOffEntries(c.fExcludeOffEntries),
+  fData(c.fData)
+{
+  //
+  // copy constructor
+  //
+  ((AliCFGridSparse &)c).Copy(*this);
+}
+
+//____________________________________________________________________
+AliCFGridSparse::~AliCFGridSparse()
+{
+  //
+  // destructor
+  //
+  if(fData) delete fData;
+}
+
+//____________________________________________________________________
+AliCFGridSparse &AliCFGridSparse::operator=(const AliCFGridSparse &c)
+{
+  //
+  // assigment operator
+  //
+  if (this != &c)
+    ((AliCFGridSparse &) c).Copy(*this);
+  return *this;
+} 
+
+//____________________________________________________________________
+void AliCFGridSparse::SetBinLimits(Int_t ivar, Double_t *array)
+{
+  //
+  // setting the arrays containing the bin limits 
+  //
+  fData->SetBinEdges(ivar, array);
+  //then fill the appropriate array in ALICFFrame, to be able to use 
+  //the getter, in case....
+  Int_t nbins=fNVarBins[ivar]+1;
+  for(Int_t i=0;i<nbins;i++){
+    fVarBinLimits[fOffset[ivar]+i] =array[i];
+  } 
+} 
+
+//____________________________________________________________________
+void AliCFGridSparse::Fill(Double_t *var, Double_t weight)
+{
+  //
+  // Fill the grid,
+  // given a set of values of the input variable, 
+  // with weight (by default w=1)
+  //
+  fData->Fill(var,weight);
+}
+
+//___________________________________________________________________
+TH1D *AliCFGridSparse::Project(Int_t ivar) const
+{
+  //
+  // Make a 1D projection along variable ivar 
+  //
+
+  //exclude overflows by default (used in projections)
+  if(fExcludeOffEntries){
+    for(Int_t i=0;i<fNVar;i++){
+      fData->GetAxis(i)->SetBit(TAxis::kAxisRange);
+    }
+  }
+  TH1D *hist=fData->Projection(ivar);
+  Float_t sum=0;
+  for(Int_t i=1;i<=fNVarBins[ivar]; i++){
+    sum+=hist->GetBinContent(i);
+  }
+
+  hist->SetEntries(sum+GetOverFlows(ivar)+GetUnderFlows(ivar));
+  return hist;
+
+}
+//___________________________________________________________________
+TH2D *AliCFGridSparse::Project(Int_t ivar1, Int_t ivar2) const
+{
+  //
+  // Make a 2D projection along variables ivar1 & ivar2 
+  //
+
+  //exclude overflows by default (used in projections)
+  if(fExcludeOffEntries){
+    for(Int_t i=0;i<fNVar;i++){
+      fData->GetAxis(i)->SetBit(TAxis::kAxisRange);
+    }
+  }
+  TH2D *hist=fData->Projection(ivar2,ivar1); //notice inverted axis (THnSparse uses TH3 2d-projction convention...)
+
+  Float_t sum=0;
+  for(Int_t i=1;i<=fNVarBins[ivar1]; i++){
+    for(Int_t j=1;j<=fNVarBins[ivar2]; j++){
+    sum+=hist->GetBinContent(i,j);
+    }
+  }
+
+  hist->SetEntries(sum+GetOverFlows(ivar1)+GetUnderFlows(ivar1)+GetOverFlows(ivar2)+GetUnderFlows(ivar2));
+  return hist;
+
+}
+//___________________________________________________________________
+TH3D *AliCFGridSparse::Project(Int_t ivar1, Int_t ivar2, Int_t ivar3) const
+{
+  //
+  // Make a 3D projection along variables ivar1 & ivar2 & ivar3 
+  //
+  //exclude overflows by default (used in projections)
+  if(fExcludeOffEntries){
+    for(Int_t i=0;i<fNVar;i++){
+      fData->GetAxis(i)->SetBit(TAxis::kAxisRange);
+    }
+  }
+
+  TH3D *hist=fData->Projection(ivar1,ivar2,ivar3); 
+
+  Float_t sum=0;
+  for(Int_t i=1;i<=fNVarBins[ivar1]; i++){
+    for(Int_t j=1;j<=fNVarBins[ivar2]; j++){
+      for(Int_t k=1;k<=fNVarBins[ivar3]; k++){
+       sum+=hist->GetBinContent(i,j,k);
+      }
+    }
+  }
+
+  hist->SetEntries(sum+GetOverFlows(ivar1)+GetUnderFlows(ivar1)+GetOverFlows(ivar2)+GetUnderFlows(ivar2)+GetOverFlows(ivar3)+GetUnderFlows(ivar3));
+  return hist;
+
+}
+
+//____________________________________________________________________
+Float_t AliCFGridSparse::GetOverFlows(Int_t ivar) const
+{
+  //
+  // Returns overflows in variable ivar
+  //
+  Int_t* bin = new Int_t[fNDim];
+  memset(bin, 0, sizeof(Int_t) * fNDim);
+  Float_t ovfl=0.;
+  for (Long64_t i = 0; i < fData->GetNbins(); ++i) {
+    Double_t v = fData->GetBinContent(i, bin);
+    Bool_t add=kTRUE;
+    for(Int_t j=0;j<fNVar;j++){
+      if(ivar==j)continue;
+      if((bin[j]==0) || (bin[j]==fNVarBins[j]+1))add=kFALSE;
+    }
+    if(bin[ivar]==fNVarBins[ivar]+1 && add) ovfl+=v;
+  }
+
+  delete[] bin;
+  return ovfl;
+}
+
+//____________________________________________________________________
+Float_t AliCFGridSparse::GetUnderFlows(Int_t ivar) const
+{
+  //
+  // Returns overflows in variable ivar
+  //
+  Int_t* bin = new Int_t[fNDim];
+  memset(bin, 0, sizeof(Int_t) * fNDim);
+  Float_t unfl=0.;
+  for (Long64_t i = 0; i < fData->GetNbins(); ++i) {
+    Double_t v = fData->GetBinContent(i, bin);
+    Bool_t add=kTRUE;
+    for(Int_t j=0;j<fNVar;j++){
+      if(ivar==j)continue;
+      if((bin[j]==0) || (bin[j]==fNVarBins[j]+1))add=kFALSE;
+    }
+    if(bin[ivar]==0 && add) unfl+=v;
+  }
+
+  delete[] bin;
+  return unfl;
+}
+
+
+//____________________________________________________________________
+Float_t AliCFGridSparse::GetEntries() const
+{
+  //
+  // total entries (including overflows and underflows)
+  //
+
+  return fData->GetEntries();
+}
+
+//____________________________________________________________________
+Float_t AliCFGridSparse::GetElement(Int_t index) const
+{
+  //
+  // Returns content of grid element index according to the
+  // linear indexing in AliCFFrame
+  //
+  Int_t *bin = new Int_t[fNVar];
+  GetBinIndex(index, bin);
+  for(Int_t i=0;i<fNVar;i++)fIndex[i]=bin[i]+1; //consistency with AliCFGrid
+  Float_t val=GetElement(fIndex);
+  delete [] bin;
+  return val; 
+  
+}
+//____________________________________________________________________
+Float_t AliCFGridSparse::GetElement(Int_t *bin) const
+{
+  //
+  // Get the content in a bin corresponding to a set of bin indexes
+  //
+  return fData->GetBinContent(bin);
+
+}  
+//____________________________________________________________________
+Float_t AliCFGridSparse::GetElement(Double_t *var) const
+{
+  //
+  // Get the content in a bin corresponding to a set of input variables
+  //
+
+  Long_t index=fData->GetBin(var,kFALSE); //this is the THnSparse index (do not allocate new cells if content is empty)
+  if(index<0){
+    return 0.;
+  }else{
+    return fData->GetBinContent(index);
+  }
+} 
+
+//____________________________________________________________________
+Float_t AliCFGridSparse::GetElementError(Int_t index) const
+{
+  //
+  // Returns the error on the content of a bin according to a linear
+  // indexing in AliCFFrame
+  //
+
+  Int_t *bin = new Int_t[fNVar];
+  GetBinIndex(index, bin);
+  for(Int_t i=0;i<fNVar;i++)fIndex[i]=bin[i]+1; //consistency with AliCFGrid
+  Float_t val=GetElementError(fIndex);
+  delete [] bin;
+  return val;
+
+}
+//____________________________________________________________________
+Float_t AliCFGridSparse::GetElementError(Int_t *bin) const
+{
+ //
+  // Get the error in a bin corresponding to a set of bin indexes
+  //
+  return fData->GetBinError(bin);
+
+}  
+//____________________________________________________________________
+Float_t AliCFGridSparse::GetElementError(Double_t *var) const
+{
+  //
+  // Get the error in a bin corresponding to a set of input variables
+  //
+
+  Long_t index=fData->GetBin(var,kFALSE); //this is the THnSparse index (do not allocate new cells if content is empy)
+  if(index<0){
+    return 0.;
+  }else{
+    return fData->GetBinError(index);
+  }
+} 
+
+
+//____________________________________________________________________
+void AliCFGridSparse::SetElement(Int_t index, Float_t val)
+{
+  //
+  // Sets grid element iel to val (linear indexing) in AliCFFrame
+  //
+  Int_t *bin = new Int_t[fNVar];
+  GetBinIndex(index, bin);
+  for(Int_t i=0;i<fNVar;i++)fIndex[i]=bin[i]+1;
+  SetElement(fIndex,val);
+  delete [] bin;
+}
+//____________________________________________________________________
+void AliCFGridSparse::SetElement(Int_t *bin, Float_t val)
+{
+  //
+  // Sets grid element of bin indeces bin to val
+  //
+  fData->SetBinContent(bin,val);
+}
+//____________________________________________________________________
+void AliCFGridSparse::SetElement(Double_t *var, Float_t val) 
+{
+  //
+  // Set the content in a bin to value val corresponding to a set of input variables
+  //
+  Long_t index=fData->GetBin(var); //THnSparse index: allocate the cell
+  Int_t *bin = new Int_t[fNVar];
+  fData->GetBinContent(index,bin); //trick to access the array of bins
+  fData->SetBinContent(bin,val);
+  delete [] bin;
+
+}
+
+//____________________________________________________________________
+void AliCFGridSparse::SetElementError(Int_t index, Float_t val)
+{
+  //
+  // Sets grid element iel error to val (linear indexing) in AliCFFrame
+  //
+  Int_t *bin = new Int_t[fNVar];
+  GetBinIndex(index, bin);
+  for(Int_t i=0;i<fNVar;i++)fIndex[i]=bin[i]+1;
+  SetElementError(fIndex,val);
+  delete [] bin;
+}
+//____________________________________________________________________
+void AliCFGridSparse::SetElementError(Int_t *bin, Float_t val)
+{
+  //
+  // Sets grid element error of bin indeces bin to val
+  //
+  fData->SetBinError(bin,val);
+}
+//____________________________________________________________________
+void AliCFGridSparse::SetElementError(Double_t *var, Float_t val) 
+{
+  //
+  // Set the error in a bin to value val corresponding to a set of input variables
+  //
+  Long_t index=fData->GetBin(var); //THnSparse index
+  Int_t *bin = new Int_t[fNVar];
+  fData->GetBinContent(index,bin); //trick to access the array of bins
+  fData->SetBinError(bin,val);
+  delete [] bin;
+}
+
+//____________________________________________________________________
+void AliCFGridSparse::SumW2()
+{
+  //
+  //set calculation of the squared sum of the weighted entries
+  //
+  if(!fSumW2){
+    fData->CalculateErrors(kTRUE); 
+  }
+
+  fSumW2=kTRUE;
+}
+
+//____________________________________________________________________
+void AliCFGridSparse::Add(AliCFVGrid* aGrid, Double_t c)
+{
+  //
+  //add aGrid to the current one
+  //
+
+
+  if(aGrid->GetNVar()!=fNVar){
+    AliInfo("Different number of variables, cannot add the grids");
+    return;
+  } 
+  if(aGrid->GetNDim()!=fNDim){
+    AliInfo("Different number of dimensions, cannot add the grids!");
+    return;
+  } 
+  
+  if(!fSumW2  && aGrid->GetSumW2())SumW2();
+
+
+  fData->Add(((AliCFGridSparse*)aGrid)->GetGrid(),c);
+
+}
+
+//____________________________________________________________________
+void AliCFGridSparse::Add(AliCFVGrid* aGrid1, AliCFVGrid* aGrid2, Double_t c1,Double_t c2)
+{
+  //
+  //Add aGrid1 and aGrid2 and deposit the result into the current one
+  //
+
+  if(fNVar!=aGrid1->GetNVar()|| fNVar!=aGrid2->GetNVar()){
+    AliInfo("Different number of variables, cannot add the grids");
+    return;
+  } 
+  if(fNDim!=aGrid1->GetNDim()|| fNDim!=aGrid2->GetNDim()){
+    AliInfo("Different number of dimensions, cannot add the grids!");
+    return;
+  } 
+  
+  if(!fSumW2  && (aGrid1->GetSumW2() || aGrid2->GetSumW2()))SumW2();
+
+
+  fData->Reset();
+  fData->Add(((AliCFGridSparse*)aGrid1)->GetGrid(),c1);
+  fData->Add(((AliCFGridSparse*)aGrid2)->GetGrid(),c2);
+
+}
+
+//____________________________________________________________________
+void AliCFGridSparse::Multiply(AliCFVGrid* aGrid, Double_t c)
+{
+  //
+  // Multiply aGrid to the current one
+  //
+
+
+  if(aGrid->GetNVar()!=fNVar){
+    AliInfo("Different number of variables, cannot multiply the grids");
+    return;
+  } 
+  if(aGrid->GetNDim()!=fNDim){
+    AliInfo("Different number of dimensions, cannot multiply the grids!");
+    return;
+  } 
+  
+  if(!fSumW2  && aGrid->GetSumW2())SumW2();
+
+  THnSparse *h= ((AliCFGridSparse*)aGrid)->GetGrid();
+
+  fData->Multiply(h);
+  fData->Scale(c);
+
+}
+
+//____________________________________________________________________
+void AliCFGridSparse::Multiply(AliCFVGrid* aGrid1, AliCFVGrid* aGrid2, Double_t c1,Double_t c2)
+{
+  //
+  //Multiply aGrid1 and aGrid2 and deposit the result into the current one
+  //
+
+  if(fNVar!=aGrid1->GetNVar()|| fNVar!=aGrid2->GetNVar()){
+    AliInfo("Different number of variables, cannot multiply the grids");
+    return;
+  } 
+  if(fNDim!=aGrid1->GetNDim()|| fNDim!=aGrid2->GetNDim()){
+    AliInfo("Different number of dimensions, cannot multiply the grids!");
+    return;
+  } 
+  
+  if(!fSumW2  && (aGrid1->GetSumW2() || aGrid2->GetSumW2()))SumW2();
+
+
+  fData->Reset();
+  THnSparse *h1= ((AliCFGridSparse*)aGrid1)->GetGrid();
+  THnSparse *h2= ((AliCFGridSparse*)aGrid2)->GetGrid();
+  h2->Multiply(h1);
+  h2->Scale(c1*c2);
+  fData->Add(h2);
+}
+
+
+
+//____________________________________________________________________
+void AliCFGridSparse::Divide(AliCFVGrid* aGrid, Double_t c)
+{
+  //
+  // Divide aGrid to the current one
+  //
+
+
+  if(aGrid->GetNVar()!=fNVar){
+    AliInfo("Different number of variables, cannot divide the grids");
+    return;
+  } 
+  if(aGrid->GetNDim()!=fNDim){
+    AliInfo("Different number of dimensions, cannot divide the grids!");
+    return;
+  } 
+  
+  if(!fSumW2  && aGrid->GetSumW2())SumW2();
+
+  THnSparse *h= ((AliCFGridSparse*)aGrid)->GetGrid();
+
+  fData->Divide(h);
+  fData->Scale(c);
+
+}
+
+//____________________________________________________________________
+void AliCFGridSparse::Divide(AliCFVGrid* aGrid1, AliCFVGrid* aGrid2, Double_t c1,Double_t c2, Option_t *option)
+{
+  //
+  //Divide aGrid1 and aGrid2 and deposit the result into the current one
+  //bynomial errors are supported
+  //
+
+  if(fNVar!=aGrid1->GetNVar()|| fNVar!=aGrid2->GetNVar()){
+    AliInfo("Different number of variables, cannot divide the grids");
+    return;
+  } 
+  if(fNDim!=aGrid1->GetNDim()|| fNDim!=aGrid2->GetNDim()){
+    AliInfo("Different number of dimensions, cannot divide the grids!");
+    return;
+  } 
+  
+  if(!fSumW2  && (aGrid1->GetSumW2() || aGrid2->GetSumW2()))SumW2();
+
+
+  THnSparse *h1= ((AliCFGridSparse*)aGrid1)->GetGrid();
+  THnSparse *h2= ((AliCFGridSparse*)aGrid2)->GetGrid();
+  fData->Divide(h1,h2,c1,c2,option);
+}
+
+
+//____________________________________________________________________
+void AliCFGridSparse::Copy(TObject& c) const
+{
+  //
+  // copy function
+  //
+  AliCFGridSparse& target = (AliCFGridSparse &) c;
+
+  if(fData)target.fData = fData;
+}
+
diff --git a/CORRFW/AliCFGridSparse.h b/CORRFW/AliCFGridSparse.h
new file mode 100755 (executable)
index 0000000..bf9212b
--- /dev/null
@@ -0,0 +1,82 @@
+#ifndef ALICFGRIDSPARSE_H
+#define ALICFGRIDSPARSE_H
+//--------------------------------------------------------------------//
+//                                                                    //
+// AliCFGridSparse.cxx Class                                          //
+// Class to handle N-dim maps for the correction Framework            // 
+// uses a THnSparse to store the grid                                 //
+// Author:S.Arcelli, silvia.arcelli@cern.ch
+//--------------------------------------------------------------------//
+
+#include "AliCFVGrid.h"
+#include "THnSparse.h"
+#include "AliLog.h"
+class TH1D;
+class TH2D;
+class TH3D;
+
+class AliCFGridSparse : public AliCFVGrid
+{
+ public:
+  AliCFGridSparse();
+  AliCFGridSparse(const Char_t* name,const Char_t* title);
+  AliCFGridSparse(const Char_t* name, const Char_t* title, const Int_t nVarIn, const Int_t* nBinIn, const Double_t  *binLimitsIn=0);
+  AliCFGridSparse(const AliCFGridSparse & c);
+  
+  virtual ~AliCFGridSparse();
+  AliCFGridSparse& operator=(const AliCFGridSparse& corr) ;
+  virtual void  SetBinLimits(Int_t ivar, Double_t * array);
+  virtual void  SetExcludeOffEntries(Bool_t in){fExcludeOffEntries=in;}; 
+  virtual Bool_t GetExcludeOffEntries( ) const {return fExcludeOffEntries;}; 
+  
+  virtual void  Fill(Double_t *var, Double_t weight=1.);
+
+  virtual Float_t GetOverFlows(Int_t var) const;
+  virtual Float_t GetUnderFlows(Int_t var)const;
+  virtual Float_t GetEntries()const;
+
+  virtual Float_t GetElement(Int_t iel)const; 
+  virtual Float_t GetElement(Int_t *bin)const; 
+  virtual Float_t GetElement(Double_t *var)const; 
+
+  virtual Float_t GetElementError(Int_t iel)const; 
+  virtual Float_t GetElementError(Int_t *bin)const; 
+  virtual Float_t GetElementError(Double_t *var)const; 
+
+  virtual void SetElement(Int_t iel, Float_t val); 
+  virtual void SetElement(Int_t *bin, Float_t val); 
+  virtual void SetElement(Double_t *var, Float_t val); 
+  virtual void SetElementError(Int_t iel, Float_t val); 
+  virtual void SetElementError(Int_t *bin, Float_t val) ; 
+  virtual void SetElementError(Double_t *var, Float_t val); 
+
+  virtual TH1D* Project( Int_t ivar) const;
+  virtual TH2D* Project( Int_t ivar1, Int_t ivar2) const;
+  virtual TH3D* Project( Int_t ivar1, Int_t ivar2,Int_t ivar3) const;
+  virtual TH1D* Slice( Int_t, Double_t *, Double_t *) const {AliInfo("Not yet implemented!"); return 0x0;};
+
+
+  //basic operations
+
+  virtual void SumW2();
+  virtual void Add(AliCFVGrid* aGrid, Double_t c=1.);
+  virtual void Add(AliCFVGrid* aGrid1 ,AliCFVGrid* aGrid2, Double_t c1=1.,Double_t c2=1.);
+  virtual void Multiply(AliCFVGrid* aGrid, Double_t c=1.);
+  virtual void Multiply(AliCFVGrid* aGrid1,AliCFVGrid* aGrid2, Double_t c1=1.,Double_t c2=1.);
+  virtual void Divide(AliCFVGrid* aGrid, Double_t c=1.);
+  virtual void Divide(AliCFVGrid* aGrid1, AliCFVGrid* aGrid2, Double_t c1=1., Double_t c2=1.,Option_t *option=0);
+
+  THnSparse  *GetGrid() const {return fData;};//  Getter for the data Container: a THnSparse
+
+  virtual void Copy(TObject& c) const;
+
+  
+ protected:
+
+  Bool_t fExcludeOffEntries; // exclude under/overflows in 'hidden dimensions' when performing projections, default is kTRUE. 
+  THnSparse  *fData;//  The data Container: a THnSparse  
+  ClassDef(AliCFGridSparse,1);
+};
+    
+#endif
+
index 7ad9df6..4974095 100644 (file)
@@ -365,43 +365,43 @@ void AliCFTrackIsPrimaryCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_
 
   switch(index){
   case kCutNSigmaToVertex:
-    fhNBinsNSigma=nbins;
+    fhNBinsNSigma=nbins+1;
     fhBinLimNSigma=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimNSigma[i]=bins[i];
     break;
 
   case kCutRequireSigmaToVertex:
-    fhNBinsRequireSigma=nbins;
+    fhNBinsRequireSigma=nbins+1;
     fhBinLimRequireSigma=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimRequireSigma[i]=bins[i];
     break;
 
   case kCutAcceptKinkDaughters:
-    fhNBinsAcceptKink=nbins;
+    fhNBinsAcceptKink=nbins+1;
     fhBinLimAcceptKink=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimAcceptKink[i]=bins[i];
     break;
 
   case kDcaXY:
-    fhNBinsDcaXY=nbins;
+    fhNBinsDcaXY=nbins+1;
     fhBinLimDcaXY=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimDcaXY[i]=bins[i];
     break;
 
   case kDcaZ:
-    fhNBinsDcaZ=nbins;
+    fhNBinsDcaZ=nbins+1;
     fhBinLimDcaZ=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimDcaZ[i]=bins[i];
     break;
 
   case kDcaXYnorm:
-    fhNBinsDcaXYnorm=nbins;
+    fhNBinsDcaXYnorm=nbins+1;
     fhBinLimDcaXYnorm=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimDcaXYnorm[i]=bins[i];
     break;
 
   case kDcaZnorm:
-    fhNBinsDcaZnorm=nbins;
+    fhNBinsDcaZnorm=nbins+1;
     fhBinLimDcaZnorm=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimDcaZnorm[i]=bins[i];
     break;
@@ -415,43 +415,43 @@ void AliCFTrackIsPrimaryCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_
   //
   switch(index){
   case kCutNSigmaToVertex:
-    fhNBinsNSigma=nbins;
+    fhNBinsNSigma=nbins+1;
     fhBinLimNSigma=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimNSigma[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutRequireSigmaToVertex:
-    fhNBinsRequireSigma=nbins;
+    fhNBinsRequireSigma=nbins+1;
     fhBinLimRequireSigma=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimRequireSigma[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutAcceptKinkDaughters:
-    fhNBinsAcceptKink=nbins;
+    fhNBinsAcceptKink=nbins+1;
     fhBinLimAcceptKink=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimAcceptKink[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kDcaXY:
-    fhNBinsDcaXY=nbins;
+    fhNBinsDcaXY=nbins+1;
     fhBinLimDcaXY=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimDcaXY[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kDcaZ:
-    fhNBinsDcaZ=nbins;
+    fhNBinsDcaZ=nbins+1;
     fhBinLimDcaZ=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimDcaZ[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kDcaXYnorm:
-    fhNBinsDcaXYnorm=nbins;
+    fhNBinsDcaXYnorm=nbins+1;
     fhBinLimDcaXYnorm=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimDcaXYnorm[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kDcaZnorm:
-    fhNBinsDcaZnorm=nbins;
+    fhNBinsDcaZnorm=nbins+1;
     fhBinLimDcaZnorm=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimDcaZnorm[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
@@ -489,13 +489,13 @@ void AliCFTrackIsPrimaryCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_
 
     fhDcaXYvsDcaZ[i]            = new  TH2F(Form("%s_dcaXYvsDcaZ%s",GetName(),str),"",200,-10,10,200,-10,10);
     fhDcaXYvsDcaZnorm[i]        = new  TH2F(Form("%s_dcaXYvsDcaZnorm%s",GetName(),str),"",200,-10,10,200,-10,10);
-    fhQA[kCutNSigmaToVertex][i]        = new TH1F(Form("%s_nSigmaToVertex%s",GetName(),str),"",fhNBinsNSigma,fhBinLimNSigma);
-    fhQA[kCutRequireSigmaToVertex][i] = new TH1F(Form("%s_requireSigmaToVertex%s",GetName(),str),"",fhNBinsRequireSigma,fhBinLimRequireSigma);
-    fhQA[kCutAcceptKinkDaughters][i] = new TH1F(Form("%s_acceptKinkDaughters%s",GetName(),str),"",fhNBinsAcceptKink,fhBinLimAcceptKink);
-    fhQA[kDcaXY][i]            = new TH1F(Form("%s_dcaXY%s",GetName(),str),"",fhNBinsDcaXY,fhBinLimDcaXY);
-    fhQA[kDcaZ][i]             = new TH1F(Form("%s_dcaZ%s",GetName(),str),"",fhNBinsDcaZ,fhBinLimDcaZ);
-    fhQA[kDcaXYnorm][i]                = new TH1F(Form("%s_dcaXYnorm%s",GetName(),str),"",fhNBinsDcaXYnorm,fhBinLimDcaXYnorm);
-    fhQA[kDcaZnorm][i]         = new TH1F(Form("%s_dcaZnorm%s",GetName(),str),"",fhNBinsDcaZnorm,fhBinLimDcaZnorm);
+    fhQA[kCutNSigmaToVertex][i]        = new TH1F(Form("%s_nSigmaToVertex%s",GetName(),str),"",fhNBinsNSigma-1,fhBinLimNSigma);
+    fhQA[kCutRequireSigmaToVertex][i] = new TH1F(Form("%s_requireSigmaToVertex%s",GetName(),str),"",fhNBinsRequireSigma-1,fhBinLimRequireSigma);
+    fhQA[kCutAcceptKinkDaughters][i] = new TH1F(Form("%s_acceptKinkDaughters%s",GetName(),str),"",fhNBinsAcceptKink-1,fhBinLimAcceptKink);
+    fhQA[kDcaXY][i]            = new TH1F(Form("%s_dcaXY%s",GetName(),str),"",fhNBinsDcaXY-1,fhBinLimDcaXY);
+    fhQA[kDcaZ][i]             = new TH1F(Form("%s_dcaZ%s",GetName(),str),"",fhNBinsDcaZ-1,fhBinLimDcaZ);
+    fhQA[kDcaXYnorm][i]                = new TH1F(Form("%s_dcaXYnorm%s",GetName(),str),"",fhNBinsDcaXYnorm-1,fhBinLimDcaXYnorm);
+    fhQA[kDcaZnorm][i]         = new TH1F(Form("%s_dcaZnorm%s",GetName(),str),"",fhNBinsDcaZnorm-1,fhBinLimDcaZnorm);
 
     fhDcaXYvsDcaZ[i]->SetXTitle("impact par. d_{z}");
     fhDcaXYvsDcaZ[i]->SetYTitle("impact par. d_{xy}");
index 94e79b1..fdc824e 100644 (file)
@@ -111,13 +111,13 @@ class AliCFTrackIsPrimaryCuts : public AliCFCutBase
   TBits *fBitmap ;                     // stores single selection decisions
 
   // QA histogram setters
-  Int_t fhNBinsNSigma;                 // number of bins: dca in units of sigma
-  Int_t fhNBinsRequireSigma;           // number of bins: require successful calcuation
-  Int_t fhNBinsAcceptKink;             // number of bins: acceptkink daughters
-  Int_t fhNBinsDcaXY;                  // number of bins: dca in transverse plane
-  Int_t fhNBinsDcaZ;                   // number of bins: dca along beam axis
-  Int_t fhNBinsDcaXYnorm;              // number of bins: normalised dca in transverse plane
-  Int_t fhNBinsDcaZnorm;               // number of bins: normalised dca along beam axis
+  Int_t fhNBinsNSigma;                 // number of bins+1: dca in units of sigma
+  Int_t fhNBinsRequireSigma;           // number of bins+1: require successful calcuation
+  Int_t fhNBinsAcceptKink;             // number of bins+1: acceptkink daughters
+  Int_t fhNBinsDcaXY;                  // number of bins+1: dca in transverse plane
+  Int_t fhNBinsDcaZ;                   // number of bins+1: dca along beam axis
+  Int_t fhNBinsDcaXYnorm;              // number of bins+1: normalised dca in transverse plane
+  Int_t fhNBinsDcaZnorm;               // number of bins+1: normalised dca along beam axis
 
   Double_t *fhBinLimNSigma; //[fhNBinsNSigma] bin limits: dca in units of sigma
   Double_t *fhBinLimRequireSigma;//[fhNBinsRequireSigma] bin limits: require successful calcuation
index 6ce2e01..89b4739 100644 (file)
@@ -448,55 +448,55 @@ void AliCFTrackKineCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t *bi
 
   switch(index){
   case kCutP:
-    fhNBinsMomentum=nbins;
+    fhNBinsMomentum=nbins+1;
     fhBinLimMomentum=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimMomentum[i]=bins[i];
     break;
 
   case kCutPt:
-    fhNBinsPt=nbins;
+    fhNBinsPt=nbins+1;
     fhBinLimPt=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimPt[i]=bins[i];
     break;
 
   case kCutPx:
-    fhNBinsPx=nbins;
+    fhNBinsPx=nbins+1;
     fhBinLimPx=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimPx[i]=bins[i];
     break;
 
   case kCutPy:
-    fhNBinsPy=nbins;
+    fhNBinsPy=nbins+1;
     fhBinLimPy=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimPy[i]=bins[i];
     break;
 
   case kCutPz:
-    fhNBinsPz=nbins;
+    fhNBinsPz=nbins+1;
     fhBinLimPz=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimPz[i]=bins[i];
     break;
 
   case kCutRapidity:
-    fhNBinsRapidity=nbins;
+    fhNBinsRapidity=nbins+1;
     fhBinLimRapidity=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimRapidity[i]=bins[i];
     break;
 
   case kCutEta:
-    fhNBinsEta=nbins;
+    fhNBinsEta=nbins+1;
     fhBinLimEta=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimEta[i]=bins[i];
     break;
 
   case kCutPhi:
-    fhNBinsPhi=nbins;
+    fhNBinsPhi=nbins+1;
     fhBinLimPhi=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimPhi[i]=bins[i];
     break;
 
   case kCutCharge:
-    fhNBinsCharge=nbins;
+    fhNBinsCharge=nbins+1;
     fhBinLimCharge=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimCharge[i]=bins[i];
     break;
@@ -510,55 +510,55 @@ void AliCFTrackKineCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmi
   //
   switch(index){
   case kCutP:
-    fhNBinsMomentum=nbins;
+    fhNBinsMomentum=nbins+1;
     fhBinLimMomentum=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimMomentum[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutPt:
-    fhNBinsPt=nbins;
+    fhNBinsPt=nbins+1;
     fhBinLimPt=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimPt[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutPx:
-    fhNBinsPx=nbins;
+    fhNBinsPx=nbins+1;
     fhBinLimPx=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimPx[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutPy:
-    fhNBinsPy=nbins;
+    fhNBinsPy=nbins+1;
     fhBinLimPy=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimPy[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutPz:
-    fhNBinsPz=nbins;
+    fhNBinsPz=nbins+1;
     fhBinLimPz=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimPz[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutRapidity:
-    fhNBinsRapidity=nbins;
+    fhNBinsRapidity=nbins+1;
     fhBinLimRapidity=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimRapidity[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutEta:
-    fhNBinsEta=nbins;
+    fhNBinsEta=nbins+1;
     fhBinLimEta=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimEta[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutPhi:
-    fhNBinsPhi=nbins;
+    fhNBinsPhi=nbins+1;
     fhBinLimPhi=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimPhi[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutCharge:
-    fhNBinsCharge=nbins;
+    fhNBinsCharge=nbins+1;
     fhBinLimCharge=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimCharge[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
@@ -616,15 +616,15 @@ void AliCFTrackKineCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmi
     if (i==0) sprintf(str," ");
     else sprintf(str,"_cut");
   
-    fhQA[kCutP][i]     = new  TH1F(Form("%s_momentum%s",GetName(),str),        "",fhNBinsMomentum,fhBinLimMomentum);
-    fhQA[kCutPt][i]    = new  TH1F(Form("%s_transverse_momentum%s",GetName(),str),"",fhNBinsPt,fhBinLimPt);
-    fhQA[kCutPx][i]    = new  TH1F(Form("%s_px%s",GetName(),str),              "",fhNBinsPx,fhBinLimPx);
-    fhQA[kCutPy][i]    = new  TH1F(Form("%s_py%s",GetName(),str),              "",fhNBinsPy,fhBinLimPy);
-    fhQA[kCutPz][i]    = new  TH1F(Form("%s_pz%s",GetName(),str),              "",fhNBinsPz,fhBinLimPz);
-    fhQA[kCutRapidity][i]=new  TH1F(Form("%s_rapidity%s",GetName(),str),       "",fhNBinsRapidity,fhBinLimRapidity);
-    fhQA[kCutEta][i]   = new  TH1F(Form("%s_eta%s",GetName(),str),             "",fhNBinsEta,fhBinLimEta);
-    fhQA[kCutPhi][i]   = new  TH1F(Form("%s_phi%s",GetName(),str),             "",fhNBinsPhi,fhBinLimPhi);
-    fhQA[kCutCharge][i]        = new  TH1F(Form("%s_charge%s",GetName(),str),          "",fhNBinsCharge,fhBinLimCharge);
+    fhQA[kCutP][i]     = new  TH1F(Form("%s_momentum%s",GetName(),str),        "",fhNBinsMomentum-1,fhBinLimMomentum);
+    fhQA[kCutPt][i]    = new  TH1F(Form("%s_transverse_momentum%s",GetName(),str),"",fhNBinsPt-1,fhBinLimPt);
+    fhQA[kCutPx][i]    = new  TH1F(Form("%s_px%s",GetName(),str),              "",fhNBinsPx-1,fhBinLimPx);
+    fhQA[kCutPy][i]    = new  TH1F(Form("%s_py%s",GetName(),str),              "",fhNBinsPy-1,fhBinLimPy);
+    fhQA[kCutPz][i]    = new  TH1F(Form("%s_pz%s",GetName(),str),              "",fhNBinsPz-1,fhBinLimPz);
+    fhQA[kCutRapidity][i]=new  TH1F(Form("%s_rapidity%s",GetName(),str),       "",fhNBinsRapidity-1,fhBinLimRapidity);
+    fhQA[kCutEta][i]   = new  TH1F(Form("%s_eta%s",GetName(),str),             "",fhNBinsEta-1,fhBinLimEta);
+    fhQA[kCutPhi][i]   = new  TH1F(Form("%s_phi%s",GetName(),str),             "",fhNBinsPhi-1,fhBinLimPhi);
+    fhQA[kCutCharge][i]        = new  TH1F(Form("%s_charge%s",GetName(),str),          "",fhNBinsCharge-1,fhBinLimCharge);
 
     fhQA[kCutP][i]     ->SetXTitle("momentum p (GeV/c)");
     fhQA[kCutPt][i]    ->SetXTitle("p_{T} (GeV/c)");
index d5cb05b..d63442f 100644 (file)
@@ -139,15 +139,15 @@ class AliCFTrackKineCuts : public AliCFCutBase
   TBits *fBitmap ;                     // stores single selection decisions
 
   // QA histogram setters
-  Int_t fhNBinsMomentum;               // number of bins: momentum
-  Int_t fhNBinsPt;                     // number of bins: pt
-  Int_t fhNBinsPx;                     // number of bins: px
-  Int_t fhNBinsPy;                     // number of bins: py
-  Int_t fhNBinsPz;                     // number of bins: pz
-  Int_t fhNBinsEta;                    // number of bins: eta
-  Int_t fhNBinsRapidity;               // number of bins: rapidity
-  Int_t fhNBinsPhi;                    // number of bins: phi
-  Int_t fhNBinsCharge;                 // number of bins: charge
+  Int_t fhNBinsMomentum;               // number of bins+1: momentum
+  Int_t fhNBinsPt;                     // number of bins+1: pt
+  Int_t fhNBinsPx;                     // number of bins+1: px
+  Int_t fhNBinsPy;                     // number of bins+1: py
+  Int_t fhNBinsPz;                     // number of bins+1: pz
+  Int_t fhNBinsEta;                    // number of bins+1: eta
+  Int_t fhNBinsRapidity;               // number of bins+1: rapidity
+  Int_t fhNBinsPhi;                    // number of bins+1: phi
+  Int_t fhNBinsCharge;                 // number of bins+1: charge
   
   Double_t *fhBinLimMomentum;  //[fhNBinsMomentum] bin limits: momentum
   Double_t *fhBinLimPt;                //[fhNBinsPt] bin limits: pt
index a8bf70b..6d20439 100644 (file)
@@ -445,67 +445,67 @@ void AliCFTrackQualityCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t
 
   switch(index){
   case kCutClusterTPC:
-    fhNBinsClusterTPC=nbins;
+    fhNBinsClusterTPC=nbins+1;
     fhBinLimClusterTPC=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimClusterTPC[i]=bins[i];
     break;
 
   case kCutClusterITS:
-    fhNBinsClusterITS=nbins;
+    fhNBinsClusterITS=nbins+1;
     fhBinLimClusterITS=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimClusterITS[i]=bins[i];
     break;
 
   case kCutChi2TPC:
-    fhNBinsChi2TPC=nbins;
+    fhNBinsChi2TPC=nbins+1;
     fhBinLimChi2TPC=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimChi2TPC[i]=bins[i];
     break;
 
   case kCutChi2ITS:
-    fhNBinsChi2ITS=nbins;
+    fhNBinsChi2ITS=nbins+1;
     fhBinLimChi2ITS=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimChi2ITS[i]=bins[i];
     break;
 
   case kCutRefitTPC:
-    fhNBinsRefitTPC=nbins;
+    fhNBinsRefitTPC=nbins+1;
     fhBinLimRefitTPC=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimRefitTPC[i]=bins[i];
     break;
 
   case kCutRefitITS:
-    fhNBinsRefitITS=nbins;
+    fhNBinsRefitITS=nbins+1;
     fhBinLimRefitITS=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimRefitITS[i]=bins[i];
     break;
 
   case kCutCovElement11:
-    fhNBinsCovariance11=nbins;
+    fhNBinsCovariance11=nbins+1;
     fhBinLimCovariance11=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance11[i]=bins[i];
     break;
 
   case kCutCovElement22:
-    fhNBinsCovariance22=nbins;
+    fhNBinsCovariance22=nbins+1;
     fhBinLimCovariance22=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance22[i]=bins[i];
     break;
 
   case kCutCovElement33:
-    fhNBinsCovariance33=nbins;
+    fhNBinsCovariance33=nbins+1;
     fhBinLimCovariance33=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance33[i]=bins[i];
     break;
 
   case kCutCovElement44:
-    fhNBinsCovariance44=nbins;
+    fhNBinsCovariance44=nbins+1;
     fhBinLimCovariance44=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance44[i]=bins[i];
     break;
 
   case kCutCovElement55:
-    fhNBinsCovariance55=nbins;
+    fhNBinsCovariance55=nbins+1;
     fhBinLimCovariance55=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance55[i]=bins[i];
     break;
@@ -519,67 +519,67 @@ void AliCFTrackQualityCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t
   //
   switch(index){
   case kCutClusterTPC:
-    fhNBinsClusterTPC=nbins;
+    fhNBinsClusterTPC=nbins+1;
     fhBinLimClusterTPC=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimClusterTPC[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutClusterITS:
-    fhNBinsClusterITS=nbins;
+    fhNBinsClusterITS=nbins+1;
     fhBinLimClusterITS=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimClusterITS[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutChi2TPC:
-    fhNBinsChi2TPC=nbins;
+    fhNBinsChi2TPC=nbins+1;
     fhBinLimChi2TPC=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimChi2TPC[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutChi2ITS:
-    fhNBinsChi2ITS=nbins;
+    fhNBinsChi2ITS=nbins+1;
     fhBinLimChi2ITS=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimChi2ITS[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutRefitTPC:
-    fhNBinsRefitTPC=nbins;
+    fhNBinsRefitTPC=nbins+1;
     fhBinLimRefitTPC=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimRefitTPC[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutRefitITS:
-    fhNBinsRefitITS=nbins;
+    fhNBinsRefitITS=nbins+1;
     fhBinLimRefitITS=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimRefitITS[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutCovElement11:
-    fhNBinsCovariance11=nbins;
+    fhNBinsCovariance11=nbins+1;
     fhBinLimCovariance11=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance11[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutCovElement22:
-    fhNBinsCovariance22=nbins;
+    fhNBinsCovariance22=nbins+1;
     fhBinLimCovariance22=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance22[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutCovElement33:
-    fhNBinsCovariance33=nbins;
+    fhNBinsCovariance33=nbins+1;
     fhBinLimCovariance33=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance33[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutCovElement44:
-    fhNBinsCovariance44=nbins;
+    fhNBinsCovariance44=nbins+1;
     fhBinLimCovariance44=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance44[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
 
   case kCutCovElement55:
-    fhNBinsCovariance55=nbins;
+    fhNBinsCovariance55=nbins+1;
     fhBinLimCovariance55=new Double_t[nbins+1];
     for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance55[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
     break;
@@ -640,17 +640,17 @@ void AliCFTrackQualityCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t
     if (i==0) sprintf(str," ");
     else sprintf(str,"_cut");
 
-    fhQA[kCutClusterTPC][i]    = new TH1F(Form("%s_nClustersTPC%s",GetName(),str)     ,"",fhNBinsClusterTPC,fhBinLimClusterTPC);
-    fhQA[kCutClusterITS][i]    = new TH1F(Form("%s_nClustersITS%s",GetName(),str)     ,"",fhNBinsClusterITS,fhBinLimClusterITS);
-    fhQA[kCutChi2TPC][i]       = new TH1F(Form("%s_chi2PerClusterTPC%s",GetName(),str),"",fhNBinsChi2TPC,fhBinLimChi2TPC);
-    fhQA[kCutChi2ITS][i]       = new TH1F(Form("%s_chi2PerClusterITS%s",GetName(),str),"",fhNBinsChi2ITS,fhBinLimChi2ITS);
-    fhQA[kCutRefitTPC][i]      = new TH1F(Form("%s_refitTPC%s",GetName(),str)     ,"",fhNBinsRefitTPC,fhBinLimRefitTPC);
-    fhQA[kCutRefitITS][i]      = new TH1F(Form("%s_refitITS%s",GetName(),str)     ,"",fhNBinsRefitITS,fhBinLimRefitITS);
-    fhQA[kCutCovElement11][i]  = new TH1F(Form("%s_covMatrixDiagonal11%s",GetName(),str),"",fhNBinsCovariance11,fhBinLimCovariance11);
-    fhQA[kCutCovElement22][i]  = new TH1F(Form("%s_covMatrixDiagonal22%s",GetName(),str),"",fhNBinsCovariance22,fhBinLimCovariance22);
-    fhQA[kCutCovElement33][i]  = new TH1F(Form("%s_covMatrixDiagonal33%s",GetName(),str),"",fhNBinsCovariance33,fhBinLimCovariance33);
-    fhQA[kCutCovElement44][i]  = new TH1F(Form("%s_covMatrixDiagonal44%s",GetName(),str),"",fhNBinsCovariance44,fhBinLimCovariance44);
-    fhQA[kCutCovElement55][i]  = new TH1F(Form("%s_covMatrixDiagonal55%s",GetName(),str),"",fhNBinsCovariance55,fhBinLimCovariance55);
+    fhQA[kCutClusterTPC][i]    = new TH1F(Form("%s_nClustersTPC%s",GetName(),str)     ,"",fhNBinsClusterTPC-1,fhBinLimClusterTPC);
+    fhQA[kCutClusterITS][i]    = new TH1F(Form("%s_nClustersITS%s",GetName(),str)     ,"",fhNBinsClusterITS-1,fhBinLimClusterITS);
+    fhQA[kCutChi2TPC][i]       = new TH1F(Form("%s_chi2PerClusterTPC%s",GetName(),str),"",fhNBinsChi2TPC-1,fhBinLimChi2TPC);
+    fhQA[kCutChi2ITS][i]       = new TH1F(Form("%s_chi2PerClusterITS%s",GetName(),str),"",fhNBinsChi2ITS-1,fhBinLimChi2ITS);
+    fhQA[kCutRefitTPC][i]      = new TH1F(Form("%s_refitTPC%s",GetName(),str)     ,"",fhNBinsRefitTPC-1,fhBinLimRefitTPC);
+    fhQA[kCutRefitITS][i]      = new TH1F(Form("%s_refitITS%s",GetName(),str)     ,"",fhNBinsRefitITS-1,fhBinLimRefitITS);
+    fhQA[kCutCovElement11][i]  = new TH1F(Form("%s_covMatrixDiagonal11%s",GetName(),str),"",fhNBinsCovariance11-1,fhBinLimCovariance11);
+    fhQA[kCutCovElement22][i]  = new TH1F(Form("%s_covMatrixDiagonal22%s",GetName(),str),"",fhNBinsCovariance22-1,fhBinLimCovariance22);
+    fhQA[kCutCovElement33][i]  = new TH1F(Form("%s_covMatrixDiagonal33%s",GetName(),str),"",fhNBinsCovariance33-1,fhBinLimCovariance33);
+    fhQA[kCutCovElement44][i]  = new TH1F(Form("%s_covMatrixDiagonal44%s",GetName(),str),"",fhNBinsCovariance44-1,fhBinLimCovariance44);
+    fhQA[kCutCovElement55][i]  = new TH1F(Form("%s_covMatrixDiagonal55%s",GetName(),str),"",fhNBinsCovariance55-1,fhBinLimCovariance55);
 
     fhQA[kCutClusterTPC][i]    ->SetXTitle("n TPC clusters");
     fhQA[kCutClusterITS][i]    ->SetXTitle("n ITS clusters");
index ee1e5e3..d5db009 100644 (file)
@@ -127,17 +127,17 @@ class AliCFTrackQualityCuts : public AliCFCutBase
   TBits *fBitmap ;                     // stores single selection decisions
 
   // QA histogram setters
-  Int_t fhNBinsClusterTPC;             // number of bins: cluster TPC
-  Int_t fhNBinsClusterITS;             // number of bins: cluster ITS
-  Int_t fhNBinsChi2TPC;                        // number of bins: chi2 per cluster TPC
-  Int_t fhNBinsChi2ITS;                        // number of bins: chi2 per cluster ITS
-  Int_t fhNBinsRefitTPC;               // number of bins: require refit TPC
-  Int_t fhNBinsRefitITS;               // number of bins: require refit ITS  
-  Int_t fhNBinsCovariance11;           // number of bins: covariance matrix element 11
-  Int_t fhNBinsCovariance22;           // number of bins: covariance matrix element 22
-  Int_t fhNBinsCovariance33;           // number of bins: covariance matrix element 33
-  Int_t fhNBinsCovariance44;           // number of bins: covariance matrix element 44
-  Int_t fhNBinsCovariance55;           // number of bins: covariance matrix element 55
+  Int_t fhNBinsClusterTPC;             // number of bins+1: cluster TPC
+  Int_t fhNBinsClusterITS;             // number of bins+1: cluster ITS
+  Int_t fhNBinsChi2TPC;                        // number of bins+1: chi2 per cluster TPC
+  Int_t fhNBinsChi2ITS;                        // number of bins+1: chi2 per cluster ITS
+  Int_t fhNBinsRefitTPC;               // number of bins+1: require refit TPC
+  Int_t fhNBinsRefitITS;               // number of bins+1: require refit ITS  
+  Int_t fhNBinsCovariance11;           // number of bins+1: covariance matrix element 11
+  Int_t fhNBinsCovariance22;           // number of bins+1: covariance matrix element 22
+  Int_t fhNBinsCovariance33;           // number of bins+1: covariance matrix element 33
+  Int_t fhNBinsCovariance44;           // number of bins+1: covariance matrix element 44
+  Int_t fhNBinsCovariance55;           // number of bins+1: covariance matrix element 55
 
   Double_t *fhBinLimClusterTPC;        //[fhNBinsClusterTPC] bin limits: cluster TPC
   Double_t *fhBinLimClusterITS;        //[fhNBinsClusterITS] bin limits: cluster ITS
index 2d539d8..3fa7edb 100755 (executable)
@@ -32,8 +32,6 @@ class AliCFVGrid : public AliCFFrame
 
   virtual Float_t GetOverFlows(Int_t var) const = 0;
   virtual Float_t GetUnderFlows(Int_t var)const = 0;
-  virtual Float_t GetOverFlows()const = 0;
-  virtual Float_t GetUnderFlows()const = 0;
   virtual Float_t GetEntries()const = 0 ;
 
   virtual Float_t GetElement(Int_t iel)const = 0; 
index 267bddf..eb8c8da 100644 (file)
@@ -7,6 +7,7 @@
 #pragma link C++ class  AliCFFrame+;
 #pragma link C++ class  AliCFVGrid+;
 #pragma link C++ class  AliCFGrid+;
+#pragma link C++ class  AliCFGridSparse+;
 #pragma link C++ class  AliCFEffGrid+;
 #pragma link C++ class  AliCFDataGrid+;
 #pragma link C++ class  AliCFContainer+;
index 4b23bf4..e6617cc 100644 (file)
@@ -1,6 +1,7 @@
 SRCS = AliCFFrame.cxx \
        AliCFVGrid.cxx \
        AliCFGrid.cxx \
+       AliCFGridSparse.cxx \
        AliCFEffGrid.cxx \
        AliCFDataGrid.cxx \
        AliCFContainer.cxx \
index f72962a..f4186f2 100644 (file)
@@ -75,7 +75,8 @@ void testCFContainers(){
   
   
   //the nstep grids "container" 
-  AliCFContainer *cont = new AliCFContainer("cont","example of  container",nstep,nvar,iBin);
+  //   AliCFContainer *cont = new AliCFContainer("cont","example of  container",nstep,nvar,iBin);
+  AliCFContainer *cont = new AliCFContainer("cont","example of  container",nstep,nvar,iBin, 0x0,kTRUE);
 
   //setting the bin limits
   cont->SetBinLimits(ipt,binLim1);
@@ -161,6 +162,7 @@ void testCFContainers(){
   hptvtx2a->SetMinimum(0.01);
   hptvtx2a->Draw("lego");
   
+  ceff->Print("eff.gif");
 
   //get the corrected data grid  
   AliCFDataGrid *corrdata = new AliCFDataGrid("corrdata","corrected data",*data);
@@ -180,11 +182,6 @@ void testCFContainers(){
   TH1D *hpt3b = corrdata->Project(ipt); //corrected data
   hpt3b->SetMinimum(0.01);
   hpt3b->Draw();
-//the "MC truth" (ideally == corrdata, modulo 0-efficiency bins....so this depends on the segmentation of your grid and the statistics you have)
-  TH1D *hpt3c = eff->GetDen()->Project(ipt); 
-  hpt3c->SetMinimum(0.01);
-  hpt3c->SetLineColor(2);
-  hpt3c->Draw("same");
   ccorrdata->cd(3);
   TH1D *hvtx3a = corrdata->GetData()->Project(ivtx); //uncorrected data
   hvtx3a->SetMinimum(0.01);
@@ -193,11 +190,6 @@ void testCFContainers(){
   TH1D *hvtx3b = corrdata->Project(ivtx); //corrected data
   hvtx3b->SetMinimum(0.01);
   hvtx3b->Draw();
-//the "MC truth" (ideally == corrdata, modulo 0-efficiency bins....so this depends on the segmentation of your grid and the statistics you have)
-  TH1D *hvtx3c = eff->GetDen()->Project(ivtx); 
-  hvtx3c->SetMinimum(0.01);
-  hvtx3c->SetLineColor(2);
-  hvtx3c->Draw("same");
   ccorrdata->Print("corrdata.gif");
 
 }