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