]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - CORRFW/AliCFContainer.cxx
QA histograms filling for missing steps
[u/mrichter/AliRoot.git] / CORRFW / AliCFContainer.cxx
index dbe12a8501f8854826a53ff6d07b5bc9f1657e57..aceddd0f19e175ecf575b338a3be1b887d492685 100644 (file)
@@ -1,5 +1,18 @@
 /* $Id$ */
-
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
 //--------------------------------------------------------------------//
 //                                                                    //
 // AliCFContainer Class                                           //
@@ -13,6 +26,7 @@
 //
 #include <AliLog.h>
 #include "AliCFGrid.h"
+#include "AliCFGridSparse.h"
 #include "AliCFContainer.h"
 
 //____________________________________________________________________
@@ -22,6 +36,7 @@ ClassImp(AliCFContainer)
 AliCFContainer::AliCFContainer() : 
   AliCFFrame(),
   fNStep(0),
+  fExclOffEntriesInProj(kTRUE),
   fGrid(0x0)
 {
   //
@@ -32,15 +47,17 @@ AliCFContainer::AliCFContainer() :
 AliCFContainer::AliCFContainer(const Char_t* name, const Char_t* title) : 
   AliCFFrame(name,title),
   fNStep(0),
+  fExclOffEntriesInProj(kTRUE),
   fGrid(0x0)
 {
   // default constructor
 }
 
 //____________________________________________________________________
-AliCFContainer::AliCFContainer(const Char_t* name, const Char_t* title,const Int_t nSelSteps, const Int_t nVarIn, const Int_t * nBinIn, const Float_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),
+  fExclOffEntriesInProj(kTRUE),
   fGrid(0x0)
 {
   //
@@ -51,18 +68,25 @@ AliCFContainer::AliCFContainer(const Char_t* name, const Char_t* title,const Int
   fNStep=nSelSteps;
 
   // The grids 
-  fGrid = new AliCFGrid*[fNStep]; //the grids at the various selection steps
+  fGrid = new AliCFVGrid*[fNStep]; //the grids at the various selection steps
   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); 
+    if(!useSparse){
+      fGrid[istep] = new AliCFGrid(gname,title,nVarIn,nBinIn,binLimitsIn); 
+      }
+    else{
+      fGrid[istep] = new AliCFGridSparse(gname,title,nVarIn,nBinIn,binLimitsIn); 
+    }
+    fGrid[istep]->SumW2(); 
   }
 }
 //____________________________________________________________________
 AliCFContainer::AliCFContainer(const AliCFContainer& c) : 
   AliCFFrame(),
-  fNStep(0),
-  fGrid(0x0)
+  fNStep(c.fNStep),
+  fExclOffEntriesInProj(c.fExclOffEntriesInProj),
+  fGrid(c.fGrid)
 {
   //
   // copy constructor
@@ -89,7 +113,7 @@ AliCFContainer &AliCFContainer::operator=(const AliCFContainer &c)
   return *this;
 } 
 //____________________________________________________________________
-void AliCFContainer::SetBinLimits(Int_t varindex, Float_t *array)
+void AliCFContainer::SetBinLimits(Int_t varindex, Double_t *array)
 {
   //
   // setting the arrays containing the bin limits 
@@ -110,6 +134,7 @@ void AliCFContainer::Copy(TObject& c) const
   //
   AliCFContainer& target = (AliCFContainer &) c;
   target.fNStep=fNStep;
+  target.fExclOffEntriesInProj=fExclOffEntriesInProj;
   target.fNVar=fNVar;
   target.fNDim=fNDim;
   target.fNVarBinLimits=fNVarBinLimits;
@@ -126,46 +151,69 @@ void AliCFContainer::Copy(TObject& c) const
     }  
 }
 //____________________________________________________________________
-void AliCFContainer::Fill(Float_t *var, Int_t istep, Float_t weight)
+void AliCFContainer::Fill(Double_t *var, Int_t istep, Double_t weight)
 {
   //
   // Fills the grid at selection step istep for a set of values of the 
   // input variables, with a given weight (by default w=1)
   //
+  if(istep >= fNStep || istep < 0){
+    AliError("Non-existent selection step, grid was not filled");
+    return;
+  }
   fGrid[istep]->Fill(var,weight);
 }
 //___________________________________________________________________
-TH1F *AliCFContainer::ShowProjection(Int_t ivar, Int_t istep) const
+TH1D *AliCFContainer::ShowProjection(Int_t ivar, Int_t istep) const
 {
   //
   // returns 1-D projection along variable ivar at selection step istep
   //
+  if(istep >= fNStep || istep < 0){
+    AliError("Non-existent selection step, return NULL");
+    return 0x0;
+  }
+  fGrid[istep]->SetExcludeOffEntriesInProj(fExclOffEntriesInProj);
   return fGrid[istep]->Project(ivar);
 }
 //___________________________________________________________________
-TH2F *AliCFContainer::ShowProjection(Int_t ivar1, Int_t ivar2, Int_t istep) const
+TH2D *AliCFContainer::ShowProjection(Int_t ivar1, Int_t ivar2, Int_t istep) const
 {
   //
   // returns 2-D projection along variables ivar1,ivar2 at selection step istep
   //
+  if(istep >= fNStep || istep < 0){
+    AliError("Non-existent selection step, return NULL");
+    return 0x0;
+  }
+  fGrid[istep]->SetExcludeOffEntriesInProj(fExclOffEntriesInProj);
   return fGrid[istep]->Project(ivar1,ivar2);
 }
 //___________________________________________________________________
