CbmRoot
Loading...
Searching...
No Matches
CbmDeviceMcbmEventSink Class Reference

#include <CbmDeviceMcbmEventSink.h>

Inheritance diagram for CbmDeviceMcbmEventSink:
[legend]
Collaboration diagram for CbmDeviceMcbmEventSink:
[legend]

Public Member Functions

 CbmDeviceMcbmEventSink ()
 
virtual ~CbmDeviceMcbmEventSink ()
 

Protected Member Functions

virtual void InitTask ()
 
bool HandleMissTsData (FairMQMessagePtr &, int)
 
bool HandleData (FairMQParts &, int)
 
bool HandleCommand (FairMQMessagePtr &, int)
 

Private Member Functions

bool IsChannelNameAllowed (std::string channelName)
 Internal methods.
 
void CheckTsQueues ()
 
void PrepareTreeEntry (CbmUnpackedTimeslice unpTs)
 
void DumpTreeEntry ()
 
bool SendHistograms ()
 
void Finish ()
 

Private Attributes

Bool_t fbFillHistos = kFALSE
 Constants.
 
Bool_t fbFinishDone = kFALSE
 Switch ON/OFF filling of histograms.
 
std::string fsOutputFileName = "mcbm_digis_events.root"
 Keep track of whether the Finish was already called.
 
std::string fsChannelNameMissedTs = "missedts"
 message queues
 
std::string fsChannelNameDataInput = "events"
 
std::string fsChannelNameCommands = "commands"
 
std::string fsChannelNameHistosInput = "histogram-in"
 
std::string fsChannelNameHistosConfig = "histo-conf"
 
std::string fsChannelNameCanvasConfig = "canvas-conf"
 
uint32_t fuPublishFreqTs = 100
 Histograms management.
 
double_t fdMinPublishTime = 0.5
 
double_t fdMaxPublishTime = 5.0
 
std::vector< std::string > fsAllowedChannels = {fsChannelNameDataInput}
 List of MQ channels names.
 
uint64_t fuPrevTsIndex = 0
 Parameters management.
 
uint64_t fulNumMessages = 0
 
uint64_t fulTsCounter = 0
 
uint64_t fulMissedTsCounter = 0
 
std::chrono::system_clock::time_point fLastPublishTime = std::chrono::system_clock::now()
 
bool fbReceivedEof = false
 Control Commands reception.
 
uint64_t fuLastTsIndex = 0
 
uint64_t fuTotalTsCount = 0
 
TClonesArray * fTimeSliceMetaDataArray = nullptr
 TS MetaData storage.
 
TimesliceMetaDatafTsMetaData = nullptr
 
std::vector< CbmTofDigi > * fvDigiBmon = nullptr
 Digis storage.
 
std::vector< CbmStsDigi > * fvDigiSts = nullptr
 
std::vector< CbmMuchBeamTimeDigi > * fvDigiMuch = nullptr
 
std::vector< CbmTrdDigi > * fvDigiTrd = nullptr
 
std::vector< CbmTofDigi > * fvDigiTof = nullptr
 
std::vector< CbmRichDigi > * fvDigiRich = nullptr
 
std::vector< CbmPsdDigi > * fvDigiPsd = nullptr
 
TClonesArray * fEventsArray = nullptr
 CbmEvents.
 
std::vector< uint64_t > fvulMissedTsIndices = {}
 output container of CbmEvents
 
std::map< uint64_t, CbmUnpackedTimeslicefmFullTsStorage = {}
 Buffered TS.
 
FairRunOnline * fpRun = nullptr
 Data storage.
 
FairRootManager * fpFairRootMgr = nullptr
 
TObjArray fArrayHisto = {}
 Array of histograms to send to the histogram server.
 
std::vector< std::pair< std::string, std::string > > fvpsHistosFolder = {}
 Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server.
 
std::vector< std::pair< std::string, std::string > > fvpsCanvasConfig = {}
 

Detailed Description

Definition at line 64 of file CbmDeviceMcbmEventSink.h.

Constructor & Destructor Documentation

◆ CbmDeviceMcbmEventSink()

CbmDeviceMcbmEventSink::CbmDeviceMcbmEventSink ( )

Definition at line 59 of file CbmDeviceMcbmEventSink.cxx.

◆ ~CbmDeviceMcbmEventSink()

CbmDeviceMcbmEventSink::~CbmDeviceMcbmEventSink ( )
virtual

FIXME: Add pointers check before delete

Close things properly if not alredy done

Clear metadata

Clear vectors

Clear events TClonesArray

