]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - TOF/AliTOFHitMap.cxx
Test suite for event-embedding (Adam).
[u/mrichter/AliRoot.git] / TOF / AliTOFHitMap.cxx
... / ...
CommitLineData
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
16/* $Id$ */
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
36#include "AliLog.h"
37#include "AliTOFHitMap.h"
38#include "AliTOFGeometry.h"
39
40
41#include <TClonesArray.h>
42
43ClassImp(AliTOFHitMap)
44
45AliTOFHitMap::AliTOFHitMap():
46 fNSector(-1),
47 fNplate(-1),
48 fNstrip(-1),
49 fNpx(-1),
50 fNpz(-1),
51 fSDigits(0x0),
52 fMaxIndex(-1),
53 fHitMap(0x0)
54{
55//
56// Default ctor
57//
58}
59
60////////////////////////////////////////////////////////////////////////
61AliTOFHitMap::AliTOFHitMap(TClonesArray *dig):
62 fNSector(-1),
63 fNplate(-1),
64 fNstrip(-1),
65 fNpx(-1),
66 fNpz(-1),
67 fSDigits(dig),
68 fMaxIndex(-1),
69 fHitMap(0x0)
70{
71//
72// ctor
73//
74
75// of course, these constants must not be hardwired
76// change later
77
78 fNSector = AliTOFGeometry::NSectors();
79 fNplate = AliTOFGeometry::NPlates();
80 fNstrip = AliTOFGeometry::NStripC();//fTOFGeometry->NMaxNstrip();
81 fNpx = AliTOFGeometry::NpadX();
82 fNpz = AliTOFGeometry::NpadZ();
83 fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
84 fHitMap = new Int_t[fMaxIndex];
85 Clear();
86}
87
88////////////////////////////////////////////////////////////////////////
89AliTOFHitMap::AliTOFHitMap(const AliTOFHitMap & /*hitMap*/)
90 :TObject(),
91 fNSector(-1),
92 fNplate(-1),
93 fNstrip(-1),
94 fNpx(-1),
95 fNpz(-1),
96 fSDigits(0x0),
97 fMaxIndex(-1),
98 fHitMap(0x0)
99{
100//
101// Dummy copy constructor
102//
103 ;
104}
105
106
107////////////////////////////////////////////////////////////////////////
108AliTOFHitMap::~AliTOFHitMap()
109{
110//
111// Destructor
112//
113 delete[] fHitMap;
114
115}
116
117////////////////////////////////////////////////////////////////////////
118void AliTOFHitMap::Clear(const char *)
119{
120//
121// Clear hitmap
122//
123 memset(fHitMap,0,sizeof(int)*fMaxIndex);
124}
125
126////////////////////////////////////////////////////////////////////////
127Int_t AliTOFHitMap::CheckedIndex(Int_t *vol) const
128{
129//
130// Return checked indices for vol
131//
132 Int_t index=
133 vol[0]*fNplate*fNstrip*fNpx*fNpz+ // sector
134 vol[1]*fNstrip*fNpx*fNpz+ // plate
135 vol[2]*fNpx*fNpz+ // strip
136 vol[3]*fNpz+ // padx
137 vol[4]; // padz
138
139 if (index >= fMaxIndex) {
140 AliError("CheckedIndex - input outside bounds");
141 return -1;
142 } else {
143 return index;
144 }
145}
146
147////////////////////////////////////////////////////////////////////////
148void AliTOFHitMap::SetHit(Int_t *vol, Int_t idigit)
149{
150//
151// Assign digit to pad vol
152//
153
154// 0 means empty pad, we need to shift indeces by 1
155 fHitMap[CheckedIndex(vol)]=idigit+1;
156}
157
158////////////////////////////////////////////////////////////////////////
159void AliTOFHitMap::SetHit(Int_t *vol)
160{
161//
162// Assign last digit to pad vol
163//
164
165// 0 means empty pad, we need to shift indeces by 1
166 fHitMap[CheckedIndex(vol)]=fSDigits->GetLast()+1;
167}
168
169////////////////////////////////////////////////////////////////////////
170Int_t AliTOFHitMap::GetHitIndex(Int_t *vol) const
171{
172//
173// Get contents of pad vol
174//
175
176// 0 means empty pad, we need to shift indeces by 1
177 return fHitMap[CheckedIndex(vol)]-1;
178}
179
180////////////////////////////////////////////////////////////////////////
181TObject* AliTOFHitMap::GetHit(Int_t *vol) const
182{
183//
184// Get pointer to object at vol
185// return 0 if vol out of bounds
186 Int_t index=GetHitIndex(vol);
187 return (index <0) ? 0 : fSDigits->UncheckedAt(index);
188}
189
190////////////////////////////////////////////////////////////////////////
191FlagType AliTOFHitMap::TestHit(Int_t *vol) const
192{
193//
194// Check if hit cell is empty, used or unused
195//
196 Int_t inf=fHitMap[CheckedIndex(vol)];
197 if (inf > 0) {
198 return kUsed;
199 } else if (inf == 0) {
200 return kEmpty;
201 } else {
202 return kUnused;
203 }
204}
205
206////////////////////////////////////////////////////////////////////////
207AliTOFHitMap & AliTOFHitMap::operator = (const AliTOFHitMap & /*rhs*/)
208{
209// Dummy assignment operator
210 return *this;
211}