Commit 5f6de5b8 authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau Committed by Pierre-Alain Loizeau
Browse files

[mCBM 2020] Add support for processing of TS ranges based on spills

- Add task finding the spill borders with the T0 + macros
- In CbmMcbm2018Source, add support for selecting TS ranges for a chosen Spill range with 3 spill borders options
- Fix TS metadata calculation against corrupted MS 0 and move it to make sure it is generated even when TS range selected
parent 97862b6e
......@@ -130,6 +130,9 @@ Set(SRCS
tasks/CbmMcbmCheckTimingAlgo.cxx
tasks/CbmMcbmCheckTimingTask.cxx
tasks/CbmMcbmSpillFindAlgo.cxx
tasks/CbmMcbmSpillFindTask.cxx
)
If(_UINT8_T_EXIST)
......
......@@ -77,4 +77,7 @@
#pragma link C++ class CbmMcbmCheckTimingAlgo + ;
#pragma link C++ class CbmMcbmCheckTimingTask + ;
#pragma link C++ class CbmMcbmSpillFindAlgo + ;
#pragma link C++ class CbmMcbmSpillFindTask + ;
#endif
......@@ -117,6 +117,76 @@ Bool_t CbmMcbm2018Source::Init() {
fTimeSliceMetaDataArray,
fbWriteOutput);
/// Single spill unpacking
if (0 <= fiUnpSpillIdxStart)
{
switch( fuFlagSpillStart )
{
case 0:
{
/// 0 = Break begin
if( fvuSpillBreakBegTs.size() - 1 <= fiUnpSpillIdxStop )
{
LOG(warning) << "Chosen last spill index larger than spills contained in chosen spill start vector: "
<< fiUnpSpillIdxStop << " VS " << fvuSpillBreakBegTs.size() - 1;
if( fiUnpSpillIdxStart < fvuSpillBreakBegTs.size() - 1 )
{
fiUnpSpillIdxStop = fvuSpillBreakBegTs.size() - 2;
LOG(warning) << "Using last possible spill instead as final one";
} // if( fiUnpSpillIdxStart < fvuSpillBreakBegTs.size() - 1 )
else LOG(fatal) << "Start index also too large, exiting";
} // if( fvuSpillBreakBegTs.size() - 1 <= fiUnpSpillIdxStop )
fuSpillBegTs = fvuSpillBreakBegTs[ fiUnpSpillIdxStart ]; //!
fuSpillEndTs = fvuSpillBreakBegTs[ fiUnpSpillIdxStop + 1 ]; //!
break;
}
case 1:
{
/// 1 = Break middle
if( fvuSpillBreakMidTs.size() - 1 <= fiUnpSpillIdxStop )
{
LOG(warning) << "Chosen last spill index larger than spills contained in chosen spill start vector: "
<< fiUnpSpillIdxStop << " VS " << fvuSpillBreakMidTs.size() - 1;
if( fiUnpSpillIdxStart < fvuSpillBreakMidTs.size() - 1 )
{
fiUnpSpillIdxStop = fvuSpillBreakMidTs.size() - 2;
LOG(warning) << "Using last possible spill instead as final one";
} // if( fiUnpSpillIdxStart < fvuSpillBreakMidTs.size() - 1 )
else LOG(fatal) << "Start index also too large, exiting";
} // if( fvuSpillBreakMidTs.size() - 1 <= fiUnpSpillIdxStop )
fuSpillBegTs = fvuSpillBreakMidTs[ fiUnpSpillIdxStart ]; //!
fuSpillEndTs = fvuSpillBreakMidTs[ fiUnpSpillIdxStop + 1 ]; //!
break;
}
case 2:
{
/// 2 = Break end
if( fvuSpillBreakEndTs.size() - 1 <= fiUnpSpillIdxStop )
{
LOG(warning) << "Chosen last spill index larger than spills contained in chosen spill start vector: "
<< fiUnpSpillIdxStop << " VS " << fvuSpillBreakEndTs.size() - 1;
if( fiUnpSpillIdxStart < fvuSpillBreakEndTs.size() - 1 )
{
fiUnpSpillIdxStop = fvuSpillBreakEndTs.size() - 2;
LOG(warning) << "Using last possible spill instead as final one";
} // if( fiUnpSpillIdxStart < fvuSpillBreakEndTs.size() - 1 )
else LOG(fatal) << "Start index also too large, exiting";
} // if( fvuSpillBreakEndTs.size() - 1 <= fiUnpSpillIdxStop )
fuSpillBegTs = fvuSpillBreakEndTs[ fiUnpSpillIdxStart ]; //!
fuSpillEndTs = fvuSpillBreakEndTs[ fiUnpSpillIdxStop + 1 ]; //!
break;
}
default:
{
LOG(fatal) << "Unknown spill start point option: " << fuFlagSpillStart;
break;
}
} // switch( fuFlagSpillStart )
} // if (0 <= fiUnpSpillIdxStart)
return kTRUE;
}
......@@ -248,26 +318,22 @@ Int_t CbmMcbm2018Source::FillBuffer() {
} // for( auto it = it_list.first; it != it_list.second; ++it )
} // else of if( it == fUnpackers.end() )
} // for (size_t c {0}; c < ts.num_components(); c++)
} // if( 1 == fTSCounter )
/// Apply TS throttling as set by user (default = 1 => no throttling)
if (0 == tsIndex % fuTsReduction) {
for (auto itUnp = fUnpackersToRun.begin(); itUnp != fUnpackersToRun.end();
++itUnp) {
(*itUnp)->DoUnpack(ts, 0);
} // for( auto itUnp = fUnpackersToRun.begin(); itUnp != fUnpackersToRun.end(); ++ itUnp )
} // if( 0 == tsIndex % fuTsReduction )
/// Save the TimeSlice meta-data for access by higher level tasks
if (fTSCounter == 1) {
/// Compute and store the timeslice and microslices properties
auto nMsInTs = ts.num_core_microslices();
if (nMsInTs > 1) {
if (nMsInTs > 2) {
// This assumes that we have a component 0 and component independent ms/ts settings!
auto msDescA = ts.descriptor(0, 0);
auto msDescB = ts.descriptor(0, 1);
auto msDescA = ts.descriptor(0, 1);
auto msDescB = ts.descriptor(0, 2);
auto msLength = msDescB.idx - msDescA.idx;
fTSLength = msLength * nMsInTs;
fTSOverlappLength = msLength * (ts.num_microslices(0) - nMsInTs);
LOG(info)
<< "CbmMcbm2018Source::FillBuffer() - TS 1 - Calculated "
<< "TimesliceMetaData information from microslices Metadata -> "
<< "MS length found to be " << msLength << " ns, TS length "
<< fTSLength << " ns, and TS overlap length "
<< fTSOverlappLength << " ns";
} else {
LOG(warning)
<< "CbmMcbm2018Source::FillBuffer() - TS 1 - Calculate "
......@@ -275,7 +341,32 @@ Int_t CbmMcbm2018Source::FillBuffer() {
"TS duration can not be calculated with the given method. Hence, "
"TimesliceMetaData duration values are filled with 0";
}
}
} // if( 1 == fTSCounter )
if (0 <= fiUnpSpillIdxStart )
{
if (tsIndex < fuSpillBegTs)
{
/// Jump all TS until reaching the first TS in the spill we want to unpack
continue;
} // if (tsIndex < fuSpillBegTs)
else if(fuSpillEndTs <= tsIndex)
{
/// Stop when reaching the first TS in the next spill
return 1;
} // else if
} // if (0 <= fiUnpSpillIdxStart)
/// Apply TS throttling as set by user (default = 1 => no throttling)
if (0 == tsIndex % fuTsReduction) {
for (auto itUnp = fUnpackersToRun.begin(); itUnp != fUnpackersToRun.end();
++itUnp) {
(*itUnp)->DoUnpack(ts, 0);
} // for( auto itUnp = fUnpackersToRun.begin(); itUnp != fUnpackersToRun.end(); ++ itUnp )
} // if( 0 == tsIndex % fuTsReduction )
/// Save the TimeSlice meta-data for access by higher level tasks
new ((*fTimeSliceMetaDataArray)[fTimeSliceMetaDataArray->GetEntriesFast()])
TimesliceMetaData(
ts.descriptor(0, 0).idx, fTSLength, fTSOverlappLength, tsIndex);
......
......@@ -77,6 +77,28 @@ public:
fuTsReduction = uTsReduction;
}
void UnpackSingleSpill( Int_t uSpillIdx, UInt_t uSpillStart = 1 ) {
fiUnpSpillIdxStart = uSpillIdx;
fiUnpSpillIdxStop = uSpillIdx;
fuFlagSpillStart = uSpillStart;
}
void UnpackSelectSpills( Int_t uSpillIdxStart, Int_t uSpillIdxStop, UInt_t uSpillStart = 1 ) {
fiUnpSpillIdxStart = uSpillIdxStart;
fiUnpSpillIdxStop = uSpillIdxStop;
fuFlagSpillStart = uSpillStart;
}
void LoadTsListSpillBreakBegin( std::vector< ULong64_t > vTsBeg ) {
fvuSpillBreakBegTs.assign( vTsBeg.begin(), vTsBeg.end() );
}
void LoadTsListSpillBreakEnd( std::vector< ULong64_t > vTsEnd ) {
fvuSpillBreakEndTs.assign( vTsEnd.begin(), vTsEnd.end() );
}
void LoadTsListSpillBreakMiddle( std::vector< ULong64_t > vTsMid ) {
fvuSpillBreakMidTs.assign( vTsMid.begin(), vTsMid.end() );
}
void SetSubscriberHwm(UInt_t val = 1) { fuSubscriberHwm = val; }
void SetWriteOutputFlag(Bool_t bFlagIn) { fbWriteOutput = bFlagIn; }
......@@ -105,6 +127,16 @@ private:
UInt_t fuTsReduction;
Int_t fiUnpSpillIdxStart = -1; //! >= 0 means unpack only from this spill
Int_t fiUnpSpillIdxStop = -1; //! >= 0 means unpack only up to this spill (included)
UInt_t fuFlagSpillStart = 0; //! 0 = Break begin, 1 = Break middle, 2 = Break end
UInt_t fuSpillBegTs = 0; //!
UInt_t fuSpillEndTs = 0; //!
std::vector< ULong64_t > fvuSpillBreakBegTs = {}; //!
std::vector< ULong64_t > fvuSpillBreakEndTs = {}; //!
std::vector< ULong64_t > fvuSpillBreakMidTs = {}; //!
std::unique_ptr<fles::TimesliceSource> fSource; //!
UInt_t fuSubscriberHwm;
......
// -----------------------------------------------------------------------------
// ----- -----
// ----- CbmMcbmSpillFindAlgo -----
// ----- Created 10.02.2019 by P.-A. Loizeau -----
// ----- -----
// -----------------------------------------------------------------------------
#include "CbmMcbmSpillFindAlgo.h"
#include "CbmFlesHistosTools.h"
#include "CbmFormatMsHeaderPrintout.h"
#include "CbmMcbm2018TofPar.h"
#include "CbmTofAddress.h"
#include "CbmTofDetectorId_v14a.h" // in cbmdata/tof
#include "FairLogger.h"
#include "FairRootManager.h"
#include "FairRun.h"
#include "FairRunOnline.h"
#include "FairRuntimeDb.h"
#include "TCanvas.h"
#include "TH1.h"
#include "TH2.h"
#include "TList.h"
#include "TPaveStats.h"
#include "TProfile.h"
#include "TROOT.h"
#include "TString.h"
#include <fstream>
#include <iomanip>
#include <iostream>
#include <stdint.h>
// -------------------------------------------------------------------------
CbmMcbmSpillFindAlgo::CbmMcbmSpillFindAlgo() : CbmStar2019Algo() {}
CbmMcbmSpillFindAlgo::~CbmMcbmSpillFindAlgo()
{
}
// -------------------------------------------------------------------------
Bool_t CbmMcbmSpillFindAlgo::Init()
{
LOG(info) << "Initializing mCBM T0 2019 monitor algo";
return kTRUE;
}
void CbmMcbmSpillFindAlgo::Reset() {}
void CbmMcbmSpillFindAlgo::Finish()
{
/// If Spill is On, add a fake spill break to have the last spill
/// If Spill is Off, add a fake spill break end so that all modes include last spill
if (fbSpillOn)
{
fvuSpillBreakBegTs.push_back( fulCurrentTsIdx + 1 );
fvuSpillBreakEndTs.push_back( fulCurrentTsIdx + 1 );
} // if (fbSpillOn)
else fvuSpillBreakEndTs.push_back( fulCurrentTsIdx + 1 );
/// Fill the vector of spill break middle points
std::vector< ULong64_t >::iterator itBreakBeg = fvuSpillBreakBegTs.begin();
std::vector< ULong64_t >::iterator itBreakEnd = fvuSpillBreakEndTs.begin();
if( itBreakBeg != fvuSpillBreakBegTs.end() && itBreakEnd != fvuSpillBreakEndTs.end() && *itBreakEnd < *itBreakBeg ) {
fvuSpillBreakMidTs.push_back((*itBreakEnd + fulFirstTsIdx) / 2);
++itBreakEnd;
} // if( itBreakBeg != fvuSpillBreakBegTs.end() && itBreakEnd != fvuSpillBreakEndTs.end() && *itBreakEnd < *itBreakBeg )
while( itBreakBeg != fvuSpillBreakBegTs.end() && itBreakEnd != fvuSpillBreakEndTs.end() ) {
fvuSpillBreakMidTs.push_back((*itBreakBeg + *itBreakEnd) / 2);
++itBreakBeg;
++itBreakEnd;
} // while( itBreakBeg != fvuSpillBreakBegTs.end() && itBreakEnd != fvuSpillBreakEndTs.end() )
if( itBreakBeg != fvuSpillBreakBegTs.end() ) {
fvuSpillBreakMidTs.push_back((*itBreakBeg + fulCurrentTsIdx) / 2);
++itBreakBeg;
} // if( itBreakBeg != fvuSpillBreakBegTs.end() )
if( itBreakBeg != fvuSpillBreakBegTs.end() || itBreakEnd != fvuSpillBreakEndTs.end() ) {
LOG(warning) << "Size of spill breaks beginning or end did not match: "
<< fvuSpillBreakBegTs.size() << " VS " << fvuSpillBreakEndTs.size();
} // if( itBreakBeg != fvuSpillBreakBegTs.end() || itBreakEnd != fvuSpillBreakEndTs.end() )
LOG(info) << "**********************************************";
LOG(info) << "TS index for beginning of spill breaks:";
for (ULong64_t uBeg : fvuSpillBreakBegTs) {
LOG(info)<< Form( "%9llu", uBeg );
} // for (ULong64_t uBeg : fvuSpillBreakBegTs)
LOG(info) << "**********************************************";
LOG(info) << "TS index for ending of spill breaks:";
for (ULong64_t uEnd : fvuSpillBreakEndTs) {
LOG(info)<< Form( "%9llu", uEnd );
} // for (ULong64_t uBeg : fvuSpillBreakBegTs)
LOG(info) << "**********************************************";
LOG(info) << "TS index for middle of spill breaks:";
for (ULong64_t uMid : fvuSpillBreakMidTs) {
LOG(info)<< Form( "%9llu", uMid );
} // for (ULong64_t uBeg : fvuSpillBreakBegTs)
LOG(info) << "**********************************************";
}
// -------------------------------------------------------------------------
Bool_t CbmMcbmSpillFindAlgo::InitContainers()
{
LOG(info) << "Init parameter containers for CbmMcbmSpillFindAlgo";
Bool_t initOK = ReInitContainers();
return initOK;
}
Bool_t CbmMcbmSpillFindAlgo::ReInitContainers()
{
LOG(info) << "**********************************************";
LOG(info) << "ReInit parameter containers for CbmMcbmSpillFindAlgo";
fUnpackPar = (CbmMcbm2018TofPar*) fParCList->FindObject("CbmMcbm2018TofPar");
if (nullptr == fUnpackPar) return kFALSE;
Bool_t initOK = InitParameters();
return initOK;
}
TList* CbmMcbmSpillFindAlgo::GetParList()
{
if (nullptr == fParCList) fParCList = new TList();
fUnpackPar = new CbmMcbm2018TofPar("CbmMcbm2018TofPar");
fParCList->Add(fUnpackPar);
return fParCList;
}
Bool_t CbmMcbmSpillFindAlgo::InitParameters()
{
fuNrOfGdpbs = fUnpackPar->GetNrOfGdpbs();
LOG(info) << "Nr. of Tof GDPBs: " << fuNrOfGdpbs;
fuNrOfFeePerGdpb = fUnpackPar->GetNrOfFeesPerGdpb();
LOG(info) << "Nr. of FEES per Tof GDPB: " << fuNrOfFeePerGdpb;
fuNrOfGet4PerFee = fUnpackPar->GetNrOfGet4PerFee();
LOG(info) << "Nr. of GET4 per Tof FEE: " << fuNrOfGet4PerFee;
fuNrOfChannelsPerGet4 = fUnpackPar->GetNrOfChannelsPerGet4();
LOG(info) << "Nr. of channels per GET4: " << fuNrOfChannelsPerGet4;
fuNrOfChannelsPerFee = fuNrOfGet4PerFee * fuNrOfChannelsPerGet4;
LOG(info) << "Nr. of channels per FEE: " << fuNrOfChannelsPerFee;
fuNrOfGet4 = fuNrOfGdpbs * fuNrOfFeePerGdpb * fuNrOfGet4PerFee;
LOG(info) << "Nr. of GET4s: " << fuNrOfGet4;
fuNrOfGet4PerGdpb = fuNrOfFeePerGdpb * fuNrOfGet4PerFee;
LOG(info) << "Nr. of GET4s per GDPB: " << fuNrOfGet4PerGdpb;
fuNrOfChannelsPerGdpb = fuNrOfGet4PerGdpb * fuNrOfChannelsPerGet4;
LOG(info) << "Nr. of channels per GDPB: " << fuNrOfChannelsPerGdpb;
fGdpbIdIndexMap.clear();
for (UInt_t i = 0; i < fuNrOfGdpbs; ++i) {
fGdpbIdIndexMap[fUnpackPar->GetGdpbId(i)] = i;
LOG(info) << "GDPB Id of TOF " << i << " : " << std::hex << fUnpackPar->GetGdpbId(i) << std::dec;
} // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i )
return kTRUE;
}
// -------------------------------------------------------------------------
void CbmMcbmSpillFindAlgo::AddMsComponentToList(size_t component, UShort_t usDetectorId)
{
/// Check for duplicates and ignore if it is the case
for (UInt_t uCompIdx = 0; uCompIdx < fvMsComponentsList.size(); ++uCompIdx)
if (component == fvMsComponentsList[uCompIdx]) return;
/// Add to list
fvMsComponentsList.push_back(component);
LOG(info) << "CbmMcbmSpillFindAlgo::AddMsComponentToList => Component " << component << " with detector ID 0x"
<< std::hex << usDetectorId << std::dec << " added to list";
}
// -------------------------------------------------------------------------
Bool_t CbmMcbmSpillFindAlgo::ProcessTs(const fles::Timeslice& ts)
{
fulCurrentTsIdx = ts.index();
fdTsStartTime = static_cast<Double_t>(ts.descriptor(0, 0).idx);
if( fulCurrentTsIdx < fulFirstTsIdx )
fulFirstTsIdx = fulCurrentTsIdx;
/// Ignore First TS as first MS is typically corrupt
if (0 == fulCurrentTsIdx) return kTRUE;
/// On first TS, extract the TS parameters from header (by definition stable over time)
if (-1.0 == fdTsCoreSizeInNs) {
fuNbCoreMsPerTs = ts.num_core_microslices();
fuNbOverMsPerTs = ts.num_microslices(0) - ts.num_core_microslices();
fdTsCoreSizeInNs = fdMsSizeInNs * (fuNbCoreMsPerTs);
fdTsFullSizeInNs = fdMsSizeInNs * (fuNbCoreMsPerTs + fuNbOverMsPerTs);
LOG(info) << "Timeslice parameters: each TS has " << fuNbCoreMsPerTs << " Core MS and " << fuNbOverMsPerTs
<< " Overlap MS, for a core duration of " << fdTsCoreSizeInNs << " ns and a full duration of "
<< fdTsFullSizeInNs << " ns";
/// Ignore overlap ms if flag set by user
fuNbMsLoop = fuNbCoreMsPerTs;
if (kFALSE == fbIgnoreOverlapMs) fuNbMsLoop += fuNbOverMsPerTs;
LOG(info) << "In each TS " << fuNbMsLoop << " MS will be looped over";
} // if( -1.0 == fdTsCoreSizeInNs )
/// Compute time of TS core end
fdTsStopTimeCore = fdTsStartTime + fdTsCoreSizeInNs;
// LOG(info) << Form( "TS %5d Start %12f Stop %12f", fulCurrentTsIdx, fdTsStartTime, fdTsStopTimeCore );
/// Loop over core microslices (and overlap ones if chosen)
for (fuMsIndex = 0; fuMsIndex < fuNbMsLoop; fuMsIndex++) {
/// Loop over registered components
for (UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx) {
UInt_t uMsComp = fvMsComponentsList[uMsCompIdx];
if (kFALSE == ProcessMs(ts, uMsComp, fuMsIndex)) {
LOG(error) << "Failed to process ts " << fulCurrentTsIdx << " MS " << fuMsIndex << " for component " << uMsComp;
return kFALSE;
} // if( kFALSE == ProcessMs( ts, uMsCompIdx, fuMsIndex ) )
} // for( UInt_t uMsCompIdx = 0; uMsCompIdx < fvMsComponentsList.size(); ++uMsCompIdx )
} // for( fuMsIndex = 0; fuMsIndex < uNbMsLoop; fuMsIndex ++ )
/// Fill plots if in monitor mode
if (fbMonitorMode) {
if (kFALSE == FillHistograms()) {
LOG(error) << "Failed to fill histos in ts " << fulCurrentTsIdx;
return kFALSE;
} // if( kFALSE == FillHistograms() )
} // if( fbMonitorMode )
return kTRUE;
}
Bool_t CbmMcbmSpillFindAlgo::ProcessMs(const fles::Timeslice& ts, size_t uMsCompIdx, size_t uMsIdx)
{
auto msDescriptor = ts.descriptor(uMsCompIdx, uMsIdx);
fuCurrentEquipmentId = msDescriptor.eq_id;
const uint8_t* msContent = reinterpret_cast<const uint8_t*>(ts.content(uMsCompIdx, uMsIdx));
uint32_t uSize = msDescriptor.size;
fulCurrentMsIdx = msDescriptor.idx;
fdMsTime = (1e-9) * static_cast<double>(fulCurrentMsIdx);
LOG(debug) << "Microslice: " << fulCurrentMsIdx << " from EqId " << std::hex << fuCurrentEquipmentId << std::dec
<< " has size: " << uSize;
if (0 == fvbMaskedComponents.size()) fvbMaskedComponents.resize(ts.num_components(), kFALSE);
fuCurrDpbId = static_cast<uint32_t>(fuCurrentEquipmentId & 0xFFFF);
/*
* Should be only for first detected TS
*/
if (fulCurrentTsIdx < 10 && 0 == uMsIdx) {
LOG(INFO) << "---------------------------------------------------------------";
LOG(INFO) << "Component " << uMsCompIdx << " TS Idx " << fulCurrentTsIdx;
LOG(INFO) << "hi hv eqid flag si sv idx/start crc size offset";
LOG(INFO) << Form("%02x %02x %04x %04x %02x %02x %016lx %08x %08x %016lx",
static_cast<unsigned int>(msDescriptor.hdr_id), static_cast<unsigned int>(msDescriptor.hdr_ver),
msDescriptor.eq_id, msDescriptor.flags, static_cast<unsigned int>(msDescriptor.sys_id),
static_cast<unsigned int>(msDescriptor.sys_ver), static_cast<unsigned long>(msDescriptor.idx),
msDescriptor.crc, msDescriptor.size, static_cast<unsigned long>(msDescriptor.offset));
} // if( fulCurrentTsIdx < 10 && 0 == uMsIdx )
/*
*/
/// Check if this sDPB ID was declared in parameter file and stop there if not
auto it = fGdpbIdIndexMap.find(fuCurrDpbId);
if (it == fGdpbIdIndexMap.end()) {
if (kFALSE == fvbMaskedComponents[uMsCompIdx]) {
LOG(info) << "---------------------------------------------------------------";
/*
LOG(info) << "hi hv eqid flag si sv idx/start crc size offset";
LOG(info) << Form( "%02x %02x %04x %04x %02x %02x %016llx %08x %08x %016llx",
static_cast<unsigned int>(msDescriptor.hdr_id),
static_cast<unsigned int>(msDescriptor.hdr_ver), msDescriptor.eq_id, msDescriptor.flags,
static_cast<unsigned int>(msDescriptor.sys_id),
static_cast<unsigned int>(msDescriptor.sys_ver), msDescriptor.idx, msDescriptor.crc,
msDescriptor.size, msDescriptor.offset );
*/
LOG(info) << FormatMsHeaderPrintout(msDescriptor);
LOG(warning) << "Could not find the gDPB index for AFCK id 0x" << std::hex << fuCurrDpbId << std::dec
<< " in timeslice " << fulCurrentTsIdx << " in microslice " << uMsIdx << " component " << uMsCompIdx
<< "\n"
<< "If valid this index has to be added in the TOF "
"parameter file in the DbpIdArray field";
fvbMaskedComponents[uMsCompIdx] = kTRUE;
} // if( kFALSE == fvbMaskedComponents[ uMsComp ] )
else
return kTRUE;
/// Try to get it from the second message in buffer (first is epoch cycle without gDPB ID)
/// TODO!!!!
return kFALSE;
} // if( it == fGdpbIdIndexMap.end() )
else
fuCurrDpbIdx = fGdpbIdIndexMap[fuCurrDpbId];
/// Spill Detection
if (0 == fuCurrDpbIdx) {
/// Check only every user defined interval (0.5s per default)
if (fdSpillCheckInterval < fdMsTime - fdLastSecondTime) {
/// Spill Off detection
if (fbSpillOn && fuCountsLastInterval < fuOffSpillCountLimit) {
fbSpillOn = kFALSE;
fuCurrentSpillIdx++;
fdStartTimeSpill = fdMsTime;
if( 0 < fvuSpillBreakBegTs.size() )
{
fhSpillDuration->Fill( fulCurrentTsIdx - fvuSpillBreakBegTs.back() );
} // if( 0 < fvuSpillBreakBegTs.size() )
fvuSpillBreakBegTs.push_back( fulCurrentTsIdx );
} // if( fbSpillOn && fuCountsLastInterval < fuOffSpillCountLimit )
else if (!fbSpillOn && fuOffSpillCountLimit < fuCountsLastInterval) {
fbSpillOn = kTRUE;
if( 0 < fvuSpillBreakBegTs.size() )
{
fhSpillBreakDuration->Fill( fuCurrentSpillIdx, fulCurrentTsIdx - fvuSpillBreakBegTs.back() );
} // if( 0 < fvuSpillBreakBegTs.size() )
if( 0 < fvuSpillBreakEndTs.size() )
{
fhHitsPerSpill->Fill( fuCurrentSpillIdx, fuCountsLastSpill );
fhSpillDuration->Fill( fuCurrentSpillIdx, fulCurrentTsIdx - fvuSpillBreakEndTs.back() );
} // if( 0 < fvuSpillBreakEndTs.size() )
fvuSpillBreakEndTs.push_back( fulCurrentTsIdx );
fuCountsLastSpill = 0;
} // else if (fuOffSpillCountLimit < fuCountsLastInterval)
fuCountsLastInterval = 0;
fdLastSecondTime = fdMsTime;
} // if( fdSpillCheckInterval < fdMsTime - fdLastSecondTime )
} // if( 0 == fuCurrDpbIdx )
/// Save start time of first valid MS )
if (fdStartTime < 0) fdStartTime = fdMsTime;
/// Reset the histograms if reached the end of the evolution histos range
else if (fuHistoryHistoSize < fdMsTime - fdStartTime) {
ResetHistograms();
fdStartTime = fdMsTime;
} // else if( fuHistoryHistoSize < fdMsTime - fdStartTime )
// If not integer number of message in input buffer, print warning/error
if (0 != (uSize % kuBytesPerMessage))
LOG(error) << "The input microslice buffer does NOT "
<< "contain only complete nDPB messages!";
// Compute the number of complete messages in the input microslice buffer
uint32_t uNbMessages = (uSize - (uSize % kuBytesPerMessage)) / kuBytesPerMessage;
// Prepare variables for the loop on contents
Int_t messageType = -111;
ULong64_t ulNbHitsTs = 0;
const uint64_t* pInBuff = reinterpret_cast<const uint64_t*>(msContent);
for (uint32_t uIdx = 0; uIdx < uNbMessages; uIdx++) {
// Fill message
uint64_t ulData = static_cast<uint64_t>(pInBuff[uIdx]);
/// Catch the Epoch cycle block which is always the first 64b of the MS
if (0 == uIdx) {
continue;
} // if( 0 == uIdx )
gdpbv100::Message mess(ulData);
/// Get message type
messageType = mess.getMessageType();
fuGet4Id = mess.getGdpbGenChipId();
fuGet4Nr = fuGet4Id / 2;
// UInt_t uChannelT0 = ( fuGet4Id < 32 ) ? ( fuGet4Id / 8 ) : (fuGet4Id / 8 - 1); /// December 2018 mapping
// UInt_t uChannelT0 = fuGet4Id / 2 + 4 * fuCurrDpbIdx; /// 2019 mapping with 320/640 Mb/s FW
if (fuNrOfGet4PerGdpb <= fuGet4Id && !mess.isStarTrigger() && (gdpbv100::kuChipIdMergedEpoch != fuGet4Id))
LOG(warning) << "Message with Get4 ID too high: " << fuGet4Id << " VS " << fuNrOfGet4PerGdpb
<< " set in parameters.";