]>
Commit | Line | Data |
---|---|---|
55a288e5 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
0bc7827a | 18 | //////////////////////////////////////////////////////////////////////////// |
19 | // // | |
20 | // AliTRDCalibraVector // | |
21 | // // | |
22 | // This class is for the vector method of the TRD calibration. // | |
23 | // // | |
24 | // Author: // | |
25 | // R. Bailhache (R.Bailhache@gsi.de) // | |
26 | // // | |
27 | //////////////////////////////////////////////////////////////////////////// | |
55a288e5 | 28 | |
29 | #include <TGraphErrors.h> | |
30 | #include <TH1F.h> | |
55a288e5 | 31 | #include <TObjArray.h> |
32 | #include <TMath.h> | |
55a288e5 | 33 | #include <TDirectory.h> |
34 | #include <TROOT.h> | |
35 | #include <TFile.h> | |
36 | ||
37 | #include "AliLog.h" | |
38 | ||
39 | #include "AliTRDCalibraVector.h" | |
40 | #include "AliTRDCommonParam.h" | |
00a3834d | 41 | #include "TArrayF.h" |
42 | #include "TArrayI.h" | |
55a288e5 | 43 | |
44 | ClassImp(AliTRDCalibraVector) | |
45 | ||
46 | //______________________________________________________________________________________ | |
47 | AliTRDCalibraVector::AliTRDCalibraVector() | |
48 | :TObject() | |
00a3834d | 49 | ,fNameCH("CH2d") |
50 | ,fNamePH("PH2d") | |
51 | ,fNamePRF("PRF2d") | |
3a0f6479 | 52 | ,fDetectorPH(-1) |
53 | ,fDetectorCH(-1) | |
54 | ,fDetectorPRF(-1) | |
55a288e5 | 55 | ,fNumberBinCharge(0) |
56 | ,fNumberBinPRF(0) | |
57 | ,fTimeMax(0) | |
170c35f1 | 58 | ,fPRFRange(1.5) |
55a288e5 | 59 | { |
60 | // | |
61 | // Default constructor | |
62 | // | |
00a3834d | 63 | |
64 | for (Int_t idet = 0; idet < 540; idet++){ | |
65 | ||
66 | fPHEntries[idet]=new TArrayI(); | |
67 | fPHMean[idet]=new TArrayF(); | |
68 | fPHSquares[idet]=new TArrayF(); | |
69 | ||
70 | fPRFEntries[idet]=new TArrayI(); | |
71 | fPRFMean[idet]=new TArrayF(); | |
72 | fPRFSquares[idet]=new TArrayF(); | |
73 | ||
74 | ||
75 | fCHEntries[idet]=new TArrayI(); | |
76 | ||
77 | } | |
3a0f6479 | 78 | |
79 | for(Int_t k = 0; k < 3; k++){ | |
80 | fDetCha0[k] = 0; | |
81 | fDetCha2[k] = 0; | |
82 | } | |
83 | ||
55a288e5 | 84 | } |
55a288e5 | 85 | //______________________________________________________________________________________ |
86 | AliTRDCalibraVector::AliTRDCalibraVector(const AliTRDCalibraVector &c) | |
87 | :TObject(c) | |
00a3834d | 88 | ,fNameCH("CH2d") |
89 | ,fNamePH("PH2d") | |
90 | ,fNamePRF("PRF2d") | |
3a0f6479 | 91 | ,fDetectorPH(-1) |
92 | ,fDetectorCH(-1) | |
93 | ,fDetectorPRF(-1) | |
170c35f1 | 94 | ,fNumberBinCharge(c.fNumberBinCharge) |
95 | ,fNumberBinPRF(c.fNumberBinPRF) | |
96 | ,fTimeMax(c.fTimeMax) | |
97 | ,fPRFRange(c.fPRFRange) | |
55a288e5 | 98 | { |
99 | // | |
100 | // Copy constructor | |
101 | // | |
3a0f6479 | 102 | for (Int_t idet = 0; idet < 540; idet++){ |
103 | ||
00a3834d | 104 | const TArrayI *phEntries = (TArrayI*)c.fPHEntries[idet]; |
105 | const TArrayF *phMean = (TArrayF*)c.fPHMean[idet]; | |
106 | const TArrayF *phSquares = (TArrayF*)c.fPHSquares[idet]; | |
3a0f6479 | 107 | |
00a3834d | 108 | const TArrayI *prfEntries = (TArrayI*)c.fPRFEntries[idet]; |
109 | const TArrayF *prfMean = (TArrayF*)c.fPRFMean[idet]; | |
110 | const TArrayF *prfSquares = (TArrayF*)c.fPRFSquares[idet]; | |
3a0f6479 | 111 | |
00a3834d | 112 | const TArrayI *chEntries = (TArrayI*)c.fCHEntries[idet]; |
55a288e5 | 113 | |
00a3834d | 114 | if ( phEntries != 0x0 ) fPHEntries[idet]=new TArrayI(*phEntries); |
115 | if ( phMean != 0x0 ) fPHMean[idet]=new TArrayF(*phMean); | |
116 | if ( phSquares != 0x0 ) fPHSquares[idet]=new TArrayF(*phSquares); | |
3a0f6479 | 117 | |
00a3834d | 118 | if ( prfEntries != 0x0 ) fPRFEntries[idet]=new TArrayI(*prfEntries); |
119 | if ( prfMean != 0x0 ) fPRFMean[idet]=new TArrayF(*prfMean); | |
120 | if ( prfSquares != 0x0 ) fPRFSquares[idet]=new TArrayF(*prfSquares); | |
3a0f6479 | 121 | |
122 | ||
00a3834d | 123 | if ( chEntries != 0x0 ) fCHEntries[idet]=new TArrayI(*chEntries); |
3a0f6479 | 124 | |
125 | } | |
126 | ||
127 | for(Int_t k = 0; k < 3; k++){ | |
128 | fDetCha0[k] = c.fDetCha0[k]; | |
129 | fDetCha2[k] = c.fDetCha2[k]; | |
130 | } | |
131 | ||
00a3834d | 132 | |
3a0f6479 | 133 | } |
134 | //_____________________________________________________________________ | |
135 | AliTRDCalibraVector& AliTRDCalibraVector::operator = (const AliTRDCalibraVector &source) | |
136 | { | |
137 | // | |
138 | // assignment operator | |
139 | // | |
140 | if (&source == this) return *this; | |
141 | new (this) AliTRDCalibraVector(source); | |
142 | ||
143 | return *this; | |
55a288e5 | 144 | } |
55a288e5 | 145 | //____________________________________________________________________________________ |
146 | AliTRDCalibraVector::~AliTRDCalibraVector() | |
147 | { | |
148 | // | |
149 | // AliTRDCalibraVector destructor | |
150 | // | |
1ca79a00 | 151 | |
152 | if(fPHEntries) delete fPHEntries; | |
153 | if(fPHMean) delete fPHMean; | |
154 | if(fPHSquares) delete fPHSquares; | |
155 | if(fPRFEntries) delete fPRFEntries; | |
156 | if(fPRFMean) delete fPRFMean; | |
157 | if(fPRFSquares) delete fPRFSquares; | |
158 | if(fCHEntries) delete fCHEntries; | |
55a288e5 | 159 | |
160 | } | |
55a288e5 | 161 | //_____________________________________________________________________________ |
162 | Int_t AliTRDCalibraVector::SearchBin(Float_t value, Int_t i) const | |
163 | { | |
164 | // | |
165 | // Search the bin | |
166 | // | |
167 | ||
170c35f1 | 168 | Int_t reponse = 0; |
169 | Float_t fbinmin = 0; | |
170 | Float_t fbinmax = value; | |
171 | Int_t fNumberOfBin = -1; | |
55a288e5 | 172 | |
3a0f6479 | 173 | switch(i) |
174 | { | |
175 | case 0: | |
176 | fbinmax = 300.0; | |
177 | fbinmin = 0.0; | |
178 | fNumberOfBin = fNumberBinCharge; | |
179 | break; | |
180 | ||
181 | case 2: | |
182 | fbinmax = TMath::Abs(fPRFRange); | |
183 | fbinmin = -TMath::Abs(fPRFRange); | |
184 | fNumberOfBin = fNumberBinPRF; | |
185 | break; | |
186 | ||
187 | default: | |
188 | return -1; | |
189 | } | |
190 | ||
55a288e5 | 191 | // Return -1 if out |
192 | if ((value >= fbinmax) || | |
193 | (value < fbinmin)) { | |
194 | return -1; | |
195 | } | |
55a288e5 | 196 | else { |
197 | reponse = (Int_t) ((fNumberOfBin*(value-fbinmin)) / (fbinmax-fbinmin)); | |
198 | } | |
199 | ||
200 | return reponse; | |
201 | ||
202 | } | |
55a288e5 | 203 | //_____________________________________________________________________________ |
3a0f6479 | 204 | Bool_t AliTRDCalibraVector::UpdateVectorCH(Int_t det, Int_t group, Float_t value) |
55a288e5 | 205 | { |
206 | // | |
3a0f6479 | 207 | // Fill the vector CH |
55a288e5 | 208 | // |
209 | ||
210 | // Search bin | |
211 | Int_t bin = SearchBin(value,0); | |
212 | // Out | |
3a0f6479 | 213 | if (bin == -1) { |
55a288e5 | 214 | return kFALSE; |
215 | } | |
216 | ||
3a0f6479 | 217 | |
218 | ||
219 | if(fDetectorCH != det){ | |
00a3834d | 220 | fCHEntries[det] = ((TArrayI *)GetCHEntries(det,kTRUE)); |
55a288e5 | 221 | } |
222 | ||
00a3834d | 223 | Int_t entries = ((TArrayI *)fCHEntries[det])->At(group*fNumberBinCharge+bin); |
3a0f6479 | 224 | |
225 | Int_t entriesn = entries+1; | |
00a3834d | 226 | ((TArrayI *)fCHEntries[det])->AddAt(entriesn,group*fNumberBinCharge+bin); |
3a0f6479 | 227 | |
228 | fDetectorCH = det; | |
229 | ||
230 | ||
55a288e5 | 231 | return kTRUE; |
232 | ||
233 | } | |
55a288e5 | 234 | //_____________________________________________________________________________ |
3a0f6479 | 235 | Bool_t AliTRDCalibraVector::UpdateVectorPRF(Int_t det, Int_t group, Float_t x, Float_t y) |
55a288e5 | 236 | { |
237 | // | |
3a0f6479 | 238 | // Fill the vector PRF |
55a288e5 | 239 | // |
240 | ||
241 | // Search bin | |
242 | Int_t bin = SearchBin(x,2); | |
243 | // Out | |
3a0f6479 | 244 | if (bin == -1) { |
55a288e5 | 245 | return kFALSE; |
246 | } | |
247 | ||
3a0f6479 | 248 | |
249 | if(fDetectorPRF != det){ | |
00a3834d | 250 | fPRFEntries[det] = ((TArrayI *)GetPRFEntries(det,kTRUE)); |
251 | fPRFMean[det] = ((TArrayF *)GetPRFMean(det,kTRUE)); | |
252 | fPRFSquares[det] = ((TArrayF *)GetPRFSquares(det,kTRUE)); | |
55a288e5 | 253 | } |
55a288e5 | 254 | |
00a3834d | 255 | Int_t entries = ((TArrayI *)fPRFEntries[det])->At((Int_t)group*fNumberBinPRF+bin); |
256 | Float_t mean = ((TArrayI *)fPRFMean[det])->At((Int_t)group*fNumberBinPRF+bin); | |
257 | Float_t square = ((TArrayI *)fPRFSquares[det])->At((Int_t)group*fNumberBinPRF+bin); | |
3a0f6479 | 258 | |
259 | Int_t entriesn = entries+1; | |
00a3834d | 260 | ((TArrayI *)fPRFEntries[det])->AddAt(entriesn,(Int_t)group*fNumberBinPRF+bin); |
3a0f6479 | 261 | Float_t meann = (mean*((Float_t)entries)+y)/((Float_t)entriesn); |
00a3834d | 262 | ((TArrayF *)fPRFMean[det])->AddAt(meann,(Int_t)group*fNumberBinPRF+bin); |
3a0f6479 | 263 | Float_t squaren = ((square*((Float_t)entries))+(y*y))/((Float_t)entriesn); |
00a3834d | 264 | ((TArrayF *)fPRFSquares[det])->AddAt(squaren,(Int_t)group*fNumberBinPRF+bin); |
55a288e5 | 265 | |
3a0f6479 | 266 | |
267 | fDetectorPRF = det; | |
55a288e5 | 268 | |
269 | return kTRUE; | |
3a0f6479 | 270 | |
55a288e5 | 271 | } |
55a288e5 | 272 | //_____________________________________________________________________________ |
3a0f6479 | 273 | Bool_t AliTRDCalibraVector::UpdateVectorPH(Int_t det, Int_t group, Int_t time, Float_t value) |
55a288e5 | 274 | { |
275 | // | |
3a0f6479 | 276 | // Fill the vector PH |
55a288e5 | 277 | // |
278 | ||
279 | // Search bin | |
280 | Int_t bin = time; | |
281 | // Out | |
282 | if ((bin < 0) || | |
283 | (bin >= fTimeMax)) { | |
284 | return kFALSE; | |
285 | } | |
286 | ||
55a288e5 | 287 | |
3a0f6479 | 288 | if(fDetectorPH != det){ |
00a3834d | 289 | fPHEntries[det] = ((TArrayI *)GetPHEntries(det,kTRUE)); |
290 | fPHMean[det] = ((TArrayF *)GetPHMean(det,kTRUE)); | |
291 | fPHSquares[det] = ((TArrayF *)GetPHSquares(det,kTRUE)); | |
3a0f6479 | 292 | } |
55a288e5 | 293 | |
00a3834d | 294 | Int_t entries = ((TArrayI *)fPHEntries[det])->At(group*fTimeMax+bin); |
295 | Float_t mean = ((TArrayI *)fPHMean[det])->At(group*fTimeMax+bin); | |
296 | Float_t square = ((TArrayI *)fPHSquares[det])->At(group*fTimeMax+bin); | |
3a0f6479 | 297 | |
298 | Int_t entriesn = entries+1; | |
00a3834d | 299 | ((TArrayI *)fPHEntries[det])->AddAt(entriesn,group*fTimeMax+bin); |
3a0f6479 | 300 | Float_t meann = (mean*((Float_t)entries)+value)/((Float_t)entriesn); |
00a3834d | 301 | ((TArrayF *)fPHMean[det])->AddAt(meann,group*fTimeMax+bin); |
3a0f6479 | 302 | Float_t squaren = ((square*((Float_t)entries))+(value*value))/((Float_t)entriesn); |
00a3834d | 303 | ((TArrayF *)fPHSquares[det])->AddAt(squaren,group*fTimeMax+bin); |
55a288e5 | 304 | |
3a0f6479 | 305 | |
306 | fDetectorPH = det; | |
55a288e5 | 307 | |
3a0f6479 | 308 | return kTRUE; |
309 | ||
310 | } | |
311 | //__________________________________________________________________________________ | |
312 | Bool_t AliTRDCalibraVector::Add(AliTRDCalibraVector *calvect) | |
313 | { | |
314 | // | |
315 | // Add a other AliTRCalibraVector to this one | |
316 | // | |
55a288e5 | 317 | |
3a0f6479 | 318 | // Check compatibility |
319 | if(fNumberBinCharge != calvect->GetNumberBinCharge()) return kFALSE; | |
320 | if(fNumberBinPRF != calvect->GetNumberBinPRF()) return kFALSE; | |
321 | if(fPRFRange != calvect->GetPRFRange()) return kFALSE; | |
322 | if(fTimeMax != calvect->GetTimeMax()) return kFALSE; | |
323 | for(Int_t k = 0; k < 3; k++){ | |
324 | if(fDetCha0[k] != calvect->GetDetCha0(k)) return kFALSE; | |
325 | if(fDetCha2[k] != calvect->GetDetCha2(k)) return kFALSE; | |
326 | } | |
55a288e5 | 327 | |
3a0f6479 | 328 | //printf("pass0!\n"); |
55a288e5 | 329 | |
3a0f6479 | 330 | // Add |
331 | for (Int_t idet = 0; idet < 540; idet++){ | |
332 | ||
00a3834d | 333 | const TArrayI *phEntriesvect = calvect->GetPHEntries(idet); |
334 | const TArrayF *phMeanvect = calvect->GetPHMean(idet); | |
335 | const TArrayF *phSquaresvect = calvect->GetPHSquares(idet); | |
3a0f6479 | 336 | |
00a3834d | 337 | const TArrayI *prfEntriesvect = calvect->GetPRFEntries(idet); |
338 | const TArrayF *prfMeanvect = calvect->GetPRFMean(idet); | |
339 | const TArrayF *prfSquaresvect = calvect->GetPRFSquares(idet); | |
3a0f6479 | 340 | |
00a3834d | 341 | const TArrayI *chEntriesvect = calvect->GetCHEntries(idet); |
3a0f6479 | 342 | |
343 | //printf("idet %d!\n",idet); | |
344 | ||
345 | //printf("phEntriesvect %d\n",(Bool_t) phEntriesvect); | |
346 | //printf("phMeanvect %d\n",(Bool_t) phMeanvect); | |
347 | //printf("phSquaresvect %d\n",(Bool_t) phSquaresvect); | |
348 | ||
349 | //printf("prfEntriesvect %d\n",(Bool_t) prfEntriesvect); | |
350 | //printf("prfMeanvect %d\n",(Bool_t) prfMeanvect); | |
351 | //printf("prfSquaresvect %d\n",(Bool_t) prfSquaresvect); | |
352 | ||
353 | //printf("chEntriesvect %d\n",(Bool_t) chEntriesvect); | |
354 | ||
355 | if ( phEntriesvect != 0x0 ){ | |
356 | //Take the stuff | |
00a3834d | 357 | fPHEntries[idet] = ((TArrayI *)GetPHEntries(idet,kTRUE)); |
358 | fPHMean[idet] = ((TArrayF *)GetPHMean(idet,kTRUE)); | |
359 | fPHSquares[idet] = ((TArrayF *)GetPHSquares(idet,kTRUE)); | |
360 | Int_t total = ((TArrayI *)fPHEntries[idet])->GetSize(); | |
3a0f6479 | 361 | // Add |
362 | for(Int_t k = 0; k < total; k++){ | |
00a3834d | 363 | Int_t entries = ((TArrayI *)fPHEntries[idet])->At(k); |
364 | Float_t mean = ((TArrayF *)fPHMean[idet])->At(k); | |
365 | Float_t square = ((TArrayF *)fPHSquares[idet])->At(k); | |
3a0f6479 | 366 | |
00a3834d | 367 | Int_t entriesn = entries+((TArrayI *)phEntriesvect)->At(k); |
3a0f6479 | 368 | if(entriesn <= 0) continue; |
00a3834d | 369 | ((TArrayI *)fPHEntries[idet])->AddAt(entriesn,k); |
370 | Float_t meann = (mean*((Float_t)entries)+((TArrayF *)phMeanvect)->At(k)*((Float_t)((TArrayI *)phEntriesvect)->At(k)))/((Float_t)entriesn); | |
371 | ((TArrayF *)fPHMean[idet])->AddAt(meann,k); | |
372 | Float_t sq = ((TArrayF *)phSquaresvect)->At(k)*((Float_t)((TArrayI *)phEntriesvect)->At(k)); | |
3a0f6479 | 373 | Float_t squaren = ((square*((Float_t)entries))+sq)/((Float_t)entriesn); |
00a3834d | 374 | ((TArrayF *)fPHSquares[idet])->AddAt(squaren,k); |
3a0f6479 | 375 | //printf("test ph!\n"); |
376 | } | |
377 | } | |
378 | ||
379 | if ( prfEntriesvect != 0x0 ){ | |
380 | //Take the stuff | |
00a3834d | 381 | fPRFEntries[idet] = ((TArrayI *)GetPRFEntries(idet,kTRUE)); |
382 | fPRFMean[idet] = ((TArrayF *)GetPRFMean(idet,kTRUE)); | |
383 | fPRFSquares[idet] = ((TArrayF *)GetPRFSquares(idet,kTRUE)); | |
384 | Int_t total = fPRFEntries[idet]->GetSize(); | |
3a0f6479 | 385 | // Add |
386 | for(Int_t k = 0; k < total; k++){ | |
00a3834d | 387 | Int_t entries = ((TArrayI *)fPRFEntries[idet])->At(k); |
388 | Float_t mean = ((TArrayF *)fPRFMean[idet])->At(k); | |
389 | Float_t square = ((TArrayF *)fPRFSquares[idet])->At(k); | |
3a0f6479 | 390 | |
391 | //printf("entries0 %d\n",entries); | |
392 | //printf("mean0 %f\n",mean); | |
393 | //printf("square0 %f\n",square); | |
394 | ||
395 | //printf("entries1 %d\n",prfEntriesvect->At(k)); | |
396 | //printf("mean1 %f\n",prfMeanvect->At(k)); | |
397 | //printf("square1 %f\n",prfSquaresvect->At(k)); | |
398 | ||
55a288e5 | 399 | |
3a0f6479 | 400 | //printf("entries0 size %d\n",fPRFEntries->GetSize()); |
401 | //printf("mean0 size %d\n",fPRFMean->GetSize()); | |
402 | //printf("squares0 size %d\n",fPRFSquares->GetSize()); | |
55a288e5 | 403 | |
3a0f6479 | 404 | //printf("entries1 size %d\n",prfEntriesvect->GetSize()); |
405 | //printf("mean1 size %d\n",prfMeanvect->GetSize()); | |
406 | //printf("squares1 size %d\n",prfSquaresvect->GetSize()); | |
55a288e5 | 407 | |
55a288e5 | 408 | |
00a3834d | 409 | Int_t entriesn = entries+((TArrayI *)prfEntriesvect)->At(k); |
3a0f6479 | 410 | if(entriesn <= 0) continue; |
00a3834d | 411 | ((TArrayI *)fPRFEntries[idet])->AddAt(entriesn,k); |
412 | Float_t meann = (mean*((Float_t)entries)+((TArrayF *)prfMeanvect)->At(k)*((Float_t)((TArrayI *)prfEntriesvect)->At(k)))/((Float_t)entriesn); | |
413 | ((TArrayF *)fPRFMean[idet])->AddAt(meann,k); | |
414 | Float_t sq = ((TArrayF *)prfSquaresvect)->At(k)*((Float_t)((TArrayI *)prfEntriesvect)->At(k)); | |
3a0f6479 | 415 | Float_t squaren = ((square*((Float_t)entries))+sq)/((Float_t)entriesn); |
00a3834d | 416 | ((TArrayF *)fPRFSquares[idet])->AddAt(squaren,k); |
3a0f6479 | 417 | //printf("test prf!\n"); |
418 | } | |
419 | } | |
55a288e5 | 420 | |
3a0f6479 | 421 | if ( chEntriesvect != 0x0 ){ |
422 | //Take the stuff | |
00a3834d | 423 | fCHEntries[idet] = ((TArrayI *)GetCHEntries(idet,kTRUE)); |
424 | Int_t total = fCHEntries[idet]->GetSize(); | |
3a0f6479 | 425 | //if(idet == 180) printf("total %d\n",total); |
426 | // Add | |
427 | for(Int_t k = 0; k < total; k++){ | |
00a3834d | 428 | Int_t entries = ((TArrayI *)fCHEntries[idet])->At(k); |
429 | Int_t entriesn = entries+((TArrayI *)chEntriesvect)->At(k); | |
3a0f6479 | 430 | //if((idet == 180) && ((entries != 0) || (entriesn != 0))) printf("for k %d we have entries %d and entriesn %d\n",k,entries,entriesn); |
431 | if(entriesn <= 0) continue; | |
00a3834d | 432 | ((TArrayI *)fCHEntries[idet])->AddAt(entriesn,k); |
3a0f6479 | 433 | } |
434 | //printf("test ch!\n"); | |
435 | } | |
436 | } | |
437 | ||
438 | return kTRUE; | |
439 | } | |
55a288e5 | 440 | //_____________________________________________________________________________ |
3a0f6479 | 441 | TGraphErrors *AliTRDCalibraVector::ConvertVectorPHTGraphErrors(Int_t det, Int_t group |
442 | , const Char_t * name) | |
55a288e5 | 443 | { |
444 | // | |
3a0f6479 | 445 | // Convert the fVectorPHMean, fVectorPHSquares and fVectorPHEntries in TGraphErrors |
55a288e5 | 446 | // |
447 | ||
3a0f6479 | 448 | // Take the info |
00a3834d | 449 | fPHEntries[det] = ((TArrayI *)GetPHEntries(det,kTRUE)); |
450 | fPHMean[det] = ((TArrayF *)GetPHMean(det,kTRUE)); | |
451 | fPHSquares[det] = ((TArrayF *)GetPHSquares(det,kTRUE)); | |
55a288e5 | 452 | |
55a288e5 | 453 | |
3a0f6479 | 454 | // Init the stuff |
55a288e5 | 455 | TGraphErrors *histo; |
55a288e5 | 456 | Float_t sf = 10.0; |
457 | AliTRDCommonParam *parCom = AliTRDCommonParam::Instance(); | |
458 | if (!parCom) { | |
459 | AliInfo("Could not get CommonParam, take the default 10MHz"); | |
460 | } | |
55a288e5 | 461 | sf = parCom->GetSamplingFrequency(); |
55a288e5 | 462 | // Axis |
463 | Double_t *x; | |
464 | Double_t *y; | |
465 | Double_t *ex; | |
466 | Double_t *ey; | |
467 | Double_t step = 0.0; | |
468 | Double_t min = 0.0; | |
3a0f6479 | 469 | x = new Double_t[fTimeMax]; // Xaxis |
470 | y = new Double_t[fTimeMax]; // Sum/entries | |
471 | ex = new Double_t[fTimeMax]; // Nentries | |
472 | ey = new Double_t[fTimeMax]; // Sum of square/nentries | |
473 | step = 1.0 / sf; | |
474 | min = 0.0; | |
475 | Int_t offset = group*fTimeMax; | |
476 | ||
55a288e5 | 477 | // Fill histo |
3a0f6479 | 478 | for (Int_t k = 0; k < fTimeMax; k++) { |
55a288e5 | 479 | x[k] = min + k*step; |
480 | y[k] = 0.0; | |
481 | ex[k] = 0.0; | |
3a0f6479 | 482 | ey[k] = 0.0; |
483 | Int_t bin = offset+k; | |
55a288e5 | 484 | // Fill only if there is more than 0 something |
00a3834d | 485 | if (fPHEntries[det]->At(bin) > 0) { |
486 | ex[k] = ((TArrayI *)fPHEntries[det])->At(bin); | |
487 | y[k] = ((TArrayF *)fPHMean[det])->At(bin); | |
488 | ey[k] = ((TArrayF *)fPHSquares[det])->At(bin); | |
55a288e5 | 489 | } |
490 | } | |
491 | ||
492 | // Define the TGraphErrors | |
3a0f6479 | 493 | histo = new TGraphErrors(fTimeMax,x,y,ex,ey); |
55a288e5 | 494 | histo->SetTitle(name); |
495 | return histo; | |
496 | ||
497 | } | |
55a288e5 | 498 | //_____________________________________________________________________________ |
3a0f6479 | 499 | TGraphErrors *AliTRDCalibraVector::ConvertVectorPRFTGraphErrors(Int_t det, Int_t group |
500 | , const Char_t * name) | |
55a288e5 | 501 | { |
502 | // | |
3a0f6479 | 503 | // Convert the fVectorPRFMean, fVectorPRFSquares and fVectorPRFEntries in TGraphErrors |
55a288e5 | 504 | // |
505 | ||
3a0f6479 | 506 | // Take the info |
00a3834d | 507 | fPRFEntries[det] = ((TArrayI *)GetPRFEntries(det,kTRUE)); |
508 | fPRFMean[det] = ((TArrayF *)GetPRFMean(det,kTRUE)); | |
509 | fPRFSquares[det] = ((TArrayF *)GetPRFSquares(det,kTRUE)); | |
55a288e5 | 510 | |
55a288e5 | 511 | |
3a0f6479 | 512 | // Init the stuff |
513 | TGraphErrors *histo; | |
514 | // Axis | |
515 | Double_t *x; | |
516 | Double_t *y; | |
517 | Double_t *ex; | |
518 | Double_t *ey; | |
519 | Double_t step = 0.0; | |
520 | Double_t min = 0.0; | |
521 | x = new Double_t[fNumberBinPRF]; // Xaxis | |
522 | y = new Double_t[fNumberBinPRF]; // Sum/entries | |
523 | ex = new Double_t[fNumberBinPRF]; // Nentries | |
524 | ey = new Double_t[fNumberBinPRF]; // Sum of square/nentries | |
525 | step = (2*TMath::Abs(fPRFRange)) / fNumberBinPRF; | |
526 | min = -TMath::Abs(fPRFRange) + step / 2.0; | |
527 | Int_t offset = group*fNumberBinPRF; | |
528 | //printf("number of total: %d\n",fNumberBinPRF); | |
529 | // Fill histo | |
530 | for (Int_t k = 0; k < fNumberBinPRF; k++) { | |
531 | x[k] = min + k*step; | |
532 | y[k] = 0.0; | |
533 | ex[k] = 0.0; | |
534 | ey[k] = 0.0; | |
535 | Int_t bin = offset+k; | |
536 | // Fill only if there is more than 0 something | |
00a3834d | 537 | if (fPRFEntries[det]->At(bin) > 0) { |
538 | ex[k] = ((TArrayF *)fPRFEntries[det])->At(bin); | |
539 | y[k] = ((TArrayF *)fPRFMean[det])->At(bin); | |
540 | ey[k] = ((TArrayF *)fPRFSquares[det])->At(bin); | |
3a0f6479 | 541 | } |
542 | //printf("Number of entries %f for %d\n",ex[k],k); | |
543 | } | |
55a288e5 | 544 | |
3a0f6479 | 545 | // Define the TGraphErrors |
546 | histo = new TGraphErrors(fNumberBinPRF,x,y,ex,ey); | |
547 | histo->SetTitle(name); | |
548 | return histo; | |
549 | ||
550 | } | |
55a288e5 | 551 | //_____________________________________________________________________________ |
3a0f6479 | 552 | TH1F *AliTRDCalibraVector::ConvertVectorCHHisto(Int_t det, Int_t group |
553 | , const Char_t * name) | |
55a288e5 | 554 | { |
555 | // | |
3a0f6479 | 556 | // Convert the fVectorCHEntries in TH1F |
55a288e5 | 557 | // |
558 | ||
3a0f6479 | 559 | // Take the info |
00a3834d | 560 | fCHEntries[det] = ((TArrayI *)GetCHEntries(det,kTRUE)); |
55a288e5 | 561 | |
3a0f6479 | 562 | // Init the stuff |
563 | TH1F *histo = new TH1F(name,name,fNumberBinCharge,0,300); | |
55a288e5 | 564 | histo->Sumw2(); |
3a0f6479 | 565 | Int_t offset = group*fNumberBinCharge; |
55a288e5 | 566 | // Fill histo |
3a0f6479 | 567 | for (Int_t k = 0; k < fNumberBinCharge; k++) { |
568 | Int_t bin = offset+k; | |
00a3834d | 569 | histo->SetBinContent(k+1,((TArrayI *)fCHEntries[det])->At(bin)); |
570 | histo->SetBinError(k+1,TMath::Sqrt(TMath::Abs(((TArrayI *)fCHEntries[det])->At(bin)))); | |
55a288e5 | 571 | } |
572 | ||
573 | return histo; | |
574 | ||
3a0f6479 | 575 | } |
576 | //_____________________________________________________________________ | |
00a3834d | 577 | TArrayI* AliTRDCalibraVector::GetPHEntries(Int_t det |
0bc7827a | 578 | , Bool_t force) /*FOLD00*/ |
3a0f6479 | 579 | { |
580 | // | |
581 | // return pointer to Carge ROC Calibration | |
582 | // if force is true create a new histogram if it doesn't exist allready | |
583 | // | |
00a3834d | 584 | TArrayI**arr = &fPHEntries[0]; |
3a0f6479 | 585 | return GetEntriesPH(det, arr, force); |
55a288e5 | 586 | } |
3a0f6479 | 587 | //_____________________________________________________________________ |
00a3834d | 588 | TArrayI* AliTRDCalibraVector::GetPRFEntries(Int_t det |
0bc7827a | 589 | , Bool_t force) /*FOLD00*/ |
55a288e5 | 590 | { |
3a0f6479 | 591 | // |
592 | // return pointer to Carge ROC Calibration | |
593 | // if force is true create a new histogram if it doesn't exist allready | |
594 | // | |
00a3834d | 595 | TArrayI**arr = &fPRFEntries[0]; |
3a0f6479 | 596 | return GetEntriesPRF(det, arr, force); |
55a288e5 | 597 | } |
3a0f6479 | 598 | //_____________________________________________________________________ |
00a3834d | 599 | TArrayI* AliTRDCalibraVector::GetCHEntries(Int_t det |
0bc7827a | 600 | , Bool_t force) /*FOLD00*/ |
55a288e5 | 601 | { |
3a0f6479 | 602 | // |
603 | // return pointer to Carge ROC Calibration | |
604 | // if force is true create a new histogram if it doesn't exist allready | |
605 | // | |
00a3834d | 606 | TArrayI**arr = &fCHEntries[0]; |
3a0f6479 | 607 | return GetEntriesCH(det, arr, force); |
55a288e5 | 608 | } |
3a0f6479 | 609 | //_____________________________________________________________________ |
00a3834d | 610 | TArrayF* AliTRDCalibraVector::GetPHMean(Int_t det |
0bc7827a | 611 | , Bool_t force) /*FOLD00*/ |
55a288e5 | 612 | { |
3a0f6479 | 613 | // |
614 | // return pointer to Carge ROC Calibration | |
615 | // if force is true create a new histogram if it doesn't exist allready | |
616 | // | |
00a3834d | 617 | TArrayF**arr = &fPHMean[0]; |
3a0f6479 | 618 | return GetMeanSquaresPH(det, arr, force); |
55a288e5 | 619 | } |
3a0f6479 | 620 | //_____________________________________________________________________ |
00a3834d | 621 | TArrayF* AliTRDCalibraVector::GetPHSquares(Int_t det |
0bc7827a | 622 | , Bool_t force) /*FOLD00*/ |
55a288e5 | 623 | { |
3a0f6479 | 624 | // |
625 | // return pointer to Carge ROC Calibration | |
626 | // if force is true create a new histogram if it doesn't exist allready | |
627 | // | |
00a3834d | 628 | TArrayF**arr = &fPHSquares[0]; |
3a0f6479 | 629 | return GetMeanSquaresPH(det, arr, force); |
55a288e5 | 630 | } |
3a0f6479 | 631 | //_____________________________________________________________________ |
00a3834d | 632 | TArrayF* AliTRDCalibraVector::GetPRFMean(Int_t det |
0bc7827a | 633 | , Bool_t force) /*FOLD00*/ |
55a288e5 | 634 | { |
3a0f6479 | 635 | // |
636 | // return pointer to Carge ROC Calibration | |
637 | // if force is true create a new histogram if it doesn't exist allready | |
638 | // | |
00a3834d | 639 | TArrayF**arr = &fPRFMean[0]; |
3a0f6479 | 640 | return GetMeanSquaresPRF(det, arr, force); |
641 | } | |
642 | //_____________________________________________________________________ | |
00a3834d | 643 | TArrayF* AliTRDCalibraVector::GetPRFSquares(Int_t det |
0bc7827a | 644 | , Bool_t force) /*FOLD00*/ |
55a288e5 | 645 | { |
3a0f6479 | 646 | // |
647 | // return pointer to Carge ROC Calibration | |
648 | // if force is true create a new histogram if it doesn't exist allready | |
649 | // | |
00a3834d | 650 | TArrayF**arr = &fPRFSquares[0]; |
3a0f6479 | 651 | return GetMeanSquaresPRF(det, arr, force); |
652 | } | |
653 | //_____________________________________________________________________ | |
00a3834d | 654 | TArrayI* AliTRDCalibraVector::GetEntriesCH(Int_t det |
655 | , TArrayI** arr | |
0bc7827a | 656 | , Bool_t force) /*FOLD00*/ |
3a0f6479 | 657 | { |
658 | // | |
00a3834d | 659 | // return pointer to TArrayI Entries |
660 | // if force is true create a new TArrayI if it doesn't exist allready | |
3a0f6479 | 661 | // |
00a3834d | 662 | if ( !force || (((TArrayI *)arr[det])->GetSize()>0)) |
663 | return (TArrayI*)arr[det]; | |
664 | ||
665 | // if we are forced and TArrayI doesn't yes exist create it | |
666 | Int_t stack = GetStack(det); | |
667 | Int_t ngroup = 0; | |
668 | if(stack == 2) ngroup = fDetCha2[0]*fNumberBinCharge; | |
669 | else ngroup = fDetCha0[0]*fNumberBinCharge; | |
670 | // init | |
671 | ((TArrayI *)arr[det])->Set(ngroup); | |
672 | for(Int_t k = 0; k < ngroup; k++){ | |
673 | ((TArrayI *)arr[det])->AddAt(0,k); | |
674 | } | |
675 | return (TArrayI*)arr[det]; | |
3a0f6479 | 676 | } |
677 | //_____________________________________________________________________ | |
00a3834d | 678 | TArrayI* AliTRDCalibraVector::GetEntriesPRF(Int_t det |
679 | , TArrayI** arr | |
0bc7827a | 680 | , Bool_t force) /*FOLD00*/ |
3a0f6479 | 681 | { |
682 | // | |
00a3834d | 683 | // return pointer to TArrayI Entries |
684 | // if force is true create a new TArrayI if it doesn't exist allready | |
3a0f6479 | 685 | // |
00a3834d | 686 | if ( !force || (((TArrayI *)arr[det])->GetSize()>0)) |
687 | return (TArrayI*)arr[det]; | |
688 | ||
689 | // if we are forced and TArrayI doesn't yes exist create it | |
690 | Int_t stack = GetStack(det); | |
691 | Int_t ngroup = 0; | |
692 | if(stack == 2) ngroup = fDetCha2[2]*fNumberBinPRF; | |
693 | else ngroup = fDetCha0[2]*fNumberBinPRF; | |
694 | // init | |
695 | ((TArrayI *)arr[det])->Set(ngroup); | |
696 | for(Int_t k = 0; k < ngroup; k++){ | |
697 | ((TArrayI *)arr[det])->AddAt(0,k); | |
698 | } | |
699 | return (TArrayI*)arr[det]; | |
55a288e5 | 700 | |
3a0f6479 | 701 | } |
702 | //_____________________________________________________________________ | |
00a3834d | 703 | TArrayI* AliTRDCalibraVector::GetEntriesPH(Int_t det |
704 | , TArrayI** arr | |
0bc7827a | 705 | , Bool_t force) /*FOLD00*/ |
3a0f6479 | 706 | { |
707 | // | |
00a3834d | 708 | // return pointer to TArrayI Entries |
709 | // if force is true create a new TArrayI if it doesn't exist allready | |
3a0f6479 | 710 | // |
00a3834d | 711 | if ( !force || (((TArrayI *)arr[det])->GetSize()>0)) |
712 | return (TArrayI*)arr[det]; | |
3a0f6479 | 713 | |
00a3834d | 714 | // if we are forced and TArrayI doesn't yes exist create it |
053767a4 | 715 | Int_t stack = GetStack(det); |
716 | Int_t ngroup = 0; | |
717 | if(stack == 2) ngroup = fDetCha2[1]*fTimeMax; | |
3a0f6479 | 718 | else ngroup = fDetCha0[1]*fTimeMax; |
719 | // init | |
00a3834d | 720 | ((TArrayI *)arr[det])->Set(ngroup); |
3a0f6479 | 721 | for(Int_t k = 0; k < ngroup; k++){ |
00a3834d | 722 | ((TArrayI *)arr[det])->AddAt(0,k); |
55a288e5 | 723 | } |
00a3834d | 724 | return (TArrayI*)arr[det]; |
55a288e5 | 725 | |
3a0f6479 | 726 | } |
727 | //_____________________________________________________________________ | |
00a3834d | 728 | TArrayF* AliTRDCalibraVector::GetMeanSquaresPH(Int_t det |
729 | , TArrayF** arr | |
0bc7827a | 730 | , Bool_t force) /*FOLD00*/ |
3a0f6479 | 731 | { |
732 | // | |
00a3834d | 733 | // return pointer to TArrayF Mean or Squares |
734 | // if force is true create a new TArrayF if it doesn't exist allready | |
3a0f6479 | 735 | // |
00a3834d | 736 | if ( !force || (((TArrayF *)arr[det])->GetSize()>0)) |
737 | return (TArrayF*)arr[det]; | |
3a0f6479 | 738 | |
00a3834d | 739 | // if we are forced and TArrayF doesn't yes exist create it |
053767a4 | 740 | Int_t stack = GetStack(det); |
741 | Int_t ngroup = 0; | |
742 | if(stack == 2) ngroup = fDetCha2[1]*fTimeMax; | |
3a0f6479 | 743 | else ngroup = fDetCha0[1]*fTimeMax; |
744 | // init | |
00a3834d | 745 | ((TArrayF *)arr[det])->Set(ngroup); |
3a0f6479 | 746 | for(Int_t k = 0; k < ngroup; k++){ |
00a3834d | 747 | ((TArrayF *)arr[det])->AddAt(0.0,k); |
55a288e5 | 748 | } |
00a3834d | 749 | return ((TArrayF *)arr[det]); |
3a0f6479 | 750 | } |
751 | //_____________________________________________________________________ | |
00a3834d | 752 | TArrayF* AliTRDCalibraVector::GetMeanSquaresPRF(Int_t det |
753 | , TArrayF** arr | |
0bc7827a | 754 | , Bool_t force) /*FOLD00*/ |
3a0f6479 | 755 | { |
756 | // | |
00a3834d | 757 | // return pointer to TArrayF Mean or Squares |
758 | // if force is true create a new TArrayF if it doesn't exist allready | |
3a0f6479 | 759 | // |
00a3834d | 760 | if ( !force || (((TArrayF *)arr[det])->GetSize()>0)) |
761 | return arr[det]; | |
762 | ||
763 | // if we are forced and TArrayF doesn't yes exist create it | |
764 | Int_t stack = GetStack(det); | |
765 | Int_t ngroup = 0; | |
766 | if(stack == 2) ngroup = fDetCha2[2]*fNumberBinPRF; | |
767 | else ngroup = fDetCha0[2]*fNumberBinPRF; | |
768 | // init | |
769 | ((TArrayF *)arr[det])->Set(ngroup); | |
770 | for(Int_t k = 0; k < ngroup; k++){ | |
771 | ((TArrayF *)arr[det])->AddAt(0.0,k); | |
772 | } | |
773 | return ((TArrayF *)arr[det]); | |
55a288e5 | 774 | } |
55a288e5 | 775 | //_____________________________________________________________________________ |
053767a4 | 776 | Int_t AliTRDCalibraVector::GetStack(Int_t d) const |
55a288e5 | 777 | { |
778 | // | |
053767a4 | 779 | // Reconstruct the stack number from the detector number |
55a288e5 | 780 | // |
781 | ||
3a0f6479 | 782 | return ((Int_t) (d % 30) / 6); |
55a288e5 | 783 | |
784 | } | |
3a0f6479 | 785 |