Fixed printf statements
[u/mrichter/AliRoot.git] / TRD / Cal / AliTRDCalPad.cxx
CommitLineData
7754cd1f 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// TRD calibration class for parameters which saved per pad //
21// //
22///////////////////////////////////////////////////////////////////////////////
23
4c87f26e 24#include <TMath.h>
25#include <TH2F.h>
26#include <TH1F.h>
27#include <TStyle.h>
28
7754cd1f 29#include "AliTRDCalPad.h"
30#include "AliTRDCalROC.h"
31#include "AliTRDCalDet.h"
4c87f26e 32#include "AliTRDpadPlane.h"
33#include "AliMathBase.h"
34#include "AliTRDgeometry.h"
7754cd1f 35
36ClassImp(AliTRDCalPad)
37
38//_____________________________________________________________________________
39AliTRDCalPad::AliTRDCalPad():TNamed()
40{
41 //
42 // AliTRDCalPad default constructor
43 //
44
45 for (Int_t idet = 0; idet < kNdet; idet++) {
46 fROC[idet] = 0;
47 }
48
49}
50
51//_____________________________________________________________________________
52AliTRDCalPad::AliTRDCalPad(const Text_t *name, const Text_t *title)
53 :TNamed(name,title)
54{
55 //
56 // AliTRDCalPad constructor
57 //
58
59 for (Int_t isec = 0; isec < kNsect; isec++) {
60 for (Int_t ipla = 0; ipla < kNplan; ipla++) {
61 for (Int_t icha = 0; icha < kNcham; icha++) {
62 Int_t idet = GetDet(ipla,icha,isec);
63 fROC[idet] = new AliTRDCalROC(ipla,icha);
64 }
65 }
66 }
67
68}
69
7754cd1f 70//_____________________________________________________________________________
4c87f26e 71AliTRDCalPad::AliTRDCalPad(const AliTRDCalPad &c)
72 :TNamed(c)
7754cd1f 73{
74 //
75 // AliTRDCalPad copy constructor
76 //
77
4c87f26e 78 for (Int_t idet = 0; idet < kNdet; idet++) {
79 fROC[idet] = new AliTRDCalROC(*((AliTRDCalPad &) c).fROC[idet]);
80 }
7754cd1f 81
82}
83
4c87f26e 84//_____________________________________________________________________________
7754cd1f 85AliTRDCalPad::~AliTRDCalPad()
86{
87 //
88 // AliTRDCalPad destructor
89 //
90
91 for (Int_t idet = 0; idet < kNdet; idet++) {
92 if (fROC[idet]) {
93 delete fROC[idet];
94 fROC[idet] = 0;
95 }
96 }
97
98}
99
100//_____________________________________________________________________________
101AliTRDCalPad &AliTRDCalPad::operator=(const AliTRDCalPad &c)
102{
103 //
104 // Assignment operator
105 //
106
107 if (this != &c) ((AliTRDCalPad &) c).Copy(*this);
108 return *this;
109
110}
111
112//_____________________________________________________________________________
113void AliTRDCalPad::Copy(TObject &c) const
114{
115 //
116 // Copy function
117 //
118
119 for (Int_t idet = 0; idet < kNdet; idet++) {
ea2a3ed8 120 if (((AliTRDCalPad &) c).fROC[idet]) {
121 delete ((AliTRDCalPad &) c).fROC[idet];
122 }
123 ((AliTRDCalPad &) c).fROC[idet] = new AliTRDCalROC();
7754cd1f 124 if (fROC[idet]) {
125 fROC[idet]->Copy(*((AliTRDCalPad &) c).fROC[idet]);
126 }
127 }
128
129 TObject::Copy(c);
2745a409 130
7754cd1f 131}
132
133//_____________________________________________________________________________
4c87f26e 134Bool_t AliTRDCalPad::ScaleROCs(const AliTRDCalDet* values)
7754cd1f 135{
136 //
137 // Scales ROCs of this class with the values from the class <values>
138 // Is used if an AliTRDCalPad object defines local variations of a parameter
139 // defined per detector using a AliTRDCalDet class
140 //
141
142 if (!values)
4c87f26e 143 return kFALSE;
144 Bool_t result = kTRUE;
7754cd1f 145 for (Int_t idet = 0; idet < kNdet; idet++) {
146 if (fROC[idet]) {
4c87f26e 147 if(!fROC[idet]->Multiply(values->GetValue(idet))) result = kFALSE;
148 }
149 }
150 return result;
151}
152
153//_____________________________________________________________________________
154Double_t AliTRDCalPad::GetMeanRMS(Double_t &rms, const AliTRDCalDet *calDet, Int_t type)
155{
156 //
157 // Calculate mean an RMS of all rocs
158 // If calDet correct the CalROC from the detector coefficient
159 // type == 0 for gain and vdrift
160 // type == 1 for t0
161 //
162 Double_t factor = 0.0;
163 if(type == 0) factor = 1.0;
164 Double_t sum = 0, sum2 = 0, n=0, val=0;
165 for (Int_t idet = 0; idet < kNdet; idet++) {
166 if(calDet) factor = calDet->GetValue(idet);
167 AliTRDCalROC *calRoc = fROC[idet];
168 if ( calRoc ){
169 for (Int_t irow=0; irow<calRoc->GetNrows(); irow++){
170 for (Int_t icol=0; icol<calRoc->GetNcols(); icol++){
171 if(type == 0) val = calRoc->GetValue(icol,irow)*factor;
172 else val = calRoc->GetValue(icol,irow)+factor;
173 sum+=val;
174 sum2+=val*val;
175 n++;
176 }
177 }
178 }
179 }
180 Double_t n1 = 1./n;
181 Double_t mean = sum*n1;
182 rms = TMath::Sqrt(TMath::Abs(sum2*n1-mean*mean));
183 return mean;
184}
185
186//_____________________________________________________________________________
187Double_t AliTRDCalPad::GetMean(const AliTRDCalDet *calDet, Int_t type, AliTRDCalPad* outlierPad)
188{
189 //
190 // return mean of the mean of all ROCs
191 // If calDet correct the CalROC from the detector coefficient
192 // type == 0 for gain and vdrift
193 // type == 1 for t0
194 //
195 Double_t factor = 0.0;
196 if(type == 0) factor = 1.0;
197 Double_t arr[kNdet];
198 Int_t n=0;
199 for (Int_t idet = 0; idet < kNdet; idet++) {
200 if(calDet) factor = calDet->GetValue(idet);
201 AliTRDCalROC *calRoc = fROC[idet];
202 if ( calRoc ){
203 AliTRDCalROC* outlierROC = 0;
204 if (outlierPad) outlierROC = outlierPad->GetCalROC(idet);
205 if(type == 0) arr[n] = calRoc->GetMean(outlierROC)*factor;
206 else arr[n] = calRoc->GetMean(outlierROC)+factor;
207 n++;
208 }
209 }
210 return TMath::Mean(n,arr);
211}
212
213//_____________________________________________________________________________
214Double_t AliTRDCalPad::GetRMS(const AliTRDCalDet *calDet, Int_t type, AliTRDCalPad* outlierPad)
215{
216 //
217 // return mean of the RMS of all ROCs
218 // If calDet correct the CalROC from the detector coefficient
219 // type == 0 for gain and vdrift
220 // type == 1 for t0
221 //
222 Double_t factor = 0.0;
223 if(type == 0) factor = 1.0;
224 Double_t arr[kNdet];
225 Int_t n=0;
226 for (Int_t idet = 0; idet < kNdet; idet++) {
227 if(calDet) factor = calDet->GetValue(idet);
228 AliTRDCalROC *calRoc = fROC[idet];
229 if ( calRoc ){
230 AliTRDCalROC* outlierROC = 0;
231 if (outlierPad) outlierROC = outlierPad->GetCalROC(idet);
232 if(type == 0) arr[n] = calRoc->GetRMS(outlierROC)*factor;
233 else arr[n] = calRoc->GetRMS(outlierROC);
234 n++;
235 }
236 }
237 return TMath::Mean(n,arr);
238}
239
240//_____________________________________________________________________________
241Double_t AliTRDCalPad::GetMedian(const AliTRDCalDet *calDet, Int_t type
242 , AliTRDCalPad* outlierPad)
243{
244 //
245 // return mean of the median of all ROCs
246 // If AliTRDCalDet, the correct the CalROC from the detector coefficient
247 // type == 0 for gain and vdrift
248 // type == 1 for t0
249 //
250 Double_t factor = 0.0;
251 if(type == 0) factor = 1.0;
252 Double_t arr[kNdet];
253 Int_t n=0;
254 for (Int_t idet = 0; idet < kNdet; idet++) {
255 if(calDet) factor = calDet->GetValue(idet);
256 AliTRDCalROC *calRoc = fROC[idet];
257 if ( calRoc ){
258 AliTRDCalROC* outlierROC = 0;
259 if (outlierPad) outlierROC = outlierPad->GetCalROC(idet);
260 if(type == 0) arr[n] = calRoc->GetMedian(outlierROC)*factor;
261 else arr[n] = calRoc->GetMedian(outlierROC)+factor;
262 n++;
263 }
264 }
265 return TMath::Mean(n,arr);
266}
267
268//_____________________________________________________________________________
269Double_t AliTRDCalPad::GetLTM(Double_t *sigma, Double_t fraction
270 , const AliTRDCalDet *calDet, Int_t type
271 , AliTRDCalPad* outlierPad)
272{
273 //
274 // return mean of the LTM and sigma of all ROCs
275 // If calDet correct the CalROC from the detector coefficient
276 // type == 0 for gain and vdrift
277 // type == 1 for t0
278 //
279 Double_t factor = 0.0;
280 if(type == 0) factor = 1.0;
281 Double_t arrm[kNdet];
282 Double_t arrs[kNdet];
283 Double_t *sTemp=0x0;
284 Int_t n=0;
285
286 for (Int_t idet = 0; idet < kNdet; idet++) {
287 if(calDet) factor = calDet->GetValue(idet);
288 AliTRDCalROC *calRoc = fROC[idet];
289 if ( calRoc ){
290 if ( sigma ) sTemp=arrs+n;
291 AliTRDCalROC* outlierROC = 0;
292 if (outlierPad) outlierROC = outlierPad->GetCalROC(idet);
293 if(type == 0) arrm[n] = calRoc->GetLTM(sTemp,fraction, outlierROC)*factor;
294 else arrm[n] = calRoc->GetLTM(sTemp,fraction, outlierROC)+factor;
295 n++;
296 }
297 }
298 if ( sigma ) *sigma = TMath::Mean(n,arrs);
299 return TMath::Mean(n,arrm);
300}
301
302//_____________________________________________________________________________
303TH1F * AliTRDCalPad::MakeHisto1D(const AliTRDCalDet *calDet, Int_t typedet
304 , Float_t min, Float_t max,Int_t type)
305{
306 //
307 // make 1D histo
308 // type -1 = user defined range
309 // 0 = nsigma cut nsigma=min
310 // If calDet correct the CalROC from the detector coefficient
311 // typedet == 0 for gain and vdrift
312 // typedet == 1 for t0
313 //
314 Float_t kEpsilonr = 0.005;
315
316 Double_t factor = 0.0;
317 if(typedet == 0) factor = 1.0;
318
319 if (type>=0){
320 if (type==0){
321 // nsigma range
322 Float_t mean = GetMean(calDet,typedet);
323 Float_t sigma = 0.0;
324 if(GetRMS(calDet,typedet) > kEpsilonr) sigma = GetRMS(calDet,typedet);
325 else {
326 Double_t rms = 0.0;
327 sigma = GetMeanRMS(rms,calDet,typedet);
328 }
329 Float_t nsigma = TMath::Abs(min);
330 sigma *= nsigma;
331 if(sigma < kEpsilonr) sigma = kEpsilonr;
332 min = mean-sigma;
333 max = mean+sigma;
334 }
335 if (type==1){
336 // fixed range
337 Float_t mean = GetMedian(calDet,typedet);
338 Float_t delta = min;
339 min = mean-delta;
340 max = mean+delta;
341 }
342 if (type==2){
343 //
344 // LTM mean +- nsigma
345 //
346 Double_t sigma;
347 Float_t mean = GetLTM(&sigma,max,calDet,typedet);
348 sigma*=min;
349 if(sigma < kEpsilonr) sigma = kEpsilonr;
350 min = mean-sigma;
351 max = mean+sigma;
352 }
353 }
354 char name[1000];
355 sprintf(name,"%s Pad 1D",GetTitle());
356 TH1F * his = new TH1F(name,name,100, min,max);
357 for (Int_t idet = 0; idet < kNdet; idet++) {
358 if(calDet) factor = calDet->GetValue(idet);
359 if (fROC[idet]){
360 for (Int_t irow=0; irow<fROC[idet]->GetNrows(); irow++){
361 for (Int_t icol=0; icol<fROC[idet]->GetNcols(); icol++){
362 if(typedet == 0) his->Fill(fROC[idet]->GetValue(irow,icol)*factor);
363 else his->Fill(fROC[idet]->GetValue(irow,icol)+factor);
364 }
365 }
366 }
367 }
368 return his;
369}
370
371//_____________________________________________________________________________
372TH2F *AliTRDCalPad::MakeHisto2DSmPl(Int_t sm, Int_t pl, const AliTRDCalDet *calDet
373 , Int_t typedet, Float_t min, Float_t max,Int_t type)
374{
375 //
376 // Make 2D graph
377 // sm - supermodule number
378 // pl - plane number
379 // If calDet correct the CalROC from the detector coefficient
380 // typedet == 0 for gain and vdrift
381 // typedet == 1 for t0
382 //
383 gStyle->SetPalette(1);
384 Double_t factor = 0.0;
385 if(typedet == 0) factor = 1.0;
386
387 Float_t kEpsilon = 0.000000000001;
388 Float_t kEpsilonr = 0.005;
389
390 if (type>=0){
391 if (type==0){
392 // nsigma range
393 Float_t mean = GetMean(calDet,typedet);
394 Float_t sigma = 0.0;
395 if(GetRMS(calDet,typedet) > kEpsilonr) sigma = GetRMS(calDet,typedet);
396 else {
397 Double_t rms = 0.0;
398 sigma = GetMeanRMS(rms,calDet,typedet);
399 }
400 Float_t nsigma = TMath::Abs(min);
401 sigma *= nsigma;
402 if(sigma < kEpsilonr) sigma = kEpsilonr;
403 min = mean-sigma;
404 max = mean+sigma;
405 }
406 if (type==1){
407 // fixed range
408 Float_t mean = GetMedian(calDet,typedet);
409 Float_t delta = min;
410 min = mean-delta;
411 max = mean+delta;
412 }
413 if (type==2){
414 //
415 // LTM mean +- nsigma
416 //
417 Double_t sigma;
418 Float_t mean = GetLTM(&sigma,max,calDet,typedet);
419 sigma*=min;
420 if(sigma < kEpsilonr) sigma = kEpsilonr;
421 min = mean-sigma;
422 max = mean+sigma;
423 }
424 }
425
426 AliTRDpadPlane *padPlane0 = new AliTRDpadPlane(pl,0);
427 Double_t row0 = padPlane0->GetRow0();
428 Double_t col0 = padPlane0->GetCol0();
429
430 char name[1000];
431 sprintf(name,"%s Pad 2D sm %d pl %d",GetTitle(),sm,pl);
432 TH2F * his = new TH2F( name, name, 76,-TMath::Abs(row0),TMath::Abs(row0),144,-TMath::Abs(col0),TMath::Abs(col0));
433
434 // Where we begin
435 Int_t offsetsmpl = 30*sm+pl;
436
437
438 for (Int_t k = 0; k < kNcham; k++){
439 Int_t det = offsetsmpl+k*6;
440 if(calDet) factor = calDet->GetValue(det);
441 if (fROC[det]){
442 AliTRDCalROC * calRoc = fROC[det];
443 for (Int_t irow=0; irow<calRoc->GetNrows(); irow++){
444 for (Int_t icol=0; icol<calRoc->GetNcols(); icol++){
445 if (TMath::Abs(calRoc->GetValue(icol,irow))>kEpsilon){
446 Int_t binz = 0;
447 Int_t kb = kNcham-1-k;
448 if(kb > 2) binz = 16*(kb-1)+12+irow+1;
449 else binz = 16*kb+irow+1;
450 Int_t biny = icol+1;
451 Float_t value = calRoc->GetValue(icol,irow);
452 if(typedet == 0) his->SetBinContent(binz,biny,value*factor);
453 else his->SetBinContent(binz,biny,value+factor);
454 }
455 }
456 }
457 }
458 }
459 his->SetXTitle("z (cm)");
460 his->SetYTitle("y (cm)");
461 his->SetStats(0);
462 his->SetMaximum(max);
463 his->SetMinimum(min);
464 return his;
465}
466
467//_____________________________________________________________________________
468TH2F *AliTRDCalPad::MakeHisto2DCh(Int_t ch, const AliTRDCalDet *calDet, Int_t typedet
469 , Float_t min, Float_t max,Int_t type)
470{
471 //
472 // Make 2D graph mean value in z direction
473 // ch - chamber
474 // If calDet correct the CalROC from the detector coefficient
475 // typedet == 0 for gain and vdrift
476 // typedet == 1 for t0
477 //
478 gStyle->SetPalette(1);
479 Double_t factor = 0.0;
480 if(typedet == 0) factor = 1.0;
481
482 Float_t kEpsilonr = 0.005;
483
484 if (type>=0){
485 if (type==0){
486 // nsigma range
487 Float_t mean = GetMean(calDet,typedet);
488 Float_t sigma = 0.0;
489 if(GetRMS(calDet,typedet) > kEpsilonr) sigma = GetRMS(calDet,typedet);
490 else {
491 Double_t rms = 0.0;
492 sigma = GetMeanRMS(rms,calDet,typedet);
493 }
494 Float_t nsigma = TMath::Abs(min);
495 sigma *= nsigma;
496 if(sigma < kEpsilonr) sigma = kEpsilonr;
497 min = mean-sigma;
498 max = mean+sigma;
499 }
500 if (type==1){
501 // fixed range
502 Float_t mean = GetMedian(calDet,typedet);
503 Float_t delta = min;
504 min = mean-delta;
505 max = mean+delta;
506 }
507 if (type==2){
508 //
509 // LTM mean +- nsigma
510 //
511 Double_t sigma;
512 Float_t mean = GetLTM(&sigma,max,calDet,typedet);
513 sigma*=min;
514 if(sigma < kEpsilonr) sigma = kEpsilonr;
515 min = mean-sigma;
516 max = mean+sigma;
517 }
518 }
519
520 AliTRDgeometry *TRDgeo = new AliTRDgeometry();
521 TRDgeo->Init();
522
523 Float_t kEpsilon = 0.000000000001;
524
525 Double_t poslocal[3] = {0.0,0.0,0.0};
526 Double_t posglobal[3] = {0.0,0.0,0.0};
527
528 char name[1000];
529 sprintf(name,"%s Pad 2D ch %d",GetTitle(),ch);
530 TH2F * his = new TH2F( name, name, 400,-400.0,400.0,400,-400.0,400.0);
531
532 // Where we begin
533 Int_t offsetch = 6*ch;
534
535
536 for (Int_t isec = 0; isec < kNsect; isec++){
537 for(Int_t ipl = 0; ipl < kNplan; ipl++){
538 Int_t det = offsetch+isec*30+ipl;
539 if(calDet) factor = calDet->GetValue(det);
540 if (fROC[det]){
541 AliTRDCalROC * calRoc = fROC[det];
542 AliTRDpadPlane *padPlane = new AliTRDpadPlane(ipl,ch);
543 for (Int_t icol=0; icol<calRoc->GetNcols(); icol++){
544 poslocal[0] = TRDgeo->GetTime0(ipl);
545 poslocal[2] = padPlane->GetRowPos(0);
546 poslocal[1] = padPlane->GetColPos(icol);
547 TRDgeo->RotateBack(det,poslocal,posglobal);
548 Int_t binx = 1+TMath::Nint((posglobal[0]+400.0)*0.5);
549 Int_t biny = 1+TMath::Nint((posglobal[1]+400.0)*0.5);
550 Float_t value = 0.0;
551 Int_t nb = 0;
552 for (Int_t irow=0; irow<calRoc->GetNrows(); irow++){
553 if (TMath::Abs(calRoc->GetValue(icol,irow))>kEpsilon){
554 value += calRoc->GetValue(icol,irow);
555 nb++;
556 }
557 }
558 value = value/nb;
559 if(typedet == 0) his->SetBinContent(binx,biny,value*factor);
560 else his->SetBinContent(binx,biny,value+factor);
561 }
562 }
563 }
564 }
565 his->SetXTitle("x (cm)");
566 his->SetYTitle("y (cm)");
567 his->SetStats(0);
568 his->SetMaximum(max);
569 his->SetMinimum(min);
570 return his;
571}
572
573//_____________________________________________________________________________
574Bool_t AliTRDCalPad::Add(Float_t c1)
575{
576 //
577 // add constant for all channels of all ROCs
578 //
579
580 Bool_t result = kTRUE;
581 for (Int_t idet = 0; idet < kNdet; idet++) {
582 if (fROC[idet]){
583 if(!fROC[idet]->Add(c1)) result = kFALSE;
7754cd1f 584 }
585 }
4c87f26e 586 return result;
587}
588
589//_____________________________________________________________________________
590Bool_t AliTRDCalPad::Multiply(Float_t c1)
591{
592 //
593 // multiply constant for all channels of all ROCs
594 //
595 Bool_t result = kTRUE;
596 for (Int_t idet = 0; idet < kNdet; idet++) {
597 if (fROC[idet]){
598 if(!fROC[idet]->Multiply(c1)) result = kFALSE;
599 }
600 }
601 return result;
602}
2745a409 603
4c87f26e 604//_____________________________________________________________________________
605Bool_t AliTRDCalPad::Add(const AliTRDCalPad * pad, Double_t c1
606 , const AliTRDCalDet * calDet1, const AliTRDCalDet *calDet2
607 , Int_t type)
608{
609 //
610 // add calpad channel by channel multiplied by c1 - all ROCs
611 // If calDet1 and calDet2, the correct the CalROC from the detector coefficient
612 // then you have calDet1 and the calPad together
613 // calDet2 and pad together
614 // typedet == 0 for gain and vdrift
615 // typedet == 1 for t0
616 //
617 Float_t kEpsilon = 0.000000000001;
618
619 Double_t factor1 = 0.0;
620 Double_t factor2 = 0.0;
621 if(type == 0) {
622 factor1 = 1.0;
623 factor2 = 1.0;
624 }
625 Bool_t result = kTRUE;
626 for (Int_t idet = 0; idet < kNdet; idet++) {
627 if(calDet1) factor1 = calDet1->GetValue(idet);
628 if(calDet2) factor2 = calDet2->GetValue(idet);
629 if (fROC[idet]){
630 if(type == 0){
631 if(TMath::Abs(factor1) > kEpsilon){
632 if(!fROC[idet]->Add(pad->GetCalROC(idet),c1*factor2/factor1)) result = kFALSE;
633 }
634 else result = kFALSE;
635 }
636 else{
637 AliTRDCalROC *croc = new AliTRDCalROC((const AliTRDCalROC) *pad->GetCalROC(idet));
638 if(!croc->Add(factor2)) result = kFALSE;
639 if(!fROC[idet]->Add(croc,c1)) result = kFALSE;
640 }
641 }
642 }
643 return result;
7754cd1f 644}
645
4c87f26e 646//_____________________________________________________________________________
647Bool_t AliTRDCalPad::Multiply(const AliTRDCalPad * pad, const AliTRDCalDet * calDet1
648 , const AliTRDCalDet *calDet2, Int_t type)
649{
650 //
651 // multiply calpad channel by channel - all ROCs
652 // If calDet1 and calDet2, the correct the CalROC from the detector coefficient
653 // then you have calDet1 and the calPad together
654 // calDet2 and pad together
655 // typedet == 0 for gain and vdrift
656 // typedet == 1 for t0
657 //
658 Float_t kEpsilon = 0.000000000001;
659 Bool_t result = kTRUE;
660 Double_t factor1 = 0.0;
661 Double_t factor2 = 0.0;
662 if(type == 0){
663 factor1 = 1.0;
664 factor2 = 1.0;
665 }
666 for (Int_t idet = 0; idet < kNdet; idet++) {
667 if(calDet1) factor1 = calDet1->GetValue(idet);
668 if(calDet2) factor2 = calDet2->GetValue(idet);
669 if (fROC[idet]){
670 if(type == 0){
671 if(TMath::Abs(factor1) > kEpsilon){
672 AliTRDCalROC *croc = new AliTRDCalROC((const AliTRDCalROC) *pad->GetCalROC(idet));
673 if(!croc->Multiply(factor2)) result = kFALSE;
674 if(!fROC[idet]->Multiply(croc)) result = kFALSE;
675 }
676 else result = kFALSE;
677 }
678 else{
679 AliTRDCalROC *croc2 = new AliTRDCalROC((const AliTRDCalROC) *pad->GetCalROC(idet));
680 if(!croc2->Add(factor2)) result = kFALSE;
681 if(!fROC[idet]->Add(factor1)) result = kFALSE;
682 if(!fROC[idet]->Multiply(croc2)) result = kFALSE;
683 if(!fROC[idet]->Add(-factor1)) result = kFALSE;
684 }
685 }
686 }
687 return result;
688}
689
690//_____________________________________________________________________________
691Bool_t AliTRDCalPad::Divide(const AliTRDCalPad * pad, const AliTRDCalDet * calDet1
692 , const AliTRDCalDet *calDet2, Int_t type)
693{
694 //
695 // divide calpad channel by channel - all ROCs
696 // If calDet1 and calDet2, the correct the CalROC from the detector coefficient
697 // then you have calDet1 and the calPad together
698 // calDet2 and pad together
699 // typedet == 0 for gain and vdrift
700 // typedet == 1 for t0
701 //
702 Float_t kEpsilon = 0.000000000001;
703 Bool_t result = kTRUE;
704 Double_t factor1 = 0.0;
705 Double_t factor2 = 0.0;
706 if(type == 0){
707 factor1 = 1.0;
708 factor2 = 1.0;
709 }
710 for (Int_t idet = 0; idet < kNdet; idet++) {
711 if(calDet1) factor1 = calDet1->GetValue(idet);
712 if(calDet2) factor2 = calDet2->GetValue(idet);
713 if (fROC[idet]){
714 if(type == 0){
715 if(TMath::Abs(factor1) > kEpsilon){
716 AliTRDCalROC *croc = new AliTRDCalROC((const AliTRDCalROC) *pad->GetCalROC(idet));
717 if(!croc->Multiply(factor2)) result = kFALSE;
718 if(!fROC[idet]->Divide(croc)) result = kFALSE;
719 }
720 else result = kFALSE;
721 }
722 else{
723 AliTRDCalROC *croc2 = new AliTRDCalROC((const AliTRDCalROC) *pad->GetCalROC(idet));
724 if(!croc2->Add(factor2)) result = kFALSE;
725 if(!fROC[idet]->Add(factor1)) result = kFALSE;
726 if(!fROC[idet]->Divide(croc2)) result = kFALSE;
727 if(!fROC[idet]->Add(-factor1)) result = kFALSE;
728 }
729 }
730 }
731 return result;
732}