]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFHitMap.cxx
#101318: Patch for various problems in AliROOT
[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
655e379f 45AliTOFHitMap::AliTOFHitMap():
46 fNSector(-1),
47 fNplate(-1),
48 fNstrip(-1),
49 fNpx(-1),
50 fNpz(-1),
51 fSDigits(0x0),
52 fMaxIndex(-1),
10056aa6 53 fHitMap(0x0)
5919c40c 54{
55//
56// Default ctor
57//
5919c40c 58}
59
60////////////////////////////////////////////////////////////////////////
10056aa6 61AliTOFHitMap::AliTOFHitMap(TClonesArray *dig):
655e379f 62 fNSector(-1),
63 fNplate(-1),
64 fNstrip(-1),
65 fNpx(-1),
66 fNpz(-1),
67 fSDigits(dig),
68 fMaxIndex(-1),
10056aa6 69 fHitMap(0x0)
5919c40c 70{
71//
72// ctor
73//
74
75// of course, these constants must not be hardwired
76// change later
77
0f4a7374 78 fNSector = AliTOFGeometry::NSectors();
79 fNplate = AliTOFGeometry::NPlates();
10056aa6 80 fNstrip = AliTOFGeometry::NStripC();//fTOFGeometry->NMaxNstrip();
0f4a7374 81 fNpx = AliTOFGeometry::NpadX();
82 fNpz = AliTOFGeometry::NpadZ();
da3d3acd 83 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
5919c40c 84 fHitMap = new Int_t[fMaxIndex];
5919c40c 85 Clear();
86}
87
5919c40c 88////////////////////////////////////////////////////////////////////////
89AliTOFHitMap::~AliTOFHitMap()
90{
91//
92// Destructor
93//
d3c7bfac 94 delete[] fHitMap;
95
5919c40c 96}
97
98////////////////////////////////////////////////////////////////////////
99void AliTOFHitMap::Clear(const char *)
100{
101//
102// Clear hitmap
103//
104 memset(fHitMap,0,sizeof(int)*fMaxIndex);
105}
106
107////////////////////////////////////////////////////////////////////////
0e74c396 108Int_t AliTOFHitMap::CheckedIndex(Int_t * const vol) const
5919c40c 109{
110//
111// Return checked indices for vol
112//
113 Int_t index=
d3c7bfac 114 vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector
115 vol[1]*fNstrip*fNpx*fNpz+ // plate
116 vol[2]*fNpx*fNpz+ // strip
117 vol[3]*fNpz+ // padx
118 vol[4]; // padz
5919c40c 119
120 if (index >= fMaxIndex) {
d076c8d5 121 AliError("CheckedIndex - input outside bounds");
5919c40c 122 return -1;
123 } else {
124 return index;
125 }
126}
127
128////////////////////////////////////////////////////////////////////////
129void AliTOFHitMap::SetHit(Int_t *vol, Int_t idigit)
130{
131//
132// Assign digit to pad vol
133//
134
135// 0 means empty pad, we need to shift indeces by 1
136 fHitMap[CheckedIndex(vol)]=idigit+1;
137}
138
139////////////////////////////////////////////////////////////////////////
140void AliTOFHitMap::SetHit(Int_t *vol)
141{
142//
143// Assign last digit to pad vol
144//
145
146// 0 means empty pad, we need to shift indeces by 1
147 fHitMap[CheckedIndex(vol)]=fSDigits->GetLast()+1;
148}
149
150////////////////////////////////////////////////////////////////////////
151Int_t AliTOFHitMap::GetHitIndex(Int_t *vol) const
152{
153//
154// Get contents of pad vol
155//
156
157// 0 means empty pad, we need to shift indeces by 1
158 return fHitMap[CheckedIndex(vol)]-1;
159}
160
161////////////////////////////////////////////////////////////////////////
162TObject* AliTOFHitMap::GetHit(Int_t *vol) const
163{
164//
165// Get pointer to object at vol
166// return 0 if vol out of bounds
2f8510c7 167 Int_t index=GetHitIndex(vol);
5919c40c 168 return (index <0) ? 0 : fSDigits->UncheckedAt(index);
169}
170
171////////////////////////////////////////////////////////////////////////
172FlagType AliTOFHitMap::TestHit(Int_t *vol) const
173{
174//
175// Check if hit cell is empty, used or unused
176//
177 Int_t inf=fHitMap[CheckedIndex(vol)];
0085f44e 178 if (inf > 0) {
5919c40c 179 return kUsed;
180 } else if (inf == 0) {
181 return kEmpty;
182 } else {
183 return kUnused;
184 }
185}