LCOV - code coverage report
Current view: top level - TRD/TRDbase - AliTRDCalDet.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 13 337 3.9 %
Date: 2016-06-14 17:26:59 Functions: 6 31 19.4 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       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             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : ///////////////////////////////////////////////////////////////////////////////
      19             : //                                                                           //
      20             : //  TRD calibration class for parameters which saved per detector            //
      21             : //                                                                           //
      22             : ///////////////////////////////////////////////////////////////////////////////
      23             : 
      24             : #include <TMath.h>
      25             : #include <TH1F.h>
      26             : #include <TH2F.h>
      27             : #include <TStyle.h>
      28             : 
      29             : #include "AliTRDCalDet.h"
      30             : #include "AliTRDgeometry.h"
      31             : #include "AliMathBase.h"
      32             : #include "AliTRDpadPlane.h"
      33             : 
      34          48 : ClassImp(AliTRDCalDet)
      35             : 
      36             : //_____________________________________________________________________________
      37          14 : AliTRDCalDet::AliTRDCalDet():TNamed()
      38          70 : {
      39             :   //
      40             :   // AliTRDCalDet default constructor
      41             :   //
      42             : 
      43       15148 :   for (Int_t idet = 0; idet < kNdet; idet++) {
      44        7560 :     fData[idet] = 0;
      45             :   }
      46             : 
      47          28 : }
      48             : 
      49             : //_____________________________________________________________________________
      50             : AliTRDCalDet::AliTRDCalDet(const Text_t *name, const Text_t *title)
      51         190 :                 :TNamed(name,title)
      52         950 : {
      53             :   //
      54             :   // AliTRDCalDet constructor
      55             :   //
      56             : 
      57      205580 :   for (Int_t idet = 0; idet < kNdet; idet++) {
      58      102600 :     fData[idet] = 0;
      59             :   }
      60             : 
      61         380 : }
      62             : 
      63             : //_____________________________________________________________________________
      64           0 : AliTRDCalDet::AliTRDCalDet(const AliTRDCalDet &c):TNamed(c)
      65           0 : {
      66             :   //
      67             :   // AliTRDCalDet copy constructor
      68             :   //
      69             : 
      70           0 :   ((AliTRDCalDet &) c).Copy(*this);
      71             : 
      72           0 : }
      73             : 
      74             : ///_____________________________________________________________________________
      75             : AliTRDCalDet::~AliTRDCalDet()
      76           0 : {
      77             :   //
      78             :   // AliTRDCalDet destructor
      79             :   //
      80             : 
      81           0 : }
      82             : 
      83             : //_____________________________________________________________________________
      84             : AliTRDCalDet &AliTRDCalDet::operator=(const AliTRDCalDet &c)
      85             : {
      86             :   //
      87             :   // Assignment operator
      88             :   //
      89             : 
      90           0 :   if (this != &c) ((AliTRDCalDet &) c).Copy(*this);
      91           0 :   return *this;
      92             : 
      93             : }
      94             : 
      95             : //_____________________________________________________________________________
      96             : void AliTRDCalDet::Copy(TObject &c) const
      97             : {
      98             :   //
      99             :   // Copy function
     100             :   //
     101             : 
     102           0 :   for (Int_t idet = 0; idet < kNdet; idet++) {
     103           0 :     ((AliTRDCalDet &) c).fData[idet] = fData[idet];
     104             :   }
     105             : 
     106           0 :   TObject::Copy(c);
     107             : 
     108           0 : }
     109             : 
     110             : //___________________________________________________________________________________
     111             : Double_t AliTRDCalDet::GetMean(AliTRDCalDet * const outlierDet) const
     112             : {
     113             :   //
     114             :   // Calculate the mean
     115             :   //
     116             : 
     117         570 :   if (!outlierDet) return TMath::Mean(kNdet,fData);
     118           0 :   Double_t *ddata = new Double_t[kNdet];
     119             :   Int_t nPoints = 0;
     120           0 :   for (Int_t i=0;i<kNdet;i++) {
     121           0 :     if (!(outlierDet->GetValue(i))) {
     122           0 :       ddata[nPoints]= fData[nPoints];
     123           0 :       nPoints++;
     124           0 :     }
     125             :   }
     126           0 :   Double_t mean = TMath::Mean(nPoints,ddata);
     127           0 :   delete [] ddata;
     128             :   return mean;
     129         190 : }
     130             : 
     131             : //_______________________________________________________________________________________
     132             : Double_t AliTRDCalDet::GetMedian(AliTRDCalDet * const outlierDet) const
     133             : {
     134             :   //
     135             :   // Calculate the median
     136             :   //
     137             : 
     138           0 :   if (!outlierDet) return (Double_t) TMath::Median(kNdet,fData);
     139           0 :   Double_t *ddata = new Double_t[kNdet];
     140             :   Int_t nPoints = 0;
     141           0 :   for (Int_t i=0;i<kNdet;i++) {
     142           0 :     if (!(outlierDet->GetValue(i))) {
     143           0 :       ddata[nPoints]= fData[nPoints];
     144           0 :       nPoints++;
     145           0 :     }
     146             :   }
     147           0 :   Double_t mean = TMath::Median(nPoints,ddata);
     148           0 :   delete [] ddata;
     149             :   return mean;
     150             : 
     151           0 : }
     152             : 
     153             : //____________________________________________________________________________________________
     154             : Double_t AliTRDCalDet::GetRMS(AliTRDCalDet * const outlierDet) const
     155             : {
     156             :   //
     157             :   // Calculate the RMS
     158             :   //
     159             : 
     160           0 :   if (!outlierDet) return TMath::RMS(kNdet,fData);
     161           0 :   Double_t *ddata = new Double_t[kNdet];
     162             :   Int_t nPoints = 0;
     163           0 :   for (Int_t i=0;i<kNdet;i++) {
     164           0 :     if (!(outlierDet->GetValue(i))) {
     165           0 :       ddata[nPoints]= fData[nPoints];
     166           0 :       nPoints++;
     167           0 :     }
     168             :   }
     169           0 :   Double_t mean = TMath::RMS(nPoints,ddata);
     170           0 :   delete [] ddata;
     171             :   return mean;
     172           0 : }
     173             : 
     174             : //____________________________________________________________________________________________
     175             : Double_t AliTRDCalDet::GetRMSRobust(Double_t robust) const
     176             : {
     177             :   //
     178             :   // Calculate the robust RMS
     179             :   //
     180             : 
     181             :   // sorted
     182           0 :   Int_t *index = new Int_t[kNdet];
     183           0 :   TMath::Sort((Int_t)kNdet,fData,index);
     184             :  
     185             :   // reject
     186           0 :   Double_t reject = (Int_t) (kNdet*(1-robust)/2.0);
     187           0 :   if(reject <= 0.0) reject = 0.0;
     188           0 :   if(reject >= kNdet) reject = 0.0;
     189             :   //printf("Rejecter %f\n",reject);
     190             : 
     191           0 :   Double_t *ddata = new Double_t[kNdet];
     192             :   Int_t nPoints = 0;
     193           0 :   for (Int_t i=0;i<kNdet;i++) {
     194             :     Bool_t rej = kFALSE;
     195           0 :     for(Int_t k = 0; k < reject; k++){
     196           0 :       if(i==index[k]) rej = kTRUE;
     197           0 :       if(i==index[kNdet-(k+1)]) rej  = kTRUE;
     198             :     }
     199           0 :     if(!rej){
     200           0 :       ddata[nPoints]= fData[i];
     201           0 :       nPoints++;
     202           0 :     }
     203             :   }
     204             :   //printf("Number of points %d\n",nPoints);
     205           0 :   Double_t mean = TMath::RMS(nPoints,ddata);
     206           0 :   delete [] ddata;
     207           0 :   delete [] index;
     208           0 :   return mean;
     209             : }
     210             : 
     211             : //______________________________________________________________________________________________
     212             : Double_t AliTRDCalDet::GetLTM(Double_t *sigma
     213             :                             , Double_t fraction
     214             :                             , AliTRDCalDet * const outlierDet)
     215             : {
     216             :   //
     217             :   //  Calculate LTM mean and sigma
     218             :   //
     219             : 
     220           0 :   Double_t *ddata = new Double_t[kNdet];
     221           0 :   Double_t mean=0, lsigma=0;
     222             :   UInt_t nPoints = 0;
     223           0 :   for (Int_t i=0;i<kNdet;i++) {
     224           0 :      if (!outlierDet || !(outlierDet->GetValue(i))) {
     225           0 :         ddata[nPoints]= fData[nPoints];
     226           0 :         nPoints++;
     227           0 :      }
     228             :   }
     229           0 :   Int_t hh = TMath::Min(TMath::Nint(fraction *nPoints), Int_t(nPoints));
     230           0 :   AliMathBase::EvaluateUni(nPoints,ddata, mean, lsigma, hh);
     231           0 :   if (sigma) *sigma=lsigma;
     232           0 :   delete [] ddata;
     233           0 :   return mean;
     234           0 : }
     235             : 
     236             : //_________________________________________________________________________
     237             : TH1F * AliTRDCalDet::MakeHisto1Distribution(Float_t min, Float_t max,Int_t type)
     238             : {
     239             :   //
     240             :   // make 1D histo
     241             :   // type -1 = user defined range
     242             :   //       0 = nsigma cut nsigma=min
     243             :   //       1 = delta cut around median delta=min
     244             :   //
     245             : 
     246           0 :   if (type>=0){
     247           0 :     if (type==0){
     248             :       // nsigma range
     249           0 :       Float_t mean  = GetMean();
     250           0 :       Float_t sigma = GetRMS();
     251           0 :       Float_t nsigma = TMath::Abs(min);
     252           0 :       min = mean-nsigma*sigma;
     253           0 :       max = mean+nsigma*sigma;
     254           0 :     }
     255           0 :     if (type==1){
     256             :       // fixed range
     257           0 :       Float_t mean   = GetMedian();
     258             :       Float_t  delta = min;
     259           0 :       min = mean-delta;
     260           0 :       max = mean+delta;
     261           0 :     }
     262           0 :     if (type==2){
     263             :       //
     264             :       // LTM mean +- nsigma
     265             :       //
     266           0 :       Double_t sigma;
     267           0 :       Float_t mean  = GetLTM(&sigma,max);
     268           0 :       sigma*=min;
     269           0 :       min = mean-sigma;
     270           0 :       max = mean+sigma;
     271           0 :     }
     272             :   }
     273           0 :   char  name[1000];
     274           0 :   snprintf(name,1000,"%s CalDet 1Distribution",GetTitle());
     275           0 :   TH1F * his = new TH1F(name,name,100, min,max);
     276           0 :   for (Int_t idet=0; idet<kNdet; idet++){
     277           0 :     his->Fill(GetValue(idet));
     278             :   }
     279           0 :   return his;
     280           0 : }
     281             : 
     282             : //________________________________________________________________________________
     283             : TH1F * AliTRDCalDet::MakeHisto1DAsFunctionOfDet(Float_t min, Float_t max,Int_t type)
     284             : {
     285             :   //
     286             :   // make 1D histo
     287             :   // type -1 = user defined range
     288             :   //       0 = nsigma cut nsigma=min
     289             :   //       1 = delta cut around median delta=min
     290             :   //
     291             : 
     292           0 :   if (type>=0){
     293           0 :     if (type==0){
     294             :       // nsigma range
     295           0 :       Float_t mean  = GetMean();
     296           0 :       Float_t sigma = GetRMS();
     297           0 :       Float_t nsigma = TMath::Abs(min);
     298           0 :       min = mean-nsigma*sigma;
     299           0 :       max = mean+nsigma*sigma;
     300           0 :     }
     301           0 :     if (type==1){
     302             :       // fixed range
     303           0 :       Float_t mean   = GetMedian();
     304             :       Float_t  delta = min;
     305           0 :       min = mean-delta;
     306           0 :       max = mean+delta;
     307           0 :     }
     308           0 :     if (type==2){
     309           0 :       Double_t sigma;
     310           0 :       Float_t mean  = GetLTM(&sigma,max);
     311           0 :       sigma*=min;
     312           0 :       min = mean-sigma;
     313           0 :       max = mean+sigma;
     314             : 
     315           0 :     }
     316             :   }
     317             :  
     318           0 :   char  name[1000];
     319           0 :   snprintf(name,1000,"%s CalDet as function of det",GetTitle());
     320           0 :   TH1F * his = new TH1F(name,name,kNdet, 0, kNdet);
     321           0 :   for(Int_t det = 0; det< kNdet; det++){
     322           0 :     his->Fill(det+0.5,GetValue(det));
     323             :   }
     324             : 
     325           0 :   his->SetMaximum(max);
     326           0 :   his->SetMinimum(min);
     327           0 :   return his;
     328           0 : }
     329             : 
     330             : //_____________________________________________________________________________
     331             : TH2F *AliTRDCalDet::MakeHisto2DCh(Int_t ch, Float_t min, Float_t max, Int_t type)
     332             : {
     333             :   //
     334             :   // Make 2D graph
     335             :   // ch    - chamber
     336             :   // type -1 = user defined range
     337             :   //       0 = nsigma cut nsigma=min
     338             :   //       1 = delta cut around median delta=min
     339             :   //
     340             : 
     341           0 :   gStyle->SetPalette(1);
     342           0 :   if (type>=0){
     343           0 :     if (type==0){
     344             :       // nsigma range
     345           0 :       Float_t mean  = GetMean();
     346           0 :       Float_t sigma = GetRMS();
     347           0 :       Float_t nsigma = TMath::Abs(min);
     348           0 :       min = mean-nsigma*sigma;
     349           0 :       max = mean+nsigma*sigma;
     350           0 :     }
     351           0 :     if (type==1){
     352             :       // fixed range
     353           0 :       Float_t mean   = GetMedian();
     354             :       Float_t  delta = min;
     355           0 :       min = mean-delta;
     356           0 :       max = mean+delta;
     357           0 :     }
     358           0 :     if (type==2){
     359           0 :       Double_t sigma;
     360           0 :       Float_t mean  = GetLTM(&sigma,max);
     361           0 :       sigma*=min;
     362           0 :       min = mean-sigma;
     363           0 :       max = mean+sigma;
     364             : 
     365           0 :     }
     366             :   }
     367             :     
     368           0 :   AliTRDgeometry *trdGeo = new AliTRDgeometry();
     369             : 
     370           0 :   Double_t poslocal[3]  = {0.0,0.0,0.0};
     371           0 :   Double_t posglobal[3] = {0.0,0.0,0.0};
     372             :   
     373           0 :   char  name[1000];
     374           0 :   snprintf(name,1000,"%s CalDet 2D ch %d",GetTitle(),ch);
     375           0 :   TH2F * his = new TH2F(name, name, 400,-400.0,400.0,400,-400.0,400.0);
     376             : 
     377             :   // Where we begin
     378           0 :   Int_t offsetch = 6*ch;
     379             :   
     380             : 
     381           0 :   for (Int_t isec = 0; isec < kNsect; isec++){
     382           0 :     for(Int_t ipl = 0; ipl < kNplan; ipl++){
     383           0 :       Int_t det   = offsetch+isec*30+ipl;
     384           0 :       AliTRDpadPlane *padPlane = trdGeo->GetPadPlane(ipl,ch);
     385           0 :       for (Int_t icol=0; icol<padPlane->GetNcols(); icol++){
     386           0 :         poslocal[0] = trdGeo->GetTime0(ipl);
     387           0 :         poslocal[2] = padPlane->GetRowPos(0);
     388           0 :         poslocal[1] = padPlane->GetColPos(icol);
     389           0 :         trdGeo->RotateBack(det,poslocal,posglobal);
     390           0 :         Int_t binx = 1+TMath::Nint((posglobal[0]+400.0)*0.5);
     391           0 :         Int_t biny = 1+TMath::Nint((posglobal[1]+400.0)*0.5);
     392           0 :         his->SetBinContent(binx,biny,fData[det]);
     393             :       }
     394             :     }    
     395             :   }
     396           0 :   his->SetXTitle("x (cm)");
     397           0 :   his->SetYTitle("y (cm)");
     398           0 :   his->SetStats(0);
     399           0 :   his->SetMaximum(max);
     400           0 :   his->SetMinimum(min);
     401           0 :   delete trdGeo;
     402           0 :   return his;
     403           0 : }
     404             : 
     405             : //_____________________________________________________________________________
     406             : TH2F *AliTRDCalDet::MakeHisto2DSmPl(Int_t sm, Int_t pl, Float_t min, Float_t max, Int_t type)
     407             : {
     408             :   //
     409             :   // Make 2D graph
     410             :   // sm    - supermodule number
     411             :   // pl    - plane number
     412             :   // type -1 = user defined range
     413             :   //       0 = nsigma cut nsigma=min
     414             :   //       1 = delta cut around median delta=min
     415             :   //
     416             : 
     417           0 :   gStyle->SetPalette(1);
     418           0 :   if (type>=0){
     419           0 :     if (type==0){
     420             :       // nsigma range
     421           0 :       Float_t mean  = GetMean();
     422           0 :       Float_t sigma = GetRMS();
     423           0 :       Float_t nsigma = TMath::Abs(min);
     424           0 :       min = mean-nsigma*sigma;
     425           0 :       max = mean+nsigma*sigma;
     426           0 :     }
     427           0 :     if (type==1){
     428             :       // fixed range
     429           0 :       Float_t mean   = GetMedian();
     430             :       Float_t  delta = min;
     431           0 :       min = mean-delta;
     432           0 :       max = mean+delta;
     433           0 :     }
     434           0 :     if (type==2){
     435           0 :       Double_t sigma;
     436           0 :       Float_t mean  = GetLTM(&sigma,max);
     437           0 :       sigma*=min;
     438           0 :       min = mean-sigma;
     439           0 :       max = mean+sigma;
     440             : 
     441           0 :     }
     442             :   }
     443             :      
     444           0 :   AliTRDgeometry *trdGeo = new AliTRDgeometry();
     445           0 :   AliTRDpadPlane *padPlane0 = trdGeo->GetPadPlane(pl,0);
     446           0 :   Double_t row0    = padPlane0->GetRow0();
     447           0 :   Double_t col0    = padPlane0->GetCol0();
     448             : 
     449           0 :   char  name[1000];
     450           0 :   snprintf(name,1000,"%s CalDet 2D sm %d and pl %d",GetTitle(),sm,pl);
     451           0 :   TH2F * his = new TH2F( name, name, 5,  -TMath::Abs(row0),  TMath::Abs(row0)
     452           0 :                                    , 4,-2*TMath::Abs(col0),2*TMath::Abs(col0));
     453             : 
     454             :   // Where we begin
     455           0 :   Int_t offsetsmpl = 30*sm+pl;
     456             :   
     457             : 
     458           0 :   for (Int_t k = 0; k < kNcham; k++){
     459           0 :     Int_t det = offsetsmpl+k*6;
     460           0 :     Int_t kb  = kNcham-1-k;
     461           0 :     his->SetBinContent(kb+1,2,fData[det]);
     462           0 :     his->SetBinContent(kb+1,3,fData[det]);
     463             :   }
     464           0 :   his->SetXTitle("z (cm)");
     465           0 :   his->SetYTitle("y (cm)");
     466           0 :   his->SetStats(0);
     467           0 :   his->SetMaximum(max);
     468           0 :   his->SetMinimum(min);
     469           0 :   delete trdGeo;
     470           0 :   return his;
     471           0 : }
     472             : 
     473             : //_____________________________________________________________________________
     474             : void AliTRDCalDet::Add(Float_t c1)
     475             : {
     476             :   //
     477             :   // Add constant for all detectors
     478             :   //
     479             : 
     480           0 :   for (Int_t idet = 0; idet < kNdet; idet++) {
     481           0 :      fData[idet] += c1;
     482             :   }
     483           0 : }
     484             : 
     485             : //_____________________________________________________________________________
     486             : void AliTRDCalDet::Multiply(Float_t c1)
     487             : {
     488             :     //
     489             :     // multiply constant for all detectors
     490             :     //
     491           0 :     for (Int_t idet = 0; idet < kNdet; idet++) {
     492           0 :       fData[idet] *= c1;
     493             :     }
     494           0 : }
     495             : 
     496             : //_____________________________________________________________________________
     497             : void AliTRDCalDet::Add(const AliTRDCalDet * calDet, Double_t c1)
     498             : {
     499             :     //
     500             :     // add caldet channel by channel multiplied by c1
     501             :     //
     502           0 :     for (Int_t idet = 0; idet < kNdet; idet++) {
     503           0 :       fData[idet] += calDet->GetValue(idet)*c1;
     504             :     }
     505           0 : }
     506             : 
     507             : //_____________________________________________________________________________
     508             : void AliTRDCalDet::Multiply(const AliTRDCalDet * calDet)
     509             : {
     510             :     //
     511             :     // multiply caldet channel by channel 
     512             :     //
     513           0 :     for (Int_t idet = 0; idet < kNdet; idet++) {
     514           0 :       fData[idet] *= calDet->GetValue(idet);
     515             :     }
     516           0 : }
     517             : 
     518             : //_____________________________________________________________________________
     519             : void AliTRDCalDet::Divide(const AliTRDCalDet * calDet)
     520             : {
     521             :     //
     522             :     // divide caldet channel by channel 
     523             :     //
     524             :  Float_t kEpsilon=0.00000000000000001;
     525           0 :     for (Int_t idet = 0; idet < kNdet; idet++) {
     526           0 :       if (TMath::Abs(calDet->GetValue(idet))>kEpsilon){
     527           0 :         fData[idet] /= calDet->GetValue(idet);
     528           0 :         }
     529             :     }
     530           0 : }
     531             : //_____________________________________________________________________________
     532             : Double_t AliTRDCalDet::CalcMean(Bool_t wghtPads, Int_t &calib)
     533             : {
     534             :   // Calculate the mean value after rejection of the chambers not calibrated
     535             :   // wghPads = kTRUE weighted with the number of pads in case of a AliTRDCalPad created (t0)
     536             :   // calib = number of used chambers for the mean calculation
     537             : 
     538             :   Int_t iSM;
     539             :   Double_t sum = 0.0;
     540             :   Int_t ndet = 0;
     541             :   Double_t meanALL = 0.0;
     542             :   Double_t meanWP = 0.0;
     543             :   Double_t pads=0.0;
     544             :   Double_t padsALL=(144*16*24+144*12*6)*18;
     545           0 :   Double_t *meanSM = new Double_t[18];
     546           0 :   Double_t *meanSMWP = new Double_t[18];
     547             :   
     548           0 :   for (Int_t i = 0; i < 18; i++) {
     549           0 :     meanSM[i]=0.0;
     550           0 :     meanSMWP[i]=0.0;
     551             :   }
     552             : 
     553             :   Int_t det = 0;
     554           0 :   while(det < 540) {
     555           0 :     Float_t val= fData[det];
     556           0 :     iSM = (Int_t)(det / (6*5));
     557           0 :     pads=(((Int_t) (det % (6 * 5)) / 6) == 2) ? 144*12 : 144*16;
     558           0 :     meanALL+=val/540.;
     559           0 :     meanSM[iSM]+=val/30.;
     560           0 :     meanWP+=val*(pads/padsALL);
     561           0 :     meanSMWP[iSM]+=val*(pads/(padsALL/18.));
     562             :     
     563             :     /*    
     564             :           printf(" det %d  val %.3f meanALL %.5f meanWP %.5f meanSM[%d] %.5f meanSMWP[%d] %.5f \n",
     565             :           det,
     566             :           val,
     567             :           meanALL,
     568             :           meanWP,
     569             :           iSM,
     570             :           meanSM[iSM],
     571             :           iSM,
     572             :           meanSMWP[iSM]);
     573             :     */
     574             :    
     575           0 :     det++;
     576             :   }
     577             : 
     578             :   // debug
     579             :   
     580             :   //  printf(" ALL %.5f \n",meanALL);
     581             : //    printf(" WP %.5f \n",meanWP);
     582             : //    for(Int_t i=0; i<18; i++) printf(" SM %02d %.5f \n",i,meanSM[i]);
     583             : //    for(Int_t i=0; i<18; i++) printf(" SM %02d %.5f \n",i,meanSMWP[i]);
     584             : //  
     585             : 
     586             :   det=0;
     587           0 :   while(det < 540) {
     588           0 :     Float_t val= fData[det];
     589           0 :     if (( (!wghtPads) &&
     590           0 :           (TMath::Abs(val - meanALL) > 0.0001) &&
     591           0 :           (TMath::Abs(val - meanSM[(Int_t)(det / (6*5))]) > 0.0001) ) ||
     592           0 :         ( (wghtPads) &&
     593           0 :           (TMath::Abs(val - meanWP) > 0.0001) &&
     594           0 :           (TMath::Abs(val - meanSMWP[(Int_t)(det / (6*5) )]) > 0.0001) )
     595             :         ) {
     596           0 :                         if(val <= 50.) { // get rid of exb alternative mean values
     597           0 :                                 sum+=val;
     598           0 :                                 ndet++;
     599           0 :                         }
     600             :     }
     601           0 :     det++;
     602             :   }
     603             : 
     604           0 :   delete []meanSM;
     605           0 :   delete []meanSMWP;
     606             : 
     607           0 :   calib=ndet;
     608           0 :   return (sum!=0.0 ? sum/ndet : -1);
     609             : }
     610             : //_____________________________________________________________________________
     611             : Double_t AliTRDCalDet::CalcMean(Bool_t wghtPads)
     612             : {
     613             :   // Calculate the mean value after rejection of the chambers not calibrated
     614             :   // wghPads = kTRUE weighted with the number of pads in case of a AliTRDCalPad created (t0)
     615             :   // calib = number of used chambers for the mean calculation
     616             : 
     617           0 :   Int_t calib = 0;                                                                                                                                                                                  
     618           0 :   return CalcMean(wghtPads, calib);
     619           0 : }
     620             : //_____________________________________________________________________________
     621             : Double_t AliTRDCalDet::CalcRMS(Bool_t wghtPads, Int_t &calib)
     622             : {
     623             :   // Calculate the RMS value after rejection of the chambers not calibrated
     624             :   // wghPads = kTRUE weighted with the number of pads in case of a AliTRDCalPad created (t0)
     625             :   // calib = number of used chambers for the mean calculation
     626             :   
     627             :   Int_t iSM;
     628             :   Double_t sum = 0.0;
     629             :   Int_t ndet = 0;
     630             :   Double_t meanALL = 0.0;
     631             :   Double_t meanWP = 0.0;
     632             :   Double_t pads=0.0;
     633             :   Double_t padsALL=(144*16*24+144*12*6)*18;
     634           0 :   Double_t *meanSM = new Double_t[18];
     635           0 :   Double_t *meanSMWP = new Double_t[18];
     636             :   
     637           0 :   for (Int_t i = 0; i < 18; i++) {
     638           0 :     meanSM[i]=0.0;
     639           0 :     meanSMWP[i]=0.0;
     640             :   }
     641             :   
     642             :   Int_t det = 0;
     643           0 :   while(det < 540) {
     644           0 :     Float_t val= fData[det];
     645           0 :     iSM = (Int_t)(det / (6*5));
     646           0 :     pads=(((Int_t) (det % (6 * 5)) / 6) == 2) ? 144*12 : 144*16;
     647           0 :     meanALL+=val/540.;
     648           0 :     meanSM[iSM]+=val/30.;
     649           0 :     meanWP+=val*(pads/padsALL);
     650           0 :     meanSMWP[iSM]+=val*(pads/(padsALL/18.));
     651           0 :     det++;
     652             :   }
     653             :   
     654             :   Double_t mean=0.0;
     655           0 :   if(!wghtPads) mean= meanALL;
     656           0 :   if(wghtPads) mean= meanWP;
     657             :   
     658             :   det=0;
     659           0 :   while(det < 540) {
     660           0 :     Float_t val= fData[det];
     661           0 :     if (( (!wghtPads) &&
     662           0 :                  (TMath::Abs(val - meanALL) > 0.0001) &&
     663           0 :                  (TMath::Abs(val - meanSM[(Int_t)(det / (6*5))]) > 0.0001) ) ||
     664           0 :         ( (wghtPads) &&
     665           0 :                  (TMath::Abs(val - meanWP) > 0.0001) &&
     666           0 :                  (TMath::Abs(val - meanSMWP[(Int_t)(det / (6*5) )]) > 0.0001) )
     667             :         ) {
     668           0 :                         if(val <= 50.) { // get rid of exb alternative mean values
     669           0 :                                 sum+=(val-mean)*(val-mean);
     670           0 :                                 ndet++;
     671           0 :                         }
     672             :     }
     673           0 :     det++;
     674             :   }
     675             :   
     676           0 :   delete []meanSM;
     677           0 :   delete []meanSMWP;
     678             :   
     679           0 :   calib=ndet;
     680           0 :   return (sum!=0.0 ? TMath::Sqrt(sum/ndet) : -1);
     681             : }
     682             : //_____________________________________________________________________________
     683             : Double_t AliTRDCalDet::CalcRMS(Bool_t wghtPads)
     684             : {
     685             :   // Calculate the RMS value after rejection of the chambers not calibrated
     686             :   // wghPads = kTRUE weighted with the number of pads in case of a AliTRDCalPad created (t0)
     687             :   // calib = number of used chambers for the mean calculation
     688             :   
     689           0 :   Int_t calib = 0;
     690           0 :         return CalcRMS(wghtPads, calib);
     691           0 : }
     692             : //_____________________________________________________________________________
     693             : Double_t AliTRDCalDet::GetMeanSM(Bool_t wghtPads, Int_t sector) const
     694             : {
     695             :   // Calculate the mean value for given sector
     696             :   // wghPads = kTRUE weighted with the number of pads in case of a AliTRDCalPad created (t0)
     697             :         
     698             :   Int_t iSM;
     699             :   Double_t meanALL = 0.0;
     700             :   Double_t meanWP = 0.0;
     701             :   Double_t pads=0.0;
     702             :   Double_t padsALL=(144*16*24+144*12*6)*18;
     703           0 :   Double_t *meanSM = new Double_t[18];
     704           0 :   Double_t *meanSMWP = new Double_t[18];
     705             :         
     706           0 :   for (Int_t i = 0; i < 18; i++) {
     707           0 :     meanSM[i]=0.0;
     708           0 :     meanSMWP[i]=0.0;
     709             :   }
     710             :         
     711             :   Int_t det = 0;
     712           0 :   while(det < 540) {
     713           0 :     Float_t val= fData[det];
     714           0 :     iSM = (Int_t)(det / (6*5));
     715           0 :     pads=(((Int_t) (det % (6 * 5)) / 6) == 2) ? 144*12 : 144*16;
     716           0 :     meanALL+=val/540.;
     717           0 :     meanSM[iSM]+=val/30.;
     718           0 :     meanWP+=val*(pads/padsALL);
     719           0 :     meanSMWP[iSM]+=val*(pads/(padsALL/18.));
     720             :                 
     721           0 :     det++;
     722             :   }
     723             :         
     724             :   Double_t mean=0.0;
     725           0 :   if(!wghtPads) mean= meanSM[sector];
     726           0 :   if(wghtPads) mean= meanSMWP[sector];
     727             :         
     728           0 :   delete []meanSM;
     729           0 :   delete []meanSMWP;
     730             :         
     731           0 :   return mean;
     732             : }

Generated by: LCOV version 1.11