Skip to content
Snippets Groups Projects
Commit e2f57330 authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau Committed by Volker Friese
Browse files

Add services main folder + histogram server binary w/o FairMQ

Runs and pop the server but:
- Input interface not defined! Something need to be invented to replace FairMQ
- Commands do not work as the static boolean accessed by CLING do not seem to be share to the main threads (worked in FairTask world)
- Due to this, no mechanism to stop the main loop apart from Ctrl+C
- Not tested with histos, neither with canvases
parent cd0ed028
No related branches found
No related tags found
1 merge request!1212Add services main folder + histogram server binary w/o FairMQ + tester binary example
...@@ -261,6 +261,7 @@ add_subdirectory (algo) ...@@ -261,6 +261,7 @@ add_subdirectory (algo)
add_subdirectory (sim) add_subdirectory (sim)
add_subdirectory (reco) add_subdirectory (reco)
add_subdirectory (analysis) add_subdirectory (analysis)
add_subdirectory (services)
### Others ### Others
Option(LARGE_TEST_STATISTIC "Run the test suite with large statistic (100 events)" OFF) Option(LARGE_TEST_STATISTIC "Run the test suite with large statistic (100 events)" OFF)
......
add_subdirectory(histserv)
add_subdirectory(app)
add_subdirectory(lib)
This diff is collapsed.
/* Copyright (C) 2023 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#ifndef CBM_SERVICES_HISTSERV_APP_APPLICATION_H
#define CBM_SERVICES_HISTSERV_APP_APPLICATION_H 1
#include "THttpServer.h"
#include "TObjArray.h"
#include <memory>
#include <string>
#include <thread>
#include "ProgramOptions.h"
class TNamed;
class TCanvas;
namespace cbm::services::histserv
{
class Application {
public:
/** @brief Standard constructor, initialises the application
** @param opt **/
explicit Application(ProgramOptions const& opt);
/** @brief Copy constructor forbidden **/
Application(const Application&) = delete;
/** @brief Assignment operator forbidden **/
void operator=(const Application&) = delete;
/** @brief Destructor **/
~Application();
/** @brief Run the application **/
void Exec();
void UpdateHttpServer();
private:
const std::string& OutputFile() const;
const std::string& ParamFile() const;
const std::string& SetupTag() const;
//const std::string& ConfigFile() const;
bool ReceiveData(/*FIXME_SOMETHING_To_Replace_FairMQ& parts*/);
bool ReceiveHistoConfig(/*FIXME_SOMETHING_To_Replace_FairMQ& parts*/);
bool ReceiveCanvasConfig(/*FIXME_SOMETHING_To_Replace_FairMQ& parts*/);
bool ReceiveConfigAndData(/*FIXME_SOMETHING_To_Replace_FairMQ& parts*/);
template<class HistoT>
bool ReadHistogram(HistoT* pHist);
int FindHistogram(const std::string& name);
bool PrepareCanvas(uint32_t uCanvIdx);
bool ResetHistograms();
bool SaveHistograms();
private:
ProgramOptions const& fOpt; ///< Program options object
THttpServer* fServer = nullptr; ///< ROOT Histogram server (JSroot)
std::thread fThread;
bool fStopThread = false;
/// Array of histograms with unique names
TObjArray fArrayHisto;
/// Vector of string with ( HistoName, FolderPath ) to configure the histogram
std::vector<std::pair<std::string, std::string>> fvpsHistosFolder = {};
/// 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);ConfigPad1(s);....;ConfigPadXY(s)"
/// Format of Pad config is "GrixX(b),GridY(b),LogX(b),LogY(b),LogZ(b),HistoName(s),DrawOptions(s)"
std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig = {};
std::vector<bool> fvbCanvasReady = {};
bool fbAllCanvasReady = false;
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;
/// Internal status
uint32_t fNMessages = 0;
};
} // namespace cbm::services::histserv
#endif /* CBM_SERVICES_HISTSERV_APP_APPLICATION_H */
# CMakeList file for binary histserv_nofairmq
# P.-A. Loizeau, 26 June 2023
set(INCLUDE_DIRECTORIES
${INCLUDE_DIRECTORIES}
${CMAKE_CURRENT_SOURCE_DIR}
${CBMROOT_SOURCE_DIR}/algo/qa/
)
set(SRCS
Application.cxx
ProgramOptions.cxx
main.cxx
)
set(HEADERS
Application.h
ProgramOptions.h
)
set(INCLUDE_DIRECTORIES
${INCLUDE_DIRECTORIES}
${CBMROOT_SOURCE_DIR}
)
add_executable(histserv_nofairmq ${SRCS} ${HEADERS})
target_link_libraries(histserv_nofairmq
PUBLIC
Algo
CbmFlibFlesTools
CbmServicesHistServ
PRIVATE
Boost::program_options
FairLogger::FairLogger
ROOT::Core
ROOT::Gpad
ROOT::Hist
ROOT::RIO
ROOT::RHTTP
)
install(TARGETS histserv_nofairmq DESTINATION bin)
/* Copyright (C) 2023 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#include "ProgramOptions.h"
#include <Logger.h>
#include <boost/program_options.hpp>
#include <iostream>
namespace po = boost::program_options;
using std::string;
namespace cbm::services::histserv
{
// ----- Parse command line ---------------------------------------------
void ProgramOptions::ParseOptions(int argc, char* argv[])
{
// --- Define generic options
po::options_description generic("Generic options");
auto generic_add = generic.add_options();
generic_add("help,h", "display this help and exit");
// --- Build default config file path
//string defconfig = std::getenv("VMCWORKDIR");
//defconfig.append("/");
//defconfig.append(DEFAULT_CONFIG);
// --- Define configuration options
po::options_description config("Configuration");
auto config_add = config.add_options();
config_add("input,i", po::value<string>(&fsChanHistosIn)->value_name("<???????>"),
"name or host:port or whatever is needed for input channel (histos/canvases config and data)");
config_add("port,p", po::value<uint32_t>(&fuHttpServerPort)->default_value(8080),
"port on which the http ROOT server (JSroot) will be available");
config_add("output,o", po::value<string>(&fsHistoFileName)->value_name("<file name>"),
"name of the output ROOT file with histograms backup");
// config_add("config,c", po::value<string>(&fConfig)->value_name("<file name>")->default_value(defconfig),
// "name of a YAML file describing the configuration of reconstruction");
config_add("overwrite,w", po::bool_switch(&fOverwrite)->default_value(false),
"allow to overwite an existing output file");
// --- Allowed options
po::options_description cmdline_options("Allowed options");
cmdline_options.add(generic).add(config);
// --- Parse command line
po::variables_map vars;
po::store(po::parse_command_line(argc, argv, cmdline_options), vars);
po::notify(vars);
// --- Help: print help information and exit program
if (vars.count("help") != 0u) {
std::cout << cmdline_options << std::endl;
exit(EXIT_SUCCESS);
}
// --- Catch mandatory parameters not being specified
if (vars.count("input") == 0u) { throw std::runtime_error("no input channel specified"); }
if (vars.count("port") == 0u) { throw std::runtime_error("no http port specified"); }
}
// --------------------------------------------------------------------------
} // namespace cbm::services::histserv
/* Copyright (C) 2023 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#ifndef CBM_SERVICES_HISTSERV_APP_PROGRAMOPTIONS_H
#define CBM_SERVICES_HISTSERV_APP_PROGRAMOPTIONS_H 1
#include <string>
namespace cbm::services::histserv
{
/** @class ProgramOptions
** @author Pierre-Alain Loizeau <p.-a.loizeau@gsi.de>
** @since 26 June 2023
**
** Program option class for the application histserv_nofairmq
**/
class ProgramOptions {
public:
/** @brief Standard constructor with command line arguments **/
ProgramOptions(int argc, char* argv[]) { ParseOptions(argc, argv); }
/** @brief Copy constructor forbidden **/
ProgramOptions(const ProgramOptions&) = default;
/** @brief Assignment operator forbidden **/
ProgramOptions& operator=(const ProgramOptions&) = default;
/** @brief Destructor **/
~ProgramOptions() = default;
/** @brief Get interface channel name or hostname + port or whatever or ????? (FIXME: replacement of FairMQ) **/
[[nodiscard]] const std::string& ComChan() const { return fsChanHistosIn; }
/** @brief Get histo server http port **/
[[nodiscard]] const uint32_t& HttpPort() const { return fuHttpServerPort; }
/** @brief Get output file name (.root format) **/
[[nodiscard]] const std::string& HistoFile() const { return fsHistoFileName; }
/** @brief Get overwrite option **/
[[nodiscard]] bool Overwrite() const { return fOverwrite; }
// /** @brief Get configuration file name (YAML format) **/
// [[nodiscard]] const std::string& ConfigFile() const { return fConfig; }
private:
/** @brief Parse command line arguments using boost program_options **/
void ParseOptions(int argc, char* argv[]);
private: // members
std::string fsChanHistosIn = "histogram-in";
uint32_t fuHttpServerPort = 8080; ///< HTTP port of the ROOT web server
std::string fsHistoFileName = "histos_dump.root"; ///< Output file name (ROOT format)
bool fOverwrite = false; ///< Enable overwriting of existing output file
//std::string fConfig = ""; ///< Configuration file name (YAML format)
};
} // namespace cbm::services::histserv
#endif /* CBM_SERVICES_HISTSERV_APP_PROGRAMOPTIONS_H */
/* Copyright (C) 2023 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#include <Logger.h>
#include "Application.h"
#include "ProgramOptions.h"
using namespace cbm::services::histserv;
int main(int argc, char* argv[])
{
LOG(info) << "***** Histogram server without FairMQ *****";
try {
ProgramOptions opt(argc, argv);
Application app(opt);
app.Exec();
}
catch (std::exception const& e) {
LOG(error) << e.what() << "; terminating.";
return EXIT_FAILURE;
}
LOG(info) << "Histogram server without FairMQ: Program completed successfully; exiting.";
return EXIT_SUCCESS;
}
# CMakeList file for library associated to HistServ service, needed by CLING to allow commands in WebUI
# P.-A. Loizeau, 26 June 2023
set(INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
)
#set(SRCS
# ui_callbacks.cxx
# )
list(APPEND HEADERS ui_callbacks.h)
set(LIBRARY_NAME CbmServicesHistServ)
set(LINKDEF ${LIBRARY_NAME}LinkDef.h )
set(PUBLIC_DEPENDENCIES
ROOT::Core
)
generate_cbm_library()
/* Copyright (C) 2023 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#endif
/* Copyright (C) 2023 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#ifndef CBM_SERVICES_HISTSERV_LIB_UI_CALLBACKS_H
#define CBM_SERVICES_HISTSERV_LIB_UI_CALLBACKS_H 1
static bool bHistoServerResetHistos = false;
static bool bHistoServerSaveHistos = false;
static bool bHistoServerStop = false;
#endif /* CBM_SERVICES_HISTSERV_LIB_UI_CALLBACKS_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment