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
37 #if !defined(__CINT__) || defined(__MAKECINT__)
40 #include "AliRawReader.h"
43 #include "AliMUONRawStreamTrackerHP.h"
44 #include "TStopwatch.h"
48 void MUONRawStreamTrackerExpert(TString fileName = "./", Int_t maxEvent = 1000,
49 Int_t minDDL = 0, Int_t maxDDL = 19)
51 /// This routine shows how to use the decoder's expert interface.
56 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
59 AliMUONRawStreamTrackerHP rawStream(rawReader);
61 // light weight interfaces to headers
62 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
63 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
64 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
70 while (rawReader->NextEvent()) {
72 if (iEvent == maxEvent)
75 printf("Event %d\n",iEvent++);
77 // read DDL while < 20 DDL
78 while(rawStream.NextDDL()) {
80 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
83 printf("\niDDL %d\n", rawStream.GetDDL());
85 // loop over block structure
86 Int_t nBlock = rawStream.GetBlockCount();
87 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
89 blkHeader = rawStream.GetBlockHeader(iBlock);
90 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
92 // loop over DSP structure
93 Int_t nDsp = rawStream.GetDspCount(iBlock);
94 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
96 dspHeader = blkHeader->GetDspHeader(iDsp);
97 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
99 // loop over BusPatch structure
100 Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
101 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
103 busStruct = dspHeader->GetBusPatch(iBusPatch);
106 dataSize = busStruct->GetLength();
107 for (Int_t iData = 0; iData < dataSize; iData++) {
109 Int_t manuId = busStruct->GetManuId(iData);
110 Int_t channelId = busStruct->GetChannelId(iData);
111 Int_t charge = busStruct->GetCharge(iData);
112 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
113 busStruct->GetBusPatchId(),
128 void MUONRawStreamTrackerExpert2(TString fileName = "./", Int_t maxEvent = 1000,
129 Int_t minDDL = 0, Int_t maxDDL = 19)
131 /// This routine shows an alternate way to iterate over the DDL structures
132 /// compared to MUONRawStreamTrackerExpert().
137 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
140 AliMUONRawStreamTrackerHP rawStream(rawReader);
142 // light weight interfaces to headers
143 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
144 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
145 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
151 while (rawReader->NextEvent()) {
153 if (iEvent == maxEvent)
156 printf("Event %d\n",iEvent++);
158 // read DDL while < 20 DDL
159 while(rawStream.NextDDL()) {
161 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
164 printf("\niDDL %d\n", rawStream.GetDDL());
166 // loop over block structure
167 Int_t nBlock = rawStream.GetBlockCount();
168 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
170 blkHeader = rawStream.GetBlockHeader(iBlock);
171 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
173 // loop over DSP structure
174 Int_t nDsp = rawStream.GetDspCount(iBlock);
175 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
177 dspHeader = rawStream.GetDspHeader(iBlock, iDsp);
178 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
180 // loop over BusPatch structure
181 Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
182 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
184 busStruct = rawStream.GetBusPatch(iBlock, iDsp, iBusPatch);
187 dataSize = busStruct->GetLength();
188 for (Int_t iData = 0; iData < dataSize; iData++) {
190 Int_t manuId = busStruct->GetManuId(iData);
191 Int_t channelId = busStruct->GetChannelId(iData);
192 Int_t charge = busStruct->GetCharge(iData);
193 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
194 busStruct->GetBusPatchId(),
209 void MUONRawStreamTrackerExpert3(TString fileName = "./", Int_t maxEvent = 1000,
210 Int_t minDDL = 0, Int_t maxDDL = 19)
212 /// This routine shows yet another alternate way to iterate over the DDL
213 /// structures compared to MUONRawStreamTrackerExpert().
218 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
221 AliMUONRawStreamTrackerHP rawStream(rawReader);
223 // light weight interfaces to headers
224 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
225 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
226 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
232 while (rawReader->NextEvent()) {
234 if (iEvent == maxEvent)
237 printf("Event %d\n",iEvent++);
239 // read DDL while < 20 DDL
240 while(rawStream.NextDDL()) {
242 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
245 printf("\niDDL %d\n", rawStream.GetDDL());
247 // loop over block structure
249 blkHeader = rawStream.GetFirstBlockHeader();
250 while (blkHeader != NULL)
252 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
254 // loop over DSP structure
256 dspHeader = blkHeader->GetFirstDspHeader();
257 while (dspHeader != NULL)
259 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
261 // loop over BusPatch structure
263 busStruct = dspHeader->GetFirstBusPatch();
264 while (busStruct != NULL)
267 dataSize = busStruct->GetLength();
268 for (Int_t iData = 0; iData < dataSize; iData++) {
270 Int_t manuId = busStruct->GetManuId(iData);
271 Int_t channelId = busStruct->GetChannelId(iData);
272 Int_t charge = busStruct->GetCharge(iData);
273 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
274 busStruct->GetBusPatchId(),
278 busStruct = busStruct->Next();
281 dspHeader = dspHeader->Next();
284 blkHeader = blkHeader->Next();
295 void MUONRawStreamTrackerSimple(TString fileName = "./", Int_t maxEvent = 1000)
297 /// This routine shows how to use the high performance decoder's simple interface.
302 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
305 AliMUONRawStreamTrackerHP rawStream(rawReader);
310 while (rawReader->NextEvent()) {
312 if (iEvent == maxEvent)
315 printf("Event %d\n",iEvent++);
318 UShort_t manuId, adc;
323 while ( rawStream.Next(busPatch,manuId,manuChannel,adc) )
325 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
326 busPatch,manuId,manuChannel, adc);
335 void MUONRawStreamTrackerSimple2(TString fileName = "./", Int_t maxEvent = 1000)
337 /// This routine is an alternative to MUONRawStreamTrackerSimple() which is even faster.
342 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
345 AliMUONRawStreamTrackerHP rawStream(rawReader);
350 while (rawReader->NextEvent()) {
352 if (iEvent == maxEvent)
355 printf("Event %d\n",iEvent++);
357 UShort_t manuId, adc;
361 const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL;
362 while ((buspatch = rawStream.Next()) != NULL)
364 for (UInt_t i = 0; i < buspatch->GetDataCount(); i++)
366 buspatch->GetData(i, manuId, manuChannel, adc);
367 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
368 buspatch->GetBusPatchId(), manuId, manuChannel, adc);