]>
Commit | Line | Data |
---|---|---|
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 | //____________________________________________________________________ | |
33 | ClassImp(AliCFDataGrid) | |
34 | ||
35 | //____________________________________________________________________ | |
36 | AliCFDataGrid::AliCFDataGrid() : | |
37 | AliCFGrid(), | |
38 | fSelData(-1), | |
39 | fContainer(0x0) | |
40 | { | |
41 | // | |
42 | // default constructor | |
43 | // | |
44 | SumW2(); //errors saved | |
45 | } | |
46 | ||
47 | //____________________________________________________________________ | |
48 | AliCFDataGrid::AliCFDataGrid(const Char_t* name,const Char_t* title) : | |
49 | AliCFGrid(name,title), | |
50 | fSelData(-1), | |
51 | fContainer(0x0) | |
52 | { | |
53 | // | |
54 | // default constructor | |
55 | // | |
56 | SumW2(); //errors saved | |
57 | } | |
58 | ||
59 | //____________________________________________________________________ | |
1e9dad92 | 60 | AliCFDataGrid::AliCFDataGrid(const Char_t* name, const Char_t* title, const Int_t nVarIn, const Int_t * nBinIn, const Double_t *binLimitsIn) : |
563113d0 | 61 | AliCFGrid(name,title,nVarIn,nBinIn,binLimitsIn), |
62 | fSelData(-1), | |
63 | fContainer(0x0) | |
64 | { | |
65 | // | |
66 | // main constructor | |
67 | // | |
68 | SumW2();// errors saved | |
69 | } | |
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()), | |
73 | fSelData(-1), | |
74 | fContainer(0x0) | |
75 | { | |
76 | // | |
77 | // main constructor | |
78 | // | |
79 | SumW2(); | |
80 | //assign the container; | |
81 | fContainer=&c; | |
82 | ||
83 | } | |
84 | //____________________________________________________________________ | |
85 | AliCFDataGrid::AliCFDataGrid(const AliCFDataGrid& data) : AliCFGrid(), | |
86 | fSelData(-1), | |
87 | fContainer(0x0) | |
88 | { | |
89 | // | |
90 | // copy constructor | |
91 | // | |
92 | ((AliCFDataGrid &)data).Copy(*this); | |
93 | } | |
94 | ||
95 | //____________________________________________________________________ | |
96 | AliCFDataGrid::~AliCFDataGrid() | |
97 | { | |
98 | // | |
99 | // destructor | |
100 | // | |
101 | } | |
102 | //____________________________________________________________________ | |
103 | AliCFDataGrid &AliCFDataGrid::operator=(const AliCFDataGrid &c) | |
104 | { | |
105 | // | |
106 | // assigment operator | |
107 | // | |
108 | if (this != &c) | |
109 | ((AliCFDataGrid &) c).Copy(*this); | |
110 | return *this; | |
111 | } | |
112 | //____________________________________________________________________ | |
113 | ||
114 | void AliCFDataGrid::SetMeasured(Int_t istep) | |
115 | { | |
116 | // | |
117 | // Deposit observed data over the grid | |
118 | // | |
119 | Int_t nEmptyBins=0; | |
120 | fSelData=istep; | |
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); | |
125 | SetElement(i,meas); | |
126 | SetElementError(i,dmeas); | |
127 | if(meas <=0)nEmptyBins++; | |
128 | } | |
129 | fNentriesTot=fNDim; | |
130 | AliInfo(Form("retrieving measured data from Container %s at selection step %i: %i empty bins were found.",fContainer->GetName(),fSelData,nEmptyBins)); | |
131 | } | |
132 | //____________________________________________________________________ | |
133 | void AliCFDataGrid::ApplyEffCorrection(const AliCFEffGrid &c) | |
134 | { | |
135 | ||
136 | // | |
137 | // Apply the efficiency correction | |
138 | // | |
139 | if(c.GetNVar()!=fNVar){ | |
140 | AliInfo("Different number of variables, cannot apply correction"); | |
141 | return; | |
142 | } | |
143 | if(c.GetNDim()!=fNDim){ | |
144 | AliInfo("Different number of dimension, cannot apply correction"); | |
145 | return; | |
146 | } | |
147 | ||
148 | //Get the data | |
149 | Int_t ncorr=0; | |
150 | Int_t nnocorr=0; | |
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); | |
1e9dad92 | 155 | deff =c.GetElementError(i); |
563113d0 | 156 | unc =GetElement(i); |
1e9dad92 | 157 | dunc =GetElementError(i); |
563113d0 | 158 | if(eff>0 && unc>0){ |
159 | ncorr++; | |
160 | corr=unc/eff; | |
161 | dcorr=TMath::Sqrt(dunc*dunc/unc/unc+deff*deff/eff/eff)*corr; | |
162 | SetElement(i,corr); | |
1e9dad92 | 163 | SetElementError(i,dcorr); |
563113d0 | 164 | } else{ |
165 | if(unc>0)nnocorr++; | |
166 | SetElement(i,0); | |
167 | SetElementError(i,0); | |
168 | } | |
169 | } | |
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())); | |
172 | } | |
173 | //____________________________________________________________________ | |
174 | void AliCFDataGrid::ApplyBGCorrection(const AliCFDataGrid &c) | |
175 | { | |
176 | ||
177 | // | |
178 | // Apply correction for background | |
179 | // | |
180 | if(c.GetNVar()!=fNVar){ | |
181 | AliInfo("Different number of variables, cannot apply correction"); | |
182 | return; | |
183 | } | |
184 | if(c.GetNDim()!=fNDim){ | |
185 | AliInfo("Different number of dimension, cannot apply correction"); | |
186 | return; | |
187 | } | |
188 | ||
189 | //Get the data | |
190 | Float_t bkg,dbkg,unc,dunc,corr,dcorr; | |
191 | ||
192 | //Apply the correction | |
193 | ||
194 | for(Int_t i=0;i<fNDim;i++){ | |
195 | bkg =c.GetElement(i); | |
1e9dad92 | 196 | dbkg =c.GetElementError(i); |
563113d0 | 197 | unc =GetElement(i); |
1e9dad92 | 198 | dunc =GetElementError(i); |
563113d0 | 199 | corr=unc-bkg; |
1e9dad92 | 200 | dcorr=TMath::Sqrt(unc+bkg); //stat err only... |
563113d0 | 201 | SetElement(i,corr); |
1e9dad92 | 202 | SetElementError(i,dcorr); |
563113d0 | 203 | |
204 | } | |
205 | } | |
563113d0 | 206 | //____________________________________________________________________ |
207 | void AliCFDataGrid::Copy(TObject& eff) const | |
208 | { | |
209 | // copy function | |
210 | ||
211 | Copy(eff); | |
212 | AliCFDataGrid& target = (AliCFDataGrid &) eff; | |
213 | target.fContainer=fContainer; | |
214 | target.fSelData=fSelData; | |
215 | ||
216 | } |