CbmRoot
Loading...
Searching...
No Matches
cbm::services::histserv::Application Class Reference

#include <Application.h>

Collaboration diagram for cbm::services::histserv::Application:
[legend]

Public Member Functions

 Application (ProgramOptions const &opt, volatile sig_atomic_t *signalStatus)
 Standard constructor, initialises the application.
 
 Application (const Application &)=delete
 Copy constructor forbidden.
 
void operator= (const Application &)=delete
 Assignment operator forbidden.
 
 ~Application ()
 Destructor.
 
void Exec ()
 Run the application.
 
void UpdateHttpServer ()
 
template<class HistoDst , class HistoSrc >
bool ReadHistogram (const HistoSrc &rHist)
 
template<class HistoSrc >
bool ReadHistogramExtendedTsId (const HistoSrc &rHist, uint64_t tsIndex)
 

Private Member Functions

int FindHistogram (const std::string &name)
 Collects histograms of the same type from the histogram list.
 
bool ResetHistograms ()
 Resets handled histograms.
 
template<class HistoDst , class HistoSrc >
bool ReadHistogram (const HistoSrc &rHist)
 Read a histogram.
 
template<class HistoSrc >
bool ReadHistogramExtendedTsId (const HistoSrc &pHistSrc, uint64_t tsIndex)
 Reads a histogram slice for an extended histogram with the TS ID.
 
bool ReceiveData (zmq::message_t &msg)
 Find histogram index in the histogram array.
 
bool ReceiveHistoConfig (zmq::message_t &msg)
 Receives histogram configuration.
 
bool ReceiveCanvasConfig (zmq::message_t &msg)
 Receives canvas configuration.
 
bool ReceiveConfigAndData (std::vector< zmq::message_t > &vMsg)
 Receives a list of canvases and histograms.
 
bool RegisterHistoConfig (const std::pair< std::string, std::string > &config)
 Register a histogram config in the histogram server.
 
bool RegisterHistogram (const TNamed *hist)
 Register a histogram in the histogram server.
 
bool PrepareCanvas (uint32_t uCanvIdx)
 Prepares canvases using received canvas configuration.
 
bool SaveHistograms ()
 Saves handled histograms.
 

Private Attributes

ProgramOptions const & fOpt
 A handler for system signals.
 
volatile sig_atomic_t * fSignalStatus
 Global signal status.
 
THttpServer * fServer = nullptr
 ROOT Histogram server (JSroot)
 
std::thread fThread
 
bool fStopThread = false
 
std::unique_ptr< UiCmdActorfUiCmdActor
 
zmq::context_t fZmqContext {1}
 Interface.
 
zmq::socket_t fZmqSocket {fZmqContext, ZMQ_PULL}
 
TObjArray fArrayHisto
 Array of histograms with unique names.
 
std::vector< std::pair< std::string, std::string > > fvpsHistosFolder = {}
 Vector of string with ( HistoName, FolderPath ) to configure the histogram.
 
std::vector< std::pair< std::string, std::string > > fvpsCanvasConfig = {}
 
std::vector< bool > fvbCanvasReady = {}
 
bool fbAllCanvasReady = false
 
AppConfig fConfig
 
std::vector< std::pair< TNamed *, std::string > > fvHistos = {}
 Vector of Histos pointers and folder path.
 
std::vector< bool > fvbHistoRegistered = {}
 
bool fbAllHistosRegistered = false
 
std::vector< std::pair< TCanvas *, std::string > > fvCanvas = {}
 Vector of Canvas pointers and folder path.
 
std::vector< bool > fvbCanvasRegistered = {}
 
bool fbAllCanvasRegistered = false
 
uint32_t fNMessages = 0
 Internal status.
 

Detailed Description

Definition at line 33 of file services/histserv/app/Application.h.

Constructor & Destructor Documentation

◆ Application() [1/2]

Application::Application ( ProgramOptions const & opt,
volatile sig_atomic_t * signalStatus )
explicit

Standard constructor, initialises the application.

Parameters
opt

Read options from executable

FIXME: SOMETHING_To_Replace_FairMQ!!!!!!!!!!!!! FIXME: Initialize communication channels of SOMETHING_To_Replace_FairMQ FIXME: Link channel to method in order to process received messages

