1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // TRD calibration class for parameters which saved per detector //
22 ///////////////////////////////////////////////////////////////////////////////
29 #include "AliTRDCalDet.h"
30 #include "AliTRDgeometry.h"
31 #include "AliMathBase.h"
32 #include "AliTRDpadPlane.h"
34 ClassImp(AliTRDCalDet)
36 //_____________________________________________________________________________
37 AliTRDCalDet::AliTRDCalDet():TNamed()
40 // AliTRDCalDet default constructor
43 for (Int_t idet = 0; idet < kNdet; idet++) {
49 //_____________________________________________________________________________
50 AliTRDCalDet::AliTRDCalDet(const Text_t *name, const Text_t *title)
54 // AliTRDCalDet constructor
57 for (Int_t idet = 0; idet < kNdet; idet++) {
63 //_____________________________________________________________________________
64 AliTRDCalDet::AliTRDCalDet(const AliTRDCalDet &c):TNamed(c)
67 // AliTRDCalDet copy constructor
70 ((AliTRDCalDet &) c).Copy(*this);
74 ///_____________________________________________________________________________
75 AliTRDCalDet::~AliTRDCalDet()
78 // AliTRDCalDet destructor
83 //_____________________________________________________________________________
84 AliTRDCalDet &AliTRDCalDet::operator=(const AliTRDCalDet &c)
87 // Assignment operator
90 if (this != &c) ((AliTRDCalDet &) c).Copy(*this);
95 //_____________________________________________________________________________
96 void AliTRDCalDet::Copy(TObject &c) const
102 for (Int_t idet = 0; idet < kNdet; idet++) {
103 ((AliTRDCalDet &) c).fData[idet] = fData[idet];
110 //___________________________________________________________________________________
111 Double_t AliTRDCalDet::GetMean(AliTRDCalDet* outlierDet)
114 // Calculate the mean
117 if (!outlierDet) return TMath::Mean(kNdet,fData);
118 Double_t *ddata = new Double_t[kNdet];
120 for (Int_t i=0;i<kNdet;i++) {
121 if (!(outlierDet->GetValue(i))) {
122 ddata[NPoints]= fData[NPoints];
126 Double_t mean = TMath::Mean(NPoints,ddata);
131 //_______________________________________________________________________________________
132 Double_t AliTRDCalDet::GetMedian(AliTRDCalDet* outlierDet)
135 // Calculate the median
138 if (!outlierDet) return (Double_t) TMath::Median(kNdet,fData);
139 Double_t *ddata = new Double_t[kNdet];
141 for (Int_t i=0;i<kNdet;i++) {
142 if (!(outlierDet->GetValue(i))) {
143 ddata[NPoints]= fData[NPoints];
147 Double_t mean = TMath::Median(NPoints,ddata);
153 //____________________________________________________________________________________________
154 Double_t AliTRDCalDet::GetRMS(AliTRDCalDet* outlierDet)
160 if (!outlierDet) return TMath::RMS(kNdet,fData);
161 Double_t *ddata = new Double_t[kNdet];
163 for (Int_t i=0;i<kNdet;i++) {
164 if (!(outlierDet->GetValue(i))) {
165 ddata[NPoints]= fData[NPoints];
169 Double_t mean = TMath::RMS(NPoints,ddata);
174 //______________________________________________________________________________________________
175 Double_t AliTRDCalDet::GetLTM(Double_t *sigma, Double_t fraction, AliTRDCalDet* outlierDet)
178 // Calculate LTM mean and sigma
181 Double_t *ddata = new Double_t[kNdet];
182 Double_t mean=0, lsigma=0;
184 for (Int_t i=0;i<kNdet;i++) {
185 if (!outlierDet || !(outlierDet->GetValue(i))) {
186 ddata[NPoints]= fData[NPoints];
190 Int_t hh = TMath::Min(TMath::Nint(fraction *NPoints), Int_t(NPoints));
191 AliMathBase::EvaluateUni(NPoints,ddata, mean, lsigma, hh);
192 if (sigma) *sigma=lsigma;
197 //_________________________________________________________________________
198 TH1F * AliTRDCalDet::MakeHisto1Distribution(Float_t min, Float_t max,Int_t type)
202 // type -1 = user defined range
203 // 0 = nsigma cut nsigma=min
204 // 1 = delta cut around median delta=min
210 Float_t mean = GetMean();
211 Float_t sigma = GetRMS();
212 Float_t nsigma = TMath::Abs(min);
213 min = mean-nsigma*sigma;
214 max = mean+nsigma*sigma;
218 Float_t mean = GetMedian();
225 // LTM mean +- nsigma
228 Float_t mean = GetLTM(&sigma,max);
235 sprintf(name,"%s CalDet 1Distribution",GetTitle());
236 TH1F * his = new TH1F(name,name,100, min,max);
237 for (Int_t idet=0; idet<kNdet; idet++){
238 his->Fill(GetValue(idet));
243 //________________________________________________________________________________
244 TH1F * AliTRDCalDet::MakeHisto1DAsFunctionOfDet(Float_t min, Float_t max,Int_t type)
248 // type -1 = user defined range
249 // 0 = nsigma cut nsigma=min
250 // 1 = delta cut around median delta=min
256 Float_t mean = GetMean();
257 Float_t sigma = GetRMS();
258 Float_t nsigma = TMath::Abs(min);
259 min = mean-nsigma*sigma;
260 max = mean+nsigma*sigma;
264 Float_t mean = GetMedian();
271 Float_t mean = GetLTM(&sigma,max);
280 sprintf(name,"%s CalDet as function of det",GetTitle());
281 TH1F * his = new TH1F(name,name,kNdet, 0, kNdet);
282 for(Int_t det = 0; det< kNdet; det++){
283 his->Fill(det+0.5,GetValue(det));
286 his->SetMaximum(max);
287 his->SetMinimum(min);
291 //_____________________________________________________________________________
292 TH2F *AliTRDCalDet::MakeHisto2DCh(Int_t ch, Float_t min, Float_t max, Int_t type)
297 // type -1 = user defined range
298 // 0 = nsigma cut nsigma=min
299 // 1 = delta cut around median delta=min
302 gStyle->SetPalette(1);
306 Float_t mean = GetMean();
307 Float_t sigma = GetRMS();
308 Float_t nsigma = TMath::Abs(min);
309 min = mean-nsigma*sigma;
310 max = mean+nsigma*sigma;
314 Float_t mean = GetMedian();
321 Float_t mean = GetLTM(&sigma,max);
329 AliTRDgeometry *TRDgeo = new AliTRDgeometry();
333 Double_t poslocal[3] = {0.0,0.0,0.0};
334 Double_t posglobal[3] = {0.0,0.0,0.0};
337 sprintf(name,"%s CalDet 2D ch %d",GetTitle(),ch);
338 TH2F * his = new TH2F(name, name, 400,-400.0,400.0,400,-400.0,400.0);
341 Int_t offsetch = 6*ch;
344 for (Int_t isec = 0; isec < kNsect; isec++){
345 for(Int_t ipl = 0; ipl < kNplan; ipl++){
346 Int_t det = offsetch+isec*30+ipl;
347 AliTRDpadPlane *padPlane = new AliTRDpadPlane(ipl,ch);
348 for (Int_t icol=0; icol<padPlane->GetNcols(); icol++){
349 poslocal[0] = TRDgeo->GetTime0(ipl);
350 poslocal[2] = padPlane->GetRowPos(0);
351 poslocal[1] = padPlane->GetColPos(icol);
352 TRDgeo->RotateBack(det,poslocal,posglobal);
353 Int_t binx = 1+TMath::Nint((posglobal[0]+400.0)*0.5);
354 Int_t biny = 1+TMath::Nint((posglobal[1]+400.0)*0.5);
355 his->SetBinContent(binx,biny,fData[det]);
359 his->SetXTitle("x (cm)");
360 his->SetYTitle("y (cm)");
362 his->SetMaximum(max);
363 his->SetMinimum(min);
367 //_____________________________________________________________________________
368 TH2F *AliTRDCalDet::MakeHisto2DSmPl(Int_t sm, Int_t pl, Float_t min, Float_t max, Int_t type)
372 // sm - supermodule number
374 // type -1 = user defined range
375 // 0 = nsigma cut nsigma=min
376 // 1 = delta cut around median delta=min
379 gStyle->SetPalette(1);
383 Float_t mean = GetMean();
384 Float_t sigma = GetRMS();
385 Float_t nsigma = TMath::Abs(min);
386 min = mean-nsigma*sigma;
387 max = mean+nsigma*sigma;
391 Float_t mean = GetMedian();
398 Float_t mean = GetLTM(&sigma,max);
406 AliTRDpadPlane *padPlane0 = new AliTRDpadPlane(pl,0);
407 Double_t row0 = padPlane0->GetRow0();
408 Double_t col0 = padPlane0->GetCol0();
412 sprintf(name,"%s CalDet 2D sm %d and pl %d",GetTitle(),sm,pl);
413 TH2F * his = new TH2F( name, name, 5, -TMath::Abs(row0), TMath::Abs(row0)
414 , 4,-2*TMath::Abs(col0),2*TMath::Abs(col0));
417 Int_t offsetsmpl = 30*sm+pl;
420 for (Int_t k = 0; k < kNcham; k++){
421 Int_t det = offsetsmpl+k*6;
422 Int_t kb = kNcham-1-k;
423 his->SetBinContent(kb+1,2,fData[det]);
424 his->SetBinContent(kb+1,3,fData[det]);
426 his->SetXTitle("z (cm)");
427 his->SetYTitle("y (cm)");
429 his->SetMaximum(max);
430 his->SetMinimum(min);
434 //_____________________________________________________________________________
435 void AliTRDCalDet::Add(Float_t c1)
438 // Add constant for all detectors
441 for (Int_t idet = 0; idet < kNdet; idet++) {
446 //_____________________________________________________________________________
447 void AliTRDCalDet::Multiply(Float_t c1)
450 // multiply constant for all detectors
452 for (Int_t idet = 0; idet < kNdet; idet++) {
457 //_____________________________________________________________________________
458 void AliTRDCalDet::Add(const AliTRDCalDet * calDet, Double_t c1)
461 // add caldet channel by channel multiplied by c1
463 for (Int_t idet = 0; idet < kNdet; idet++) {
464 fData[idet] += calDet->GetValue(idet)*c1;
468 //_____________________________________________________________________________
469 void AliTRDCalDet::Multiply(const AliTRDCalDet * calDet)
472 // multiply caldet channel by channel
474 for (Int_t idet = 0; idet < kNdet; idet++) {
475 fData[idet] *= calDet->GetValue(idet);
479 //_____________________________________________________________________________
480 void AliTRDCalDet::Divide(const AliTRDCalDet * calDet)
483 // divide caldet channel by channel
485 Float_t kEpsilon=0.00000000000000001;
486 for (Int_t idet = 0; idet < kNdet; idet++) {
487 if (TMath::Abs(calDet->GetValue(idet))>kEpsilon){
488 fData[idet] /= calDet->GetValue(idet);