LCOV - code coverage report
Current view: top level - ITS/ITSbase - AliITSCalibrationSPD.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 64 144 44.4 %
Date: 2016-06-14 17:26:59 Functions: 13 20 65.0 %

          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             : #include "TArrayI.h"
      16             : #include "TBuffer.h"
      17             : #include "AliITSCalibrationSPD.h"
      18             : 
      19             : ///////////////////////////////////////////////////////////////////////////
      20             : //  Calibration class for set:ITS                   
      21             : //  Specific subdetector implementation for         
      22             : //  Silicon pixels                                  
      23             : //
      24             : //  Modified by D. Elia, G.E. Bruno, H. Tydesjo
      25             : ///////////////////////////////////////////////////////////////////////////
      26             : 
      27         118 : ClassImp(AliITSCalibrationSPD)
      28             : 
      29             : //______________________________________________________________________
      30             : AliITSCalibrationSPD::AliITSCalibrationSPD():
      31        1920 : AliITSCalibration(),
      32        1920 : fNrBad(0),
      33       11520 : fBadChannels(0){
      34             :   // constructor
      35             : 
      36        1920 :    SetDataType("simulated");
      37        1920 :    ClearBad();
      38        3840 : }
      39             : //____________________________________________________________________________
      40             : void AliITSCalibrationSPD::ClearBad() {
      41             :   // clear all bad pixels (single+chips)
      42        3840 :   fBadChannels.Reset();
      43        1920 :   fNrBad=0;
      44       23040 :   for (UInt_t chip=0; chip<5; chip++) {
      45        9600 :     fBadChip[chip]=kFALSE;
      46             :   }
      47        1920 : }
      48             : //____________________________________________________________________________
      49             : void AliITSCalibrationSPD::AddBad(UInt_t col, UInt_t row) {
      50             :   // add single bad pixel 
      51           0 :   fBadChannels.Set(fNrBad*2+2);
      52           0 :   fBadChannels.AddAt(col,fNrBad*2);
      53           0 :   fBadChannels.AddAt(row,fNrBad*2+1);
      54           0 :   fNrBad++;
      55           0 : }
      56             : //____________________________________________________________________________
      57             : void AliITSCalibrationSPD::SetChipBad(UInt_t chip) {
      58             :   // set full chip bad
      59           0 :   if (chip>=5) {AliError("Wrong chip number");
      60           0 :   }
      61             :   else {
      62           0 :     fBadChip[chip]=kTRUE;
      63             :   }
      64           0 : }
      65             : //____________________________________________________________________________
      66             : void AliITSCalibrationSPD::UnSetChipBad(UInt_t chip) {
      67             :   // unset full chip bad
      68           0 :   if (chip>=5 ) {AliError("Wrong chip number");
      69           0 :   }
      70             :   else {
      71           0 :     fBadChip[chip]=kFALSE;
      72             :   }
      73           0 : }
      74             : //____________________________________________________________________________
      75             : Int_t AliITSCalibrationSPD::GetBadColAt(UInt_t index) const {
      76             :   // Get column of index-th bad pixel
      77     3271544 :   if ((Int_t)index<GetNrBadSingle()) {
      78     1635772 :     return fBadChannels.At(index*2);
      79             :   }
      80             :   else {
      81           0 :     Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
      82             :     Int_t badChipsFound =0;
      83           0 :     for (UInt_t chip=0; chip<5; chip++) {
      84           0 :       if (fBadChip[chip]) badChipsFound++;
      85           0 :       if (badChipIndex==badChipsFound-1) {
      86           0 :         Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
      87           0 :         return chip*32 + badPixelIndex/256;
      88             :       }
      89             :     }
      90           0 :   }
      91           0 :   AliError(Form("Index %d is out of bounds - returning -1",index));
      92           0 :   return -1;
      93     1635772 : }
      94             : //____________________________________________________________________________
      95             : Int_t AliITSCalibrationSPD::GetBadRowAt(UInt_t index) const {
      96             :   // Get row of index-th bad pixel
      97     1251684 :   if ((Int_t)index<GetNrBadSingle()) {
      98      625842 :     return fBadChannels.At(index*2+1);
      99             :   }
     100             :   else {
     101           0 :     Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
     102             :     Int_t badChipsFound =0;
     103           0 :     for (UInt_t chip=0; chip<5; chip++) {
     104           0 :       if (fBadChip[chip]) badChipsFound++;
     105           0 :       if (badChipIndex==badChipsFound-1) {
     106           0 :         Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
     107           0 :         return badPixelIndex%256;
     108             :       }
     109             :     }
     110           0 :   }
     111           0 :   AliError(Form("Index %d is out of bounds - returning -1",index));
     112           0 :   return -1;
     113      625842 : }
     114             : //____________________________________________________________________________
     115             : void AliITSCalibrationSPD::GetBadPixel(Int_t index, Int_t &row, Int_t &col) const {
     116             :   // i: is the i-th bad pixel in single bad pixel list
     117             :   // row: is the corresponding row (-1 if i is out of range)
     118             :   // col: is the corresponding column (-1 if i is out of range)
     119     5183844 :   row = -1;
     120     2591922 :   col = -1;
     121     5183844 :   if(index>=0 && index<GetNrBadSingle()){
     122      625842 :     col = GetBadColAt(index);
     123      625842 :     row = GetBadRowAt(index);
     124      625842 :     return;
     125             :   }
     126             :   else {
     127     1966080 :     if (index>=0) {
     128     1966080 :       Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
     129             :       Int_t badChipsFound =0;
     130    11796480 :       for (UInt_t chip=0; chip<5; chip++) {
     131    11796480 :         if (fBadChip[chip]) badChipsFound++;
     132     5898240 :         if (badChipIndex==badChipsFound-1) {
     133     1966080 :           Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
     134     1966080 :           col = chip*32 + badPixelIndex/256;
     135     1966080 :           row = badPixelIndex%256;
     136             :           return;
     137             :         }
     138             :       }
     139           0 :     }
     140             :   }
     141           0 :   AliError(Form("Index %d is out of bounds - nothing done",index));
     142     2591922 : }
     143             : //___________________________________________________________________________
     144             : Int_t  AliITSCalibrationSPD::GetNrBad() const {
     145             :   // Total number of bad pixels (including bad chips) in a given module
     146             :   Int_t bad=0;
     147             :   // single pixels:
     148     5192500 :   bad+=fNrBad;
     149             :   // whole chips:
     150    31155000 :   for (UInt_t chip=0; chip<5; chip++) {
     151    12981250 :     bad+=fBadChip[chip]*32*256;
     152             :   }
     153     2596250 :   return bad;
     154             : }
     155             : //___________________________________________________________________________
     156             : Int_t  AliITSCalibrationSPD::GetNrBadInChip(Int_t chip) const {
     157             :   // Total number of bad pixels (including bad chips) in a given chip: chip range [0,4]
     158        9600 :   if(chip<0 || chip>4) {AliError("Wrong chip number"); return -1;}
     159        5040 :   if (fBadChip[chip]) return 32*256;
     160             :   else {
     161             :     Int_t bad=0;
     162     2028980 :     for (UInt_t i=0; i<fNrBad; i++) {
     163     1009930 :       Int_t col = GetBadColAt(i);
     164     1009930 :       if (col!=-1) {
     165     1211916 :         if (GetChipIndexFromCol(col)==chip) bad++;
     166             :       }
     167             :     }
     168             :     return bad;
     169             :   }
     170        4800 : }
     171             : //___________________________________________________________________________
     172             : Int_t  AliITSCalibrationSPD::GetNrBadInColumn(Int_t col) const {
     173             :   // Total number of bad pixels (including bad chips) in a given column: col. range [0,159]
     174           0 :   if(col<0 || col>159) {AliError("Wrong column number"); return -1;}
     175           0 :   if (fBadChip[GetChipIndexFromCol(col)]) return 256;
     176             :   else {
     177             :     Int_t bad=0;
     178           0 :     for (UInt_t i=0; i<fNrBad; i++) {
     179           0 :       if (GetBadColAt(i)==col) bad++;
     180             :     }
     181             :     return bad;
     182             :   }
     183           0 : }
     184             : //______________________________________________________________________
     185             : Bool_t AliITSCalibrationSPD::IsBad() const {
     186             :   // Are all chips of this module bad?
     187        7609 :   for (UInt_t chip=0; chip<5; chip++) {
     188        4427 :     if (!fBadChip[chip]) return kFALSE;
     189             :   }
     190         149 :   return kTRUE;
     191        1990 : }
     192             : //______________________________________________________________________
     193             : Bool_t AliITSCalibrationSPD::IsChipBad(Int_t chip) const {
     194             :   // Is the full chip bad?
     195        9600 :   return (GetNrBadInChip(chip)==32*256);
     196             : }
     197             : //______________________________________________________________________
     198             : Bool_t AliITSCalibrationSPD::IsColumnBad(Int_t col) const {
     199             :   // Is the full column bad?
     200           0 :   return (GetNrBadInColumn(col)==256);
     201             : }
     202             : //____________________________________________________________________________
     203             : Bool_t AliITSCalibrationSPD::IsPixelBad(Int_t col, Int_t row) const {
     204             :   // Is this pixel bad?
     205           0 :   if(col<0 || col>159) {AliError("Wrong column number"); return kFALSE;}
     206           0 :   Int_t chip = GetChipIndexFromCol(col);
     207           0 :   if (fBadChip[chip]) return kTRUE;
     208           0 :   for (UInt_t i=0; i<fNrBad; i++) { 
     209           0 :     if (GetBadColAt(i)==col && GetBadRowAt(i)==row) {
     210           0 :       return kTRUE;
     211             :     }
     212             :   }
     213           0 :   return kFALSE;
     214           0 : }
     215             : //______________________________________________________________________
     216             : Int_t AliITSCalibrationSPD::GetChipIndexFromCol(UInt_t col) const {
     217             :   // returns chip index for specific column
     218     2019860 :   if(col>=160) {AliWarning("Wrong column number"); return -1;}
     219     1009930 :   return col/32;
     220     1009930 : }
     221             : //______________________________________________________________________
     222             : void AliITSCalibrationSPD::SetNrBad(UInt_t /*nr*/) {
     223             :   // should not be used anymore !!!
     224           0 :   AliError("This method should not be used anymore. Use SetNrBadSingle instead!!!");
     225           0 : }
     226             : //______________________________________________________________________
     227             : void AliITSCalibrationSPD::Streamer(TBuffer &ruub) {
     228             :   // Stream an object of class AliITSCalibrationSPD.
     229        3840 :   UInt_t ruus, ruuc;
     230        1920 :   if (ruub.IsReading()) {
     231        1920 :     Version_t ruuv = ruub.ReadVersion(&ruus, &ruuc); if (ruuv) { }
     232        1920 :     AliITSCalibration::Streamer(ruub);
     233        1920 :     if (ruuv >= 8) {
     234        1920 :       ruub >> fNrBad;
     235        1920 :       fBadChannels.Streamer(ruub);
     236        1920 :       ruub.ReadStaticArray((bool*)fBadChip);
     237        1920 :     }
     238             :     else {
     239           0 :       Double_t dummy;
     240           0 :       ruub >> dummy;
     241           0 :       ruub >> dummy;
     242           0 :       ruub >> dummy;
     243           0 :       ruub >> dummy;
     244           0 :       ruub >> dummy;
     245           0 :       ruub >> dummy;
     246           0 :       ruub >> dummy;
     247           0 :       ruub >> fNrBad;
     248           0 :       if (ruuv == 7) {
     249           0 :         fBadChannels.Streamer(ruub);
     250           0 :         ruub.ReadStaticArray((bool*)fBadChip);
     251           0 :       }
     252             :       else {
     253           0 :         if (ruuv == 6) {
     254           0 :           fBadChannels.Streamer(ruub);
     255           0 :         }
     256             :         else {
     257           0 :           TArrayI fBadChannelsV1;
     258           0 :           fBadChannelsV1.Streamer(ruub);
     259           0 :           fBadChannels.Set(fNrBad*2);
     260           0 :           for (UInt_t i=0; i<fNrBad*2; i++) {
     261           0 :             fBadChannels[i] = fBadChannelsV1[i];
     262             :           }
     263           0 :         }
     264           0 :         for (UInt_t i=0; i<5; i++) {
     265           0 :           fBadChip[i]=kFALSE;
     266             :         }
     267             :       }
     268           0 :     }
     269        1920 :     ruub.CheckByteCount(ruus, ruuc, AliITSCalibrationSPD::IsA());
     270        1920 :   }
     271             :   else {
     272           0 :     ruuc = ruub.WriteVersion(AliITSCalibrationSPD::IsA(), kTRUE);
     273           0 :     AliITSCalibration::Streamer(ruub);
     274           0 :     ruub << fNrBad;
     275           0 :     fBadChannels.Streamer(ruub);
     276           0 :     ruub.WriteArray(fBadChip, 5);
     277           0 :     ruub.SetByteCount(ruuc, kTRUE);
     278             :   }
     279        1920 : }

Generated by: LCOV version 1.11