AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MUONRawStreamTracker.C
Go to the documentation of this file.
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 
35 
36 
37 #if !defined(__CINT__) || defined(__MAKECINT__)
38 
39 // RAW includes
40 #include "AliRawReader.h"
41 
42 // MUON includes
44 #include "TStopwatch.h"
45 #include "AliRawDataErrorLog.h"
46 #include "Riostream.h"
47 #include "AliMUONLogger.h"
48 
49 #endif
50 
51 void MUONRawStreamTrackerExpert(TString fileName = "./", Int_t maxEvent = 1000,
52  Int_t minDDL = 0, Int_t maxDDL = 19)
53 {
55 
56  TStopwatch timer;
57  timer.Start(kTRUE);
58 
59  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
60 
61  // raw stream
62  AliMUONRawStreamTrackerHP rawStream(rawReader);
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
81  while(rawStream.NextDDL()) {
82 
83  if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
84  continue;
85 
86  printf("\niDDL %d\n", rawStream.GetDDL());
87 
88  // loop over block structure
89  Int_t nBlock = rawStream.GetBlockCount();
90  for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
91 
92  blkHeader = rawStream.GetBlockHeader(iBlock);
93  printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
94 
95  // loop over DSP structure
96  Int_t nDsp = rawStream.GetDspCount(iBlock);
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
103  Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
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;
127  timer.Print();
128 }
129 
130 
131 void MUONRawStreamTrackerExpert2(TString fileName = "./", Int_t maxEvent = 1000,
132  Int_t minDDL = 0, Int_t maxDDL = 19)
133 {
136 
137  TStopwatch timer;
138  timer.Start(kTRUE);
139 
140  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
141 
142  // raw stream
143  AliMUONRawStreamTrackerHP rawStream(rawReader);
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
162  while(rawStream.NextDDL()) {
163 
164  if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
165  continue;
166 
167  printf("\niDDL %d\n", rawStream.GetDDL());
168 
169  // loop over block structure
170  Int_t nBlock = rawStream.GetBlockCount();
171  for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
172 
173  blkHeader = rawStream.GetBlockHeader(iBlock);
174  printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
175 
176  // loop over DSP structure
177  Int_t nDsp = rawStream.GetDspCount(iBlock);
178  for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
179 
180  dspHeader = rawStream.GetDspHeader(iBlock, iDsp);
181  printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
182 
183  // loop over BusPatch structure
184  Int_t nBusPatch = rawStream.GetBusPatchCount(iBlock, iDsp);
185  for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
186 
187  busStruct = rawStream.GetBusPatch(iBlock, iDsp, iBusPatch);
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;
208  timer.Print();
209 }
210 
211 
212 void MUONRawStreamTrackerExpert3(TString fileName = "./", Int_t maxEvent = 1000,
213  Int_t minDDL = 0, Int_t maxDDL = 19)
214 {
217 
218  TStopwatch timer;
219  timer.Start(kTRUE);
220 
221  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
222 
223  // raw stream
224  AliMUONRawStreamTrackerHP rawStream(rawReader);
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
243  while(rawStream.NextDDL()) {
244 
245  if (rawStream.GetDDL() < minDDL || rawStream.GetDDL() > maxDDL)
246  continue;
247 
248  printf("\niDDL %d\n", rawStream.GetDDL());
249 
250  // loop over block structure
251  Int_t iBlock = 0;
252  blkHeader = rawStream.GetFirstBlockHeader();
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;
294  timer.Print();
295 }
296 
297 
298 void MUONRawStreamTrackerSimple(TString fileName = "./", Int_t maxEvent = 1000)
299 {
301 
302  TStopwatch timer;
303  timer.Start(kTRUE);
304 
305  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
306 
307  // raw stream
308  AliMUONRawStreamTrackerHP rawStream(rawReader);
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 
324  rawStream.First();
325 
326  while ( rawStream.Next(busPatch,manuId,manuChannel,adc) )
327  {
328  printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
329  busPatch,manuId,manuChannel, adc);
330  }
331  }
332 
333  delete rawReader;
334  timer.Print();
335 }
336 
337 
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 
352 void MUONRawStreamTrackerSimple2(TString fileName = "./", Int_t maxEvent = 1000)
353 {
355 
356  TStopwatch timer;
357  timer.Start(kTRUE);
358 
359  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
360 
361  // raw stream
362  AliMUONRawStreamTrackerHP rawStream(rawReader);
363  rawStream.EnableRawReaderErrorLogger();
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 
378  rawStream.First();
379  const AliMUONRawStreamTrackerHP::AliBusPatch* buspatch = NULL;
380  while ((buspatch = rawStream.Next()) != NULL)
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  }
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 {
400 
401  TStopwatch timer;
402  timer.Start(kTRUE);
403 
404  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
405 
406  // raw stream
407  AliMUONRawStreamTrackerHP rawStream(rawReader);
408  rawStream.DisableWarnings();
409 
410  AliMUONLogger logger;
411 
412  rawStream.EnableMUONErrorLogger();
413  rawStream.SetMUONErrorLogger(&logger);
414  rawStream.SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kMediumErrorDetail);
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  }
430 
431  ++iEvent;
432  }
433 
434  logger.Print();
435 
436 // ShowErrors(*rawReader);
437 
438  delete rawReader;
439  timer.Print();
440 }
441 
A high performance stream decoder for muon tracking DDL streams.
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
void Print(Option_t *opt="") const
void MUONRawStreamTrackerExpert(TString fileName="./", Int_t maxEvent=1000, Int_t minDDL=0, Int_t maxDDL=19)
UInt_t GetDataCount() const
Returns the number of raw data words within this bus patch.
Light weight interface class to the block header data.
const AliDspHeader * GetFirstDspHeader() const
Returns the first AliDspHeader class in this block.
Int_t GetLength() const
Return length of raw data.
Int_t GetErrorWord() const
Return Error word.
void Print() const
Print the contents of the header to screen.
Light weight interface class to the DSP header data.
A logger that keeps track of the number of times a message appeared.
Definition: AliMUONLogger.h:29
Int_t GetBusPatchId() const
Return bus patch id.
void MUONRawStreamTrackerErrorCount(TString fileName="collection://filelist", Int_t maxEvent=-1)
const UInt_t * GetData() const
Return raw digit data.
const AliBusPatch * GetBusPatch(UInt_t i) const
Return the i'th bus patch in this DSP.
Int_t GetTotalLength() const
Return total length of block structure (w/o padding word)
void ShowErrors(const AliRawReader &rawReader)
const AliDspHeader * Next() const
Return the next DSP header.
const AliBusPatch * GetFirstBusPatch() const
Returns the first AliBusPatch class in this DSP.
Int_t GetTotalLength() const
Return total length of block structure.
Logs minimal information in the error messages.
void MUONRawStreamTrackerExpert3(TString fileName="./", Int_t maxEvent=1000, Int_t minDDL=0, Int_t maxDDL=19)
UShort_t GetManuId(UInt_t n) const
Returns the MANU ID of the n'th raw data word.
UShort_t GetCharge(UInt_t n) const
Returns the charge/signal of the n'th raw data word.
Light weight interface class to the bus patch data.
void MUONRawStreamTrackerSimple2(TString fileName="./", Int_t maxEvent=1000)
void MUONRawStreamTrackerExpert2(TString fileName="./", Int_t maxEvent=1000, Int_t minDDL=0, Int_t maxDDL=19)
const AliBlockHeader * Next() const
Return the next block header.
const AliDspHeader * GetDspHeader(UInt_t i) const
Return the i'th DSP in this block.
UChar_t GetChannelId(UInt_t n) const
Returns the channel ID of the n'th raw data word.
Declaration of the high performance decoder for muon trigger chamber raw streams. ...
const AliBusPatch * Next() const
Return the next bus patch header.
void MUONRawStreamTrackerSimple(TString fileName="./", Int_t maxEvent=1000)