1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 /// \file MUONRawStreamTrigger.C
20 /// \brief Macro for reading trigger raw data
22 /// \author Ch. Finck, Subatech, April 2006
24 /// Added example routines to show how to use the interface of the high
25 /// performance decoder AliMUONRawStreamTriggerrHP.
26 /// -- Artur Szostak <artursz@iafrica.com>
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.
40 #if !defined(__CINT__) || defined(__MAKECINT__)
43 #include "AliRawReader.h"
44 #include "AliRawReaderFile.h"
45 #include "AliRawReaderRoot.h"
48 #include "AliMUONRawStreamTrigger.h"
49 #include "AliMUONRawStreamTriggerHP.h"
50 #include "AliMUONDarcHeader.h"
51 #include "AliMUONRegHeader.h"
52 #include "AliMUONLocalStruct.h"
53 #include "AliMUONDDLTrigger.h"
54 #include "AliMpTriggerCrate.h"
55 #include "AliMpDDLStore.h"
58 #include "TStopwatch.h"
63 void MUONRawStreamTrigger(Int_t maxEvent = 1, Int_t minDDL = 0, Int_t maxDDL = 1, TString fileName = "./")
69 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
72 if ( ! AliMpCDB::LoadDDLStore() ) {
73 printf("Could not access mapping from OCDB !\n");
77 AliMUONRawStreamTrigger* rawStream = new AliMUONRawStreamTrigger(rawReader);
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);
86 AliMUONDDLTrigger* ddlTrigger = 0x0;
87 AliMUONDarcHeader* darcHeader = 0x0;
88 AliMUONRegHeader* regHeader = 0x0;
89 AliMUONLocalStruct* localStruct = 0x0;
95 while (rawReader->NextEvent()) {
97 if (iEvent == maxEvent)
100 printf("Event %d\n",iEvent++);
102 // read DDL while < 2 DDL
103 while(rawStream->NextDDL()) {
105 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
108 printf("\niDDL %d\n", rawStream->GetDDL());
110 ddlTrigger = rawStream->GetDDLTrigger();
111 darcHeader = ddlTrigger->GetDarcHeader();
113 printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
115 // loop over regional structures
116 Int_t nReg = darcHeader->GetRegHeaderEntries();
117 for(Int_t iReg = 0; iReg < nReg ;iReg++){ //REG loop
119 // printf("RegionalId %d\n", iReg);
121 regHeader = darcHeader->GetRegHeaderEntry(iReg);
122 // printf("Reg length %d\n",regHeader->GetHeaderLength());
125 AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->
126 GetTriggerCrate(rawStream->GetDDL(), iReg);
128 // loop over local structures
129 Int_t nLocal = regHeader->GetLocalEntries();
130 for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) {
132 localStruct = regHeader->GetLocalEntry(iLocal);
134 Int_t iLocCard = crate->GetLocalBoardId(localStruct->GetId());
136 if ( !iLocCard ) continue; // empty slot
139 if (localStruct->GetTriggerX()
140 || localStruct->GetTriggerY()) { // no empty data
142 printf("LocalId %d\n", localStruct->GetId());
144 Int_t loStripX = (Int_t)localStruct->GetXPos();
145 Int_t loStripY = (Int_t)localStruct->GetYPos();
146 Int_t loDev = (Int_t)localStruct->GetXDev();
148 printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", iLocCard, loStripX, loStripY, loDev);
164 void MUONRawStreamTriggerHPExpert(Int_t maxEvent = 1, Int_t minDDL = 0, Int_t maxDDL = 1, TString fileName = "./")
166 /// Decodes raw MUON trigger data using the fast decoder.
171 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
174 if ( ! AliMpCDB::LoadDDLStore() ) {
175 printf("Could not access mapping from OCDB !\n");
179 AliMUONRawStreamTriggerHP* rawStream = new AliMUONRawStreamTriggerHP(rawReader);
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;
189 while (rawReader->NextEvent()) {
191 if (iEvent == maxEvent)
194 printf("Event %d\n",iEvent++);
196 // read DDL while < 2 DDL
197 while(rawStream->NextDDL()) {
199 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
202 printf("\niDDL %d\n", rawStream->GetDDL());
204 darcHeader = rawStream->GetHeaders();
206 printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
208 // loop over regional structures
209 Int_t nReg = (Int_t) rawStream->GetRegionalHeaderCount();
210 for(Int_t iReg = 0; iReg < nReg ;iReg++){ //REG loop
212 // printf("RegionalId %d\n", iReg);
214 regHeader = rawStream->GetRegionalHeader(iReg);
217 AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->
218 GetTriggerCrate(rawStream->GetDDL(), iReg);
220 // loop over local structures
221 Int_t nLocal = rawStream->GetLocalStructCount(iReg);
222 for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) {
224 localStruct = rawStream->GetLocalStruct(iReg, iLocal);
226 Int_t iLocCard = crate->GetLocalBoardId(localStruct->GetId());
228 if ( !iLocCard ) continue; // empty slot
231 if (localStruct->GetTriggerX()
232 || localStruct->GetTriggerY()) { // no empty data
234 printf("LocalId %d\n", localStruct->GetId());
236 Int_t loStripX = (Int_t)localStruct->GetXPos();
237 Int_t loStripY = (Int_t)localStruct->GetYPos();
238 Int_t loDev = (Int_t)localStruct->GetXDev();
240 printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", iLocCard, loStripX, loStripY, loDev);
256 void MUONRawStreamTriggerHPExpert2(Int_t maxEvent = 1, Int_t minDDL = 0, Int_t maxDDL = 1, TString fileName = "./")
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.
265 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
268 if ( ! AliMpCDB::LoadDDLStore() ) {
269 printf("Could not access mapping from OCDB !\n");
273 AliMUONRawStreamTriggerHP* rawStream = new AliMUONRawStreamTriggerHP(rawReader);
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;
283 while (rawReader->NextEvent()) {
285 if (iEvent == maxEvent)
288 printf("Event %d\n",iEvent++);
290 // read DDL while < 2 DDL
291 while(rawStream->NextDDL()) {
293 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
296 printf("\niDDL %d\n", rawStream->GetDDL());
298 darcHeader = rawStream->GetHeaders();
300 printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
302 // loop over regional structures
303 Int_t nReg = (Int_t) rawStream->GetRegionalHeaderCount();
304 for(Int_t iReg = 0; iReg < nReg ;iReg++){ //REG loop
306 // printf("RegionalId %d\n", iReg);
308 regHeader = rawStream->GetRegionalHeader(iReg);
311 AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->
312 GetTriggerCrate(rawStream->GetDDL(), iReg);
314 // loop over local structures
315 Int_t nLocal = regHeader->GetLocalStructCount();
316 for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) {
318 localStruct = regHeader->GetLocalStruct(iLocal);
320 Int_t iLocCard = crate->GetLocalBoardId(localStruct->GetId());
322 if ( !iLocCard ) continue; // empty slot
325 if (localStruct->GetTriggerX()
326 || localStruct->GetTriggerY()) { // no empty data
328 printf("LocalId %d\n", localStruct->GetId());
330 Int_t loStripX = (Int_t)localStruct->GetXPos();
331 Int_t loStripY = (Int_t)localStruct->GetYPos();
332 Int_t loDev = (Int_t)localStruct->GetXDev();
334 printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", iLocCard, loStripX, loStripY, loDev);
350 void MUONRawStreamTriggerHPExpert3(Int_t maxEvent = 1, Int_t minDDL = 0, Int_t maxDDL = 1, TString fileName = "./")
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.
359 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
362 if ( ! AliMpCDB::LoadDDLStore() ) {
363 printf("Could not access mapping from OCDB !\n");
367 AliMUONRawStreamTriggerHP* rawStream = new AliMUONRawStreamTriggerHP(rawReader);
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;
377 while (rawReader->NextEvent()) {
379 if (iEvent == maxEvent)
382 printf("Event %d\n",iEvent++);
384 // read DDL while < 2 DDL
385 while(rawStream->NextDDL()) {
387 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
390 printf("\niDDL %d\n", rawStream->GetDDL());
392 darcHeader = rawStream->GetHeaders();
394 printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
396 // loop over regional structures
398 regHeader = rawStream->GetFirstRegionalHeader();
399 while (regHeader != NULL)
401 // printf("RegionalId %d\n", iReg);
403 regHeader = rawStream->GetRegionalHeader(iReg);
406 AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->
407 GetTriggerCrate(rawStream->GetDDL(), iReg);
409 // loop over local structures
411 localStruct = regHeader->GetFirstLocalStruct();
412 while (localStruct != NULL)
414 Int_t iLocCard = crate->GetLocalBoardId(localStruct->GetId());
415 if ( !iLocCard ) continue; // empty slot
418 if (localStruct->GetTriggerX()
419 || localStruct->GetTriggerY()) { // no empty data
421 printf("LocalId %d\n", localStruct->GetId());
423 Int_t loStripX = (Int_t)localStruct->GetXPos();
424 Int_t loStripY = (Int_t)localStruct->GetYPos();
425 Int_t loDev = (Int_t)localStruct->GetXDev();
427 printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", iLocCard, loStripX, loStripY, loDev);
431 localStruct = localStruct->Next();
434 regHeader = regHeader->Next();
447 void MUONRawStreamTriggerSimple(Int_t maxEvent = 1, TString fileName = "./")
449 /// Reads the raw data in fileName, using a simplified interface (iterator
450 /// over local structure response).
455 AliRawReader* rawReader = 0x0;
457 if (fileName.EndsWith("/")) {
458 rawReader = new AliRawReaderFile(fileName);// DDL files
459 } else if (fileName.EndsWith(".root")) {
460 rawReader = new AliRawReaderRoot(fileName);
464 AliMUONRawStreamTrigger* rawStream = new AliMUONRawStreamTrigger(rawReader);
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);
490 while (rawReader->NextEvent()) {
492 if (iEvent == maxEvent)
495 printf("Event %d\n",iEvent++);
499 // read while there are digits
500 while( rawStream->Next(id, dec, trigY, yPos, sXDev, xDev, xPos,
501 triggerX, triggerY, xPattern, yPattern) )
503 if ( triggerX || triggerY ) // no empty data
504 printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", id, xPos, yPos, xDev);
518 void MUONRawStreamTriggerHPSimple(Int_t maxEvent = 1, TString fileName = "./")
520 /// Reads the raw data in fileName, using the simplified interface of the
521 /// high performance decoder.
526 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
527 AliMUONRawStreamTriggerHP* rawStream = new AliMUONRawStreamTriggerHP(rawReader);
544 while (rawReader->NextEvent())
547 if (iEvent == maxEvent)
550 printf("Event %d\n", iEvent++);
554 // read while there are digits
555 while ( rawStream->Next(id, dec, trigY, yPos, sXDev, xDev, xPos,
556 triggerX, triggerY, xPattern, yPattern) )
558 if ( triggerX || triggerY ) // no empty data
559 printf("iLocCard: %d, XPos: %d, YPos: %d Dev: %d\n", id, xPos, yPos, xDev);
570 void MUONRawStreamTriggerHPSimple2(Int_t maxEvent = 1, TString fileName = "./")
572 /// Reads the raw data in fileName, using the simplified interface of the
573 /// high performance decoder.
578 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
579 AliMUONRawStreamTriggerHP* rawStream = new AliMUONRawStreamTriggerHP(rawReader);
581 const AliMUONRawStreamTriggerHP::AliLocalStruct* localStruct;
586 while (rawReader->NextEvent())
589 if (iEvent == maxEvent)
592 printf("Event %d\n", iEvent++);
596 // read while there are digits
597 while ( (localStruct = rawStream->Next()) != NULL )
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()