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