Definition at line 635 of file CbmDeviceMcbmEventSink.cxx.

References fbFinishDone, fEventsArray, Finish(), fpRun, fTimeSliceMetaDataArray, fTsMetaData, fvDigiBmon, fvDigiMuch, fvDigiPsd, fvDigiRich, fvDigiSts, fvDigiTof, and fvDigiTrd.

Member Function Documentation

◆ CheckTsQueues()

void CbmDeviceMcbmEventSink::CheckTsQueues ( )
private

Check if the first TS in the full TS queue is the next one

Fill all storage variables registers for data output

Trigger FairRoot manager to dump Tree entry

Update counters

Increment iterator

Check if the first TS in the missed TS queue is the next one

Prepare entry with only dummy TS metadata and empty storage variables

Trigger FairRoot manager to dump Tree entry

Update counters

Increment iterator

Should be reached only if both queues at the end or hole found in both

Delete the processed entries

End of data: clean save of data + close file + send last state of histos if enabled

Definition at line 476 of file CbmDeviceMcbmEventSink.cxx.

References DumpTreeEntry(), fbReceivedEof, Finish(), fmFullTsStorage, fTimeSliceMetaDataArray, fuLastTsIndex, fulMissedTsCounter, fulTsCounter, fuPrevTsIndex, fuTotalTsCount, fvulMissedTsIndices, and PrepareTreeEntry().

Referenced by HandleData(), and HandleMissTsData().

◆ DumpTreeEntry()

void CbmDeviceMcbmEventSink::DumpTreeEntry ( )
private

FairRunOnline style

Clear metadata array

Clear vectors

Clear event array

Definition at line 578 of file CbmDeviceMcbmEventSink.cxx.

References fEventsArray, fpFairRootMgr, fTimeSliceMetaDataArray, fvDigiBmon, fvDigiMuch, fvDigiPsd, fvDigiRich, fvDigiSts, fvDigiTof, and fvDigiTrd.

Referenced by CheckTsQueues(), and HandleData().

◆ Finish()

void CbmDeviceMcbmEventSink::Finish ( )
private

◆ HandleCommand()

bool CbmDeviceMcbmEventSink::HandleCommand ( FairMQMessagePtr & msg,
int  )
protected

Extract the last TS index and global full TS count

Last TS index

Total TS count

End of data: clean save of data + close file + send last state of histos if enabled

TODO: different treatment in case of "BAD" ending compared to EOF? Source failure: clean save of received data + close file + send last state of histos if enabled

Definition at line 413 of file CbmDeviceMcbmEventSink.cxx.

References fbReceivedEof, Finish(), fuLastTsIndex, fulTsCounter, fuPrevTsIndex, and fuTotalTsCount.

Referenced by InitTask().

◆ HandleData()

bool CbmDeviceMcbmEventSink::HandleData ( FairMQParts & parts,
int  )
protected

Extract unpacked data from input message

TS metadata TODO: code order of vectors in the TS MetaData!!

FIXME: Need to check if TS arrived in order (probably not!!!) + buffer!!!

Fill all storage variables registers for data output

Trigger FairRoot manager to dump Tree entry

Update counters

If not consecutive to last TS sent,

Clear metadata => crashes, maybe not needed as due to move the pointer is invalidated?

Check TS queue and process it if needed (in case it filled a hole!)

Histograms management

Send histograms each 100 time slices. Should be each ~1s Use also runtime checker to trigger sending after M s if processing too slow or delay sending if processing too fast

Definition at line 345 of file CbmDeviceMcbmEventSink.cxx.

References CheckTsQueues(), DumpTreeEntry(), fbFillHistos, fdMaxPublishTime, fdMinPublishTime, fLastPublishTime, fmFullTsStorage, fTsMetaData, fulNumMessages, fulTsCounter, fuPrevTsIndex, fuPublishFreqTs, TimesliceMetaData::GetIndex(), PrepareTreeEntry(), and SendHistograms().

Referenced by InitTask().

◆ HandleMissTsData()

bool CbmDeviceMcbmEventSink::HandleMissTsData ( FairMQMessagePtr & msg,
int  )
protected

Check TS queue and process it if needed (in case it filled a hole!)

Definition at line 328 of file CbmDeviceMcbmEventSink.cxx.

References CheckTsQueues(), and fvulMissedTsIndices.

Referenced by InitTask().

◆ InitTask()

void CbmDeviceMcbmEventSink::InitTask ( )
protectedvirtual

Read options from executable

Associate the MissedTs Channel to the corresponding handler

Associate the command Channel to the corresponding handler

