X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONDigitMaker.cxx;h=0d78f303138698642c9e227a3a536b9fbd7d134a;hb=feb66c4c9c03911cc6b7f67722a92ee70189d89a;hp=4b9238868bf3eaa9376ef9fae1fa5741a1e70602;hpb=e3a2b9c9edb56742c252e886eaabd26f6f96b597;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONDigitMaker.cxx b/MUON/AliMUONDigitMaker.cxx index 4b9238868bf..0d78f303138 100644 --- a/MUON/AliMUONDigitMaker.cxx +++ b/MUON/AliMUONDigitMaker.cxx @@ -44,7 +44,6 @@ #include "AliMUONDigitMaker.h" -#include "AliLog.h" #include "AliMUONDDLTrigger.h" #include "AliMUONDarcHeader.h" #include "AliMUONVDigit.h" @@ -52,61 +51,99 @@ #include "AliMUONGlobalTrigger.h" #include "AliMUONLocalStruct.h" #include "AliMUONLocalTrigger.h" -#include "AliMUONRawStreamTracker.h" +#include "AliMUONLogger.h" #include "AliMUONRawStreamTrackerHP.h" -#include "AliMUONRawStreamTrigger.h" +#include "AliMUONRawStreamTriggerHP.h" #include "AliMUONRegHeader.h" -#include "AliMUONTriggerCircuit.h" +#include "AliMUONVTriggerStore.h" +#include "AliMpCDB.h" +#include "AliMpDetElement.h" #include "AliMpTriggerCrate.h" #include "AliMpLocalBoard.h" -#include "AliMUONVTriggerStore.h" #include "AliMpCathodType.h" #include "AliMpDDLStore.h" #include "AliMpDEManager.h" #include "AliMpPad.h" #include "AliMpSegmentation.h" #include "AliMpVSegmentation.h" +#include "AliCodeTimer.h" +#include "AliLog.h" #include "AliRawReader.h" #include +using std::endl; +using std::cout; /// \cond CLASSIMP ClassImp(AliMUONDigitMaker) // Class implementation in ROOT context /// \endcond //__________________________________________________________________________ -AliMUONDigitMaker::AliMUONDigitMaker(Bool_t enableErrorLogger, Bool_t useFastDecoder) - : TObject(), +AliMUONDigitMaker::AliMUONDigitMaker(Bool_t enableErrorLogger, Bool_t a, Bool_t b) : +TObject(), +fScalerEvent(kFALSE), +fMakeTriggerDigits(kFALSE), +fRawStreamTracker(new AliMUONRawStreamTrackerHP), +fRawStreamTrigger(new AliMUONRawStreamTriggerHP), +fDigitStore(0x0), +fTriggerStore(0x0), +fLogger(new AliMUONLogger(10000)){ + /// ctor + + if ( !a || !b ) AliFatal("no longer supported"); + + AliDebug(1,""); + + // Standard Constructor + if (enableErrorLogger) + { + fRawStreamTracker->EnabbleErrorLogger(); + fRawStreamTrigger->EnabbleErrorLogger(); + } + else + { + fRawStreamTracker->DisableWarnings(); + } + + SetMakeTriggerDigits(); + + // Load mapping + if ( ! AliMpCDB::LoadDDLStore() ) { + AliFatal("Could not access mapping from OCDB !"); + } +} + +//__________________________________________________________________________ +AliMUONDigitMaker::AliMUONDigitMaker(Bool_t enableErrorLogger) : +TObject(), fScalerEvent(kFALSE), fMakeTriggerDigits(kFALSE), - fRawStreamTracker(NULL), - fRawStreamTrigger(new AliMUONRawStreamTrigger()), - fTrackerTimer(), - fTriggerTimer(), - fMappingTimer(), + fRawStreamTracker(new AliMUONRawStreamTrackerHP), + fRawStreamTrigger(new AliMUONRawStreamTriggerHP), fDigitStore(0x0), - fTriggerStore(0x0) + fTriggerStore(0x0), + fLogger(new AliMUONLogger(10000)) { /// ctor AliDebug(1,""); - if (useFastDecoder) - fRawStreamTracker = new AliMUONRawStreamTrackerHP(); - else - fRawStreamTracker = new AliMUONRawStreamTracker(); - // Standard Constructor - if (enableErrorLogger) { + if (enableErrorLogger) + { fRawStreamTracker->EnabbleErrorLogger(); fRawStreamTrigger->EnabbleErrorLogger(); } + else + { + fRawStreamTracker->DisableWarnings(); + } - fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop(); - fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop(); - fMappingTimer.Start(kTRUE); fMappingTimer.Stop(); - SetMakeTriggerDigits(); + // Load mapping + if ( ! AliMpCDB::LoadDDLStore() ) { + AliFatal("Could not access mapping from OCDB !"); + } } //__________________________________________________________________________ @@ -117,21 +154,29 @@ AliMUONDigitMaker::~AliMUONDigitMaker() delete fRawStreamTracker; delete fRawStreamTrigger; + delete fLogger; +} - AliDebug(1, Form("Execution time for MUON tracker : R:%.2fs C:%.2fs", - fTrackerTimer.RealTime(),fTrackerTimer.CpuTime())); - AliDebug(1, Form(" Execution time for MUON tracker (mapping calls part) " - ": R:%.2fs C:%.2fs", - fMappingTimer.RealTime(),fMappingTimer.CpuTime())); - AliDebug(1, Form("Execution time for MUON trigger : R:%.2fs C:%.2fs", - fTriggerTimer.RealTime(),fTriggerTimer.CpuTime())); +//____________________________________________________________________ +void +AliMUONDigitMaker::Print(Option_t*) const +{ + /// Printout + + cout << "RawStreamerTracker class=" << fRawStreamTracker->ClassName() + << " MakeTriggerDigits=" << fMakeTriggerDigits + << " ScalerEvent=" << fScalerEvent + << " DigitStore=" << fDigitStore + << " TriggerStore=" << fTriggerStore << endl; + if ( fLogger ) fLogger->Print(); } //____________________________________________________________________ -Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader, - AliMUONVDigitStore* digitStore, - AliMUONVTriggerStore* triggerStore) +Int_t +AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader, + AliMUONVDigitStore* digitStore, + AliMUONVTriggerStore* triggerStore) { /// Main method to creates digit /// for tracker @@ -145,14 +190,17 @@ Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader, if (!fDigitStore && !fTriggerStore) { - AliError("No digit or trigger store given. Nothing to do..."); - return kFALSE; + fLogger->Log("No digit or trigger store given. Nothing to do..."); + return kTriggerBAD & kTrackerBAD; } + Int_t tracker(kOK); + Int_t trigger(kOK); + if ( fDigitStore ) { fDigitStore->Clear(); // insure we start with an empty container - ReadTrackerDDL(rawReader); + tracker = ReadTrackerDDL(rawReader); } if ( fTriggerStore || fMakeTriggerDigits ) @@ -160,26 +208,27 @@ Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader, if ( fTriggerStore ) fTriggerStore->Clear(); if ( fMakeTriggerDigits && !fDigitStore ) { - AliError("Asking for trigger digits but digitStore is null"); + fLogger->Log("Asking for trigger digits but digitStore is null"); } else { - ReadTriggerDDL(rawReader); + trigger = ReadTriggerDDL(rawReader); } } - return kTRUE; + return tracker | trigger; } //____________________________________________________________________ -Int_t AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader) +Int_t +AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader) { /// Reading tracker DDL /// filling the fDigitStore container, which must not be null AliDebug(1,""); - fTrackerTimer.Start(kFALSE); + AliCodeTimerAuto("",0); // elex info Int_t buspatchId; @@ -190,71 +239,88 @@ Int_t AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader) fRawStreamTracker->SetReader(rawReader); fRawStreamTracker->First(); - while ( fRawStreamTracker->Next(buspatchId,manuId,channelId,charge) ) + while ( fRawStreamTracker->Next(buspatchId,manuId,channelId,charge,kTRUE) ) { // getting DE from buspatch Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(buspatchId); + AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); + + if (!de) + { + fLogger->Log(Form("DE %04d does not exist !", detElemId)); + continue; + } + + if (!de->IsConnectedChannel(manuId,channelId)) + { + // non connected pad, do nothing (this is not an error !) + continue; + } + const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId, manuId); - AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId, - seg->PlaneType()); - - AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,channelId),kFALSE); + if (!seg) + { + fLogger->Log(Form("(DE,MANUID)=(%04d,%04d) is not valid",detElemId,manuId)); + continue; + } + AliMp::CathodType cathodeType = de->GetCathodType(seg->PlaneType()); + + AliMpPad pad = seg->PadByLocation(manuId,channelId,kFALSE); + if (!pad.IsValid()) { - AliError(Form("No pad for detElemId: %d, manuId: %d, channelId: %d", + fLogger->Log(Form("No pad for detElemId: %d, manuId: %d, channelId: %d", detElemId, manuId, channelId)); continue; } - + AliMUONVDigit* digit = fDigitStore->Add(detElemId,manuId,channelId,cathodeType, AliMUONVDigitStore::kDeny); + if (!digit) { - AliError(Form("Digit DE %04d Manu %04d Channel %02d could not be added", + fLogger->Log(Form("Digit DE %04d Manu %04d Channel %02d could not be added", detElemId, manuId, channelId)); continue; } - digit->SetPadXY(pad.GetIndices().GetFirst(), - pad.GetIndices().GetSecond()); + digit->SetPadXY(pad.GetIx(),pad.GetIy()); - digit->SetADC(charge); + digit->SetADC(charge); } - fTrackerTimer.Stop(); - - return kTRUE; + if ( fRawStreamTracker->IsErrorMessage() ) + { + return kTrackerBAD; + } + + return kOK; } //____________________________________________________________________ -Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader) +Int_t +AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader) { - /// reading tracker DDL + /// reading tracker DDL like ReadTriggerDDL but with fast decoder interface. /// filling the fTriggerStore container, which must not be null - AliDebug(1,""); - - AliMUONDDLTrigger* ddlTrigger = 0x0; - AliMUONDarcHeader* darcHeader = 0x0; - AliMUONRegHeader* regHeader = 0x0; - AliMUONLocalStruct* localStruct = 0x0; + const AliMUONRawStreamTriggerHP::AliHeader* darcHeader = 0x0; + const AliMUONRawStreamTriggerHP::AliRegionalHeader* regHeader = 0x0; + const AliMUONRawStreamTriggerHP::AliLocalStruct* localStruct = 0x0; Int_t loCircuit; - fTriggerTimer.Start(kFALSE); - fRawStreamTrigger->SetReader(rawReader); - while (fRawStreamTrigger->NextDDL()) + while (fRawStreamTrigger->NextDDL()) { - ddlTrigger = fRawStreamTrigger->GetDDLTrigger(); - darcHeader = ddlTrigger->GetDarcHeader(); + darcHeader = fRawStreamTrigger->GetHeaders(); // fill global trigger information if (fTriggerStore) @@ -263,11 +329,12 @@ Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader) { AliMUONGlobalTrigger globalTrigger; globalTrigger.SetFromGlobalResponse(darcHeader->GetGlobalOutput()); + globalTrigger.SetFromGlobalInput(darcHeader->GetGlobalHeader()->fInput); fTriggerStore->SetGlobal(globalTrigger); } } - Int_t nReg = darcHeader->GetRegHeaderEntries(); + Int_t nReg = fRawStreamTrigger->GetRegionalHeaderCount(); for(Int_t iReg = 0; iReg < nReg ;iReg++) { //reg loop @@ -277,70 +344,72 @@ Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader) AliMpTriggerCrate* crate = AliMpDDLStore::Instance()-> GetTriggerCrate(fRawStreamTrigger->GetDDL(), iReg); - if (!crate) - AliWarning(Form("Missing crate number %d in DDL %d\n", iReg, fRawStreamTrigger->GetDDL())); - + if (!crate) { + fLogger->Log(Form("Missing crate number %d in DDL %d\n", iReg, fRawStreamTrigger->GetDDL())); + continue; + } - regHeader = darcHeader->GetRegHeaderEntry(iReg); + regHeader = fRawStreamTrigger->GetRegionalHeader(iReg); - Int_t nLocal = regHeader->GetLocalEntries(); + Int_t nLocal = regHeader->GetLocalStructCount(); for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) - { + { - localStruct = regHeader->GetLocalEntry(iLocal); + localStruct = regHeader->GetLocalStruct(iLocal); // if card exist if (localStruct) { - loCircuit = crate->GetLocalBoardId(localStruct->GetId()); - - if ( !loCircuit ) continue; // empty slot - - AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, false); - - // skip copy cards - if( !localBoard->IsNotified()) - continue; + loCircuit = crate->GetLocalBoardId(localStruct->GetId()); + + if ( !loCircuit ) continue; // empty slot + - if (fTriggerStore) + if (fTriggerStore) { // fill local trigger AliMUONLocalTrigger localTrigger; localTrigger.SetLocalStruct(loCircuit, *localStruct); fTriggerStore->Add(localTrigger); - } + } if ( fMakeTriggerDigits ) { //FIXEME should find something better than a TArray TArrayS xyPattern[2]; - localStruct->GetXPattern(xyPattern[0]); - localStruct->GetYPattern(xyPattern[1]); + localStruct->GetXPattern(xyPattern[0]); + localStruct->GetYPattern(xyPattern[1]); TriggerDigits(loCircuit, xyPattern, *fDigitStore); - } + } } // if triggerY } // iLocal } // iReg } // NextDDL - fTriggerTimer.Stop(); - - return kTRUE; - + return kOK; } //____________________________________________________________________ Int_t AliMUONDigitMaker::TriggerDigits(Int_t nBoard, - TArrayS* xyPattern, - AliMUONVDigitStore& digitStore) const + const TArrayS* xyPattern, + AliMUONVDigitStore& digitStore, Bool_t warn) const { /// make digits for trigger from pattern, and add them to digitStore + AliCodeTimerAuto("",0); + Int_t detElemId; AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(nBoard); + + if ( ! localBoard->IsNotified() ) { + // Copy board + // The mapping is not correct for copy boards + // Use the one of corresponding phyiscal board + nBoard = localBoard->GetInputXfrom(); + } Int_t n,b; @@ -366,19 +435,19 @@ Int_t AliMUONDigitMaker::TriggerDigits(Int_t nBoard, { // not quite sure about this Int_t offset = 0; - if (iCath && localBoard->GetSwitch(6)) offset = -8; + if (iCath && localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB)) offset = -8; - AliMpPad pad = seg->PadByLocation(AliMpIntPair(nBoard,ibitxy+offset),kTRUE); + AliMpPad pad = seg->PadByLocation(nBoard,ibitxy+offset,warn); if (!pad.IsValid()) { - AliWarning(Form("No pad for detElemId: %d, nboard %d, ibitxy: %d\n", + fLogger->Log(Form("No pad for detElemId: %d, nboard %d, ibitxy: %d\n", detElemId, nBoard, ibitxy)); continue; } - n = pad.GetLocation(0).GetFirst(); // always take first location so that digits are not inserted several times - b = pad.GetLocation(0).GetSecond(); + n = pad.GetLocalBoardId(0); // always take first location so that digits are not inserted several times + b = pad.GetLocalBoardChannel(0); AliDebug(1,Form("Using localBoard %d ixy %d instead of %d,%d", n,b,nBoard,ibitxy)); @@ -392,8 +461,8 @@ Int_t AliMUONDigitMaker::TriggerDigits(Int_t nBoard, continue; } - Int_t padX = pad.GetIndices().GetFirst(); - Int_t padY = pad.GetIndices().GetSecond(); + Int_t padX = pad.GetIx(); + Int_t padY = pad.GetIy(); // fill digit digit->SetPadXY(padX,padY); @@ -404,4 +473,41 @@ Int_t AliMUONDigitMaker::TriggerDigits(Int_t nBoard, } // ichamber return kTRUE; -} +} + +//______________________________________________________________________________ +Bool_t +AliMUONDigitMaker::TriggerToDigitsStore(const AliMUONVTriggerStore& triggerStore, + AliMUONVDigitStore& digitStore) const +{ + // + /// make (S)Digit for trigger + // + + digitStore.Clear(); + + AliMUONLocalTrigger* locTrg; + TIter next(triggerStore.CreateLocalIterator()); + + while ( ( locTrg = static_cast(next()) ) ) + { + if (locTrg->IsNull()) continue; + + TArrayS xyPattern[2]; + locTrg->GetXPattern(xyPattern[0]); + locTrg->GetYPattern(xyPattern[1]); + + Int_t nBoard = locTrg->LoCircuit(); + TriggerDigits(nBoard, xyPattern, digitStore); + } + return kTRUE; +} + +//______________________________________________________________________________ +void +AliMUONDigitMaker::SetTryRecover(Bool_t flag) +{ + /// Instruct the decoder to try to recover corrupted raw data. + /// Only use for specific cases for which you know it will work... + fRawStreamTracker->TryRecover(flag); +}