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