]>
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" | |
6068f9cf | 47 | |
3bdf2aea | 48 | #endif |
6068f9cf | 49 | |
3bdf2aea | 50 | void MUONRawStreamTrackerExpert(TString fileName = "./", Int_t maxEvent = 1000, |
51 | Int_t minDDL = 0, Int_t maxDDL = 19) | |
6068f9cf | 52 | { |
4f131d83 | 53 | /// This routine shows how to use the decoder's expert interface. |
8a0dae7c | 54 | |
55 | TStopwatch timer; | |
56 | timer.Start(kTRUE); | |
57 | ||
ce22afdc | 58 | AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); |
8a0dae7c | 59 | |
60 | // raw stream | |
4f131d83 | 61 | AliMUONRawStreamTrackerHP rawStream(rawReader); |
8a0dae7c | 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 | |
4f131d83 | 80 | while(rawStream.NextDDL()) { |
8a0dae7c | 81 | |
4f131d83 | 82 | if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL) |
8a0dae7c | 83 | continue; |
84 | ||
4f131d83 | 85 | printf("\niDDL %d\n", rawStream.GetDDL()); |
8a0dae7c | 86 | |
87 | // loop over block structure | |
4f131d83 | 88 | Int_t nBlock = rawStream.GetBlockCount(); |
8a0dae7c | 89 | for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){ |
90 | ||
4f131d83 | 91 | blkHeader = rawStream.GetBlockHeader(iBlock); |
8a0dae7c | 92 | printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength()); |
93 | ||
94 | // loop over DSP structure | |
4f131d83 | 95 | Int_t nDsp = rawStream.GetDspCount(iBlock); |
8a0dae7c | 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 | |
4f131d83 | 102 | Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp); |
8a0dae7c | 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; | |
8a0dae7c | 126 | timer.Print(); |
127 | } | |
128 | ||
129 | ||
4f131d83 | 130 | void MUONRawStreamTrackerExpert2(TString fileName = "./", Int_t maxEvent = 1000, |
8a0dae7c | 131 | Int_t minDDL = 0, Int_t maxDDL = 19) |
132 | { | |
133 | /// This routine shows an alternate way to iterate over the DDL structures | |
4f131d83 | 134 | /// compared to MUONRawStreamTrackerExpert(). |
8a0dae7c | 135 | |
136 | TStopwatch timer; | |
137 | timer.Start(kTRUE); | |
138 | ||
ce22afdc | 139 | AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); |
8a0dae7c | 140 | |
141 | // raw stream | |
4f131d83 | 142 | AliMUONRawStreamTrackerHP rawStream(rawReader); |
8a0dae7c | 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 | |
4f131d83 | 161 | while(rawStream.NextDDL()) { |
8a0dae7c | 162 | |
4f131d83 | 163 | if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL) |
8a0dae7c | 164 | continue; |
165 | ||
4f131d83 | 166 | printf("\niDDL %d\n", rawStream.GetDDL()); |
8a0dae7c | 167 | |
168 | // loop over block structure | |
4f131d83 | 169 | Int_t nBlock = rawStream.GetBlockCount(); |
8a0dae7c | 170 | for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){ |
171 | ||
4f131d83 | 172 | blkHeader = rawStream.GetBlockHeader(iBlock); |
8a0dae7c | 173 | printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength()); |
174 | ||
175 | // loop over DSP structure | |
4f131d83 | 176 | Int_t nDsp = rawStream.GetDspCount(iBlock); |
8a0dae7c | 177 | for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop |
178 | ||
4f131d83 | 179 | dspHeader = rawStream.GetDspHeader(iBlock, iDsp); |
8a0dae7c | 180 | printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord()); |
181 | ||
182 | // loop over BusPatch structure | |
4f131d83 | 183 | Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp); |
8a0dae7c | 184 | for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) { |
185 | ||
4f131d83 | 186 | busStruct = rawStream.GetBusPatch(iBlock, iDsp, iBusPatch); |
8a0dae7c | 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; | |
8a0dae7c | 207 | timer.Print(); |
208 | } | |
209 | ||
210 | ||
4f131d83 | 211 | void MUONRawStreamTrackerExpert3(TString fileName = "./", Int_t maxEvent = 1000, |
8a0dae7c | 212 | Int_t minDDL = 0, Int_t maxDDL = 19) |
213 | { | |
214 | /// This routine shows yet another alternate way to iterate over the DDL | |
4f131d83 | 215 | /// structures compared to MUONRawStreamTrackerExpert(). |
8a0dae7c | 216 | |
217 | TStopwatch timer; | |
218 | timer.Start(kTRUE); | |
219 | ||
ce22afdc | 220 | AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); |
8a0dae7c | 221 | |
222 | // raw stream | |
4f131d83 | 223 | AliMUONRawStreamTrackerHP rawStream(rawReader); |
8a0dae7c | 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 | |
4f131d83 | 242 | while(rawStream.NextDDL()) { |
8a0dae7c | 243 | |
4f131d83 | 244 | if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL) |
8a0dae7c | 245 | continue; |
246 | ||
4f131d83 | 247 | printf("\niDDL %d\n", rawStream.GetDDL()); |
8a0dae7c | 248 | |
249 | // loop over block structure | |
250 | Int_t iBlock = 0; | |
4f131d83 | 251 | blkHeader = rawStream.GetFirstBlockHeader(); |
8a0dae7c | 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; | |
8a0dae7c | 293 | timer.Print(); |
294 | } | |
295 | ||
296 | ||
297 | void MUONRawStreamTrackerSimple(TString fileName = "./", Int_t maxEvent = 1000) | |
8a0dae7c | 298 | { |
299 | /// This routine shows how to use the high performance decoder's simple interface. | |
300 | ||
301 | TStopwatch timer; | |
302 | timer.Start(kTRUE); | |
303 | ||
ce22afdc | 304 | AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); |
8a0dae7c | 305 | |
306 | // raw stream | |
4f131d83 | 307 | AliMUONRawStreamTrackerHP rawStream(rawReader); |
8a0dae7c | 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 | ||
4f131d83 | 323 | rawStream.First(); |
8a0dae7c | 324 | |
4f131d83 | 325 | while ( rawStream.Next(busPatch,manuId,manuChannel,adc) ) |
8a0dae7c | 326 | { |
327 | printf("buspatch %5d manuI %4d channel %3d charge %4d\n", | |
328 | busPatch,manuId,manuChannel, adc); | |
329 | } | |
330 | } | |
331 | ||
332 | delete rawReader; | |
8a0dae7c | 333 | timer.Print(); |
334 | } | |
335 | ||
336 | ||
4b790a77 | 337 | void 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 | ||
4f131d83 | 351 | void MUONRawStreamTrackerSimple2(TString fileName = "./", Int_t maxEvent = 1000) |
8a0dae7c | 352 | { |
4f131d83 | 353 | /// This routine is an alternative to MUONRawStreamTrackerSimple() which is even faster. |
8a0dae7c | 354 | |
355 | TStopwatch timer; | |
356 | timer.Start(kTRUE); | |
357 | ||
ce22afdc | 358 | AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); |
8a0dae7c | 359 | |
360 | // raw stream | |
64c2397e | 361 | AliMUONRawStreamTrackerHP rawStream(rawReader); |
362 | rawStream.EnableRawReaderErrorLogger(); | |
8a0dae7c | 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 | ||
4f131d83 | 377 | rawStream.First(); |
8a0dae7c | 378 | const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL; |
4f131d83 | 379 | while ((buspatch = rawStream.Next()) != NULL) |
8a0dae7c | 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 | } | |
4b790a77 | 389 | |
390 | ShowErrors(*rawReader); | |
391 | ||
392 | delete rawReader; | |
393 | timer.Print(); | |
394 | } | |
395 | ||
396 | void 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 | |
64c2397e | 406 | AliMUONRawStreamTrackerHP rawStream(rawReader); |
407 | rawStream.EnableRawReaderErrorLogger(); | |
408 | rawStream.DisableWarnings(); | |
4b790a77 | 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); | |
8a0dae7c | 427 | |
428 | delete rawReader; | |
8a0dae7c | 429 | timer.Print(); |
430 | } | |
431 |