LCOV - code coverage report
Current view: top level - TOF/TOFbase - AliTOFDigitMap.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 56 145 38.6 %
Date: 2016-06-14 17:26:59 Functions: 12 23 52.2 %

          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             : /*
      17             : $Log$
      18             : Revision 1.12  2007/02/20 15:57:00  decaro
      19             : Raw data update: to read the TOF raw data defined in UNPACKED mode
      20             : 
      21             : */
      22             : 
      23             : ////////////////////////////////////////////////////////////////////////
      24             : //
      25             : // AliTOFDigitMap class
      26             : //
      27             : // digitmap enables fast check if the pad was already digit.
      28             : 
      29             : // The index of a AliTOFdigit is saved in the each digitmap "cell"
      30             : // (there is an offset +1, because the index can be zero and zero
      31             : // means empty cell).
      32             : // In TOF, number of strips varies according plate type, the highest
      33             : // number is in plate C. For all plates is used this number, so the
      34             : // size of the digitmap is a little bit greater than necessary, but it
      35             : // simplifies the access algorithm.
      36             : // 
      37             : //
      38             : // Author: F. Pierella based on AliTOFHitMap
      39             : //
      40             : // Modified by A. De Caro
      41             : //
      42             : ///////////////////////////////////////////////////////////////////////
      43             : 
      44             : #include "AliLog.h"
      45             : 
      46             : #include "AliTOFDigitMap.h"
      47             : #include "AliTOFGeometry.h"
      48             : 
      49          26 : ClassImp(AliTOFDigitMap)
      50             : 
      51          27 : AliTOFDigitMap::AliTOFDigitMap():
      52          27 :   fNSector(AliTOFGeometry::NSectors()),
      53          27 :   fNplate(AliTOFGeometry::NPlates()),
      54          27 :   fNstrip(AliTOFGeometry::NStripC()),
      55          27 :   fNpx(AliTOFGeometry::NpadX()),
      56          27 :   fNpz(AliTOFGeometry::NpadZ()),
      57          27 :   fMaxIndex(-1),
      58          27 :   fDigitMap(0x0)
      59         135 : {
      60             : //
      61             : // Default ctor
      62             : //
      63             : 
      64          27 :   fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
      65          54 :   fDigitMap = new Int_t*[fMaxIndex];
      66             : 
      67    13297014 :   for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
      68          27 :   Clear();
      69          54 : }
      70             : 
      71             : ////////////////////////////////////////////////////////////////////////
      72             : AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & digitMap):
      73           0 :   TObject(digitMap),
      74           0 :   fNSector(digitMap.fNSector),
      75           0 :   fNplate(digitMap.fNplate),
      76           0 :   fNstrip(digitMap.fNstrip),
      77           0 :   fNpx(digitMap.fNpx),
      78           0 :   fNpz(digitMap.fNpz),
      79           0 :   fMaxIndex(-1),
      80           0 :   fDigitMap(0x0)
      81           0 : {
      82             :   //
      83             :   // Copy constructor
      84             :   //
      85           0 :   fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
      86           0 :   fDigitMap = new Int_t*[fMaxIndex];
      87           0 :   for (Int_t i=0; i<fMaxIndex; i++) {
      88           0 :     fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
      89           0 :     for (Int_t j=0; j<kMaxDigitsPerPad; j++)
      90           0 :       fDigitMap[i][j]=digitMap.fDigitMap[i][j];
      91             :   }
      92           0 : }
      93             : 
      94             : ////////////////////////////////////////////////////////////////////////
      95             : AliTOFDigitMap & AliTOFDigitMap::operator=(const AliTOFDigitMap & digitMap)
      96             : {
      97             :   //
      98             :   // Assignment operator
      99             :   //
     100             :   
     101           0 :   if (this != &digitMap) {
     102           0 :     TObject::operator=(digitMap);
     103           0 :     fNSector=digitMap.fNSector;
     104           0 :     fNplate=digitMap.fNplate;
     105           0 :     fNstrip=digitMap.fNstrip;
     106           0 :     fNpx=digitMap.fNpx;
     107           0 :     fNpz=digitMap.fNpz;
     108           0 :     fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
     109           0 :     for (Int_t i=0; i<fMaxIndex; ++i) delete [] fDigitMap[i];
     110           0 :     delete [] fDigitMap;
     111           0 :     fDigitMap = new Int_t*[fMaxIndex];
     112           0 :     for (Int_t i=0; i<fMaxIndex; i++) {
     113           0 :       fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
     114           0 :       for (Int_t j=0; j<kMaxDigitsPerPad; j++)
     115           0 :         fDigitMap[i][j]=digitMap.fDigitMap[i][j];
     116             :     }
     117           0 :   }
     118           0 :   return *this;
     119             : }
     120             : 
     121             :  
     122             : ////////////////////////////////////////////////////////////////////////
     123             : AliTOFDigitMap::~AliTOFDigitMap()
     124         162 : {
     125             : //
     126             : // Destructor
     127             : //
     128          27 :   if (fDigitMap) {
     129    17729334 :     for (Int_t i=0; i<fMaxIndex; i++)  delete[] fDigitMap[i];
     130          54 :     delete [] fDigitMap;
     131             :   }
     132             : 
     133             : 
     134          81 : }
     135             : 
     136             : ////////////////////////////////////////////////////////////////////////
     137             : void AliTOFDigitMap::Clear(const Option_t*)
     138             : {
     139             :   //
     140             :   // Clear digitmap
     141             :   //
     142             : 
     143    10178013 :   for(Int_t ii=0; ii<fMaxIndex; ii++) {
     144   111957120 :     for (Int_t jj=0; jj<kMaxDigitsPerPad; jj++) {
     145    50889600 :       fDigitMap[ii][jj] = 0;
     146             :     }
     147             :   }
     148             :  
     149          31 : }
     150             : 
     151             : ////////////////////////////////////////////////////////////////////////
     152             : Int_t AliTOFDigitMap::CheckedIndex(Int_t * const vol) const
     153             : {
     154             :   //
     155             :   // Return checked index for vol
     156             :   //
     157             : 
     158             :   Int_t index =
     159     1888176 :     vol[0]*fNplate*fNstrip*fNpx*fNpz+             // sector
     160     1258784 :     vol[1]*fNstrip*fNpx*fNpz+                     // plate
     161     1258784 :     vol[2]*fNpx*fNpz+                             // strip
     162     1258784 :     vol[3]*fNpz+                                  // padx
     163      629392 :     vol[4];                                       // padz
     164             : 
     165      629392 :     if (index >= fMaxIndex || index < 0) {
     166           0 :       AliError("CheckedIndex - input outside bounds");
     167           0 :       return -1;
     168             :     } else {
     169      629392 :       return index;
     170             :     }
     171      629392 : }
     172             : 
     173             : ////////////////////////////////////////////////////////////////////////
     174             : void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit)
     175             : {
     176             :   //
     177             :   // Assign digit to pad vol
     178             :   //
     179             :   // 0 means empty pad, we need to shift indeces by 1
     180             : 
     181         200 :   if (fDigitMap[CheckedIndex(vol)][kMaxDigitsPerPad-1]!=0) {
     182           0 :     AliDebug(1,Form("In the volume (Se%i, Pl%i, St%i, PadR%i, Pad%i) there is not more possibility to add other digits.", vol[0], vol[1], vol[2], vol[4], vol[3]));
     183           0 :     AliDebug(1,Form("Then, the digit number %i will be not inserted in the digit map, i.e. it will be lost.", idigit));
     184           0 :     AliDebug(1,Form("Please, check the possibility to increase the digit map size (succently set to %i)", kMaxDigitsPerPad));
     185             :     return;
     186             :   }
     187             : 
     188         200 :   for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
     189             : 
     190         100 :     if (fDigitMap[CheckedIndex(vol)][slot]==0) {
     191         100 :       fDigitMap[CheckedIndex(vol)][slot]=idigit+1;
     192         100 :       break;
     193             :     }
     194             :     //else continue;
     195             : 
     196             :   }
     197             : 
     198         100 : }
     199             : 
     200             : ////////////////////////////////////////////////////////////////////////
     201             : void AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t *digitLabels) const
     202             : {
     203             :   //
     204             :   // Get all contents (digitLabels) of pad volume (vol)
     205             :   //
     206             : 
     207             :   // 0 means empty pad, we need to shift indeces by 1
     208             : 
     209             :   Int_t dummy;
     210     1887176 :     for (Int_t j=0; j<kMaxDigitsPerPad; j++) {
     211      629092 :       dummy = GetDigitIndex(vol,j);
     212      629192 :       if (dummy>=0) digitLabels[j] = dummy;
     213      628992 :       else break;
     214             :     }
     215      628992 : }
     216             : 
     217             : ////////////////////////////////////////////////////////////////////////
     218             : Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const
     219             : {
     220             :   //
     221             :   // Get one of the contents (label) of pad volume (vol)
     222             :   //
     223             : 
     224             :   // 0 means empty pad, we need to shift indeces by 1
     225             : 
     226     1258184 :   if (!(label<kMaxDigitsPerPad)) {
     227           0 :     AliWarning(Form("label (=%i) >= kMaxDigitsPerPad (=%i)", label, kMaxDigitsPerPad));
     228           0 :     return -1;
     229             :   }
     230             : 
     231      629092 :   Int_t ci = CheckedIndex(vol);
     232      629092 :   if (ci==-1) return -1;
     233             :   
     234      629092 :   Int_t dummy = fDigitMap[ci][label];
     235             :   
     236      629192 :   if (dummy>0) return dummy-1;
     237      628992 :   else return -1;
     238             : 
     239      629092 : }
     240             : 
     241             : ////////////////////////////////////////////////////////////////////////
     242             : FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const
     243             : {
     244             : //
     245             : // Check if hit cell is empty, used or unused
     246             : //
     247           0 :   Int_t inf=fDigitMap[CheckedIndex(vol)][0]; // to be modified
     248           0 :     if (inf > 0) {
     249           0 :         return kUsed;
     250           0 :     } else if (inf == 0) {
     251           0 :         return kEmpty;
     252             :     } else {
     253           0 :         return kUnused;
     254             :     }
     255           0 : }
     256             : 
     257             : ////////////////////////////////////////////////////////////////////////
     258             : Int_t AliTOFDigitMap::GetFilledCellNumber() const
     259             : {
     260             :   //
     261             :   // Returns the number of filled cells of the TOF digit map
     262             :   //
     263             : 
     264             :   Int_t counter = 0;
     265             : 
     266  1796583456 :   for (Int_t index = 0; index < fMaxIndex; ++index)
     267             :   {
     268 20657648160 :     for (Int_t label = 0; label < kMaxDigitsPerPad; ++label)
     269             :     {
     270  8981604000 :       if (fDigitMap[index][label] > 0)
     271             :       {
     272      136800 :         ++counter;
     273      136800 :         break;
     274             :       }
     275             :     }
     276             :   }
     277             : 
     278        5472 :   return counter;
     279             : }
     280             : 
     281             : ////////////////////////////////////////////////////////////////////////
     282             : Bool_t AliTOFDigitMap::StripDigitCheck(Int_t iSector, Int_t iPlate, Int_t iStrip) const
     283             : {
     284             :   //
     285             :   // Returns:
     286             :   //           kFALSE if the strip doesn't contain digits
     287             :   //           kTRUE  if the strip contains at least one digit
     288             :   //
     289             : 
     290           0 :   Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1};
     291             :   Bool_t counter = kFALSE;
     292             : 
     293           0 :   for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
     294           0 :     for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++)
     295             :       {
     296           0 :         volume[3] = iPadX;
     297           0 :         volume[4] = iPadZ;
     298           0 :         for (Int_t label=0; label<kMaxDigitsPerPad; label++) {
     299           0 :           if (GetDigitIndex(volume, label)>=0) {
     300             :             counter = kTRUE;
     301           0 :             break;
     302             :           }
     303             :         }
     304             :       }
     305             : 
     306           0 :   return counter;
     307             : 
     308           0 : }
     309             : 
     310             : ////////////////////////////////////////////////////////////////////////
     311             : Int_t AliTOFDigitMap::DigitInStrip(Int_t iSector, Int_t iPlate, Int_t iStrip) const
     312             : {
     313             :   //
     314             :   // Returns number of digits in the strip iStrip,
     315             :   //         in the plate iPlate of the sector iSector
     316             :   //
     317             : 
     318           0 :   Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1};
     319             :   Int_t counter = 0;
     320             : 
     321           0 :   for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
     322           0 :     for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++)
     323           0 :       for (Int_t label=0; label<kMaxDigitsPerPad; label++) {
     324           0 :         volume[3] = iPadX;
     325           0 :         volume[4] = iPadZ;
     326           0 :         if (GetDigitIndex(volume, label)>=0)
     327           0 :           counter++;
     328             :       }
     329             : 
     330           0 :   return counter;
     331             : 
     332           0 : }
     333             : 
     334             : ////////////////////////////////////////////////////////////////////////
     335             : Int_t AliTOFDigitMap::FilledCellsInStrip(Int_t iSector, Int_t iPlate, Int_t iStrip) const
     336             : {
     337             :   //
     338             :   // Returns number of digits in the strip iStrip,
     339             :   //         in the plate iPlate of the sector iSector
     340             :   //
     341             : 
     342           0 :   Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1};
     343             :   Int_t counter = 0;
     344             : 
     345           0 :   for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
     346           0 :     for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++) {
     347           0 :       volume[3] = iPadX;
     348           0 :       volume[4] = iPadZ;
     349           0 :       if (GetDigitIndex(volume, 0)>=0)
     350           0 :         counter++;
     351             :     }
     352             : 
     353           0 :   return counter;
     354             : 
     355           0 : }
     356             : 
     357             : ////////////////////////////////////////////////////////////////////////
     358             : void AliTOFDigitMap::ResetDigitNumber(Int_t *vol, Int_t dig)
     359             : {
     360             :   //
     361             :   // Reset digit into pad vol
     362             :   //
     363             : 
     364           0 :   for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
     365           0 :     if (fDigitMap[CheckedIndex(vol)][slot]-1==dig) {
     366           0 :       fDigitMap[CheckedIndex(vol)][slot] = 0;
     367           0 :     }
     368             :   }
     369             : 
     370           0 : }
     371             : 
     372             : ////////////////////////////////////////////////////////////////////////
     373             : void AliTOFDigitMap::ResetDigit(Int_t *vol, Int_t dig)
     374             : {
     375             :   //
     376             :   // Reset digit into pad vol
     377             :   //
     378             :   // 0 means empty pad, we need to shift indeces by 1
     379             : 
     380           0 :   fDigitMap[CheckedIndex(vol)][dig] = 0;
     381             : 
     382           0 : }
     383             : 
     384             : ////////////////////////////////////////////////////////////////////////
     385             : void AliTOFDigitMap::ResetDigit(Int_t *vol)
     386             : {
     387             :   //
     388             :   // Reset digit into pad vol
     389             :   //
     390             :   // 0 means empty pad, we need to shift indices by 1
     391             : 
     392           0 :   for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++)
     393           0 :     fDigitMap[CheckedIndex(vol)][slot] = 0;
     394             : 
     395           0 : }
     396             : 
     397             : ////////////////////////////////////////////////////////////////////////
     398             : Int_t AliTOFDigitMap::GetNumberOfDigits(Int_t *vol)
     399             : {
     400             :   //
     401             :   // Returns the number of digit
     402             :   //   into pad volume vol
     403             :   //
     404             :   // 0 means empty pad
     405             :   //
     406             : 
     407             :   Int_t counter = 0;
     408             : 
     409           0 :   for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++)
     410           0 :     if (GetDigitIndex(vol, slot)>=0) counter++;
     411             : 
     412           0 :   return counter;
     413             : 
     414             : }

Generated by: LCOV version 1.11