]>
Commit | Line | Data |
---|---|---|
c0751163 | 1 | /************************************************************************** |
33434f31 | 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 | **************************************************************************/ | |
c0751163 | 15 | |
c4ee792d | 16 | /* $Id $ */ |
17 | ||
c0751163 | 18 | |
19 | /////////////////////////////////////////////////////////////////////////////// | |
20 | /// | |
c4ee792d | 21 | /// \class AliMUONRawStreamTracker |
c0751163 | 22 | /// This class provides access to MUON digits in raw data. |
23 | /// | |
24 | /// It loops over all MUON digits in the raw data given by the AliRawReader. | |
25 | /// The Next method goes to the next digit. If there are no digits left | |
26 | /// it returns kFALSE (under develpment) | |
313a427d | 27 | /// It can loop also over DDL and store the decoded rawdata in TClonesArray |
28 | /// in Payload class. | |
c0751163 | 29 | /// |
30 | /// First version implement for Tracker | |
31 | /// | |
c4ee792d | 32 | /// \author Christian Finck |
c0751163 | 33 | /////////////////////////////////////////////////////////////////////////////// |
34 | ||
35 | #include "AliMUONRawStreamTracker.h" | |
36 | ||
37 | #include "AliRawReader.h" | |
38 | #include "AliRawDataHeader.h" | |
9e378ff4 | 39 | #include "AliDAQ.h" |
c0751163 | 40 | #include "AliLog.h" |
33434f31 | 41 | #include "AliMUONPayloadTracker.h" |
42 | #include "AliMUONBlockHeader.h" | |
43 | #include "AliMUONDspHeader.h" | |
44 | #include "AliMUONBusStruct.h" | |
45 | #include "AliMUONDDLTracker.h" | |
46 | #include "Riostream.h" | |
c0751163 | 47 | |
00e86732 | 48 | /// \cond CLASSIMP |
c0751163 | 49 | ClassImp(AliMUONRawStreamTracker) |
00e86732 | 50 | /// \endcond |
c0751163 | 51 | |
52 | AliMUONRawStreamTracker::AliMUONRawStreamTracker() | |
33434f31 | 53 | : TObject(), |
54 | fRawReader(0x0), | |
55 | fDDL(0), | |
56 | fMaxDDL(20), | |
57 | fPayload(new AliMUONPayloadTracker()), | |
58 | fCurrentDDL(0), | |
59 | fCurrentDDLIndex(fMaxDDL), | |
60 | fCurrentBlockHeader(0), | |
61 | fCurrentBlockHeaderIndex(0), | |
62 | fCurrentDspHeader(0), | |
63 | fCurrentDspHeaderIndex(0), | |
64 | fCurrentBusStruct(0), | |
65 | fCurrentBusStructIndex(0), | |
66 | fCurrentDataIndex(0) | |
c0751163 | 67 | { |
00e86732 | 68 | /// |
69 | /// create an object to read MUON raw digits | |
70 | /// Default ctor for monitoring purposes | |
71 | /// | |
33434f31 | 72 | |
73 | ||
c0751163 | 74 | } |
75 | ||
76 | //_________________________________________________________________ | |
77 | AliMUONRawStreamTracker::AliMUONRawStreamTracker(AliRawReader* rawReader) | |
33434f31 | 78 | : TObject(), |
79 | fRawReader(rawReader), | |
80 | fDDL(0), | |
81 | fMaxDDL(20), | |
82 | fPayload(new AliMUONPayloadTracker()), | |
83 | fCurrentDDL(0L), | |
84 | fCurrentDDLIndex(fMaxDDL), | |
85 | fCurrentBlockHeader(0), | |
86 | fCurrentBlockHeaderIndex(0), | |
87 | fCurrentDspHeader(0), | |
88 | fCurrentDspHeaderIndex(0), | |
89 | fCurrentBusStruct(0), | |
90 | fCurrentBusStructIndex(0), | |
91 | fCurrentDataIndex(0) | |
c0751163 | 92 | { |
00e86732 | 93 | /// |
94 | /// ctor with AliRawReader as argument | |
95 | /// for reconstruction purpose | |
96 | /// | |
33434f31 | 97 | |
98 | ||
c0751163 | 99 | } |
100 | ||
c0751163 | 101 | //___________________________________ |
102 | AliMUONRawStreamTracker::~AliMUONRawStreamTracker() | |
103 | { | |
00e86732 | 104 | /// |
105 | /// clean up | |
106 | /// | |
313a427d | 107 | delete fPayload; |
c0751163 | 108 | } |
109 | ||
110 | //_____________________________________________________________ | |
33434f31 | 111 | Bool_t |
112 | AliMUONRawStreamTracker::Next(Int_t& busPatchId, | |
113 | UShort_t& manuId, UChar_t& manuChannel, | |
114 | UShort_t& adc) | |
c0751163 | 115 | { |
00e86732 | 116 | /// |
117 | /// read the next raw digit (buspatch structure) | |
118 | /// returns kFALSE if there is no digit left | |
33434f31 | 119 | /// |
120 | ||
121 | if ( IsDone() ) return kFALSE; | |
122 | ||
123 | if ( fCurrentDataIndex >= fCurrentBusStruct->GetLength()-1 ) | |
124 | { | |
125 | Bool_t ok = GetNextBusStruct(); | |
126 | if (!ok) | |
127 | { | |
128 | // this is the end | |
129 | return kFALSE; | |
130 | } | |
131 | } | |
132 | ||
133 | ++fCurrentDataIndex; | |
134 | ||
135 | busPatchId = fCurrentBusStruct->GetBusPatchId(); | |
136 | manuId = fCurrentBusStruct->GetManuId(fCurrentDataIndex); | |
137 | manuChannel = fCurrentBusStruct->GetChannelId(fCurrentDataIndex); | |
138 | adc = fCurrentBusStruct->GetCharge(fCurrentDataIndex); | |
139 | ||
140 | return kTRUE; | |
c0751163 | 141 | } |
142 | ||
143 | //______________________________________________________ | |
33434f31 | 144 | Bool_t |
145 | AliMUONRawStreamTracker::IsDone() const | |
c0751163 | 146 | { |
33434f31 | 147 | /// Whether the iteration is finished or not |
148 | return (fCurrentBusStruct==0); | |
149 | } | |
c0751163 | 150 | |
33434f31 | 151 | //______________________________________________________ |
152 | void | |
153 | AliMUONRawStreamTracker::First() | |
154 | { | |
155 | /// Initialize the iteration process | |
156 | ||
157 | fCurrentDDLIndex = -1; | |
158 | fCurrentDspHeaderIndex = -1; | |
159 | fCurrentBusStructIndex = -1; | |
160 | ||
161 | fCurrentDspHeader = 0; | |
162 | fCurrentBusStruct = 0; | |
163 | ||
164 | // Find the first non-empty structure | |
165 | GetNextDDL(); | |
166 | GetNextBlockHeader(); | |
167 | GetNextDspHeader(); | |
168 | GetNextBusStruct(); | |
169 | } | |
c0751163 | 170 | |
33434f31 | 171 | //______________________________________________________ |
172 | Bool_t | |
173 | AliMUONRawStreamTracker::GetNextDDL() | |
174 | { | |
175 | /// Returns the next DDL present | |
176 | ||
177 | Bool_t kFound(kFALSE); | |
178 | ||
179 | while ( fCurrentDDLIndex < fMaxDDL-1 && !kFound ) | |
180 | { | |
181 | ++fCurrentDDLIndex; | |
182 | fRawReader->Reset(); | |
183 | fRawReader->Select("MUONTRK",fCurrentDDLIndex,fCurrentDDLIndex); | |
184 | if ( fRawReader->ReadHeader() ) | |
185 | { | |
186 | kFound = kTRUE; | |
187 | } | |
188 | } | |
189 | ||
190 | if ( !kFound ) | |
191 | { | |
192 | fCurrentDDLIndex = fMaxDDL; | |
c0751163 | 193 | return kFALSE; |
194 | } | |
33434f31 | 195 | |
313a427d | 196 | Int_t totalDataWord = fRawReader->GetDataSize(); // in bytes |
33434f31 | 197 | |
198 | AliDebug(3, Form("DDL Number %d totalDataWord %d\n", fCurrentDDLIndex, | |
199 | totalDataWord)); | |
200 | ||
313a427d | 201 | UInt_t *buffer = new UInt_t[totalDataWord/4]; |
33434f31 | 202 | |
203 | if ( !fRawReader->ReadNext((UChar_t*)buffer, totalDataWord) ) | |
204 | { | |
205 | fCurrentDDL = 0; | |
206 | return kFALSE; | |
207 | } | |
208 | fPayload->ResetDDL(); | |
209 | ||
210 | Bool_t ok = fPayload->Decode(buffer, totalDataWord/4); | |
211 | ||
212 | delete[] buffer; | |
213 | ||
214 | fCurrentDDL = fPayload->GetDDLTracker(); | |
215 | ||
216 | fCurrentBlockHeaderIndex = -1; | |
217 | ||
218 | return ok; | |
219 | } | |
c0751163 | 220 | |
33434f31 | 221 | //______________________________________________________ |
222 | Bool_t | |
223 | AliMUONRawStreamTracker::GetNextBlockHeader() | |
224 | { | |
225 | /// Returns the next block Header present | |
c0751163 | 226 | |
33434f31 | 227 | fCurrentBlockHeader = 0; |
c0751163 | 228 | |
33434f31 | 229 | Int_t i(fCurrentBlockHeaderIndex); |
230 | ||
231 | while ( fCurrentBlockHeader == 0 && i < fCurrentDDL->GetBlkHeaderEntries()-1 ) | |
232 | { | |
233 | ++i; | |
234 | fCurrentBlockHeader = fCurrentDDL->GetBlkHeaderEntry(i); | |
235 | } | |
236 | ||
237 | if ( !fCurrentBlockHeader ) | |
238 | { | |
239 | Bool_t ok = GetNextDDL(); | |
240 | if (!ok) | |
241 | { | |
242 | return kFALSE; | |
243 | } | |
244 | else | |
245 | { | |
246 | return GetNextBlockHeader(); | |
247 | } | |
248 | } | |
249 | ||
250 | fCurrentBlockHeaderIndex = i; | |
251 | ||
252 | fCurrentDspHeaderIndex = -1; | |
253 | ||
254 | return kTRUE; | |
255 | } | |
c0751163 | 256 | |
33434f31 | 257 | //______________________________________________________ |
258 | Bool_t | |
259 | AliMUONRawStreamTracker::GetNextDspHeader() | |
260 | { | |
261 | /// Returns the next Dsp Header present | |
262 | ||
263 | fCurrentDspHeader = 0; | |
264 | ||
265 | Int_t i(fCurrentDspHeaderIndex); | |
266 | ||
267 | while ( fCurrentDspHeader == 0 && i < fCurrentBlockHeader->GetDspHeaderEntries()-1 ) | |
268 | { | |
269 | ++i; | |
270 | fCurrentDspHeader = fCurrentBlockHeader->GetDspHeaderEntry(i); | |
271 | } | |
272 | ||
273 | if ( !fCurrentDspHeader ) | |
274 | { | |
275 | Bool_t ok = GetNextBlockHeader(); | |
276 | if (!ok) | |
277 | { | |
278 | return kFALSE; | |
279 | } | |
280 | else | |
281 | { | |
282 | return GetNextDspHeader(); | |
283 | } | |
284 | } | |
285 | ||
286 | fCurrentDspHeaderIndex = i; | |
287 | ||
288 | fCurrentBusStructIndex = -1; | |
289 | ||
290 | return kTRUE; | |
291 | } | |
c0751163 | 292 | |
33434f31 | 293 | //______________________________________________________ |
294 | Bool_t | |
295 | AliMUONRawStreamTracker::GetNextBusStruct() | |
296 | { | |
297 | /// Find the next non-empty busPatch structure | |
298 | ||
299 | fCurrentBusStruct = 0; | |
300 | ||
301 | Int_t i(fCurrentBusStructIndex); | |
302 | ||
303 | while ( fCurrentBusStruct == 0 && i < fCurrentDspHeader->GetBusPatchEntries()-1 ) | |
304 | { | |
305 | ++i; | |
306 | fCurrentBusStruct = fCurrentDspHeader->GetBusPatchEntry(i); | |
307 | } | |
308 | ||
309 | if ( !fCurrentBusStruct ) | |
310 | { | |
311 | Bool_t ok = GetNextDspHeader(); | |
312 | if (!ok) | |
313 | { | |
314 | return kFALSE; | |
315 | } | |
316 | else | |
317 | { | |
318 | return GetNextBusStruct(); | |
319 | } | |
320 | } | |
321 | ||
322 | fCurrentBusStructIndex = i; | |
323 | ||
324 | fCurrentDataIndex = -1; | |
325 | ||
c0751163 | 326 | return kTRUE; |
327 | } | |
c0751163 | 328 | |
33434f31 | 329 | //______________________________________________________ |
330 | Bool_t AliMUONRawStreamTracker::NextDDL() | |
331 | { | |
332 | /// reading tracker DDL | |
333 | ||
334 | fPayload->ResetDDL(); | |
335 | ||
336 | while ( fDDL < 20 ) | |
337 | { | |
338 | fRawReader->Reset(); | |
339 | fRawReader->Select("MUONTRK", fDDL, fDDL); //Select the DDL file to be read | |
340 | if (fRawReader->ReadHeader()) break; | |
341 | AliDebug(3,Form("Skipping DDL %d which does not seem to be there",fDDL)); | |
342 | ++fDDL; | |
343 | } | |
344 | ||
345 | if ( fDDL == 20 ) | |
346 | { | |
347 | fDDL = 0; | |
348 | return kFALSE; | |
349 | } | |
350 | ||
351 | AliDebug(3, Form("DDL Number %d\n", fDDL )); | |
352 | ||
353 | Int_t totalDataWord = fRawReader->GetDataSize(); // in bytes | |
354 | ||
355 | UInt_t *buffer = new UInt_t[totalDataWord/4]; | |
356 | ||
357 | if(!fRawReader->ReadNext((UChar_t*)buffer, totalDataWord)) | |
358 | { | |
359 | AliError("a memory leak is here"); | |
360 | return kFALSE; | |
361 | } | |
362 | ||
363 | Bool_t ok = fPayload->Decode(buffer, totalDataWord/4); | |
364 | ||
365 | delete[] buffer; | |
366 | ||
367 | fDDL++; | |
368 | ||
369 | return ok; | |
370 | } | |
371 | ||
c0751163 | 372 | //______________________________________________________ |
373 | void AliMUONRawStreamTracker::SetMaxDDL(Int_t ddl) | |
374 | { | |
00e86732 | 375 | /// set DDL number |
c0751163 | 376 | if (ddl > 20) ddl = 20; |
377 | fMaxDDL = ddl; | |
378 | } | |
379 | ||
380 | //______________________________________________________ | |
381 | void AliMUONRawStreamTracker::SetMaxBlock(Int_t blk) | |
382 | { | |
00e86732 | 383 | /// set regional card number |
313a427d | 384 | fPayload->SetMaxBlock(blk); |
c0751163 | 385 | } |