X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONRawWriter.cxx;h=4e5b4b9dff7d331adf2b4792cb8b7bdfe547b4ad;hb=03dec2c995153acc4cbb3a0f13b3b6a455d81ce1;hp=eed62c3c441edb08610cd9168c0275831b2f4ed4;hpb=134d296456a01925627ade4df65d90b51aac5536;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONRawWriter.cxx b/MUON/AliMUONRawWriter.cxx index eed62c3c441..4e5b4b9dff7 100644 --- a/MUON/AliMUONRawWriter.cxx +++ b/MUON/AliMUONRawWriter.cxx @@ -15,6 +15,7 @@ /* $Id$ */ +//----------------------------------------------------------------------------- /// \class AliMUONRawWriter /// MUON Raw Data generaton in ALICE-MUON /// Raw data structure could be found in Alice-note. @@ -40,6 +41,7 @@ /// Using AliMpDDLStore::GetBusPatchId. /// /// \author Ch. Finck, Feb. 07. +//----------------------------------------------------------------------------- #include "AliMUONRawWriter.h" @@ -63,6 +65,7 @@ #include "AliMpDDLStore.h" #include "AliMpDDL.h" +#include "AliMpRegionalTrigger.h" #include "AliMpTriggerCrate.h" #include "AliMpLocalBoard.h" #include "AliMpDetElement.h" @@ -75,6 +78,7 @@ #include "AliMpVSegmentation.h" #include "AliRawReader.h" +#include "AliRawDataHeaderSim.h" #include "AliBitPacking.h" #include "AliDAQ.h" #include "AliLog.h" @@ -97,7 +101,7 @@ AliMUONRawWriter::AliMUONRawWriter() fLocalStruct(new AliMUONLocalStruct()), fDDLStore(AliMpDDLStore::Instance()), fScalerEvent(kFALSE), - fHeader(), + fHeader(0x0), fBufferSize((((43*AliMpConstants::ManuNofChannels() + 4)*5 + 10)*5 + 8)*2), fBuffer(new Int_t [fBufferSize]) { @@ -160,7 +164,7 @@ Int_t AliMUONRawWriter::Digits2Raw(AliMUONVDigitStore* digitStore, { AliCodeTimerAuto("for Tracker") - AliMpExMap busPatchMap(true); + AliMpExMap busPatchMap; Int_t nDDLs = AliDAQ::NumberOfDdls("MUONTRK"); @@ -231,8 +235,11 @@ AliMUONRawWriter::Digits2BusPatchMap(const AliMUONVDigitStore& digitStore, UChar_t channelId = 0; UShort_t charge = 0; Int_t busPatchId = 0; + Int_t currentBusPatchId = -1; UInt_t word; + AliMUONBusStruct* busStruct(0x0); + TIter next(digitStore.CreateTrackerIterator()); AliMUONVDigit* digit; @@ -243,8 +250,8 @@ AliMUONRawWriter::Digits2BusPatchMap(const AliMUONVDigitStore& digitStore, { // This is most probably an error in the digitizer (which should insure // the adc is below kMAXADC), so make it a (non-fatal) error indeed. - AliError(Form("adc value %d above %x for DE %d . Setting to %x. Digit is:", - digit->DetElemId(),charge,kMAXADC,kMAXADC)); + AliError(Form("adc value %d above 0x%x for DE %d . Setting to 0x%x. Digit is:", + charge,kMAXADC,digit->DetElemId(),kMAXADC)); StdoutToAliError(digit->Print()); charge = kMAXADC; } @@ -277,9 +284,13 @@ AliMUONRawWriter::Digits2BusPatchMap(const AliMUONVDigitStore& digitStore, parity ^= ((word >> i) & 0x1); } AliBitPacking::PackWord((UInt_t)parity,word,31,31); - - AliMUONBusStruct* busStruct = - static_cast(busPatchMap.GetValue(busPatchId)); + + if ( currentBusPatchId != busPatchId ) + { + busStruct = + static_cast(busPatchMap.GetValue(busPatchId)); + currentBusPatchId = busPatchId; + } if (!busStruct) { @@ -307,6 +318,10 @@ AliMUONRawWriter::WriteTrackerDDL(AliMpExMap& busPatchMap, Int_t iDDL) AliCodeTimerAuto("") + if (fHeader == 0x0) { + AliError("Raw data header must be set"); + return; + } memset(fBuffer,0,fBufferSize*sizeof(Int_t)); AliMpDDL* ddl = fDDLStore->GetDDL(iDDL); @@ -332,10 +347,10 @@ AliMUONRawWriter::WriteTrackerDDL(AliMpExMap& busPatchMap, Int_t iDDL) for (Int_t iDsp = 0; iDsp < iDspMax; ++iDsp) { // DSP header - Int_t length = fDspHeader->GetHeaderLength(); - memcpy(&fBuffer[index],fDspHeader->GetHeader(),length*4); + Int_t dspHeaderLength = fDspHeader->GetHeaderLength(); + memcpy(&fBuffer[index],fDspHeader->GetHeader(),dspHeaderLength*4); Int_t indexDsp = index; - index += length; + index += dspHeaderLength; // 5 buspatches max per DSP for (Int_t i = 0; i < iBusPerDSP[iDsp]; ++i) @@ -355,14 +370,14 @@ AliMUONRawWriter::WriteTrackerDDL(AliMpExMap& busPatchMap, Int_t iDDL) if (busStructPtr) { // add bus patch structure header - Int_t length = busStructPtr->GetHeaderLength(); - memcpy(&fBuffer[index],busStructPtr->GetHeader(),length*4); - index += length; + Int_t busHeaderLength = busStructPtr->GetHeaderLength(); + memcpy(&fBuffer[index],busStructPtr->GetHeader(),busHeaderLength*4); + index += busHeaderLength; // add bus patch data - length = busStructPtr->GetLength(); - memcpy(&fBuffer[index],busStructPtr->GetData(),length*4); - index += length; + Int_t busLength = busStructPtr->GetLength(); + memcpy(&fBuffer[index],busStructPtr->GetData(),busLength*4); + index += busLength; } else { @@ -385,7 +400,7 @@ AliMUONRawWriter::WriteTrackerDDL(AliMpExMap& busPatchMap, Int_t iDDL) totalDspLength++; } - Int_t dspLength = totalDspLength - fDspHeader->GetHeaderLength(); + Int_t dspLength = totalDspLength - fDspHeader->GetHeaderLength(); fBuffer[indexDsp+1] = totalDspLength; // dsp total length fBuffer[indexDsp+2] = dspLength; // data length @@ -394,23 +409,30 @@ AliMUONRawWriter::WriteTrackerDDL(AliMpExMap& busPatchMap, Int_t iDDL) Int_t totalBlkLength = index - indexBlk; Int_t blkLength = totalBlkLength - fBlockHeader->GetHeaderLength(); - totalDDLLength += totalBlkLength; + totalDDLLength += totalBlkLength; fBuffer[indexBlk+1] = totalBlkLength; // total block length fBuffer[indexBlk+2] = blkLength; - + } // block + // add twice the end of CRT structure data key + // hope it's good placed (ChF) + fBuffer[index++] = fBlockHeader->GetDdlDataKey(); + fBuffer[index++] = fBlockHeader->GetDdlDataKey(); + totalDDLLength += 2; + // writting onto disk // total length in bytes // DDL header - Int_t headerSize = sizeof(fHeader)/4; + + Int_t headerSize = sizeof(AliRawDataHeader)/4; - fHeader.fSize = (totalDDLLength + headerSize) * 4; + fHeader->fSize = (totalDDLLength + headerSize) * 4; AliFstream* file = new AliFstream(AliDAQ::DdlFileName("MUONTRK",iDDL)); - file->WriteBuffer((char*)(&fHeader),headerSize*4); + file->WriteBuffer((char*)fHeader,headerSize*4); file->WriteBuffer((char*)fBuffer,sizeof(int)*index); delete file; } @@ -430,6 +452,11 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore AliCodeTimerAuto("") + if (fHeader == 0x0) { + AliError("Raw data header must be set"); + return 0; + } + // DDL event one per half chamber // DDL header size @@ -443,6 +470,7 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore } Int_t gloTrigResp = gloTrg->GetGlobalResponse(); + UInt_t *gloTrigInput = gloTrg->GetGlobalInput(); UInt_t word; Int_t* buffer = 0; @@ -478,9 +506,10 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore (kRegHeaderLength + kRegScalerLength +1))* 8 + (kDarcHeaderLength + kDarcScalerLength + kGlobalHeaderLength + kGlobalScalerLength + 2); - if(fScalerEvent) + if(fScalerEvent) { eventPhys = 0; //set to generate scaler events - + fHeader->fWord2 |= (0x1 << 14); // set L1SwC bit on + } if(fScalerEvent) buffer = new Int_t [kScalerBufferSize]; else @@ -511,10 +540,14 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore index += kDarcHeaderLength; // no global input for the moment.... - if (iDDL == 0) - fDarcHeader->SetGlobalOutput(gloTrigResp); - else - fDarcHeader->SetGlobalOutput(0); + if (iDDL == 0) { + fDarcHeader->SetGlobalOutput(gloTrigResp); + for (Int_t ii = 0; ii < 4; ii++) { + fDarcHeader->SetGlobalInput(gloTrigInput[ii],ii); + } + } else { + fDarcHeader->SetGlobalOutput(0); + } if (fScalerEvent) { // 6 DARC scaler words @@ -530,15 +563,17 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore if (fScalerEvent) { // 10 Global scaler words - memcpy(fDarcHeader->GetGlobalScalers(), &buffer[index], kGlobalScalerLength*4); + memcpy(&buffer[index], fDarcHeader->GetGlobalScalers(), kGlobalScalerLength*4); index += kGlobalScalerLength; } // end of global word buffer[index++] = fDarcHeader->GetEndOfGlobal(); + const AliMpRegionalTrigger* reg = AliMpDDLStore::Instance()->GetRegionalTrigger(); + Int_t nCrate = reg->GetNofTriggerCrates()/2; // 8 regional cards per DDL - for (Int_t iReg = 0; iReg < 8; ++iReg) { + for (Int_t iReg = 0; iReg < nCrate; ++iReg) { // crate info AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->GetTriggerCrate(iDDL, iReg); @@ -547,8 +582,10 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore AliWarning(Form("Missing crate number %d in DDL %d\n", iReg, iDDL)); // regional info tree, make sure that no reg card missing - AliMUONRegionalTrigger* regTrg = triggerStore.FindRegional(iReg+iDDL*8); - + AliMUONRegionalTrigger* regTrg = triggerStore.FindRegional(crate->GetId()); + if (!regTrg) + AliError(Form("Missing regional board %d in trigger Store\n", crate->GetId())); + // Regional card header word = 0; @@ -556,15 +593,15 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore fRegHeader->SetDarcWord(word); regOut = regTrg->GetOutput(); - regInpHpt = regTrg->GetLocalOutput(0); - regInpLpt = regTrg->GetLocalOutput(1); + regInpLpt = regTrg->GetLocalOutput(0); + regInpHpt = regTrg->GetLocalOutput(1); // fill darc word, not darc status for the moment (empty) //see AliMUONRegHeader.h for details AliBitPacking::PackWord((UInt_t)eventPhys,word,31,31); - AliBitPacking::PackWord((UInt_t)serialNb,word,19,24); - AliBitPacking::PackWord((UInt_t)version,word,7,14); - AliBitPacking::PackWord((UInt_t)iReg,word,15,18); + AliBitPacking::PackWord((UInt_t)serialNb,word,20,25); + AliBitPacking::PackWord((UInt_t)version,word,8,15); + AliBitPacking::PackWord((UInt_t)crate->GetId(),word,16,19); AliBitPacking::PackWord((UInt_t)regOut,word,0,7); fRegHeader->SetWord(word); @@ -585,7 +622,9 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore // 16 local card per regional board // UShort_t localMask = 0x0; - for (Int_t iLoc = 0; iLoc < 16; iLoc++) { + Int_t nLocalBoard = AliMpConstants::LocalBoardNofChannels(); + + for (Int_t iLoc = 0; iLoc < nLocalBoard; iLoc++) { // slot zero for Regional card Int_t localBoardId = crate->GetLocalBoardId(iLoc); @@ -655,7 +694,7 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore } // local card // fill regional header with local output - fRegHeader->SetInput(regInpHpt, 0); + fRegHeader->SetInput(regInpLpt, 0); fRegHeader->SetInput(regInpHpt, 1); memcpy(&buffer[indexReg],fRegHeader->GetHeader(),kRegHeaderLength*4); @@ -664,8 +703,8 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore // writting onto disk // write DDL's - fHeader.fSize = (index + headerSize) * 4;// total length in bytes - file[iDDL]->WriteBuffer((char*)(&fHeader),headerSize*4); + fHeader->fSize = (index + headerSize) * 4;// total length in bytes + file[iDDL]->WriteBuffer((char*)fHeader,headerSize*4); file[iDDL]->WriteBuffer((char*)buffer,sizeof(int)*index); }