2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16 //--------------------------------------------------------------------//
18 // AliCFDataGrid Class //
19 // Class to handle observed data and correct them //
21 // -- Author : S.Arcelli //
25 //--------------------------------------------------------------------//
30 #include "AliCFDataGrid.h"
32 //____________________________________________________________________
33 ClassImp(AliCFDataGrid)
35 //____________________________________________________________________
36 AliCFDataGrid::AliCFDataGrid() :
42 // default constructor
46 //____________________________________________________________________
47 AliCFDataGrid::AliCFDataGrid(const Char_t* name,const Char_t* title) :
48 AliCFGridSparse(name,title),
53 // default constructor
57 //____________________________________________________________________
58 AliCFDataGrid::AliCFDataGrid(const Char_t* name, const Char_t* title, const Int_t nVarIn, const Int_t * nBinIn, const Double_t *binLimitsIn) :
59 AliCFGridSparse(name,title,nVarIn,nBinIn,binLimitsIn),
66 SumW2();// errors saved
68 //____________________________________________________________________
69 AliCFDataGrid::AliCFDataGrid(const Char_t* name, const Char_t* title, const AliCFContainer &c) :
70 AliCFGridSparse(name,title,c.GetNVar(),c.GetNBins(),c.GetBinLimits()),
78 //assign the container;
82 //____________________________________________________________________
83 AliCFDataGrid::AliCFDataGrid(const AliCFDataGrid& data) : AliCFGridSparse(),
90 ((AliCFDataGrid &)data).Copy(*this);
93 //____________________________________________________________________
94 AliCFDataGrid::~AliCFDataGrid()
100 //____________________________________________________________________
101 AliCFDataGrid &AliCFDataGrid::operator=(const AliCFDataGrid &c)
104 // assigment operator
107 ((AliCFDataGrid &) c).Copy(*this);
110 //____________________________________________________________________
112 void AliCFDataGrid::SetMeasured(Int_t istep)
115 // Deposit observed data over the grid
119 //Initially, set the corrected data to the measured data
120 for(Int_t i=0;i<fNDim;i++){
121 Float_t meas=fContainer->GetGrid(fSelData)->GetElement(i);
122 Float_t dmeas=fContainer->GetGrid(fSelData)->GetElementError(i);
124 SetElementError(i,dmeas);
125 if(meas <=0)nEmptyBins++;
128 //fNentriesTot=fNDim;
129 GetGrid()->SetEntries(GetData()->GetEntries());
132 AliInfo(Form("retrieving measured data from Container %s at selection step %i: %i empty bins were found.",fContainer->GetName(),fSelData,nEmptyBins));
134 //____________________________________________________________________
135 void AliCFDataGrid::ApplyEffCorrection(const AliCFEffGrid &c)
139 // Apply the efficiency correction
141 if(c.GetNVar()!=fNVar){
142 AliInfo("Different number of variables, cannot apply correction");
145 if(c.GetNDim()!=fNDim){
146 AliInfo("Different number of dimension, cannot apply correction");
153 Float_t eff,deff,unc,dunc,corr,dcorr;
154 //Apply the correction
155 for(Int_t i=0;i<fNDim;i++){
156 eff =c.GetElement(i);
157 deff =c.GetElementError(i);
159 dunc =GetElementError(i);
164 dcorr=TMath::Sqrt(dunc*dunc/unc/unc+deff*deff/eff/eff)*corr;
166 SetElementError(i,dcorr);
170 SetElementError(i,0);
173 AliInfo(Form("correction applied for %i cells in correction matrix of Container %s, having entries in Data Container %s.",ncorr,c.GetName(),GetName()));
174 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()));
176 //____________________________________________________________________
177 void AliCFDataGrid::ApplyBGCorrection(const AliCFDataGrid &c)
181 // Apply correction for background
183 if(c.GetNVar()!=fNVar){
184 AliInfo("Different number of variables, cannot apply correction");
187 if(c.GetNDim()!=fNDim){
188 AliInfo("Different number of dimension, cannot apply correction");
193 Float_t bkg,dbkg,unc,dunc,corr,dcorr;
195 //Apply the correction
197 for(Int_t i=0;i<fNDim;i++){
198 bkg =c.GetElement(i);
199 dbkg =c.GetElementError(i);
201 dunc =GetElementError(i);
203 dcorr=TMath::Sqrt(unc+bkg); //stat err only...
205 SetElementError(i,dcorr);
209 //____________________________________________________________________
210 void AliCFDataGrid::Copy(TObject& eff) const
215 AliCFDataGrid& target = (AliCFDataGrid &) eff;
216 target.fContainer=fContainer;
217 target.fSelData=fSelData;