CbmRoot
|
#include <Application.h>
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< UiCmdActor > | fUiCmdActor |
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. | |
Definition at line 33 of file services/histserv/app/Application.h.
|
explicit |
Standard constructor, initialises the application.
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().
|
delete |
Copy constructor forbidden.
cbm::services::histserv::Application::~Application | ( | ) |
Destructor.
void cbm::services::histserv::Application::Exec | ( | ) |
Run the application.
|
private |
Collects histograms of the same type from the histogram list.
HistoSrc | Histogram type |
container | List of histograms |
name | A name of the histogram |
Definition at line 738 of file services/histserv/app/Application.cxx.
References fArrayHisto.
Referenced by PrepareCanvas(), ReadHistogram(), and ReadHistogramExtendedTsId().
|
delete |
Assignment operator forbidden.
|
private |
Prepares canvases using received canvas configuration.
uCanvIdx | Index 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().
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().
|
private |
Read a histogram.
HistoDst | Destination histogram type |
HistoSrc | Source histogram type |
rHist | Reference to the source histogram |
Referenced by ReceiveData().
|
private |
Reads a histogram slice for an extended histogram with the TS ID.
HistoSrc | Source histogram type |
rHistSrc | Reference to the source histogram |
tsIndex | Index of timeslice |
Referenced by ReceiveData().
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.
|
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().
|
private |
Receives a list of canvases and histograms.
vMsg | Message 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().
|
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().
|
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().
|
private |
Register a histogram config in the histogram server.
config | A 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().
|
private |
Register a histogram in the histogram server.
hist | A pointer to histogram |
|
private |
Resets handled histograms.
Definition at line 845 of file services/histserv/app/Application.cxx.
References fArrayHisto.
Referenced by UpdateHttpServer().
|
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().
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().
|
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().
|
private |
Definition at line 139 of file services/histserv/app/Application.h.
Referenced by ReceiveCanvasConfig(), and ReceiveData().
|
private |
Definition at line 147 of file services/histserv/app/Application.h.
Referenced by PrepareCanvas(), and ReceiveCanvasConfig().
|
private |
Definition at line 144 of file services/histserv/app/Application.h.
Referenced by ReadHistogram(), ReadHistogramExtendedTsId(), and RegisterHistoConfig().
|
private |
Definition at line 140 of file services/histserv/app/Application.h.
Referenced by ReadHistogramExtendedTsId().
|
private |
Internal status.
Definition at line 150 of file services/histserv/app/Application.h.
Referenced by ReceiveData().
|
private |
A handler for system signals.
signal | Signal ID Program options object |
Definition at line 118 of file services/histserv/app/Application.h.
Referenced by Application(), ReceiveCanvasConfig(), ReceiveConfigAndData(), ReceiveData(), ReceiveHistoConfig(), and SaveHistograms().
|
private |
ROOT Histogram server (JSroot)
Definition at line 120 of file services/histserv/app/Application.h.
Referenced by Application(), PrepareCanvas(), ReadHistogram(), ReadHistogramExtendedTsId(), and UpdateHttpServer().
|
private |
Global signal status.
Definition at line 119 of file services/histserv/app/Application.h.
Referenced by cbm::sim::digitization::Application::Exec().
|
private |
Definition at line 122 of file services/histserv/app/Application.h.
Referenced by cbm::sim::digitization::Application::Exec(), ReceiveConfigAndData(), and UpdateHttpServer().
|
private |
Definition at line 121 of file services/histserv/app/Application.h.
Referenced by cbm::sim::digitization::Application::Exec().
|
private |
Definition at line 124 of file services/histserv/app/Application.h.
Referenced by Application(), cbm::sim::digitization::Application::Exec(), ReceiveConfigAndData(), and UpdateHttpServer().
|
private |
Definition at line 138 of file services/histserv/app/Application.h.
Referenced by ReceiveCanvasConfig(), and ReceiveData().
|
private |
Definition at line 146 of file services/histserv/app/Application.h.
Referenced by PrepareCanvas(), and ReceiveCanvasConfig().
|
private |
Definition at line 143 of file services/histserv/app/Application.h.
Referenced by ReadHistogram(), ReadHistogramExtendedTsId(), and RegisterHistoConfig().
|
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().
|
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().
|
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().
|
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().
|
private |
Interface.
Definition at line 127 of file services/histserv/app/Application.h.
|
private |
Definition at line 128 of file services/histserv/app/Application.h.
Referenced by Application(), and cbm::sim::digitization::Application::Exec().