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
44 SumW2(); //errors saved
47 //____________________________________________________________________
48 AliCFDataGrid::AliCFDataGrid(const Char_t* name,const Char_t* title) :
49 AliCFGrid(name,title),
54 // default constructor
56 SumW2(); //errors saved
59 //____________________________________________________________________
60 AliCFDataGrid::AliCFDataGrid(const Char_t* name, const Char_t* title, const Int_t nVarIn, const Int_t * nBinIn, const Double_t *binLimitsIn) :
61 AliCFGrid(name,title,nVarIn,nBinIn,binLimitsIn),
68 SumW2();// errors saved
70 //____________________________________________________________________
71 AliCFDataGrid::AliCFDataGrid(const Char_t* name, const Char_t* title, const AliCFContainer &c) :
72 AliCFGrid(name,title,c.GetNVar(),c.GetNBins(),c.GetBinLimits()),
80 //assign the container;
84 //____________________________________________________________________
85 AliCFDataGrid::AliCFDataGrid(const AliCFDataGrid& data) : AliCFGrid(),
92 ((AliCFDataGrid &)data).Copy(*this);
95 //____________________________________________________________________
96 AliCFDataGrid::~AliCFDataGrid()
102 //____________________________________________________________________
103 AliCFDataGrid &AliCFDataGrid::operator=(const AliCFDataGrid &c)
106 // assigment operator
109 ((AliCFDataGrid &) c).Copy(*this);
112 //____________________________________________________________________
114 void AliCFDataGrid::SetMeasured(Int_t istep)
117 // Deposit observed data over the grid
121 //Initially, set the corrected data to the measured data
122 for(Int_t i=0;i<fNDim;i++){
123 Float_t meas=fContainer->GetGrid(fSelData)->GetElement(i);
124 Float_t dmeas=fContainer->GetGrid(fSelData)->GetElementError(i);
126 SetElementError(i,dmeas);
127 if(meas <=0)nEmptyBins++;
130 AliInfo(Form("retrieving measured data from Container %s at selection step %i: %i empty bins were found.",fContainer->GetName(),fSelData,nEmptyBins));
132 //____________________________________________________________________
133 void AliCFDataGrid::ApplyEffCorrection(const AliCFEffGrid &c)
137 // Apply the efficiency correction
139 if(c.GetNVar()!=fNVar){
140 AliInfo("Different number of variables, cannot apply correction");
143 if(c.GetNDim()!=fNDim){
144 AliInfo("Different number of dimension, cannot apply correction");
151 Float_t eff,deff,unc,dunc,corr,dcorr;
152 //Apply the correction
153 for(Int_t i=0;i<fNDim;i++){
154 eff =c.GetElement(i);
155 deff =c.GetElementError(i);
157 dunc =GetElementError(i);
161 dcorr=TMath::Sqrt(dunc*dunc/unc/unc+deff*deff/eff/eff)*corr;
163 SetElementError(i,dcorr);
167 SetElementError(i,0);
170 AliInfo(Form("correction applied for %i cells in correction matrix of Container %s, having entries in Data Container %s.",ncorr,c.GetName(),GetName()));
171 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()));
173 //____________________________________________________________________
174 void AliCFDataGrid::ApplyBGCorrection(const AliCFDataGrid &c)
178 // Apply correction for background
180 if(c.GetNVar()!=fNVar){
181 AliInfo("Different number of variables, cannot apply correction");
184 if(c.GetNDim()!=fNDim){
185 AliInfo("Different number of dimension, cannot apply correction");
190 Float_t bkg,dbkg,unc,dunc,corr,dcorr;
192 //Apply the correction
194 for(Int_t i=0;i<fNDim;i++){
195 bkg =c.GetElement(i);
196 dbkg =c.GetElementError(i);
198 dunc =GetElementError(i);
200 dcorr=TMath::Sqrt(unc+bkg); //stat err only...
202 SetElementError(i,dcorr);
206 //____________________________________________________________________
207 void AliCFDataGrid::Copy(TObject& eff) const
212 AliCFDataGrid& target = (AliCFDataGrid &) eff;
213 target.fContainer=fContainer;
214 target.fSelData=fSelData;