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 //--------------------------------------------------------------------//
32 #include "AliCFDataGrid.h"
34 //____________________________________________________________________
35 ClassImp(AliCFDataGrid)
37 //____________________________________________________________________
38 AliCFDataGrid::AliCFDataGrid() :
44 // default constructor
46 SumW2(); //errors saved
49 //____________________________________________________________________
50 AliCFDataGrid::AliCFDataGrid(const Char_t* name,const Char_t* title) :
51 AliCFGrid(name,title),
56 // default constructor
58 SumW2(); //errors saved
61 //____________________________________________________________________
62 AliCFDataGrid::AliCFDataGrid(const Char_t* name, const Char_t* title, const Int_t nVarIn, const Int_t * nBinIn, const Double_t *binLimitsIn) :
63 AliCFGrid(name,title,nVarIn,nBinIn,binLimitsIn),
70 SumW2();// errors saved
72 //____________________________________________________________________
73 AliCFDataGrid::AliCFDataGrid(const Char_t* name, const Char_t* title, const AliCFContainer &c) :
74 AliCFGrid(name,title,c.GetNVar(),c.GetNBins(),c.GetBinLimits()),
82 //assign the container;
86 //____________________________________________________________________
87 AliCFDataGrid::AliCFDataGrid(const AliCFDataGrid& data) : AliCFGrid(),
94 ((AliCFDataGrid &)data).Copy(*this);
97 //____________________________________________________________________
98 AliCFDataGrid::~AliCFDataGrid()
104 //____________________________________________________________________
105 AliCFDataGrid &AliCFDataGrid::operator=(const AliCFDataGrid &c)
108 // assigment operator
111 ((AliCFDataGrid &) c).Copy(*this);
114 //____________________________________________________________________
116 void AliCFDataGrid::SetMeasured(Int_t istep)
119 // Deposit observed data over the grid
123 //Initially, set the corrected data to the measured data
124 for(Int_t i=0;i<fNDim;i++){
125 Float_t meas=fContainer->GetGrid(fSelData)->GetElement(i);
126 Float_t dmeas=fContainer->GetGrid(fSelData)->GetElementError(i);
128 SetElementError(i,dmeas);
129 if(meas <=0)nEmptyBins++;
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);
163 dcorr=TMath::Sqrt(dunc*dunc/unc/unc+deff*deff/eff/eff)*corr;
165 SetElementError(i,dcorr);
169 SetElementError(i,0);
172 AliInfo(Form("correction applied for %i cells in correction matrix of Container %s, having entries in Data Container %s.",ncorr,c.GetName(),GetName()));
173 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()));
175 //____________________________________________________________________
176 void AliCFDataGrid::ApplyBGCorrection(const AliCFDataGrid &c)
180 // Apply correction for background
182 if(c.GetNVar()!=fNVar){
183 AliInfo("Different number of variables, cannot apply correction");
186 if(c.GetNDim()!=fNDim){
187 AliInfo("Different number of dimension, cannot apply correction");
192 Float_t bkg,dbkg,unc,dunc,corr,dcorr;
194 //Apply the correction
196 for(Int_t i=0;i<fNDim;i++){
197 bkg =c.GetElement(i);
198 dbkg =c.GetElementError(i);
200 dunc =GetElementError(i);
202 dcorr=TMath::Sqrt(unc+bkg); //stat err only...
204 SetElementError(i,dcorr);
208 //____________________________________________________________________
209 void AliCFDataGrid::Copy(TObject& eff) const
214 AliCFDataGrid& target = (AliCFDataGrid &) eff;
215 target.fContainer=fContainer;
216 target.fSelData=fSelData;