- totalDDLLength = 0;
-
- // filling buffer
- buffer = new Int_t [(2048+24)*50]; // 24 words at most for one buspatch and 2048 manu info at most
-
- indexBlk = 0;
- indexDsp = 0;
- index = 0;
-
- // two blocks A and B per DDL
- for (Int_t iBlock = 0; iBlock < 2; iBlock++) {
-
- // block header
- length = fBlockHeader->GetHeaderLength();
- memcpy(&buffer[index],fBlockHeader->GetHeader(),length*4);
- indexBlk = index;
- index += length;
-
- // 5 DSP's max per block
- for (Int_t iDsp = 0; iDsp < iDspMax; iDsp++) {
-
- // DSP header
- length = fDspHeader->GetHeaderLength();
- memcpy(&buffer[index],fDspHeader->GetHeader(),length*4);
- indexDsp = index;
- index += length;
-
- //Â 5 buspatches max per DSP
- for (Int_t i = 0; i < iBusPerDSP[iDsp]; i++) {
-
- iBusPatch++;
- if ((fBusPatchManager->GetDDLfromBus(iBusPatch) % 2) == 0) // comparing to DDL file
- iFile = 1;
- else
- iFile = 0;
-
- AliDebug(3,Form("iCh %d iDDL %d iBlock %d iDsp %d busPatchId %d", iCh, iDDL, iBlock, iDsp, iBusPatch));
-
- nEntries = fBusArray->GetEntriesFast();
- busPatchId = -1;
-
- for (Int_t iEntries = 0; iEntries < nEntries; iEntries++) { // method "bourrique"...
- busStructPtr = (AliMUONBusStruct*)fBusArray->At(iEntries);
- busPatchId = busStructPtr->GetBusPatchId();
- if (busPatchId == iBusPatch) break;
- busPatchId = -1;
- AliDebug(3,Form("busPatchId %d", busStructPtr->GetBusPatchId()));
- }
-
- // check if buspatchid has digit
- if (busPatchId != -1) {
- // add bus patch structure header
- length = busStructPtr->GetHeaderLength();
- memcpy(&buffer[index],busStructPtr->GetHeader(),length*4);
- index += length;
-
- // add bus patch data
- for (Int_t j = 0; j < busStructPtr->GetLength(); j++) {
- buffer[index++] = busStructPtr->GetData(j);
- AliDebug(3,Form("busPatchId %d, manuId %d channelId %d\n",
- busStructPtr->GetBusPatchId(),
- busStructPtr->GetManuId(j), busStructPtr->GetChannelId(j) ));
- }
- // fBusArray->RemoveAt(iEntries);
- // fBusArray->Compress();
- } else {
- // writting anyhow buspatch structure (empty ones)
- buffer[index++] = busStructPtr->GetDefaultDataKey(); // fill it also for empty data size
- buffer[index++] = busStructPtr->GetHeaderLength(); // header length
- buffer[index++] = 0; // raw data length
- buffer[index++] = iBusPatch; // bus patch
- }
- } // bus patch
-
- totalDspLength = index - indexDsp;
- dspLength = totalDspLength - fDspHeader->GetHeaderLength();
-
- buffer[indexDsp+1] = totalDspLength; // dsp total length
- buffer[indexDsp+2] = dspLength; // data length
-
- // remove padding word if necessary cos already in Dsp header length
- // if total length is even, remove already placed padding word, else let it as it is.
- if ((totalDspLength % 2) == 1) {
- buffer[indexDsp+1] -= 1;
- buffer[indexDsp+2] -= 1;
- index--;
- Int_t indexCopy = indexDsp + fDspHeader->GetHeaderLength() - 2;
- memcpy(&buffer[indexCopy], &buffer[indexCopy+1],
- (totalDspLength - fDspHeader->GetHeaderLength() + 2)*4);
- }
-
- } // dsp
-
- totalBlkLength = index - indexBlk;
- blkLength = totalBlkLength - fBlockHeader->GetHeaderLength();
- totalDDLLength += totalBlkLength;
-
- buffer[indexBlk+1] = totalBlkLength; // total block length
- buffer[indexBlk+2] = blkLength;
-
- } // block