1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 ////////////////////////////////////////////////////////////////////////
19 // AliTOFDigitMap class
21 // digitmap enables fast check if the pad was already digit.
23 // The index of a AliTOFdigit is saved in the each digitmap "cell"
24 // (there is an offset +1, because the index can be zero and zero
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 the
28 // size of the digitmap is a little bit greater than necessary, but it
29 // simplifies the access algorithm.
32 // Author: F. Pierella based on AliTOFHitMap
34 // Modified by A. De Caro
36 ///////////////////////////////////////////////////////////////////////
40 #include "AliTOFDigitMap.h"
41 #include "AliTOFGeometry.h"
43 ClassImp(AliTOFDigitMap)
45 AliTOFDigitMap::AliTOFDigitMap():
53 fTOFGeometry(new AliTOFGeometry())
59 fNSector = AliTOFGeometry::NSectors();
60 fNplate = AliTOFGeometry::NPlates();
61 fNstrip = fTOFGeometry->NStripC();//fTOFGeometry->NMaxNstrip();
62 fNpx = AliTOFGeometry::NpadX();
63 fNpz = AliTOFGeometry::NpadZ();
64 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
66 fDigitMap = new Int_t*[fMaxIndex];
67 for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
71 ////////////////////////////////////////////////////////////////////////
72 AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & /*digitMap*/):
81 fTOFGeometry(new AliTOFGeometry())
84 // Dummy copy constructor
91 ////////////////////////////////////////////////////////////////////////
92 AliTOFDigitMap::~AliTOFDigitMap()
98 for (Int_t i=0; i<fMaxIndex; i++) delete[] fDigitMap[i];
105 ////////////////////////////////////////////////////////////////////////
106 void AliTOFDigitMap::Clear(const Option_t*)
112 for(Int_t ii=0; ii<fMaxIndex; ii++) {
113 for (Int_t jj=0; jj<kMaxDigitsPerPad; jj++) {
114 fDigitMap[ii][jj] = 0;
120 ////////////////////////////////////////////////////////////////////////
121 Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const
124 // Return checked index for vol
128 vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector
129 vol[1]*fNstrip*fNpx*fNpz+ // plate
130 vol[2]*fNpx*fNpz+ // strip
134 if (index >= fMaxIndex || index < 0) {
135 AliError("CheckedIndex - input outside bounds");
142 ////////////////////////////////////////////////////////////////////////
143 void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit)
146 // Assign digit to pad vol
148 // 0 means empty pad, we need to shift indeces by 1
150 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
152 if (fDigitMap[CheckedIndex(vol)][slot]==0) {
153 fDigitMap[CheckedIndex(vol)][slot]=idigit+1;
161 ////////////////////////////////////////////////////////////////////////
162 void AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t *digitLabels) const
165 // Get all contents (digitLabels) of pad volume (vol)
168 // 0 means empty pad, we need to shift indeces by 1
171 for (Int_t j=0; j<kMaxDigitsPerPad; j++) {
172 dummy = GetDigitIndex(vol,j);
173 if (dummy>=0) digitLabels[j] = dummy;
178 ////////////////////////////////////////////////////////////////////////
179 Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const
182 // Get one of the contents (label) of pad volume (vol)
185 // 0 means empty pad, we need to shift indeces by 1
187 if (!(label<kMaxDigitsPerPad)) {
188 AliWarning(Form("label (=%i) >= kMaxDigitsPerPad (=%i)", label, kMaxDigitsPerPad));
192 if (CheckedIndex(vol)==-1) return -1;
194 Int_t dummy = fDigitMap[CheckedIndex(vol)][label];
196 if (dummy>0) return dummy-1;
201 ////////////////////////////////////////////////////////////////////////
202 FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const
205 // Check if hit cell is empty, used or unused
207 Int_t inf=fDigitMap[CheckedIndex(vol)][0]; // to be modified
210 } else if (inf == 0) {
217 ////////////////////////////////////////////////////////////////////////
218 AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/)
220 // Dummy assignment operator