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 ///////////////////////////////////////////////////////////////////////////////
21 /// Decodes rawdata from buffer and stores in TClonesArray.
23 /// First version implement for Tracker
25 ///////////////////////////////////////////////////////////////////////////////
27 #include "AliMUONPayloadTracker.h"
29 #include "AliRawReader.h"
30 #include "AliRawDataHeader.h"
33 #include "AliMUONDspHeader.h"
34 #include "AliMUONBlockHeader.h"
35 #include "AliMUONBusStruct.h"
36 #include "AliMUONDDLTracker.h"
38 ClassImp(AliMUONPayloadTracker)
40 AliMUONPayloadTracker::AliMUONPayloadTracker()
47 // create an object to decode MUON payload
50 fDDLTracker = new AliMUONDDLTracker();
51 fBusStruct = new AliMUONBusStruct();
52 fBlockHeader = new AliMUONBlockHeader();
53 fDspHeader = new AliMUONDspHeader();
56 //_________________________________________________________________
57 AliMUONPayloadTracker::AliMUONPayloadTracker(const AliMUONPayloadTracker& stream) :
63 AliFatal("copy constructor not implemented");
66 //______________________________________________________________________
67 AliMUONPayloadTracker& AliMUONPayloadTracker::operator = (const AliMUONPayloadTracker&
71 // assignment operator
73 AliFatal("assignment operator not implemented");
78 //___________________________________
79 AliMUONPayloadTracker::~AliMUONPayloadTracker()
90 //______________________________________________________
91 Bool_t AliMUONPayloadTracker::Decode(UInt_t* buffer, Int_t totalDDLSize)
94 // Each DDL is made with 2 Blocks each of which consists of 5 DSP's at most
95 // and each of DSP has at most 5 buspatches.
96 // The different structures, Block (CRT), DSP (FRT) and Buspatch,
97 // are identified by a key word 0xFC0000FC, 0xF000000F and 0xB000000B respectively.
98 // (fBusPatchManager no more needed !)
101 //Read Header Size of DDL,Block,DSP and BusPatch
102 static Int_t kBlockHeaderSize = fBlockHeader->GetHeaderLength();
103 static Int_t kDspHeaderSize = fDspHeader->GetHeaderLength();
104 static Int_t kBusPatchHeaderSize = fBusStruct->GetHeaderLength();
107 Int_t totalBlockSize;
109 Int_t totalBusPatchSize;
121 while (buffer[index] == fBlockHeader->GetDefaultDataKey()) {
123 if (iBlock > fMaxBlock) break;
125 // copy within padding words
126 memcpy(fBlockHeader->GetHeader(),&buffer[index], (kBlockHeaderSize)*4);
128 totalBlockSize = fBlockHeader->GetTotalLength();
131 index += kBlockHeaderSize;
133 // copy in TClonesArray
134 fDDLTracker->AddBlkHeader(*fBlockHeader);
138 while (buffer[index] == fDspHeader->GetDefaultDataKey()) {
140 if (iDsp > fMaxDsp) break; // if ever...
142 memcpy(fDspHeader->GetHeader(),&buffer[index], kDspHeaderSize*4);
144 totalDspSize = fDspHeader->GetTotalLength();
146 index += kDspHeaderSize;
148 if (fDspHeader->GetPaddingWord() != fDspHeader->GetDefaultPaddingWord()) {
149 // copy the field of Padding word into ErrorWord field
150 fDspHeader->SetErrorWord(fDspHeader->GetPaddingWord());
154 // copy in TClonesArray
155 fDDLTracker->AddDspHeader(*fDspHeader, iBlock);
157 // buspatch structure
159 while (buffer[index] == fBusStruct->GetDefaultDataKey()) {
161 if (iBusPatch > fMaxBus) break; // if ever
163 //copy buffer into header structure
164 memcpy(fBusStruct->GetHeader(), &buffer[index], kBusPatchHeaderSize*4);
166 totalBusPatchSize = fBusStruct->GetTotalLength();
167 indexBusPatch = index;
169 //Check Buspatch header, not empty events
170 if(totalBusPatchSize > kBusPatchHeaderSize) {
172 index += kBusPatchHeaderSize;
173 dataSize = fBusStruct->GetLength();
174 bufSize = fBusStruct->GetBufSize();
176 if(dataSize > 0) { // check data present
177 if (dataSize > bufSize) // check buffer size
178 fBusStruct->SetAlloc(dataSize);
180 //copy buffer into data structure
181 memcpy(fBusStruct->GetData(), &buffer[index], dataSize*4);
182 fBusStruct->SetBlockId(iBlock); // could be usefull in future applications ?
183 fBusStruct->SetDspId(iDsp);
185 // copy in TClonesArray
186 fDDLTracker->AddBusPatch(*fBusStruct, iBlock, iDsp);
190 } // testing buspatch
192 index = indexBusPatch + totalBusPatchSize;
193 if (index >= totalDDLSize) {// check the end of DDL
194 index = totalDDLSize - 1; // point to the last element of buffer
200 index = indexDsp + totalDspSize;
201 if (index >= totalDDLSize) {
202 index = totalDDLSize - 1;
208 index = indexBlk + totalBlockSize;
209 if (index >= totalDDLSize) {
210 index = totalDDLSize - 1;
219 //______________________________________________________
220 void AliMUONPayloadTracker::ResetDDL()
222 // reseting TClonesArray
225 fDDLTracker->GetBlkHeaderArray()->Delete();
228 //______________________________________________________
229 void AliMUONPayloadTracker::SetMaxBlock(Int_t blk)
231 // set regional card number
232 if (blk > 2) blk = 2;