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"
47 #include "AliMUONLogger.h"
51 void MUONRawStreamTrackerExpert(TString fileName = "./", Int_t maxEvent = 1000,
52 Int_t minDDL = 0, Int_t maxDDL = 19)
54 /// This routine shows how to use the decoder's expert interface.
59 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
62 AliMUONRawStreamTrackerHP rawStream(rawReader);
64 // light weight interfaces to headers
65 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
66 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
67 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
73 while (rawReader->NextEvent()) {
75 if (iEvent == maxEvent)
78 printf("Event %d\n",iEvent++);
80 // read DDL while < 20 DDL
81 while(rawStream.NextDDL()) {
83 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
86 printf("\niDDL %d\n", rawStream.GetDDL());
88 // loop over block structure
89 Int_t nBlock = rawStream.GetBlockCount();
90 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
92 blkHeader = rawStream.GetBlockHeader(iBlock);
93 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
95 // loop over DSP structure
96 Int_t nDsp = rawStream.GetDspCount(iBlock);
97 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
99 dspHeader = blkHeader->GetDspHeader(iDsp);
100 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
102 // loop over BusPatch structure
103 Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
104 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
106 busStruct = dspHeader->GetBusPatch(iBusPatch);
109 dataSize = busStruct->GetLength();
110 for (Int_t iData = 0; iData < dataSize; iData++) {
112 Int_t manuId = busStruct->GetManuId(iData);
113 Int_t channelId = busStruct->GetChannelId(iData);
114 Int_t charge = busStruct->GetCharge(iData);
115 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
116 busStruct->GetBusPatchId(),
131 void MUONRawStreamTrackerExpert2(TString fileName = "./", Int_t maxEvent = 1000,
132 Int_t minDDL = 0, Int_t maxDDL = 19)
134 /// This routine shows an alternate way to iterate over the DDL structures
135 /// compared to MUONRawStreamTrackerExpert().
140 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
143 AliMUONRawStreamTrackerHP rawStream(rawReader);
145 // light weight interfaces to headers
146 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
147 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
148 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
154 while (rawReader->NextEvent()) {
156 if (iEvent == maxEvent)
159 printf("Event %d\n",iEvent++);
161 // read DDL while < 20 DDL
162 while(rawStream.NextDDL()) {
164 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
167 printf("\niDDL %d\n", rawStream.GetDDL());
169 // loop over block structure
170 Int_t nBlock = rawStream.GetBlockCount();
171 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
173 blkHeader = rawStream.GetBlockHeader(iBlock);
174 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
176 // loop over DSP structure
177 Int_t nDsp = rawStream.GetDspCount(iBlock);
178 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
180 dspHeader = rawStream.GetDspHeader(iBlock, iDsp);
181 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
183 // loop over BusPatch structure
184 Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
185 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
187 busStruct = rawStream.GetBusPatch(iBlock, iDsp, iBusPatch);
190 dataSize = busStruct->GetLength();
191 for (Int_t iData = 0; iData < dataSize; iData++) {
193 Int_t manuId = busStruct->GetManuId(iData);
194 Int_t channelId = busStruct->GetChannelId(iData);
195 Int_t charge = busStruct->GetCharge(iData);
196 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
197 busStruct->GetBusPatchId(),
212 void MUONRawStreamTrackerExpert3(TString fileName = "./", Int_t maxEvent = 1000,
213 Int_t minDDL = 0, Int_t maxDDL = 19)
215 /// This routine shows yet another alternate way to iterate over the DDL
216 /// structures compared to MUONRawStreamTrackerExpert().
221 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
224 AliMUONRawStreamTrackerHP rawStream(rawReader);
226 // light weight interfaces to headers
227 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
228 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
229 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
235 while (rawReader->NextEvent()) {
237 if (iEvent == maxEvent)
240 printf("Event %d\n",iEvent++);
242 // read DDL while < 20 DDL
243 while(rawStream.NextDDL()) {
245 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
248 printf("\niDDL %d\n", rawStream.GetDDL());
250 // loop over block structure
252 blkHeader = rawStream.GetFirstBlockHeader();
253 while (blkHeader != NULL)
255 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
257 // loop over DSP structure
259 dspHeader = blkHeader->GetFirstDspHeader();
260 while (dspHeader != NULL)
262 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
264 // loop over BusPatch structure
266 busStruct = dspHeader->GetFirstBusPatch();
267 while (busStruct != NULL)
270 dataSize = busStruct->GetLength();
271 for (Int_t iData = 0; iData < dataSize; iData++) {
273 Int_t manuId = busStruct->GetManuId(iData);
274 Int_t channelId = busStruct->GetChannelId(iData);
275 Int_t charge = busStruct->GetCharge(iData);
276 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
277 busStruct->GetBusPatchId(),
281 busStruct = busStruct->Next();
284 dspHeader = dspHeader->Next();
287 blkHeader = blkHeader->Next();
298 void MUONRawStreamTrackerSimple(TString fileName = "./", Int_t maxEvent = 1000)
300 /// This routine shows how to use the high performance decoder's simple interface.
305 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
308 AliMUONRawStreamTrackerHP rawStream(rawReader);
313 while (rawReader->NextEvent()) {
315 if (iEvent == maxEvent)
318 printf("Event %d\n",iEvent++);
321 UShort_t manuId, adc;
326 while ( rawStream.Next(busPatch,manuId,manuChannel,adc) )
328 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
329 busPatch,manuId,manuChannel, adc);
338 void ShowErrors(const AliRawReader& rawReader)
340 for ( Int_t i = 0; i < rawReader.GetNumberOfErrorLogs(); ++i )
342 AliRawDataErrorLog* error = rawReader.GetErrorLog(i);
346 cout << Form("Number of error logs : %d (%d events)",
347 rawReader.GetNumberOfErrorLogs(),
348 rawReader.GetNumberOfEvents()) << endl;
352 void MUONRawStreamTrackerSimple2(TString fileName = "./", Int_t maxEvent = 1000)
354 /// This routine is an alternative to MUONRawStreamTrackerSimple() which is even faster.
359 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
362 AliMUONRawStreamTrackerHP rawStream(rawReader);
363 rawStream.EnableRawReaderErrorLogger();
368 while (rawReader->NextEvent()) {
370 if (iEvent == maxEvent)
373 printf("Event %d\n",iEvent++);
375 UShort_t manuId, adc;
379 const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL;
380 while ((buspatch = rawStream.Next()) != NULL)
382 for (UInt_t i = 0; i < buspatch->GetDataCount(); i++)
384 buspatch->GetData(i, manuId, manuChannel, adc);
385 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
386 buspatch->GetBusPatchId(), manuId, manuChannel, adc);
391 ShowErrors(*rawReader);
397 void MUONRawStreamTrackerErrorCount(TString fileName = "collection://filelist", Int_t maxEvent = -1)
399 /// This routine is just a loop to get the error log at the end
404 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
407 AliMUONRawStreamTrackerHP rawStream(rawReader);
408 rawStream.DisableWarnings();
410 AliMUONLogger logger;
412 rawStream.EnableMUONErrorLogger();
413 rawStream.SetMUONErrorLogger(&logger);
414 rawStream.SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kMediumErrorDetail);
419 while (rawReader->NextEvent())
421 if (iEvent == maxEvent) break;
425 const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL;
427 while ((buspatch = rawStream.Next()) != NULL)
436 // ShowErrors(*rawReader);