]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/MUONRawStreamTrigger.C
Coding convention (data member comments after the data member definition)
[u/mrichter/AliRoot.git] / MUON / MUONRawStreamTrigger.C
CommitLineData
99e11065 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
e54bf126 16// $Id$
17
18/// \ingroup macros
19/// \file MUONRawStreamTrigger.C
20/// \brief Macro for reading trigger raw data
21///
22/// \author Ch. Finck, Subatech, April 2006
23///
1788245f 24/// Added example routines to show how to use the interface of the high
25/// performance decoder AliMUONRawStreamTriggerrHP.
26/// -- Artur Szostak <artursz@iafrica.com>
27///
e54bf126 28/// Implement "digits" iterator.
29/// This macro is interface with AliRawReader for RAW.
30/// The different stucture of the patload are readout and stored in TClonesArray
31/// with AliMUONRawStreamTrigger class.
32/// The macro just simply reads again the TClonesArray contents.
33/// The parameter of each structure could be seen in the container classes
34/// AliMUONDarcHeader, AliMUONRegHeader, AliMUONLocalStruct.
35/// The class AliMUONDDLTrigger manages the structure containers.
36/// The number of structures in the rawdata file could be set.
37/// The DATE format reading is no more supported please use the MUONTRGda code.
38
99e11065 39
40#if !defined(__CINT__) || defined(__MAKECINT__)
41
42// RAW includes
ce22afdc 43#include "AliRawReader.h"
1788245f 44#include "AliRawReaderFile.h"
45#include "AliRawReaderRoot.h"
99e11065 46
47// MUON includes
48#include "AliMUONRawStreamTrigger.h"
1788245f 49#include "AliMUONRawStreamTriggerHP.h"
99e11065 50#include "AliMUONDarcHeader.h"
51#include "AliMUONRegHeader.h"
52#include "AliMUONLocalStruct.h"
53#include "AliMUONDDLTrigger.h"
9d1949d2 54#include "AliMpTriggerCrate.h"
55#include "AliMpDDLStore.h"
a89c7656 56#include "AliMpCDB.h"
57
58#include "TStopwatch.h"
59
60
99e11065 61#endif
62
63898c67 63void MUONRawStreamTrigger(Int_t maxEvent = 1, Int_t minDDL = 0, Int_t maxDDL = 1, TString fileName = "./")
99e11065 64{
a89c7656 65
66 TStopwatch timer;
67 timer.Start(kTRUE);
68
ce22afdc 69 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
99e11065 70
a89c7656 71 // Load mapping
72 if ( ! AliMpCDB::LoadDDLStore() ) {
73 printf("Could not access mapping from OCDB !\n");
74 }
99e11065 75
76 // raw stream
77 AliMUONRawStreamTrigger* rawStream = new AliMUONRawStreamTrigger(rawReader);
78
a89c7656 79 // set the number ofreg & local that are PRESENT in the rawdata file
99e11065 80 // it's NOT the number to be read.
a89c7656 81 // default wise set to 8, 16 respectively.
82 // rawStream->SetMaxReg(2);
99e11065 83 // rawStream->SetMaxLoc(xx);
84
85 // containers
86 AliMUONDDLTrigger* ddlTrigger = 0x0;
87 AliMUONDarcHeader* darcHeader = 0x0;
88 AliMUONRegHeader* regHeader = 0x0;
89 AliMUONLocalStruct* localStruct = 0x0;
90
63898c67 91
99e11065 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
a89c7656 119// printf("RegionalId %d\n", iReg);
99e11065 120
121 regHeader = darcHeader->GetRegHeaderEntry(iReg);
122 // printf("Reg length %d\n",regHeader->GetHeaderLength());
123
9d1949d2 124 // crate info
125 AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->
126 GetTriggerCrate(rawStream->GetDDL(), iReg);
63898c67 127
99e11065 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
9d1949d2 134 Int_t iLocCard = crate->GetLocalBoardId(localStruct->GetId());
135
136 if ( !iLocCard ) continue; // empty slot
137
99e11065 138 // check if trigger
a89c7656 139 if (localStruct->GetTriggerX()
8d1deca2 140 || localStruct->GetTriggerY()) { // no empty data
99e11065 141
a89c7656 142 printf("LocalId %d\n", localStruct->GetId());
63898c67 143
a89c7656 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
63898c67 148 printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", iLocCard, loStripX, loStripY, loDev);
a89c7656 149
99e11065 150 }
151 } // iLocal
152 } // iReg
153 } // NextDDL
154 }// NextEvent
155
156 delete rawReader;
157 delete rawStream;
a89c7656 158
159 timer.Print();
160
161}
162
163
1788245f 164void MUONRawStreamTriggerHPExpert(Int_t maxEvent = 1, Int_t minDDL = 0, Int_t maxDDL = 1, TString fileName = "./")
165{
166 /// Decodes raw MUON trigger data using the fast decoder.
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
217 AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->
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
256void MUONRawStreamTriggerHPExpert2(Int_t maxEvent = 1, Int_t minDDL = 0, Int_t maxDDL = 1, TString fileName = "./")
257{
258 /// Decodes raw MUON trigger data using the fast decoder.
259 /// This method shows a slightly different method of iteration over the
260 /// data using the AliMUONRawStreamTriggerHP interface.
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
311 AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->
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
350void MUONRawStreamTriggerHPExpert3(Int_t maxEvent = 1, Int_t minDDL = 0, Int_t maxDDL = 1, TString fileName = "./")
351{
352 /// Decodes raw MUON trigger data using the fast decoder.
353 /// This method shows a jet another method of iteration over the
354 /// data using the AliMUONRawStreamTriggerHP interface.
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
406 AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->
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
a89c7656 447void MUONRawStreamTriggerSimple(Int_t maxEvent = 1, TString fileName = "./")
448{
449 /// Reads the raw data in fileName, using a simplified interface (iterator
450 /// over local structure response).
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
99e11065 515}
1788245f 516
517
518void MUONRawStreamTriggerHPSimple(Int_t maxEvent = 1, TString fileName = "./")
519{
520 /// Reads the raw data in fileName, using the simplified interface of the
521 /// high performance decoder.
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
570void MUONRawStreamTriggerHPSimple2(Int_t maxEvent = 1, TString fileName = "./")
571{
572 /// Reads the raw data in fileName, using the simplified interface of the
573 /// high performance decoder.
574
575 TStopwatch timer;
576 timer.Start(kTRUE);
577
578 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
579 AliMUONRawStreamTriggerHP* rawStream = new AliMUONRawStreamTriggerHP(rawReader);
580
581 const AliMUONRawStreamTriggerHP::AliLocalStruct* localStruct;
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