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 "AliMathBase.h"
34 #include "AliTRDCalROC.h"
36 ClassImp(AliTRDCalROC)
38 //_____________________________________________________________________________
39 AliTRDCalROC::AliTRDCalROC()
49 // Default constructor
54 //_____________________________________________________________________________
55 AliTRDCalROC::AliTRDCalROC(Int_t p, Int_t c)
65 // Constructor that initializes a given pad plane type
69 // The pad plane parameter
134 fNchannels = fNrows * fNcols;
135 if (fNchannels != 0) {
136 fData = new UShort_t[fNchannels];
139 for (Int_t i=0; i<fNchannels; ++i) {
145 //_____________________________________________________________________________
146 AliTRDCalROC::AliTRDCalROC(const AliTRDCalROC &c)
152 ,fNchannels(c.fNchannels)
156 // AliTRDCalROC copy constructor
161 fData = new UShort_t[fNchannels];
162 for (iBin = 0; iBin < fNchannels; iBin++) {
163 fData[iBin] = ((AliTRDCalROC &) c).fData[iBin];
168 //_____________________________________________________________________________
169 AliTRDCalROC::~AliTRDCalROC()
172 // AliTRDCalROC destructor
182 //_____________________________________________________________________________
183 AliTRDCalROC &AliTRDCalROC::operator=(const AliTRDCalROC &c)
186 // Assignment operator
189 if (this != &c) ((AliTRDCalROC &) c).Copy(*this);
194 //_____________________________________________________________________________
195 void AliTRDCalROC::Copy(TObject &c) const
201 ((AliTRDCalROC &) c).fPla = fPla;
202 ((AliTRDCalROC &) c).fCha = fCha;
204 ((AliTRDCalROC &) c).fNrows = fNrows;
205 ((AliTRDCalROC &) c).fNcols = fNcols;
209 ((AliTRDCalROC &) c).fNchannels = fNchannels;
211 if (((AliTRDCalROC &) c).fData) delete [] ((AliTRDCalROC &) c).fData;
212 ((AliTRDCalROC &) c).fData = new UShort_t[fNchannels];
213 for (iBin = 0; iBin < fNchannels; iBin++) {
214 ((AliTRDCalROC &) c).fData[iBin] = fData[iBin];
221 //___________________________________________________________________________________
222 Double_t AliTRDCalROC::GetMean(AliTRDCalROC* const outlierROC) const
225 // Calculate the mean
228 Double_t *ddata = new Double_t[fNchannels];
230 for (Int_t i=0;i<fNchannels;i++) {
231 if ((!outlierROC) || (!(outlierROC->GetValue(i)))) {
232 if(fData[i] > 0.000000000000001){
233 ddata[nPoints]= (Double_t) fData[i]/10000;
238 Double_t mean = TMath::Mean(nPoints,ddata);
243 //_______________________________________________________________________________________
244 Double_t AliTRDCalROC::GetMedian(AliTRDCalROC* const outlierROC) const
247 // Calculate the median
250 Double_t *ddata = new Double_t[fNchannels];
252 for (Int_t i=0;i<fNchannels;i++) {
253 if ((!outlierROC) || (!(outlierROC->GetValue(i)))) {
254 if(fData[i] > 0.000000000000001){
255 ddata[nPoints]= (Double_t) fData[i]/10000;
260 Double_t mean = TMath::Median(nPoints,ddata);
265 //____________________________________________________________________________________________
266 Double_t AliTRDCalROC::GetRMS(AliTRDCalROC* const outlierROC) const
272 Double_t *ddata = new Double_t[fNchannels];
274 for (Int_t i=0;i<fNchannels;i++) {
275 if ((!outlierROC) || (!(outlierROC->GetValue(i)))) {
276 if(fData[i] > 0.000000000000001){
277 ddata[nPoints]= (Double_t)fData[i]/10000;
282 Double_t mean = TMath::RMS(nPoints,ddata);
287 //______________________________________________________________________________________________
288 Double_t AliTRDCalROC::GetLTM(Double_t *sigma, Double_t fraction, AliTRDCalROC* const outlierROC)
291 // Calculate LTM mean and sigma
294 Double_t *ddata = new Double_t[fNchannels];
295 Double_t mean=0, lsigma=0;
297 for (Int_t i=0;i<fNchannels;i++) {
298 if (!outlierROC || !(outlierROC->GetValue(i))) {
299 if(fData[i] > 0.000000000000001){
300 ddata[nPoints]= (Double_t) fData[i]/10000;
305 Int_t hh = TMath::Min(TMath::Nint(fraction *nPoints), Int_t(nPoints));
306 AliMathBase::EvaluateUni(nPoints,ddata, mean, lsigma, hh);
307 if (sigma) *sigma=lsigma;
312 //___________________________________________________________________________________
313 Bool_t AliTRDCalROC::Add(Float_t c1)
319 Bool_t result = kTRUE;
320 for (Int_t idata = 0; idata< fNchannels; idata++) {
321 if(((GetValue(idata)+c1) <= 6.5535) && ((GetValue(idata)+c1) >= 0.0)) SetValue(idata,GetValue(idata)+c1);
330 //_______________________________________________________________________________________
331 Bool_t AliTRDCalROC::Multiply(Float_t c1)
337 Bool_t result = kTRUE;
338 if(c1 < 0) return kFALSE;
339 for (Int_t idata = 0; idata< fNchannels; idata++) {
340 if((GetValue(idata)*c1) <= 6.5535) SetValue(idata,GetValue(idata)*c1);
349 //____________________________________________________________________________________________
350 Bool_t AliTRDCalROC::Add(const AliTRDCalROC * roc, Double_t c1)
356 Bool_t result = kTRUE;
357 for (Int_t idata = 0; idata< fNchannels; idata++){
358 if(((GetValue(idata)+roc->GetValue(idata)*c1) <= 6.5535) &&
359 ((GetValue(idata)+roc->GetValue(idata)*c1) >= 0.0))
360 SetValue(idata,GetValue(idata)+roc->GetValue(idata)*c1);
369 //____________________________________________________________________________________________
370 Bool_t AliTRDCalROC::Multiply(const AliTRDCalROC* roc)
373 // 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)
395 Bool_t result = kTRUE;
396 Float_t kEpsilon=0.00000000000000001;
397 for (Int_t idata = 0; idata< fNchannels; idata++){
398 if (TMath::Abs(roc->GetValue(idata))>kEpsilon){
399 if((GetValue(idata)/roc->GetValue(idata)) <= 6.5535)
400 SetValue(idata,GetValue(idata)/roc->GetValue(idata));
406 else result = kFALSE;
410 //______________________________________________________________________________________________
411 Bool_t AliTRDCalROC::Unfold()
414 // Compute the mean value per pad col
415 // Divide with this value each pad col
416 // This is for the noise study
417 // Return kFALSE if one or more of the pad col was not normalised
420 Bool_t result = kTRUE;
421 Float_t kEpsilon=0.00000000000000001;
423 // calcul the mean value per col
424 for(Int_t icol = 0; icol < fNcols; icol++){
429 for(Int_t irow = 0; irow < fNrows; irow++){
430 if((GetValue(icol,irow) > 0.06) && (GetValue(icol,irow) < 0.15)){
431 mean += GetValue(icol,irow);
441 for(Int_t irow = 0; irow < fNrows; irow++){
442 Float_t value = GetValue(icol,irow);
443 SetValue(icol,irow,(Float_t)(value/mean));
446 else result = kFALSE;
450 else result = kFALSE;
459 //__________________________________________________________________________________
460 TH2F * AliTRDCalROC::MakeHisto2D(Float_t min, Float_t max,Int_t type, Float_t mu)
464 // type -1 = user defined range
465 // 0 = nsigma cut nsigma=min
466 // 1 = delta cut around median delta=min
468 Float_t kEpsilonr = 0.005;
469 gStyle->SetPalette(1);
474 Float_t mean = GetMean();
475 Float_t sigma = GetRMS();
476 Float_t nsigma = TMath::Abs(min);
478 if(sigma < kEpsilonr) sigma = kEpsilonr;
484 Float_t mean = GetMedian();
491 Float_t mean = GetLTM(&sigma,max);
493 if(sigma < kEpsilonr) sigma = kEpsilonr;
501 sprintf(name,"%s 2D Plane %d Chamber %d",GetTitle(),fPla, fCha);
502 TH2F * his = new TH2F(name,name,fNrows,0, fNrows, fNcols, 0, fNcols);
503 for (Int_t irow=0; irow<fNrows; irow++){
504 for (Int_t icol=0; icol<fNcols; icol++){
505 his->Fill(irow+0.5,icol+0.5,GetValue(icol,irow)*mu);
509 his->SetMaximum(max);
510 his->SetMinimum(min);
514 //_______________________________________________________________________________________
515 TH1F * AliTRDCalROC::MakeHisto1D(Float_t min, Float_t max,Int_t type, Float_t mu)
519 // type -1 = user defined range
520 // 0 = nsigma cut nsigma=min
521 // 1 = delta cut around median delta=min
523 Float_t kEpsilonr = 0.005;
528 Float_t mean = GetMean();
529 Float_t sigma = GetRMS();
530 Float_t nsigma = TMath::Abs(min);
532 if(sigma < kEpsilonr) sigma = kEpsilonr;
538 Float_t mean = GetMedian();
545 // LTM mean +- nsigma
548 Float_t mean = GetLTM(&sigma,max);
550 if(sigma < kEpsilonr) sigma = kEpsilonr;
556 sprintf(name,"%s 1D Plane %d Chamber %d",GetTitle(),fPla, fCha);
557 TH1F * his = new TH1F(name,name,100, min,max);
558 for (Int_t irow=0; irow<fNrows; irow++){
559 for (Int_t icol=0; icol<fNcols; icol++){
560 his->Fill(GetValue(icol,irow)*mu);