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>
40 #include "AliTOFHitMap.h"
41 #include "AliTOFSDigit.h"
42 #include "AliTOFGeometry.h"
45 #include <TClonesArray.h>
47 ClassImp(AliTOFHitMap)
49 AliTOFHitMap::AliTOFHitMap()
58 ////////////////////////////////////////////////////////////////////////
59 AliTOFHitMap::AliTOFHitMap(TClonesArray *dig, AliTOFGeometry *tofGeom)
65 // of course, these constants must not be hardwired
68 fTOFGeometry = tofGeom;
70 fNSector = AliTOFGeometry::NSectors();
71 fNplate = AliTOFGeometry::NPlates();
72 fNstrip = fTOFGeometry->NMaxNstrip();
73 fNpx = AliTOFGeometry::NpadX();
74 fNpz = AliTOFGeometry::NpadZ();
75 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
76 fHitMap = new Int_t[fMaxIndex];
81 ////////////////////////////////////////////////////////////////////////
82 AliTOFHitMap::AliTOFHitMap(const AliTOFHitMap & /*hitMap*/)
86 // Dummy copy constructor
92 ////////////////////////////////////////////////////////////////////////
93 AliTOFHitMap::~AliTOFHitMap()
104 ////////////////////////////////////////////////////////////////////////
105 void AliTOFHitMap::Clear(const char *)
110 memset(fHitMap,0,sizeof(int)*fMaxIndex);
113 ////////////////////////////////////////////////////////////////////////
114 Int_t AliTOFHitMap::CheckedIndex(Int_t *vol) const
117 // Return checked indices for vol
120 vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector
121 vol[1]*fNstrip*fNpx*fNpz+ // plate
122 vol[2]*fNpx*fNpz+ // strip
126 if (index >= fMaxIndex) {
127 AliError("CheckedIndex - input outside bounds");
134 ////////////////////////////////////////////////////////////////////////
135 void AliTOFHitMap::SetHit(Int_t *vol, Int_t idigit)
138 // Assign digit to pad vol
141 // 0 means empty pad, we need to shift indeces by 1
142 fHitMap[CheckedIndex(vol)]=idigit+1;
145 ////////////////////////////////////////////////////////////////////////
146 void AliTOFHitMap::SetHit(Int_t *vol)
149 // Assign last digit to pad vol
152 // 0 means empty pad, we need to shift indeces by 1
153 fHitMap[CheckedIndex(vol)]=fSDigits->GetLast()+1;
156 ////////////////////////////////////////////////////////////////////////
157 Int_t AliTOFHitMap::GetHitIndex(Int_t *vol) const
160 // Get contents of pad vol
163 // 0 means empty pad, we need to shift indeces by 1
164 return fHitMap[CheckedIndex(vol)]-1;
167 ////////////////////////////////////////////////////////////////////////
168 TObject* AliTOFHitMap::GetHit(Int_t *vol) const
171 // Get pointer to object at vol
172 // return 0 if vol out of bounds
173 Int_t index=GetHitIndex(vol);
174 return (index <0) ? 0 : fSDigits->UncheckedAt(index);
177 ////////////////////////////////////////////////////////////////////////
178 FlagType AliTOFHitMap::TestHit(Int_t *vol) const
181 // Check if hit cell is empty, used or unused
183 Int_t inf=fHitMap[CheckedIndex(vol)];
186 } else if (inf == 0) {
193 ////////////////////////////////////////////////////////////////////////
194 AliTOFHitMap & AliTOFHitMap::operator = (const AliTOFHitMap & /*rhs*/)
196 // Dummy assignment operator