Associate the Event + Unp data Channel to the corresponding handler

Create input vectors

Prepare storage TClonesArrays TS MetaData storage

Events storage

TODO: remove TObject from CbmEvent and switch to vectors!

Prepare root output

Register all input data members with the FairRoot manager TS MetaData

Digis storage

CbmEvent

Histograms management

Definition at line 61 of file CbmDeviceMcbmEventSink.cxx.

References fbFillHistos, fdMaxPublishTime, fdMinPublishTime, fEventsArray, fpFairRootMgr, fpRun, fsAllowedChannels, fsChannelNameCanvasConfig, fsChannelNameCommands, fsChannelNameDataInput, fsChannelNameHistosConfig, fsChannelNameHistosInput, fsChannelNameMissedTs, fsOutputFileName, fTimeSliceMetaDataArray, fuPublishFreqTs, fvDigiBmon, fvDigiMuch, fvDigiPsd, fvDigiRich, fvDigiSts, fvDigiTof, fvDigiTrd, HandleCommand(), HandleData(), HandleMissTsData(), and IsChannelNameAllowed().

◆ IsChannelNameAllowed()

bool CbmDeviceMcbmEventSink::IsChannelNameAllowed ( std::string channelName)
private

Internal methods.

Definition at line 247 of file CbmDeviceMcbmEventSink.cxx.

References fsAllowedChannels, and pos.

Referenced by InitTask().

◆ PrepareTreeEntry()

void CbmDeviceMcbmEventSink::PrepareTreeEntry ( CbmUnpackedTimeslice unpTs)
private

FIXME: poor man solution with lots of data copy until we undertsnad how to properly deal with FairMq messages ownership and memory managment

FIXME: Not sure if this is the proper way to insert the data

move version: safe but slow Bmon

STS

MUCH

TRD

BmonF

RICH

PSD

Extract CbmEvent TClonesArray from input message

Definition at line 533 of file CbmDeviceMcbmEventSink.cxx.

References fEventsArray, CbmUnpackedTimeslice::fEventsArray, fTimeSliceMetaDataArray, CbmUnpackedTimeslice::fTsMetaData, CbmUnpackedTimeslice::fvDigiBmon, CbmUnpackedTimeslice::fvDigiMuch, CbmUnpackedTimeslice::fvDigiPsd, CbmUnpackedTimeslice::fvDigiRich, CbmUnpackedTimeslice::fvDigiSts, CbmUnpackedTimeslice::fvDigiTof, and CbmUnpackedTimeslice::fvDigiTrd.

Referenced by CheckTsQueues(), and HandleData().

◆ SendHistograms()

bool CbmDeviceMcbmEventSink::SendHistograms ( )
private

Serialize the array of histos into a single MQ message

Send message to the common histogram messages queue

Reset the histograms after sending them (but do not reset the time)

Definition at line 615 of file CbmDeviceMcbmEventSink.cxx.

References fArrayHisto, and fsChannelNameHistosInput.

Referenced by Finish(), and HandleData().

Member Data Documentation

◆ fArrayHisto

TObjArray CbmDeviceMcbmEventSink::fArrayHisto = {}
private

Array of histograms to send to the histogram server.

Definition at line 145 of file CbmDeviceMcbmEventSink.h.

Referenced by SendHistograms().

◆ fbFillHistos

Bool_t CbmDeviceMcbmEventSink::fbFillHistos = kFALSE
private

Constants.

Control flags

Definition at line 79 of file CbmDeviceMcbmEventSink.h.

Referenced by Finish(), HandleData(), and InitTask().

◆ fbFinishDone

Bool_t CbmDeviceMcbmEventSink::fbFinishDone = kFALSE
private

Switch ON/OFF filling of histograms.

Definition at line 80 of file CbmDeviceMcbmEventSink.h.

Referenced by Finish(), and ~CbmDeviceMcbmEventSink().

◆ fbReceivedEof

bool CbmDeviceMcbmEventSink::fbReceivedEof = false
private

Control Commands reception.

Definition at line 112 of file CbmDeviceMcbmEventSink.h.

Referenced by CheckTsQueues(), and HandleCommand().

◆ fdMaxPublishTime

double_t CbmDeviceMcbmEventSink::fdMaxPublishTime = 5.0
private

Definition at line 95 of file CbmDeviceMcbmEventSink.h.

Referenced by HandleData(), and InitTask().

◆ fdMinPublishTime

double_t CbmDeviceMcbmEventSink::fdMinPublishTime = 0.5
private

Definition at line 94 of file CbmDeviceMcbmEventSink.h.

