1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 /// \file MUONRawStreamTracker.C
20 /// \brief Macro for reading tracker raw data
22 /// \author Ch. Finck, Subatech Febuary
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>
28 /// This macro is interfaced with AliRawReader for RAW
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
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.
44 #if !defined(__CINT__) || defined(__MAKECINT__)
47 #include "AliRawReaderDate.h"
48 #include "AliRawReaderFile.h"
49 #include "AliRawReaderRoot.h"
52 #include "AliMUONRawStreamTracker.h"
53 #include "AliMUONRawStreamTrackerHP.h"
54 #include "AliMUONDspHeader.h"
55 #include "AliMUONBlockHeader.h"
56 #include "AliMUONBusStruct.h"
57 #include "AliMUONDDLTracker.h"
59 #include "TStopwatch.h"
63 void MUONRawStreamTrackerExpert(TString fileName = "./", Int_t maxEvent = 1000,
64 Int_t minDDL = 0, Int_t maxDDL = 19)
66 /// Reads the data from fileName, using an "expert" mode where all substructures
72 AliRawReader* rawReader = 0x0;
74 // check extention to choose the rawdata file format
75 if (fileName.EndsWith("/")) {
76 rawReader = new AliRawReaderFile(fileName); // DDL files
77 } else if (fileName.EndsWith(".root")) {
78 rawReader = new AliRawReaderRoot(fileName);
79 } else if (!fileName.IsNull()) {
80 rawReader = new AliRawReaderDate(fileName); // DATE file
84 AliMUONRawStreamTracker* rawStream = new AliMUONRawStreamTracker(rawReader);
86 // set the number of DDL block Dsp & buspatch structures that are PRESENT in the rawdata file
87 // it's NOT the number to be read.
88 // default wise set to 20, 2, 5 ans 5 respectively.
89 // rawStream->SetMaxDDL(xx);
90 // rawStream->SetMaxBlock(xx);
91 // rawStream->SetMaxDsp(xx);
92 // rawStream->SetMaxBus(xx);
95 AliMUONDDLTracker* ddlTracker = 0x0;
96 AliMUONBlockHeader* blkHeader = 0x0;
97 AliMUONDspHeader* dspHeader = 0x0;
98 AliMUONBusStruct* busStruct = 0x0;
104 while (rawReader->NextEvent()) {
106 if (iEvent == maxEvent)
109 printf("Event %d\n",iEvent++);
111 // read DDL while < 20 DDL
112 while(rawStream->NextDDL()) {
114 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
117 printf("\niDDL %d\n", rawStream->GetDDL());
119 ddlTracker = rawStream->GetDDLTracker();
121 // loop over block structure
122 Int_t nBlock = ddlTracker->GetBlkHeaderEntries();
123 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
125 blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock);
126 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
128 // loop over DSP structure
129 Int_t nDsp = blkHeader->GetDspHeaderEntries();
130 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
132 dspHeader = blkHeader->GetDspHeaderEntry(iDsp);
133 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
135 // loop over BusPatch structure
136 Int_t nBusPatch = dspHeader->GetBusPatchEntries();
137 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
139 busStruct = dspHeader->GetBusPatchEntry(iBusPatch);
141 // printf("busPatchId %d", busStruct->GetBusPatchId());
142 // printf(" BlockId %d", busStruct->GetBlockId());
143 // printf(" DspId %d\n", busStruct->GetDspId());
146 dataSize = busStruct->GetLength();
147 for (Int_t iData = 0; iData < dataSize; iData++) {
149 Int_t manuId = busStruct->GetManuId(iData);
150 Int_t channelId = busStruct->GetChannelId(iData);
151 Int_t charge = busStruct->GetCharge(iData);
152 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
153 busStruct->GetBusPatchId(),
169 void MUONRawStreamTrackerHPExpert(TString fileName = "./", Int_t maxEvent = 1000,
170 Int_t minDDL = 0, Int_t maxDDL = 19)
172 /// This routine shows how to use the high performance decoder's expert interface.
177 AliRawReader* rawReader = 0x0;
179 // check extention to choose the rawdata file format
180 if (fileName.EndsWith("/")) {
181 rawReader = new AliRawReaderFile(fileName); // DDL files
182 } else if (fileName.EndsWith(".root")) {
183 rawReader = new AliRawReaderRoot(fileName);
184 } else if (!fileName.IsNull()) {
185 rawReader = new AliRawReaderDate(fileName); // DATE file
189 AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader);
191 // light weight interfaces to headers
192 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
193 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
194 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
200 while (rawReader->NextEvent()) {
202 if (iEvent == maxEvent)
205 printf("Event %d\n",iEvent++);
207 // read DDL while < 20 DDL
208 while(rawStream->NextDDL()) {
210 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
213 printf("\niDDL %d\n", rawStream->GetDDL());
215 // loop over block structure
216 Int_t nBlock = rawStream->GetBlockCount();
217 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
219 blkHeader = rawStream->GetBlockHeader(iBlock);
220 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
222 // loop over DSP structure
223 Int_t nDsp = rawStream->GetDspCount(iBlock);
224 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
226 dspHeader = blkHeader->GetDspHeader(iDsp);
227 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
229 // loop over BusPatch structure
230 Int_t nBusPatch = rawStream->GetBusPatchCount(iBlock, iDsp);
231 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
233 busStruct = dspHeader->GetBusPatch(iBusPatch);
236 dataSize = busStruct->GetLength();
237 for (Int_t iData = 0; iData < dataSize; iData++) {
239 Int_t manuId = busStruct->GetManuId(iData);
240 Int_t channelId = busStruct->GetChannelId(iData);
241 Int_t charge = busStruct->GetCharge(iData);
242 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
243 busStruct->GetBusPatchId(),
259 void MUONRawStreamTrackerHPExpert2(TString fileName = "./", Int_t maxEvent = 1000,
260 Int_t minDDL = 0, Int_t maxDDL = 19)
262 /// This routine shows an alternate way to iterate over the DDL structures
263 /// compared to MUONRawStreamTrackerHPExpert().
268 AliRawReader* rawReader = 0x0;
270 // check extention to choose the rawdata file format
271 if (fileName.EndsWith("/")) {
272 rawReader = new AliRawReaderFile(fileName); // DDL files
273 } else if (fileName.EndsWith(".root")) {
274 rawReader = new AliRawReaderRoot(fileName);
275 } else if (!fileName.IsNull()) {
276 rawReader = new AliRawReaderDate(fileName); // DATE file
280 AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader);
282 // light weight interfaces to headers
283 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
284 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
285 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
291 while (rawReader->NextEvent()) {
293 if (iEvent == maxEvent)
296 printf("Event %d\n",iEvent++);
298 // read DDL while < 20 DDL
299 while(rawStream->NextDDL()) {
301 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
304 printf("\niDDL %d\n", rawStream->GetDDL());
306 // loop over block structure
307 Int_t nBlock = rawStream->GetBlockCount();
308 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
310 blkHeader = rawStream->GetBlockHeader(iBlock);
311 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
313 // loop over DSP structure
314 Int_t nDsp = rawStream->GetDspCount(iBlock);
315 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
317 dspHeader = rawStream->GetDspHeader(iBlock, iDsp);
318 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
320 // loop over BusPatch structure
321 Int_t nBusPatch = rawStream->GetBusPatchCount(iBlock, iDsp);
322 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
324 busStruct = rawStream->GetBusPatch(iBlock, iDsp, iBusPatch);
327 dataSize = busStruct->GetLength();
328 for (Int_t iData = 0; iData < dataSize; iData++) {
330 Int_t manuId = busStruct->GetManuId(iData);
331 Int_t channelId = busStruct->GetChannelId(iData);
332 Int_t charge = busStruct->GetCharge(iData);
333 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
334 busStruct->GetBusPatchId(),
350 void MUONRawStreamTrackerHPExpert3(TString fileName = "./", Int_t maxEvent = 1000,
351 Int_t minDDL = 0, Int_t maxDDL = 19)
353 /// This routine shows yet another alternate way to iterate over the DDL
354 /// structures compared to MUONRawStreamTrackerHPExpert().
359 AliRawReader* rawReader = 0x0;
361 // check extention to choose the rawdata file format
362 if (fileName.EndsWith("/")) {
363 rawReader = new AliRawReaderFile(fileName); // DDL files
364 } else if (fileName.EndsWith(".root")) {
365 rawReader = new AliRawReaderRoot(fileName);
366 } else if (!fileName.IsNull()) {
367 rawReader = new AliRawReaderDate(fileName); // DATE file
371 AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader);
373 // light weight interfaces to headers
374 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
375 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
376 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
382 while (rawReader->NextEvent()) {
384 if (iEvent == maxEvent)
387 printf("Event %d\n",iEvent++);
389 // read DDL while < 20 DDL
390 while(rawStream->NextDDL()) {
392 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
395 printf("\niDDL %d\n", rawStream->GetDDL());
397 // loop over block structure
399 blkHeader = rawStream->GetFirstBlockHeader();
400 while (blkHeader != NULL)
402 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
404 // loop over DSP structure
406 dspHeader = blkHeader->GetFirstDspHeader();
407 while (dspHeader != NULL)
409 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
411 // loop over BusPatch structure
413 busStruct = dspHeader->GetFirstBusPatch();
414 while (busStruct != NULL)
417 dataSize = busStruct->GetLength();
418 for (Int_t iData = 0; iData < dataSize; iData++) {
420 Int_t manuId = busStruct->GetManuId(iData);
421 Int_t channelId = busStruct->GetChannelId(iData);
422 Int_t charge = busStruct->GetCharge(iData);
423 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
424 busStruct->GetBusPatchId(),
428 busStruct = busStruct->Next();
431 dspHeader = dspHeader->Next();
434 blkHeader = blkHeader->Next();
446 void MUONRawStreamTrackerSimple(TString fileName = "./", Int_t maxEvent = 1000)
448 /// Reads the raw data in fileName, using a simplified interface (iterator
453 AliRawReader* rawReader = 0x0;
455 // check extention to choose the rawdata file format
456 if (fileName.EndsWith("/")) {
457 rawReader = new AliRawReaderFile(fileName); // DDL files
458 } else if (fileName.EndsWith(".root")) {
459 rawReader = new AliRawReaderRoot(fileName);
460 } else if (!fileName.IsNull()) {
461 rawReader = new AliRawReaderDate(fileName); // DATE file
465 AliMUONRawStreamTracker* rawStream = new AliMUONRawStreamTracker(rawReader);
470 while (rawReader->NextEvent()) {
472 if (iEvent == maxEvent)
475 printf("Event %d\n",iEvent++);
478 UShort_t manuId, adc;
483 while ( rawStream->Next(busPatch,manuId,manuChannel,adc) )
485 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
486 busPatch,manuId,manuChannel, adc);
496 void MUONRawStreamTrackerHPSimple(TString fileName = "./", Int_t maxEvent = 1000)
498 /// This routine shows how to use the high performance decoder's simple interface.
503 AliRawReader* rawReader = 0x0;
505 // check extention to choose the rawdata file format
506 if (fileName.EndsWith("/")) {
507 rawReader = new AliRawReaderFile(fileName); // DDL files
508 } else if (fileName.EndsWith(".root")) {
509 rawReader = new AliRawReaderRoot(fileName);
510 } else if (!fileName.IsNull()) {
511 rawReader = new AliRawReaderDate(fileName); // DATE file
515 AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader);
520 while (rawReader->NextEvent()) {
522 if (iEvent == maxEvent)
525 printf("Event %d\n",iEvent++);
528 UShort_t manuId, adc;
533 while ( rawStream->Next(busPatch,manuId,manuChannel,adc) )
535 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
536 busPatch,manuId,manuChannel, adc);
546 void MUONRawStreamTrackerHPSimple2(TString fileName = "./", Int_t maxEvent = 1000)
548 /// This routine is an alternative to MUONRawStreamTrackerHPSimple() which is even faster.
553 AliRawReader* rawReader = 0x0;
555 // check extention to choose the rawdata file format
556 if (fileName.EndsWith("/")) {
557 rawReader = new AliRawReaderFile(fileName); // DDL files
558 } else if (fileName.EndsWith(".root")) {
559 rawReader = new AliRawReaderRoot(fileName);
560 } else if (!fileName.IsNull()) {
561 rawReader = new AliRawReaderDate(fileName); // DATE file
565 AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader);
570 while (rawReader->NextEvent()) {
572 if (iEvent == maxEvent)
575 printf("Event %d\n",iEvent++);
577 UShort_t manuId, adc;
581 const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL;
582 while ((buspatch = rawStream->Next()) != NULL)
584 for (UInt_t i = 0; i < buspatch->GetDataCount(); i++)
586 buspatch->GetData(i, manuId, manuChannel, adc);
587 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
588 buspatch->GetBusPatchId(), manuId, manuChannel, adc);