-TH3F *AliCFContainer::ShowProjection(Int_t ivar1, Int_t ivar2, Int_t ivar3, Int_t istep) const
+TH3D *AliCFContainer::ShowProjection(Int_t ivar1, Int_t ivar2, Int_t ivar3, Int_t istep) const
 {
   //
   // returns 3-D projection along variables ivar1,ivar2,ivar3 
   // at selection step istep
   //
+  if(istep >= fNStep || istep < 0){
+    AliError("Non-existent selection step, return NULL");
+    return 0x0;
+  }
+  fGrid[istep]->SetExcludeOffEntriesInProj(fExclOffEntriesInProj);
   return fGrid[istep]->Project(ivar1,ivar2,ivar3);
 }
 //___________________________________________________________________
-TH1F *AliCFContainer::ShowSlice(Int_t ivar, Float_t *varMin, Float_t* varMax, Int_t istep) const
+TH1D *AliCFContainer::ShowSlice(Int_t ivar, Double_t *varMin, Double_t* varMax, Int_t istep) const
 {
   //
   // Make a slice along variable ivar at selection level istep in range [varMin,varMax]
   //
-  return (TH1F*)fGrid[istep]->Slice(ivar,varMin,varMax);
+  if(istep >= fNStep || istep < 0){
+    AliError("Non-existent selection step, return NULL");
+    return 0x0;
+  }
+  return (TH1D*)fGrid[istep]->Slice(ivar,varMin,varMax);
 }
 //____________________________________________________________________
 Long64_t AliCFContainer::Merge(TCollection* list)
@@ -196,16 +244,19 @@ Long64_t AliCFContainer::Merge(TCollection* list)
 }
 
 //____________________________________________________________________
-void AliCFContainer::Add(AliCFContainer* aContainerToAdd, Float_t c)
+void AliCFContainer::Add(AliCFContainer* aContainerToAdd, Double_t c)
 {
   //
   //add the content of container aContainerToAdd to the current one
   //
-
-  if(aContainerToAdd->GetNStep()!=fNStep)AliError("Different number of steps, cannot add the containers");
-  if(aContainerToAdd->GetNVar()!=fNVar)AliError("Different number of variables, cannot add the containers");
-  if(aContainerToAdd->GetNDim()!=fNDim)AliError("Different number of dimensions, cannot add the containers!");
-  
+  if( (aContainerToAdd->GetNStep()!=fNStep)
+      ||
+      (aContainerToAdd->GetNVar()!=fNVar)
+      ||
+      (aContainerToAdd->GetNDim()!=fNDim)){
+    AliError("Different number of steps/sensitive variables/grid elements: cannot add the containers");
+    return;
+  }
   for(Int_t istep=0;istep<fNStep;istep++){
     fGrid[istep]->Add(aContainerToAdd->GetGrid(istep),c);
   }
@@ -215,63 +266,77 @@ Float_t AliCFContainer::GetOverFlows( Int_t ivar, Int_t istep) const {
   //
   // Get overflows in variable var at selection level istep
   //
+  if(istep >= fNStep || istep < 0){
+    AliError("Non-existent selection step, return -1");
+    return -1.;
+  }
   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
+  // Get underflows in variable var at selection level istep
   //
+  if(istep >= fNStep || istep < 0){
+    AliError("Non-existent selection step, return -1");
+    return -1.;
+  }
   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
+  // Get total entries in variable var at selection level istep
   //
+  if(istep >= fNStep || istep < 0){
+    AliError("Non-existent selection step, return -1");
+    return -1.;
+  }
   return fGrid[istep]->GetEntries();
 } 
 //____________________________________________________________________
 Int_t AliCFContainer::GetEmptyBins( Int_t istep) const {
   //
-  // Get overflows in variable var at selection level istep
+  // Get empty bins in variable var at selection level istep
   //
+  if(istep >= fNStep || istep < 0){
+    AliError("Non-existent selection step, return -1");
+    return -1;
+  }
   return fGrid[istep]->GetEmptyBins();
 } 
 //____________________________________________________________________
-Int_t AliCFContainer::GetEmptyBins( Int_t istep, Float_t *varMin, Float_t* varMax) const {
+Int_t AliCFContainer::GetEmptyBins( Int_t istep, Double_t *varMin, Double_t* varMax) const {
   //
-  // Get overflows in variable var at selection level istep
+  // Get empty bins in a range in variable var at selection level istep
   //
+  if(istep >= fNStep || istep < 0){
+    AliError("Non-existent selection step, return -1");
+    return -1;
+  }
   return fGrid[istep]->GetEmptyBins(varMin,varMax);
 } 
 //_____________________________________________________________________
-Float_t AliCFContainer::GetIntegral( Int_t istep) const 
+Double_t AliCFContainer::GetIntegral( Int_t istep) const 
 {
   //
-  // Get Integral at selection level istep
+  // Get Integral over the grid at selection level istep
   //
+  if(istep >= fNStep || istep < 0){
+    AliError("Non-existent selection step, return -1");
+    return -1.;
+  }
   return fGrid[istep]->GetIntegral();
 }
 //_____________________________________________________________________
-Float_t AliCFContainer::GetIntegral( Int_t istep, Float_t *varMin, Float_t* varMax ) const 
+Double_t AliCFContainer::GetIntegral( Int_t istep, Double_t *varMin, Double_t* varMax ) const 
 {
   //
-  // Get Integral at selection level istep
+  // Get Integral over the grid in a range at selection level istep
   //
+  if(istep >= fNStep || istep < 0){
+    AliError("Non-existent selection step, return -1");
+    return -1.;
+  }
   return fGrid[istep]->GetIntegral(varMin,varMax);
 }