Referenced by HandleData(), and InitTask().

◆ fEventsArray

TClonesArray* CbmDeviceMcbmEventSink::fEventsArray = nullptr
private

CbmEvents.

Definition at line 131 of file CbmDeviceMcbmEventSink.h.

Referenced by DumpTreeEntry(), InitTask(), PrepareTreeEntry(), and ~CbmDeviceMcbmEventSink().

◆ fLastPublishTime

std::chrono::system_clock::time_point CbmDeviceMcbmEventSink::fLastPublishTime = std::chrono::system_clock::now()
private

Definition at line 109 of file CbmDeviceMcbmEventSink.h.

Referenced by Finish(), and HandleData().

◆ fmFullTsStorage

std::map<uint64_t, CbmUnpackedTimeslice> CbmDeviceMcbmEventSink::fmFullTsStorage = {}
private

Buffered TS.

Definition at line 138 of file CbmDeviceMcbmEventSink.h.

Referenced by CheckTsQueues(), and HandleData().

◆ fpFairRootMgr

FairRootManager* CbmDeviceMcbmEventSink::fpFairRootMgr = nullptr
private

Definition at line 142 of file CbmDeviceMcbmEventSink.h.

Referenced by DumpTreeEntry(), Finish(), and InitTask().

◆ fpRun

FairRunOnline* CbmDeviceMcbmEventSink::fpRun = nullptr
private

Data storage.

Definition at line 141 of file CbmDeviceMcbmEventSink.h.

Referenced by InitTask(), and ~CbmDeviceMcbmEventSink().

◆ fsAllowedChannels

std::vector<std::string> CbmDeviceMcbmEventSink::fsAllowedChannels = {fsChannelNameDataInput}
private

List of MQ channels names.

Definition at line 98 of file CbmDeviceMcbmEventSink.h.

Referenced by InitTask(), and IsChannelNameAllowed().

◆ fsChannelNameCanvasConfig

std::string CbmDeviceMcbmEventSink::fsChannelNameCanvasConfig = "canvas-conf"
private

Definition at line 91 of file CbmDeviceMcbmEventSink.h.

Referenced by InitTask().

◆ fsChannelNameCommands

std::string CbmDeviceMcbmEventSink::fsChannelNameCommands = "commands"
private

Definition at line 88 of file CbmDeviceMcbmEventSink.h.

Referenced by InitTask().

◆ fsChannelNameDataInput

std::string CbmDeviceMcbmEventSink::fsChannelNameDataInput = "events"
private

Definition at line 87 of file CbmDeviceMcbmEventSink.h.

Referenced by InitTask().

◆ fsChannelNameHistosConfig

std::string CbmDeviceMcbmEventSink::fsChannelNameHistosConfig = "histo-conf"
private

Definition at line 90 of file CbmDeviceMcbmEventSink.h.

Referenced by InitTask().

◆ fsChannelNameHistosInput

std::string CbmDeviceMcbmEventSink::fsChannelNameHistosInput = "histogram-in"
private

Definition at line 89 of file CbmDeviceMcbmEventSink.h.

Referenced by InitTask(), and SendHistograms().

◆ fsChannelNameMissedTs

std::string CbmDeviceMcbmEventSink::fsChannelNameMissedTs = "missedts"
private

message queues

Definition at line 86 of file CbmDeviceMcbmEventSink.h.

Referenced by InitTask().

◆ fsOutputFileName

std::string CbmDeviceMcbmEventSink::fsOutputFileName = "mcbm_digis_events.root"
private

Keep track of whether the Finish was already called.

User settings parameters Algo enum settings

Definition at line 84 of file CbmDeviceMcbmEventSink.h.

Referenced by InitTask().

◆ fTimeSliceMetaDataArray

TClonesArray* CbmDeviceMcbmEventSink::fTimeSliceMetaDataArray = nullptr
private

TS MetaData storage.

Data reception Event (TS) header

Definition at line 120 of file CbmDeviceMcbmEventSink.h.

Referenced by CheckTsQueues(), DumpTreeEntry(), InitTask(), PrepareTreeEntry(), and ~CbmDeviceMcbmEventSink().

◆ fTsMetaData

TimesliceMetaData* CbmDeviceMcbmEventSink::fTsMetaData = nullptr
private

Definition at line 121 of file CbmDeviceMcbmEventSink.h.

Referenced by HandleData(), and ~CbmDeviceMcbmEventSink().

◆ fuLastTsIndex

uint64_t CbmDeviceMcbmEventSink::fuLastTsIndex = 0
private

