Skip to content
Snippets Groups Projects
Commit 1ce84b0a authored by Norbert Herrmann's avatar Norbert Herrmann
Browse files

cover all mapping cases

git-svn-id: https://subversion.gsi.de/cbmsoft/cbmroot/trunk@15645 5a1b234a-d7ce-0410-9a93-fd649a8fa65c
parent 8aad8d7e
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,17 @@
#include <stdint.h>
#include <iomanip>
#include <fstream>
#include <vector>
static Int_t NMappingWarnings=100;
static uint32_t pat_mess[8]={8*0};
std::vector< std::vector <uint32_t> > Pat_Request;
std::vector<Bool_t> bGdpbOK;
static Bool_t bEnableOut=kFALSE;
static Int_t fiMsGood=0;
static Int_t fiMsBad=0;
// -------------------------------------------------------------------------
CbmMcbm2018UnpackerAlgoTof::CbmMcbm2018UnpackerAlgoTof() :
CbmStar2019Algo(),
......@@ -125,15 +135,16 @@ void CbmMcbm2018UnpackerAlgoTof::Reset()
void CbmMcbm2018UnpackerAlgoTof::Finish()
{
/// Printout Goodbye message and stats
LOG(INFO)<<"<I> MS statistics - Good: " << fiMsGood <<", Bad: " << fiMsBad;
/// Write Output histos
}
// -------------------------------------------------------------------------
Bool_t CbmMcbm2018UnpackerAlgoTof::InitContainers()
{
LOG(info) << "Init parameter containers for CbmMcbm2018UnpackerAlgoTof";
Bool_t initOK = ReInitContainers();
return initOK;
......@@ -144,9 +155,10 @@ Bool_t CbmMcbm2018UnpackerAlgoTof::ReInitContainers()
LOG(info) << "ReInit parameter containers for CbmMcbm2018UnpackerAlgoTof";
fUnpackPar = (CbmMcbm2018TofPar*)fParCList->FindObject("CbmMcbm2018TofPar");
if( nullptr == fUnpackPar )
if( nullptr == fUnpackPar ) {
LOG(ERROR) << " CbmMcbm2018TofPar not found ";
return kFALSE;
}
Bool_t initOK = InitParameters();
return initOK;
......@@ -162,6 +174,8 @@ TList* CbmMcbm2018UnpackerAlgoTof::GetParList()
}
Bool_t CbmMcbm2018UnpackerAlgoTof::InitParameters()
{
LOG(INFO) << "InitParameters from " << fUnpackPar;
fdMsSizeInNs = fUnpackPar->GetSizeMsInNs();
fuNrOfGdpbs = fUnpackPar->GetNrOfGdpbs();
LOG(info) << "Nr. of Tof GDPBs: " << fuNrOfGdpbs;
......@@ -246,6 +260,33 @@ Bool_t CbmMcbm2018UnpackerAlgoTof::InitParameters()
}
break;
case 1: // STAR eTOF modules
if(fviRpcSide[iGbtx]<2){ // mTof modules
const Int_t RpcMap[3]={0,1,2};
for(Int_t iRpc= 0; iRpc < fviNrOfRpc[iGbtx]; iRpc++) {
Int_t iStrMax=32;
Int_t iChNext=1;
for(Int_t iStr= 0; iStr < iStrMax; iStr++) {
Int_t iStrMap = iStr;
Int_t iRpcMap = RpcMap[iRpc];
if( fviRpcSide[iGbtx] == 0) iStrMap=31-iStr;
if(fviModuleId[iGbtx] > -1)
fviRpcChUId[iCh]=CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx],
iRpcMap,iStrMap,
fviRpcSide[iGbtx],
fviRpcType[iGbtx]);
else
fviRpcChUId[iCh]=0;
// LOG(DEBUG)<<Form("Map Ch %d to Address 0x%08x",iCh,fviRpcChUId[iCh]);
iCh += iChNext;
}
}
}
iCh += 64;
break;
/// Special Treatment for the T0 diamond
case 5:
{
......@@ -254,6 +295,7 @@ Bool_t CbmMcbm2018UnpackerAlgoTof::InitParameters()
{
for( UInt_t uCh = 0; uCh < fUnpackPar->GetNrOfChannelsPerFee(); ++uCh )
{
/*
if( uFee < 4 && 0 == uCh ) {
fviRpcChUId[ iCh ] = CbmTofAddress::GetUniqueAddress(
fviModuleId[iGbtx],
......@@ -262,13 +304,14 @@ Bool_t CbmMcbm2018UnpackerAlgoTof::InitParameters()
LOG(info) << Form( "Map T0 Ch %d to Address 0x%08x", iCh, fviRpcChUId[iCh] );
}
else fviRpcChUId[ iCh ] = 0;
*/
/// Mapping for the 2019 beamtime
if( 0 == uFee && 1 == fviNrOfRpc[iGbtx] )
{
switch( uCh % 8 )
{
case 0:
case 2:
case 4:
{
/// 2019 mapping with 320/640 Mb/s FW
......@@ -280,8 +323,8 @@ Bool_t CbmMcbm2018UnpackerAlgoTof::InitParameters()
fviModuleId[iGbtx],
0, uChannelT0,
0, fviRpcType[iGbtx] );
LOG(info) << Form( "T0 channel: %u from GBTx %2u Fee %2u Channel %2u address %08x",
uChannelT0, iGbtx, uFee, uCh, fviRpcChUId[ iCh ] );
LOG(info) << Form( "T0 channel: %u from GBTx %2u Fee %2u Channel %2u, indx %d address %08x",
uChannelT0, iGbtx, uFee, uCh, iCh, fviRpcChUId[ iCh ] );
break;
} // Valid T0 channel
default:
......@@ -373,7 +416,29 @@ Bool_t CbmMcbm2018UnpackerAlgoTof::InitParameters()
Int_t iStrMap = iStr;
Int_t iRpcMap = iRpc[iFeet];
Int_t iSideMap = iSide[iFeet];
//if(iSideMap == 0)iStrMap=31-iStr;
switch (fviRpcSide[iGbtx]) {
case 0:
;
break;
case 1: // HD cosmic 2019, Buc2018, v18n
iStrMap=31-iStr;
iRpcMap=1-iRpcMap;
break;
case 2: // v18m_cosmicHD
// iStrMap=31-iStr;
iSideMap=1-iSideMap;
break;
case 3:
iStrMap=31-iStr;
iRpcMap=1-iRpcMap;
iSideMap=1-iSideMap;
break;
case 4: // HD cosmic 2019, Buc2018, v18o
iRpcMap=1-iRpcMap;
break;
default:
;
}
if( iSideMap > -1)
fviRpcChUId[iCh]=CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx],
iRpcMap,iStrMap,
......@@ -407,6 +472,31 @@ Bool_t CbmMcbm2018UnpackerAlgoTof::InitParameters()
} // for( UInt_t i = 0; i < uNrOfChannels; ++i)
LOG(info) << sPrintout;
// Request masks
LOG(INFO) << " Load " << fUnpackPar->GetNrReqPattern() << " GET4 Request masks for " << fuNrOfGdpbs << " Gdpbs ";
if(fUnpackPar->GetNrReqPattern()>0){
bGdpbOK.resize(fuNrOfGdpbs);
Pat_Request.resize(fuNrOfGdpbs);
Int_t iInd=0;
for(Int_t iGdpb=0; iGdpb<fuNrOfGdpbs; iGdpb++) {
bGdpbOK[iGdpb]=kTRUE;
/*
Pat_Request[iGdpb].resize(fUnpackPar->GetNrReqPattern());
for (Int_t iPat=0; iPat<fUnpackPar->GetNrReqPattern(); iPat++) {
UInt_t PatGet4=fUnpackPar->GetReqPattern(iInd++);
for( UInt_t uBit = 0; uBit < 32; ++uBit ) {
if( ( PatGet4 >> uBit ) & 0x1 ) {
UInt_t iGet4=iPat*32+uBit;
UInt_t uElink=fUnpackPar->Get4IdxToElinkIdx(iGet4);
UInt_t ubit=uElink%32;
UInt_t iEPat=(uElink-ubit)/32;
Pat_Request[iGdpb][iEPat] |= (0x1 << ubit);
}
}
}
*/
}
}
/// Internal status initialization
fvulCurrentEpoch.resize( fuNrOfGdpbs, 0 );
fvulCurrentEpochCycle.resize( fuNrOfGdpbs, 0 );
......@@ -463,6 +553,7 @@ Bool_t CbmMcbm2018UnpackerAlgoTof::ProcessTs( const fles::Timeslice& ts )
{
fulCurrentTsIdx = ts.index();
fdTsStartTime = static_cast< Double_t >( ts.descriptor( 0, 0 ).idx );
LOG(DEBUG) << "ProcessTs "<< fulCurrentTsIdx;
/// Ignore First TS as first MS is typically corrupt
if( 0 == fulCurrentTsIdx )
......@@ -531,6 +622,14 @@ Bool_t CbmMcbm2018UnpackerAlgoTof::ProcessTs( const fles::Timeslice& ts )
fDigiVect.reserve( fuTsMaxVectorSize );
} // if( fuTsMaxVectorSize < fDigiVect.size() )
if(!bEnableOut) {
LOG(DEBUG) << "Ts "<< fulCurrentTsIdx << " removed ";
fiMsBad++;
fDigiVect.clear();
}else {
LOG(DEBUG) << "Ts "<< fulCurrentTsIdx << " accepted ";
fiMsGood++;
}
return kTRUE;
}
......@@ -814,7 +913,7 @@ void CbmMcbm2018UnpackerAlgoTof::ProcessEndOfMsEpoch()
<< " New epoch cycle for Gdpb " << fuCurrDpbIdx
<< Form( ": Current cycle 0x%09llX New cycle 0x%09llX", fvulCurrentEpochCycle[fuCurrDpbIdx], fvulCurrentEpochCycle[fuCurrDpbIdx] + 1 )
<< Form( "(old Ep %08llx new Ep %08llx)", fvulCurrentEpoch[ fuCurrDpbIdx ], ulEpochNr )
<< std::endl;
;
fvulCurrentEpochCycle[ fuCurrDpbIdx ]++;
} // if( 0 < fvulCurrentEpoch[ fuCurrDpbIdx ] && ulEpochNr < fvulCurrentEpoch[ fuCurrDpbIdx ] )
/*
......@@ -1073,9 +1172,18 @@ void CbmMcbm2018UnpackerAlgoTof::ProcessHit( gdpbv100::FullMessage mess )
<< ", FiS " << uFeeNrInSys
<< ", GBTx " << uGbtxNrInSys;
*/
if( 0 == uChanUId )
if( 0 == uChanUId ) {
if( 0 < NMappingWarnings-- )
LOG(warning) << "Unused data item at " << uRemappedChannelNrInSys
<< ", from GdpbNr " << fuCurrDpbIdx
<< ", Get4 " << fuGet4Id
<< ", Ch " << uChannel
<< ", ChNr " << uChannelNr
<< ", ChNrIF " << uChannelNrInFee
<< ", FiS " << uFeeNrInSys
;
return; // Hit not mapped to digi
}
/// Apply offset to T0 only to TOF digis
if( 0x90 != fuCurrentMsSysId )
dHitTime -= fdTimeOffsetNs;
......@@ -1083,11 +1191,12 @@ void CbmMcbm2018UnpackerAlgoTof::ProcessHit( gdpbv100::FullMessage mess )
LOG(debug) << Form("Insert 0x%08x digi with time ", uChanUId ) << dHitTime << Form(", Tot %4.0f",dHitTot)
// << " into buffer with " << fBuffer->GetSize() << " data from "
// << Form("%11.1f to %11.1f ", fBuffer->GetTimeFirst(), fBuffer->GetTimeLast())
<< " at epoch " << mess.getExtendedEpoch();
CbmTofDigiExp digi( uChanUId, dHitTime, dHitTot );
fDigiVect.push_back( digi );
}
// -------------------------------------------------------------------------
void CbmMcbm2018UnpackerAlgoTof::ProcessSlCtrl( gdpbv100::FullMessage /*mess*/ )
......@@ -1173,6 +1282,7 @@ void CbmMcbm2018UnpackerAlgoTof::ProcessError( gdpbv100::FullMessage mess )
return;
}
void CbmMcbm2018UnpackerAlgoTof::ProcessPattern( gdpbv100::FullMessage mess )
{
uint16_t usType = mess.getGdpbSysPattType();
......@@ -1183,10 +1293,20 @@ void CbmMcbm2018UnpackerAlgoTof::ProcessPattern( gdpbv100::FullMessage mess )
{
case gdpbv100::PATT_MISSMATCH:
{
LOG(debug) << Form( "Missmatch pattern message => Type %d, Index %2d, Pattern 0x%08X", usType, usIndex, uPattern );
break;
LOG(debug) << Form( "Missmatch pattern message => Type %u, Index %2d, Pattern 0x%08X", usType, usIndex, uPattern );
if(usIndex==7) {
TString Tok;
if (bEnableOut) Tok="Ena";
else Tok="Dis";
LOG(DEBUG) << Form( "Mismatch pat in TS %llu, MS %llu, Gdpb %u, T %u, Pattern 0x%08X %08X %08X %08X %08X %08X %08X %08X ",
fulCurrentTsIdx, fulCurrentMsIdx, fuCurrDpbIdx, usType,
pat_mess[0], pat_mess[1], pat_mess[2], pat_mess[3], pat_mess[4], pat_mess[5], pat_mess[6], pat_mess[7] )
<< Tok;
}
break;
} // case gdpbv100::PATT_MISSMATCH:
case gdpbv100::PATT_ENABLE:
{
LOG(debug2) << Form( "Enable pattern message => Type %d, Index %2d, Pattern 0x%08X", usType, usIndex, uPattern );
......@@ -1200,6 +1320,7 @@ void CbmMcbm2018UnpackerAlgoTof::ProcessPattern( gdpbv100::FullMessage mess )
*/
break;
} // case gdpbv100::PATT_ENABLE:
case gdpbv100::PATT_RESYNC:
{
LOG(debug) << Form( "RESYNC pattern message => Type %d, Index %2d, Pattern 0x%08X", usType, usIndex, uPattern );
......@@ -1212,7 +1333,14 @@ void CbmMcbm2018UnpackerAlgoTof::ProcessPattern( gdpbv100::FullMessage mess )
break;
} // default
} // switch( usType )
if(usIndex==7) {
bEnableOut=kTRUE;
/*
for(Int_t iGdpb=0; iGdpb<fUnpackPar->GetNrOfGdpbs(); iGdpb++) {
bEnableOut &= bGdpbOK[iGdpb];
}
*/
}
return;
}
// -------------------------------------------------------------------------
......
......@@ -63,6 +63,7 @@ class CbmMcbm2018UnpackerAlgoTof : public CbmStar2019Algo<CbmTofDigiExp>
inline void SetDiamondDpbIdx( UInt_t uIdx = 2 ) { fuDiamondDpbIdx = uIdx; }
inline void SetVectCapInc( Double_t dIncFact ) { fdCapacityIncFactor = dIncFact; }
inline void SetMaxAsicInactive( Int_t ival) { fMaxAsicInactive = ival; }
private:
/// Control flags
......@@ -165,10 +166,11 @@ class CbmMcbm2018UnpackerAlgoTof : public CbmStar2019Algo<CbmTofDigiExp>
*/
TH1* fhVectorSize = nullptr;
TH1* fhVectorCapacity = nullptr;
size_t fuTsMaxVectorSize = 0;
Double_t fdCapacityIncFactor = 1.1;
size_t fuTsMaxVectorSize = 0;
Double_t fdCapacityIncFactor = 1.1;
Int_t fMaxAsicInactive=0;
void ProcessEpochCycle( uint64_t ulCycleData );
void ProcessEpochCycle( uint64_t ulCycleData );
void ProcessEpoch( gdpbv100::Message mess, uint32_t uMesgIdx );
void ProcessEndOfMsEpoch( );
void ProcessStarTrigger( gdpbv100::Message mess );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment