]>
Commit | Line | Data |
---|---|---|
1b98727b | 1 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
2 | * See cxx source for full Copyright notice */ | |
3 | ||
4 | // Author: Henrik Qvigstad <henrik.qvigstad@cern.ch> | |
5 | /* $Id$ */ | |
6 | ||
7 | ||
8 | #include "AliTRUPedestalOutput.h" | |
9 | ||
10 | ClassImp(AliTRUPedestalOutput) | |
11 | ||
12 | #include "TMath.h" | |
13 | #include <TH1I.h> | |
14 | #include <TH1F.h> | |
15 | #include <TH2F.h> | |
16 | #include <TString.h> | |
17 | #include "TCanvas.h" | |
18 | ||
19 | #include <iostream> | |
20 | using namespace std; | |
21 | ||
22 | AliTRUPedestalOutput::AliTRUPedestalOutput() | |
23 | : fRun(-1), | |
24 | fNEvents(0), | |
25 | fPedestals(0), | |
26 | fPedestalRMS(0), | |
27 | fPedestalSamples(0), | |
28 | fPedestals2d({0}), | |
29 | fPedestalRMS2d({0}), | |
30 | fPedestalsId(0), | |
31 | fPedestals_branch({{{0}}}), | |
32 | fTRUSignals({{{{{0}}}}}) | |
33 | { | |
34 | ||
35 | } | |
36 | ||
37 | AliTRUPedestalOutput::~AliTRUPedestalOutput() | |
38 | { | |
39 | // All the class contains is Histograms, they are owned by current ROOT folder. | |
40 | // new TCanvas; | |
41 | // fTRUSignals[2][0][1][0][1]->DrawCopy(); | |
42 | } | |
43 | ||
44 | void AliTRUPedestalOutput::SetRun ( Int_t run ) | |
45 | { | |
46 | if( fRun >= 0 ) // fRun is initilized to -1 | |
47 | Error("SetRun", "Only one run allowed, i.e. run should not be set, then set to something different."); | |
48 | fRun = run; | |
49 | } | |
50 | ||
51 | void AliTRUPedestalOutput::EventAdded() | |
52 | { | |
53 | fNEvents++; | |
54 | } | |
55 | ||
56 | TH1F* AliTRUPedestalOutput::GetPedestals() | |
57 | { | |
58 | // Delete Histogram if exists | |
59 | if( fPedestals ) | |
60 | fPedestals->Delete(); | |
61 | fPedestals = 0; | |
62 | ||
63 | // Create Histogram | |
64 | fPedestals = new TH1F("fPedestals", "TRU Pedestals", 10*1024, 0, 1024); | |
65 | fPedestals->GetXaxis()->SetTitle("Pedestals, <signal>_c"); | |
66 | fPedestals->GetYaxis()->SetTitle("Count"); | |
67 | ||
68 | // Fill Histogram | |
69 | for (unsigned int mod=0; mod<kNMods; ++mod) { | |
70 | for (unsigned int row=0; row<kNTRURows; ++row) { | |
71 | for (unsigned int branch=0; branch<kNBranches; ++branch) { | |
72 | for (unsigned int xrow=0; xrow<kN2x2XPrTRURow; ++xrow) { | |
73 | for (unsigned int zcol=0; zcol<kN2x2ZPrBranch; ++zcol) { | |
74 | if( ! fTRUSignals[mod][row][branch][xrow][zcol] ) | |
75 | continue; | |
76 | ||
77 | double pedestal = GetPedestal(mod, row, branch, xrow, zcol); | |
78 | fPedestals->Fill(pedestal); | |
79 | } | |
80 | } | |
81 | } | |
82 | } | |
83 | } | |
84 | ||
85 | return fPedestals; | |
86 | } | |
87 | ||
88 | TH1F* AliTRUPedestalOutput::GetPedestalRMS() | |
89 | { | |
90 | // Delete Histogram if exists | |
91 | if( fPedestalRMS ) | |
92 | fPedestalRMS->Delete(); | |
93 | fPedestalRMS = 0; | |
94 | ||
95 | fPedestalRMS = new TH1F("fPedestalRMS", "TRU Pedestal RMS", 1020, 0, 102); | |
96 | fPedestalRMS->GetXaxis()->SetTitle("RMS"); | |
97 | fPedestalRMS->GetYaxis()->SetTitle("Count"); | |
98 | ||
99 | for (unsigned int mod=0; mod<kNMods; ++mod) { | |
100 | for (unsigned int row=0; row<kNTRURows; ++row) { | |
101 | for (unsigned int branch=0; branch<kNBranches; ++branch) { | |
102 | for (unsigned int xrow=0; xrow<kN2x2XPrTRURow; ++xrow) { | |
103 | for (unsigned int zcol=0; zcol<kN2x2ZPrBranch; ++zcol) { | |
104 | if( ! fTRUSignals[mod][row][branch][xrow][zcol] ) | |
105 | continue; | |
106 | ||
107 | double rms = GetRMS(mod, row, branch, xrow, zcol); | |
108 | fPedestalRMS->Fill(rms); | |
109 | if ( 2 < rms ) | |
110 | printf("AliTRUPedestalOutput::GetPedestalRMS: ped. RMS:%f, mod:%d row:%d branch:%d x:%02d z:%02d\n", rms, mod, row, branch, xrow, zcol); | |
111 | ||
112 | } | |
113 | } | |
114 | } | |
115 | } | |
116 | } | |
117 | ||
118 | return fPedestalRMS; | |
119 | } | |
120 | ||
121 | TH1I* AliTRUPedestalOutput::GetPedestalSamples() | |
122 | { | |
123 | if( fPedestalSamples ) | |
124 | fPedestalSamples->Delete(); | |
125 | fPedestalSamples = 0; | |
126 | ||
127 | fPedestalSamples = new TH1I("fPedestalSamples", "TRU Pedestal Samples", 1000, 0, kNTRUTimeBins*fNEvents); | |
128 | fPedestalSamples->GetXaxis()->SetTitle("Samples"); | |
129 | fPedestalSamples->GetYaxis()->SetTitle("Count"); | |
130 | ||
131 | int smallThreshold = 2600; | |
132 | for (unsigned int mod=0; mod<kNMods; ++mod) { | |
133 | for (unsigned int row=0; row<kNTRURows; ++row) { | |
134 | for (unsigned int branch=0; branch<kNBranches; ++branch) { | |
135 | int smallCount = 0; | |
136 | for (unsigned int xrow=0; xrow<kN2x2XPrTRURow; ++xrow) { | |
137 | for (unsigned int zcol=0; zcol<kN2x2ZPrBranch; ++zcol) { | |
138 | if( ! fTRUSignals[mod][row][branch][xrow][zcol] ) | |
139 | continue; | |
140 | ||
141 | double entries = GetSamples(mod, row, branch, xrow, zcol); | |
142 | fPedestalSamples->Fill(entries); | |
143 | if ( entries < smallThreshold ) | |
144 | ++smallCount; | |
145 | } // z | |
146 | } // x | |
147 | if(smallCount) | |
148 | printf("AliTRUPedestalOutput::GetPedestalSamples: Small Sample! %d cells in TRU: mod:%d row:%d branch:%d\n", smallCount, mod, row, branch); | |
149 | } // branch | |
150 | } // row | |
151 | } // mod | |
152 | ||
153 | return fPedestalSamples; | |
154 | } | |
155 | ||
156 | TH2F* AliTRUPedestalOutput::GetPedestals2d(UInt_t mod) | |
157 | { | |
158 | if( fPedestals2d[mod] ) | |
159 | fPedestals2d[mod]->Delete(); | |
160 | fPedestals2d[mod] = 0; | |
161 | ||
162 | const int nhr = kN2x2X +kNTRURows -1; // number of histogram rows, x | |
163 | const int nhc = kN2x2Z +kNBranches -1; // number of histogram columns, z | |
164 | TString name("fPedestals2d_mod:"); name += mod; | |
165 | TString title("fPedestals, Mod: "); title += mod; | |
166 | fPedestals2d[mod] = new TH2F(name, title, nhr, 0, nhr, nhc, 0, nhc); | |
167 | fPedestals2d[mod]->GetXaxis()->SetTitle("x = x_tru + 9*tru"); | |
168 | fPedestals2d[mod]->GetYaxis()->SetTitle("z = z_tru + 15*branch"); | |
169 | fPedestals2d[mod]->SetStats(0); | |
170 | ||
171 | for (unsigned int row=0; row<kNTRURows; ++row) { | |
172 | for (unsigned int branch=0; branch<kNBranches; ++branch) { | |
173 | for (unsigned int xrow=0; xrow<kN2x2XPrTRURow; ++xrow) { | |
174 | for (unsigned int zcol=0; zcol<kN2x2ZPrBranch; ++zcol) { | |
175 | if( ! fTRUSignals[mod][row][branch][xrow][zcol] ) | |
176 | continue; | |
177 | ||
178 | int xindex = xrow + kN2x2XPrTRURow*row +row; | |
179 | int zindex = zcol + kN2x2ZPrBranch*branch +branch; | |
180 | double pedestal = GetPedestal(mod, row, branch, xrow, zcol); | |
181 | ||
182 | fPedestals2d[mod]->SetBinContent(xindex+1, zindex+1, pedestal); | |
183 | } // z col | |
184 | } // x row | |
185 | } // branch, tru | |
186 | } // row, tru | |
187 | fPedestals2d[mod]->SetDrawOption("colz"); | |
188 | return fPedestals2d[mod]; | |
189 | } | |
190 | ||
191 | TH2F* AliTRUPedestalOutput::GetPedestalRMS2d(UInt_t mod) | |
192 | { | |
193 | if( fPedestalRMS2d[mod] ) | |
194 | fPedestalRMS2d[mod]->Delete(); | |
195 | fPedestalRMS2d[mod] = 0; | |
196 | ||
197 | const int nhr = kN2x2X +kNTRURows -1; // number of histogram rows, x | |
198 | const int nhc = kN2x2Z +kNBranches -1; // number of histogram columns, z | |
199 | TString name("fPedestalRMS2d_mod:"); name += mod; | |
200 | TString title("RMS, Mod: "); title += mod; | |
201 | fPedestalRMS2d[mod] = new TH2F(name, title, nhr, 0, nhr, nhc, 0, nhc); | |
202 | fPedestalRMS2d[mod]->GetXaxis()->SetTitle("x = x_tru + 9*tru"); | |
203 | fPedestalRMS2d[mod]->GetYaxis()->SetTitle("z = z_tru + 15*branch"); | |
204 | fPedestalRMS2d[mod]->SetStats(0); | |
205 | ||
206 | for (unsigned int row=0; row<kNTRURows; ++row) { | |
207 | for (unsigned int branch=0; branch<kNBranches; ++branch) { | |
208 | for (unsigned int xrow=0; xrow<kN2x2XPrTRURow; ++xrow) { | |
209 | for (unsigned int zcol=0; zcol<kN2x2ZPrBranch; ++zcol) { | |
210 | if( ! fTRUSignals[mod][row][branch][xrow][zcol] ) | |
211 | continue; | |
212 | ||
213 | int xindex = xrow + kN2x2XPrTRURow*row +row; | |
214 | int zindex = zcol + kN2x2ZPrBranch*branch +branch; | |
215 | double rms = GetRMS(mod, row, branch, xrow, zcol); | |
216 | ||
217 | fPedestalRMS2d[mod]->SetBinContent(xindex+1, zindex+1, rms); | |
218 | } // z col | |
219 | } // x row | |
220 | } // branch, tru | |
221 | } // row, tru | |
222 | fPedestalRMS2d[mod]->SetDrawOption("colz"); | |
223 | return fPedestalRMS2d[mod]; | |
224 | } | |
225 | ||
226 | TH1F* AliTRUPedestalOutput::GetPedestalsId() | |
227 | { | |
228 | if( fPedestalsId ) | |
229 | fPedestalsId->Delete(); | |
230 | fPedestalsId = 0; | |
231 | ||
232 | // else Initilize | |
233 | int nhc = kNMods*kNTRURows*kNBranches*kN2x2XPrTRURow*kN2x2ZPrBranch; | |
234 | TString title("Id v Pedestal"); | |
235 | fPedestalsId = new TH1F("fPedestalsId", title.Data(), nhc, 0, nhc); | |
236 | fPedestalsId->GetXaxis()->SetTitle("Id ([mod][row][branch][x][z], Row-major order)"); | |
237 | fPedestalsId->GetYaxis()->SetTitle("Pedestal"); | |
238 | fPedestalsId->SetStats(0); | |
239 | ||
240 | for (unsigned int mod=0; mod<kNMods; ++mod) { | |
241 | for (unsigned int row=0; row<kNTRURows; ++row) { | |
242 | for (unsigned int branch=0; branch<kNBranches; ++branch) { | |
243 | for (unsigned int xrow=0; xrow<kN2x2XPrTRURow; ++xrow) { | |
244 | for (unsigned int zcol=0; zcol<kN2x2ZPrBranch; ++zcol) { | |
245 | if( ! fTRUSignals[mod][row][branch][xrow][zcol] ) | |
246 | continue; | |
247 | ||
248 | int index = | |
249 | mod*kNTRURows*kNBranches*kN2x2XPrTRURow*kN2x2ZPrBranch | |
250 | + row*kNBranches*kN2x2XPrTRURow*kN2x2ZPrBranch | |
251 | + branch*kN2x2XPrTRURow*kN2x2ZPrBranch | |
252 | + xrow*kN2x2ZPrBranch | |
253 | + zcol; | |
254 | double pedestal = GetPedestal(mod, row, branch, xrow, zcol); | |
255 | double pederror = GetPedestalError(mod, row, branch, xrow, zcol); | |
256 | fPedestalsId->SetBinContent(index+1, pedestal); | |
257 | fPedestalsId->SetBinError(index+1, pederror); | |
258 | } | |
259 | } | |
260 | } | |
261 | } | |
262 | } | |
263 | fPedestalsId->SetDrawOption("E"); | |
264 | return fPedestalsId; | |
265 | } | |
266 | ||
267 | TH1F* AliTRUPedestalOutput::GetPedestals_branch ( UInt_t mod, UInt_t row, UInt_t branch ) | |
268 | { | |
269 | if( fPedestals_branch[mod][row][branch] ) | |
270 | fPedestals_branch[mod][row][branch]->Delete(); | |
271 | fPedestals_branch[mod][row][branch] = 0; | |
272 | ||
273 | TH1F* hist = new TH1F("fPedestals", "Pedestals", 10*1024, 0, 1024); | |
274 | hist->GetXaxis()->SetTitle("Pedestals, <signal>"); | |
275 | hist->GetYaxis()->SetTitle("Count"); | |
276 | ||
277 | for (unsigned int xrow=0; xrow<kN2x2XPrTRURow; ++xrow) { | |
278 | for (unsigned int zcol=0; zcol<kN2x2ZPrBranch; ++zcol) { | |
279 | if( ! fTRUSignals[mod][row][branch][xrow][zcol] ) | |
280 | continue; | |
281 | double pedestal = GetPedestal(mod, row, branch, xrow, zcol); | |
282 | hist->Fill(pedestal); | |
283 | } | |
284 | } | |
285 | ||
286 | return fPedestals_branch[mod][row][branch] = hist; | |
287 | } | |
288 | ||
289 | TH1I* AliTRUPedestalOutput::GetTRUSignals ( UInt_t mod, UInt_t row, UInt_t branch, UInt_t x, UInt_t z ) | |
290 | { | |
291 | if( fTRUSignals[mod][row][branch][x][z] ) | |
292 | return fTRUSignals[mod][row][branch][x][z]; | |
293 | else | |
294 | { | |
295 | // else Initilize | |
296 | char name[256]; | |
297 | sprintf(name, "fTRUSignals_m:%d_r:%d_b:%d_x:%02d_z:%02d", mod, row, branch, x, z); | |
298 | char title[256]; | |
299 | sprintf(title, "TRU Signal mod:%d row:%d branch:%d x:%02d z:%02d", mod, row, branch, x, z); | |
300 | ||
301 | TH1I* hist = new TH1I(name, title, 1024, 0, 1024); | |
302 | hist->GetXaxis()->SetTitle("Bin"); | |
303 | hist->GetYaxis()->SetTitle("Count"); | |
304 | return fTRUSignals[mod][row][branch][x][z] = hist; | |
305 | } | |
306 | } | |
307 | ||
308 | Double_t AliTRUPedestalOutput::GetPedestal ( UInt_t mod, UInt_t row, UInt_t branch, UInt_t x, UInt_t z ) | |
309 | { | |
310 | ||
311 | if( fTRUSignals[mod][row][branch][x][z] ) | |
312 | return fTRUSignals[mod][row][branch][x][z]->GetMean(); | |
313 | else | |
314 | return -1; | |
315 | } | |
316 | ||
317 | Double_t AliTRUPedestalOutput::GetPedestalError ( UInt_t mod, UInt_t row, UInt_t branch, UInt_t x, UInt_t z ) | |
318 | { | |
319 | if( fTRUSignals[mod][row][branch][x][z] ) | |
320 | return fTRUSignals[mod][row][branch][x][z]->GetMeanError(); | |
321 | else | |
322 | return -1; | |
323 | ||
324 | } | |
325 | ||
326 | Double_t AliTRUPedestalOutput::GetRMS ( UInt_t mod, UInt_t row, UInt_t branch, UInt_t x, UInt_t z ) | |
327 | { | |
328 | if( fTRUSignals[mod][row][branch][x][z] ) | |
329 | return fTRUSignals[mod][row][branch][x][z]->GetRMS(); | |
330 | else | |
331 | return -1; | |
332 | } | |
333 | ||
334 | Double_t AliTRUPedestalOutput::GetSamples(UInt_t mod, UInt_t row, UInt_t branch, UInt_t x, UInt_t z) | |
335 | { | |
336 | if( fTRUSignals[mod][row][branch][x][z] ) | |
337 | return fTRUSignals[mod][row][branch][x][z]->GetEntries(); | |
338 | else | |
339 | return -1; | |
340 | } | |
341 | ||
342 | // TH2F* AliTRUPedestalOutput::GetPedestalRMS2d_old(UInt_t mod) | |
343 | // { | |
344 | // if( fPedestalRMS2d[mod] ) | |
345 | // fPedestalRMS2d[mod]->Delete(); | |
346 | // fPedestalRMS2d[mod] = 0; | |
347 | // | |
348 | // const int nhr = 2*kN2x2X +2*kNTRURows; // number of histogram rows, x | |
349 | // const int nhc = 2*kN2x2Z +2*kNBranches; // number of histogram columns, z | |
350 | // TString name("fPedestalRMS2d_mod:"); name += mod; | |
351 | // TString title("RMS, Mod: "); title += mod; | |
352 | // fPedestalRMS2d[mod] = new TH2F(name, title, nhr, 0, nhr, nhc, 0, nhc); | |
353 | // fPedestalRMS2d[mod]->GetXaxis()->SetTitle("x"); | |
354 | // fPedestalRMS2d[mod]->GetYaxis()->SetTitle("z"); | |
355 | // | |
356 | // for (unsigned int row=0; row<kNTRURows; ++row) { | |
357 | // for (unsigned int branch=0; branch<kNBranches; ++branch) { | |
358 | // for (unsigned int xrow=0; xrow<kN2x2XPrTRURow; ++xrow) { | |
359 | // for (unsigned int zcol=0; zcol<kN2x2ZPrBranch; ++zcol) { | |
360 | // if( ! fTRUSignals[mod][row][branch][xrow][zcol] ) | |
361 | // continue; | |
362 | // | |
363 | // int xindex = 2*xrow + 2*kN2x2XPrTRURow*row +2*row; | |
364 | // int zindex = 2*zcol + 2*kN2x2ZPrBranch*branch +2*branch; | |
365 | // double rms = GetRMS(mod, row, branch, xrow, zcol); | |
366 | // | |
367 | // fPedestalRMS2d[mod]->SetBinContent(xindex+1, zindex+1, rms); | |
368 | // } // z col | |
369 | // } // x row | |
370 | // } // branch, tru | |
371 | // } // row, tru | |
372 | // fPedestalRMS2d[mod]->SetDrawOption("colz"); | |
373 | // return fPedestalRMS2d[mod]; | |
374 | // } |