]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/Cal/AliTRDCalPad.cxx
Include informations from rstate module
[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
7dcf6933 153//_____________________________________________________________________________
154void AliTRDCalPad::SetCalROC(Int_t det, AliTRDCalROC* calroc)
155{
156 //
157 // Set the AliTRDCalROC to this one
158 //
159
160 if (!calroc) return;
161 if (fROC[det]) {
162 for(Int_t icol = 0; icol < calroc->GetNcols(); icol++){
163 for(Int_t irow = 0; irow < calroc->GetNrows(); irow++){
164 fROC[det]->SetValue(icol,irow,calroc->GetValue(icol,irow));
165 }
166 }
167 }
168
169}
4c87f26e 170//_____________________________________________________________________________
171Double_t AliTRDCalPad::GetMeanRMS(Double_t &rms, const AliTRDCalDet *calDet, Int_t type)
172{
173 //
174 // Calculate mean an RMS of all rocs
175 // If calDet correct the CalROC from the detector coefficient
176 // type == 0 for gain and vdrift
177 // type == 1 for t0
178 //
179 Double_t factor = 0.0;
180 if(type == 0) factor = 1.0;
181 Double_t sum = 0, sum2 = 0, n=0, val=0;
182 for (Int_t idet = 0; idet < kNdet; idet++) {
183 if(calDet) factor = calDet->GetValue(idet);
184 AliTRDCalROC *calRoc = fROC[idet];
185 if ( calRoc ){
186 for (Int_t irow=0; irow<calRoc->GetNrows(); irow++){
187 for (Int_t icol=0; icol<calRoc->GetNcols(); icol++){
188 if(type == 0) val = calRoc->GetValue(icol,irow)*factor;
189 else val = calRoc->GetValue(icol,irow)+factor;
190 sum+=val;
191 sum2+=val*val;
192 n++;
193 }
194 }
195 }
196 }
197 Double_t n1 = 1./n;
198 Double_t mean = sum*n1;
199 rms = TMath::Sqrt(TMath::Abs(sum2*n1-mean*mean));
200 return mean;
201}
202
203//_____________________________________________________________________________
204Double_t AliTRDCalPad::GetMean(const AliTRDCalDet *calDet, Int_t type, AliTRDCalPad* outlierPad)
205{
206 //
207 // return mean of the mean of all ROCs
208 // If calDet correct the CalROC from the detector coefficient
209 // type == 0 for gain and vdrift
210 // type == 1 for t0
211 //
212 Double_t factor = 0.0;
213 if(type == 0) factor = 1.0;
214 Double_t arr[kNdet];
215 Int_t n=0;
216 for (Int_t idet = 0; idet < kNdet; idet++) {
217 if(calDet) factor = calDet->GetValue(idet);
218 AliTRDCalROC *calRoc = fROC[idet];
219 if ( calRoc ){
220 AliTRDCalROC* outlierROC = 0;
221 if (outlierPad) outlierROC = outlierPad->GetCalROC(idet);
222 if(type == 0) arr[n] = calRoc->GetMean(outlierROC)*factor;
223 else arr[n] = calRoc->GetMean(outlierROC)+factor;
224 n++;
225 }
226 }
227 return TMath::Mean(n,arr);
228}
229
230//_____________________________________________________________________________
231Double_t AliTRDCalPad::GetRMS(const AliTRDCalDet *calDet, Int_t type, AliTRDCalPad* outlierPad)
232{
233 //
234 // return mean of the RMS of all ROCs
235 // If calDet correct the CalROC from the detector coefficient
236 // type == 0 for gain and vdrift
237 // type == 1 for t0
238 //
239 Double_t factor = 0.0;
240 if(type == 0) factor = 1.0;
241 Double_t arr[kNdet];
242 Int_t n=0;
243 for (Int_t idet = 0; idet < kNdet; idet++) {
244 if(calDet) factor = calDet->GetValue(idet);
245 AliTRDCalROC *calRoc = fROC[idet];
246 if ( calRoc ){
247 AliTRDCalROC* outlierROC = 0;
248 if (outlierPad) outlierROC = outlierPad->GetCalROC(idet);
249 if(type == 0) arr[n] = calRoc->GetRMS(outlierROC)*factor;
250 else arr[n] = calRoc->GetRMS(outlierROC);
251 n++;
252 }
253 }
254 return TMath::Mean(n,arr);
255}
256
257//_____________________________________________________________________________
258Double_t AliTRDCalPad::GetMedian(const AliTRDCalDet *calDet, Int_t type
259 , AliTRDCalPad* outlierPad)
260{
261 //
262 // return mean of the median of all ROCs
263 // If AliTRDCalDet, the correct the CalROC from the detector coefficient
264 // type == 0 for gain and vdrift
265 // type == 1 for t0
266 //
267 Double_t factor = 0.0;
268 if(type == 0) factor = 1.0;
269 Double_t arr[kNdet];
270 Int_t n=0;
271 for (Int_t idet = 0; idet < kNdet; idet++) {
272 if(calDet) factor = calDet->GetValue(idet);
273 AliTRDCalROC *calRoc = fROC[idet];
274 if ( calRoc ){
275 AliTRDCalROC* outlierROC = 0;
276 if (outlierPad) outlierROC = outlierPad->GetCalROC(idet);
277 if(type == 0) arr[n] = calRoc->GetMedian(outlierROC)*factor;
278 else arr[n] = calRoc->GetMedian(outlierROC)+factor;
279 n++;
280 }
281 }
282 return TMath::Mean(n,arr);
283}
284
285//_____________________________________________________________________________
286Double_t AliTRDCalPad::GetLTM(Double_t *sigma, Double_t fraction
287 , const AliTRDCalDet *calDet, Int_t type
288 , AliTRDCalPad* outlierPad)
289{
290 //
291 // return mean of the LTM and sigma of all ROCs
292 // If calDet correct the CalROC from the detector coefficient
293 // type == 0 for gain and vdrift
294 // type == 1 for t0
295 //
296 Double_t factor = 0.0;
297 if(type == 0) factor = 1.0;
298 Double_t arrm[kNdet];
299 Double_t arrs[kNdet];
300 Double_t *sTemp=0x0;
301 Int_t n=0;
302
303 for (Int_t idet = 0; idet < kNdet; idet++) {
304 if(calDet) factor = calDet->GetValue(idet);
305 AliTRDCalROC *calRoc = fROC[idet];
306 if ( calRoc ){
307 if ( sigma ) sTemp=arrs+n;
308 AliTRDCalROC* outlierROC = 0;
309 if (outlierPad) outlierROC = outlierPad->GetCalROC(idet);
310 if(type == 0) arrm[n] = calRoc->GetLTM(sTemp,fraction, outlierROC)*factor;
311 else arrm[n] = calRoc->GetLTM(sTemp,fraction, outlierROC)+factor;
312 n++;
313 }
314 }
315 if ( sigma ) *sigma = TMath::Mean(n,arrs);
316 return TMath::Mean(n,arrm);
317}
318
319//_____________________________________________________________________________
320TH1F * AliTRDCalPad::MakeHisto1D(const AliTRDCalDet *calDet, Int_t typedet
321 , Float_t min, Float_t max,Int_t type)
322{
323 //
324 // make 1D histo
325 // type -1 = user defined range
326 // 0 = nsigma cut nsigma=min
327 // If calDet correct the CalROC from the detector coefficient
328 // typedet == 0 for gain and vdrift
329 // typedet == 1 for t0
330 //
331 Float_t kEpsilonr = 0.005;
332
333 Double_t factor = 0.0;
334 if(typedet == 0) factor = 1.0;
335
336 if (type>=0){
337 if (type==0){
338 // nsigma range
339 Float_t mean = GetMean(calDet,typedet);
340 Float_t sigma = 0.0;
341 if(GetRMS(calDet,typedet) > kEpsilonr) sigma = GetRMS(calDet,typedet);
342 else {
343 Double_t rms = 0.0;
344 sigma = GetMeanRMS(rms,calDet,typedet);
345 }
346 Float_t nsigma = TMath::Abs(min);
347 sigma *= nsigma;
348 if(sigma < kEpsilonr) sigma = kEpsilonr;
349 min = mean-sigma;
350 max = mean+sigma;
351 }
352 if (type==1){
353 // fixed range
354 Float_t mean = GetMedian(calDet,typedet);
355 Float_t delta = min;
356 min = mean-delta;
357 max = mean+delta;
358 }
359 if (type==2){
360 //
361 // LTM mean +- nsigma
362 //
363 Double_t sigma;
364 Float_t mean = GetLTM(&sigma,max,calDet,typedet);
365 sigma*=min;
366 if(sigma < kEpsilonr) sigma = kEpsilonr;
367 min = mean-sigma;
368 max = mean+sigma;
369 }
370 }
371 char name[1000];
372 sprintf(name,"%s Pad 1D",GetTitle());
373 TH1F * his = new TH1F(name,name,100, min,max);
374 for (Int_t idet = 0; idet < kNdet; idet++) {
375 if(calDet) factor = calDet->GetValue(idet);
376 if (fROC[idet]){
377 for (Int_t irow=0; irow<fROC[idet]->GetNrows(); irow++){
378 for (Int_t icol=0; icol<fROC[idet]->GetNcols(); icol++){
379 if(typedet == 0) his->Fill(fROC[idet]->GetValue(irow,icol)*factor);
380 else his->Fill(fROC[idet]->GetValue(irow,icol)+factor);
381 }
382 }
383 }
384 }
385 return his;
386}
387
388//_____________________________________________________________________________
389TH2F *AliTRDCalPad::MakeHisto2DSmPl(Int_t sm, Int_t pl, const AliTRDCalDet *calDet
390 , Int_t typedet, Float_t min, Float_t max,Int_t type)
391{
392 //
393 // Make 2D graph
394 // sm - supermodule number
395 // pl - plane number
396 // If calDet correct the CalROC from the detector coefficient
397 // typedet == 0 for gain and vdrift
398 // typedet == 1 for t0
399 //
400 gStyle->SetPalette(1);
401 Double_t factor = 0.0;
402 if(typedet == 0) factor = 1.0;
403
404 Float_t kEpsilon = 0.000000000001;
405 Float_t kEpsilonr = 0.005;
406
015cd5ba 407 AliTRDgeometry *trdGeo = new AliTRDgeometry();
408
4c87f26e 409 if (type>=0){
410 if (type==0){
411 // nsigma range
412 Float_t mean = GetMean(calDet,typedet);
413 Float_t sigma = 0.0;
414 if(GetRMS(calDet,typedet) > kEpsilonr) sigma = GetRMS(calDet,typedet);
415 else {
416 Double_t rms = 0.0;
417 sigma = GetMeanRMS(rms,calDet,typedet);
418 }
419 Float_t nsigma = TMath::Abs(min);
420 sigma *= nsigma;
421 if(sigma < kEpsilonr) sigma = kEpsilonr;
422 min = mean-sigma;
423 max = mean+sigma;
424 }
425 if (type==1){
426 // fixed range
427 Float_t mean = GetMedian(calDet,typedet);
428 Float_t delta = min;
429 min = mean-delta;
430 max = mean+delta;
431 }
432 if (type==2){
433 //
434 // LTM mean +- nsigma
435 //
436 Double_t sigma;
437 Float_t mean = GetLTM(&sigma,max,calDet,typedet);
438 sigma*=min;
439 if(sigma < kEpsilonr) sigma = kEpsilonr;
440 min = mean-sigma;
441 max = mean+sigma;
442 }
443 }
444
015cd5ba 445 AliTRDpadPlane *padPlane0 = trdGeo->GetPadPlane(pl,0);
4c87f26e 446 Double_t row0 = padPlane0->GetRow0();
447 Double_t col0 = padPlane0->GetCol0();
448
449 char name[1000];
450 sprintf(name,"%s Pad 2D sm %d pl %d",GetTitle(),sm,pl);
451 TH2F * his = new TH2F( name, name, 76,-TMath::Abs(row0),TMath::Abs(row0),144,-TMath::Abs(col0),TMath::Abs(col0));
452
453 // Where we begin
454 Int_t offsetsmpl = 30*sm+pl;
455
456
457 for (Int_t k = 0; k < kNcham; k++){
458 Int_t det = offsetsmpl+k*6;
459 if(calDet) factor = calDet->GetValue(det);
460 if (fROC[det]){
461 AliTRDCalROC * calRoc = fROC[det];
462 for (Int_t irow=0; irow<calRoc->GetNrows(); irow++){
463 for (Int_t icol=0; icol<calRoc->GetNcols(); icol++){
464 if (TMath::Abs(calRoc->GetValue(icol,irow))>kEpsilon){
465 Int_t binz = 0;
466 Int_t kb = kNcham-1-k;
413153cb 467 Int_t krow = calRoc->GetNrows()-1-irow;
468 Int_t kcol = calRoc->GetNcols()-1-icol;
469 if(kb > 2) binz = 16*(kb-1)+12+krow+1;
470 else binz = 16*kb+krow+1;
471 Int_t biny = kcol+1;
4c87f26e 472 Float_t value = calRoc->GetValue(icol,irow);
473 if(typedet == 0) his->SetBinContent(binz,biny,value*factor);
474 else his->SetBinContent(binz,biny,value+factor);
475 }
476 }
477 }
478 }
479 }
480 his->SetXTitle("z (cm)");
481 his->SetYTitle("y (cm)");
482 his->SetStats(0);
483 his->SetMaximum(max);
484 his->SetMinimum(min);
015cd5ba 485 delete trdGeo;
4c87f26e 486 return his;
487}
488
489//_____________________________________________________________________________
490TH2F *AliTRDCalPad::MakeHisto2DCh(Int_t ch, const AliTRDCalDet *calDet, Int_t typedet
491 , Float_t min, Float_t max,Int_t type)
492{
493 //
494 // Make 2D graph mean value in z direction
495 // ch - chamber
496 // If calDet correct the CalROC from the detector coefficient
497 // typedet == 0 for gain and vdrift
498 // typedet == 1 for t0
499 //
500 gStyle->SetPalette(1);
501 Double_t factor = 0.0;
502 if(typedet == 0) factor = 1.0;
503
504 Float_t kEpsilonr = 0.005;
505
506 if (type>=0){
507 if (type==0){
508 // nsigma range
509 Float_t mean = GetMean(calDet,typedet);
510 Float_t sigma = 0.0;
511 if(GetRMS(calDet,typedet) > kEpsilonr) sigma = GetRMS(calDet,typedet);
512 else {
513 Double_t rms = 0.0;
514 sigma = GetMeanRMS(rms,calDet,typedet);
515 }
516 Float_t nsigma = TMath::Abs(min);
517 sigma *= nsigma;
518 if(sigma < kEpsilonr) sigma = kEpsilonr;
519 min = mean-sigma;
520 max = mean+sigma;
521 }
522 if (type==1){
523 // fixed range
524 Float_t mean = GetMedian(calDet,typedet);
525 Float_t delta = min;
526 min = mean-delta;
527 max = mean+delta;
528 }
529 if (type==2){
530 //
531 // LTM mean +- nsigma
532 //
533 Double_t sigma;
534 Float_t mean = GetLTM(&sigma,max,calDet,typedet);
535 sigma*=min;
536 if(sigma < kEpsilonr) sigma = kEpsilonr;
537 min = mean-sigma;
538 max = mean+sigma;
539 }
540 }
541
015cd5ba 542 AliTRDgeometry *trdGeo = new AliTRDgeometry();
4c87f26e 543
544 Float_t kEpsilon = 0.000000000001;
545
546 Double_t poslocal[3] = {0.0,0.0,0.0};
547 Double_t posglobal[3] = {0.0,0.0,0.0};
548
549 char name[1000];
550 sprintf(name,"%s Pad 2D ch %d",GetTitle(),ch);
551 TH2F * his = new TH2F( name, name, 400,-400.0,400.0,400,-400.0,400.0);
552
553 // Where we begin
554 Int_t offsetch = 6*ch;
555
556
557 for (Int_t isec = 0; isec < kNsect; isec++){
558 for(Int_t ipl = 0; ipl < kNplan; ipl++){
559 Int_t det = offsetch+isec*30+ipl;
560 if(calDet) factor = calDet->GetValue(det);
561 if (fROC[det]){
562 AliTRDCalROC * calRoc = fROC[det];
015cd5ba 563 AliTRDpadPlane *padPlane = trdGeo->GetPadPlane(ipl,ch);
4c87f26e 564 for (Int_t icol=0; icol<calRoc->GetNcols(); icol++){
015cd5ba 565 poslocal[0] = trdGeo->GetTime0(ipl);
4c87f26e 566 poslocal[2] = padPlane->GetRowPos(0);
567 poslocal[1] = padPlane->GetColPos(icol);
015cd5ba 568 trdGeo->RotateBack(det,poslocal,posglobal);
4c87f26e 569 Int_t binx = 1+TMath::Nint((posglobal[0]+400.0)*0.5);
570 Int_t biny = 1+TMath::Nint((posglobal[1]+400.0)*0.5);
571 Float_t value = 0.0;
572 Int_t nb = 0;
573 for (Int_t irow=0; irow<calRoc->GetNrows(); irow++){
574 if (TMath::Abs(calRoc->GetValue(icol,irow))>kEpsilon){
575 value += calRoc->GetValue(icol,irow);
576 nb++;
577 }
578 }
579 value = value/nb;
580 if(typedet == 0) his->SetBinContent(binx,biny,value*factor);
581 else his->SetBinContent(binx,biny,value+factor);
582 }
583 }
584 }
585 }
586 his->SetXTitle("x (cm)");
587 his->SetYTitle("y (cm)");
588 his->SetStats(0);
589 his->SetMaximum(max);
590 his->SetMinimum(min);
015cd5ba 591 delete trdGeo;
4c87f26e 592 return his;
593}
594
595//_____________________________________________________________________________
596Bool_t AliTRDCalPad::Add(Float_t c1)
597{
598 //
599 // add constant for all channels of all ROCs
600 //
601
602 Bool_t result = kTRUE;
603 for (Int_t idet = 0; idet < kNdet; idet++) {
604 if (fROC[idet]){
605 if(!fROC[idet]->Add(c1)) result = kFALSE;
7754cd1f 606 }
607 }
4c87f26e 608 return result;
609}
610
611//_____________________________________________________________________________
612Bool_t AliTRDCalPad::Multiply(Float_t c1)
613{
614 //
615 // multiply constant for all channels of all ROCs
616 //
617 Bool_t result = kTRUE;
618 for (Int_t idet = 0; idet < kNdet; idet++) {
619 if (fROC[idet]){
620 if(!fROC[idet]->Multiply(c1)) result = kFALSE;
621 }
622 }
623 return result;
624}
2745a409 625
4c87f26e 626//_____________________________________________________________________________
627Bool_t AliTRDCalPad::Add(const AliTRDCalPad * pad, Double_t c1
628 , const AliTRDCalDet * calDet1, const AliTRDCalDet *calDet2
629 , Int_t type)
630{
631 //
632 // add calpad channel by channel multiplied by c1 - all ROCs
633 // If calDet1 and calDet2, the correct the CalROC from the detector coefficient
634 // then you have calDet1 and the calPad together
635 // calDet2 and pad together
636 // typedet == 0 for gain and vdrift
637 // typedet == 1 for t0
638 //
639 Float_t kEpsilon = 0.000000000001;
640
641 Double_t factor1 = 0.0;
642 Double_t factor2 = 0.0;
643 if(type == 0) {
644 factor1 = 1.0;
645 factor2 = 1.0;
646 }
647 Bool_t result = kTRUE;
648 for (Int_t idet = 0; idet < kNdet; idet++) {
649 if(calDet1) factor1 = calDet1->GetValue(idet);
650 if(calDet2) factor2 = calDet2->GetValue(idet);
651 if (fROC[idet]){
652 if(type == 0){
653 if(TMath::Abs(factor1) > kEpsilon){
654 if(!fROC[idet]->Add(pad->GetCalROC(idet),c1*factor2/factor1)) result = kFALSE;
655 }
656 else result = kFALSE;
657 }
658 else{
659 AliTRDCalROC *croc = new AliTRDCalROC((const AliTRDCalROC) *pad->GetCalROC(idet));
660 if(!croc->Add(factor2)) result = kFALSE;
661 if(!fROC[idet]->Add(croc,c1)) result = kFALSE;
662 }
663 }
664 }
665 return result;
7754cd1f 666}
667
4c87f26e 668//_____________________________________________________________________________
669Bool_t AliTRDCalPad::Multiply(const AliTRDCalPad * pad, const AliTRDCalDet * calDet1
670 , const AliTRDCalDet *calDet2, Int_t type)
671{
672 //
673 // multiply calpad channel by channel - all ROCs
674 // If calDet1 and calDet2, the correct the CalROC from the detector coefficient
675 // then you have calDet1 and the calPad together
676 // calDet2 and pad together
677 // typedet == 0 for gain and vdrift
678 // typedet == 1 for t0
679 //
680 Float_t kEpsilon = 0.000000000001;
681 Bool_t result = kTRUE;
682 Double_t factor1 = 0.0;
683 Double_t factor2 = 0.0;
684 if(type == 0){
685 factor1 = 1.0;
686 factor2 = 1.0;
687 }
688 for (Int_t idet = 0; idet < kNdet; idet++) {
689 if(calDet1) factor1 = calDet1->GetValue(idet);
690 if(calDet2) factor2 = calDet2->GetValue(idet);
691 if (fROC[idet]){
692 if(type == 0){
693 if(TMath::Abs(factor1) > kEpsilon){
694 AliTRDCalROC *croc = new AliTRDCalROC((const AliTRDCalROC) *pad->GetCalROC(idet));
695 if(!croc->Multiply(factor2)) result = kFALSE;
696 if(!fROC[idet]->Multiply(croc)) result = kFALSE;
697 }
698 else result = kFALSE;
699 }
700 else{
701 AliTRDCalROC *croc2 = new AliTRDCalROC((const AliTRDCalROC) *pad->GetCalROC(idet));
702 if(!croc2->Add(factor2)) result = kFALSE;
703 if(!fROC[idet]->Add(factor1)) result = kFALSE;
704 if(!fROC[idet]->Multiply(croc2)) result = kFALSE;
705 if(!fROC[idet]->Add(-factor1)) result = kFALSE;
706 }
707 }
708 }
709 return result;
710}
711
712//_____________________________________________________________________________
713Bool_t AliTRDCalPad::Divide(const AliTRDCalPad * pad, const AliTRDCalDet * calDet1
714 , const AliTRDCalDet *calDet2, Int_t type)
715{
716 //
717 // divide calpad channel by channel - all ROCs
718 // If calDet1 and calDet2, the correct the CalROC from the detector coefficient
719 // then you have calDet1 and the calPad together
720 // calDet2 and pad together
721 // typedet == 0 for gain and vdrift
722 // typedet == 1 for t0
723 //
724 Float_t kEpsilon = 0.000000000001;
725 Bool_t result = kTRUE;
726 Double_t factor1 = 0.0;
727 Double_t factor2 = 0.0;
728 if(type == 0){
729 factor1 = 1.0;
730 factor2 = 1.0;
731 }
732 for (Int_t idet = 0; idet < kNdet; idet++) {
733 if(calDet1) factor1 = calDet1->GetValue(idet);
734 if(calDet2) factor2 = calDet2->GetValue(idet);
735 if (fROC[idet]){
736 if(type == 0){
737 if(TMath::Abs(factor1) > kEpsilon){
738 AliTRDCalROC *croc = new AliTRDCalROC((const AliTRDCalROC) *pad->GetCalROC(idet));
739 if(!croc->Multiply(factor2)) result = kFALSE;
740 if(!fROC[idet]->Divide(croc)) result = kFALSE;
741 }
742 else result = kFALSE;
743 }
744 else{
745 AliTRDCalROC *croc2 = new AliTRDCalROC((const AliTRDCalROC) *pad->GetCalROC(idet));
746 if(!croc2->Add(factor2)) result = kFALSE;
747 if(!fROC[idet]->Add(factor1)) result = kFALSE;
748 if(!fROC[idet]->Divide(croc2)) result = kFALSE;
749 if(!fROC[idet]->Add(-factor1)) result = kFALSE;
750 }
751 }
752 }
753 return result;
754}