Adding a simplified interface Next(buspatch,manu,channel,charge) to iterate over...
[u/mrichter/AliRoot.git] / MUON / MUONRawStreamTracker.C
CommitLineData
6068f9cf 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//
17// Macro for reading tracker raw data
18// Ch. Finck, Subatech Febuary
19//
20
21#if !defined(__CINT__) || defined(__MAKECINT__)
22
23// RAW includes
24#include "AliRawReaderDate.h"
25#include "AliRawReaderFile.h"
26#include "AliRawReaderRoot.h"
27
28// MUON includes
29#include "AliMUONRawStreamTracker.h"
30#include "AliMUONDspHeader.h"
31#include "AliMUONBlockHeader.h"
32#include "AliMUONBusStruct.h"
33#include "AliMUONDDLTracker.h"
34
35#endif
36
37
38// Macro to read rawdata for tracker
39// Ch. Finck, Subatech, April. 2006
40//
41// This macro is interface with AliRawReader for RAW
42// The different stucture of the patload are readout and stored in TClonesArray
43// with AliMUONRawStreamTracker classe.
44// The macro just simpy read again the TClonesArray contents.
45// The parameter of each structure could be seen in the container classes
46// AliMUONBlockHeader, AliMUONBlockHeader, AliMUONBusStruct.
47// The class AliMUONDDLTracker manages the structure containers.
48// The number of structures in the rawdata file could be set.
49
50void MUONRawStreamTracker(Int_t maxEvent = 1000, Int_t minDDL = 0, Int_t maxDDL = 19, TString fileName = "./")
51{
52 AliRawReader* rawReader = 0x0;
53
54 // check extention to choose the rawdata file format
55 if (fileName.EndsWith("/")) {
56 rawReader = new AliRawReaderFile(fileName); // DDL files
57 } else if (fileName.EndsWith(".root")) {
58 rawReader = new AliRawReaderRoot(fileName);
59 } else if (!fileName.IsNull()) {
60 rawReader = new AliRawReaderDate(fileName); // DATE file
61 }
62
63 // raw stream
64 AliMUONRawStreamTracker* rawStream = new AliMUONRawStreamTracker(rawReader);
65
66 // set the number of DDL block Dsp & buspatch structures that are PRESENT in the rawdata file
67 // it's NOT the number to be read.
68 // default wise set to 20, 2, 5 ans 5 respectively.
69 // rawStream->SetMaxDDL(xx);
70 // rawStream->SetMaxBlock(xx);
71 // rawStream->SetMaxDsp(xx);
72 // rawStream->SetMaxBus(xx);
73
74 // containers
75 AliMUONDDLTracker* ddlTracker = 0x0;
76 AliMUONBlockHeader* blkHeader = 0x0;
77 AliMUONDspHeader* dspHeader = 0x0;
78 AliMUONBusStruct* busStruct = 0x0;
79
80 // Loop over events
81 Int_t iEvent = 0;
82 Int_t dataSize;
83
84 while (rawReader->NextEvent()) {
85
86 if (iEvent == maxEvent)
87 break;
88
89 printf("Event %d\n",iEvent++);
90
91 // read DDL while < 20 DDL
92 while(rawStream->NextDDL()) {
93
94 if (rawStream->GetDDL() < minDDL || rawStream->GetDDL() > maxDDL)
95 continue;
96
97 printf("\niDDL %d\n", rawStream->GetDDL());
98
99 ddlTracker = rawStream->GetDDLTracker();
100
101 // loop over block structure
102 Int_t nBlock = ddlTracker->GetBlkHeaderEntries();
103 for(Int_t iBlock = 0; iBlock < nBlock ;iBlock++){
104
105 blkHeader = ddlTracker->GetBlkHeaderEntry(iBlock);
106 printf("Block Total length %d\n",blkHeader->GetTotalLength());
107
108 // loop over DSP structure
109 Int_t nDsp = blkHeader->GetDspHeaderEntries();
110 for(Int_t iDsp = 0; iDsp < nDsp ;iDsp++){ //DSP loop
111
112 dspHeader = blkHeader->GetDspHeaderEntry(iDsp);
113 // printf("Dsp length %d even word %d\n",dspHeader->GetTotalLength(), dspHeader->GetEventWord());
114
115 // loop over BusPatch structure
116 Int_t nBusPatch = dspHeader->GetBusPatchEntries();
117 for(Int_t iBusPatch = 0; iBusPatch < nBusPatch; iBusPatch++) {
118
119 busStruct = dspHeader->GetBusPatchEntry(iBusPatch);
120
121 printf("busPatchId %d", busStruct->GetBusPatchId());
122 printf(" BlockId %d", busStruct->GetBlockId());
123 printf(" DspId %d\n", busStruct->GetDspId());
124
125 // loop over data
126 dataSize = busStruct->GetLength();
127 for (Int_t iData = 0; iData < dataSize; iData++) {
128
129 Int_t manuId = busStruct->GetManuId(iData);
130 Int_t channelId = busStruct->GetChannelId(iData);
131 Int_t charge = busStruct->GetCharge(iData);
132 printf("manuId: %d, channelId: %d charge: %d\n", manuId,
133 channelId, charge);
134
135 } // iData
136 } // iBusPatch
137 } // iDsp
138 } // iBlock
139 } // NextDDL
140 }// NextEvent
141
142 delete rawReader;
143 delete rawStream;
144}