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.2 2001/11/22 11:30:30 hristov
21 Revision 1.1 2001/11/22 11:22:51 hristov
22 Updated version of TOF digitization, N^2 problem solved (J.Chudoba)
26 ////////////////////////////////////////////////////////////////////////
30 // hitmap enables fast check if the pad was already hit
31 // The index of a AliTOFSDigit is saved in the each hitmap "cell"
32 // (there is an offset +1, because the index can be zero and
33 // zero means empty cell.
34 // In TOF, number of strips varies according plate type, the highest
35 // number is in plate C. For all plates is used this number, so
36 // the size of the hitmap is a little bit greater than necessary, but
37 // it simplifies the access algorithm.
40 // Author: Jiri Chudoba (CERN), based on AliMUONHitMap
42 ////////////////////////////////////////////////////////////////////////
47 #include "AliTOFHitMap.h"
48 #include "AliTOFSDigit.h"
49 #include "AliTOFConstants.h"
52 #include <TClonesArray.h>
54 ClassImp(AliTOFHitMap)
56 AliTOFHitMap::AliTOFHitMap()
65 ////////////////////////////////////////////////////////////////////////
66 AliTOFHitMap::AliTOFHitMap(TClonesArray *dig)
72 // of course, these constants must not be hardwired
75 fNSector = AliTOFConstants::fgkNSectors;
76 fNplate = AliTOFConstants::fgkNPlates;
77 fNstrip = AliTOFConstants::fgkNStripC;
78 fNpx = AliTOFConstants::fgkNpadX;
79 fNpy = AliTOFConstants::fgkNpadZ;
80 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpy;
81 fHitMap = new Int_t[fMaxIndex];
86 ////////////////////////////////////////////////////////////////////////
87 AliTOFHitMap::AliTOFHitMap(const AliTOFHitMap & hitMap)
90 // Dummy copy constructor
96 ////////////////////////////////////////////////////////////////////////
97 AliTOFHitMap::~AliTOFHitMap()
102 if (fHitMap) delete[] fHitMap;
105 ////////////////////////////////////////////////////////////////////////
106 void AliTOFHitMap::Clear(const char *)
111 memset(fHitMap,0,sizeof(int)*fMaxIndex);
114 ////////////////////////////////////////////////////////////////////////
115 Int_t AliTOFHitMap::CheckedIndex(Int_t *vol) const
118 // Return checked indices for vol
121 (vol[0]-1)*fNplate*fNstrip*fNpx*fNpy+ // sector
122 (vol[1]-1)*fNstrip*fNpx*fNpy+ // plate
123 (vol[2]-1)*fNpx*fNpy+ // strip
124 (vol[3]-1)*fNpy+ // padx
125 (vol[4]-1); // pady (=padz)
127 if (index >= fMaxIndex) {
128 Error("AliTOFHitMap","CheckedIndex - input outside bounds");
135 ////////////////////////////////////////////////////////////////////////
136 void AliTOFHitMap::SetHit(Int_t *vol, Int_t idigit)
139 // Assign digit to pad vol
142 // 0 means empty pad, we need to shift indeces by 1
143 fHitMap[CheckedIndex(vol)]=idigit+1;
146 ////////////////////////////////////////////////////////////////////////
147 void AliTOFHitMap::SetHit(Int_t *vol)
150 // Assign last digit to pad vol
153 // 0 means empty pad, we need to shift indeces by 1
154 fHitMap[CheckedIndex(vol)]=fSDigits->GetLast()+1;
157 ////////////////////////////////////////////////////////////////////////
158 Int_t AliTOFHitMap::GetHitIndex(Int_t *vol) const
161 // Get contents of pad vol
164 // 0 means empty pad, we need to shift indeces by 1
165 return fHitMap[CheckedIndex(vol)]-1;
168 ////////////////////////////////////////////////////////////////////////
169 TObject* AliTOFHitMap::GetHit(Int_t *vol) const
172 // Get pointer to object at vol
173 // return 0 if vol out of bounds
174 Int_t index=GetHitIndex(vol);
175 return (index <0) ? 0 : fSDigits->UncheckedAt(index);
178 ////////////////////////////////////////////////////////////////////////
179 FlagType AliTOFHitMap::TestHit(Int_t *vol) const
182 // Check if hit cell is empty, used or unused
184 Int_t inf=fHitMap[CheckedIndex(vol)];
187 } else if (inf == 0) {
194 ////////////////////////////////////////////////////////////////////////
195 AliTOFHitMap & AliTOFHitMap::operator = (const AliTOFHitMap & rhs)
197 // Dummy assignment operator