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 ////////////////////////////////////////////////////////////////////////
37 #include "AliTOFHitMap.h"
38 #include "AliTOFGeometry.h"
41 #include <TClonesArray.h>
43 ClassImp(AliTOFHitMap)
45 AliTOFHitMap::AliTOFHitMap():
61 ////////////////////////////////////////////////////////////////////////
62 AliTOFHitMap::AliTOFHitMap(TClonesArray *dig, AliTOFGeometry *tofGeom):
77 // of course, these constants must not be hardwired
80 fNSector = AliTOFGeometry::NSectors();
81 fNplate = AliTOFGeometry::NPlates();
82 fNstrip = fTOFGeometry->NStripC();//fTOFGeometry->NMaxNstrip();
83 fNpx = AliTOFGeometry::NpadX();
84 fNpz = AliTOFGeometry::NpadZ();
85 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
86 fHitMap = new Int_t[fMaxIndex];
90 ////////////////////////////////////////////////////////////////////////
91 AliTOFHitMap::AliTOFHitMap(const AliTOFHitMap & /*hitMap*/)
104 // Dummy copy constructor
110 ////////////////////////////////////////////////////////////////////////
111 AliTOFHitMap::~AliTOFHitMap()
122 ////////////////////////////////////////////////////////////////////////
123 void AliTOFHitMap::Clear(const char *)
128 memset(fHitMap,0,sizeof(int)*fMaxIndex);
131 ////////////////////////////////////////////////////////////////////////
132 Int_t AliTOFHitMap::CheckedIndex(Int_t *vol) const
135 // Return checked indices for vol
138 vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector
139 vol[1]*fNstrip*fNpx*fNpz+ // plate
140 vol[2]*fNpx*fNpz+ // strip
144 if (index >= fMaxIndex) {
145 AliError("CheckedIndex - input outside bounds");
152 ////////////////////////////////////////////////////////////////////////
153 void AliTOFHitMap::SetHit(Int_t *vol, Int_t idigit)
156 // Assign digit to pad vol
159 // 0 means empty pad, we need to shift indeces by 1
160 fHitMap[CheckedIndex(vol)]=idigit+1;
163 ////////////////////////////////////////////////////////////////////////
164 void AliTOFHitMap::SetHit(Int_t *vol)
167 // Assign last digit to pad vol
170 // 0 means empty pad, we need to shift indeces by 1
171 fHitMap[CheckedIndex(vol)]=fSDigits->GetLast()+1;
174 ////////////////////////////////////////////////////////////////////////
175 Int_t AliTOFHitMap::GetHitIndex(Int_t *vol) const
178 // Get contents of pad vol
181 // 0 means empty pad, we need to shift indeces by 1
182 return fHitMap[CheckedIndex(vol)]-1;
185 ////////////////////////////////////////////////////////////////////////
186 TObject* AliTOFHitMap::GetHit(Int_t *vol) const
189 // Get pointer to object at vol
190 // return 0 if vol out of bounds
191 Int_t index=GetHitIndex(vol);
192 return (index <0) ? 0 : fSDigits->UncheckedAt(index);
195 ////////////////////////////////////////////////////////////////////////
196 FlagType AliTOFHitMap::TestHit(Int_t *vol) const
199 // Check if hit cell is empty, used or unused
201 Int_t inf=fHitMap[CheckedIndex(vol)];
204 } else if (inf == 0) {
211 ////////////////////////////////////////////////////////////////////////
212 AliTOFHitMap & AliTOFHitMap::operator = (const AliTOFHitMap & /*rhs*/)
214 // Dummy assignment operator