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 "AliRawReader.h"
50 #include "AliMUONRawStreamTracker.h"
51 #include "AliMUONRawStreamTrackerHP.h"
52 #include "AliMUONDspHeader.h"
53 #include "AliMUONBlockHeader.h"
54 #include "AliMUONBusStruct.h"
55 #include "AliMUONDDLTracker.h"
57 #include "TStopwatch.h"
61 void MUONRawStreamTrackerExpert(TString fileName = "./", Int_t maxEvent = 1000,
62 Int_t minDDL = 0, Int_t maxDDL = 19)
64 /// Reads the data from fileName, using an "expert" mode where all substructures
70 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
73 AliMUONRawStreamTracker* rawStream = new AliMUONRawStreamTracker(rawReader);
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);
84 AliMUONDDLTracker* ddlTracker = 0x0;
85 AliMUONBlockHeader* blkHeader = 0x0;
86 AliMUONDspHeader* dspHeader = 0x0;
87 AliMUONBusStruct* busStruct = 0x0;
93 while (rawReader->NextEvent()) {
95 if (iEvent == maxEvent)
98 printf("Event %d\n",iEvent++);
100 // read DDL while < 20 DDL
101 while(rawStream->NextDDL()) {
103 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
106 printf("\niDDL %d\n", rawStream->GetDDL());
108 ddlTracker = rawStream->GetDDLTracker();
110 // loop over block structure
111 Int_t nBlock = ddlTracker->GetBlkHeaderEntries();
112 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
114 blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock);
115 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
117 // loop over DSP structure
118 Int_t nDsp = blkHeader->GetDspHeaderEntries();
119 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
121 dspHeader = blkHeader->GetDspHeaderEntry(iDsp);
122 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
124 // loop over BusPatch structure
125 Int_t nBusPatch = dspHeader->GetBusPatchEntries();
126 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
128 busStruct = dspHeader->GetBusPatchEntry(iBusPatch);
130 // printf("busPatchId %d", busStruct->GetBusPatchId());
131 // printf(" BlockId %d", busStruct->GetBlockId());
132 // printf(" DspId %d\n", busStruct->GetDspId());
135 dataSize = busStruct->GetLength();
136 for (Int_t iData = 0; iData < dataSize; iData++) {
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(),
158 void MUONRawStreamTrackerHPExpert(TString fileName = "./", Int_t maxEvent = 1000,
159 Int_t minDDL = 0, Int_t maxDDL = 19)
161 /// This routine shows how to use the high performance decoder's expert interface.
166 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
169 AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader);
171 // light weight interfaces to headers
172 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
173 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
174 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
180 while (rawReader->NextEvent()) {
182 if (iEvent == maxEvent)
185 printf("Event %d\n",iEvent++);
187 // read DDL while < 20 DDL
188 while(rawStream->NextDDL()) {
190 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
193 printf("\niDDL %d\n", rawStream->GetDDL());
195 // loop over block structure
196 Int_t nBlock = rawStream->GetBlockCount();
197 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
199 blkHeader = rawStream->GetBlockHeader(iBlock);
200 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
202 // loop over DSP structure
203 Int_t nDsp = rawStream->GetDspCount(iBlock);
204 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
206 dspHeader = blkHeader->GetDspHeader(iDsp);
207 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
209 // loop over BusPatch structure
210 Int_t nBusPatch = rawStream->GetBusPatchCount(iBlock, iDsp);
211 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
213 busStruct = dspHeader->GetBusPatch(iBusPatch);
216 dataSize = busStruct->GetLength();
217 for (Int_t iData = 0; iData < dataSize; iData++) {
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(),
239 void MUONRawStreamTrackerHPExpert2(TString fileName = "./", Int_t maxEvent = 1000,
240 Int_t minDDL = 0, Int_t maxDDL = 19)
242 /// This routine shows an alternate way to iterate over the DDL structures
243 /// compared to MUONRawStreamTrackerHPExpert().
248 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
251 AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader);
253 // light weight interfaces to headers
254 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
255 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
256 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
262 while (rawReader->NextEvent()) {
264 if (iEvent == maxEvent)
267 printf("Event %d\n",iEvent++);
269 // read DDL while < 20 DDL
270 while(rawStream->NextDDL()) {
272 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
275 printf("\niDDL %d\n", rawStream->GetDDL());
277 // loop over block structure
278 Int_t nBlock = rawStream->GetBlockCount();
279 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
281 blkHeader = rawStream->GetBlockHeader(iBlock);
282 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
284 // loop over DSP structure
285 Int_t nDsp = rawStream->GetDspCount(iBlock);
286 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
288 dspHeader = rawStream->GetDspHeader(iBlock, iDsp);
289 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
291 // loop over BusPatch structure
292 Int_t nBusPatch = rawStream->GetBusPatchCount(iBlock, iDsp);
293 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
295 busStruct = rawStream->GetBusPatch(iBlock, iDsp, iBusPatch);
298 dataSize = busStruct->GetLength();
299 for (Int_t iData = 0; iData < dataSize; iData++) {
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(),
321 void MUONRawStreamTrackerHPExpert3(TString fileName = "./", Int_t maxEvent = 1000,
322 Int_t minDDL = 0, Int_t maxDDL = 19)
324 /// This routine shows yet another alternate way to iterate over the DDL
325 /// structures compared to MUONRawStreamTrackerHPExpert().
330 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
333 AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader);
335 // light weight interfaces to headers
336 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
337 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
338 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
344 while (rawReader->NextEvent()) {
346 if (iEvent == maxEvent)
349 printf("Event %d\n",iEvent++);
351 // read DDL while < 20 DDL
352 while(rawStream->NextDDL()) {
354 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
357 printf("\niDDL %d\n", rawStream->GetDDL());
359 // loop over block structure
361 blkHeader = rawStream->GetFirstBlockHeader();
362 while (blkHeader != NULL)
364 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
366 // loop over DSP structure
368 dspHeader = blkHeader->GetFirstDspHeader();
369 while (dspHeader != NULL)
371 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
373 // loop over BusPatch structure
375 busStruct = dspHeader->GetFirstBusPatch();
376 while (busStruct != NULL)
379 dataSize = busStruct->GetLength();
380 for (Int_t iData = 0; iData < dataSize; iData++) {
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(),
390 busStruct = busStruct->Next();
393 dspHeader = dspHeader->Next();
396 blkHeader = blkHeader->Next();
408 void MUONRawStreamTrackerSimple(TString fileName = "./", Int_t maxEvent = 1000)
410 /// Reads the raw data in fileName, using a simplified interface (iterator
415 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
418 AliMUONRawStreamTracker* rawStream = new AliMUONRawStreamTracker(rawReader);
423 while (rawReader->NextEvent()) {
425 if (iEvent == maxEvent)
428 printf("Event %d\n",iEvent++);
431 UShort_t manuId, adc;
436 while ( rawStream->Next(busPatch,manuId,manuChannel,adc) )
438 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
439 busPatch,manuId,manuChannel, adc);
449 void MUONRawStreamTrackerHPSimple(TString fileName = "./", Int_t maxEvent = 1000)
451 /// This routine shows how to use the high performance decoder's simple interface.
456 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
459 AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader);
464 while (rawReader->NextEvent()) {
466 if (iEvent == maxEvent)
469 printf("Event %d\n",iEvent++);
472 UShort_t manuId, adc;
477 while ( rawStream->Next(busPatch,manuId,manuChannel,adc) )
479 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
480 busPatch,manuId,manuChannel, adc);
490 void MUONRawStreamTrackerHPSimple2(TString fileName = "./", Int_t maxEvent = 1000)
492 /// This routine is an alternative to MUONRawStreamTrackerHPSimple() which is even faster.
497 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
500 AliMUONRawStreamTrackerHP* rawStream = new AliMUONRawStreamTrackerHP(rawReader);
505 while (rawReader->NextEvent()) {
507 if (iEvent == maxEvent)
510 printf("Event %d\n",iEvent++);
512 UShort_t manuId, adc;
516 const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL;
517 while ((buspatch = rawStream->Next()) != NULL)
519 for (UInt_t i = 0; i < buspatch->GetDataCount(); i++)
521 buspatch->GetData(i, manuId, manuChannel, adc);
522 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
523 buspatch->GetBusPatchId(), manuId, manuChannel, adc);