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.1 2001/11/22 11:22:51 hristov
19 Updated version of TOF digitization, N^2 problem solved (J.Chudoba)
23 ////////////////////////////////////////////////////////////////////////
27 // hitmap enables fast check if the pad was already hit
28 // The index of a AliTOFSDigit is saved in the each hitmap "cell"
29 // (there is an offset +1, because the index can be zero and
30 // zero means empty cell.
31 // In TOF, number of strips varies according plate type, the highest
32 // number is in plate C. For all plates is used this number, so
33 // the size of the hitmap is a little bit greater than necessary, but
34 // it simplifies the access algorithm.
37 // Author: Jiri Chudoba (CERN), based on AliMUONHitMap
39 ////////////////////////////////////////////////////////////////////////
44 #include "AliTOFHitMap.h"
45 #include "AliTOFSDigit.h"
46 #include "AliTOFConstants.h"
49 #include <TClonesArray.h>
51 ClassImp(AliTOFHitMap)
53 AliTOFHitMap::AliTOFHitMap()
62 ////////////////////////////////////////////////////////////////////////
63 AliTOFHitMap::AliTOFHitMap(TClonesArray *dig)
69 // of course, these constants must not be hardwired
72 fNSector = AliTOFConstants::fgkNSectors;
73 fNplate = AliTOFConstants::fgkNPlates;
74 fNstrip = AliTOFConstants::fgkNStripC;
75 fNpx = AliTOFConstants::fgkNpadX;
76 fNpy = AliTOFConstants::fgkNpadZ;
77 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpy;
78 fHitMap = new Int_t[fMaxIndex];
83 ////////////////////////////////////////////////////////////////////////
84 AliTOFHitMap::AliTOFHitMap(const AliTOFHitMap & hitMap)
87 // Dummy copy constructor
93 ////////////////////////////////////////////////////////////////////////
94 AliTOFHitMap::~AliTOFHitMap()
99 if (fHitMap) delete[] fHitMap;
102 ////////////////////////////////////////////////////////////////////////
103 void AliTOFHitMap::Clear(const char *)
108 memset(fHitMap,0,sizeof(int)*fMaxIndex);
111 ////////////////////////////////////////////////////////////////////////
112 Int_t AliTOFHitMap::CheckedIndex(Int_t *vol) const
115 // Return checked indices for vol
118 (vol[0]-1)*fNplate*fNstrip*fNpx*fNpy+ // sector
119 (vol[1]-1)*fNstrip*fNpx*fNpy+ // plate
120 (vol[2]-1)*fNpx*fNpy+ // strip
121 (vol[3]-1)*fNpy+ // padx
122 (vol[4]-1); // pady (=padz)
124 if (index >= fMaxIndex) {
125 Error("AliTOFHitMap","CheckedIndex - input outside bounds");
132 ////////////////////////////////////////////////////////////////////////
133 void AliTOFHitMap::SetHit(Int_t *vol, Int_t idigit)
136 // Assign digit to pad vol
139 // 0 means empty pad, we need to shift indeces by 1
140 fHitMap[CheckedIndex(vol)]=idigit+1;
143 ////////////////////////////////////////////////////////////////////////
144 void AliTOFHitMap::SetHit(Int_t *vol)
147 // Assign last digit to pad vol
150 // 0 means empty pad, we need to shift indeces by 1
151 fHitMap[CheckedIndex(vol)]=fSDigits->GetLast()+1;
154 ////////////////////////////////////////////////////////////////////////
155 Int_t AliTOFHitMap::GetHitIndex(Int_t *vol) const
158 // Get contents of pad vol
161 // 0 means empty pad, we need to shift indeces by 1
162 return fHitMap[CheckedIndex(vol)]-1;
165 ////////////////////////////////////////////////////////////////////////
166 TObject* AliTOFHitMap::GetHit(Int_t *vol) const
169 // Get pointer to object at vol
170 // return 0 if vol out of bounds
171 Int_t index=GetHitIndex(vol)-1;
172 return (index <0) ? 0 : fSDigits->UncheckedAt(index);
175 ////////////////////////////////////////////////////////////////////////
176 FlagType AliTOFHitMap::TestHit(Int_t *vol) const
179 // Check if hit cell is empty, used or unused
181 Int_t inf=fHitMap[CheckedIndex(vol)];
184 } else if (inf == 0) {
191 ////////////////////////////////////////////////////////////////////////
192 AliTOFHitMap & AliTOFHitMap::operator = (const AliTOFHitMap & rhs)
194 // Dummy assignment operator