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
197 fNchannels = c.fNchannels;
202 fData = new UShort_t[fNchannels];
203 for (Int_t iBin = 0; iBin < fNchannels; iBin++) {
204 fData[iBin] = ((AliTRDCalROC &) c).fData[iBin];
211 //_____________________________________________________________________________
212 void AliTRDCalROC::Copy(TObject &c) const
218 ((AliTRDCalROC &) c).fPla = fPla;
219 ((AliTRDCalROC &) c).fCha = fCha;
221 ((AliTRDCalROC &) c).fNrows = fNrows;
222 ((AliTRDCalROC &) c).fNcols = fNcols;
226 ((AliTRDCalROC &) c).fNchannels = fNchannels;
228 if (((AliTRDCalROC &) c).fData) delete [] ((AliTRDCalROC &) c).fData;
229 ((AliTRDCalROC &) c).fData = new UShort_t[fNchannels];
230 for (iBin = 0; iBin < fNchannels; iBin++) {
231 ((AliTRDCalROC &) c).fData[iBin] = fData[iBin];
238 //___________________________________________________________________________________
239 Double_t AliTRDCalROC::GetMean(AliTRDCalROC* const outlierROC) const
242 // Calculate the mean
245 Double_t *ddata = new Double_t[fNchannels];
247 for (Int_t i=0;i<fNchannels;i++) {
248 if ((!outlierROC) || (!(outlierROC->GetValue(i)))) {
249 //if(fData[i] > 0.000000000000001){
250 ddata[nPoints]= (Double_t) fData[i]/10000;
255 Double_t mean = TMath::Mean(nPoints,ddata);
260 //_______________________________________________________________________________________
261 Double_t AliTRDCalROC::GetMedian(AliTRDCalROC* const outlierROC) const
264 // Calculate the median
267 Double_t *ddata = new Double_t[fNchannels];
269 for (Int_t i=0;i<fNchannels;i++) {
270 if ((!outlierROC) || (!(outlierROC->GetValue(i)))) {
271 if(fData[i] > 0.000000000000001){
272 ddata[nPoints]= (Double_t) fData[i]/10000;
277 Double_t mean = TMath::Median(nPoints,ddata);
282 //____________________________________________________________________________________________
283 Double_t AliTRDCalROC::GetRMS(AliTRDCalROC* const outlierROC) const
289 Double_t *ddata = new Double_t[fNchannels];
291 for (Int_t i=0;i<fNchannels;i++) {
292 if ((!outlierROC) || (!(outlierROC->GetValue(i)))) {
293 //if(fData[i] > 0.000000000000001){
294 ddata[nPoints]= (Double_t)fData[i]/10000;
299 Double_t mean = TMath::RMS(nPoints,ddata);
304 //______________________________________________________________________________________________
305 Double_t AliTRDCalROC::GetLTM(Double_t *sigma, Double_t fraction, AliTRDCalROC* const outlierROC)
308 // Calculate LTM mean and sigma
311 Double_t *ddata = new Double_t[fNchannels];
312 Double_t mean=0, lsigma=0;
314 for (Int_t i=0;i<fNchannels;i++) {
315 if (!outlierROC || !(outlierROC->GetValue(i))) {
316 if(fData[i] > 0.000000000000001){
317 ddata[nPoints]= (Double_t) fData[i]/10000;
322 Int_t hh = TMath::Min(TMath::Nint(fraction *nPoints), Int_t(nPoints));
323 AliMathBase::EvaluateUni(nPoints,ddata, mean, lsigma, hh);
324 if (sigma) *sigma=lsigma;
329 //___________________________________________________________________________________
330 Bool_t AliTRDCalROC::Add(Float_t c1)
336 Bool_t result = kTRUE;
337 for (Int_t idata = 0; idata< fNchannels; idata++) {
338 if(((GetValue(idata)+c1) <= 6.5535) && ((GetValue(idata)+c1) >= 0.0)) SetValue(idata,GetValue(idata)+c1);
347 //_______________________________________________________________________________________
348 Bool_t AliTRDCalROC::Multiply(Float_t c1)
354 Bool_t result = kTRUE;
355 if(c1 < 0) return kFALSE;
356 for (Int_t idata = 0; idata< fNchannels; idata++) {
357 if((GetValue(idata)*c1) <= 6.5535) SetValue(idata,GetValue(idata)*c1);
366 //____________________________________________________________________________________________
367 Bool_t AliTRDCalROC::Add(const AliTRDCalROC * roc, Double_t c1)
373 Bool_t result = kTRUE;
374 for (Int_t idata = 0; idata< fNchannels; idata++){
375 if(((GetValue(idata)+roc->GetValue(idata)*c1) <= 6.5535) &&
376 ((GetValue(idata)+roc->GetValue(idata)*c1) >= 0.0))
377 SetValue(idata,GetValue(idata)+roc->GetValue(idata)*c1);
386 //____________________________________________________________________________________________
387 Bool_t AliTRDCalROC::Multiply(const AliTRDCalROC* roc)
390 // multiply values - per by pad
393 Bool_t result = kTRUE;
394 for (Int_t idata = 0; idata< fNchannels; idata++){
395 if((GetValue(idata)*roc->GetValue(idata)) <= 6.5535)
396 SetValue(idata,GetValue(idata)*roc->GetValue(idata));
405 //______________________________________________________________________________________________
406 Bool_t AliTRDCalROC::Divide(const AliTRDCalROC* roc)
412 Bool_t result = kTRUE;
413 Float_t kEpsilon=0.00000000000000001;
414 for (Int_t idata = 0; idata< fNchannels; idata++){
415 if (TMath::Abs(roc->GetValue(idata))>kEpsilon){
416 if((GetValue(idata)/roc->GetValue(idata)) <= 6.5535)
417 SetValue(idata,GetValue(idata)/roc->GetValue(idata));
423 else result = kFALSE;
427 //______________________________________________________________________________________________
428 Bool_t AliTRDCalROC::Unfold()
431 // Compute the mean value per pad col
432 // Divide with this value each pad col
433 // This is for the noise study
434 // Return kFALSE if one or more of the pad col was not normalised
437 Bool_t result = kTRUE;
438 Float_t kEpsilon=0.00000000000000001;
440 // calcul the mean value per col
441 for(Int_t icol = 0; icol < fNcols; icol++){
446 for(Int_t irow = 0; irow < fNrows; irow++){
447 if((GetValue(icol,irow) > 0.06) && (GetValue(icol,irow) < 0.15)){
448 mean += GetValue(icol,irow);
458 for(Int_t irow = 0; irow < fNrows; irow++){
459 Float_t value = GetValue(icol,irow);
460 SetValue(icol,irow,(Float_t)(value/mean));
463 else result = kFALSE;
467 else result = kFALSE;
476 //__________________________________________________________________________________
477 TH2F * AliTRDCalROC::MakeHisto2D(Float_t min, Float_t max,Int_t type, Float_t mu)
481 // type -1 = user defined range
482 // 0 = nsigma cut nsigma=min
483 // 1 = delta cut around median delta=min
485 Float_t kEpsilonr = 0.005;
486 gStyle->SetPalette(1);
491 Float_t mean = GetMean();
492 Float_t sigma = GetRMS();
493 Float_t nsigma = TMath::Abs(min);
495 if(sigma < kEpsilonr) sigma = kEpsilonr;
501 Float_t mean = GetMedian();
508 Float_t mean = GetLTM(&sigma,max);
510 if(sigma < kEpsilonr) sigma = kEpsilonr;
518 snprintf(name,1000,"%s 2D Plane %d Chamber %d",GetTitle(),fPla, fCha);
519 TH2F * his = new TH2F(name,name,fNrows,0, fNrows, fNcols, 0, fNcols);
520 for (Int_t irow=0; irow<fNrows; irow++){
521 for (Int_t icol=0; icol<fNcols; icol++){
522 his->Fill(irow+0.5,icol+0.5,GetValue(icol,irow)*mu);
526 his->SetMaximum(max);
527 his->SetMinimum(min);
531 //_______________________________________________________________________________________
532 TH1F * AliTRDCalROC::MakeHisto1D(Float_t min, Float_t max,Int_t type, Float_t mu)
536 // type -1 = user defined range
537 // 0 = nsigma cut nsigma=min
538 // 1 = delta cut around median delta=min
540 Float_t kEpsilonr = 0.005;
545 Float_t mean = GetMean();
546 Float_t sigma = GetRMS();
547 Float_t nsigma = TMath::Abs(min);
549 if(sigma < kEpsilonr) sigma = kEpsilonr;
555 Float_t mean = GetMedian();
562 // LTM mean +- nsigma
565 Float_t mean = GetLTM(&sigma,max);
567 if(sigma < kEpsilonr) sigma = kEpsilonr;
573 snprintf(name,1000,"%s 1D Plane %d Chamber %d",GetTitle(),fPla, fCha);
574 TH1F * his = new TH1F(name,name,100, min,max);
575 for (Int_t irow=0; irow<fNrows; irow++){
576 for (Int_t icol=0; icol<fNcols; icol++){
577 his->Fill(GetValue(icol,irow)*mu);