Definition at line 113 of file CbmDeviceMcbmEventSink.h.

Referenced by CheckTsQueues(), and HandleCommand().

◆ fulMissedTsCounter

uint64_t CbmDeviceMcbmEventSink::fulMissedTsCounter = 0
private

Definition at line 108 of file CbmDeviceMcbmEventSink.h.

Referenced by CheckTsQueues(), and Finish().

◆ fulNumMessages

uint64_t CbmDeviceMcbmEventSink::fulNumMessages = 0
private

Definition at line 106 of file CbmDeviceMcbmEventSink.h.

Referenced by HandleData().

◆ fulTsCounter

uint64_t CbmDeviceMcbmEventSink::fulTsCounter = 0
private

Definition at line 107 of file CbmDeviceMcbmEventSink.h.

Referenced by CheckTsQueues(), Finish(), HandleCommand(), and HandleData().

◆ fuPrevTsIndex

uint64_t CbmDeviceMcbmEventSink::fuPrevTsIndex = 0
private

Parameters management.

Statistics & missed TS detection

Definition at line 105 of file CbmDeviceMcbmEventSink.h.

Referenced by CheckTsQueues(), HandleCommand(), and HandleData().

◆ fuPublishFreqTs

uint32_t CbmDeviceMcbmEventSink::fuPublishFreqTs = 100
private

Histograms management.

Definition at line 93 of file CbmDeviceMcbmEventSink.h.

Referenced by HandleData(), and InitTask().

◆ fuTotalTsCount

uint64_t CbmDeviceMcbmEventSink::fuTotalTsCount = 0
private

Definition at line 114 of file CbmDeviceMcbmEventSink.h.

Referenced by CheckTsQueues(), and HandleCommand().

◆ fvDigiBmon

std::vector<CbmTofDigi>* CbmDeviceMcbmEventSink::fvDigiBmon = nullptr
private

Digis storage.

Definition at line 123 of file CbmDeviceMcbmEventSink.h.

Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().

◆ fvDigiMuch

std::vector<CbmMuchBeamTimeDigi>* CbmDeviceMcbmEventSink::fvDigiMuch = nullptr
private

Definition at line 125 of file CbmDeviceMcbmEventSink.h.

Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().

◆ fvDigiPsd

std::vector<CbmPsdDigi>* CbmDeviceMcbmEventSink::fvDigiPsd = nullptr
private

Definition at line 129 of file CbmDeviceMcbmEventSink.h.

Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().

◆ fvDigiRich

std::vector<CbmRichDigi>* CbmDeviceMcbmEventSink::fvDigiRich = nullptr
private

Definition at line 128 of file CbmDeviceMcbmEventSink.h.

Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().

◆ fvDigiSts

std::vector<CbmStsDigi>* CbmDeviceMcbmEventSink::fvDigiSts = nullptr
private

Definition at line 124 of file CbmDeviceMcbmEventSink.h.

Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().

◆ fvDigiTof

std::vector<CbmTofDigi>* CbmDeviceMcbmEventSink::fvDigiTof = nullptr
private

Definition at line 127 of file CbmDeviceMcbmEventSink.h.

Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().

◆ fvDigiTrd

std::vector<CbmTrdDigi>* CbmDeviceMcbmEventSink::fvDigiTrd = nullptr
private

Definition at line 126 of file CbmDeviceMcbmEventSink.h.

Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().

◆ fvpsCanvasConfig

std::vector<std::pair<std::string, std::string> > CbmDeviceMcbmEventSink::fvpsCanvasConfig = {}
private

Vector of string pairs with ( CanvasName, CanvasConfig ) to send to the histogram server Format of Can config is "NbPadX(U);NbPadY(U);ConfigPad1(s);....;ConfigPadXY(s)" Format of Pad config is "GrixX(b),GridY(b),LogX(b),LogY(b),LogZ(b),HistoName(s),DrawOptions(s)"

Definition at line 151 of file CbmDeviceMcbmEventSink.h.

◆ fvpsHistosFolder

std::vector<std::pair<std::string, std::string> > CbmDeviceMcbmEventSink::fvpsHistosFolder = {}
private

Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server.

Definition at line 147 of file CbmDeviceMcbmEventSink.h.

◆ fvulMissedTsIndices

std::vector<uint64_t> CbmDeviceMcbmEventSink::fvulMissedTsIndices = {}
private

output container of CbmEvents

Storage for re-ordering Missed TS vector

Definition at line 136 of file CbmDeviceMcbmEventSink.h.

Referenced by CheckTsQueues(), and HandleMissTsData().


The documentation for this class was generated from the following files: