LCOV - code coverage report
Current view: top level - TOF/TOFsim - AliTOFHitMap.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 44 60 73.3 %
Date: 2016-06-14 17:26:59 Functions: 12 15 80.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             : 
      16             : /* $Id$ */
      17             : 
      18             : ////////////////////////////////////////////////////////////////////////
      19             : //
      20             : // AliTOFHitMap class
      21             : //
      22             : // hitmap enables fast check if the pad was already hit
      23             : // The index of a AliTOFSDigit is saved in the each hitmap "cell"
      24             : // (there is an offset +1, because the index can be zero and 
      25             : // zero means empty cell. 
      26             : // In TOF, number of strips varies according plate type, the highest
      27             : // number is in plate C. For all plates is used this number, so
      28             : // the size of the hitmap is a little bit greater than necessary, but
      29             : // it simplifies the access algorithm. 
      30             : // 
      31             : //
      32             : // Author: Jiri Chudoba (CERN), based on AliMUONHitMap
      33             : //
      34             : ////////////////////////////////////////////////////////////////////////
      35             : 
      36             : #include "AliLog.h"
      37             : #include "AliTOFHitMap.h"
      38             : #include "AliTOFGeometry.h"
      39             : 
      40             : 
      41             : #include <TClonesArray.h>
      42             : 
      43          26 : ClassImp(AliTOFHitMap)
      44             : 
      45           0 : AliTOFHitMap::AliTOFHitMap():
      46           0 :   fNSector(-1),
      47           0 :   fNplate(-1),
      48           0 :   fNstrip(-1),
      49           0 :   fNpx(-1),
      50           0 :   fNpz(-1),
      51           0 :   fSDigits(0x0),
      52           0 :   fMaxIndex(-1),
      53           0 :   fHitMap(0x0)
      54           0 : {
      55             : //
      56             : // Default ctor
      57             : //
      58           0 : }
      59             : 
      60             : ////////////////////////////////////////////////////////////////////////
      61           8 : AliTOFHitMap::AliTOFHitMap(TClonesArray *dig):
      62           8 :   fNSector(-1),
      63           8 :   fNplate(-1),
      64           8 :   fNstrip(-1),
      65           8 :   fNpx(-1),
      66           8 :   fNpz(-1),
      67           8 :   fSDigits(dig),
      68           8 :   fMaxIndex(-1),
      69           8 :   fHitMap(0x0)
      70          40 : {
      71             : //
      72             : // ctor
      73             : //
      74             : 
      75             : // of course, these constants must not be hardwired
      76             : // change later
      77             : 
      78           8 :   fNSector = AliTOFGeometry::NSectors();
      79           8 :   fNplate = AliTOFGeometry::NPlates();
      80           8 :   fNstrip = AliTOFGeometry::NStripC();//fTOFGeometry->NMaxNstrip();
      81           8 :   fNpx  = AliTOFGeometry::NpadX();
      82           8 :   fNpz  = AliTOFGeometry::NpadZ();
      83           8 :   fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
      84          16 :   fHitMap = new Int_t[fMaxIndex];
      85           8 :   Clear();
      86          16 : }
      87             : 
      88             : ////////////////////////////////////////////////////////////////////////
      89             : AliTOFHitMap::~AliTOFHitMap()
      90          48 : {
      91             : //
      92             : // Destructor
      93             : //
      94          16 :   delete[] fHitMap;
      95             : 
      96          24 : }
      97             : 
      98             : ////////////////////////////////////////////////////////////////////////
      99             : void AliTOFHitMap::Clear(const char *)
     100             : {
     101             : //
     102             : // Clear hitmap
     103             : //
     104          16 :     memset(fHitMap,0,sizeof(int)*fMaxIndex);
     105           8 : }
     106             : 
     107             : ////////////////////////////////////////////////////////////////////////
     108             : Int_t AliTOFHitMap::CheckedIndex(Int_t * const vol) const
     109             : {
     110             : //
     111             : // Return checked indices for vol
     112             : //
     113             :   Int_t index=
     114        1260 :     vol[0]*fNplate*fNstrip*fNpx*fNpz+             // sector
     115         840 :     vol[1]*fNstrip*fNpx*fNpz+                     // plate
     116         840 :     vol[2]*fNpx*fNpz+                             // strip
     117         840 :     vol[3]*fNpz+                                  // padx
     118         420 :     vol[4];                                       // padz
     119             : 
     120         420 :     if (index >= fMaxIndex) {
     121           0 :       AliError("CheckedIndex - input outside bounds");
     122           0 :         return -1;
     123             :     } else {
     124         420 :         return index;
     125             :     }
     126         420 : }
     127             : 
     128             : ////////////////////////////////////////////////////////////////////////
     129             : void  AliTOFHitMap::SetHit(Int_t *vol, Int_t idigit)
     130             : {
     131             : //
     132             : // Assign digit to pad vol
     133             : //
     134             : 
     135             : // 0 means empty pad, we need to shift indeces by 1
     136           0 :     fHitMap[CheckedIndex(vol)]=idigit+1;
     137           0 : }
     138             : 
     139             : ////////////////////////////////////////////////////////////////////////
     140             : void  AliTOFHitMap::SetHit(Int_t *vol)
     141             : {
     142             : //
     143             : // Assign last digit to pad vol 
     144             : //
     145             : 
     146             : // 0 means empty pad, we need to shift indeces by 1
     147         400 :     fHitMap[CheckedIndex(vol)]=fSDigits->GetLast()+1;
     148         200 : }
     149             : 
     150             : ////////////////////////////////////////////////////////////////////////
     151             : Int_t AliTOFHitMap::GetHitIndex(Int_t *vol) const
     152             : {
     153             : //
     154             : // Get contents of pad vol
     155             : //
     156             : 
     157             : // 0 means empty pad, we need to shift indeces by 1
     158          20 :     return fHitMap[CheckedIndex(vol)]-1;
     159             : }
     160             : 
     161             : ////////////////////////////////////////////////////////////////////////
     162             : TObject* AliTOFHitMap::GetHit(Int_t *vol) const
     163             : {
     164             : //
     165             : // Get pointer to object at vol
     166             : // return 0 if vol out of bounds
     167          20 :     Int_t index=GetHitIndex(vol);
     168          30 :     return (index <0) ? 0 : fSDigits->UncheckedAt(index);
     169             : }
     170             : 
     171             : ////////////////////////////////////////////////////////////////////////
     172             : FlagType AliTOFHitMap::TestHit(Int_t *vol) const
     173             : {
     174             : //
     175             : // Check if hit cell is empty, used or unused
     176             : //
     177         420 :     Int_t inf=fHitMap[CheckedIndex(vol)];
     178         210 :     if (inf > 0) {
     179          10 :         return kUsed;
     180         200 :     } else if (inf == 0) {
     181         200 :         return kEmpty;
     182             :     } else {
     183           0 :         return kUnused;
     184             :     }
     185         210 : }

Generated by: LCOV version 1.11