CbmRoot
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. More...
 
void CheckTsQueues ()
 
void PrepareTreeEntry (CbmUnpackedTimeslice unpTs)
 
void DumpTreeEntry ()
 
bool SendHistograms ()
 
void Finish ()
 

Private Attributes

Bool_t fbFillHistos = kFALSE
 Constants. More...
 
Bool_t fbFinishDone
 Switch ON/OFF filling of histograms. More...
 
std::string fsOutputFileName = "mcbm_digis_events.root"
 Keep track of whether the Finish was already called. More...
 
std::string fsChannelNameMissedTs = "missedts"
 message queues More...
 
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. More...
 
double_t fdMinPublishTime = 0.5
 
double_t fdMaxPublishTime = 5.0
 
std::vector< std::string > fsAllowedChannels = {fsChannelNameDataInput}
 List of MQ channels names. More...
 
uint64_t fuPrevTsIndex = 0
 Parameters management. More...
 
uint64_t fulNumMessages = 0
 
uint64_t fulTsCounter = 0
 
uint64_t fulMissedTsCounter = 0
 
std::chrono::system_clock::time_point fLastPublishTime
 
bool fbReceivedEof = false
 Control Commands reception. More...
 
uint64_t fuLastTsIndex = 0
 
uint64_t fuTotalTsCount = 0
 
TClonesArray * fTimeSliceMetaDataArray = nullptr
 TS MetaData storage. More...
 
TimesliceMetaDatafTsMetaData = nullptr
 
std::vector< CbmTofDigi > * fvDigiT0 = nullptr
 Digis storage. More...
 
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. More...
 
std::vector< uint64_t > fvulMissedTsIndices = {}
 output container of CbmEvents More...
 
std::map< uint64_t, CbmUnpackedTimeslicefmFullTsStorage = {}
 Buffered TS. More...
 
FairRunOnline * fpRun = nullptr
 Data storage. More...
 
FairRootManager * fpFairRootMgr = nullptr
 
TFile * fpOutRootFile = nullptr
 
TObjArray fArrayHisto = {}
 Array of histograms to send to the histogram server. More...
 
std::vector< std::pair< std::string, std::string > > fvpsHistosFolder = {}
 Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server. More...
 
std::vector< std::pair< std::string, std::string > > fvpsCanvasConfig = {}
 

Detailed Description

Definition at line 58 of file CbmDeviceMcbmEventSink.h.

Constructor & Destructor Documentation

◆ CbmDeviceMcbmEventSink()

CbmDeviceMcbmEventSink::CbmDeviceMcbmEventSink ( )

Definition at line 52 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 641 of file CbmDeviceMcbmEventSink.cxx.

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 481 of file CbmDeviceMcbmEventSink.cxx.

◆ DumpTreeEntry()

void CbmDeviceMcbmEventSink::DumpTreeEntry ( )
private

FairRunOnline style

Clear metadata array

Clear vectors

Clear event array

Definition at line 587 of file CbmDeviceMcbmEventSink.cxx.

◆ Finish()

void CbmDeviceMcbmEventSink::Finish ( )
private

Definition at line 668 of file CbmDeviceMcbmEventSink.cxx.

References cbm::mq::ChangeState().

◆ 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 415 of file CbmDeviceMcbmEventSink.cxx.

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 341 of file CbmDeviceMcbmEventSink.cxx.

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 323 of file CbmDeviceMcbmEventSink.cxx.

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 54 of file CbmDeviceMcbmEventSink.cxx.

References HandleCommand(), HandleData(), and HandleMissTsData().

◆ IsChannelNameAllowed()

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

Internal methods.

Definition at line 239 of file CbmDeviceMcbmEventSink.cxx.

References pos.

◆ 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 T0

STS

MUCH

TRD

T0F

RICH

PSD

Extract CbmEvent TClonesArray from input message

Definition at line 543 of file CbmDeviceMcbmEventSink.cxx.

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

◆ 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 623 of file CbmDeviceMcbmEventSink.cxx.

Member Data Documentation

◆ fArrayHisto

TObjArray CbmDeviceMcbmEventSink::fArrayHisto = {}
private

Array of histograms to send to the histogram server.

Definition at line 142 of file CbmDeviceMcbmEventSink.h.

◆ fbFillHistos

Bool_t CbmDeviceMcbmEventSink::fbFillHistos = kFALSE
private

Constants.

Control flags

Definition at line 73 of file CbmDeviceMcbmEventSink.h.

◆ fbFinishDone

Bool_t CbmDeviceMcbmEventSink::fbFinishDone
private
Initial value:
=
kFALSE

Switch ON/OFF filling of histograms.

Definition at line 74 of file CbmDeviceMcbmEventSink.h.

◆ fbReceivedEof

bool CbmDeviceMcbmEventSink::fbReceivedEof = false
private

Control Commands reception.

Definition at line 108 of file CbmDeviceMcbmEventSink.h.

◆ fdMaxPublishTime

double_t CbmDeviceMcbmEventSink::fdMaxPublishTime = 5.0
private

