CbmRoot
|
#include <CbmDeviceMcbmEventSink.h>
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. | |
TimesliceMetaData * | fTsMetaData = 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, CbmUnpackedTimeslice > | fmFullTsStorage = {} |
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 = {} |
Definition at line 64 of file CbmDeviceMcbmEventSink.h.
CbmDeviceMcbmEventSink::CbmDeviceMcbmEventSink | ( | ) |
Definition at line 59 of file CbmDeviceMcbmEventSink.cxx.
|
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.
|
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().
|
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().
|
private |
Definition at line 663 of file CbmDeviceMcbmEventSink.cxx.
References fbFillHistos, fbFinishDone, fLastPublishTime, fpFairRootMgr, fulMissedTsCounter, fulTsCounter, and SendHistograms().
Referenced by CheckTsQueues(), HandleCommand(), and ~CbmDeviceMcbmEventSink().
|
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().
|
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().
|
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().
|
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
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().
|
private |
Internal methods.
Definition at line 247 of file CbmDeviceMcbmEventSink.cxx.
References fsAllowedChannels, and pos.
Referenced by InitTask().
|
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().
|
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().
|
private |
Array of histograms to send to the histogram server.
Definition at line 145 of file CbmDeviceMcbmEventSink.h.
Referenced by SendHistograms().
|
private |
Constants.
Control flags
Definition at line 79 of file CbmDeviceMcbmEventSink.h.
Referenced by Finish(), HandleData(), and InitTask().
|
private |
Switch ON/OFF filling of histograms.
Definition at line 80 of file CbmDeviceMcbmEventSink.h.
Referenced by Finish(), and ~CbmDeviceMcbmEventSink().
|
private |
Control Commands reception.
Definition at line 112 of file CbmDeviceMcbmEventSink.h.
Referenced by CheckTsQueues(), and HandleCommand().
|
private |
Definition at line 95 of file CbmDeviceMcbmEventSink.h.
Referenced by HandleData(), and InitTask().
|
private |
Definition at line 94 of file CbmDeviceMcbmEventSink.h.
Referenced by HandleData(), and InitTask().
|
private |
CbmEvents.
Definition at line 131 of file CbmDeviceMcbmEventSink.h.
Referenced by DumpTreeEntry(), InitTask(), PrepareTreeEntry(), and ~CbmDeviceMcbmEventSink().
|
private |
Definition at line 109 of file CbmDeviceMcbmEventSink.h.
Referenced by Finish(), and HandleData().
|
private |
Buffered TS.
Definition at line 138 of file CbmDeviceMcbmEventSink.h.
Referenced by CheckTsQueues(), and HandleData().
|
private |
Definition at line 142 of file CbmDeviceMcbmEventSink.h.
Referenced by DumpTreeEntry(), Finish(), and InitTask().
|
private |
Data storage.
Definition at line 141 of file CbmDeviceMcbmEventSink.h.
Referenced by InitTask(), and ~CbmDeviceMcbmEventSink().
|
private |
List of MQ channels names.
Definition at line 98 of file CbmDeviceMcbmEventSink.h.
Referenced by InitTask(), and IsChannelNameAllowed().
|
private |
Definition at line 91 of file CbmDeviceMcbmEventSink.h.
Referenced by InitTask().
|
private |
Definition at line 88 of file CbmDeviceMcbmEventSink.h.
Referenced by InitTask().
|
private |
Definition at line 87 of file CbmDeviceMcbmEventSink.h.
Referenced by InitTask().
|
private |
Definition at line 90 of file CbmDeviceMcbmEventSink.h.
Referenced by InitTask().
|
private |
Definition at line 89 of file CbmDeviceMcbmEventSink.h.
Referenced by InitTask(), and SendHistograms().
|
private |
|
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().
|
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().
|
private |
Definition at line 121 of file CbmDeviceMcbmEventSink.h.
Referenced by HandleData(), and ~CbmDeviceMcbmEventSink().
|
private |
Definition at line 113 of file CbmDeviceMcbmEventSink.h.
Referenced by CheckTsQueues(), and HandleCommand().
|
private |
Definition at line 108 of file CbmDeviceMcbmEventSink.h.
Referenced by CheckTsQueues(), and Finish().
|
private |
Definition at line 106 of file CbmDeviceMcbmEventSink.h.
Referenced by HandleData().
|
private |
Definition at line 107 of file CbmDeviceMcbmEventSink.h.
Referenced by CheckTsQueues(), Finish(), HandleCommand(), and HandleData().
|
private |
Parameters management.
Statistics & missed TS detection
Definition at line 105 of file CbmDeviceMcbmEventSink.h.
Referenced by CheckTsQueues(), HandleCommand(), and HandleData().
|
private |
Histograms management.
Definition at line 93 of file CbmDeviceMcbmEventSink.h.
Referenced by HandleData(), and InitTask().
|
private |
Definition at line 114 of file CbmDeviceMcbmEventSink.h.
Referenced by CheckTsQueues(), and HandleCommand().
|
private |
Digis storage.
Definition at line 123 of file CbmDeviceMcbmEventSink.h.
Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().
|
private |
Definition at line 125 of file CbmDeviceMcbmEventSink.h.
Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().
|
private |
Definition at line 129 of file CbmDeviceMcbmEventSink.h.
Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().
|
private |
Definition at line 128 of file CbmDeviceMcbmEventSink.h.
Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().
|
private |
Definition at line 124 of file CbmDeviceMcbmEventSink.h.
Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().
|
private |
Definition at line 127 of file CbmDeviceMcbmEventSink.h.
Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().
|
private |
Definition at line 126 of file CbmDeviceMcbmEventSink.h.
Referenced by DumpTreeEntry(), InitTask(), and ~CbmDeviceMcbmEventSink().
|
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.
|
private |
Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server.
Definition at line 147 of file CbmDeviceMcbmEventSink.h.
|
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().