I have put as default the current parameterization of V0 and SPD --from run 166530...
[u/mrichter/AliRoot.git] / MUON / MUONRawStreamTracker.C
... / ...
CommitLineData
1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
15
16// $Id$
17
18/// \ingroup macros
19/// \file MUONRawStreamTracker.C
20/// \brief Macro for reading tracker raw data
21///
22/// \author Ch. Finck, Subatech Febuary
23///
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>
27///
28/// This macro is interfaced with AliRawReader for RAW
29///
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
33/// (charge).
34///
35
36
37#if !defined(__CINT__) || defined(__MAKECINT__)
38
39// RAW includes
40#include "AliRawReader.h"
41
42// MUON includes
43#include "AliMUONRawStreamTrackerHP.h"
44#include "TStopwatch.h"
45#include "AliRawDataErrorLog.h"
46#include "Riostream.h"
47
48#endif
49
50void MUONRawStreamTrackerExpert(TString fileName = "./", Int_t maxEvent = 1000,
51 Int_t minDDL = 0, Int_t maxDDL = 19)
52{
53 /// This routine shows how to use the decoder's expert interface.
54
55 TStopwatch timer;
56 timer.Start(kTRUE);
57
58 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
59
60 // raw stream
61 AliMUONRawStreamTrackerHP rawStream(rawReader);
62
63 // light weight interfaces to headers
64 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
65 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
66 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
67
68 // Loop over events
69 Int_t iEvent = 0;
70 Int_t dataSize;
71
72 while (rawReader->NextEvent()) {
73
74 if (iEvent == maxEvent)
75 break;
76
77 printf("Event %d\n",iEvent++);
78
79 // read DDL while < 20 DDL
80 while(rawStream.NextDDL()) {
81
82 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
83 continue;
84
85 printf("\niDDL %d\n", rawStream.GetDDL());
86
87 // loop over block structure
88 Int_t nBlock = rawStream.GetBlockCount();
89 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
90
91 blkHeader = rawStream.GetBlockHeader(iBlock);
92 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
93
94 // loop over DSP structure
95 Int_t nDsp = rawStream.GetDspCount(iBlock);
96 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
97
98 dspHeader = blkHeader->GetDspHeader(iDsp);
99 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
100
101 // loop over BusPatch structure
102 Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
103 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
104
105 busStruct = dspHeader->GetBusPatch(iBusPatch);
106
107 // loop over data
108 dataSize = busStruct->GetLength();
109 for (Int_t iData = 0; iData < dataSize; iData++) {
110
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(),
116 manuId,
117 channelId, charge);
118 } // iData
119 } // iBusPatch
120 } // iDsp
121 } // iBlock
122 } // NextDDL
123 }// NextEvent
124
125 delete rawReader;
126 timer.Print();
127}
128
129
130void MUONRawStreamTrackerExpert2(TString fileName = "./", Int_t maxEvent = 1000,
131 Int_t minDDL = 0, Int_t maxDDL = 19)
132{
133 /// This routine shows an alternate way to iterate over the DDL structures
134 /// compared to MUONRawStreamTrackerExpert().
135
136 TStopwatch timer;
137 timer.Start(kTRUE);
138
139 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
140
141 // raw stream
142 AliMUONRawStreamTrackerHP rawStream(rawReader);
143
144 // light weight interfaces to headers
145 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
146 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
147 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
148
149 // Loop over events
150 Int_t iEvent = 0;
151 Int_t dataSize;
152
153 while (rawReader->NextEvent()) {
154
155 if (iEvent == maxEvent)
156 break;
157
158 printf("Event %d\n",iEvent++);
159
160 // read DDL while < 20 DDL
161 while(rawStream.NextDDL()) {
162
163 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
164 continue;
165
166 printf("\niDDL %d\n", rawStream.GetDDL());
167
168 // loop over block structure
169 Int_t nBlock = rawStream.GetBlockCount();
170 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
171
172 blkHeader = rawStream.GetBlockHeader(iBlock);
173 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
174
175 // loop over DSP structure
176 Int_t nDsp = rawStream.GetDspCount(iBlock);
177 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
178
179 dspHeader = rawStream.GetDspHeader(iBlock, iDsp);
180 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
181
182 // loop over BusPatch structure
183 Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
184 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
185
186 busStruct = rawStream.GetBusPatch(iBlock, iDsp, iBusPatch);
187
188 // loop over data
189 dataSize = busStruct->GetLength();
190 for (Int_t iData = 0; iData < dataSize; iData++) {
191
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(),
197 manuId,
198 channelId, charge);
199 } // iData
200 } // iBusPatch
201 } // iDsp
202 } // iBlock
203 } // NextDDL
204 }// NextEvent
205
206 delete rawReader;
207 timer.Print();
208}
209
210
211void MUONRawStreamTrackerExpert3(TString fileName = "./", Int_t maxEvent = 1000,
212 Int_t minDDL = 0, Int_t maxDDL = 19)
213{
214 /// This routine shows yet another alternate way to iterate over the DDL
215 /// structures compared to MUONRawStreamTrackerExpert().
216
217 TStopwatch timer;
218 timer.Start(kTRUE);
219
220 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
221
222 // raw stream
223 AliMUONRawStreamTrackerHP rawStream(rawReader);
224
225 // light weight interfaces to headers
226 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
227 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
228 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
229
230 // Loop over events
231 Int_t iEvent = 0;
232 Int_t dataSize;
233
234 while (rawReader->NextEvent()) {
235
236 if (iEvent == maxEvent)
237 break;
238
239 printf("Event %d\n",iEvent++);
240
241 // read DDL while < 20 DDL
242 while(rawStream.NextDDL()) {
243
244 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
245 continue;
246
247 printf("\niDDL %d\n", rawStream.GetDDL());
248
249 // loop over block structure
250 Int_t iBlock = 0;
251 blkHeader = rawStream.GetFirstBlockHeader();
252 while (blkHeader != NULL)
253 {
254 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
255
256 // loop over DSP structure
257 Int_t iDsp = 0;
258 dspHeader = blkHeader->GetFirstDspHeader();
259 while (dspHeader != NULL)
260 {
261 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
262
263 // loop over BusPatch structure
264 Int_t iBusPatch = 0;
265 busStruct = dspHeader->GetFirstBusPatch();
266 while (busStruct != NULL)
267 {
268 // loop over data
269 dataSize = busStruct->GetLength();
270 for (Int_t iData = 0; iData < dataSize; iData++) {
271
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(),
277 manuId,
278 channelId, charge);
279 } // iData
280 busStruct = busStruct->Next();
281 iBusPatch++;
282 } // iBusPatch
283 dspHeader = dspHeader->Next();
284 iDsp++;
285 } // iDsp
286 blkHeader = blkHeader->Next();
287 iBlock++;
288 } // iBlock
289 } // NextDDL
290 }// NextEvent
291
292 delete rawReader;
293 timer.Print();
294}
295
296
297void MUONRawStreamTrackerSimple(TString fileName = "./", Int_t maxEvent = 1000)
298{
299 /// This routine shows how to use the high performance decoder's simple interface.
300
301 TStopwatch timer;
302 timer.Start(kTRUE);
303
304 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
305
306 // raw stream
307 AliMUONRawStreamTrackerHP rawStream(rawReader);
308
309 // Loop over events
310 Int_t iEvent = 0;
311
312 while (rawReader->NextEvent()) {
313
314 if (iEvent == maxEvent)
315 break;
316
317 printf("Event %d\n",iEvent++);
318
319 Int_t busPatch;
320 UShort_t manuId, adc;
321 UChar_t manuChannel;
322
323 rawStream.First();
324
325 while ( rawStream.Next(busPatch,manuId,manuChannel,adc) )
326 {
327 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
328 busPatch,manuId,manuChannel, adc);
329 }
330 }
331
332 delete rawReader;
333 timer.Print();
334}
335
336
337void ShowErrors(const AliRawReader& rawReader)
338{
339 for ( Int_t i = 0; i < rawReader.GetNumberOfErrorLogs(); ++i )
340 {
341 AliRawDataErrorLog* error = rawReader.GetErrorLog(i);
342 error->Print();
343 }
344
345 cout << Form("Number of error logs : %d (%d events)",
346 rawReader.GetNumberOfErrorLogs(),
347 rawReader.GetNumberOfEvents()) << endl;
348}
349
350
351void MUONRawStreamTrackerSimple2(TString fileName = "./", Int_t maxEvent = 1000)
352{
353 /// This routine is an alternative to MUONRawStreamTrackerSimple() which is even faster.
354
355 TStopwatch timer;
356 timer.Start(kTRUE);
357
358 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
359
360 // raw stream
361 AliMUONRawStreamTrackerHP rawStream(rawReader);
362 rawStream.EnableRawReaderErrorLogger();
363
364 // Loop over events
365 Int_t iEvent = 0;
366
367 while (rawReader->NextEvent()) {
368
369 if (iEvent == maxEvent)
370 break;
371
372 printf("Event %d\n",iEvent++);
373
374 UShort_t manuId, adc;
375 UChar_t manuChannel;
376
377 rawStream.First();
378 const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL;
379 while ((buspatch = rawStream.Next()) != NULL)
380 {
381 for (UInt_t i = 0; i < buspatch->GetDataCount(); i++)
382 {
383 buspatch->GetData(i, manuId, manuChannel, adc);
384 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
385 buspatch->GetBusPatchId(), manuId, manuChannel, adc);
386 }
387 }
388 }
389
390 ShowErrors(*rawReader);
391
392 delete rawReader;
393 timer.Print();
394}
395
396void MUONRawStreamTrackerErrorCount(TString fileName = "collection://filelist", Int_t maxEvent = -1)
397{
398 /// This routine is just a loop to get the error log at the end
399
400 TStopwatch timer;
401 timer.Start(kTRUE);
402
403 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
404
405 // raw stream
406 AliMUONRawStreamTrackerHP rawStream(rawReader);
407 rawStream.EnableRawReaderErrorLogger();
408 rawStream.DisableWarnings();
409
410 // Loop over events
411 Int_t iEvent = 0;
412
413 while (rawReader->NextEvent())
414 {
415 if (iEvent == maxEvent) break;
416
417 rawStream.First();
418
419 const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL;
420
421 while ((buspatch = rawStream.Next()) != NULL)
422 {
423 }
424 }
425
426 ShowErrors(*rawReader);
427
428 delete rawReader;
429 timer.Print();
430}
431