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 if(fData[i] > 0.000000000000001){
245 ddata[NPoints]= (Double_t) fData[i]/10000;
250 Double_t mean = TMath::Mean(NPoints,ddata);
255 //_______________________________________________________________________________________
256 Double_t AliTRDCalROC::GetMedian(AliTRDCalROC* outlierROC)
259 // Calculate the median
262 Double_t *ddata = new Double_t[fNchannels];
264 for (Int_t i=0;i<fNchannels;i++) {
265 if ((!outlierROC) || (!(outlierROC->GetValue(i)))) {
266 if(fData[i] > 0.000000000000001){
267 ddata[NPoints]= (Double_t) fData[i]/10000;
272 Double_t mean = TMath::Median(NPoints,ddata);
277 //____________________________________________________________________________________________
278 Double_t AliTRDCalROC::GetRMS(AliTRDCalROC* outlierROC)
284 Double_t *ddata = new Double_t[fNchannels];
286 for (Int_t i=0;i<fNchannels;i++) {
287 if ((!outlierROC) || (!(outlierROC->GetValue(i)))) {
288 if(fData[i] > 0.000000000000001){
289 ddata[NPoints]= (Double_t)fData[i]/10000;
294 Double_t mean = TMath::RMS(NPoints,ddata);
299 //______________________________________________________________________________________________
300 Double_t AliTRDCalROC::GetLTM(Double_t *sigma, Double_t fraction, AliTRDCalROC* outlierROC)
303 // Calculate LTM mean and sigma
306 Double_t *ddata = new Double_t[fNchannels];
307 Double_t mean=0, lsigma=0;
309 for (Int_t i=0;i<fNchannels;i++) {
310 if (!outlierROC || !(outlierROC->GetValue(i))) {
311 if(fData[i] > 0.000000000000001){
312 ddata[NPoints]= (Double_t) fData[i]/10000;
317 Int_t hh = TMath::Min(TMath::Nint(fraction *NPoints), Int_t(NPoints));
318 AliMathBase::EvaluateUni(NPoints,ddata, mean, lsigma, hh);
319 if (sigma) *sigma=lsigma;
324 //___________________________________________________________________________________
325 Bool_t AliTRDCalROC::Add(Float_t c1)
330 Bool_t result = kTRUE;
331 for (Int_t idata = 0; idata< fNchannels; idata++) {
332 if(((GetValue(idata)+c1) <= 6.5535) && ((GetValue(idata)+c1) >= 0.0)) SetValue(idata,GetValue(idata)+c1);
341 //_______________________________________________________________________________________
342 Bool_t AliTRDCalROC::Multiply(Float_t c1)
347 Bool_t result = kTRUE;
348 if(c1 < 0) return kFALSE;
349 for (Int_t idata = 0; idata< fNchannels; idata++) {
350 if((GetValue(idata)*c1) <= 6.5535) SetValue(idata,GetValue(idata)*c1);
359 //____________________________________________________________________________________________
360 Bool_t AliTRDCalROC::Add(const AliTRDCalROC * roc, Double_t c1)
365 Bool_t result = kTRUE;
366 for (Int_t idata = 0; idata< fNchannels; idata++){
367 if(((GetValue(idata)+roc->GetValue(idata)*c1) <= 6.5535) &&
368 ((GetValue(idata)+roc->GetValue(idata)*c1) >= 0.0))
369 SetValue(idata,GetValue(idata)+roc->GetValue(idata)*c1);
378 //____________________________________________________________________________________________
379 Bool_t AliTRDCalROC::Multiply(const AliTRDCalROC* roc)
382 // multiply values - per by pad
384 Bool_t result = kTRUE;
385 for (Int_t idata = 0; idata< fNchannels; idata++){
386 if((GetValue(idata)*roc->GetValue(idata)) <= 6.5535)
387 SetValue(idata,GetValue(idata)*roc->GetValue(idata));
396 //______________________________________________________________________________________________
397 Bool_t AliTRDCalROC::Divide(const AliTRDCalROC* roc)
402 Bool_t result = kTRUE;
403 Float_t kEpsilon=0.00000000000000001;
404 for (Int_t idata = 0; idata< fNchannels; idata++){
405 if (TMath::Abs(roc->GetValue(idata))>kEpsilon){
406 if((GetValue(idata)/roc->GetValue(idata)) <= 6.5535)
407 SetValue(idata,GetValue(idata)/roc->GetValue(idata));
413 else result = kFALSE;
417 //______________________________________________________________________________________________
418 Bool_t AliTRDCalROC::Unfold()
421 // Compute the mean value per pad col
422 // Divide with this value each pad col
423 // This is for the noise study
424 // Return kFALSE if one or more of the pad col was not normalised
426 Bool_t result = kTRUE;
427 Float_t kEpsilon=0.00000000000000001;
429 // calcul the mean value per col
430 for(Int_t icol = 0; icol < fNcols; icol++){
435 for(Int_t irow = 0; irow < fNrows; irow++){
436 if((GetValue(icol,irow) > 0.06) && (GetValue(icol,irow) < 0.15)){
437 mean += GetValue(icol,irow);
447 for(Int_t irow = 0; irow < fNrows; irow++){
448 Float_t value = GetValue(icol,irow);
449 SetValue(icol,irow,(Float_t)(value/mean));
452 else result = kFALSE;
456 else result = kFALSE;
465 //__________________________________________________________________________________
466 TH2F * AliTRDCalROC::MakeHisto2D(Float_t min, Float_t max,Int_t type, Float_t mu)
470 // type -1 = user defined range
471 // 0 = nsigma cut nsigma=min
472 // 1 = delta cut around median delta=min
473 Float_t kEpsilonr = 0.005;
474 gStyle->SetPalette(1);
479 Float_t mean = GetMean();
480 Float_t sigma = GetRMS();
481 Float_t nsigma = TMath::Abs(min);
483 if(sigma < kEpsilonr) sigma = kEpsilonr;
489 Float_t mean = GetMedian();
496 Float_t mean = GetLTM(&sigma,max);
498 if(sigma < kEpsilonr) sigma = kEpsilonr;
506 sprintf(name,"%s 2D Plane %d Chamber %d",GetTitle(),fPla, fCha);
507 TH2F * his = new TH2F(name,name,fNrows,0, fNrows, fNcols, 0, fNcols);
508 for (Int_t irow=0; irow<fNrows; irow++){
509 for (Int_t icol=0; icol<fNcols; icol++){
510 his->Fill(irow+0.5,icol+0.5,GetValue(icol,irow)*mu);
514 his->SetMaximum(max);
515 his->SetMinimum(min);
519 //_______________________________________________________________________________________
520 TH1F * AliTRDCalROC::MakeHisto1D(Float_t min, Float_t max,Int_t type, Float_t mu)
524 // type -1 = user defined range
525 // 0 = nsigma cut nsigma=min
526 // 1 = delta cut around median delta=min
527 Float_t kEpsilonr = 0.005;
533 Float_t mean = GetMean();
534 Float_t sigma = GetRMS();
535 Float_t nsigma = TMath::Abs(min);
537 if(sigma < kEpsilonr) sigma = kEpsilonr;
543 Float_t mean = GetMedian();
550 // LTM mean +- nsigma
553 Float_t mean = GetLTM(&sigma,max);
555 if(sigma < kEpsilonr) sigma = kEpsilonr;
561 sprintf(name,"%s 1D Plane %d Chamber %d",GetTitle(),fPla, fCha);
562 TH1F * his = new TH1F(name,name,100, min,max);
563 for (Int_t irow=0; irow<fNrows; irow++){
564 for (Int_t icol=0; icol<fNcols; icol++){
565 his->Fill(GetValue(icol,irow)*mu);