]> git.uio.no Git - u/mrichter/AliRoot.git/blame - CORRFW/AliCFDataGrid.cxx
Move old trigger code to attic
[u/mrichter/AliRoot.git] / CORRFW / AliCFDataGrid.cxx
CommitLineData
563113d0 1/* $Id$ */
1e9dad92 2/**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
7 * *
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 **************************************************************************/
563113d0 16//--------------------------------------------------------------------//
17// //
18// AliCFDataGrid Class //
19// Class to handle observed data and correct them //
20// //
21// -- Author : S.Arcelli //
22// //
23// //
24// //
25//--------------------------------------------------------------------//
26//
27//
9f6be3a2 28#include "TMath.h"
29#include "AliLog.h"
563113d0 30#include "AliCFDataGrid.h"
31
32//____________________________________________________________________
33ClassImp(AliCFDataGrid)
34
35//____________________________________________________________________
36AliCFDataGrid::AliCFDataGrid() :
25488e18 37 AliCFGridSparse(),
563113d0 38 fSelData(-1),
39 fContainer(0x0)
40{
41 //
42 // default constructor
43 //
563113d0 44}
45
46//____________________________________________________________________
47AliCFDataGrid::AliCFDataGrid(const Char_t* name,const Char_t* title) :
25488e18 48 AliCFGridSparse(name,title),
563113d0 49 fSelData(-1),
50 fContainer(0x0)
51{
52 //
53 // default constructor
54 //
563113d0 55}
56
57//____________________________________________________________________
1e9dad92 58AliCFDataGrid::AliCFDataGrid(const Char_t* name, const Char_t* title, const Int_t nVarIn, const Int_t * nBinIn, const Double_t *binLimitsIn) :
25488e18 59 AliCFGridSparse(name,title,nVarIn,nBinIn,binLimitsIn),
563113d0 60 fSelData(-1),
61 fContainer(0x0)
62{
63 //
64 // main constructor
65 //
66 SumW2();// errors saved
67}
68//____________________________________________________________________
69AliCFDataGrid::AliCFDataGrid(const Char_t* name, const Char_t* title, const AliCFContainer &c) :
25488e18 70 AliCFGridSparse(name,title,c.GetNVar(),c.GetNBins(),c.GetBinLimits()),
563113d0 71 fSelData(-1),
72 fContainer(0x0)
73{
74 //
75 // main constructor
76 //
77 SumW2();
78 //assign the container;
79 fContainer=&c;
80
81}
82//____________________________________________________________________
25488e18 83AliCFDataGrid::AliCFDataGrid(const AliCFDataGrid& data) : AliCFGridSparse(),
563113d0 84 fSelData(-1),
85 fContainer(0x0)
86{
87 //
88 // copy constructor
89 //
90 ((AliCFDataGrid &)data).Copy(*this);
91}
92
93//____________________________________________________________________
94AliCFDataGrid::~AliCFDataGrid()
95{
96 //
97 // destructor
98 //
99}
100//____________________________________________________________________
101AliCFDataGrid &AliCFDataGrid::operator=(const AliCFDataGrid &c)
102{
103 //
104 // assigment operator
105 //
106 if (this != &c)
107 ((AliCFDataGrid &) c).Copy(*this);
108 return *this;
109}
110//____________________________________________________________________
111
112void AliCFDataGrid::SetMeasured(Int_t istep)
113{
114 //
115 // Deposit observed data over the grid
116 //
117 Int_t nEmptyBins=0;
118 fSelData=istep;
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);
123 SetElement(i,meas);
124 SetElementError(i,dmeas);
125 if(meas <=0)nEmptyBins++;
126 }
25488e18 127
128 //fNentriesTot=fNDim;
129 GetGrid()->SetEntries(GetData()->GetEntries());
130 //
131
563113d0 132 AliInfo(Form("retrieving measured data from Container %s at selection step %i: %i empty bins were found.",fContainer->GetName(),fSelData,nEmptyBins));
133}
134//____________________________________________________________________
135void AliCFDataGrid::ApplyEffCorrection(const AliCFEffGrid &c)
136{
137
138 //
139 // Apply the efficiency correction
140 //
141 if(c.GetNVar()!=fNVar){
142 AliInfo("Different number of variables, cannot apply correction");
143 return;
144 }
145 if(c.GetNDim()!=fNDim){
146 AliInfo("Different number of dimension, cannot apply correction");
147 return;
148 }
149
150 //Get the data
151 Int_t ncorr=0;
152 Int_t nnocorr=0;
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);
1e9dad92 157 deff =c.GetElementError(i);
563113d0 158 unc =GetElement(i);
1e9dad92 159 dunc =GetElementError(i);
25488e18 160
563113d0 161 if(eff>0 && unc>0){
162 ncorr++;
163 corr=unc/eff;
164 dcorr=TMath::Sqrt(dunc*dunc/unc/unc+deff*deff/eff/eff)*corr;
165 SetElement(i,corr);
1e9dad92 166 SetElementError(i,dcorr);
563113d0 167 } else{
168 if(unc>0)nnocorr++;
169 SetElement(i,0);
170 SetElementError(i,0);
171 }
172 }
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()));
175}
176//____________________________________________________________________
177void AliCFDataGrid::ApplyBGCorrection(const AliCFDataGrid &c)
178{
179
180 //
181 // Apply correction for background
182 //
183 if(c.GetNVar()!=fNVar){
184 AliInfo("Different number of variables, cannot apply correction");
185 return;
186 }
187 if(c.GetNDim()!=fNDim){
188 AliInfo("Different number of dimension, cannot apply correction");
189 return;
190 }
191
192 //Get the data
193 Float_t bkg,dbkg,unc,dunc,corr,dcorr;
194
195 //Apply the correction
196
197 for(Int_t i=0;i<fNDim;i++){
198 bkg =c.GetElement(i);
1e9dad92 199 dbkg =c.GetElementError(i);
563113d0 200 unc =GetElement(i);
1e9dad92 201 dunc =GetElementError(i);
563113d0 202 corr=unc-bkg;
1e9dad92 203 dcorr=TMath::Sqrt(unc+bkg); //stat err only...
563113d0 204 SetElement(i,corr);
1e9dad92 205 SetElementError(i,dcorr);
563113d0 206
207 }
208}
563113d0 209//____________________________________________________________________
210void AliCFDataGrid::Copy(TObject& eff) const
211{
212 // copy function
213
214 Copy(eff);
215 AliCFDataGrid& target = (AliCFDataGrid &) eff;
216 target.fContainer=fContainer;
217 target.fSelData=fSelData;
218
219}