CbmRoot
CbmMqHistoServer Class Reference

#include <CbmMqHistoServer.h>

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

Public Member Functions

 CbmMqHistoServer ()
 
virtual ~CbmMqHistoServer ()
 
void UpdateHttpServer ()
 

Protected Member Functions

virtual void InitTask ()
 
bool ReceiveData (FairMQMessagePtr &msg, int index)
 
bool ReceiveHistoConfig (FairMQMessagePtr &msg, int index)
 
bool ReceiveCanvasConfig (FairMQMessagePtr &msg, int index)
 
virtual void PreRun ()
 
virtual void PostRun ()
 

Private Member Functions

template<class HistoT >
bool ReadHistogram (HistoT *pHist)
 
int FindHistogram (const std::string &name)
 
bool PrepareCanvas (uint32_t uCanvIdx)
 
bool ResetHistograms ()
 
bool SaveHistograms ()
 

Private Attributes

std::string fsChannelNameHistosInput
 Parameters. More...
 
std::string fsChannelNameHistosConfig
 
std::string fsChannelNameCanvasConfig
 
std::string fsHistoFileName
 
uint32_t fuHttpServerPort
 
TObjArray fArrayHisto
 Array of histograms with unique names. More...
 
std::vector< std::pair< std::string, std::string > > fvpsHistosFolder
 Vector of string with ( HistoName, FolderPath ) to send to the histogram server. More...
 
std::vector< std::pair< std::string, std::string > > fvpsCanvasConfig
 
std::vector< bool > fvbCanvasReady
 
bool fbAllCanvasReady
 
std::vector< std::pair< TNamed *, std::string > > fvHistos
 
std::vector< bool > fvbHistoRegistered
 Vector of Histos pointers and folder path. More...
 
bool fbAllHistosRegistered
 
std::vector< std::pair< TCanvas *, std::string > > fvCanvas
 
std::vector< bool > fvbCanvasRegistered
 Vector of Canvas pointers and folder path. More...
 
bool fbAllCanvasRegistered
 
int fNMessages
 Internal status. More...
 
THttpServer * fServer
 
std::thread fThread
 
bool fStopThread
 

Detailed Description

Definition at line 23 of file CbmMqHistoServer.h.

Constructor & Destructor Documentation

◆ CbmMqHistoServer()

CbmMqHistoServer::CbmMqHistoServer ( )

Definition at line 36 of file CbmMqHistoServer.cxx.

◆ ~CbmMqHistoServer()

CbmMqHistoServer::~CbmMqHistoServer ( )
virtual

Definition at line 52 of file CbmMqHistoServer.cxx.

Member Function Documentation

◆ FindHistogram()

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

Definition at line 287 of file CbmMqHistoServer.cxx.

References fArrayHisto.

Referenced by PrepareCanvas(), and ReadHistogram().

◆ InitTask()

void CbmMqHistoServer::InitTask ( )
protectedvirtual

Read options from executable

Link channels to methods in order to process received messages

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

Definition at line 54 of file CbmMqHistoServer.cxx.

References fsChannelNameCanvasConfig, fsChannelNameHistosConfig, fsChannelNameHistosInput, fServer, fsHistoFileName, fuHttpServerPort, ReceiveCanvasConfig(), ReceiveData(), and ReceiveHistoConfig().

◆ PostRun()

void CbmMqHistoServer::PostRun ( )
protectedvirtual

Definition at line 227 of file CbmMqHistoServer.cxx.

References fStopThread, and fThread.

◆ PrepareCanvas()

bool CbmMqHistoServer::PrepareCanvas ( uint32_t  uCanvIdx)
private

◆ PreRun()

void CbmMqHistoServer::PreRun ( )
protectedvirtual

Definition at line 213 of file CbmMqHistoServer.cxx.

References fStopThread, fThread, and UpdateHttpServer().

◆ ReadHistogram()

template<class HistoT >
bool CbmMqHistoServer::ReadHistogram ( HistoT *  pHist)
private

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 233 of file CbmMqHistoServer.cxx.

References fArrayHisto, fbAllHistosRegistered, FindHistogram(), first, fServer, fvbHistoRegistered, fvHistos, and fvpsHistosFolder.

◆ ReceiveCanvasConfig()

bool CbmMqHistoServer::ReceiveCanvasConfig ( FairMQMessagePtr &  msg,
int  index 
)
protected

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 179 of file CbmMqHistoServer.cxx.

References fbAllCanvasReady, fbAllCanvasRegistered, first, fvbCanvasReady, fvbCanvasRegistered, fvCanvas, and fvpsCanvasConfig.

Referenced by InitTask().

◆ ReceiveData()

bool CbmMqHistoServer::ReceiveData ( FairMQMessagePtr &  msg,
int  index 
)
protected

Need to use Delete instead of Clear to avoid 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

TODO: control flags communication with histo server Idea: 1 req channel (per device or not mixup?), polling every N TS and/or M s

Definition at line 79 of file CbmMqHistoServer.cxx.

References bMqHistoServerResetHistos, bMqHistoServerSaveHistos, fbAllCanvasReady, fNMessages, fvbCanvasReady, fvpsCanvasConfig, i, mtx, PrepareCanvas(), ResetHistograms(), and SaveHistograms().

Referenced by InitTask().

◆ ReceiveHistoConfig()

bool CbmMqHistoServer::ReceiveHistoConfig ( FairMQMessagePtr &  msg,
int  index 
)
protected

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 147 of file CbmMqHistoServer.cxx.

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

Referenced by InitTask().

