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