Definition at line 90 of file CbmDeviceMcbmEventSink.h.

◆ fdMinPublishTime

double_t CbmDeviceMcbmEventSink::fdMinPublishTime = 0.5
private

Definition at line 89 of file CbmDeviceMcbmEventSink.h.

◆ fEventsArray

TClonesArray* CbmDeviceMcbmEventSink::fEventsArray = nullptr
private

CbmEvents.

Definition at line 127 of file CbmDeviceMcbmEventSink.h.

◆ fLastPublishTime

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

Definition at line 104 of file CbmDeviceMcbmEventSink.h.

◆ fmFullTsStorage

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

Buffered TS.

Definition at line 134 of file CbmDeviceMcbmEventSink.h.

◆ fpFairRootMgr

FairRootManager* CbmDeviceMcbmEventSink::fpFairRootMgr = nullptr
private

Definition at line 138 of file CbmDeviceMcbmEventSink.h.

◆ fpOutRootFile

TFile* CbmDeviceMcbmEventSink::fpOutRootFile = nullptr
private

Definition at line 139 of file CbmDeviceMcbmEventSink.h.

◆ fpRun

FairRunOnline* CbmDeviceMcbmEventSink::fpRun = nullptr
private

Data storage.

Definition at line 137 of file CbmDeviceMcbmEventSink.h.

◆ fsAllowedChannels

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

List of MQ channels names.

Definition at line 93 of file CbmDeviceMcbmEventSink.h.

◆ fsChannelNameCanvasConfig

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

Definition at line 86 of file CbmDeviceMcbmEventSink.h.

◆ fsChannelNameCommands

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

Definition at line 83 of file CbmDeviceMcbmEventSink.h.

◆ fsChannelNameDataInput

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

Definition at line 82 of file CbmDeviceMcbmEventSink.h.

◆ fsChannelNameHistosConfig

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

Definition at line 85 of file CbmDeviceMcbmEventSink.h.

◆ fsChannelNameHistosInput

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

Definition at line 84 of file CbmDeviceMcbmEventSink.h.

◆ fsChannelNameMissedTs

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

message queues

Definition at line 81 of file CbmDeviceMcbmEventSink.h.

◆ 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 79 of file CbmDeviceMcbmEventSink.h.

◆ fTimeSliceMetaDataArray

TClonesArray* CbmDeviceMcbmEventSink::fTimeSliceMetaDataArray = nullptr
private

TS MetaData storage.

Data reception Event (TS) header

Definition at line 116 of file CbmDeviceMcbmEventSink.h.

◆ fTsMetaData

TimesliceMetaData* CbmDeviceMcbmEventSink::fTsMetaData = nullptr
private

Definition at line 117 of file CbmDeviceMcbmEventSink.h.

◆ fuLastTsIndex

uint64_t CbmDeviceMcbmEventSink::fuLastTsIndex = 0
private

Definition at line 109 of file CbmDeviceMcbmEventSink.h.

◆ fulMissedTsCounter

uint64_t CbmDeviceMcbmEventSink::fulMissedTsCounter = 0
private

Definition at line 103 of file CbmDeviceMcbmEventSink.h.

◆ fulNumMessages

uint64_t CbmDeviceMcbmEventSink::fulNumMessages = 0
private

Definition at line 101 of file CbmDeviceMcbmEventSink.h.

◆ fulTsCounter

uint64_t CbmDeviceMcbmEventSink::fulTsCounter = 0
private

Definition at line 102 of file CbmDeviceMcbmEventSink.h.

◆ fuPrevTsIndex

uint64_t CbmDeviceMcbmEventSink::fuPrevTsIndex = 0
private

Parameters management.

Statistics & missed TS detection

Definition at line 100 of file CbmDeviceMcbmEventSink.h.

◆ fuPublishFreqTs

uint32_t CbmDeviceMcbmEventSink::fuPublishFreqTs = 100
private

Histograms management.

Definition at line 88 of file CbmDeviceMcbmEventSink.h.

◆ fuTotalTsCount

uint64_t CbmDeviceMcbmEventSink::fuTotalTsCount = 0
private

Definition at line 110 of file CbmDeviceMcbmEventSink.h.

◆ fvDigiMuch

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

Definition at line 121 of file CbmDeviceMcbmEventSink.h.

◆ fvDigiPsd

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

Definition at line 125 of file CbmDeviceMcbmEventSink.h.

◆ fvDigiRich

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

Definition at line 124 of file CbmDeviceMcbmEventSink.h.

◆ fvDigiSts

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

Definition at line 120 of file CbmDeviceMcbmEventSink.h.

◆ fvDigiT0

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

Digis storage.

Definition at line 119 of file CbmDeviceMcbmEventSink.h.

◆ fvDigiTof

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

Definition at line 123 of file CbmDeviceMcbmEventSink.h.

◆ fvDigiTrd

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

Definition at line 122 of file CbmDeviceMcbmEventSink.h.

◆ 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 148 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 144 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 132 of file CbmDeviceMcbmEventSink.h.


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