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