]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/MUONRawStreamTracker.C
fix BxByBz - testing
[u/mrichter/AliRoot.git] / MUON / MUONRawStreamTracker.C
CommitLineData
6068f9cf 1/**************************************************************************
3bdf2aea 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**************************************************************************/
6068f9cf 15
e54bf126 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///
e54bf126 35
6068f9cf 36
37#if !defined(__CINT__) || defined(__MAKECINT__)
38
39// RAW includes
ce22afdc 40#include "AliRawReader.h"
6068f9cf 41
42// MUON includes
8a0dae7c 43#include "AliMUONRawStreamTrackerHP.h"
3bdf2aea 44#include "TStopwatch.h"
6068f9cf 45
3bdf2aea 46#endif
6068f9cf 47
3bdf2aea 48void MUONRawStreamTrackerExpert(TString fileName = "./", Int_t maxEvent = 1000,
49 Int_t minDDL = 0, Int_t maxDDL = 19)
6068f9cf 50{
4f131d83 51 /// This routine shows how to use the decoder's expert interface.
8a0dae7c 52
53 TStopwatch timer;
54 timer.Start(kTRUE);
55
ce22afdc 56 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
8a0dae7c 57
58 // raw stream
4f131d83 59 AliMUONRawStreamTrackerHP rawStream(rawReader);
8a0dae7c 60
61 // light weight interfaces to headers
62 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
63 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
64 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
65
66 // Loop over events
67 Int_t iEvent = 0;
68 Int_t dataSize;
69
70 while (rawReader->NextEvent()) {
71
72 if (iEvent == maxEvent)
73 break;
74
75 printf("Event %d\n",iEvent++);
76
77 // read DDL while < 20 DDL
4f131d83 78 while(rawStream.NextDDL()) {
8a0dae7c 79
4f131d83 80 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
8a0dae7c 81 continue;
82
4f131d83 83 printf("\niDDL %d\n", rawStream.GetDDL());
8a0dae7c 84
85 // loop over block structure
4f131d83 86 Int_t nBlock = rawStream.GetBlockCount();
8a0dae7c 87 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
88
4f131d83 89 blkHeader = rawStream.GetBlockHeader(iBlock);
8a0dae7c 90 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
91
92 // loop over DSP structure
4f131d83 93 Int_t nDsp = rawStream.GetDspCount(iBlock);
8a0dae7c 94 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
95
96 dspHeader = blkHeader->GetDspHeader(iDsp);
97 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
98
99 // loop over BusPatch structure
4f131d83 100 Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
8a0dae7c 101 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
102
103 busStruct = dspHeader->GetBusPatch(iBusPatch);
104
105 // loop over data
106 dataSize = busStruct->GetLength();
107 for (Int_t iData = 0; iData < dataSize; iData++) {
108
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(),
114 manuId,
115 channelId, charge);
116 } // iData
117 } // iBusPatch
118 } // iDsp
119 } // iBlock
120 } // NextDDL
121 }// NextEvent
122
123 delete rawReader;
8a0dae7c 124 timer.Print();
125}
126
127
4f131d83 128void MUONRawStreamTrackerExpert2(TString fileName = "./", Int_t maxEvent = 1000,
8a0dae7c 129 Int_t minDDL = 0, Int_t maxDDL = 19)
130{
131 /// This routine shows an alternate way to iterate over the DDL structures
4f131d83 132 /// compared to MUONRawStreamTrackerExpert().
8a0dae7c 133
134 TStopwatch timer;
135 timer.Start(kTRUE);
136
ce22afdc 137 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
8a0dae7c 138
139 // raw stream
4f131d83 140 AliMUONRawStreamTrackerHP rawStream(rawReader);
8a0dae7c 141
142 // light weight interfaces to headers
143 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
144 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
145 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
146
147 // Loop over events
148 Int_t iEvent = 0;
149 Int_t dataSize;
150
151 while (rawReader->NextEvent()) {
152
153 if (iEvent == maxEvent)
154 break;
155
156 printf("Event %d\n",iEvent++);
157
158 // read DDL while < 20 DDL
4f131d83 159 while(rawStream.NextDDL()) {
8a0dae7c 160
4f131d83 161 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
8a0dae7c 162 continue;
163
4f131d83 164 printf("\niDDL %d\n", rawStream.GetDDL());
8a0dae7c 165
166 // loop over block structure
4f131d83 167 Int_t nBlock = rawStream.GetBlockCount();
8a0dae7c 168 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
169
4f131d83 170 blkHeader = rawStream.GetBlockHeader(iBlock);
8a0dae7c 171 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
172
173 // loop over DSP structure
4f131d83 174 Int_t nDsp = rawStream.GetDspCount(iBlock);
8a0dae7c 175 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
176
4f131d83 177 dspHeader = rawStream.GetDspHeader(iBlock, iDsp);
8a0dae7c 178 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
179
180 // loop over BusPatch structure
4f131d83 181 Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
8a0dae7c 182 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
183
4f131d83 184 busStruct = rawStream.GetBusPatch(iBlock, iDsp, iBusPatch);
8a0dae7c 185
186 // loop over data
187 dataSize = busStruct->GetLength();
188 for (Int_t iData = 0; iData < dataSize; iData++) {
189
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(),
195 manuId,
196 channelId, charge);
197 } // iData
198 } // iBusPatch
199 } // iDsp
200 } // iBlock
201 } // NextDDL
202 }// NextEvent
203
204 delete rawReader;
8a0dae7c 205 timer.Print();
206}
207
208
4f131d83 209void MUONRawStreamTrackerExpert3(TString fileName = "./", Int_t maxEvent = 1000,
8a0dae7c 210 Int_t minDDL = 0, Int_t maxDDL = 19)
211{
212 /// This routine shows yet another alternate way to iterate over the DDL
4f131d83 213 /// structures compared to MUONRawStreamTrackerExpert().
8a0dae7c 214
215 TStopwatch timer;
216 timer.Start(kTRUE);
217
ce22afdc 218 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
8a0dae7c 219
220 // raw stream
4f131d83 221 AliMUONRawStreamTrackerHP rawStream(rawReader);
8a0dae7c 222
223 // light weight interfaces to headers
224 const AliMUONRawStreamTrackerHP::AliBlockHeader* blkHeader = 0x0;
225 const AliMUONRawStreamTrackerHP::AliDspHeader* dspHeader = 0x0;
226 const AliMUONRawStreamTrackerHP::AliBusPatch* busStruct = 0x0;
227
228 // Loop over events
229 Int_t iEvent = 0;
230 Int_t dataSize;
231
232 while (rawReader->NextEvent()) {
233
234 if (iEvent == maxEvent)
235 break;
236
237 printf("Event %d\n",iEvent++);
238
239 // read DDL while < 20 DDL
4f131d83 240 while(rawStream.NextDDL()) {
8a0dae7c 241
4f131d83 242 if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
8a0dae7c 243 continue;
244
4f131d83 245 printf("\niDDL %d\n", rawStream.GetDDL());
8a0dae7c 246
247 // loop over block structure
248 Int_t iBlock = 0;
4f131d83 249 blkHeader = rawStream.GetFirstBlockHeader();
8a0dae7c 250 while (blkHeader != NULL)
251 {
252 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
253
254 // loop over DSP structure
255 Int_t iDsp = 0;
256 dspHeader = blkHeader->GetFirstDspHeader();
257 while (dspHeader != NULL)
258 {
259 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
260
261 // loop over BusPatch structure
262 Int_t iBusPatch = 0;
263 busStruct = dspHeader->GetFirstBusPatch();
264 while (busStruct != NULL)
265 {
266 // loop over data
267 dataSize = busStruct->GetLength();
268 for (Int_t iData = 0; iData < dataSize; iData++) {
269
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(),
275 manuId,
276 channelId, charge);
277 } // iData
278 busStruct = busStruct->Next();
279 iBusPatch++;
280 } // iBusPatch
281 dspHeader = dspHeader->Next();
282 iDsp++;
283 } // iDsp
284 blkHeader = blkHeader->Next();
285 iBlock++;
286 } // iBlock
287 } // NextDDL
288 }// NextEvent
289
290 delete rawReader;
8a0dae7c 291 timer.Print();
292}
293
294
295void MUONRawStreamTrackerSimple(TString fileName = "./", Int_t maxEvent = 1000)
8a0dae7c 296{
297 /// This routine shows how to use the high performance decoder's simple interface.
298
299 TStopwatch timer;
300 timer.Start(kTRUE);
301
ce22afdc 302 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
8a0dae7c 303
304 // raw stream
4f131d83 305 AliMUONRawStreamTrackerHP rawStream(rawReader);
8a0dae7c 306
307 // Loop over events
308 Int_t iEvent = 0;
309
310 while (rawReader->NextEvent()) {
311
312 if (iEvent == maxEvent)
313 break;
314
315 printf("Event %d\n",iEvent++);
316
317 Int_t busPatch;
318 UShort_t manuId, adc;
319 UChar_t manuChannel;
320
4f131d83 321 rawStream.First();
8a0dae7c 322
4f131d83 323 while ( rawStream.Next(busPatch,manuId,manuChannel,adc) )
8a0dae7c 324 {
325 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
326 busPatch,manuId,manuChannel, adc);
327 }
328 }
329
330 delete rawReader;
8a0dae7c 331 timer.Print();
332}
333
334
4f131d83 335void MUONRawStreamTrackerSimple2(TString fileName = "./", Int_t maxEvent = 1000)
8a0dae7c 336{
4f131d83 337 /// This routine is an alternative to MUONRawStreamTrackerSimple() which is even faster.
8a0dae7c 338
339 TStopwatch timer;
340 timer.Start(kTRUE);
341
ce22afdc 342 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
8a0dae7c 343
344 // raw stream
4f131d83 345 AliMUONRawStreamTrackerHP rawStream(rawReader);
8a0dae7c 346
347 // Loop over events
348 Int_t iEvent = 0;
349
350 while (rawReader->NextEvent()) {
351
352 if (iEvent == maxEvent)
353 break;
354
355 printf("Event %d\n",iEvent++);
356
357 UShort_t manuId, adc;
358 UChar_t manuChannel;
359
4f131d83 360 rawStream.First();
8a0dae7c 361 const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL;
4f131d83 362 while ((buspatch = rawStream.Next()) != NULL)
8a0dae7c 363 {
364 for (UInt_t i = 0; i < buspatch->GetDataCount(); i++)
365 {
366 buspatch->GetData(i, manuId, manuChannel, adc);
367 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
368 buspatch->GetBusPatchId(), manuId, manuChannel, adc);
369 }
370 }
371 }
372
373 delete rawReader;
8a0dae7c 374 timer.Print();
375}
376