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