]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONPayloadTracker.cxx
Overlaps fixed
[u/mrichter/AliRoot.git] / MUON / AliMUONPayloadTracker.cxx
CommitLineData
939ae4b2 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///////////////////////////////////////////////////////////////////////////////
18///
19/// Class Payload
20///
21/// Decodes rawdata from buffer and stores in TClonesArray.
22///
23/// First version implement for Tracker
24///
25///////////////////////////////////////////////////////////////////////////////
26
27#include "AliMUONPayloadTracker.h"
28
29#include "AliRawReader.h"
30#include "AliRawDataHeader.h"
31#include "AliLog.h"
32
33#include "AliMUONDspHeader.h"
34#include "AliMUONBlockHeader.h"
35#include "AliMUONBusStruct.h"
36#include "AliMUONDDLTracker.h"
37
38ClassImp(AliMUONPayloadTracker)
39
40AliMUONPayloadTracker::AliMUONPayloadTracker()
41 : TObject(),
42 fMaxBlock(2),
43 fMaxDsp(5),
44 fMaxBus(5)
45{
46 //
47 // create an object to read MUON raw digits
48 // Default ctor for monitoring purposes
49 //
50 fBusPatchManager = new AliMpBusPatch();
51 fBusPatchManager->ReadBusPatchFile();
52
53 fDDLTracker = new AliMUONDDLTracker();
54 fBusStruct = new AliMUONBusStruct();
55 fBlockHeader = new AliMUONBlockHeader();
56 fDspHeader = new AliMUONDspHeader();
57}
58
59//_________________________________________________________________
60AliMUONPayloadTracker::AliMUONPayloadTracker(const AliMUONPayloadTracker& stream) :
61 TObject(stream)
62{
63 //
64 // copy ctor
65 //
66 AliFatal("copy constructor not implemented");
67}
68
69//______________________________________________________________________
70AliMUONPayloadTracker& AliMUONPayloadTracker::operator = (const AliMUONPayloadTracker&
71 /* stream */)
72{
73 //
74 // assignment operator
75 //
76 AliFatal("assignment operator not implemented");
77 return *this;
78}
79
80
81//___________________________________
82AliMUONPayloadTracker::~AliMUONPayloadTracker()
83{
84 //
85 // clean up
86 //
87 delete fBusPatchManager;
88 delete fDDLTracker;
89 delete fBusStruct;
90 delete fBlockHeader;
91 delete fDspHeader;
92}
93
94//______________________________________________________
95Bool_t AliMUONPayloadTracker::Decode(UInt_t* buffer, Int_t ddl)
96{
97 // reading tracker DDL
98 // store buspatch info into Array
99 // store only non-empty structures (buspatch info with datalength !=0)
100
101
102 //Read Header Size of DDL,Block,DSP and BusPatch
103 Int_t kBlockHeaderSize = fBlockHeader->GetHeaderLength();
104 Int_t kDspHeaderSize = fDspHeader->GetHeaderLength();
105 Int_t kBusPatchHeaderSize = fBusStruct->GetHeaderLength();
106
107 // Int_t totalDDLSize;
108 Int_t totalBlockSize;
109 Int_t totalDspSize;
110 Int_t totalBusPatchSize;
111 Int_t dataSize;
112
113
114 Int_t iBusPerDSP[5]; // number of bus patches per DSP
115 Int_t iDspMax; // number max of DSP per block
116
117 // minimum data size (only header's)
118 // Int_t blankDDLSize;
119 Int_t blankBlockSize;
120 Int_t blankDspSize;
121
122 AliDebug(3, Form("DDL Number %d\n", ddl ));
123
124 // getting DSP info
125 fBusPatchManager->GetDspInfo(ddl/2, iDspMax, iBusPerDSP);
126
127 // Each DDL is made with 2 Blocks each of which consists of 5 DSP's at most
128 // and each of DSP has at most 5 buspatches.
129 // This information is used to calculate the size of headers (Block and DSP)
130 // which has empty data.
131
132 // blankDDLSize = 2*kBlockHeaderSize + 2*iDspMax*kDspHeaderSize;
133 blankBlockSize = kBlockHeaderSize + iDspMax*kDspHeaderSize;
134 // totalDDLSize = sizeof(buffer)/4;
135
136 for (Int_t i = 0; i < iDspMax; i++) {
137 // blankDDLSize += 2*iBusPerDSP[i]*kBusPatchHeaderSize;
138 blankBlockSize += iBusPerDSP[i]*kBusPatchHeaderSize;
139 }
140
141 // Compare the DDL header with an empty DDL header size to read the file
142 // if(totalDDLSize > blankDDLSize) { //should not happen in real life
143
144 // indexes
145 Int_t indexDsp;
146 Int_t indexBusPatch;
147 Int_t index = 0;
148
149 for(Int_t iBlock = 0; iBlock < 2 ;iBlock++){ // loop over 2 blocks
150
151 // copy within padding words
152 memcpy(fBlockHeader->GetHeader(),&buffer[index], (kBlockHeaderSize+1)*4);
153
154 totalBlockSize = fBlockHeader->GetTotalLength();
155
156 fDDLTracker->AddBlkHeader(*fBlockHeader);
157
158 if (fBlockHeader->GetPadding() == 0xDEAD) // skipping padding word
159 index++;
160
161 if(totalBlockSize > blankBlockSize) { // compare block header
162 index += kBlockHeaderSize;
163
164 for(Int_t iDsp = 0; iDsp < iDspMax ;iDsp++){ //DSP loop
165
166 if (iDsp > fMaxDsp) break;
167
168 memcpy(fDspHeader->GetHeader(),&buffer[index], kDspHeaderSize*4);
169
170 totalDspSize = fDspHeader->GetTotalLength();
171 indexDsp = index;
172
173 blankDspSize = kDspHeaderSize + iBusPerDSP[iDsp]*kBusPatchHeaderSize; // no data just header
174
175 fDDLTracker->AddDspHeader(*fDspHeader, iBlock);
176
177 if(totalDspSize > blankDspSize) { // Compare DSP Header
178 index += kDspHeaderSize;
179
180 for(Int_t iBusPatch = 0; iBusPatch < iBusPerDSP[iDsp]; iBusPatch++) {
181
182 if (iBusPatch > fMaxBus) break;
183
184 //copy buffer into header structure
185 memcpy(fBusStruct->GetBusPatchHeader(), &buffer[index], kBusPatchHeaderSize*4);
186
187 totalBusPatchSize = fBusStruct->GetTotalLength();
188 indexBusPatch = index;
189
190 //Check Buspatch header, not empty events
191 if(totalBusPatchSize > kBusPatchHeaderSize) {
192
193 index += kBusPatchHeaderSize;
194 dataSize = fBusStruct->GetLength();
195 Int_t bufSize = fBusStruct->GetBufSize();
196
197 if(dataSize > 0) { // check data present
198 if (dataSize > bufSize) fBusStruct->SetAlloc(dataSize);
199
200 //copy buffer into data structure
201 memcpy(fBusStruct->GetData(), &buffer[index], dataSize*4);
202 fBusStruct->SetBlockId(iBlock); // could be usefull in future applications ?
203 fBusStruct->SetDspId(iDsp);
204 fDDLTracker->AddBusPatch(*fBusStruct, iBlock, iDsp);
205
206 } // dataSize test
207
208 } // testing buspatch
209
210 index = indexBusPatch + totalBusPatchSize;
211
212 } //buspatch loop
213
214 } // dsp test
215
216 index = indexDsp + totalDspSize;
217
218 } // dsp loop
219
220 } //block test
221
222 index = totalBlockSize;
223
224 } //block loop
225
226 // } //loop checking the header size of DDL
227
228 return kTRUE;
229}
230
231//______________________________________________________
232void AliMUONPayloadTracker::ResetDDL()
233{
234 // reseting TClonesArray
235 // after each DDL
236 //
237 fDDLTracker->GetBlkHeaderArray()->Delete();
238}
239
240//______________________________________________________
241void AliMUONPayloadTracker::SetMaxBlock(Int_t blk)
242{
243 // set regional card number
244 if (blk > 2) blk = 2;
245 fMaxBlock = blk;
246}