]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFRawStream.cxx
ESDtrack TOF cluster index now pointing to recPoints (S.Arcelli, C.Zampolli)
[u/mrichter/AliRoot.git] / TOF / AliTOFRawStream.cxx
CommitLineData
571dda3d 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/*
17Revision 0.02 2005/07/28 A. De Caro:
18 Update format TOF raw data
19 (temporary solution)
20 Correction of few wrong corrispondences
21 between 'software' and 'hardware' numberings
22
23Revision 0.01 2005/07/22 A. De Caro
24 Implement methods Next()
25 GetSector(),
26 GetPlate(),
27 GetStrip(),
28 GetPadZ(),
29 GetPadX()
30*/
31
32///////////////////////////////////////////////////////////////////////////////
33//
34// This class provides access to TOF raw data in DDL files.
35//
36// It loops over all TOF raw data given by the AliRawReader.
37//
38///////////////////////////////////////////////////////////////////////////////
39
40#include "AliLog.h"
41#include "AliRawReader.h"
42
43#include "AliTOFGeometry.h"
44#include "AliTOFRawStream.h"
45
46ClassImp(AliTOFRawStream)
47
48
49//_____________________________________________________________________________
50AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader)
51{
52 //
53 // create an object to read TOF raw digits
54 //
55
56 fRawReader = rawReader;
57 fDDL = -1;
58 fTRM = -1;
59 fTDC = -1;
60 fTDCChannel = -1;
61 fTof = -1;
62 fADC = -1;
63 fErrorFlag = -1;
64 //fCounter = -1; // v0.01
65
66 fRawReader->Select(5);
67
68}
69
70//_____________________________________________________________________________
71AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
72 TObject(stream)
73{
74 //
75 // copy constructor
76 //
77
78 fRawReader = NULL;
79 fDDL = -1;
80 fTRM = -1;
81 fTDC = -1;
82 fTDCChannel = -1;
83 fTof = -1;
84 fADC = -1;
85 fErrorFlag = -1;
86 //fCounter = -1; // v0.01
87
88}
89
90//_____________________________________________________________________________
91AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
92{
93 //
94 // assignment operator
95 //
96
97 fRawReader = stream.fRawReader;
98 fDDL = stream.fDDL;
99 fTRM = stream.fTRM;
100 fTDC = stream.fTDC;
101 fTDCChannel = stream.fTDCChannel;
102 fTof = stream.fTof;
103 fADC = stream.fADC;
104 fErrorFlag = stream.fErrorFlag;
105 //fCounter = stream.fCounter; // v0.01
106
107 return *this;
108
109}
110
111//_____________________________________________________________________________
112AliTOFRawStream::~AliTOFRawStream()
113{
114// destructor
115
116}
117
118
119//_____________________________________________________________________________
120Bool_t AliTOFRawStream::Next()
121{
122// read the next raw digit
123// returns kFALSE if there is no digit left
124
125 //fCounter++; // v0.01
126
127 UInt_t data;
128
129 /*
130 // v0.01
131 if (fCounter==0) {
132 if (!fRawReader->ReadNextInt(data)) return kFALSE;
133 Int_t dummy = data & 0x007F; // first 7 bits
134 AliInfo(Form("This is the number of the current DDL file %2i",dummy));
135 }
136 */
137
138 if (!fRawReader->ReadNextInt(data)) return kFALSE;
139
140 fTRM = data & 0x000F; // first 4 bits
141 fTDC = (data >> 4) & 0x001F; // next 5 bits
142 fTDCChannel = (data >> 9) & 0x0007; // next 3 bits
143 fADC = (data >> 12) & 0x000FFFFF; // last 20 bits // v0.01
144 //fADC = (data >> 12) & 0x00FF; // next 8 bits // v0.02
145
146 if (!fRawReader->ReadNextInt(data)) return kFALSE;
147
148 fErrorFlag = data & 0x00FF; // first 8 bits
149 fTof = (data >> 8) & 0x00FFFFFF; // last 24 bits // v0.01
150 //fTof = (data >> 8) & 0x0FFF; // next 12 bits // v0.02
151
152 fDDL = fRawReader->GetDDLID();
153
154 //AliInfo(Form("fDDL %2i,fTRM %2i, fTDC %2i, fTDCChannel %1i",fDDL,fTRM,fTDC,fTDCChannel));
155
156 return kTRUE;
157}
158//_____________________________________________________________________________
159
160Int_t AliTOFRawStream::GetSector() const
161{
162 //
163 // Transform the Hardware coordinate to Software coordinate
164 // and also write it in the digit form
165 //
166
167 Int_t iSector = -1;
168 iSector = (Int_t)((Float_t)fDDL/AliTOFGeometry::NDDL());
169
170 return iSector;
171
172}
173//_____________________________________________________________________________
174
175Int_t AliTOFRawStream::GetPlate() const
176{
177 //
178 // Transform the Hardware coordinate to Software coordinate
179 // and also write it in the digit form
180 //
181
182 Int_t iPlate = -1;
183
184 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
185
186 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
187
188 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
189
190 if (iStripPerSector < AliTOFGeometry::NStripC())
191 iPlate = 0;
192 else if (iStripPerSector>=AliTOFGeometry::NStripC() &&
193 iStripPerSector< AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())
194 iPlate = 1;
195 else if (iStripPerSector>=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB() &&
196 iStripPerSector< AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA())
197 iPlate = 2;
198 else if (iStripPerSector>=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA() &&
199 iStripPerSector< AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB())
200 iPlate = 3;
201 else if (iStripPerSector>=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB() &&
202 iStripPerSector< AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripC())
203 iPlate = 4;
204 else
205 iPlate = -1;
206
207 return iPlate;
208
209}
210//_____________________________________________________________________________
211
212Int_t AliTOFRawStream::GetStrip() const
213{
214 //
215 // Transform the Hardware coordinate to Software coordinate
216 // and also write it in the digit form
217 //
218
219 Int_t iStrip = -1;
220
221 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
222
223 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
224
225 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
226
227 if (iStripPerSector < AliTOFGeometry::NStripC())
228 iStrip = iStripPerSector;
229 else if (iStripPerSector >=AliTOFGeometry::NStripC() &&
230 iStripPerSector < AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())
231 iStrip = iStripPerSector-AliTOFGeometry::NStripC();
232 else if (iStripPerSector >=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB() &&
233 iStripPerSector < AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA())
234 iStrip = iStripPerSector-AliTOFGeometry::NStripC()-AliTOFGeometry::NStripB();
235 else if (iStripPerSector >=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA() &&
236 iStripPerSector < AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB())
237 iStrip = iStripPerSector-AliTOFGeometry::NStripC()-AliTOFGeometry::NStripB()-AliTOFGeometry::NStripA();
238 else if (iStripPerSector >=AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB() &&
239 iStripPerSector < AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripC())
240 iStrip = iStripPerSector-AliTOFGeometry::NStripC()-AliTOFGeometry::NStripB()-AliTOFGeometry::NStripA()-AliTOFGeometry::NStripB();
241 else
242 iStrip = -1;
243
244 return iStrip;
245
246}
247//_____________________________________________________________________________
248
249Int_t AliTOFRawStream::GetPadZ() const
250{
251 //
252 // Transform the Hardware coordinate to Software coordinate
253 // and also write it in the digit form
254 //
255
256 Int_t iPadZ = -1;
257
258 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
259
260 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
261
262 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
263
264 Int_t iPadPerStrip = iPadPerSector-AliTOFGeometry::NpadX()*AliTOFGeometry::NpadZ()*iStripPerSector;
265
266 iPadZ = iPadPerStrip%AliTOFGeometry::NpadZ();
267
268 return iPadZ;
269
270}
271//_____________________________________________________________________________
272
273Int_t AliTOFRawStream::GetPadX() const
274{
275 //
276 // Transform the Hardware coordinate to Software coordinate
277 // and also write it in the digit form
278 //
279
280 Int_t iPadX = -1;
281
282 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
283
284 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
285
286 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
287
288 Int_t iPadPerStrip = iPadPerSector-AliTOFGeometry::NpadX()*AliTOFGeometry::NpadZ()*iStripPerSector;
289
290 iPadX = (Int_t)(iPadPerStrip/(Float_t)AliTOFGeometry::NpadZ());
291
292 return iPadX;
293
294}
295//_____________________________________________________________________________