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 // Calibration base class for a single ROC //
21 // Contains one UShort_t value per pad //
22 // However, values are set and get as float, there are stored internally as //
23 // (UShort_t) value * 10000 //
25 ///////////////////////////////////////////////////////////////////////////////
32 #include "AliTRDCalROC.h"
34 #include "AliMathBase.h"
35 #include "TLinearFitter.h"
41 #include "TGraphDelaunay.h"
44 #include "AliTRDCommonParam.h"
45 #include "AliTRDpadPlane.h"
48 ClassImp(AliTRDCalROC)
50 //_____________________________________________________________________________
51 AliTRDCalROC::AliTRDCalROC()
61 // Default constructor
66 //_____________________________________________________________________________
67 AliTRDCalROC::AliTRDCalROC(Int_t p, Int_t c)
77 // Constructor that initializes a given pad plane type
81 // The pad plane parameter
146 fNchannels = fNrows * fNcols;
147 if (fNchannels != 0) {
148 fData = new UShort_t[fNchannels];
151 for (Int_t i=0; i<fNchannels; ++i) {
157 //_____________________________________________________________________________
158 AliTRDCalROC::AliTRDCalROC(const AliTRDCalROC &c)
164 ,fNchannels(c.fNchannels)
168 // AliTRDCalROC copy constructor
173 fData = new UShort_t[fNchannels];
174 for (iBin = 0; iBin < fNchannels; iBin++) {
175 fData[iBin] = ((AliTRDCalROC &) c).fData[iBin];
180 //_____________________________________________________________________________
181 AliTRDCalROC::~AliTRDCalROC()
184 // AliTRDCalROC destructor
194 //_____________________________________________________________________________
195 AliTRDCalROC &AliTRDCalROC::operator=(const AliTRDCalROC &c)
198 // Assignment operator
201 if (this != &c) ((AliTRDCalROC &) c).Copy(*this);
206 //_____________________________________________________________________________
207 void AliTRDCalROC::Copy(TObject &c) const
213 ((AliTRDCalROC &) c).fPla = fPla;
214 ((AliTRDCalROC &) c).fCha = fCha;
216 ((AliTRDCalROC &) c).fNrows = fNrows;
217 ((AliTRDCalROC &) c).fNcols = fNcols;
221 ((AliTRDCalROC &) c).fNchannels = fNchannels;
223 if (((AliTRDCalROC &) c).fData) delete [] ((AliTRDCalROC &) c).fData;
224 ((AliTRDCalROC &) c).fData = new UShort_t[fNchannels];
225 for (iBin = 0; iBin < fNchannels; iBin++) {
226 ((AliTRDCalROC &) c).fData[iBin] = fData[iBin];
233 //___________________________________________________________________________________
234 Double_t AliTRDCalROC::GetMean(AliTRDCalROC* outlierROC)
237 // Calculate the mean
240 Double_t *ddata = new Double_t[fNchannels];
242 for (Int_t i=0;i<fNchannels;i++) {
243 if ((!outlierROC) || (!(outlierROC->GetValue(i)))) {
244 ddata[NPoints]= (Double_t) fData[NPoints]/10000;
248 Double_t mean = TMath::Mean(NPoints,ddata);
253 //_______________________________________________________________________________________
254 Double_t AliTRDCalROC::GetMedian(AliTRDCalROC* outlierROC)
257 // Calculate the median
260 Double_t *ddata = new Double_t[fNchannels];
262 for (Int_t i=0;i<fNchannels;i++) {
263 if ((!outlierROC) || (!(outlierROC->GetValue(i)))) {
264 ddata[NPoints]= (Double_t) fData[NPoints]/10000;
268 Double_t mean = TMath::Median(NPoints,ddata);
273 //____________________________________________________________________________________________
274 Double_t AliTRDCalROC::GetRMS(AliTRDCalROC* outlierROC)
280 Double_t *ddata = new Double_t[fNchannels];
282 for (Int_t i=0;i<fNchannels;i++) {
283 if ((!outlierROC) || (!(outlierROC->GetValue(i)))) {
284 ddata[NPoints]= (Double_t)fData[NPoints]/10000;
288 Double_t mean = TMath::RMS(NPoints,ddata);
293 //______________________________________________________________________________________________
294 Double_t AliTRDCalROC::GetLTM(Double_t *sigma, Double_t fraction, AliTRDCalROC* outlierROC)
297 // Calculate LTM mean and sigma
300 Double_t *ddata = new Double_t[fNchannels];
301 Double_t mean=0, lsigma=0;
303 for (Int_t i=0;i<fNchannels;i++) {
304 if (!outlierROC || !(outlierROC->GetValue(i))) {
305 ddata[NPoints]= (Double_t) fData[NPoints]/10000;
309 Int_t hh = TMath::Min(TMath::Nint(fraction *NPoints), Int_t(NPoints));
310 AliMathBase::EvaluateUni(NPoints,ddata, mean, lsigma, hh);
311 if (sigma) *sigma=lsigma;
316 //___________________________________________________________________________________
317 Bool_t AliTRDCalROC::Add(Float_t c1)
322 Bool_t result = kTRUE;
323 for (Int_t idata = 0; idata< fNchannels; idata++) {
324 if(((GetValue(idata)+c1) <= 6.5535) && ((GetValue(idata)+c1) >= 0.0)) SetValue(idata,GetValue(idata)+c1);
333 //_______________________________________________________________________________________
334 Bool_t AliTRDCalROC::Multiply(Float_t c1)
339 Bool_t result = kTRUE;
340 if(c1 < 0) return kFALSE;
341 for (Int_t idata = 0; idata< fNchannels; idata++) {
342 if((GetValue(idata)*c1) <= 6.5535) SetValue(idata,GetValue(idata)*c1);
351 //____________________________________________________________________________________________
352 Bool_t AliTRDCalROC::Add(const AliTRDCalROC * roc, Double_t c1)
357 Bool_t result = kTRUE;
358 for (Int_t idata = 0; idata< fNchannels; idata++){
359 if(((GetValue(idata)+roc->GetValue(idata)*c1) <= 6.5535) &&
360 ((GetValue(idata)+roc->GetValue(idata)*c1) >= 0.0))
361 SetValue(idata,GetValue(idata)+roc->GetValue(idata)*c1);
370 //____________________________________________________________________________________________
371 Bool_t AliTRDCalROC::Multiply(const AliTRDCalROC* roc)
374 // multiply values - per by pad
376 Bool_t result = kTRUE;
377 for (Int_t idata = 0; idata< fNchannels; idata++){
378 if((GetValue(idata)*roc->GetValue(idata)) <= 6.5535)
379 SetValue(idata,GetValue(idata)*roc->GetValue(idata));
388 //______________________________________________________________________________________________
389 Bool_t AliTRDCalROC::Divide(const AliTRDCalROC* roc)
394 Bool_t result = kTRUE;
395 Float_t kEpsilon=0.00000000000000001;
396 for (Int_t idata = 0; idata< fNchannels; idata++){
397 if (TMath::Abs(roc->GetValue(idata))>kEpsilon){
398 if((GetValue(idata)/roc->GetValue(idata)) <= 6.5535)
399 SetValue(idata,GetValue(idata)/roc->GetValue(idata));
405 else result = kFALSE;
410 //__________________________________________________________________________________
411 TH2F * AliTRDCalROC::MakeHisto2D(Float_t min, Float_t max,Int_t type, Float_t mu)
415 // type -1 = user defined range
416 // 0 = nsigma cut nsigma=min
417 // 1 = delta cut around median delta=min
418 Float_t kEpsilonr = 0.005;
419 gStyle->SetPalette(1);
424 Float_t mean = GetMean();
425 Float_t sigma = GetRMS();
426 Float_t nsigma = TMath::Abs(min);
428 if(sigma < kEpsilonr) sigma = kEpsilonr;
434 Float_t mean = GetMedian();
441 Float_t mean = GetLTM(&sigma,max);
443 if(sigma < kEpsilonr) sigma = kEpsilonr;
451 sprintf(name,"%s 2D Plane %d Chamber %d",GetTitle(),fPla, fCha);
452 TH2F * his = new TH2F(name,name,fNrows,0, fNrows, fNcols, 0, fNcols);
453 for (Int_t irow=0; irow<fNrows; irow++){
454 for (Int_t icol=0; icol<fNcols; icol++){
455 his->Fill(irow+0.5,icol+0.5,GetValue(icol,irow)*mu);
459 his->SetMaximum(max);
460 his->SetMinimum(min);
464 //_______________________________________________________________________________________
465 TH1F * AliTRDCalROC::MakeHisto1D(Float_t min, Float_t max,Int_t type, Float_t mu)
469 // type -1 = user defined range
470 // 0 = nsigma cut nsigma=min
471 // 1 = delta cut around median delta=min
472 Float_t kEpsilonr = 0.005;
478 Float_t mean = GetMean();
479 Float_t sigma = GetRMS();
480 Float_t nsigma = TMath::Abs(min);
482 if(sigma < kEpsilonr) sigma = kEpsilonr;
488 Float_t mean = GetMedian();
495 // LTM mean +- nsigma
498 Float_t mean = GetLTM(&sigma,max);
500 if(sigma < kEpsilonr) sigma = kEpsilonr;
506 sprintf(name,"%s 1D Plane %d Chamber %d",GetTitle(),fPla, fCha);
507 TH1F * his = new TH1F(name,name,100, min,max);
508 for (Int_t irow=0; irow<fNrows; irow++){
509 for (Int_t icol=0; icol<fNcols; icol++){
510 his->Fill(GetValue(icol,irow)*mu);