/* $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. *
+ **************************************************************************/
//--------------------------------------------------------------------//
// //
-// AliCFDataGrid Class //
+// AliCFDataGrid Class //
// Class to handle observed data and correct them //
// //
// -- Author : S.Arcelli //
// //
-// //
+// substantially modified by r. vernet //
// //
//--------------------------------------------------------------------//
//
//
-#include <TROOT.h>
-#include <TMath.h>
-#include <TFile.h>
-#include <AliLog.h>
+#include "TMath.h"
+#include "AliLog.h"
#include "AliCFDataGrid.h"
//____________________________________________________________________
//____________________________________________________________________
AliCFDataGrid::AliCFDataGrid() :
- AliCFGrid(),
- fSelData(-1),
- fContainer(0x0)
-{
- //
- // default constructor
- //
- SumW2(); //errors saved
-}
-
-//____________________________________________________________________
-AliCFDataGrid::AliCFDataGrid(const Char_t* name,const Char_t* title) :
- AliCFGrid(name,title),
+ AliCFGridSparse(),
fSelData(-1),
fContainer(0x0)
{
//
// default constructor
//
- SumW2(); //errors saved
}
//____________________________________________________________________
-AliCFDataGrid::AliCFDataGrid(const Char_t* name, const Char_t* title, const Int_t nVarIn, const Int_t * nBinIn, const Float_t *binLimitsIn) :
- AliCFGrid(name,title,nVarIn,nBinIn,binLimitsIn),
+AliCFDataGrid::AliCFDataGrid(const Char_t* name, const Char_t* title, const Int_t nVarIn, const Int_t * nBinIn) :
+ AliCFGridSparse(name,title,nVarIn,nBinIn),
fSelData(-1),
fContainer(0x0)
{
//
SumW2();// errors saved
}
+
//____________________________________________________________________
-AliCFDataGrid::AliCFDataGrid(const Char_t* name, const Char_t* title, const AliCFContainer &c) :
- AliCFGrid(name,title,c.GetNVar(),c.GetNBins(),c.GetBinLimits()),
- fSelData(-1),
- fContainer(0x0)
+AliCFDataGrid::AliCFDataGrid(const Char_t* name, const Char_t* title, const AliCFContainer &c, Int_t step) :
+ AliCFGridSparse(name,title),
+ fSelData(step),
+ fContainer(&c)
{
//
// main constructor
+ // assign directly the selection step
//
- SumW2();
- //assign the container;
- fContainer=&c;
+ //simply clones the container's data at specified step
+ fData = (THnSparse*) fContainer->GetGrid(fSelData)->GetGrid()->Clone();
+ SumW2();
+ AliInfo(Form("retrieving measured data from Container %s at selection step %i.",fContainer->GetName(),fSelData));
}
+
//____________________________________________________________________
-AliCFDataGrid::AliCFDataGrid(const AliCFDataGrid& data) : AliCFGrid(),
+AliCFDataGrid::AliCFDataGrid(const AliCFDataGrid& data) :
+ AliCFGridSparse(data),
fSelData(-1),
fContainer(0x0)
{
// destructor
//
}
+
//____________________________________________________________________
AliCFDataGrid &AliCFDataGrid::operator=(const AliCFDataGrid &c)
{
//
// assigment operator
//
- if (this != &c)
- ((AliCFDataGrid &) c).Copy(*this);
+ if (this != &c) c.Copy(*this);
return *this;
}
-//____________________________________________________________________
-void AliCFDataGrid::SetMeasured(Int_t istep)
-{
- //
- // Deposit observed data over the grid
- //
- Int_t nEmptyBins=0;
- fSelData=istep;
- //Initially, set the corrected data to the measured data
- for(Int_t i=0;i<fNDim;i++){
- Float_t meas=fContainer->GetGrid(fSelData)->GetElement(i);
- Float_t dmeas=fContainer->GetGrid(fSelData)->GetElementError(i);
- SetElement(i,meas);
- SetElementError(i,dmeas);
- if(meas <=0)nEmptyBins++;
- }
- fNentriesTot=fNDim;
- AliInfo(Form("retrieving measured data from Container %s at selection step %i: %i empty bins were found.",fContainer->GetName(),fSelData,nEmptyBins));
-}
//____________________________________________________________________
void AliCFDataGrid::ApplyEffCorrection(const AliCFEffGrid &c)
{
//
// Apply the efficiency correction
//
- if(c.GetNVar()!=fNVar){
+ if (c.GetNVar()!=GetNVar()) {
AliInfo("Different number of variables, cannot apply correction");
return;
}
- if(c.GetNDim()!=fNDim){
- AliInfo("Different number of dimension, cannot apply correction");
- return;
- }
-
- //Get the data
- Int_t ncorr=0;
- Int_t nnocorr=0;
- Float_t eff,deff,unc,dunc,corr,dcorr;
- //Apply the correction
- for(Int_t i=0;i<fNDim;i++){
- eff =c.GetElement(i);
- deff =TMath::Sqrt(c.GetElementError(i));
- unc =GetElement(i);
- dunc =TMath::Sqrt(GetElementError(i));
- if(eff>0 && unc>0){
- ncorr++;
- corr=unc/eff;
- dcorr=TMath::Sqrt(dunc*dunc/unc/unc+deff*deff/eff/eff)*corr;
- SetElement(i,corr);
- SetElementError(i,dcorr*dcorr);
-
- } else{
- if(unc>0)nnocorr++;
- SetElement(i,0);
- SetElementError(i,0);
- }
- }
- AliInfo(Form("correction applied for %i cells in correction matrix of Container %s, having entries in Data Container %s.",ncorr,c.GetName(),GetName()));
- AliInfo(Form("No correction applied for %i empty bins in correction matrix of Container %s, having entries in Data Container %s. Their content in the corrected data container was set to zero",nnocorr,c.GetName(),GetName()));
+ Divide(&c);
+ AliInfo(Form("correction applied on data grid %s with efficiency %s.",GetName(),c.GetName()));
}
//____________________________________________________________________
void AliCFDataGrid::ApplyBGCorrection(const AliCFDataGrid &c)
//
// Apply correction for background
//
- if(c.GetNVar()!=fNVar){
+ if (c.GetNVar()!=GetNVar()) {
AliInfo("Different number of variables, cannot apply correction");
return;
}
- if(c.GetNDim()!=fNDim){
- AliInfo("Different number of dimension, cannot apply correction");
- return;
- }
-
- //Get the data
- Float_t bkg,dbkg,unc,dunc,corr,dcorr;
-
- //Apply the correction
-
- for(Int_t i=0;i<fNDim;i++){
- bkg =c.GetElement(i);
- dbkg =TMath::Sqrt(c.GetElementError(i));
- unc =GetElement(i);
- dunc =TMath::Sqrt(GetElementError(i));
- corr=unc-bkg;
- dcorr=TMath::Sqrt(unc+bkg); //stats only, check this
- SetElement(i,corr);
- SetElementError(i,dcorr*dcorr);
-
- }
+ Add(&c,-1);
+ AliInfo(Form("background %s subtracted from data %s.",c.GetName(),GetName()));
}
//____________________________________________________________________
-void AliCFDataGrid::Copy(TObject& eff) const
+void AliCFDataGrid::Copy(TObject& c) const
{
// copy function
-
- Copy(eff);
- AliCFDataGrid& target = (AliCFDataGrid &) eff;
+ Copy(c);
+ AliCFDataGrid& target = (AliCFDataGrid &) c;
target.fContainer=fContainer;
target.fSelData=fSelData;
-
}