X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONRawWriter.cxx;h=d783d441343da0765c2f3ef031dfe37f96ec0cbe;hb=65a7dc2a5a307d8bfc1582bc9c9e5d114b89e7c2;hp=670a7e0ced23745fb5dce1302a8e1ab812dfd742;hpb=92c23b09d8263caf283ea958a86fd82f6fe74832;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONRawWriter.cxx b/MUON/AliMUONRawWriter.cxx index 670a7e0ced2..d783d441343 100644 --- a/MUON/AliMUONRawWriter.cxx +++ b/MUON/AliMUONRawWriter.cxx @@ -63,6 +63,7 @@ #include "AliMUONVTriggerStore.h" #include "AliCodeTimer.h" +#include "AliMpCDB.h" #include "AliMpDDLStore.h" #include "AliMpDDL.h" #include "AliMpRegionalTrigger.h" @@ -113,6 +114,13 @@ AliMUONRawWriter::AliMUONRawWriter() fBlockHeader->SetDataKey(fBlockHeader->GetDefaultDataKey()); fDspHeader->SetDataKey(fDspHeader->GetDefaultDataKey()); + // Load mapping + if ( ! fDDLStore ) { + if ( ! AliMpCDB::LoadDDLStore() ) { + AliFatal("Could not access mapping from OCDB !"); + } + fDDLStore = AliMpDDLStore::Instance(); + } } //__________________________________________________________________________ @@ -148,23 +156,22 @@ void AliMUONRawWriter::LocalWordPacking(UInt_t& word, UInt_t locId, UInt_t locD } //____________________________________________________________________ -Int_t AliMUONRawWriter::Digits2Raw(AliMUONVDigitStore* digitStore, - AliMUONVTriggerStore* triggerStore) +Int_t AliMUONRawWriter::Digits2Raw(const AliMUONVDigitStore* digitStore, + const AliMUONVTriggerStore* triggerStore) { /// convert digits of the current event to raw data - AliCodeTimerAuto("") + AliCodeTimerAuto("",0) Int_t idDDL; - Char_t name[255]; // tracking chambers if ( digitStore ) { - AliCodeTimerAuto("for Tracker") + AliCodeTimerAuto("for Tracker",1) - AliMpExMap busPatchMap(true); + AliMpExMap busPatchMap; Int_t nDDLs = AliDAQ::NumberOfDdls("MUONTRK"); @@ -189,7 +196,7 @@ Int_t AliMUONRawWriter::Digits2Raw(AliMUONVDigitStore* digitStore, if ( triggerStore ) { - AliCodeTimerAuto("for Trigger") + AliCodeTimerAuto("for Trigger",1) // trigger chambers @@ -197,12 +204,10 @@ Int_t AliMUONRawWriter::Digits2Raw(AliMUONVDigitStore* digitStore, // open files idDDL = 0;// MUTR - strcpy(name,AliDAQ::DdlFileName("MUONTRG",idDDL)); - file[0] = new AliFstream(name); + file[0] = new AliFstream(AliDAQ::DdlFileName("MUONTRG",idDDL)); idDDL = 1;// MUTR - strcpy(name,AliDAQ::DdlFileName("MUONTRG",idDDL)); - file[1] = new AliFstream(name); + file[1] = new AliFstream(AliDAQ::DdlFileName("MUONTRG",idDDL)); WriteTriggerDDL(*triggerStore,file); @@ -223,7 +228,7 @@ AliMUONRawWriter::Digits2BusPatchMap(const AliMUONVDigitStore& digitStore, { /// Create bus patch structures corresponding to digits in the store - AliCodeTimerAuto("") + AliCodeTimerAuto("",0) static const Int_t kMAXADC = (1<<12)-1; // We code the charge on a 12 bits ADC. @@ -235,8 +240,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; @@ -281,9 +289,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) { @@ -309,7 +321,7 @@ AliMUONRawWriter::WriteTrackerDDL(AliMpExMap& busPatchMap, Int_t iDDL) // (((43 manus max per bus patch *64 channels + 4 bus patch words) * 5 bus patch // + 10 dsp words)*5 dsps + 8 block words)*2 blocks - AliCodeTimerAuto("") + AliCodeTimerAuto("",0) if (fHeader == 0x0) { AliError("Raw data header must be set"); @@ -340,10 +352,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) @@ -363,14 +375,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 { @@ -443,7 +455,7 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore { /// Write trigger DDL - AliCodeTimerAuto("") + AliCodeTimerAuto("",0) if (fHeader == 0x0) { AliError("Raw data header must be set"); @@ -463,6 +475,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; @@ -532,10 +545,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 @@ -551,7 +568,7 @@ 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; } @@ -566,13 +583,17 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore // crate info AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->GetTriggerCrate(iDDL, iReg); - if (!crate) - AliWarning(Form("Missing crate number %d in DDL %d\n", iReg, iDDL)); + if (!crate) { + AliError(Form("Missing crate number %d in DDL %d\n", iReg, iDDL)); + continue; + } // regional info tree, make sure that no reg card missing AliMUONRegionalTrigger* regTrg = triggerStore.FindRegional(crate->GetId()); - if (!regTrg) + if (!regTrg) { AliError(Form("Missing regional board %d in trigger Store\n", crate->GetId())); + continue; + } // Regional card header word = 0; @@ -581,15 +602,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); @@ -623,28 +644,29 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore if (localBoard->IsNotified()) {// if notified board AliMUONLocalTrigger* locTrg = triggerStore.FindLocal(localBoardId); - locCard = locTrg->LoCircuit(); - locDec = locTrg->GetLoDecision(); - trigY = locTrg->LoTrigY(); - posY = locTrg->LoStripY(); - posX = locTrg->LoStripX(); - devX = locTrg->LoDev(); - sdevX = locTrg->LoSdev(); - - AliDebug(4,Form("loctrg %d, posX %d, posY %d, devX %d\n", - locTrg->LoCircuit(),locTrg->LoStripX(),locTrg->LoStripY(),locTrg->LoDev())); - //packing word - word = 0; - LocalWordPacking(word, (UInt_t)iLoc, (UInt_t)locDec, (UInt_t)trigY, (UInt_t)posY, - (UInt_t)posX, (UInt_t)sdevX, (UInt_t)devX); - - buffer[index++] = (locTrg->GetX1Pattern() | (locTrg->GetX2Pattern() << 16)); - buffer[index++] = (locTrg->GetX3Pattern() | (locTrg->GetX4Pattern() << 16)); - buffer[index++] = (locTrg->GetY1Pattern() | (locTrg->GetY2Pattern() << 16)); - buffer[index++] = (locTrg->GetY3Pattern() | (locTrg->GetY4Pattern() << 16)); - buffer[index++] = (Int_t)word; // data word - - + if (locTrg) + { + locCard = locTrg->LoCircuit(); + locDec = locTrg->GetLoDecision(); + trigY = locTrg->LoTrigY(); + posY = locTrg->LoStripY(); + posX = locTrg->LoStripX(); + devX = locTrg->LoDev(); + sdevX = locTrg->LoSdev(); + + AliDebug(4,Form("loctrg %d, posX %d, posY %d, devX %d\n", + locTrg->LoCircuit(),locTrg->LoStripX(),locTrg->LoStripY(),locTrg->LoDev())); + //packing word + word = 0; + LocalWordPacking(word, (UInt_t)iLoc, (UInt_t)locDec, (UInt_t)trigY, (UInt_t)posY, + (UInt_t)posX, (UInt_t)sdevX, (UInt_t)devX); + + buffer[index++] = (locTrg->GetX1Pattern() | (locTrg->GetX2Pattern() << 16)); + buffer[index++] = (locTrg->GetX3Pattern() | (locTrg->GetX4Pattern() << 16)); + buffer[index++] = (locTrg->GetY1Pattern() | (locTrg->GetY2Pattern() << 16)); + buffer[index++] = (locTrg->GetY3Pattern() | (locTrg->GetY4Pattern() << 16)); + buffer[index++] = (Int_t)word; // data word + } } // fill copy card X-Y inputs from the notified cards if (localBoard->GetInputXfrom() && localBoard->GetInputYfrom()) @@ -658,11 +680,14 @@ Int_t AliMUONRawWriter::WriteTriggerDDL(const AliMUONVTriggerStore& triggerStore Int_t localFromId = localBoard->GetInputXfrom(); AliMUONLocalTrigger* locTrgfrom = triggerStore.FindLocal(localFromId); - buffer[index++] = 0; // copy only X3-4 & Y1-4 - buffer[index++] = (locTrgfrom->GetX3Pattern() | (locTrgfrom->GetX4Pattern() << 16)); - buffer[index++] = (locTrgfrom->GetY1Pattern() | (locTrgfrom->GetY2Pattern() << 16)); - buffer[index++] = (locTrgfrom->GetY3Pattern() | (locTrgfrom->GetY4Pattern() << 16)); - buffer[index++] = word; + if ( locTrgfrom ) + { + buffer[index++] = 0; // copy only X3-4 & Y1-4 + buffer[index++] = (locTrgfrom->GetX3Pattern() | (locTrgfrom->GetX4Pattern() << 16)); + buffer[index++] = (locTrgfrom->GetY1Pattern() | (locTrgfrom->GetY2Pattern() << 16)); + buffer[index++] = (locTrgfrom->GetY3Pattern() | (locTrgfrom->GetY4Pattern() << 16)); + buffer[index++] = word; + } } } else { @@ -682,7 +707,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);