To avoid the server sucking all Histos from gROOT when no output file is used

Definition at line 55 of file services/histserv/app/Application.cxx.

References cbm::services::histserv::ProgramOptions::ComChan(), cbm::services::histserv::ProgramOptions::ComChanZmqRcvHwm(), cbm::services::histserv::ProgramOptions::ComChanZmqRcvTo(), fOpt, fServer, fUiCmdActor, fZmqSocket, cbm::services::histserv::ProgramOptions::HideGuiCommands(), cbm::services::histserv::ProgramOptions::HistoFile(), cbm::services::histserv::ProgramOptions::HttpPort(), and cbm::services::histserv::ProgramOptions::Overwrite().

◆ Application() [2/2]

cbm::services::histserv::Application::Application ( const Application & )
delete

Copy constructor forbidden.

◆ ~Application()

cbm::services::histserv::Application::~Application ( )

Destructor.

Member Function Documentation

◆ Exec()

void cbm::services::histserv::Application::Exec ( )

Run the application.

◆ FindHistogram()

int Application::FindHistogram ( const std::string & name)
private

Collects histograms of the same type from the histogram list.

Template Parameters
HistoSrcHistogram type
Parameters
containerList of histograms
nameA name of the histogram

Definition at line 738 of file services/histserv/app/Application.cxx.

References fArrayHisto.

Referenced by PrepareCanvas(), ReadHistogram(), and ReadHistogramExtendedTsId().

◆ operator=()

void cbm::services::histserv::Application::operator= ( const Application & )
delete

Assignment operator forbidden.

◆ PrepareCanvas()

bool Application::PrepareCanvas ( uint32_t uCanvIdx)
private

Prepares canvases using received canvas configuration.

Parameters
uCanvIdxIndex of canvas

First check if all objects to be drawn are present

Check for empty pads!

Create new canvas and pads

Loop on pads

Pad settings

