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 **************************************************************************/
17 // Macro for reading tracker raw data
18 // Ch. Finck, Subatech Febuary
21 #if !defined(__CINT__) || defined(__MAKECINT__)
24 #include "AliRawReaderDate.h"
25 #include "AliRawReaderFile.h"
26 #include "AliRawReaderRoot.h"
29 #include "AliMUONRawStreamTracker.h"
30 #include "AliMUONDspHeader.h"
31 #include "AliMUONBlockHeader.h"
32 #include "AliMUONBusStruct.h"
33 #include "AliMUONDDLTracker.h"
35 #include "TStopwatch.h"
39 // Macro to read rawdata for tracker
40 // Ch. Finck, Subatech, April. 2006
42 // This macro is interfaced with AliRawReader for RAW
44 // There are 2 ways of reading the data : one where each intermediate structure
45 // (block, dsp, buspatch) is looped over, and one, using an iterator, where
46 // we're directly accessing the pad informations (charge).
48 // The different stucture of the payload are readout and stored in TClonesArray
49 // with AliMUONRawStreamTracker classe.
50 // The macro just simpy read again the TClonesArray contents.
51 // The parameter of each structure could be seen in the container classes
52 // AliMUONBlockHeader, AliMUONBlockHeader, AliMUONBusStruct.
53 // The class AliMUONDDLTracker manages the structure containers.
54 // The number of structures in the rawdata file could be set.
58 void MUONRawStreamTrackerExpert(TString fileName = "./", Int_t maxEvent = 1000,
59 Int_t minDDL = 0, Int_t maxDDL = 19)
61 /// Reads the data from fileName, using an "expert" mode where all substructures
67 AliRawReader* rawReader = 0x0;
69 // check extention to choose the rawdata file format
70 if (fileName.EndsWith("/")) {
71 rawReader = new AliRawReaderFile(fileName); // DDL files
72 } else if (fileName.EndsWith(".root")) {
73 rawReader = new AliRawReaderRoot(fileName);
74 } else if (!fileName.IsNull()) {
75 rawReader = new AliRawReaderDate(fileName); // DATE file
79 AliMUONRawStreamTracker* rawStream = new AliMUONRawStreamTracker(rawReader);
81 // set the number of DDL block Dsp & buspatch structures that are PRESENT in the rawdata file
82 // it's NOT the number to be read.
83 // default wise set to 20, 2, 5 ans 5 respectively.
84 // rawStream->SetMaxDDL(xx);
85 // rawStream->SetMaxBlock(xx);
86 // rawStream->SetMaxDsp(xx);
87 // rawStream->SetMaxBus(xx);
90 AliMUONDDLTracker* ddlTracker = 0x0;
91 AliMUONBlockHeader* blkHeader = 0x0;
92 AliMUONDspHeader* dspHeader = 0x0;
93 AliMUONBusStruct* busStruct = 0x0;
99 while (rawReader->NextEvent()) {
101 if (iEvent == maxEvent)
104 printf("Event %d\n",iEvent++);
106 // read DDL while < 20 DDL
107 while(rawStream->NextDDL()) {
109 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
112 printf("\niDDL %d\n", rawStream->GetDDL());
114 ddlTracker = rawStream->GetDDLTracker();
116 // loop over block structure
117 Int_t nBlock = ddlTracker->GetBlkHeaderEntries();
118 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
120 blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock);
121 printf("Block %d Total length %d\n",iBlock,blkHeader->GetTotalLength());
123 // loop over DSP structure
124 Int_t nDsp = blkHeader->GetDspHeaderEntries();
125 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
127 dspHeader = blkHeader->GetDspHeaderEntry(iDsp);
128 printf("Dsp %d length %d error word %d\n",iDsp,dspHeader->GetTotalLength(), dspHeader->GetErrorWord());
130 // loop over BusPatch structure
131 Int_t nBusPatch = dspHeader->GetBusPatchEntries();
132 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
134 busStruct = dspHeader->GetBusPatchEntry(iBusPatch);
136 // printf("busPatchId %d", busStruct->GetBusPatchId());
137 // printf(" BlockId %d", busStruct->GetBlockId());
138 // printf(" DspId %d\n", busStruct->GetDspId());
141 dataSize = busStruct->GetLength();
142 for (Int_t iData = 0; iData < dataSize; iData++) {
144 Int_t manuId = busStruct->GetManuId(iData);
145 Int_t channelId = busStruct->GetChannelId(iData);
146 Int_t charge = busStruct->GetCharge(iData);
147 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
148 busStruct->GetBusPatchId(),
163 void MUONRawStreamTrackerSimple(TString fileName, Int_t maxEvent)
165 /// Reads the raw data in fileName, using a simplified interface (iterator
170 AliRawReader* rawReader = 0x0;
172 // check extention to choose the rawdata file format
173 if (fileName.EndsWith("/")) {
174 rawReader = new AliRawReaderFile(fileName); // DDL files
175 } else if (fileName.EndsWith(".root")) {
176 rawReader = new AliRawReaderRoot(fileName);
177 } else if (!fileName.IsNull()) {
178 rawReader = new AliRawReaderDate(fileName); // DATE file
182 AliMUONRawStreamTracker* rawStream = new AliMUONRawStreamTracker(rawReader);
187 while (rawReader->NextEvent()) {
189 if (iEvent == maxEvent)
192 printf("Event %d\n",iEvent++);
195 UShort_t manuId, adc;
200 while ( rawStream->Next(busPatch,manuId,manuChannel,adc) )
202 printf("buspatch %5d manuI %4d channel %3d charge %4d\n",
203 busPatch,manuId,manuChannel, adc);