LCOV - code coverage report
Current view: top level - TOF/TOFbase - AliTOFRawMap.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 53 1.9 %
Date: 2016-06-14 17:26:59 Functions: 1 15 6.7 %

          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             : // AliTOFRawMap class                                                  //
      21             : //                                                                     //
      22             : // It enables fast check if the TDC channel was already engaged        //
      23             : // for a measurement.                                                  //
      24             : // The index of a AliTOFrawData is saved in the each rawdatamap "cell" //
      25             : // (there is an offset +1, because the index can be zero and           //
      26             : // zero means empty cell.                                              //
      27             : //                                                                     //
      28             : /////////////////////////////////////////////////////////////////////////
      29             : 
      30             : #include "TClonesArray.h"
      31             : 
      32             : #include "AliLog.h"
      33             : 
      34             : #include "AliTOFGeometry.h"
      35             : #include "AliTOFRawMap.h"
      36             : 
      37          26 : ClassImp(AliTOFRawMap)
      38             : 
      39             : AliTOFRawMap::AliTOFRawMap():
      40           0 :   TObject(),
      41           0 :   fNtrm(-1),
      42           0 :   fNtrmChain(-1),
      43           0 :   fNtdc(-1),
      44           0 :   fNtdcChannel(-1),
      45           0 :   fRawData(0x0),
      46           0 :   fMaxIndex(-1),
      47           0 :   fRawMap(0x0)
      48           0 : {
      49             : //
      50             : // Default ctor
      51             : //
      52           0 : }
      53             : 
      54             : ////////////////////////////////////////////////////////////////////////
      55             : AliTOFRawMap::AliTOFRawMap(TClonesArray *dig)://, AliTOFGeometry *tofGeom:
      56           0 :   TObject(),
      57           0 :   fNtrm(AliTOFGeometry::NTRM()+2),
      58           0 :   fNtrmChain(AliTOFGeometry::NChain()),
      59           0 :   fNtdc(AliTOFGeometry::NTdc()),
      60           0 :   fNtdcChannel(AliTOFGeometry::NCh()),
      61           0 :   fRawData(dig),
      62           0 :   fMaxIndex(-1),
      63           0 :   fRawMap(0x0)
      64           0 : {
      65             : //
      66             : // ctor
      67             : //
      68             : 
      69             : // of course, these constants must not be hardwired
      70             : // change later
      71             : 
      72           0 :   fMaxIndex = fNtrm*fNtrmChain*fNtdc*fNtdcChannel;
      73           0 :   fRawMap = new Int_t[fMaxIndex];
      74           0 :   Clear();
      75           0 : }
      76             : 
      77             : ////////////////////////////////////////////////////////////////////////
      78             : AliTOFRawMap::~AliTOFRawMap()
      79           0 : {
      80             : //
      81             : // Destructor
      82             : //
      83           0 :   if (fRawMap)
      84           0 :     delete[] fRawMap;
      85             : 
      86           0 : }
      87             : 
      88             : ////////////////////////////////////////////////////////////////////////
      89             : void AliTOFRawMap::Clear(const char *)
      90             : {
      91             : //
      92             : // Clear hitmap
      93             : //
      94           0 :     memset(fRawMap,0,sizeof(int)*fMaxIndex);
      95           0 : }
      96             : 
      97             : ////////////////////////////////////////////////////////////////////////
      98             : Int_t AliTOFRawMap::CheckedIndex(const Int_t * const slot) const
      99             : {
     100             : //
     101             : // Return checked indices for vol
     102             : //
     103             :   Int_t index =
     104           0 :     slot[0]*fNtrmChain*fNtdc*fNtdcChannel + // TRM
     105           0 :     slot[1]*fNtdc*fNtdcChannel +            // TRM chain
     106           0 :     slot[2]*fNtdcChannel +                  // TDC
     107           0 :     slot[3];                                // TDC channel
     108             : 
     109           0 :     if (index >= fMaxIndex) {
     110           0 :       AliError("CheckedIndex - input outside bounds");
     111           0 :         return -1;
     112             :     } else {
     113           0 :         return index;
     114             :     }
     115           0 : }
     116             : 
     117             : ////////////////////////////////////////////////////////////////////////
     118             : void  AliTOFRawMap::SetHit(Int_t *slot, Int_t idigit)
     119             : {
     120             : //
     121             : // Assign digit to pad vol
     122             : //
     123             : 
     124             : // 0 means empty pad, we need to shift indeces by 1
     125           0 :     fRawMap[CheckedIndex(slot)]=idigit+1;
     126           0 : }
     127             : 
     128             : ////////////////////////////////////////////////////////////////////////
     129             : void  AliTOFRawMap::SetHit(Int_t *slot)
     130             : {
     131             : //
     132             : // Assign last digit to channel slot
     133             : //
     134             : 
     135             : // 0 means empty pad, we need to shift indeces by 1
     136           0 :     fRawMap[CheckedIndex(slot)]=fRawData->GetLast()+1;
     137           0 : }
     138             : 
     139             : ////////////////////////////////////////////////////////////////////////
     140             : Int_t AliTOFRawMap::GetHitIndex(Int_t *slot) const
     141             : {
     142             : //
     143             : // Get contents of channel slot
     144             : //
     145             : 
     146             : // 0 means empty pad, we need to shift indeces by 1
     147           0 :     return fRawMap[CheckedIndex(slot)]-1;
     148             : }
     149             : 
     150             : ////////////////////////////////////////////////////////////////////////
     151             : TObject* AliTOFRawMap::GetHit(Int_t *slot) const
     152             : {
     153             : //
     154             : // Get pointer to object at alot
     155             : // return 0 if vol out of bounds
     156           0 :     Int_t index = GetHitIndex(slot);
     157           0 :     return (index <0) ? 0 : fRawData->UncheckedAt(index);
     158             : }
     159             : 
     160             : ////////////////////////////////////////////////////////////////////////
     161             : FlagType AliTOFRawMap::TestHit(Int_t *slot) const
     162             : {
     163             : //
     164             : // Check if hit cell is empty, used or unused
     165             : //
     166           0 :     Int_t inf = fRawMap[CheckedIndex(slot)];
     167           0 :     if (inf > 0) {
     168           0 :         return kUsed;
     169           0 :     } else if (inf == 0) {
     170           0 :         return kEmpty;
     171             :     } else {
     172           0 :         return kUnused;
     173             :     }
     174           0 : }
     175             : 

Generated by: LCOV version 1.11