]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFRawStream.cxx
Minor fixes in the event tag to take into account the new way of storing the trigger...
[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
0e46b9ae 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////////////////////////////////////////////////////////////////////////
571dda3d 39
571dda3d 40#include "AliRawReader.h"
41
42#include "AliTOFGeometry.h"
303e152f 43#include "AliTOFGeometryV5.h"
571dda3d 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
303e152f 66 fTOFGeometry = new AliTOFGeometryV5();
d3c7bfac 67
571dda3d 68 fRawReader->Select(5);
69
70}
71
72//_____________________________________________________________________________
73AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
74 TObject(stream)
75{
76 //
77 // copy constructor
78 //
79
80 fRawReader = NULL;
81 fDDL = -1;
82 fTRM = -1;
83 fTDC = -1;
84 fTDCChannel = -1;
85 fTof = -1;
86 fADC = -1;
87 fErrorFlag = -1;
88 //fCounter = -1; // v0.01
89
303e152f 90 fTOFGeometry = new AliTOFGeometryV5();
d3c7bfac 91
571dda3d 92}
93
94//_____________________________________________________________________________
95AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
96{
97 //
98 // assignment operator
99 //
100
101 fRawReader = stream.fRawReader;
102 fDDL = stream.fDDL;
103 fTRM = stream.fTRM;
104 fTDC = stream.fTDC;
105 fTDCChannel = stream.fTDCChannel;
106 fTof = stream.fTof;
107 fADC = stream.fADC;
108 fErrorFlag = stream.fErrorFlag;
109 //fCounter = stream.fCounter; // v0.01
110
d3c7bfac 111 fTOFGeometry = stream.fTOFGeometry;
112
571dda3d 113 return *this;
114
115}
116
117//_____________________________________________________________________________
118AliTOFRawStream::~AliTOFRawStream()
119{
120// destructor
121
7e9654e7 122 fTOFGeometry = 0;
d3c7bfac 123
571dda3d 124}
125
126
127//_____________________________________________________________________________
128Bool_t AliTOFRawStream::Next()
129{
130// read the next raw digit
131// returns kFALSE if there is no digit left
132
133 //fCounter++; // v0.01
134
135 UInt_t data;
136
137 /*
138 // v0.01
139 if (fCounter==0) {
140 if (!fRawReader->ReadNextInt(data)) return kFALSE;
141 Int_t dummy = data & 0x007F; // first 7 bits
142 AliInfo(Form("This is the number of the current DDL file %2i",dummy));
143 }
144 */
145
146 if (!fRawReader->ReadNextInt(data)) return kFALSE;
147
148 fTRM = data & 0x000F; // first 4 bits
149 fTDC = (data >> 4) & 0x001F; // next 5 bits
150 fTDCChannel = (data >> 9) & 0x0007; // next 3 bits
151 fADC = (data >> 12) & 0x000FFFFF; // last 20 bits // v0.01
152 //fADC = (data >> 12) & 0x00FF; // next 8 bits // v0.02
153
154 if (!fRawReader->ReadNextInt(data)) return kFALSE;
155
156 fErrorFlag = data & 0x00FF; // first 8 bits
157 fTof = (data >> 8) & 0x00FFFFFF; // last 24 bits // v0.01
158 //fTof = (data >> 8) & 0x0FFF; // next 12 bits // v0.02
159
160 fDDL = fRawReader->GetDDLID();
161
162 //AliInfo(Form("fDDL %2i,fTRM %2i, fTDC %2i, fTDCChannel %1i",fDDL,fTRM,fTDC,fTDCChannel));
163
164 return kTRUE;
165}
166//_____________________________________________________________________________
167
168Int_t AliTOFRawStream::GetSector() const
169{
170 //
171 // Transform the Hardware coordinate to Software coordinate
172 // and also write it in the digit form
173 //
174
175 Int_t iSector = -1;
176 iSector = (Int_t)((Float_t)fDDL/AliTOFGeometry::NDDL());
177
178 return iSector;
179
180}
181//_____________________________________________________________________________
182
183Int_t AliTOFRawStream::GetPlate() const
184{
185 //
186 // Transform the Hardware coordinate to Software coordinate
187 // and also write it in the digit form
188 //
189
190 Int_t iPlate = -1;
191
192 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
193
194 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
195
196 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
197
d3c7bfac 198 if (iStripPerSector < fTOFGeometry->NStripC())
571dda3d 199 iPlate = 0;
d3c7bfac 200 else if (iStripPerSector>=fTOFGeometry->NStripC() &&
201 iStripPerSector< fTOFGeometry->NStripC()+AliTOFGeometry::NStripB())
571dda3d 202 iPlate = 1;
d3c7bfac 203 else if (iStripPerSector>=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB() &&
204 iStripPerSector< fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA())
571dda3d 205 iPlate = 2;
d3c7bfac 206 else if (iStripPerSector>=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA() &&
207 iStripPerSector< fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB())
571dda3d 208 iPlate = 3;
d3c7bfac 209 else if (iStripPerSector>=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB() &&
210 iStripPerSector< fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB()+fTOFGeometry->NStripC())
571dda3d 211 iPlate = 4;
212 else
213 iPlate = -1;
214
215 return iPlate;
216
217}
218//_____________________________________________________________________________
219
220Int_t AliTOFRawStream::GetStrip() const
221{
222 //
223 // Transform the Hardware coordinate to Software coordinate
224 // and also write it in the digit form
225 //
226
227 Int_t iStrip = -1;
228
229 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
230
231 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
232
233 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
234
d3c7bfac 235 if (iStripPerSector < fTOFGeometry->NStripC())
571dda3d 236 iStrip = iStripPerSector;
d3c7bfac 237 else if (iStripPerSector >=fTOFGeometry->NStripC() &&
238 iStripPerSector < fTOFGeometry->NStripC()+AliTOFGeometry::NStripB())
239 iStrip = iStripPerSector-fTOFGeometry->NStripC();
240 else if (iStripPerSector >=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB() &&
241 iStripPerSector < fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA())
242 iStrip = iStripPerSector-fTOFGeometry->NStripC()-AliTOFGeometry::NStripB();
243 else if (iStripPerSector >=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA() &&
244 iStripPerSector < fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB())
245 iStrip = iStripPerSector-fTOFGeometry->NStripC()-AliTOFGeometry::NStripB()-AliTOFGeometry::NStripA();
246 else if (iStripPerSector >=fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB() &&
247 iStripPerSector < fTOFGeometry->NStripC()+AliTOFGeometry::NStripB()+AliTOFGeometry::NStripA()+AliTOFGeometry::NStripB()+fTOFGeometry->NStripC())
248 iStrip = iStripPerSector-fTOFGeometry->NStripC()-AliTOFGeometry::NStripB()-AliTOFGeometry::NStripA()-AliTOFGeometry::NStripB();
571dda3d 249 else
250 iStrip = -1;
251
252 return iStrip;
253
254}
255//_____________________________________________________________________________
256
257Int_t AliTOFRawStream::GetPadZ() const
258{
259 //
260 // Transform the Hardware coordinate to Software coordinate
261 // and also write it in the digit form
262 //
263
264 Int_t iPadZ = -1;
265
266 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
267
268 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
269
270 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
271
272 Int_t iPadPerStrip = iPadPerSector-AliTOFGeometry::NpadX()*AliTOFGeometry::NpadZ()*iStripPerSector;
273
274 iPadZ = iPadPerStrip%AliTOFGeometry::NpadZ();
275
276 return iPadZ;
277
278}
279//_____________________________________________________________________________
280
281Int_t AliTOFRawStream::GetPadX() const
282{
283 //
284 // Transform the Hardware coordinate to Software coordinate
285 // and also write it in the digit form
286 //
287
288 Int_t iPadX = -1;
289
290 Int_t localDDL = fDDL%AliTOFGeometry::NDDL();
291
292 Int_t iPadPerSector = fTDCChannel + AliTOFGeometry::NCh()*(fTDC + AliTOFGeometry::NTdc()*(fTRM + AliTOFGeometry::NTRM()*localDDL));
293
294 Int_t iStripPerSector = (Int_t)(iPadPerSector/(Float_t)AliTOFGeometry::NpadX()/(Float_t)AliTOFGeometry::NpadZ());
295
296 Int_t iPadPerStrip = iPadPerSector-AliTOFGeometry::NpadX()*AliTOFGeometry::NpadZ()*iStripPerSector;
297
298 iPadX = (Int_t)(iPadPerStrip/(Float_t)AliTOFGeometry::NpadZ());
299
300 return iPadX;
301
302}
303//_____________________________________________________________________________