]>
Commit | Line | Data |
---|---|---|
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 | /// \ingroup macros | |
19 | /// \file MUONRawStreamTracker.C | |
20 | /// \brief Macro for reading tracker raw data | |
21 | /// | |
22 | /// \author Ch. Finck, Subatech Febuary | |
23 | /// | |
24 | /// Added example routines to show how to use the interface of the high | |
25 | /// performance decoder AliMUONRawStreamTrackerHP. | |
26 | /// by Artur Szostak <artursz@iafrica.com> | |
27 | /// | |
28 | /// This macro is interfaced with AliRawReader for RAW | |
29 | /// | |
30 | /// There are 2 ways of reading the data: | |
31 | /// - one where each intermediate structure (block, dsp, buspatch) is looped over | |
32 | /// - and one, using an iterator, where we're directly accessing the pad informations | |
33 | /// (charge). | |
34 | /// | |
35 | /// The different stucture of the payload are readout and stored in TClonesArray | |
36 | /// with AliMUONRawStreamTracker class. | |
37 | /// The macro just simply reads again the TClonesArray contents. | |
38 | /// The parameters of each structure could be seen in the container classes | |
39 | /// AliMUONBlockHeader, AliMUONBlockHeader, AliMUONBusStruct. | |
40 | /// The class AliMUONDDLTracker manages the structure containers. | |
41 | /// The number of structures in the rawdata file could be set. | |
42 | ||
43 | ||
44 | #if !defined(__CINT__) || defined(__MAKECINT__) | |
45 | ||
46 | // RAW includes | |
47 | #include "AliRawReader.h" | |
48 | ||
49 | // MUON includes | |
50 | #include "AliMUONRawStreamTracker.h" | |
51 | #include "AliMUONRawStreamTrackerHP.h" | |
52 | #include "AliMUONDspHeader.h" | |
53 | #include "AliMUONBlockHeader.h" | |
54 | #include "AliMUONBusStruct.h" | |
55 | #include "AliMUONDDLTracker.h" | |
56 | ||
57 | #include "TStopwatch.h" | |
58 | ||
59 | #endif | |
60 | ||
61 | void MUONRawStreamTrackerExpert(TString fileName = "./", Int_t maxEvent = 1000, | |
62 | Int_t minDDL = 0, Int_t maxDDL = 19) | |
63 | { | |
64 | /// Reads the data from fileName, using an "expert" mode where all substructures | |
65 | /// are looped upon. | |
66 | ||
67 | TStopwatch timer; | |
68 | timer.Start(kTRUE); | |
69 | ||
70 | AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); | |
71 | ||
72 | // raw stream | |
73 | AliMUONRawStreamTracker* rawStream = new AliMUONRawStreamTracker(rawReader); | |
74 | ||
75 | // set the number of DDL block Dsp & buspatch structures that are PRESENT in the rawdata file | |
76 | // it's NOT the number to be read. | |
77 | // default wise set to 20, 2, 5 ans 5 respectively. | |
78 | // rawStream->SetMaxDDL(xx); | |
79 | // rawStream->SetMaxBlock(xx); | |
80 | // rawStream->SetMaxDsp(xx); | |
81 | // rawStream->SetMaxBus(xx); | |
82 | ||
83 | // containers | |
84 | AliMUONDDLTracker* ddlTracker = 0x0; | |
85 | AliMUONBlockHeader* blkHeader = 0x0; | |
86 | AliMUONDspHeader* dspHeader = 0x0; | |
87 | AliMUONBusStruct* busStruct = 0x0; | |
88 | ||
89 | // Loop over events | |
90 | Int_t iEvent = 0; | |
91 | Int_t dataSize; | |
92 | ||
93 | while (rawReader->NextEvent()) { | |
94 | ||
95 | if (iEvent == maxEvent) | |
96 | break; | |
97 | ||
98 | printf("Event %d\n",iEvent++); | |
99 | ||
100 | // read DDL while < 20 DDL | |
101 | while(rawStream->NextDDL()) { | |
102 | ||
103 | if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL) | |
104 | continue; | |
105 | ||
106 | printf("\niDDL %d\n", rawStream->GetDDL()); | |
107 | ||
108 | ddlTracker = rawStream->GetDDLTracker(); | |
109 | ||
110 | // loop over block structure | |
111 | Int_t nBlock = ddlTracker->GetBlkHeaderEntries(); | |
112 | for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){ | |
113 | ||
114 | blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock); | |
115 | printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength()); | |
116 | ||
117 | // loop over DSP structure | |
118 | Int_t nDsp = blkHeader->GetDspHeaderEntries(); | |
119 | for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop | |
120 | ||
121 | dspHeader = blkHeader->GetDspHeaderEntry(iDsp); | |
122 | printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord()); | |
123 | ||
124 | // loop over BusPatch structure | |
125 | Int_t nBusPatch = dspHeader->GetBusPatchEntries(); | |
126 | for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) { | |
127 | ||
128 | busStruct = dspHeader->GetBusPatchEntry(iBusPatch); | |
129 | ||
130 | // printf("busPatchId %d", busStruct->GetBusPatchId()); | |
131 | // printf(" BlockId %d", busStruct->GetBlockId()); | |
132 | // printf(" DspId %d\n", busStruct->GetDspId()); | |
133 | ||
134 | // loop over data | |
135 | dataSize = busStruct->GetLength(); | |
136 | for (Int_t iData = 0; iData < dataSize; iData++) { | |
137 | ||
138 | Int_t manuId = busStruct->GetManuId(iData); | |
139 | Int_t channelId = busStruct->GetChannelId(iData); | |
140 | Int_t charge = busStruct->GetCharge(iData); | |
141 | printf("buspatch %5d manuI %4d channel %3d charge %4d\n", | |
142 | busStruct->GetBusPatchId(), | |
143 | manuId, | |
144 | channelId, charge); | |
145 | } // iData | |
146 | } // iBusPatch | |
147 | } // iDsp | |
148 | } // iBlock | |
149 | } // NextDDL | |
150 | }// NextEvent | |
151 | ||
152 | delete rawReader; | |
153 | delete rawStream; | |
154 | timer.Print(); | |
155 | } | |
156 | ||
157 | ||
158 | void MUONRawStreamTrackerHPExpert(TString fileName = "./", Int_t maxEvent = 1000, | |
159 | Int_t minDDL = 0, Int_t maxDDL = 19) | |
160 | { | |
161 | /// This routine shows how to use the high performance decoder's expert interface. | |
162 | ||
163 | TStopwatch timer; | |
164 | timer.Start(kTRUE); | |
165 | ||
166 | AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); | |
167 | ||
168 | // raw stream | |
169 | AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader); | |
170 | ||
171 | // light weight interfaces to headers | |
172 | const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0; | |
173 | const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0; | |
174 | const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0; | |
175 | ||
176 | // Loop over events | |
177 | Int_t iEvent = 0; | |
178 | Int_t dataSize; | |
179 | ||
180 | while (rawReader->NextEvent()) { | |
181 | ||
182 | if (iEvent == maxEvent) | |
183 | break; | |
184 | ||
185 | printf("Event %d\n",iEvent++); | |
186 | ||
187 | // read DDL while < 20 DDL | |
188 | while(rawStream->NextDDL()) { | |
189 | ||
190 | if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL) | |
191 | continue; | |
192 | ||
193 | printf("\niDDL %d\n", rawStream->GetDDL()); | |
194 | ||
195 | // loop over block structure | |
196 | Int_t nBlock = rawStream->GetBlockCount(); | |
197 | for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){ | |
198 | ||
199 | blkHeader = rawStream->GetBlockHeader(iBlock); | |
200 | printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength()); | |
201 | ||
202 | // loop over DSP structure | |
203 | Int_t nDsp = rawStream->GetDspCount(iBlock); | |
204 | for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop | |
205 | ||
206 | dspHeader = blkHeader->GetDspHeader(iDsp); | |
207 | printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord()); | |
208 | ||
209 | // loop over BusPatch structure | |
210 | Int_t nBusPatch = rawStream->GetBusPatchCount(iBlock, iDsp); | |
211 | for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) { | |
212 | ||
213 | busStruct = dspHeader->GetBusPatch(iBusPatch); | |
214 | ||
215 | // loop over data | |
216 | dataSize = busStruct->GetLength(); | |
217 | for (Int_t iData = 0; iData < dataSize; iData++) { | |
218 | ||
219 | Int_t manuId = busStruct->GetManuId(iData); | |
220 | Int_t channelId = busStruct->GetChannelId(iData); | |
221 | Int_t charge = busStruct->GetCharge(iData); | |
222 | printf("buspatch %5d manuI %4d channel %3d charge %4d\n", | |
223 | busStruct->GetBusPatchId(), | |
224 | manuId, | |
225 | channelId, charge); | |
226 | } // iData | |
227 | } // iBusPatch | |
228 | } // iDsp | |
229 | } // iBlock | |
230 | } // NextDDL | |
231 | }// NextEvent | |
232 | ||
233 | delete rawReader; | |
234 | delete rawStream; | |
235 | timer.Print(); | |
236 | } | |
237 | ||
238 | ||
239 | void MUONRawStreamTrackerHPExpert2(TString fileName = "./", Int_t maxEvent = 1000, | |
240 | Int_t minDDL = 0, Int_t maxDDL = 19) | |
241 | { | |
242 | /// This routine shows an alternate way to iterate over the DDL structures | |
243 | /// compared to MUONRawStreamTrackerHPExpert(). | |
244 | ||
245 | TStopwatch timer; | |
246 | timer.Start(kTRUE); | |
247 | ||
248 | AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); | |
249 | ||
250 | // raw stream | |
251 | AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader); | |
252 | ||
253 | // light weight interfaces to headers | |
254 | const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0; | |
255 | const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0; | |
256 | const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0; | |
257 | ||
258 | // Loop over events | |
259 | Int_t iEvent = 0; | |
260 | Int_t dataSize; | |
261 | ||
262 | while (rawReader->NextEvent()) { | |
263 | ||
264 | if (iEvent == maxEvent) | |
265 | break; | |
266 | ||
267 | printf("Event %d\n",iEvent++); | |
268 | ||
269 | // read DDL while < 20 DDL | |
270 | while(rawStream->NextDDL()) { | |
271 | ||
272 | if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL) | |
273 | continue; | |
274 | ||
275 | printf("\niDDL %d\n", rawStream->GetDDL()); | |
276 | ||
277 | // loop over block structure | |
278 | Int_t nBlock = rawStream->GetBlockCount(); | |
279 | for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){ | |
280 | ||
281 | blkHeader = rawStream->GetBlockHeader(iBlock); | |
282 | printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength()); | |
283 | ||
284 | // loop over DSP structure | |
285 | Int_t nDsp = rawStream->GetDspCount(iBlock); | |
286 | for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop | |
287 | ||
288 | dspHeader = rawStream->GetDspHeader(iBlock, iDsp); | |
289 | printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord()); | |
290 | ||
291 | // loop over BusPatch structure | |
292 | Int_t nBusPatch = rawStream->GetBusPatchCount(iBlock, iDsp); | |
293 | for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) { | |
294 | ||
295 | busStruct = rawStream->GetBusPatch(iBlock, iDsp, iBusPatch); | |
296 | ||
297 | // loop over data | |
298 | dataSize = busStruct->GetLength(); | |
299 | for (Int_t iData = 0; iData < dataSize; iData++) { | |
300 | ||
301 | Int_t manuId = busStruct->GetManuId(iData); | |
302 | Int_t channelId = busStruct->GetChannelId(iData); | |
303 | Int_t charge = busStruct->GetCharge(iData); | |
304 | printf("buspatch %5d manuI %4d channel %3d charge %4d\n", | |
305 | busStruct->GetBusPatchId(), | |
306 | manuId, | |
307 | channelId, charge); | |
308 | } // iData | |
309 | } // iBusPatch | |
310 | } // iDsp | |
311 | } // iBlock | |
312 | } // NextDDL | |
313 | }// NextEvent | |
314 | ||
315 | delete rawReader; | |
316 | delete rawStream; | |
317 | timer.Print(); | |
318 | } | |
319 | ||
320 | ||
321 | void MUONRawStreamTrackerHPExpert3(TString fileName = "./", Int_t maxEvent = 1000, | |
322 | Int_t minDDL = 0, Int_t maxDDL = 19) | |
323 | { | |
324 | /// This routine shows yet another alternate way to iterate over the DDL | |
325 | /// structures compared to MUONRawStreamTrackerHPExpert(). | |
326 | ||
327 | TStopwatch timer; | |
328 | timer.Start(kTRUE); | |
329 | ||
330 | AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); | |
331 | ||
332 | // raw stream | |
333 | AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader); | |
334 | ||
335 | // light weight interfaces to headers | |
336 | const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0; | |
337 | const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0; | |
338 | const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0; | |
339 | ||
340 | // Loop over events | |
341 | Int_t iEvent = 0; | |
342 | Int_t dataSize; | |
343 | ||
344 | while (rawReader->NextEvent()) { | |
345 | ||
346 | if (iEvent == maxEvent) | |
347 | break; | |
348 | ||
349 | printf("Event %d\n",iEvent++); | |
350 | ||
351 | // read DDL while < 20 DDL | |
352 | while(rawStream->NextDDL()) { | |
353 | ||
354 | if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL) | |
355 | continue; | |
356 | ||
357 | printf("\niDDL %d\n", rawStream->GetDDL()); | |
358 | ||
359 | // loop over block structure | |
360 | Int_t iBlock = 0; | |
361 | blkHeader = rawStream->GetFirstBlockHeader(); | |
362 | while (blkHeader != NULL) | |
363 | { | |
364 | printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength()); | |
365 | ||
366 | // loop over DSP structure | |
367 | Int_t iDsp = 0; | |
368 | dspHeader = blkHeader->GetFirstDspHeader(); | |
369 | while (dspHeader != NULL) | |
370 | { | |
371 | printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord()); | |
372 | ||
373 | // loop over BusPatch structure | |
374 | Int_t iBusPatch = 0; | |
375 | busStruct = dspHeader->GetFirstBusPatch(); | |
376 | while (busStruct != NULL) | |
377 | { | |
378 | // loop over data | |
379 | dataSize = busStruct->GetLength(); | |
380 | for (Int_t iData = 0; iData < dataSize; iData++) { | |
381 | ||
382 | Int_t manuId = busStruct->GetManuId(iData); | |
383 | Int_t channelId = busStruct->GetChannelId(iData); | |
384 | Int_t charge = busStruct->GetCharge(iData); | |
385 | printf("buspatch %5d manuI %4d channel %3d charge %4d\n", | |
386 | busStruct->GetBusPatchId(), | |
387 | manuId, | |
388 | channelId, charge); | |
389 | } // iData | |
390 | busStruct = busStruct->Next(); | |
391 | iBusPatch++; | |
392 | } // iBusPatch | |
393 | dspHeader = dspHeader->Next(); | |
394 | iDsp++; | |
395 | } // iDsp | |
396 | blkHeader = blkHeader->Next(); | |
397 | iBlock++; | |
398 | } // iBlock | |
399 | } // NextDDL | |
400 | }// NextEvent | |
401 | ||
402 | delete rawReader; | |
403 | delete rawStream; | |
404 | timer.Print(); | |
405 | } | |
406 | ||
407 | ||
408 | void MUONRawStreamTrackerSimple(TString fileName = "./", Int_t maxEvent = 1000) | |
409 | { | |
410 | /// Reads the raw data in fileName, using a simplified interface (iterator | |
411 | /// over pads). | |
412 | TStopwatch timer; | |
413 | timer.Start(kTRUE); | |
414 | ||
415 | AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); | |
416 | ||
417 | // raw stream | |
418 | AliMUONRawStreamTracker* rawStream = new AliMUONRawStreamTracker(rawReader); | |
419 | ||
420 | // Loop over events | |
421 | Int_t iEvent = 0; | |
422 | ||
423 | while (rawReader->NextEvent()) { | |
424 | ||
425 | if (iEvent == maxEvent) | |
426 | break; | |
427 | ||
428 | printf("Event %d\n",iEvent++); | |
429 | ||
430 | Int_t busPatch; | |
431 | UShort_t manuId, adc; | |
432 | UChar_t manuChannel; | |
433 | ||
434 | rawStream->First(); | |
435 | ||
436 | while ( rawStream->Next(busPatch,manuId,manuChannel,adc) ) | |
437 | { | |
438 | printf("buspatch %5d manuI %4d channel %3d charge %4d\n", | |
439 | busPatch,manuId,manuChannel, adc); | |
440 | } | |
441 | } | |
442 | ||
443 | delete rawReader; | |
444 | delete rawStream; | |
445 | timer.Print(); | |
446 | } | |
447 | ||
448 | ||
449 | void MUONRawStreamTrackerHPSimple(TString fileName = "./", Int_t maxEvent = 1000) | |
450 | { | |
451 | /// This routine shows how to use the high performance decoder's simple interface. | |
452 | ||
453 | TStopwatch timer; | |
454 | timer.Start(kTRUE); | |
455 | ||
456 | AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); | |
457 | ||
458 | // raw stream | |
459 | AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader); | |
460 | ||
461 | // Loop over events | |
462 | Int_t iEvent = 0; | |
463 | ||
464 | while (rawReader->NextEvent()) { | |
465 | ||
466 | if (iEvent == maxEvent) | |
467 | break; | |
468 | ||
469 | printf("Event %d\n",iEvent++); | |
470 | ||
471 | Int_t busPatch; | |
472 | UShort_t manuId, adc; | |
473 | UChar_t manuChannel; | |
474 | ||
475 | rawStream->First(); | |
476 | ||
477 | while ( rawStream->Next(busPatch,manuId,manuChannel,adc) ) | |
478 | { | |
479 | printf("buspatch %5d manuI %4d channel %3d charge %4d\n", | |
480 | busPatch,manuId,manuChannel, adc); | |
481 | } | |
482 | } | |
483 | ||
484 | delete rawReader; | |
485 | delete rawStream; | |
486 | timer.Print(); | |
487 | } | |
488 | ||
489 | ||
490 | void MUONRawStreamTrackerHPSimple2(TString fileName = "./", Int_t maxEvent = 1000) | |
491 | { | |
492 | /// This routine is an alternative to MUONRawStreamTrackerHPSimple() which is even faster. | |
493 | ||
494 | TStopwatch timer; | |
495 | timer.Start(kTRUE); | |
496 | ||
497 | AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); | |
498 | ||
499 | // raw stream | |
500 | AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader); | |
501 | ||
502 | // Loop over events | |
503 | Int_t iEvent = 0; | |
504 | ||
505 | while (rawReader->NextEvent()) { | |
506 | ||
507 | if (iEvent == maxEvent) | |
508 | break; | |
509 | ||
510 | printf("Event %d\n",iEvent++); | |
511 | ||
512 | UShort_t manuId, adc; | |
513 | UChar_t manuChannel; | |
514 | ||
515 | rawStream->First(); | |
516 | const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL; | |
517 | while ((buspatch = rawStream->Next()) != NULL) | |
518 | { | |
519 | for (UInt_t i = 0; i < buspatch->GetDataCount(); i++) | |
520 | { | |
521 | buspatch->GetData(i, manuId, manuChannel, adc); | |
522 | printf("buspatch %5d manuI %4d channel %3d charge %4d\n", | |
523 | buspatch->GetBusPatchId(), manuId, manuChannel, adc); | |
524 | } | |
525 | } | |
526 | } | |
527 | ||
528 | delete rawReader; | |
529 | delete rawStream; | |
530 | timer.Print(); | |
531 | } | |
532 |