]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFRawMap.cxx
Changing order of T0 selections (Alla)
[u/mrichter/AliRoot.git] / TOF / AliTOFRawMap.cxx
CommitLineData
15ec34b9 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// AliTOFRawMap class //
21// //
22// It enables fast check if the TDC channel was already engaged //
23// for a measurement. //
24// The index of a AliTOFrawData is saved in the each rawdatamap "cell" //
25// (there is an offset +1, because the index can be zero and //
26// zero means empty cell. //
27// //
28/////////////////////////////////////////////////////////////////////////
29
30#include "TClonesArray.h"
31
32#include "AliLog.h"
33
34#include "AliTOFGeometry.h"
35#include "AliTOFRawMap.h"
36
37ClassImp(AliTOFRawMap)
38
39AliTOFRawMap::AliTOFRawMap():
8a190ba2 40 TObject(),
15ec34b9 41 fNtrm(-1),
42 fNtrmChain(-1),
43 fNtdc(-1),
44 fNtdcChannel(-1),
45 fRawData(0x0),
46 fMaxIndex(-1),
47 fRawMap(0x0)
48{
49//
50// Default ctor
51//
52}
53
54////////////////////////////////////////////////////////////////////////
8a190ba2 55AliTOFRawMap::AliTOFRawMap(TClonesArray *dig)://, AliTOFGeometry *tofGeom:
56 TObject(),
57 fNtrm(AliTOFGeometry::NTRM()+2),
58 fNtrmChain(AliTOFGeometry::NChain()),
59 fNtdc(AliTOFGeometry::NTdc()),
60 fNtdcChannel(AliTOFGeometry::NCh()),
15ec34b9 61 fRawData(dig),
62 fMaxIndex(-1),
63 fRawMap(0x0)
64{
65//
66// ctor
67//
68
69// of course, these constants must not be hardwired
70// change later
71
15ec34b9 72 fMaxIndex = fNtrm*fNtrmChain*fNtdc*fNtdcChannel;
73 fRawMap = new Int_t[fMaxIndex];
74 Clear();
75}
76
77////////////////////////////////////////////////////////////////////////
a3b608e8 78AliTOFRawMap::AliTOFRawMap(const AliTOFRawMap & rawMap) :
79 TObject(rawMap),
8a190ba2 80 fNtrm(rawMap.fNtrm),
81 fNtrmChain(rawMap.fNtrmChain),
82 fNtdc(rawMap.fNtdc),
83 fNtdcChannel(rawMap.fNtdcChannel),
84 fRawData(rawMap.fRawData),
15ec34b9 85 fMaxIndex(-1),
86 fRawMap(0x0)
87{
88//
89// Dummy copy constructor
90//
91
8a190ba2 92 fMaxIndex = fNtrm*fNtrmChain*fNtdc*fNtdcChannel;
93 fRawMap = new Int_t[fMaxIndex];
a3b608e8 94 for (Int_t i=0; i<fMaxIndex; i++)
95 fRawMap[i]=rawMap.fRawMap[i];
96
8a190ba2 97}
98
99////////////////////////////////////////////////////////////////////////
a3b608e8 100AliTOFRawMap & AliTOFRawMap::operator=(const AliTOFRawMap & rawMap)
8a190ba2 101{
102//
103// Dummy copy constructor
104//
a3b608e8 105
106 if (this == &rawMap)
107 return *this;
108
109 fNtrm=rawMap.fNtrm;
110 fNtrmChain=rawMap.fNtrmChain;
111 fNtdc=rawMap.fNtdc;
112 fNtdcChannel=rawMap.fNtdcChannel;
113 fRawData=rawMap.fRawData;
114 fMaxIndex=fNtrm*fNtrmChain*fNtdc*fNtdcChannel;
115 fRawMap = new Int_t[fMaxIndex];
116 for (Int_t i=0; i<fMaxIndex; i++)
117 fRawMap[i]=rawMap.fRawMap[i];
8a190ba2 118 return *this;
a3b608e8 119
15ec34b9 120}
121
122
123////////////////////////////////////////////////////////////////////////
124AliTOFRawMap::~AliTOFRawMap()
125{
126//
127// Destructor
128//
8a190ba2 129 if (fRawMap)
130 delete[] fRawMap;
15ec34b9 131
132}
133
134////////////////////////////////////////////////////////////////////////
135void AliTOFRawMap::Clear(const char *)
136{
137//
138// Clear hitmap
139//
140 memset(fRawMap,0,sizeof(int)*fMaxIndex);
141}
142
143////////////////////////////////////////////////////////////////////////
0e74c396 144Int_t AliTOFRawMap::CheckedIndex(const Int_t * const slot) const
15ec34b9 145{
146//
147// Return checked indices for vol
148//
149 Int_t index =
150 slot[0]*fNtrmChain*fNtdc*fNtdcChannel + // TRM
151 slot[1]*fNtdc*fNtdcChannel + // TRM chain
152 slot[2]*fNtdcChannel + // TDC
153 slot[3]; // TDC channel
154
155 if (index >= fMaxIndex) {
156 AliError("CheckedIndex - input outside bounds");
157 return -1;
158 } else {
159 return index;
160 }
161}
162
163////////////////////////////////////////////////////////////////////////
164void AliTOFRawMap::SetHit(Int_t *slot, Int_t idigit)
165{
166//
167// Assign digit to pad vol
168//
169
170// 0 means empty pad, we need to shift indeces by 1
171 fRawMap[CheckedIndex(slot)]=idigit+1;
172}
173
174////////////////////////////////////////////////////////////////////////
175void AliTOFRawMap::SetHit(Int_t *slot)
176{
177//
178// Assign last digit to channel slot
179//
180
181// 0 means empty pad, we need to shift indeces by 1
182 fRawMap[CheckedIndex(slot)]=fRawData->GetLast()+1;
183}
184
185////////////////////////////////////////////////////////////////////////
186Int_t AliTOFRawMap::GetHitIndex(Int_t *slot) const
187{
188//
189// Get contents of channel slot
190//
191
192// 0 means empty pad, we need to shift indeces by 1
193 return fRawMap[CheckedIndex(slot)]-1;
194}
195
196////////////////////////////////////////////////////////////////////////
197TObject* AliTOFRawMap::GetHit(Int_t *slot) const
198{
199//
200// Get pointer to object at alot
201// return 0 if vol out of bounds
202 Int_t index = GetHitIndex(slot);
203 return (index <0) ? 0 : fRawData->UncheckedAt(index);
204}
205
206////////////////////////////////////////////////////////////////////////
207FlagType AliTOFRawMap::TestHit(Int_t *slot) const
208{
209//
210// Check if hit cell is empty, used or unused
211//
212 Int_t inf = fRawMap[CheckedIndex(slot)];
213 if (inf > 0) {
214 return kUsed;
215 } else if (inf == 0) {
216 return kEmpty;
217 } else {
218 return kUnused;
219 }
220}
221