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():
52 fNSector(AliTOFGeometry::NSectors()),
53 fNplate(AliTOFGeometry::NPlates()),
54 fNstrip(AliTOFGeometry::NStripC()),
55 fNpx(AliTOFGeometry::NpadX()),
56 fNpz(AliTOFGeometry::NpadZ()),
64 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
65 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):
74 fNSector(digitMap.fNSector),
75 fNplate(digitMap.fNplate),
76 fNstrip(digitMap.fNstrip),
85 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
86 fDigitMap = new Int_t*[fMaxIndex];
87 for (Int_t i=0; i<fMaxIndex; i++) {
88 fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
89 for (Int_t j=0; j<kMaxDigitsPerPad; j++)
90 fDigitMap[i][j]=digitMap.fDigitMap[i][j];
94 ////////////////////////////////////////////////////////////////////////
95 AliTOFDigitMap & AliTOFDigitMap::operator=(const AliTOFDigitMap & digitMap)
98 // Assignment operator
101 if (this != &digitMap) {
102 TObject::operator=(digitMap);
103 fNSector=digitMap.fNSector;
104 fNplate=digitMap.fNplate;
105 fNstrip=digitMap.fNstrip;
108 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
109 for (Int_t i=0; i<fMaxIndex; ++i) delete [] fDigitMap[i];
111 fDigitMap = new Int_t*[fMaxIndex];
112 for (Int_t i=0; i<fMaxIndex; i++) {
113 fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
114 for (Int_t j=0; j<kMaxDigitsPerPad; j++)
115 fDigitMap[i][j]=digitMap.fDigitMap[i][j];
122 ////////////////////////////////////////////////////////////////////////
123 AliTOFDigitMap::~AliTOFDigitMap()
129 for (Int_t i=0; i<fMaxIndex; i++) delete[] fDigitMap[i];
136 ////////////////////////////////////////////////////////////////////////
137 void AliTOFDigitMap::Clear(const Option_t*)
143 for(Int_t ii=0; ii<fMaxIndex; ii++) {
144 for (Int_t jj=0; jj<kMaxDigitsPerPad; jj++) {
145 fDigitMap[ii][jj] = 0;
151 ////////////////////////////////////////////////////////////////////////
152 Int_t AliTOFDigitMap::CheckedIndex(Int_t * const vol) const
155 // Return checked index for vol
159 vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector
160 vol[1]*fNstrip*fNpx*fNpz+ // plate
161 vol[2]*fNpx*fNpz+ // strip
165 if (index >= fMaxIndex || index < 0) {
166 AliError("CheckedIndex - input outside bounds");
173 ////////////////////////////////////////////////////////////////////////
174 void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit)
177 // Assign digit to pad vol
179 // 0 means empty pad, we need to shift indeces by 1
181 if (fDigitMap[CheckedIndex(vol)][kMaxDigitsPerPad-1]!=0) {
182 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 AliDebug(1,Form("Then, the digit number %i will be not inserted in the digit map, i.e. it will be lost.", idigit));
184 AliDebug(1,Form("Please, check the possibility to increase the digit map size (succently set to %i)", kMaxDigitsPerPad));
188 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
190 if (fDigitMap[CheckedIndex(vol)][slot]==0) {
191 fDigitMap[CheckedIndex(vol)][slot]=idigit+1;
200 ////////////////////////////////////////////////////////////////////////
201 void AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t *digitLabels) const
204 // Get all contents (digitLabels) of pad volume (vol)
207 // 0 means empty pad, we need to shift indeces by 1
210 for (Int_t j=0; j<kMaxDigitsPerPad; j++) {
211 dummy = GetDigitIndex(vol,j);
212 if (dummy>=0) digitLabels[j] = dummy;
217 ////////////////////////////////////////////////////////////////////////
218 Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const
221 // Get one of the contents (label) of pad volume (vol)
224 // 0 means empty pad, we need to shift indeces by 1
226 if (!(label<kMaxDigitsPerPad)) {
227 AliWarning(Form("label (=%i) >= kMaxDigitsPerPad (=%i)", label, kMaxDigitsPerPad));
231 Int_t ci = CheckedIndex(vol);
232 if (ci==-1) return -1;
234 Int_t dummy = fDigitMap[ci][label];
236 if (dummy>0) return dummy-1;
241 ////////////////////////////////////////////////////////////////////////
242 FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const
245 // Check if hit cell is empty, used or unused
247 Int_t inf=fDigitMap[CheckedIndex(vol)][0]; // to be modified
250 } else if (inf == 0) {
257 ////////////////////////////////////////////////////////////////////////
258 Int_t AliTOFDigitMap::GetFilledCellNumber() const
261 // Returns the number of filled cells of the TOF digit map
266 for (Int_t index = 0; index < fMaxIndex; ++index)
268 for (Int_t label = 0; label < kMaxDigitsPerPad; ++label)
270 if (fDigitMap[index][label] > 0)
281 ////////////////////////////////////////////////////////////////////////
282 Bool_t AliTOFDigitMap::StripDigitCheck(Int_t iSector, Int_t iPlate, Int_t iStrip) const
286 // kFALSE if the strip doesn't contain digits
287 // kTRUE if the strip contains at least one digit
290 Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1};
291 Bool_t counter = kFALSE;
293 for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
294 for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++)
298 for (Int_t label=0; label<kMaxDigitsPerPad; label++) {
299 if (GetDigitIndex(volume, label)>=0) {
310 ////////////////////////////////////////////////////////////////////////
311 Int_t AliTOFDigitMap::DigitInStrip(Int_t iSector, Int_t iPlate, Int_t iStrip) const
314 // Returns number of digits in the strip iStrip,
315 // in the plate iPlate of the sector iSector
318 Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1};
321 for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
322 for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++)
323 for (Int_t label=0; label<kMaxDigitsPerPad; label++) {
326 if (GetDigitIndex(volume, label)>=0)
334 ////////////////////////////////////////////////////////////////////////
335 Int_t AliTOFDigitMap::FilledCellsInStrip(Int_t iSector, Int_t iPlate, Int_t iStrip) const
338 // Returns number of digits in the strip iStrip,
339 // in the plate iPlate of the sector iSector
342 Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1};
345 for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
346 for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++) {
349 if (GetDigitIndex(volume, 0)>=0)
357 ////////////////////////////////////////////////////////////////////////
358 void AliTOFDigitMap::ResetDigitNumber(Int_t *vol, Int_t dig)
361 // Reset digit into pad vol
364 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
365 if (fDigitMap[CheckedIndex(vol)][slot]-1==dig) {
366 fDigitMap[CheckedIndex(vol)][slot] = 0;
372 ////////////////////////////////////////////////////////////////////////
373 void AliTOFDigitMap::ResetDigit(Int_t *vol, Int_t dig)
376 // Reset digit into pad vol
378 // 0 means empty pad, we need to shift indeces by 1
380 fDigitMap[CheckedIndex(vol)][dig] = 0;
384 ////////////////////////////////////////////////////////////////////////
385 void AliTOFDigitMap::ResetDigit(Int_t *vol)
388 // Reset digit into pad vol
390 // 0 means empty pad, we need to shift indices by 1
392 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++)
393 fDigitMap[CheckedIndex(vol)][slot] = 0;
397 ////////////////////////////////////////////////////////////////////////
398 Int_t AliTOFDigitMap::GetNumberOfDigits(Int_t *vol)
401 // Returns the number of digit
402 // into pad volume vol
409 for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++)
410 if (GetDigitIndex(vol, slot)>=0) counter++;