]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - TRD/AliTRDCalibraVector.cxx
clean up the log summary creation
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraVector.cxx
... / ...
CommitLineData
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
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////////////////////////////////////////////////////////////////////////////
28
29#include <TGraphErrors.h>
30#include <TH1F.h>
31#include <TObjArray.h>
32#include <TObject.h>
33#include <TMath.h>
34#include <TDirectory.h>
35#include <TROOT.h>
36#include <TFile.h>
37#include <TString.h>
38
39#include "AliLog.h"
40
41#include "AliTRDCalibraVector.h"
42#include "AliTRDCommonParam.h"
43#include "AliTRDCalibraMode.h"
44#include "AliTRDPhInfo.h"
45#include "AliTRDEntriesInfo.h"
46#include "AliTRDPrfInfo.h"
47#include "AliTRDgeometry.h"
48
49ClassImp(AliTRDCalibraVector)
50
51//______________________________________________________________________________________
52AliTRDCalibraVector::AliTRDCalibraVector()
53 :TObject()
54 ,fModeCH(0)
55 ,fModePH(0)
56 ,fModePRF(0)
57 ,fNbGroupPRF(0)
58 ,fDetectorPH(-1)
59 ,fDetectorCH(-1)
60 ,fDetectorPRF(-1)
61 ,fStopFillCH(kFALSE)
62 ,fHisto(0x0)
63 ,fGraph(0x0)
64 ,fCalVector(0x0)
65 ,fNumberBinCharge(0)
66 ,fNumberBinPRF(0)
67 ,fTimeMax(0)
68 ,fPRFRange(1.5)
69{
70 //
71 // Default constructor
72 //
73
74 for (Int_t idet = 0; idet < 540; idet++){
75
76 fPHEntries[idet]= 0x0;
77 fPHMean[idet]= 0x0;
78 fPHSquares[idet]= 0x0;
79
80 fPRFEntries[idet]= 0x0;
81 fPRFMean[idet]= 0x0;
82 fPRFSquares[idet]= 0x0;
83
84
85 fCHEntries[idet]= 0x0;
86
87 }
88
89 for(Int_t k = 0; k < 3; k++){
90 fDetCha0[k] = 0;
91 fDetCha2[k] = 0;
92 }
93
94}
95//______________________________________________________________________________________
96AliTRDCalibraVector::AliTRDCalibraVector(const AliTRDCalibraVector &c)
97 :TObject(c)
98 ,fModeCH(c.fModeCH)
99 ,fModePH(c.fModePH)
100 ,fModePRF(c.fModePRF)
101 ,fNbGroupPRF(c.fNbGroupPRF)
102 ,fDetectorPH(-1)
103 ,fDetectorCH(-1)
104 ,fDetectorPRF(-1)
105 ,fStopFillCH(kFALSE)
106 ,fHisto(0x0)
107 ,fGraph(0x0)
108 ,fCalVector(0x0)
109 ,fNumberBinCharge(c.fNumberBinCharge)
110 ,fNumberBinPRF(c.fNumberBinPRF)
111 ,fTimeMax(c.fTimeMax)
112 ,fPRFRange(c.fPRFRange)
113{
114 //
115 // Copy constructor
116 //
117
118 for(Int_t k = 0; k < 3; k++){
119 fDetCha0[k] = c.fDetCha0[k];
120 fDetCha2[k] = c.fDetCha2[k];
121 }
122
123 for (Int_t idet = 0; idet < 540; idet++){
124
125 const AliTRDEntriesInfo *phEntries = (AliTRDEntriesInfo*)c.fPHEntries[idet];
126 const AliTRDPhInfo *phMean = (AliTRDPhInfo *)c.fPHMean[idet];
127 const AliTRDPhInfo *phSquares = (AliTRDPhInfo *)c.fPHSquares[idet];
128
129 const AliTRDEntriesInfo *prfEntries = (AliTRDEntriesInfo*)c.fPRFEntries[idet];
130 const AliTRDPrfInfo *prfMean = (AliTRDPrfInfo *)c.fPRFMean[idet];
131 const AliTRDPrfInfo *prfSquares = (AliTRDPrfInfo *)c.fPRFSquares[idet];
132
133 const AliTRDEntriesInfo *chEntries = (AliTRDEntriesInfo*)c.fCHEntries[idet];
134
135 if ( chEntries != 0x0 ) fCHEntries[idet] = new AliTRDEntriesInfo(*chEntries);
136
137 if ( phEntries != 0x0 ) {
138 fPHMean[idet] = new AliTRDPhInfo(*phMean);
139 fPHSquares[idet] = new AliTRDPhInfo(*phSquares);
140 fPHEntries[idet] = new AliTRDEntriesInfo(*phEntries);
141 }
142
143 if ( prfEntries != 0x0 ) {
144 fPRFEntries[idet] = new AliTRDEntriesInfo(*prfEntries);
145 fPRFMean[idet] = new AliTRDPrfInfo(*prfMean);
146 fPRFSquares[idet] = new AliTRDPrfInfo(*prfSquares);
147 }
148
149 }
150
151}
152//_____________________________________________________________________
153AliTRDCalibraVector& AliTRDCalibraVector::operator = (const AliTRDCalibraVector &source)
154{
155 //
156 // assignment operator
157 //
158 if (&source == this) return *this;
159 new (this) AliTRDCalibraVector(source);
160
161 return *this;
162}
163//____________________________________________________________________________________
164AliTRDCalibraVector::~AliTRDCalibraVector()
165{
166 //
167 // AliTRDCalibraVector destructor
168 //
169
170 for (Int_t i=0; i<540; i++) {
171 delete fPHEntries[i];
172 delete fPHMean[i];
173 delete fPHSquares[i];
174 delete fPRFEntries[i];
175 delete fPRFMean[i];
176 delete fPRFSquares[i];
177 delete fCHEntries[i];
178 }
179
180 if(fHisto) delete fHisto;
181 if(fGraph) delete fGraph;
182 if(fCalVector) delete fCalVector;
183
184}
185//_____________________________________________________________________________
186Long64_t AliTRDCalibraVector::Merge(const TCollection* list)
187{
188 // Merge list of objects (needed by PROOF)
189
190 if (!list)
191 return 0;
192
193 if (list->IsEmpty())
194 return 1;
195
196 TIterator* iter = list->MakeIterator();
197 TObject* obj = 0;
198
199 // collection of generated histograms
200 Int_t count=0;
201 while((obj = iter->Next()) != 0)
202 {
203 AliTRDCalibraVector* entry = dynamic_cast<AliTRDCalibraVector*>(obj);
204 if (entry == 0) continue;
205
206 if(this->Add(entry)) count++;
207
208 }
209
210 return count;
211}
212//_____________________________________________________________________________
213void AliTRDCalibraVector::TestInit(Int_t i, Int_t detmax)
214{
215 //
216 // Init to see the size
217 //
218
219 for(Int_t det = 0; det < detmax; det++){
220
221 if(i==2) {
222
223 fPRFEntries[det] = ((AliTRDEntriesInfo *)GetPRFEntries(det,kTRUE));
224 fPRFMean[det] = ((AliTRDPrfInfo *)GetPRFMean(det,kTRUE));
225 fPRFSquares[det] = ((AliTRDPrfInfo *)GetPRFSquares(det,kTRUE));
226
227 }
228
229 if(i==1) {
230
231 fPHEntries[det] = ((AliTRDEntriesInfo *)GetPHEntries(det,kTRUE));
232 fPHMean[det] = ((AliTRDPhInfo *)GetPHMean(det,kTRUE));
233 fPHSquares[det] = ((AliTRDPhInfo *)GetPHSquares(det,kTRUE));
234
235 }
236
237 if(i==0) fCHEntries[det] = ((AliTRDEntriesInfo *)GetCHEntries(det,kTRUE));
238
239 }
240
241}
242//_____________________________________________________________________________
243Int_t AliTRDCalibraVector::SearchBin(Float_t value, Int_t i) const
244{
245 //
246 // Search the bin
247 //
248
249 Int_t reponse = 0;
250 Float_t fbinmin = 0;
251 Float_t fbinmax = value;
252 Int_t fNumberOfBin = -1;
253
254 switch(i)
255 {
256 case 0:
257 fbinmax = 300.0;
258 fbinmin = 0.0;
259 fNumberOfBin = fNumberBinCharge;
260 break;
261
262 case 2:
263 fbinmax = TMath::Abs(fPRFRange);
264 fbinmin = -TMath::Abs(fPRFRange);
265 fNumberOfBin = fNumberBinPRF;
266 break;
267
268 default:
269 return -1;
270 }
271
272 // Return -1 if out
273 if ((value >= fbinmax) ||
274 (value < fbinmin)) {
275 return -1;
276 }
277 else {
278 reponse = (Int_t) ((fNumberOfBin*(value-fbinmin)) / (fbinmax-fbinmin));
279 }
280
281 return reponse;
282
283}
284//_____________________________________________________________________________
285Bool_t AliTRDCalibraVector::UpdateVectorCH(Int_t det, Int_t group, Float_t value)
286{
287 //
288 // Fill the vector CH
289 //
290
291 // Search bin
292 Int_t bin = SearchBin(value,0);
293 // Out
294 if (bin == -1) {
295 return kFALSE;
296 }
297
298
299
300 if(fDetectorCH != det){
301 fCHEntries[det] = ((AliTRDEntriesInfo *)GetCHEntries(det,kTRUE));
302 }
303
304 Int_t entries = ((AliTRDEntriesInfo *)fCHEntries[det])->At(group*fNumberBinCharge+bin);
305
306 Int_t entriesn = entries+1;
307
308 if(entriesn > 65535) {
309 fStopFillCH = kTRUE;
310 return kTRUE;
311 }
312
313 ((AliTRDEntriesInfo *)fCHEntries[det])->AddAt(entriesn,group*fNumberBinCharge+bin);
314
315 fDetectorCH = det;
316
317
318 return kTRUE;
319
320}
321//_____________________________________________________________________________
322Bool_t AliTRDCalibraVector::UpdateVectorPRF(Int_t det, Int_t group, Float_t x, Float_t y)
323{
324 //
325 // Fill the vector PRF
326 //
327
328 // Search bin
329 Int_t bin = SearchBin(x,2);
330 // Out
331 if (bin == -1) {
332 return kFALSE;
333 }
334
335
336 if(fDetectorPRF != det){
337 fPRFEntries[det] = ((AliTRDEntriesInfo *)GetPRFEntries(det,kTRUE));
338 fPRFMean[det] = ((AliTRDPrfInfo *)GetPRFMean(det,kTRUE));
339 fPRFSquares[det] = ((AliTRDPrfInfo *)GetPRFSquares(det,kTRUE));
340 }
341
342 Int_t entries = ((AliTRDEntriesInfo *)fPRFEntries[det])->At((Int_t)group*fNumberBinPRF+bin);
343 Float_t mean = ((AliTRDPrfInfo *)fPRFMean[det])->At((Int_t)group*fNumberBinPRF+bin);
344 Float_t square = ((AliTRDPrfInfo *)fPRFSquares[det])->At((Int_t)group*fNumberBinPRF+bin);
345
346 Int_t entriesn = entries+1;
347
348 if(entriesn > 65535) return kTRUE;
349
350 ((AliTRDEntriesInfo *)fPRFEntries[det])->AddAt(entriesn,(Int_t)group*fNumberBinPRF+bin);
351 Float_t meann = (mean*((Float_t)entries)+y)/((Float_t)entriesn);
352 ((AliTRDPrfInfo *)fPRFMean[det])->AddAt(meann,(Int_t)group*fNumberBinPRF+bin);
353 Float_t squaren = ((square*((Float_t)entries))+(y*y))/((Float_t)entriesn);
354 ((AliTRDPrfInfo *)fPRFSquares[det])->AddAt(squaren,(Int_t)group*fNumberBinPRF+bin);
355
356
357 fDetectorPRF = det;
358
359 return kTRUE;
360
361}
362//_____________________________________________________________________________
363Bool_t AliTRDCalibraVector::UpdateVectorPH(Int_t det, Int_t group, Int_t time, Float_t value)
364{
365 //
366 // Fill the vector PH
367 //
368
369 // Search bin
370 Int_t bin = time;
371 // Out
372 if ((bin < 0) ||
373 (bin >= fTimeMax)) {
374 return kFALSE;
375 }
376
377
378 if(fDetectorPH != det){
379 fPHEntries[det] = ((AliTRDEntriesInfo *)GetPHEntries(det,kTRUE));
380 fPHMean[det] = ((AliTRDPhInfo *)GetPHMean(det,kTRUE));
381 fPHSquares[det] = ((AliTRDPhInfo *)GetPHSquares(det,kTRUE));
382 }
383
384 Int_t entries = ((AliTRDEntriesInfo *)fPHEntries[det])->At(group*fTimeMax+bin);
385 Float_t mean = ((AliTRDPhInfo *)fPHMean[det])->At(group*fTimeMax+bin);
386 Float_t square = ((AliTRDPhInfo *)fPHSquares[det])->AtS(group*fTimeMax+bin);
387
388 Int_t entriesn = entries+1;
389 Float_t meann = (mean*((Float_t)entries)+value)/((Float_t)entriesn);
390 Float_t squaren = ((square*((Float_t)entries))+(value*value))/((Float_t)entriesn);
391
392 if(entriesn > 65535) return kTRUE;
393 //printf("meann %f, squaren %f\n",meann,squaren);
394 if((meann > 3000.0) || (meann < 0.0) || (squaren > (3000.0*3000.0)) || (squaren < 0.0)) return kFALSE;
395
396 ((AliTRDEntriesInfo *)fPHEntries[det])->AddAt(entriesn,group*fTimeMax+bin);
397 ((AliTRDPhInfo *)fPHMean[det])->AddAt(meann,group*fTimeMax+bin);
398 ((AliTRDPhInfo *)fPHSquares[det])->AddAtS(squaren,group*fTimeMax+bin);
399
400 fDetectorPH = det;
401
402 return kTRUE;
403
404}
405//_____________________________________________________________________________
406Bool_t AliTRDCalibraVector::FillVectorCH(Int_t det, Int_t group, Int_t bin, Int_t entries)
407{
408 //
409 // Fill the vector CH
410 //
411
412 if(entries > 65535) return kFALSE;
413
414 if(fDetectorCH != det){
415 fCHEntries[det] = ((AliTRDEntriesInfo *)GetCHEntries(det,kTRUE));
416 }
417
418 ((AliTRDEntriesInfo *)fCHEntries[det])->AddAt(entries,group*fNumberBinCharge+bin);
419
420 fDetectorCH = det;
421
422
423 return kTRUE;
424
425}
426//_____________________________________________________________________________
427Bool_t AliTRDCalibraVector::FillVectorPRF(Int_t det, Int_t group, Int_t bin, Int_t entries, Float_t mean, Float_t square)
428{
429 //
430 // Fill the vector PRF
431 //
432
433 if((entries > 65535) || (mean > 1.0) || (mean < 0.0) || (square > 1.0) || (square < 0.0)) return kFALSE;
434
435 if(fDetectorPRF != det){
436 fPRFEntries[det] = ((AliTRDEntriesInfo *)GetPRFEntries(det,kTRUE));
437 fPRFMean[det] = ((AliTRDPrfInfo *)GetPRFMean(det,kTRUE));
438 fPRFSquares[det] = ((AliTRDPrfInfo *)GetPRFSquares(det,kTRUE));
439 }
440
441 ((AliTRDEntriesInfo *)fPRFEntries[det])->AddAt(entries,(Int_t)group*fNumberBinPRF+bin);
442 ((AliTRDPrfInfo *)fPRFMean[det])->AddAt(mean,(Int_t)group*fNumberBinPRF+bin);
443 ((AliTRDPrfInfo *)fPRFSquares[det])->AddAt(square,(Int_t)group*fNumberBinPRF+bin);
444
445
446 fDetectorPRF = det;
447
448 return kTRUE;
449
450}
451//_____________________________________________________________________________
452Bool_t AliTRDCalibraVector::FillVectorPH(Int_t det, Int_t group, Int_t bin, Int_t entries, Float_t mean, Float_t square)
453{
454 //
455 // Fill the vector PH
456 //
457
458 if((entries > 65535) || (mean > 3000.0) || (mean < 0.0) || (square > (3000.0*3000.0)) || (square < 0.0)) return kFALSE;
459
460
461 if(fDetectorPH != det){
462 fPHEntries[det] = ((AliTRDEntriesInfo *)GetPHEntries(det,kTRUE));
463 fPHMean[det] = ((AliTRDPhInfo *)GetPHMean(det,kTRUE));
464 fPHSquares[det] = ((AliTRDPhInfo *)GetPHSquares(det,kTRUE));
465 }
466
467 ((AliTRDEntriesInfo *)fPHEntries[det])->AddAt(entries,group*fTimeMax+bin);
468 ((AliTRDPhInfo *)fPHMean[det])->AddAt(mean,group*fTimeMax+bin);
469 ((AliTRDPhInfo *)fPHSquares[det])->AddAtS(square,group*fTimeMax+bin);
470
471 fDetectorPH = det;
472
473 return kTRUE;
474
475}
476//__________________________________________________________________________________
477Bool_t AliTRDCalibraVector::Add(AliTRDCalibraVector *calvect)
478{
479 //
480 // Add a other AliTRCalibraVector to this one
481 //
482
483 Bool_t result = kTRUE;
484
485 // Check compatibility
486 if(fNumberBinCharge != calvect->GetNumberBinCharge()) return kFALSE;
487 if(fNumberBinPRF != calvect->GetNumberBinPRF()) return kFALSE;
488 if(fPRFRange != calvect->GetPRFRange()) return kFALSE;
489 if(fTimeMax != calvect->GetTimeMax()) return kFALSE;
490 for(Int_t k = 0; k < 3; k++){
491 if(fDetCha0[k] != calvect->GetDetCha0(k)) return kFALSE;
492 if(fDetCha2[k] != calvect->GetDetCha2(k)) return kFALSE;
493 }
494
495 //printf("All ok for variables before adding!\n");
496
497 // Add
498 for (Int_t idet = 0; idet < 540; idet++){
499
500 //printf("Detector %d\n",idet);
501
502 const AliTRDEntriesInfo *phEntriesvect = (AliTRDEntriesInfo *) calvect->GetPHEntries(idet);
503 const AliTRDPhInfo *phMeanvect = (AliTRDPhInfo *) calvect->GetPHMean(idet);
504 const AliTRDPhInfo *phSquaresvect = (AliTRDPhInfo *) calvect->GetPHSquares(idet);
505
506 const AliTRDEntriesInfo *prfEntriesvect = (AliTRDEntriesInfo *) calvect->GetPRFEntries(idet);
507 const AliTRDPrfInfo *prfMeanvect = (AliTRDPrfInfo *) calvect->GetPRFMean(idet);
508 const AliTRDPrfInfo *prfSquaresvect = (AliTRDPrfInfo *) calvect->GetPRFSquares(idet);
509
510 const AliTRDEntriesInfo *chEntriesvect = (AliTRDEntriesInfo *) calvect->GetCHEntries(idet);
511
512 if ( phEntriesvect != 0x0 ){
513 //Take the stuff
514 fPHEntries[idet] = ((AliTRDEntriesInfo *)GetPHEntries(idet,kTRUE));
515 fPHMean[idet] = ((AliTRDPhInfo *)GetPHMean(idet,kTRUE));
516 fPHSquares[idet] = ((AliTRDPhInfo *)GetPHSquares(idet,kTRUE));
517
518 Int_t total = fPHEntries[idet]->GetSize();
519 //printf("Total size PH %d\n",total);
520 // Add
521 for(Int_t k = 0; k < total; k++){
522 Int_t entriesv = ((AliTRDEntriesInfo *)phEntriesvect)->At(k);
523 Float_t meanv = ((AliTRDPhInfo *)phMeanvect)->At(k);
524 Float_t squarev = ((AliTRDPhInfo *)phSquaresvect)->AtS(k);
525
526 Int_t entries = ((AliTRDEntriesInfo *)fPHEntries[idet])->At(k);
527 Float_t mean = ((AliTRDPhInfo *)fPHMean[idet])->At(k);
528 Float_t square = ((AliTRDPhInfo *)fPHSquares[idet])->AtS(k);
529
530 Int_t entriesn = entries+entriesv;
531 Float_t meann = (mean*((Float_t)entries)+meanv*((Float_t)entriesv))/((Float_t)entriesn);
532 Float_t squaren = ((square*((Float_t)entries))+(squarev*((Float_t)entriesv)))/((Float_t)entriesn);
533
534 if((entriesn > 0) && (entriesn <= 65535) && (meann >= 0) && (meann < 3000.0) && (squaren >= 0.0) && (squaren < (3000.0*3000.0))) {
535
536 ((AliTRDEntriesInfo *)fPHEntries[idet])->AddAt(entriesn,k);
537 ((AliTRDPhInfo *)fPHMean[idet])->AddAt(meann,k);
538 ((AliTRDPhInfo *)fPHSquares[idet])->AddAtS(squaren,k);
539
540 }
541 }
542 }
543
544 if ( prfEntriesvect != 0x0 ){
545 //Take the stuff
546 fPRFEntries[idet] = ((AliTRDEntriesInfo *)GetPRFEntries(idet,kTRUE));
547 fPRFMean[idet] = ((AliTRDPrfInfo *)GetPRFMean(idet,kTRUE));
548 fPRFSquares[idet] = ((AliTRDPrfInfo *)GetPRFSquares(idet,kTRUE));
549
550 Int_t total = fPRFEntries[idet]->GetSize();
551 //Int_t total0 = fPRFMean[idet]->GetSize();
552 //Int_t total1 = fPRFSquares[idet]->GetSize();
553 //printf("Total size PRF %d\n",total);
554 //printf("Total0 size PRF %d\n",total0);
555 //printf("Total1 size PRF %d\n",total1);
556 // Add
557 for(Int_t k = 0; k < total; k++){
558
559
560 Int_t entries = ((AliTRDEntriesInfo *)fPRFEntries[idet])->At(k);
561 Float_t mean = ((AliTRDPrfInfo *)fPRFMean[idet])->At(k);
562 Float_t square = ((AliTRDPrfInfo *)fPRFSquares[idet])->At(k);
563
564 Int_t entriesv = ((AliTRDEntriesInfo *)prfEntriesvect)->At(k);
565 Float_t meanv = ((AliTRDPrfInfo *)prfMeanvect)->At(k);
566 Float_t squarev = ((AliTRDPrfInfo *)prfSquaresvect)->At(k);
567
568 Int_t entriesn = entries + entriesv;
569
570 if((entriesn > 0) && (entriesn <= 65535)) {
571
572 ((AliTRDEntriesInfo *)fPRFEntries[idet])->AddAt(entriesn,k);
573
574 Float_t meann = (mean*((Float_t)entries)+meanv*((Float_t)entriesv))/((Float_t)entriesn);
575 //printf("test0\n");
576 ((AliTRDPrfInfo *)fPRFMean[idet])->AddAt(meann,k);
577 //printf("test1\n");
578
579 Float_t squaren = ((square*((Float_t)entries))+(squarev*((Float_t)entriesv)))/((Float_t)entriesn);
580 //printf("test2\n");
581 ((AliTRDPrfInfo *)fPRFSquares[idet])->AddAt(squaren,k);
582 //printf("test3\n");
583
584 }
585 }
586 }
587
588 if ( chEntriesvect != 0x0 ){
589 //Take the stuff
590 fCHEntries[idet] = ((AliTRDEntriesInfo *)GetCHEntries(idet,kTRUE));
591 //printf("TestAdd\n");
592 fStopFillCH = ((AliTRDEntriesInfo *)fCHEntries[idet])->TestAdd((AliTRDEntriesInfo *)chEntriesvect);
593 //
594 if(!fStopFillCH) {
595 fStopFillCH = kTRUE;
596 result = kFALSE;
597 }
598 else {
599
600 ((AliTRDEntriesInfo *)fCHEntries[idet])->Add(chEntriesvect);
601 //printf("Add\n");
602 }
603 }
604 }
605
606 return result;
607}
608//_____________________________________________________________________________________________________________________
609AliTRDCalibraVector *AliTRDCalibraVector::AddStatsPerDetectorCH()
610{
611 //
612 // Create a AliTRDCalibraVector detector wise
613 //
614
615 // Use a AliTRDCalibraMode to navigate in the calibration groups
616 AliTRDCalibraMode calibMode = AliTRDCalibraMode();
617 calibMode.SetNz(0,GetNz(0));
618 calibMode.SetNrphi(0,GetNrphi(0));
619 if(((calibMode.GetNz(0) == 100) && (calibMode.GetNrphi(0) == 100)) || ((calibMode.GetNz(0) == 10) && (calibMode.GetNrphi(0) == 10))) return 0x0;
620
621 Int_t nybins = 6*4*18*fDetCha0[0]+6*18*fDetCha2[0];
622 Int_t nxbins = fNumberBinCharge;
623
624 // Check
625 Int_t perChamber2 = 0;
626 Int_t perChamber0 = 0;
627 calibMode.ModePadCalibration(2,0);
628 calibMode.ModePadFragmentation(0,2,0,0);
629 calibMode.SetDetChamb2(0);
630 perChamber2 = (Int_t) calibMode.GetDetChamb2(0);
631 calibMode.ModePadCalibration(0,0);
632 calibMode.ModePadFragmentation(0,0,0,0);
633 calibMode.SetDetChamb0(0);
634 perChamber0 = (Int_t) calibMode.GetDetChamb0(0);
635 if(nybins != (6*18*perChamber2+6*4*18*perChamber0)) return 0x0;
636
637 // Create calvector
638 if(!fCalVector) fCalVector = new AliTRDCalibraVector();
639 else{
640 fCalVector->~AliTRDCalibraVector();
641 new(fCalVector) AliTRDCalibraVector();
642 }
643 fCalVector->SetNumberBinCharge(nxbins);
644 fCalVector->SetDetCha0(0,1);
645 fCalVector->SetDetCha2(0,1);
646 fCalVector->SetNzNrphi(0,0,0);
647
648
649 for(Int_t det = 0; det < 540; det++){
650
651 // Take
652 AliTRDEntriesInfo *entriesch = (AliTRDEntriesInfo *)GetCHEntries(det,kFALSE);
653 if(!entriesch) continue;
654
655 // Number of groups
656 Int_t numberofgroup = 0;
657 if(AliTRDgeometry::GetStack(det) == 2) numberofgroup = perChamber2;
658 else numberofgroup = perChamber0;
659
660 // Check if one can merge calibration groups for this chamber
661 // entries is the number of entries in each bin after adding the different the calibration group in the detector
662 fStopFillCH = kFALSE;
663 Int_t firstnumberofgroup = -1;
664 Int_t entries[500];
665 for(Int_t k = 0; k < nxbins; k++){
666 entries[k] = 0;
667 }
668 // Loop over group in the detector
669 for(Int_t k = 0; k < numberofgroup; k++){
670 // Loop over bins
671 for(Int_t nx = 0; nx < nxbins; nx++) {
672 Int_t binnumber = k*nxbins+nx;
673 entries[nx] += entriesch->At(binnumber);
674 // as soon as one bin is over threshold stop
675 if(!fStopFillCH) {
676 if(entries[nx] > 65535) {
677 firstnumberofgroup = k;
678 fStopFillCH = kTRUE;
679 }
680 }
681 else continue;
682 }
683 }
684 if(fStopFillCH && (firstnumberofgroup == 0)) return 0x0;
685 if(!fStopFillCH) firstnumberofgroup = numberofgroup;
686
687 // Now add up to possible
688 for(Int_t k = 0; k < nxbins; k++){
689 entries[k] = 0;
690 }
691 for(Int_t k = 0; k < firstnumberofgroup; k++){
692 for(Int_t nx = 0; nx < nxbins; nx++) {
693 Int_t binnumber = k*nxbins+nx;
694 entries[nx] += entriesch->At(binnumber);
695 }
696 }
697
698 // Finally fill
699 for(Int_t nx = 0; nx < nxbins; nx++){
700 fCalVector->FillVectorCH(det,0,nx,(Int_t)entries[nx]);
701 }
702 }
703
704 return fCalVector;
705}
706//_____________________________________________________________________________________________________________________
707AliTRDCalibraVector *AliTRDCalibraVector::AddStatsPerDetectorPH()
708{
709 //
710 // Create a AliTRDCalibraVector detector wise
711 //
712
713 AliTRDCalibraMode calibMode = AliTRDCalibraMode();
714 calibMode.SetNz(1,GetNz(1));
715 calibMode.SetNrphi(1,GetNrphi(1));
716 if(((calibMode.GetNz(1) == 100) && (calibMode.GetNrphi(1) == 100)) || ((calibMode.GetNz(1) == 10) && (calibMode.GetNrphi(1) == 10))) return 0x0;
717
718
719 // Check
720 Int_t nybins = 6*4*18*fDetCha0[1]+6*18*fDetCha2[1];
721 Int_t nxbins = fTimeMax;
722
723 Int_t perChamber2 = 0;
724 Int_t perChamber0 = 0;
725 calibMode.ModePadCalibration(2,1);
726 calibMode.ModePadFragmentation(0,2,0,1);
727 calibMode.SetDetChamb2(1);
728 perChamber2 = (Int_t) calibMode.GetDetChamb2(1);
729 calibMode.ModePadCalibration(0,1);
730 calibMode.ModePadFragmentation(0,0,0,1);
731 calibMode.SetDetChamb0(1);
732 perChamber0 = (Int_t) calibMode.GetDetChamb0(1);
733
734 if(nybins != (6*18*perChamber2+6*4*18*perChamber0)) return 0x0;
735
736 // Create calvector
737 if(!fCalVector) fCalVector = new AliTRDCalibraVector();
738 else{
739 fCalVector->~AliTRDCalibraVector();
740 new(fCalVector) AliTRDCalibraVector();
741 }
742 fCalVector->SetTimeMax(nxbins);
743 fCalVector->SetDetCha0(1,1);
744 fCalVector->SetDetCha2(1,1);
745 fCalVector->SetNzNrphi(1,0,0);
746
747
748 for(Int_t det = 0; det < 540; det++){
749
750 // Take
751 AliTRDEntriesInfo *entriesph = (AliTRDEntriesInfo *)GetPHEntries(det,kFALSE);
752 if(!entriesph) continue;
753 AliTRDPhInfo *meanph = (AliTRDPhInfo *)GetPHMean(det,kFALSE);
754 AliTRDPhInfo *squaresph = (AliTRDPhInfo *)GetPHSquares(det,kFALSE);
755
756 // Number of groups
757 Int_t numberofgroup = 0;
758 if(AliTRDgeometry::GetStack(det) == 2) numberofgroup = perChamber2;
759 else numberofgroup = perChamber0;
760
761 // PH
762 for(Int_t nx = 0; nx < nxbins; nx++) {
763
764 Double_t entries = 0.0;
765 Double_t sumw2 = 0.0;
766 Double_t sumw = 0.0;
767
768 // Sum the contributions of the different calibration group in the detector
769 for(Int_t k = 0; k < numberofgroup; k++){
770
771 Int_t binnumber = k*nxbins+nx;
772
773 Int_t entriesv = ((AliTRDEntriesInfo *)entriesph)->At(binnumber);
774 Float_t sumw2v = ((AliTRDPhInfo *)squaresph)->AtS(binnumber)*entriesv;
775 Float_t sumwv = ((AliTRDPhInfo *)meanph)->At(binnumber)*entriesv;
776
777
778 if(((entries+entriesv) > 65535) || ((entries+entriesv) <= 0)) continue;
779
780 entries += entriesv;
781 sumw2 += sumw2v;
782 sumw += sumwv;
783
784 }
785
786 if(entries > 0) {
787 sumw2 = sumw2/((Float_t)entries);
788 sumw = sumw/((Float_t)entries);
789 }
790
791 fCalVector->FillVectorPH(det,0,nx,(Int_t)entries,(Float_t)sumw,(Float_t)sumw2);
792 }
793 }
794
795 return fCalVector;
796
797}
798//_____________________________________________________________________________________________________________________
799AliTRDCalibraVector *AliTRDCalibraVector::AddStatsPerDetectorPRF()
800{
801 //
802 // Create a AliTRDCalibraVector detector wise
803 //
804
805 AliTRDCalibraMode calibMode = AliTRDCalibraMode();
806 calibMode.SetNz(2,GetNz(2));
807 calibMode.SetNrphi(2,GetNrphi(2));
808 if(((calibMode.GetNz(2) == 100) && (calibMode.GetNrphi(2) == 100)) || ((calibMode.GetNz(2) == 10) && (calibMode.GetNrphi(2) == 10))) return 0x0;
809
810 // Check
811 Int_t nybins = 6*4*18*fDetCha0[2]+ 6*18*fDetCha2[2];
812 Int_t nxbins = fNumberBinPRF;
813
814 Int_t perChamber2 = 0;
815 Int_t perChamber0 = 0;
816 calibMode.ModePadCalibration(2,2);
817 calibMode.ModePadFragmentation(0,2,0,2);
818 calibMode.SetDetChamb2(2);
819 perChamber2 = (Int_t) calibMode.GetDetChamb2(2);
820 calibMode.ModePadCalibration(0,2);
821 calibMode.ModePadFragmentation(0,0,0,2);
822 calibMode.SetDetChamb0(2);
823 perChamber0 = (Int_t) calibMode.GetDetChamb0(2);
824
825 if(nybins != (6*18*perChamber2+6*4*18*perChamber0)) return 0x0;
826
827 // Create calvector
828 if(!fCalVector) fCalVector = new AliTRDCalibraVector();
829 else{
830 fCalVector->~AliTRDCalibraVector();
831 new(fCalVector) AliTRDCalibraVector();
832 }
833 fCalVector->SetNumberBinPRF(nxbins);
834 fCalVector->SetDetCha0(2,1);
835 fCalVector->SetDetCha2(2,1);
836 fCalVector->SetNzNrphi(2,0,0);
837 fCalVector->SetNbGroupPRF(fNbGroupPRF);
838
839
840 for(Int_t det = 0; det < 540; det++){
841
842 // Take
843 AliTRDEntriesInfo *entriesprf = (AliTRDEntriesInfo *) GetPRFEntries(det,kFALSE);
844 if(!entriesprf) continue;
845 AliTRDPrfInfo *meanprf = (AliTRDPrfInfo *) GetPRFMean(det,kFALSE);
846 AliTRDPrfInfo *squaresprf = (AliTRDPrfInfo *) GetPRFSquares(det,kFALSE);
847
848 // Number of groups
849 Int_t numberofgroup = 0;
850 if(AliTRDgeometry::GetStack(det) == 2) numberofgroup = perChamber2;
851 else numberofgroup = perChamber0;
852
853 for(Int_t nx = 0; nx < nxbins; nx++) {
854
855 Double_t entries = 0.0;
856 Double_t sumw2 = 0.0;
857 Double_t sumw = 0.0;
858
859 // Sum the contributions of the different groups in the detector for one bin
860 for(Int_t k = 0; k < numberofgroup; k++){
861
862 Int_t binnumber = k*nxbins+nx;
863
864 Int_t entriesv = ((AliTRDEntriesInfo *)entriesprf)->At(binnumber);
865 Float_t sumw2v = ((AliTRDPrfInfo *)squaresprf)->At(binnumber)*entriesv;
866 Float_t sumwv = ((AliTRDPrfInfo *)meanprf)->At(binnumber)*entriesv;
867
868 if(((entries+entriesv) > 65535) || ((entries+entriesv) <= 0)) continue;
869
870 entries += entriesv;
871 sumw2 += sumw2v;
872 sumw += sumwv;
873
874 }
875
876 if(entries > 0) {
877 sumw2 = sumw2/((Float_t)entries);
878 sumw = sumw/((Float_t)entries);
879 }
880
881 fCalVector->FillVectorPRF(det,0,nx,(Int_t)entries,(Float_t)sumw,(Float_t)sumw2);
882
883 }
884 }
885
886 return fCalVector;
887}
888//_______________________________________________________________________________
889Bool_t AliTRDCalibraVector::FindTheMaxEntries(Int_t i, Int_t &detectormax, Int_t &groupmax)
890{
891 //
892 // Find detectormax and groupmax with the biggest number of entries
893 //
894
895 // Coverity
896 //Int_t numberofTB = 0;
897 //if(i==0) numberofTB = (Int_t) GetNumberBinCharge();
898 //if(i==1) numberofTB = GetTimeMax();
899 //if(i==2) numberofTB = GetNumberBinPRF();
900 if((i!=0) && (i!=1) && (i!=2)) AliInfo("Didn't understand i");
901
902
903 // Init
904 Double_t entries [540];
905 for(Int_t idet = 0; idet < 540; idet++){
906 entries[idet] = 0.0;
907 }
908
909 AliTRDEntriesInfo *entriesd = 0x0;
910 // Take the number of entries per detector
911 for(Int_t idet = 0; idet < 540; idet++){
912
913 if(i==0) entriesd = (AliTRDEntriesInfo *) GetCHEntries(idet,kFALSE);
914 if(i==1) entriesd = (AliTRDEntriesInfo *) GetPHEntries(idet,kFALSE);
915 if(i==2) entriesd = (AliTRDEntriesInfo *) GetPRFEntries(idet,kFALSE);
916 if(!entriesd) continue;
917
918 entries[idet] = entriesd->GetSum();
919
920 }
921
922 // Search detector max
923 Double_t max = -10;
924 detectormax = -1;
925 for(Int_t idet = 0; idet < 540; idet++){
926 if(entries[idet] > max) {
927 max = entries[idet];
928 detectormax = idet;
929 }
930 }
931 if((max == 0.0) || (detectormax <0.0)) return kFALSE;
932
933 // Search group max
934 if(i==0) entriesd = (AliTRDEntriesInfo *) GetCHEntries(detectormax,kFALSE);
935 if(i==1) entriesd = (AliTRDEntriesInfo *) GetPHEntries(detectormax,kFALSE);
936 if(i==2) entriesd = (AliTRDEntriesInfo *) GetPRFEntries(detectormax,kFALSE);
937 if(!entriesd) return kFALSE;
938 // Number of groups
939 Int_t numberofgroup = 0;
940 if(AliTRDgeometry::GetStack(detectormax) == 2) numberofgroup = fDetCha2[i];
941 else numberofgroup = fDetCha0[i];
942 // Init
943 Double_t nbgroup [2304];
944 for(Int_t k = 0; k < 2304; k++){
945 nbgroup[k] = 0.0;
946 }
947 Int_t nxbins = 0;
948 if(i==0) nxbins = fNumberBinCharge;
949 if(i==1) nxbins = fTimeMax;
950 if(i==2) nxbins = fNumberBinPRF;
951 // Compute the number of entries per group
952 for(Int_t k = 0; k < numberofgroup; k++){
953 for(Int_t nx = 0; nx < nxbins; nx++) {
954 Int_t binnumber = k*nxbins+nx;
955 nbgroup[k] += ((AliTRDEntriesInfo *)entriesd)->At(binnumber);
956 }
957 }
958 max = -10.0;
959 groupmax = -1;
960 for(Int_t io = 0; io < numberofgroup; io++){
961 if(nbgroup[io] > max){
962 max = nbgroup[io];
963 groupmax = io;
964 }
965 }
966 if((max == 0.0) || (groupmax < 0.0) || (groupmax >= numberofgroup)) return kFALSE;
967
968 return kTRUE;
969
970}
971//_____________________________________________________________________________
972TGraphErrors *AliTRDCalibraVector::ConvertVectorPHTGraphErrors(Int_t det, Int_t group , const Char_t * name)
973{
974 //
975 // Convert the fVectorPHMean, fVectorPHSquares and fVectorPHEntries in TGraphErrors
976 //
977
978 // Take the info
979 fPHEntries[det] = ((AliTRDEntriesInfo *)GetPHEntries(det,kTRUE));
980 fPHMean[det] = ((AliTRDPhInfo *)GetPHMean(det,kTRUE));
981 fPHSquares[det] = ((AliTRDPhInfo *)GetPHSquares(det,kTRUE));
982
983
984 // Axis
985 Float_t sf = 10.0;
986 AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
987 if (parCom) {
988 sf = parCom->GetSamplingFrequency();
989 }
990 else {
991 AliInfo("Could not get CommonParam, take the default 10MHz");
992 }
993 // Axis
994 Double_t x[35]; // Xaxis
995 Double_t y[35]; // Sum/entries
996 Double_t ex[35]; // Nentries
997 Double_t ey[35]; // Sum of square/nentries
998 Double_t step = 0.0;
999 Double_t min = 0.0;
1000 if(sf > 0.0) step = 1.0 / sf;
1001 min = 0.0;
1002 Int_t offset = group*fTimeMax;
1003
1004 // Fill histo
1005 for (Int_t k = 0; k < fTimeMax; k++) {
1006 x[k] = min + k*step;
1007 y[k] = 0.0;
1008 ex[k] = 0.0;
1009 ey[k] = 0.0;
1010 Int_t bin = offset+k;
1011 // Fill only if there is more than 0 something
1012 if (((AliTRDEntriesInfo *)fPHEntries[det])->At(bin) > 0) {
1013 ex[k] = ((AliTRDEntriesInfo *)fPHEntries[det])->At(bin);
1014 y[k] = ((AliTRDPhInfo *)fPHMean[det])->At(bin);
1015 ey[k] = ((AliTRDPhInfo *)fPHSquares[det])->AtS(bin);
1016 }
1017 }
1018
1019 // Define the TGraphErrors
1020 if(!fGraph) fGraph = new TGraphErrors(fTimeMax,&x[0],&y[0],&ex[0],&ey[0]);
1021 else{
1022 fGraph->~TGraphErrors();
1023 new(fGraph) TGraphErrors(fTimeMax,&x[0],&y[0],&ex[0],&ey[0]);
1024 }
1025 fGraph->SetTitle(name);
1026
1027 return fGraph;
1028
1029}
1030//_____________________________________________________________________________
1031TGraphErrors *AliTRDCalibraVector::ConvertVectorPRFTGraphErrors(Int_t det, Int_t group , const Char_t * name)
1032{
1033 //
1034 // Convert the fVectorPRFMean, fVectorPRFSquares and fVectorPRFEntries in TGraphErrors
1035 //
1036
1037 // Take the info
1038 fPRFEntries[det] = ((AliTRDEntriesInfo *)GetPRFEntries(det,kTRUE));
1039 fPRFMean[det] = ((AliTRDPrfInfo *)GetPRFMean(det,kTRUE));
1040 fPRFSquares[det] = ((AliTRDPrfInfo *)GetPRFSquares(det,kTRUE));
1041
1042
1043 // Axis
1044 Double_t x[200]; // Xaxis
1045 Double_t y[200]; // Sum/entries
1046 Double_t ex[200]; //Nentries
1047 Double_t ey[200]; // Sum of square/nentries
1048 Double_t step = 0.0;
1049 Double_t min = 0.0;
1050 if(fNumberBinPRF) step = (2*TMath::Abs(fPRFRange)) / fNumberBinPRF;
1051 min = -TMath::Abs(fPRFRange) + step / 2.0;
1052 Int_t offset = group*fNumberBinPRF;
1053 //printf("number of total: %d\n",fNumberBinPRF);
1054 // Fill histo
1055 for (Int_t k = 0; k < fNumberBinPRF; k++) {
1056 x[k] = min + k*step;
1057 y[k] = 0.0;
1058 ex[k] = 0.0;
1059 ey[k] = 0.0;
1060 Int_t bin = offset+k;
1061 // Fill only if there is more than 0 something
1062 if (((AliTRDEntriesInfo *)fPRFEntries[det])->At(bin) > 0) {
1063 ex[k] = ((AliTRDEntriesInfo *)fPRFEntries[det])->At(bin);
1064 y[k] = ((AliTRDPrfInfo *)fPRFMean[det])->At(bin);
1065 ey[k] = ((AliTRDPrfInfo *)fPRFSquares[det])->At(bin);
1066 }
1067 //printf("Number of entries %f for %d\n",ex[k],k);
1068 }
1069
1070 // Define the TGraphErrors
1071 if(!fGraph) fGraph = new TGraphErrors(fNumberBinPRF,&x[0],&y[0],&ex[0],&ey[0]);
1072 else{
1073 fGraph->~TGraphErrors();
1074 new(fGraph) TGraphErrors(fNumberBinPRF,&x[0],&y[0],&ex[0],&ey[0]);
1075 }
1076 fGraph->SetTitle(name);
1077
1078 return fGraph;
1079
1080
1081
1082}
1083//_____________________________________________________________________________
1084TH1F *AliTRDCalibraVector::CorrectTheError(const TGraphErrors *hist, Int_t &nbEntries)
1085{
1086 //
1087 // In the case of the vectors method the trees contains TGraphErrors for PH and PRF
1088 // to be able to add them after
1089 // We convert it to a TH1F to be able to applied the same fit function method
1090 // After having called this function you can not add the statistics anymore
1091 //
1092
1093 Int_t nbins = hist->GetN();
1094 Double_t *x = hist->GetX();
1095 Double_t *entries = hist->GetEX();
1096 Double_t *mean = hist->GetY();
1097 Double_t *square = hist->GetEY();
1098 nbEntries = 0;
1099
1100 if (nbins < 2) {
1101 return 0x0;
1102 }
1103
1104 Double_t step = x[1] - x[0];
1105 Double_t minvalue = x[0] - step/2;
1106 Double_t maxvalue = x[(nbins-1)] + step/2;
1107
1108 if(!fHisto) fHisto = new TH1F("projcorrecterror","",nbins,minvalue,maxvalue);
1109 else{
1110 fHisto->~TH1F();
1111 new(fHisto) TH1F("projcorrecterror","",nbins,minvalue,maxvalue);
1112 }
1113
1114 for (Int_t k = 0; k < nbins; k++) {
1115 fHisto->SetBinContent(k+1,mean[k]);
1116 if (entries[k] > 0.0) {
1117 nbEntries += (Int_t) entries[k];
1118 Double_t d = TMath::Abs(square[k] - (mean[k]*mean[k]));
1119 fHisto->SetBinError(k+1,TMath::Sqrt(d/entries[k]));
1120 }
1121 else {
1122 fHisto->SetBinError(k+1,0.0);
1123 }
1124 }
1125
1126 return fHisto;
1127
1128}
1129//_____________________________________________________________________________
1130TH1F *AliTRDCalibraVector::ConvertVectorCHHisto(Int_t det, Int_t group, const Char_t * name)
1131{
1132 //
1133 // Convert the fVectorCHEntries in TH1F
1134 //
1135
1136 // Take the info
1137 fCHEntries[det] = ((AliTRDEntriesInfo *)GetCHEntries(det,kTRUE));
1138
1139 // Init the stuff
1140 if(!fHisto) fHisto = new TH1F(name,name,fNumberBinCharge,0,300);
1141 else{
1142 fHisto->~TH1F();
1143 new(fHisto) TH1F(name,name,fNumberBinCharge,0,300);
1144 }
1145 fHisto->Sumw2();
1146 Int_t offset = group*fNumberBinCharge;
1147 // Fill histo
1148 for (Int_t k = 0; k < fNumberBinCharge; k++) {
1149 Int_t bin = offset+k;
1150 fHisto->SetBinContent(k+1,((AliTRDEntriesInfo *)fCHEntries[det])->At(bin));
1151 fHisto->SetBinError(k+1,TMath::Sqrt(TMath::Abs(((AliTRDEntriesInfo *)fCHEntries[det])->At(bin))));
1152 }
1153
1154 return fHisto;
1155
1156}
1157//_____________________________________________________________________
1158TObject* AliTRDCalibraVector::GetPHEntries(Int_t det
1159 , Bool_t force) /*FOLD00*/
1160{
1161 //
1162 // return pointer to Carge ROC Calibration
1163 // if force is true create a new histogram if it doesn't exist allready
1164 //
1165 AliTRDEntriesInfo**arr = &fPHEntries[0];
1166 return (TObject *) GetEntriesPH(det, arr, force);
1167}
1168//_____________________________________________________________________
1169TObject* AliTRDCalibraVector::GetPRFEntries(Int_t det
1170 , Bool_t force) /*FOLD00*/
1171{
1172 //
1173 // return pointer to Carge ROC Calibration
1174 // if force is true create a new histogram if it doesn't exist allready
1175 //
1176 AliTRDEntriesInfo**arr = &fPRFEntries[0];
1177 return (TObject *) GetEntriesPRF(det, arr, force);
1178}
1179//_____________________________________________________________________
1180TObject* AliTRDCalibraVector::GetCHEntries(Int_t det
1181 , Bool_t force) /*FOLD00*/
1182{
1183 //
1184 // return pointer to Carge ROC Calibration
1185 // if force is true create a new histogram if it doesn't exist allready
1186 //
1187 AliTRDEntriesInfo**arr = &fCHEntries[0];
1188 return (TObject *) GetEntriesCH(det, arr, force);
1189}
1190//_____________________________________________________________________
1191TObject* AliTRDCalibraVector::GetPHMean(Int_t det
1192 , Bool_t force) /*FOLD00*/
1193{
1194 //
1195 // return pointer to ROC Calibration
1196 // if force is true create a new array
1197 //
1198 AliTRDPhInfo**arr = &fPHMean[0];
1199 return (TObject *) GetMeanSquaresPH(det, arr, force);
1200}
1201//_____________________________________________________________________
1202TObject* AliTRDCalibraVector::GetPHSquares(Int_t det
1203 , Bool_t force) /*FOLD00*/
1204{
1205 //
1206 // return pointer to ROC Calibration
1207 // if force is true create a new array
1208 //
1209 AliTRDPhInfo**arr = &fPHSquares[0];
1210 return (TObject *) GetMeanSquaresPH(det, arr, force);
1211}
1212//_____________________________________________________________________
1213TObject* AliTRDCalibraVector::GetPRFMean(Int_t det
1214 , Bool_t force) /*FOLD00*/
1215{
1216 //
1217 // return pointer to ROC Calibration
1218 // if force is true create a new array
1219 //
1220 AliTRDPrfInfo**arr = &fPRFMean[0];
1221 return (TObject *) GetMeanSquaresPRF(det, arr, force);
1222}
1223//_____________________________________________________________________
1224TObject* AliTRDCalibraVector::GetPRFSquares(Int_t det
1225 , Bool_t force) /*FOLD00*/
1226{
1227 //
1228 // return pointer to ROC Calibration
1229 // if force is true create a new array
1230 //
1231 AliTRDPrfInfo**arr = &fPRFSquares[0];
1232 return (TObject *) GetMeanSquaresPRF(det, arr, force);
1233}
1234//_____________________________________________________________________
1235AliTRDEntriesInfo* AliTRDCalibraVector::GetEntriesCH(Int_t det
1236 , AliTRDEntriesInfo** arr
1237 , Bool_t force) /*FOLD00*/
1238{
1239 //
1240 // return pointer to UShort_t array Entries
1241 // if force is true create a new UShort_t array if it doesn't exist allready
1242 //
1243 if ( (!force) || (arr[det]))
1244 return (AliTRDEntriesInfo*)arr[det];
1245
1246 // if we are forced and TArrayI doesn't yes exist create it
1247 Int_t ngroup = GetTotalNumberOfBinsInDetector(det,0,fNumberBinCharge);
1248 // init
1249 arr[det] = new AliTRDEntriesInfo(ngroup);
1250
1251 return (AliTRDEntriesInfo*)arr[det];
1252
1253}
1254//_____________________________________________________________________
1255AliTRDEntriesInfo* AliTRDCalibraVector::GetEntriesPRF(Int_t det
1256 , AliTRDEntriesInfo** arr
1257 , Bool_t force) /*FOLD00*/
1258{
1259 //
1260 // return pointer to UShort_t array Entries
1261 // if force is true create a new UShort_t array if it doesn't exist allready
1262 //
1263 if ( (!force) || (arr[det]))
1264 return (AliTRDEntriesInfo*)arr[det];
1265
1266 // if we are forced and TArrayI doesn't yes exist create it
1267 Int_t ngroup = GetTotalNumberOfBinsInDetector(det,2,fNumberBinPRF);
1268 // init
1269 arr[det] = new AliTRDEntriesInfo(ngroup);
1270
1271 return (AliTRDEntriesInfo*)arr[det];
1272
1273}
1274//_____________________________________________________________________
1275AliTRDEntriesInfo *AliTRDCalibraVector::GetEntriesPH(Int_t det
1276 , AliTRDEntriesInfo ** arr
1277 , Bool_t force) /*FOLD00*/
1278{
1279 //
1280 // return pointer to UShort_t array Entries
1281 // if force is true create a new UShort_t array if it doesn't exist allready
1282 //
1283 if ( (!force) || (arr[det]))
1284 return (AliTRDEntriesInfo *)arr[det];
1285
1286 // if we are forced and UShort_t doesn't yet exist create it
1287 Int_t ngroup = GetTotalNumberOfBinsInDetector(det,1,fTimeMax);
1288 // init
1289 arr[det] = new AliTRDEntriesInfo(ngroup);
1290
1291 return (AliTRDEntriesInfo*)arr[det];
1292
1293}
1294//_____________________________________________________________________
1295AliTRDPhInfo* AliTRDCalibraVector::GetMeanSquaresPH(Int_t det
1296 , AliTRDPhInfo** arr
1297 , Bool_t force) /*FOLD00*/
1298{
1299 //
1300 // return pointer to Float_t array Mean or Squares
1301 // if force is true create a new Float_t array if it doesn't exist allready
1302 //
1303 if ( (!force) || (arr[det]))
1304 return (AliTRDPhInfo*)arr[det];
1305
1306 // if we are forced and Float_t array doesn't yes exist create it
1307 Int_t ngroup = GetTotalNumberOfBinsInDetector(det,1,fTimeMax);
1308 // init
1309 arr[det] = new AliTRDPhInfo(ngroup);
1310
1311 return ((AliTRDPhInfo *)arr[det]);
1312}
1313//_____________________________________________________________________
1314AliTRDPrfInfo* AliTRDCalibraVector::GetMeanSquaresPRF(Int_t det
1315 , AliTRDPrfInfo** arr
1316 , Bool_t force) /*FOLD00*/
1317{
1318 //
1319 // return pointer to Float_t array Mean or Squares
1320 // if force is true create a new array if it doesn't exist allready
1321 //
1322 if ( (!force) || (arr[det]))
1323 return arr[det];
1324
1325 // if we are forced and the array doesn't yet exist create it
1326 Int_t ngroup = GetTotalNumberOfBinsInDetector(det,2,fNumberBinPRF);
1327 // init
1328 arr[det] = new AliTRDPrfInfo(ngroup);
1329
1330 return (AliTRDPrfInfo*)arr[det];
1331
1332}
1333//_____________________________________________________________________________
1334Int_t AliTRDCalibraVector::GetTotalNumberOfBinsInDetector(Int_t det, Int_t i, Int_t nbBin) const
1335{
1336 //
1337 // Get the total number of bins (Nb of bins*Nb of groups) in the detector det for the group i
1338 //
1339
1340 Int_t ngroup = 0;
1341 Int_t stack = AliTRDgeometry::GetStack(det);
1342 if(stack == 2) ngroup = fDetCha2[i]*nbBin;
1343 else ngroup = fDetCha0[i]*nbBin;
1344
1345 return ngroup;
1346
1347}
1348//____________________________________________________________________________
1349Int_t AliTRDCalibraVector::GetNz(Int_t i) const
1350{
1351 //
1352 // Get Nz the granularity in row
1353 //
1354
1355 Int_t nz = 0;
1356 if(i==0) nz = (Int_t)(fModeCH>>4);
1357 if(i==1) nz = (Int_t)(fModePH>>4);
1358 if(i==2) nz = (Int_t)(fModePRF>>4);
1359
1360 return nz;
1361
1362}
1363//____________________________________________________________________________
1364Int_t AliTRDCalibraVector::GetNrphi(Int_t i) const
1365{
1366 //
1367 // Get Nrphi the granularity in col
1368 //
1369
1370 Int_t nrphi = 0;
1371 if(i==0) nrphi = (Int_t)(fModeCH&15);
1372 if(i==1) nrphi = (Int_t)(fModePH&15);
1373 if(i==2) nrphi = (Int_t)(fModePRF&15);
1374
1375 return nrphi;
1376
1377}
1378//_________________________________________________________________________________
1379TString AliTRDCalibraVector::GetNamePH() const
1380{
1381 //
1382 // Get the name of PH to know the granularity
1383 //
1384
1385 Int_t nz = GetNz(1);
1386 Int_t nrphi = GetNrphi(1);
1387
1388 TString name("Nz");
1389 name += nz;
1390 name += "Nrphi";
1391 name += nrphi;
1392
1393 return name;
1394
1395}
1396//_________________________________________________________________________________
1397TString AliTRDCalibraVector::GetNameCH() const
1398{
1399 //
1400 // Get the name of CH to know the granularity
1401 //
1402
1403 Int_t nz = GetNz(0);
1404 Int_t nrphi = GetNrphi(0);
1405
1406 TString name("Nz");
1407 name += nz;
1408 name += "Nrphi";
1409 name += nrphi;
1410
1411 return name;
1412
1413}
1414//_________________________________________________________________________________
1415TString AliTRDCalibraVector::GetNamePRF() const
1416{
1417 //
1418 // Get the name of PRF to know the granularity
1419 //
1420
1421 Int_t nz = GetNz(2);
1422 Int_t nrphi = GetNrphi(2);
1423
1424 TString name("Nz");
1425 name += nz;
1426 name += "Nrphi";
1427 name += nrphi;
1428 name += "Ngp";
1429 name += fNbGroupPRF;
1430
1431 return name;
1432
1433}
1434//____________________________________________________________________________
1435void AliTRDCalibraVector::SetNzNrphi(Int_t i, Int_t nz, Int_t nrphi)
1436{
1437 //
1438 // Set NzNrphi for the granularity
1439 //
1440
1441 if(i==0) {
1442 fModeCH = nz;
1443 fModeCH = fModeCH << 4;
1444 fModeCH |= nrphi;
1445 }
1446 if(i==1) {
1447 fModePH = nz;
1448 fModePH = fModePH << 4;
1449 fModePH |= nrphi;
1450 }
1451 if(i==2) {
1452 fModePRF = nz;
1453 fModePRF = fModePRF << 4;
1454 fModePRF |= nrphi;
1455 }
1456
1457}
1458