◆ ResetHistograms()

bool CbmMqHistoServer::ResetHistograms ( )
private

Definition at line 297 of file CbmMqHistoServer.cxx.

References fArrayHisto.

Referenced by ReceiveData().

◆ SaveHistograms()

bool CbmMqHistoServer::SaveHistograms ( )
private

(Re-)Create ROOT file to store the histos

Register the histos in the HTTP server

Make sure we end up in chosen folder

Write plot

Make sure we end up in chosen folder

Write plot

Definition at line 383 of file CbmMqHistoServer.cxx.

References fsHistoFileName, fvCanvas, and fvHistos.

Referenced by ReceiveData().

◆ UpdateHttpServer()

void CbmMqHistoServer::UpdateHttpServer ( )

Definition at line 218 of file CbmMqHistoServer.cxx.

References fServer, fStopThread, and mtx.

Referenced by PreRun().

Member Data Documentation

◆ fArrayHisto

TObjArray CbmMqHistoServer::fArrayHisto
private

Array of histograms with unique names.

Definition at line 53 of file CbmMqHistoServer.h.

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

◆ fbAllCanvasReady

bool CbmMqHistoServer::fbAllCanvasReady
private

Definition at line 61 of file CbmMqHistoServer.h.

Referenced by ReceiveCanvasConfig(), and ReceiveData().

◆ fbAllCanvasRegistered

bool CbmMqHistoServer::fbAllCanvasRegistered
private

Definition at line 70 of file CbmMqHistoServer.h.

Referenced by PrepareCanvas(), and ReceiveCanvasConfig().

◆ fbAllHistosRegistered

bool CbmMqHistoServer::fbAllHistosRegistered
private

Definition at line 66 of file CbmMqHistoServer.h.

Referenced by ReadHistogram(), and ReceiveHistoConfig().

◆ fNMessages

int CbmMqHistoServer::fNMessages
private

Internal status.

Definition at line 73 of file CbmMqHistoServer.h.

Referenced by ReceiveData().

◆ fsChannelNameCanvasConfig

std::string CbmMqHistoServer::fsChannelNameCanvasConfig
private

Definition at line 48 of file CbmMqHistoServer.h.

Referenced by InitTask().

◆ fsChannelNameHistosConfig

std::string CbmMqHistoServer::fsChannelNameHistosConfig
private

Definition at line 47 of file CbmMqHistoServer.h.

Referenced by InitTask().

◆ fsChannelNameHistosInput

std::string CbmMqHistoServer::fsChannelNameHistosInput
private

Parameters.

Definition at line 46 of file CbmMqHistoServer.h.

Referenced by InitTask().

◆ fServer

THttpServer* CbmMqHistoServer::fServer
private

Definition at line 75 of file CbmMqHistoServer.h.

Referenced by InitTask(), PrepareCanvas(), ReadHistogram(), and UpdateHttpServer().

◆ fsHistoFileName

std::string CbmMqHistoServer::fsHistoFileName
private

Definition at line 49 of file CbmMqHistoServer.h.

Referenced by InitTask(), and SaveHistograms().

◆ fStopThread

bool CbmMqHistoServer::fStopThread
private

Definition at line 78 of file CbmMqHistoServer.h.

Referenced by PostRun(), PreRun(), and UpdateHttpServer().

◆ fThread

std::thread CbmMqHistoServer::fThread
private

Definition at line 77 of file CbmMqHistoServer.h.

Referenced by PostRun(), and PreRun().

◆ fuHttpServerPort

uint32_t CbmMqHistoServer::fuHttpServerPort
private

Definition at line 50 of file CbmMqHistoServer.h.

Referenced by InitTask().

◆ fvbCanvasReady

std::vector<bool> CbmMqHistoServer::fvbCanvasReady
private

Definition at line 60 of file CbmMqHistoServer.h.

Referenced by ReceiveCanvasConfig(), and ReceiveData().

◆ fvbCanvasRegistered

std::vector<bool> CbmMqHistoServer::fvbCanvasRegistered
private

Vector of Canvas pointers and folder path.

Definition at line 69 of file CbmMqHistoServer.h.

Referenced by PrepareCanvas(), and ReceiveCanvasConfig().

◆ fvbHistoRegistered

std::vector<bool> CbmMqHistoServer::fvbHistoRegistered
private

Vector of Histos pointers and folder path.

Definition at line 65 of file CbmMqHistoServer.h.

Referenced by ReadHistogram(), and ReceiveHistoConfig().

◆ fvCanvas

std::vector<std::pair<TCanvas*, std::string> > CbmMqHistoServer::fvCanvas
private

Definition at line 68 of file CbmMqHistoServer.h.

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

◆ fvHistos

std::vector<std::pair<TNamed*, std::string> > CbmMqHistoServer::fvHistos
private

Definition at line 64 of file CbmMqHistoServer.h.

Referenced by ReadHistogram(), ReceiveHistoConfig(), and SaveHistograms().

◆ fvpsCanvasConfig

std::vector<std::pair<std::string, std::string> > CbmMqHistoServer::fvpsCanvasConfig
private

Vector of string pairs with ( CanvasName, CanvasConfig ) to send to the histogram server Format of Can config is "Name;Title;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 59 of file CbmMqHistoServer.h.

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

◆ fvpsHistosFolder

std::vector<std::pair<std::string, std::string> > CbmMqHistoServer::fvpsHistosFolder
private

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

Definition at line 55 of file CbmMqHistoServer.h.

Referenced by ReadHistogram(), and ReceiveHistoConfig().


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