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 read MUON raw digits
48 // Default ctor for monitoring purposes
50 fBusPatchManager = new AliMpBusPatch();
51 fBusPatchManager->ReadBusPatchFile();
53 fDDLTracker = new AliMUONDDLTracker();
54 fBusStruct = new AliMUONBusStruct();
55 fBlockHeader = new AliMUONBlockHeader();
56 fDspHeader = new AliMUONDspHeader();
59 //_________________________________________________________________
60 AliMUONPayloadTracker::AliMUONPayloadTracker(const AliMUONPayloadTracker& stream) :
66 AliFatal("copy constructor not implemented");
69 //______________________________________________________________________
70 AliMUONPayloadTracker& AliMUONPayloadTracker::operator = (const AliMUONPayloadTracker&
74 // assignment operator
76 AliFatal("assignment operator not implemented");
81 //___________________________________
82 AliMUONPayloadTracker::~AliMUONPayloadTracker()
87 delete fBusPatchManager;
94 //______________________________________________________
95 Bool_t AliMUONPayloadTracker::Decode(UInt_t* buffer, Int_t ddl)
97 // reading tracker DDL
98 // store buspatch info into Array
99 // store only non-empty structures (buspatch info with datalength !=0)
102 //Read Header Size of DDL,Block,DSP and BusPatch
103 static Int_t kBlockHeaderSize = fBlockHeader->GetHeaderLength();
104 static Int_t kDspHeaderSize = fDspHeader->GetHeaderLength();
105 static Int_t kBusPatchHeaderSize = fBusStruct->GetHeaderLength();
107 // Int_t totalDDLSize;
108 Int_t totalBlockSize;
110 Int_t totalBusPatchSize;
114 Int_t iBusPerDSP[5]; // number of bus patches per DSP
115 Int_t iDspMax; // number max of DSP per block
117 // minimum data size (only header's)
118 // Int_t blankDDLSize;
119 Int_t blankBlockSize;
122 AliDebug(3, Form("DDL Number %d\n", ddl ));
125 fBusPatchManager->GetDspInfo(ddl/2, iDspMax, iBusPerDSP);
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.
132 // blankDDLSize = 2*kBlockHeaderSize + 2*iDspMax*kDspHeaderSize;
133 blankBlockSize = kBlockHeaderSize + iDspMax*kDspHeaderSize;
134 // totalDDLSize = sizeof(buffer)/4;
136 for (Int_t i = 0; i < iDspMax; i++) {
137 // blankDDLSize += 2*iBusPerDSP[i]*kBusPatchHeaderSize;
138 blankBlockSize += iBusPerDSP[i]*kBusPatchHeaderSize;
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
149 for(Int_t iBlock = 0; iBlock < 2 ;iBlock++){ // loop over 2 blocks
151 // copy within padding words
152 memcpy(fBlockHeader->GetHeader(),&buffer[index], (kBlockHeaderSize+1)*4);
154 totalBlockSize = fBlockHeader->GetTotalLength();
156 fDDLTracker->AddBlkHeader(*fBlockHeader);
158 if (fBlockHeader->GetPadding() == 0xDEAD) // skipping padding word
161 if(totalBlockSize > blankBlockSize) { // compare block header
162 index += kBlockHeaderSize;
164 for(Int_t iDsp = 0; iDsp < iDspMax ;iDsp++){ //DSP loop
166 if (iDsp > fMaxDsp) break;
168 memcpy(fDspHeader->GetHeader(),&buffer[index], kDspHeaderSize*4);
170 totalDspSize = fDspHeader->GetTotalLength();
173 blankDspSize = kDspHeaderSize + iBusPerDSP[iDsp]*kBusPatchHeaderSize; // no data just header
175 fDDLTracker->AddDspHeader(*fDspHeader, iBlock);
177 if(totalDspSize > blankDspSize) { // Compare DSP Header
178 index += kDspHeaderSize;
180 for(Int_t iBusPatch = 0; iBusPatch < iBusPerDSP[iDsp]; iBusPatch++) {
182 if (iBusPatch > fMaxBus) break;
184 //copy buffer into header structure
185 memcpy(fBusStruct->GetBusPatchHeader(), &buffer[index], kBusPatchHeaderSize*4);
187 totalBusPatchSize = fBusStruct->GetTotalLength();
188 indexBusPatch = index;
190 //Check Buspatch header, not empty events
191 if(totalBusPatchSize > kBusPatchHeaderSize) {
193 index += kBusPatchHeaderSize;
194 dataSize = fBusStruct->GetLength();
195 Int_t bufSize = fBusStruct->GetBufSize();
197 if(dataSize > 0) { // check data present
198 if (dataSize > bufSize) fBusStruct->SetAlloc(dataSize);
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);
208 } // testing buspatch
210 index = indexBusPatch + totalBusPatchSize;
216 index = indexDsp + totalDspSize;
222 index = totalBlockSize;
226 // } //loop checking the header size of DDL
231 //______________________________________________________
232 void AliMUONPayloadTracker::ResetDDL()
234 // reseting TClonesArray
237 fDDLTracker->GetBlkHeaderArray()->Delete();
240 //______________________________________________________
241 void AliMUONPayloadTracker::SetMaxBlock(Int_t blk)
243 // set regional card number
244 if (blk > 2) blk = 2;