Add objects (we know they are there

Update flag telling whether all known canvases are registered

Definition at line 751 of file services/histserv/app/Application.cxx.

References ExtractCanvasConfigFromString(), fArrayHisto, fbAllCanvasRegistered, FindHistogram(), fServer, fvbCanvasRegistered, fvCanvas, fvpsCanvasConfig, CanvasConfig::GetGridx(), CanvasConfig::GetGridy(), CanvasConfig::GetLogx(), CanvasConfig::GetLogy(), CanvasConfig::GetLogz(), CanvasConfig::GetName(), CanvasConfig::GetNbObjsInPad(), CanvasConfig::GetNbPads(), CanvasConfig::GetNbPadsX(), CanvasConfig::GetNbPadsY(), CanvasConfig::GetObjName(), CanvasConfig::GetOption(), and CanvasConfig::GetTitle().

Referenced by ReceiveData().

◆ ReadHistogram() [1/2]

template<class HistoDst , class HistoSrc >
bool cbm::services::histserv::Application::ReadHistogram ( const HistoSrc & rHist)

If new histo received, try to register it if configuration available

Jump histos already ready

Check if name matches one in config for others

Update flag telling whether all known histos are registered

Definition at line 551 of file services/histserv/app/Application.cxx.

References fArrayHisto, fbAllHistosRegistered, FindHistogram(), first, fServer, fvbHistoRegistered, fvHistos, fvpsHistosFolder, and cbm::qa::OnlineInterface::ROOTHistogram().

◆ ReadHistogram() [2/2]

template<class HistoDst , class HistoSrc >
bool cbm::services::histserv::Application::ReadHistogram ( const HistoSrc & rHist)
private

Read a histogram.

Template Parameters
HistoDstDestination histogram type
HistoSrcSource histogram type
Parameters
rHistReference to the source histogram

Referenced by ReceiveData().

◆ ReadHistogramExtendedTsId() [1/2]

template<class HistoSrc >
bool cbm::services::histserv::Application::ReadHistogramExtendedTsId ( const HistoSrc & pHistSrc,
uint64_t tsIndex )
private

Reads a histogram slice for an extended histogram with the TS ID.

Template Parameters
HistoSrcSource histogram type
Parameters
rHistSrcReference to the source histogram
tsIndexIndex of timeslice

Referenced by ReceiveData().

◆ ReadHistogramExtendedTsId() [2/2]

template<class HistoSrc >
bool cbm::services::histserv::Application::ReadHistogramExtendedTsId ( const HistoSrc & rHist,
uint64_t tsIndex )

If new histo received, try to register it if configuration available

Jump histos already ready

Check if name matches one in config for others

Update flag telling whether all known histos are registered

Definition at line 614 of file services/histserv/app/Application.cxx.

References cbm::qa::OnlineInterface::AddSlice(), fArrayHisto, fbAllHistosRegistered, fConfig, FindHistogram(), first, cbm::services::histserv::AppConfig::fNofTsToStore, fServer, fvbHistoRegistered, fvHistos, and fvpsHistosFolder.

◆ ReceiveCanvasConfig()

bool Application::ReceiveCanvasConfig ( zmq::message_t & msg)
private

Receives canvas configuration.

FIXME: Something to replace FairMQ and extract the config!!!!

Check if canvas name already received in previous messages Linear search should be ok as config is shared only at startup

Not sure if we should return false here...

Definition at line 407 of file services/histserv/app/Application.cxx.

References cbm::services::histserv::ProgramOptions::CompressedInput(), fbAllCanvasReady, fbAllCanvasRegistered, first, fOpt, fvbCanvasReady, fvbCanvasRegistered, fvCanvas, and fvpsCanvasConfig.

Referenced by ReceiveConfigAndData().

◆ ReceiveConfigAndData()

bool Application::ReceiveConfigAndData ( std::vector< zmq::message_t > & vMsg)
private

Receives a list of canvases and histograms.

Parameters
vMsgMessage with the histograms and canvases list

FIXME: Something to replace FairMQ and extract the histograms!!!!

Header contains a pair of unsigned integers FIXME: Something to replace FairMQ and extract the header!!!!

Decode parts for histograms configuration (auto-skip empty message if 0 declared in header)

Decode parts for histograms configuration (auto-skip empty message if 0 declared in header)

Decode the histograms data now that the configuration is loaded

Definition at line 462 of file services/histserv/app/Application.cxx.

References cbm::services::histserv::ProgramOptions::CompressedInput(), fOpt, fStopThread, fUiCmdActor, ReceiveCanvasConfig(), ReceiveData(), ReceiveHistoConfig(), and size().

Referenced by cbm::sim::digitization::Application::Exec().

◆ ReceiveData()

bool Application::ReceiveData ( zmq::message_t & msg)
private

Find histogram index in the histogram array.

Receives histograms

FIXME: Something to replace FairMQ and extract the histograms!!!! FIXME: Need something to replace the ROOT serializer which allowed to have any of TH1x, TH2x, TH3x or TProfile FIXME: Need something to replace the TObjArray which allowed to have a mix of of TH1x, TH2x, TH3x or TProfile

copied from CbmTaskDigiEventQa::ToTH1D FIXME: Should be placed in a tools/interface/whatever library with all similar functions!! FIXME: Reverse OP need to be implemented + CI unit tests for back and forth in each direction (ROOT <-> Algo) FIXME: Lead to "Warning in <TROOT::Append>: Replacing existing TH1: xxxxxx (Potential memory leak)."

If new histos received, try to prepare as many canvases as possible Should be expensive on start and cheap afterward

Jump canvases already ready

Now come the expensive part as we unpack its config and check each histo

FIXME: make the log frequency configurable?

Definition at line 203 of file services/histserv/app/Application.cxx.

References cbm::services::histserv::ProgramOptions::CompressedInput(), fbAllCanvasReady, fNMessages, fOpt, cbm::algo::qa::HistogramContainer::fTimesliceId, fvbCanvasReady, cbm::algo::qa::HistogramContainer::fvH1, cbm::algo::qa::HistogramContainer::fvH2, cbm::algo::qa::HistogramContainer::fvP1, cbm::algo::qa::HistogramContainer::fvP2, fvpsCanvasConfig, cbm::algo::qa::OmitIntegrated, PrepareCanvas(), ReadHistogram(), ReadHistogramExtendedTsId(), and cbm::algo::qa::StoreVsTsId.

Referenced by cbm::sim::digitization::Application::Exec(), and ReceiveConfigAndData().

◆ ReceiveHistoConfig()

bool Application::ReceiveHistoConfig ( zmq::message_t & msg)
private

Receives histogram configuration.

FIXME: Something to replace FairMQ and extract the config!!!!

Definition at line 361 of file services/histserv/app/Application.cxx.

References cbm::services::histserv::ProgramOptions::CompressedInput(), fOpt, and RegisterHistoConfig().

Referenced by ReceiveConfigAndData().

◆ RegisterHistoConfig()

bool Application::RegisterHistoConfig ( const std::pair< std::string, std::string > & config)
private

Register a histogram config in the histogram server.

Parameters
configA pair (histogram name, histogram directory)

This function should be called after the metadata is extracted from the config.

Check if histo name already received in previous messages Linear search should be ok as config is shared only at startup

Not sure if we should return false here...

Definition at line 707 of file services/histserv/app/Application.cxx.

References fbAllHistosRegistered, first, fvbHistoRegistered, fvHistos, and fvpsHistosFolder.

Referenced by ReceiveHistoConfig().

◆ RegisterHistogram()

bool cbm::services::histserv::Application::RegisterHistogram ( const TNamed * hist)
private

Register a histogram in the histogram server.

Parameters
histA pointer to histogram

◆ ResetHistograms()

bool Application::ResetHistograms ( )
private

Resets handled histograms.

Definition at line 845 of file services/histserv/app/Application.cxx.

References fArrayHisto.

Referenced by UpdateHttpServer().

◆ SaveHistograms()

bool Application::SaveHistograms ( )
private

Saves handled histograms.

Save old global file and folder pointer to avoid messing with FairRoot

(Re-)Create ROOT file to store the histos

Register the histos in the HTTP server

catch case of histograms declared in config but not yet received

Make sure we end up in chosen folder

Write plot

catch case of canvases declared in config but for which not all histos were yet received

Make sure we end up in chosen folder

Write plot

Restore old global file and folder pointer to avoid messing with FairRoot

Definition at line 855 of file services/histserv/app/Application.cxx.

References first, fOpt, fvCanvas, fvHistos, cbm::services::histserv::ProgramOptions::HistoFile(), and cbm::services::histserv::ProgramOptions::Overwrite().

Referenced by UpdateHttpServer().

◆ UpdateHttpServer()

void Application::UpdateHttpServer ( )

This is needed to have a reactive GUI independently of histogram updates reception

TODO: control flags communication from histo server to histograms sources? Idea: 1 req channel (per process or not, mixup?), polling every N TS and/or M s

Definition at line 151 of file services/histserv/app/Application.cxx.

References fServer, fStopThread, fUiCmdActor, mtx, ResetHistograms(), and SaveHistograms().

Referenced by cbm::sim::digitization::Application::Exec().

Member Data Documentation

◆ fArrayHisto

TObjArray cbm::services::histserv::Application::fArrayHisto
private

Array of histograms with unique names.

Definition at line 131 of file services/histserv/app/Application.h.

Referenced by FindHistogram(), PrepareCanvas(), ReadHistogram(), ReadHistogramExtendedTsId(), and ResetHistograms().

◆ fbAllCanvasReady

bool cbm::services::histserv::Application::fbAllCanvasReady = false
private

Definition at line 139 of file services/histserv/app/Application.h.

Referenced by ReceiveCanvasConfig(), and ReceiveData().

◆ fbAllCanvasRegistered

bool cbm::services::histserv::Application::fbAllCanvasRegistered = false
private

Definition at line 147 of file services/histserv/app/Application.h.

Referenced by PrepareCanvas(), and ReceiveCanvasConfig().

◆ fbAllHistosRegistered

bool cbm::services::histserv::Application::fbAllHistosRegistered = false
private

◆ fConfig

AppConfig cbm::services::histserv::Application::fConfig
private

Definition at line 140 of file services/histserv/app/Application.h.

Referenced by ReadHistogramExtendedTsId().

◆ fNMessages

uint32_t cbm::services::histserv::Application::fNMessages = 0
private

Internal status.

Definition at line 150 of file services/histserv/app/Application.h.

Referenced by ReceiveData().

◆ fOpt

ProgramOptions const& cbm::services::histserv::Application::fOpt
private

A handler for system signals.

Parameters
signalSignal ID Program options object

Definition at line 118 of file services/histserv/app/Application.h.

Referenced by Application(), ReceiveCanvasConfig(), ReceiveConfigAndData(), ReceiveData(), ReceiveHistoConfig(), and SaveHistograms().

◆ fServer

THttpServer* cbm::services::histserv::Application::fServer = nullptr
private

ROOT Histogram server (JSroot)

Definition at line 120 of file services/histserv/app/Application.h.

Referenced by Application(), PrepareCanvas(), ReadHistogram(), ReadHistogramExtendedTsId(), and UpdateHttpServer().

◆ fSignalStatus

volatile sig_atomic_t* cbm::services::histserv::Application::fSignalStatus
private

Global signal status.

Definition at line 119 of file services/histserv/app/Application.h.

Referenced by cbm::sim::digitization::Application::Exec().

◆ fStopThread

bool cbm::services::histserv::Application::fStopThread = false
private

◆ fThread

std::thread cbm::services::histserv::Application::fThread
private

◆ fUiCmdActor

std::unique_ptr<UiCmdActor> cbm::services::histserv::Application::fUiCmdActor
private

◆ fvbCanvasReady

std::vector<bool> cbm::services::histserv::Application::fvbCanvasReady = {}
private

Definition at line 138 of file services/histserv/app/Application.h.

Referenced by ReceiveCanvasConfig(), and ReceiveData().

◆ fvbCanvasRegistered

std::vector<bool> cbm::services::histserv::Application::fvbCanvasRegistered = {}
private

Definition at line 146 of file services/histserv/app/Application.h.

Referenced by PrepareCanvas(), and ReceiveCanvasConfig().

◆ fvbHistoRegistered

std::vector<bool> cbm::services::histserv::Application::fvbHistoRegistered = {}
private

◆ fvCanvas

std::vector<std::pair<TCanvas*, std::string> > cbm::services::histserv::Application::fvCanvas = {}
private

Vector of Canvas pointers and folder path.

Definition at line 145 of file services/histserv/app/Application.h.

Referenced by PrepareCanvas(), ReceiveCanvasConfig(), and SaveHistograms().

◆ fvHistos

std::vector<std::pair<TNamed*, std::string> > cbm::services::histserv::Application::fvHistos = {}
private

Vector of Histos pointers and folder path.

Definition at line 142 of file services/histserv/app/Application.h.

Referenced by ReadHistogram(), ReadHistogramExtendedTsId(), RegisterHistoConfig(), and SaveHistograms().

◆ fvpsCanvasConfig

std::vector<std::pair<std::string, std::string> > cbm::services::histserv::Application::fvpsCanvasConfig = {}
private

Vector of string pairs with ( CanvasName, CanvasConfig ) to configure the canvases and histos within Format of Can config is "Name;Title;NbPadX(U);NbPadY(U);ConfigPad2(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 137 of file services/histserv/app/Application.h.

Referenced by PrepareCanvas(), ReceiveCanvasConfig(), and ReceiveData().

◆ fvpsHistosFolder

std::vector<std::pair<std::string, std::string> > cbm::services::histserv::Application::fvpsHistosFolder = {}
private

Vector of string with ( HistoName, FolderPath ) to configure the histogram.

Definition at line 133 of file services/histserv/app/Application.h.

Referenced by ReadHistogram(), ReadHistogramExtendedTsId(), and RegisterHistoConfig().

◆ fZmqContext

zmq::context_t cbm::services::histserv::Application::fZmqContext {1}
private

Interface.

Definition at line 127 of file services/histserv/app/Application.h.

◆ fZmqSocket

zmq::socket_t cbm::services::histserv::Application::fZmqSocket {fZmqContext, ZMQ_PULL}
private

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