]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFHitMap.cxx
minor changes to improve serializability
[u/mrichter/AliRoot.git] / TOF / AliTOFHitMap.cxx
CommitLineData
5919c40c 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
88cb7938 16/* $Id$ */
5919c40c 17
18////////////////////////////////////////////////////////////////////////
19//
20// AliTOFHitMap class
21//
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.
30//
31//
32// Author: Jiri Chudoba (CERN), based on AliMUONHitMap
33//
34////////////////////////////////////////////////////////////////////////
35
d076c8d5 36#include "AliLog.h"
5919c40c 37#include "AliTOFHitMap.h"
0f4a7374 38#include "AliTOFGeometry.h"
5919c40c 39
40
41#include <TClonesArray.h>
42
43ClassImp(AliTOFHitMap)
44
45AliTOFHitMap::AliTOFHitMap()
46{
47//
48// Default ctor
49//
50 fHitMap = 0;
51 fSDigits = 0;
52}
53
54////////////////////////////////////////////////////////////////////////
d3c7bfac 55AliTOFHitMap::AliTOFHitMap(TClonesArray *dig, AliTOFGeometry *tofGeom)
5919c40c 56{
57//
58// ctor
59//
60
61// of course, these constants must not be hardwired
62// change later
63
d3c7bfac 64 fTOFGeometry = tofGeom;
65
0f4a7374 66 fNSector = AliTOFGeometry::NSectors();
67 fNplate = AliTOFGeometry::NPlates();
d3c7bfac 68 fNstrip = fTOFGeometry->NMaxNstrip();
0f4a7374 69 fNpx = AliTOFGeometry::NpadX();
70 fNpz = AliTOFGeometry::NpadZ();
da3d3acd 71 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
5919c40c 72 fHitMap = new Int_t[fMaxIndex];
73 fSDigits = dig;
74 Clear();
75}
76
77////////////////////////////////////////////////////////////////////////
5c016a7b 78AliTOFHitMap::AliTOFHitMap(const AliTOFHitMap & /*hitMap*/)
79:TObject()
5919c40c 80{
81//
82// Dummy copy constructor
83//
d3c7bfac 84 ;
5919c40c 85}
86
87
88////////////////////////////////////////////////////////////////////////
89AliTOFHitMap::~AliTOFHitMap()
90{
91//
92// Destructor
93//
d3c7bfac 94 delete[] fHitMap;
95
afd804a3 96 fTOFGeometry = 0x0;
d3c7bfac 97
5919c40c 98}
99
100////////////////////////////////////////////////////////////////////////
101void AliTOFHitMap::Clear(const char *)
102{
103//
104// Clear hitmap
105//
106 memset(fHitMap,0,sizeof(int)*fMaxIndex);
107}
108
109////////////////////////////////////////////////////////////////////////
110Int_t AliTOFHitMap::CheckedIndex(Int_t *vol) const
111{
112//
113// Return checked indices for vol
114//
115 Int_t index=
d3c7bfac 116 vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector
117 vol[1]*fNstrip*fNpx*fNpz+ // plate
118 vol[2]*fNpx*fNpz+ // strip
119 vol[3]*fNpz+ // padx
120 vol[4]; // padz
5919c40c 121
122 if (index >= fMaxIndex) {
d076c8d5 123 AliError("CheckedIndex - input outside bounds");
5919c40c 124 return -1;
125 } else {
126 return index;
127 }
128}
129
130////////////////////////////////////////////////////////////////////////
131void AliTOFHitMap::SetHit(Int_t *vol, Int_t idigit)
132{
133//
134// Assign digit to pad vol
135//
136
137// 0 means empty pad, we need to shift indeces by 1
138 fHitMap[CheckedIndex(vol)]=idigit+1;
139}
140
141////////////////////////////////////////////////////////////////////////
142void AliTOFHitMap::SetHit(Int_t *vol)
143{
144//
145// Assign last digit to pad vol
146//
147
148// 0 means empty pad, we need to shift indeces by 1
149 fHitMap[CheckedIndex(vol)]=fSDigits->GetLast()+1;
150}
151
152////////////////////////////////////////////////////////////////////////
153Int_t AliTOFHitMap::GetHitIndex(Int_t *vol) const
154{
155//
156// Get contents of pad vol
157//
158
159// 0 means empty pad, we need to shift indeces by 1
160 return fHitMap[CheckedIndex(vol)]-1;
161}
162
163////////////////////////////////////////////////////////////////////////
164TObject* AliTOFHitMap::GetHit(Int_t *vol) const
165{
166//
167// Get pointer to object at vol
168// return 0 if vol out of bounds
2f8510c7 169 Int_t index=GetHitIndex(vol);
5919c40c 170 return (index <0) ? 0 : fSDigits->UncheckedAt(index);
171}
172
173////////////////////////////////////////////////////////////////////////
174FlagType AliTOFHitMap::TestHit(Int_t *vol) const
175{
176//
177// Check if hit cell is empty, used or unused
178//
179 Int_t inf=fHitMap[CheckedIndex(vol)];
0085f44e 180 if (inf > 0) {
5919c40c 181 return kUsed;
182 } else if (inf == 0) {
183 return kEmpty;
184 } else {
185 return kUnused;
186 }
187}
188
189////////////////////////////////////////////////////////////////////////
5c016a7b 190AliTOFHitMap & AliTOFHitMap::operator = (const AliTOFHitMap & /*rhs*/)
5919c40c 191{
192// Dummy assignment operator
193 return *this;
194}