//
#include <AliLog.h>
#include "AliCFGrid.h"
-//#include "AliCFGridSparse.h"
+#include "AliCFGridSparse.h"
#include "AliCFContainer.h"
//____________________________________________________________________
AliCFContainer::AliCFContainer() :
AliCFFrame(),
fNStep(0),
+ fExclOffEntriesInProj(kTRUE),
fGrid(0x0)
{
//
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 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),
+ fExclOffEntriesInProj(kTRUE),
fGrid(0x0)
{
//
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();
}
}
//____________________________________________________________________
AliCFContainer::AliCFContainer(const AliCFContainer& c) :
AliCFFrame(),
- fNStep(0),
- fGrid(0x0)
+ fNStep(c.fNStep),
+ fExclOffEntriesInProj(c.fExclOffEntriesInProj),
+ fGrid(c.fGrid)
{
//
// copy constructor
//
AliCFContainer& target = (AliCFContainer &) c;
target.fNStep=fNStep;
+ target.fExclOffEntriesInProj=fExclOffEntriesInProj;
target.fNVar=fNVar;
target.fNDim=fNDim;
target.fNVarBinLimits=fNVarBinLimits;
// 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);
}
//___________________________________________________________________
//
// 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);
}
//___________________________________________________________________
//
// 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);
}
//___________________________________________________________________
// 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);
}
//___________________________________________________________________
//
// Make a slice along variable ivar at selection level istep in range [varMin,varMax]
//
+ if(istep >= fNStep || istep < 0){
+ AliError("Non-existent selection step, return NULL");
+ return 0x0;
+ }
return (TH1D*)fGrid[istep]->Slice(ivar,varMin,varMax);
}
//____________________________________________________________________
//
//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);
}
//
// 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, 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);
}
//_____________________________________________________________________
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();
}
//_____________________________________________________________________
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);
}