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 ////////////////////////////////////////////////////////////////////////
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.
32 // Author: Jiri Chudoba (CERN), based on AliMUONHitMap
34 ////////////////////////////////////////////////////////////////////////
36 #include <Riostream.h>
39 #include "AliTOFHitMap.h"
40 #include "AliTOFSDigit.h"
41 #include "AliTOFConstants.h"
44 #include <TClonesArray.h>
46 ClassImp(AliTOFHitMap)
48 AliTOFHitMap::AliTOFHitMap()
57 ////////////////////////////////////////////////////////////////////////
58 AliTOFHitMap::AliTOFHitMap(TClonesArray *dig)
64 // of course, these constants must not be hardwired
67 fNSector = AliTOFConstants::fgkNSectors;
68 fNplate = AliTOFConstants::fgkNPlates;
69 fNstrip = AliTOFConstants::fgkNStripC;
70 fNpx = AliTOFConstants::fgkNpadX;
71 fNpy = AliTOFConstants::fgkNpadZ;
72 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpy;
73 fHitMap = new Int_t[fMaxIndex];
78 ////////////////////////////////////////////////////////////////////////
79 AliTOFHitMap::AliTOFHitMap(const AliTOFHitMap & hitMap)
82 // Dummy copy constructor
88 ////////////////////////////////////////////////////////////////////////
89 AliTOFHitMap::~AliTOFHitMap()
94 if (fHitMap) delete[] fHitMap;
97 ////////////////////////////////////////////////////////////////////////
98 void AliTOFHitMap::Clear(const char *)
103 memset(fHitMap,0,sizeof(int)*fMaxIndex);
106 ////////////////////////////////////////////////////////////////////////
107 Int_t AliTOFHitMap::CheckedIndex(Int_t *vol) const
110 // Return checked indices for vol
113 (vol[0]-1)*fNplate*fNstrip*fNpx*fNpy+ // sector
114 (vol[1]-1)*fNstrip*fNpx*fNpy+ // plate
115 (vol[2]-1)*fNpx*fNpy+ // strip
116 (vol[3]-1)*fNpy+ // padx
117 (vol[4]-1); // pady (=padz)
119 if (index >= fMaxIndex) {
120 Error("AliTOFHitMap","CheckedIndex - input outside bounds");
127 ////////////////////////////////////////////////////////////////////////
128 void AliTOFHitMap::SetHit(Int_t *vol, Int_t idigit)
131 // Assign digit to pad vol
134 // 0 means empty pad, we need to shift indeces by 1
135 fHitMap[CheckedIndex(vol)]=idigit+1;
138 ////////////////////////////////////////////////////////////////////////
139 void AliTOFHitMap::SetHit(Int_t *vol)
142 // Assign last digit to pad vol
145 // 0 means empty pad, we need to shift indeces by 1
146 fHitMap[CheckedIndex(vol)]=fSDigits->GetLast()+1;
149 ////////////////////////////////////////////////////////////////////////
150 Int_t AliTOFHitMap::GetHitIndex(Int_t *vol) const
153 // Get contents of pad vol
156 // 0 means empty pad, we need to shift indeces by 1
157 return fHitMap[CheckedIndex(vol)]-1;
160 ////////////////////////////////////////////////////////////////////////
161 TObject* AliTOFHitMap::GetHit(Int_t *vol) const
164 // Get pointer to object at vol
165 // return 0 if vol out of bounds
166 Int_t index=GetHitIndex(vol);
167 return (index <0) ? 0 : fSDigits->UncheckedAt(index);
170 ////////////////////////////////////////////////////////////////////////
171 FlagType AliTOFHitMap::TestHit(Int_t *vol) const
174 // Check if hit cell is empty, used or unused
176 Int_t inf=fHitMap[CheckedIndex(vol)];
179 } else if (inf == 0) {
186 ////////////////////////////////////////////////////////////////////////
187 AliTOFHitMap & AliTOFHitMap::operator = (const AliTOFHitMap & rhs)
189 // Dummy assignment operator