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"
45 #include "AliRawDataErrorLog.h"
46 #include "Riostream.h"
50 void MUONRawStreamTrackerExpert(TString fileName = "./", Int_t maxEvent = 1000,
51 Int_t minDDL = 0, Int_t maxDDL = 19)
53 /// This routine shows how to use the decoder's expert interface.
58 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
61 AliMUONRawStreamTrackerHP rawStream(rawReader);
63 // light weight interfaces to headers
64 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
65 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
66 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
72 while (rawReader->NextEvent()) {
74 if (iEvent == maxEvent)
77 printf("Event %d\n",iEvent++);
79 // read DDL while < 20 DDL
80 while(rawStream.NextDDL()) {
82 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
85 printf("\niDDL %d\n", rawStream.GetDDL());
87 // loop over block structure
88 Int_t nBlock = rawStream.GetBlockCount();
89 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
91 blkHeader = rawStream.GetBlockHeader(iBlock);
92 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
94 // loop over DSP structure
95 Int_t nDsp = rawStream.GetDspCount(iBlock);
96 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
98 dspHeader = blkHeader->GetDspHeader(iDsp);
99 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
101 // loop over BusPatch structure
102 Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
103 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
105 busStruct = dspHeader->GetBusPatch(iBusPatch);
108 dataSize = busStruct->GetLength();
109 for (Int_t iData = 0; iData < dataSize; iData++) {
111 Int_t manuId = busStruct->GetManuId(iData);
112 Int_t channelId = busStruct->GetChannelId(iData);
113 Int_t charge = busStruct->GetCharge(iData);
114 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
115 busStruct->GetBusPatchId(),
130 void MUONRawStreamTrackerExpert2(TString fileName = "./", Int_t maxEvent = 1000,
131 Int_t minDDL = 0, Int_t maxDDL = 19)
133 /// This routine shows an alternate way to iterate over the DDL structures
134 /// compared to MUONRawStreamTrackerExpert().
139 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
142 AliMUONRawStreamTrackerHP rawStream(rawReader);
144 // light weight interfaces to headers
145 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
146 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
147 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
153 while (rawReader->NextEvent()) {
155 if (iEvent == maxEvent)
158 printf("Event %d\n",iEvent++);
160 // read DDL while < 20 DDL
161 while(rawStream.NextDDL()) {
163 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
166 printf("\niDDL %d\n", rawStream.GetDDL());
168 // loop over block structure
169 Int_t nBlock = rawStream.GetBlockCount();
170 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
172 blkHeader = rawStream.GetBlockHeader(iBlock);
173 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
175 // loop over DSP structure
176 Int_t nDsp = rawStream.GetDspCount(iBlock);
177 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
179 dspHeader = rawStream.GetDspHeader(iBlock, iDsp);
180 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
182 // loop over BusPatch structure
183 Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
184 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
186 busStruct = rawStream.GetBusPatch(iBlock, iDsp, iBusPatch);
189 dataSize = busStruct->GetLength();
190 for (Int_t iData = 0; iData < dataSize; iData++) {
192 Int_t manuId = busStruct->GetManuId(iData);
193 Int_t channelId = busStruct->GetChannelId(iData);
194 Int_t charge = busStruct->GetCharge(iData);
195 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
196 busStruct->GetBusPatchId(),
211 void MUONRawStreamTrackerExpert3(TString fileName = "./", Int_t maxEvent = 1000,
212 Int_t minDDL = 0, Int_t maxDDL = 19)
214 /// This routine shows yet another alternate way to iterate over the DDL
215 /// structures compared to MUONRawStreamTrackerExpert().
220 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
223 AliMUONRawStreamTrackerHP rawStream(rawReader);
225 // light weight interfaces to headers
226 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
227 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
228 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
234 while (rawReader->NextEvent()) {
236 if (iEvent == maxEvent)
239 printf("Event %d\n",iEvent++);
241 // read DDL while < 20 DDL
242 while(rawStream.NextDDL()) {
244 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
247 printf("\niDDL %d\n", rawStream.GetDDL());
249 // loop over block structure
251 blkHeader = rawStream.GetFirstBlockHeader();
252 while (blkHeader != NULL)
254 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
256 // loop over DSP structure
258 dspHeader = blkHeader->GetFirstDspHeader();
259 while (dspHeader != NULL)
261 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
263 // loop over BusPatch structure
265 busStruct = dspHeader->GetFirstBusPatch();
266 while (busStruct != NULL)
269 dataSize = busStruct->GetLength();
270 for (Int_t iData = 0; iData < dataSize; iData++) {
272 Int_t manuId = busStruct->GetManuId(iData);
273 Int_t channelId = busStruct->GetChannelId(iData);
274 Int_t charge = busStruct->GetCharge(iData);
275 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
276 busStruct->GetBusPatchId(),
280 busStruct = busStruct->Next();
283 dspHeader = dspHeader->Next();
286 blkHeader = blkHeader->Next();
297 void MUONRawStreamTrackerSimple(TString fileName = "./", Int_t maxEvent = 1000)
299 /// This routine shows how to use the high performance decoder's simple interface.
304 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
307 AliMUONRawStreamTrackerHP rawStream(rawReader);
312 while (rawReader->NextEvent()) {
314 if (iEvent == maxEvent)
317 printf("Event %d\n",iEvent++);
320 UShort_t manuId, adc;
325 while ( rawStream.Next(busPatch,manuId,manuChannel,adc) )
327 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
328 busPatch,manuId,manuChannel, adc);
337 void ShowErrors(const AliRawReader& rawReader)
339 for ( Int_t i = 0; i < rawReader.GetNumberOfErrorLogs(); ++i )
341 AliRawDataErrorLog* error = rawReader.GetErrorLog(i);
345 cout << Form("Number of error logs : %d (%d events)",
346 rawReader.GetNumberOfErrorLogs(),
347 rawReader.GetNumberOfEvents()) << endl;
351 void MUONRawStreamTrackerSimple2(TString fileName = "./", Int_t maxEvent = 1000)
353 /// This routine is an alternative to MUONRawStreamTrackerSimple() which is even faster.
358 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
361 AliMUONRawStreamTrackerHP rawStream(rawReader);
362 rawStream.EnableRawReaderErrorLogger();
367 while (rawReader->NextEvent()) {
369 if (iEvent == maxEvent)
372 printf("Event %d\n",iEvent++);
374 UShort_t manuId, adc;
378 const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL;
379 while ((buspatch = rawStream.Next()) != NULL)
381 for (UInt_t i = 0; i < buspatch->GetDataCount(); i++)
383 buspatch->GetData(i, manuId, manuChannel, adc);
384 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
385 buspatch->GetBusPatchId(), manuId, manuChannel, adc);
390 ShowErrors(*rawReader);
396 void MUONRawStreamTrackerErrorCount(TString fileName = "collection://filelist", Int_t maxEvent = -1)
398 /// This routine is just a loop to get the error log at the end
403 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
406 AliMUONRawStreamTrackerHP rawStream(rawReader);
407 rawStream.EnableRawReaderErrorLogger();
408 rawStream.DisableWarnings();
413 while (rawReader->NextEvent())
415 if (iEvent == maxEvent) break;
419 const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL;
421 while ((buspatch = rawStream.Next()) != NULL)
426 ShowErrors(*rawReader);