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