AliRoot Core  edcc906 (edcc906)
MUONRawStreamTrigger.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 
38 
39 
40 #if !defined(__CINT__) || defined(__MAKECINT__)
41 
42 // RAW includes
43 #include "AliRawReader.h"
44 #include "AliRawReaderFile.h"
45 #include "AliRawReaderRoot.h"
46 
47 // MUON includes
50 #include "AliMUONDarcHeader.h"
51 #include "AliMUONRegHeader.h"
52 #include "AliMUONLocalStruct.h"
53 #include "AliMUONDDLTrigger.h"
54 #include "AliMpTriggerCrate.h"
55 #include "AliMpDDLStore.h"
56 #include "AliMpCDB.h"
57 
58 #include "TStopwatch.h"
59 
60 
61 #endif
62 
63 void MUONRawStreamTrigger(Int_t maxEvent = 1, Int_t minDDL = 0, Int_t maxDDL = 1, TString fileName = "./")
64 {
65 
66  TStopwatch timer;
67  timer.Start(kTRUE);
68 
69  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
70 
71  // Load mapping
72  if ( ! AliMpCDB::LoadDDLStore() ) {
73  printf("Could not access mapping from OCDB !\n");
74  }
75 
76  // raw stream
77  AliMUONRawStreamTrigger* rawStream = new AliMUONRawStreamTrigger(rawReader);
78 
79  // set the number ofreg & local that are PRESENT in the rawdata file
80  // it's NOT the number to be read.
81  // default wise set to 8, 16 respectively.
82  // rawStream->SetMaxReg(2);
83  // rawStream->SetMaxLoc(xx);
84 
85  // containers
86  AliMUONDDLTrigger* ddlTrigger = 0x0;
87  AliMUONDarcHeader* darcHeader = 0x0;
88  AliMUONRegHeader* regHeader = 0x0;
89  AliMUONLocalStruct* localStruct = 0x0;
90 
91 
92  // Loop over events
93  Int_t iEvent = 0;
94 
95  while (rawReader->NextEvent()) {
96 
97  if (iEvent == maxEvent)
98  break;
99 
100  printf("Event %d\n",iEvent++);
101 
102  // read DDL while < 2 DDL
103  while(rawStream->NextDDL()) {
104 
105  if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
106  continue;
107 
108  printf("\niDDL %d\n", rawStream->GetDDL());
109 
110  ddlTrigger = rawStream->GetDDLTrigger();
111  darcHeader = ddlTrigger->GetDarcHeader();
112 
113  printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
114 
115  // loop over regional structures
116  Int_t nReg = darcHeader->GetRegHeaderEntries();
117  for(Int_t iReg = 0; iReg < nReg ;iReg++){ //REG loop
118 
119 // printf("RegionalId %d\n", iReg);
120 
121  regHeader = darcHeader->GetRegHeaderEntry(iReg);
122  // printf("Reg length %d\n",regHeader->GetHeaderLength());
123 
124  // crate info
126  GetTriggerCrate(rawStream->GetDDL(), iReg);
127 
128  // loop over local structures
129  Int_t nLocal = regHeader->GetLocalEntries();
130  for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) {
131 
132  localStruct = regHeader->GetLocalEntry(iLocal);
133 
134  Int_t iLocCard = crate->GetLocalBoardId(localStruct->GetId());
135 
136  if ( !iLocCard ) continue; // empty slot
137 
138  // check if trigger
139  if (localStruct->GetTriggerX()
140  || localStruct->GetTriggerY()) { // no empty data
141 
142  printf("LocalId %d\n", localStruct->GetId());
143 
144  Int_t loStripX = (Int_t)localStruct->GetXPos();
145  Int_t loStripY = (Int_t)localStruct->GetYPos();
146  Int_t loDev = (Int_t)localStruct->GetXDev();
147 
148  printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", iLocCard, loStripX, loStripY, loDev);
149 
150  }
151  } // iLocal
152  } // iReg
153  } // NextDDL
154  }// NextEvent
155 
156  delete rawReader;
157  delete rawStream;
158 
159  timer.Print();
160 
161 }
162 
163 
164 void MUONRawStreamTriggerHPExpert(Int_t maxEvent = 1, Int_t minDDL = 0, Int_t maxDDL = 1, TString fileName = "./")
165 {
167 
168  TStopwatch timer;
169  timer.Start(kTRUE);
170 
171  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
172 
173  // Load mapping
174  if ( ! AliMpCDB::LoadDDLStore() ) {
175  printf("Could not access mapping from OCDB !\n");
176  }
177 
178  // raw stream
179  AliMUONRawStreamTriggerHP* rawStream = new AliMUONRawStreamTriggerHP(rawReader);
180 
181  // Light weight interfaces to the raw data.
182  const AliMUONRawStreamTriggerHP::AliHeader* darcHeader = 0x0;
183  const AliMUONRawStreamTriggerHP::AliRegionalHeader* regHeader = 0x0;
184  const AliMUONRawStreamTriggerHP::AliLocalStruct* localStruct = 0x0;
185 
186  // Loop over events.
187  Int_t iEvent = 0;
188 
189  while (rawReader->NextEvent()) {
190 
191  if (iEvent == maxEvent)
192  break;
193 
194  printf("Event %d\n",iEvent++);
195 
196  // read DDL while < 2 DDL
197  while(rawStream->NextDDL()) {
198 
199  if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
200  continue;
201 
202  printf("\niDDL %d\n", rawStream->GetDDL());
203 
204  darcHeader = rawStream->GetHeaders();
205 
206  printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
207 
208  // loop over regional structures
209  Int_t nReg = (Int_t) rawStream->GetRegionalHeaderCount();
210  for(Int_t iReg = 0; iReg < nReg ;iReg++){ //REG loop
211 
212 // printf("RegionalId %d\n", iReg);
213 
214  regHeader = rawStream->GetRegionalHeader(iReg);
215 
216  // crate info
218  GetTriggerCrate(rawStream->GetDDL(), iReg);
219 
220  // loop over local structures
221  Int_t nLocal = rawStream->GetLocalStructCount(iReg);
222  for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) {
223 
224  localStruct = rawStream->GetLocalStruct(iReg, iLocal);
225 
226  Int_t iLocCard = crate->GetLocalBoardId(localStruct->GetId());
227 
228  if ( !iLocCard ) continue; // empty slot
229 
230  // check if trigger
231  if (localStruct->GetTriggerX()
232  || localStruct->GetTriggerY()) { // no empty data
233 
234  printf("LocalId %d\n", localStruct->GetId());
235 
236  Int_t loStripX = (Int_t)localStruct->GetXPos();
237  Int_t loStripY = (Int_t)localStruct->GetYPos();
238  Int_t loDev = (Int_t)localStruct->GetXDev();
239 
240  printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", iLocCard, loStripX, loStripY, loDev);
241 
242  }
243  } // iLocal
244  } // iReg
245  } // NextDDL
246  }// NextEvent
247 
248  delete rawReader;
249  delete rawStream;
250 
251  timer.Print();
252 
253 }
254 
255 
256 void MUONRawStreamTriggerHPExpert2(Int_t maxEvent = 1, Int_t minDDL = 0, Int_t maxDDL = 1, TString fileName = "./")
257 {
261 
262  TStopwatch timer;
263  timer.Start(kTRUE);
264 
265  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
266 
267  // Load mapping
268  if ( ! AliMpCDB::LoadDDLStore() ) {
269  printf("Could not access mapping from OCDB !\n");
270  }
271 
272  // raw stream
273  AliMUONRawStreamTriggerHP* rawStream = new AliMUONRawStreamTriggerHP(rawReader);
274 
275  // Light weight interfaces to the raw data.
276  const AliMUONRawStreamTriggerHP::AliHeader* darcHeader = 0x0;
277  const AliMUONRawStreamTriggerHP::AliRegionalHeader* regHeader = 0x0;
278  const AliMUONRawStreamTriggerHP::AliLocalStruct* localStruct = 0x0;
279 
280  // Loop over events.
281  Int_t iEvent = 0;
282 
283  while (rawReader->NextEvent()) {
284 
285  if (iEvent == maxEvent)
286  break;
287 
288  printf("Event %d\n",iEvent++);
289 
290  // read DDL while < 2 DDL
291  while(rawStream->NextDDL()) {
292 
293  if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
294  continue;
295 
296  printf("\niDDL %d\n", rawStream->GetDDL());
297 
298  darcHeader = rawStream->GetHeaders();
299 
300  printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
301 
302  // loop over regional structures
303  Int_t nReg = (Int_t) rawStream->GetRegionalHeaderCount();
304  for(Int_t iReg = 0; iReg < nReg ;iReg++){ //REG loop
305 
306 // printf("RegionalId %d\n", iReg);
307 
308  regHeader = rawStream->GetRegionalHeader(iReg);
309 
310  // crate info
312  GetTriggerCrate(rawStream->GetDDL(), iReg);
313 
314  // loop over local structures
315  Int_t nLocal = regHeader->GetLocalStructCount();
316  for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) {
317 
318  localStruct = regHeader->GetLocalStruct(iLocal);
319 
320  Int_t iLocCard = crate->GetLocalBoardId(localStruct->GetId());
321 
322  if ( !iLocCard ) continue; // empty slot
323 
324  // check if trigger
325  if (localStruct->GetTriggerX()
326  || localStruct->GetTriggerY()) { // no empty data
327 
328  printf("LocalId %d\n", localStruct->GetId());
329 
330  Int_t loStripX = (Int_t)localStruct->GetXPos();
331  Int_t loStripY = (Int_t)localStruct->GetYPos();
332  Int_t loDev = (Int_t)localStruct->GetXDev();
333 
334  printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", iLocCard, loStripX, loStripY, loDev);
335 
336  }
337  } // iLocal
338  } // iReg
339  } // NextDDL
340  }// NextEvent
341 
342  delete rawReader;
343  delete rawStream;
344 
345  timer.Print();
346 
347 }
348 
349 
350 void MUONRawStreamTriggerHPExpert3(Int_t maxEvent = 1, Int_t minDDL = 0, Int_t maxDDL = 1, TString fileName = "./")
351 {
355 
356  TStopwatch timer;
357  timer.Start(kTRUE);
358 
359  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
360 
361  // Load mapping
362  if ( ! AliMpCDB::LoadDDLStore() ) {
363  printf("Could not access mapping from OCDB !\n");
364  }
365 
366  // raw stream
367  AliMUONRawStreamTriggerHP* rawStream = new AliMUONRawStreamTriggerHP(rawReader);
368 
369  // Light weight interfaces to the raw data.
370  const AliMUONRawStreamTriggerHP::AliHeader* darcHeader = 0x0;
371  const AliMUONRawStreamTriggerHP::AliRegionalHeader* regHeader = 0x0;
372  const AliMUONRawStreamTriggerHP::AliLocalStruct* localStruct = 0x0;
373 
374  // Loop over events.
375  Int_t iEvent = 0;
376 
377  while (rawReader->NextEvent()) {
378 
379  if (iEvent == maxEvent)
380  break;
381 
382  printf("Event %d\n",iEvent++);
383 
384  // read DDL while < 2 DDL
385  while(rawStream->NextDDL()) {
386 
387  if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
388  continue;
389 
390  printf("\niDDL %d\n", rawStream->GetDDL());
391 
392  darcHeader = rawStream->GetHeaders();
393 
394  printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
395 
396  // loop over regional structures
397  Int_t iReg = 0;
398  regHeader = rawStream->GetFirstRegionalHeader();
399  while (regHeader != NULL)
400  {
401 // printf("RegionalId %d\n", iReg);
402 
403  regHeader = rawStream->GetRegionalHeader(iReg);
404 
405  // crate info
407  GetTriggerCrate(rawStream->GetDDL(), iReg);
408 
409  // loop over local structures
410  Int_t iLocal = 0;
411  localStruct = regHeader->GetFirstLocalStruct();
412  while (localStruct != NULL)
413  {
414  Int_t iLocCard = crate->GetLocalBoardId(localStruct->GetId());
415  if ( !iLocCard ) continue; // empty slot
416 
417  // check if trigger
418  if (localStruct->GetTriggerX()
419  || localStruct->GetTriggerY()) { // no empty data
420 
421  printf("LocalId %d\n", localStruct->GetId());
422 
423  Int_t loStripX = (Int_t)localStruct->GetXPos();
424  Int_t loStripY = (Int_t)localStruct->GetYPos();
425  Int_t loDev = (Int_t)localStruct->GetXDev();
426 
427  printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", iLocCard, loStripX, loStripY, loDev);
428 
429  }
430  iLocal++;
431  localStruct = localStruct->Next();
432  } // iLocal
433  iReg++;
434  regHeader = regHeader->Next();
435  } // iReg
436  } // NextDDL
437  }// NextEvent
438 
439  delete rawReader;
440  delete rawStream;
441 
442  timer.Print();
443 
444 }
445 
446 
447 void MUONRawStreamTriggerSimple(Int_t maxEvent = 1, TString fileName = "./")
448 {
451 
452  TStopwatch timer;
453  timer.Start(kTRUE);
454 
455  AliRawReader* rawReader = 0x0;
456 
457  if (fileName.EndsWith("/")) {
458  rawReader = new AliRawReaderFile(fileName);// DDL files
459  } else if (fileName.EndsWith(".root")) {
460  rawReader = new AliRawReaderRoot(fileName);
461  }
462 
463  // raw stream
464  AliMUONRawStreamTrigger* rawStream = new AliMUONRawStreamTrigger(rawReader);
465 
466  // set the number of reg & local that are PRESENT in the rawdata file
467  // it's NOT the number to be read.
468  // default wise set to 8, 16 respectively.
469  // rawStream->SetMaxReg(2);
470  // rawStream->SetMaxLoc(xx);
471 
472  UChar_t id;
473  UChar_t dec;
474  Bool_t trigY;
475  UChar_t yPos;
476  UChar_t sXDev;
477  UChar_t xDev;
478  UChar_t xPos;
479 
480  Bool_t triggerX;
481  Bool_t triggerY;
482 
483 
484  TArrayS xPattern;
485  TArrayS yPattern;
486 
487  // Loop over events
488  Int_t iEvent = 0;
489 
490  while (rawReader->NextEvent()) {
491 
492  if (iEvent == maxEvent)
493  break;
494 
495  printf("Event %d\n",iEvent++);
496 
497  rawStream->First();
498 
499  // read while there are digits
500  while( rawStream->Next(id, dec, trigY, yPos, sXDev, xDev, xPos,
501  triggerX, triggerY, xPattern, yPattern) )
502  {
503  if ( triggerX || triggerY ) // no empty data
504  printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", id, xPos, yPos, xDev);
505 
506  }// Next
507 
508  }// NextEvent
509 
510  delete rawReader;
511  delete rawStream;
512 
513  timer.Print();
514 
515 }
516 
517 
518 void MUONRawStreamTriggerHPSimple(Int_t maxEvent = 1, TString fileName = "./")
519 {
522 
523  TStopwatch timer;
524  timer.Start(kTRUE);
525 
526  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
527  AliMUONRawStreamTriggerHP* rawStream = new AliMUONRawStreamTriggerHP(rawReader);
528 
529  UChar_t id;
530  UChar_t dec;
531  Bool_t trigY;
532  UChar_t yPos;
533  UChar_t sXDev;
534  UChar_t xDev;
535  UChar_t xPos;
536  Bool_t triggerX;
537  Bool_t triggerY;
538  TArrayS xPattern;
539  TArrayS yPattern;
540 
541  // Loop over events
542  Int_t iEvent = 0;
543 
544  while (rawReader->NextEvent())
545  {
546 
547  if (iEvent == maxEvent)
548  break;
549 
550  printf("Event %d\n", iEvent++);
551 
552  rawStream->First();
553 
554  // read while there are digits
555  while ( rawStream->Next(id, dec, trigY, yPos, sXDev, xDev, xPos,
556  triggerX, triggerY, xPattern, yPattern) )
557  {
558  if ( triggerX || triggerY ) // no empty data
559  printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", id, xPos, yPos, xDev);
560  }// Next
561  }// NextEvent
562 
563  delete rawReader;
564  delete rawStream;
565 
566  timer.Print();
567 }
568 
569 
570 void MUONRawStreamTriggerHPSimple2(Int_t maxEvent = 1, TString fileName = "./")
571 {
574 
575  TStopwatch timer;
576  timer.Start(kTRUE);
577 
578  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
579  AliMUONRawStreamTriggerHP* rawStream = new AliMUONRawStreamTriggerHP(rawReader);
580 
582 
583  // Loop over events
584  Int_t iEvent = 0;
585 
586  while (rawReader->NextEvent())
587  {
588 
589  if (iEvent == maxEvent)
590  break;
591 
592  printf("Event %d\n", iEvent++);
593 
594  rawStream->First();
595 
596  // read while there are digits
597  while ( (localStruct = rawStream->Next()) != NULL )
598  {
599  if ( localStruct->GetTriggerX() || localStruct->GetTriggerY() ) // no empty data
600  printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n",
601  localStruct->GetId(),
602  localStruct->GetXPos(),
603  localStruct->GetYPos(),
604  localStruct->GetXDev()
605  );
606  }// Next
607  }// NextEvent
608 
609  delete rawReader;
610  delete rawStream;
611 
612  timer.Print();
613 }
614 
virtual Bool_t Next(UChar_t &id, UChar_t &dec, Bool_t &trigY, UChar_t &yPos, UChar_t &sXDev, UChar_t &xDev, UChar_t &xPos, Bool_t &triggerY, Bool_t &triggerX, TArrayS &xPattern, TArrayS &yPattern)
Advance one step in the iteration. Returns false if finished.
const AliHeader * GetHeaders() const
Returns the DARC and global headers plus scalars if they exist.
Light weight interface class to the local trigger card data.
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
UChar_t GetGlobalOutput() const
Return global output.
Int_t GetRegHeaderEntries() const
get entries
Rawdata local card structure for trigger.
UInt_t GetLocalStructCount(UInt_t reg) const
The class defines the properties of trigger crate.
AliMUONLocalStruct * GetLocalEntry(Int_t i) const
get entry
TStopwatch timer
Definition: kNNSpeed.C:15
virtual Bool_t NextDDL()
DDL iterator.
Int_t GetLocalBoardId(Int_t index) const
Light weight interface class to the DARC and global header data.
const AliRegionalHeader * GetRegionalHeader(UInt_t i) const
Return the i&#39;th regional header or NULL if not found.
static Bool_t LoadDDLStore(Bool_t warn=false)
Definition: AliMpCDB.cxx:149
Higher performance decoder stream class for reading MUON raw trigger data.
void MUONRawStreamTriggerHPSimple2(Int_t maxEvent=1, TString fileName="./")
MUON regional header for trigger.
TString fileName(const char *dir, int runNumber, const char *da, int i, const char *type)
const AliLocalStruct * GetLocalStruct(UInt_t i) const
Return the i&#39;th local trigger structure in this regional structure.
void MUONRawStreamTriggerHPExpert(Int_t maxEvent=1, Int_t minDDL=0, Int_t maxDDL=1, TString fileName="./")
void MUONRawStreamTriggerHPSimple(Int_t maxEvent=1, TString fileName="./")
Class for reading MUON raw digits.
static AliMpDDLStore * Instance(Bool_t warn=true)
Bool_t GetTriggerY() const
Return TriggerY.
void MUONRawStreamTriggerSimple(Int_t maxEvent=1, TString fileName="./")
AliMUONDDLTrigger * GetDDLTrigger() const
Return pointer for DDL structure.
void MUONRawStreamTrigger(Int_t maxEvent=1, Int_t minDDL=0, Int_t maxDDL=1, TString fileName="./")
const AliLocalStruct * GetFirstLocalStruct() const
Returns the first AliLocalStruct class in this regional structure.
const AliRegionalHeader * GetFirstRegionalHeader() const
Return the first regional structure header.
Int_t GetDDL() const
Return number of DDL.
Bool_t GetTriggerX() const
Return TriggerX.
MUON Darc header for Trigger.
Light weight interface class to the regional card header data.
virtual Int_t GetDDL() const
Return number of the current DDL being handled in the range [0..1] and -1 if no DDL set...
const AliLocalStruct * GetLocalStruct(UInt_t reg, UInt_t i) const
const AliRegionalHeader * Next() const
Return the next regional structure header.
AliMUONRegHeader * GetRegHeaderEntry(Int_t i) const
get entry
void First()
Initialize iterator.
void MUONRawStreamTriggerHPExpert2(Int_t maxEvent=1, Int_t minDDL=0, Int_t maxDDL=1, TString fileName="./")
UInt_t GetRegionalHeaderCount() const
Return the number of regional structures in the DDL payload.
UChar_t GetXPos() const
Return Xpos.
UChar_t GetId() const
Return Id.
UChar_t GetXDev() const
Get X deviation.
Int_t GetLocalEntries() const
get entries
void MUONRawStreamTriggerHPExpert3(Int_t maxEvent=1, Int_t minDDL=0, Int_t maxDDL=1, TString fileName="./")
const AliLocalStruct * Next() const
Return the next local trigger structure.
MUON DDL Trigger.
virtual Bool_t NextDDL()
DDL iterator.
UChar_t GetYPos() const
Return Upos.
UInt_t GetLocalStructCount() const
Returns the number of local trigger structures within this regional structure.