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 **************************************************************************/
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
23 ////////////////////////////////////////////////////////////////////////
25 // AliTOFDigitMap class
27 // digitmap enables fast check if the pad was already digit.
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
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.
38 // Author: F. Pierella based on AliTOFHitMap
40 // Modified by A. De Caro
42 ///////////////////////////////////////////////////////////////////////
46 #include "AliTOFDigitMap.h"
47 #include "AliTOFGeometry.h"
49 ClassImp(AliTOFDigitMap)
51 AliTOFDigitMap::AliTOFDigitMap():
64 fNSector = AliTOFGeometry::NSectors();
65 fNplate = AliTOFGeometry::NPlates();
66 fNstrip = AliTOFGeometry::NStripC();
67 fNpx = AliTOFGeometry::NpadX();
68 fNpz = AliTOFGeometry::NpadZ();
69 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
71 fDigitMap = new Int_t*[fMaxIndex];
72 for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
76 ////////////////////////////////////////////////////////////////////////
77 AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & /*digitMap*/):
88 // Dummy copy constructor
95 ////////////////////////////////////////////////////////////////////////
96 AliTOFDigitMap::~AliTOFDigitMap()
102 for (Int_t i=0; i<fMaxIndex; i++) delete[] fDigitMap[i];
108 ////////////////////////////////////////////////////////////////////////
109 void AliTOFDigitMap::Clear(const Option_t*)
115 for(Int_t ii=0; ii<fMaxIndex; ii++) {
116 for (Int_t jj=0; jj<kMaxDigitsPerPad; jj++) {
117 fDigitMap[ii][jj] = 0;
123 ////////////////////////////////////////////////////////////////////////
124 Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const
127 // Return checked index for vol
131 vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector
132 vol[1]*fNstrip*fNpx*fNpz+ // plate
133 vol[2]*fNpx*fNpz+ // strip
137 if (index >= fMaxIndex || index < 0) {
138 AliError("CheckedIndex - input outside bounds");
145 ////////////////////////////////////////////////////////////////////////
146 void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit)
149 // Assign digit to pad vol
151 // 0 means empty pad, we need to shift indeces by 1
153 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
155 if (fDigitMap[CheckedIndex(vol)][slot]==0) {
156 fDigitMap[CheckedIndex(vol)][slot]=idigit+1;
164 ////////////////////////////////////////////////////////////////////////
165 void AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t *digitLabels) const
168 // Get all contents (digitLabels) of pad volume (vol)
171 // 0 means empty pad, we need to shift indeces by 1
174 for (Int_t j=0; j<kMaxDigitsPerPad; j++) {
175 dummy = GetDigitIndex(vol,j);
176 if (dummy>=0) digitLabels[j] = dummy;
181 ////////////////////////////////////////////////////////////////////////
182 Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const
185 // Get one of the contents (label) of pad volume (vol)
188 // 0 means empty pad, we need to shift indeces by 1
190 if (!(label<kMaxDigitsPerPad)) {
191 AliWarning(Form("label (=%i) >= kMaxDigitsPerPad (=%i)", label, kMaxDigitsPerPad));
195 if (CheckedIndex(vol)==-1) return -1;
197 Int_t dummy = fDigitMap[CheckedIndex(vol)][label];
199 if (dummy>0) return dummy-1;
204 ////////////////////////////////////////////////////////////////////////
205 FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const
208 // Check if hit cell is empty, used or unused
210 Int_t inf=fDigitMap[CheckedIndex(vol)][0]; // to be modified
213 } else if (inf == 0) {
220 ////////////////////////////////////////////////////////////////////////
221 AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/)
223 // Dummy assignment operator
226 ////////////////////////////////////////////////////////////////////////
227 Int_t AliTOFDigitMap::GetFilledCellNumber() const
230 // Returns the number of filled cells of the TOF digit map
233 Int_t volume[5] = {-1, -1, -1, -1, -1};
236 for (Int_t iSector=0; iSector<fNSector; iSector++)
237 for (Int_t iPlate=0; iPlate<fNplate; iPlate++)
238 for (Int_t iStrip=0; iStrip<fNstrip; iStrip++)
239 for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
240 for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++)
249 //if (CheckedIndex(volume)!=-1) counter++;
250 if (GetDigitIndex(volume, 0)>0) counter++;
257 ////////////////////////////////////////////////////////////////////////
258 void AliTOFDigitMap::ResetDigit(Int_t *vol)
261 // Reset digit into pad vol
263 // 0 means empty pad, we need to shift indeces by 1
265 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++)
266 fDigitMap[CheckedIndex(vol)][slot] = 0;