1 #ifndef ARTDAQ_DAQDATA_GLOBALS_HH
2 #define ARTDAQ_DAQDATA_GLOBALS_HH
4 #ifndef TRACE_DEFINE // as set in Globals.cc
7 #include "artdaq-utilities/Plugins/MetricManager.hh"
8 #include "artdaq/DAQdata/PortManager.hh"
10 #define my_rank artdaq::Globals::my_rank_
11 #define app_name artdaq::Globals::app_name_
12 #define metricMan artdaq::Globals::metricMan_
13 #define portMan artdaq::Globals::portMan_
14 #define seedAndRandom() artdaq::Globals::seedAndRandom_()
15 #define GetPartitionNumber() artdaq::Globals::getPartitionNumber_()
17 #define GetMFIteration() artdaq::Globals::GetMFIteration_()
18 #define GetMFModuleName() artdaq::Globals::GetMFModuleName_()
19 #define SetMFModuleName(name) artdaq::Globals::SetMFModuleName_(name)
20 #define SetMFIteration(name) artdaq::Globals::SetMFIteration_(name)
57 static bool initialized_ =
false;
60 int fp = open(
"/dev/random", O_RDONLY);
61 if (fp == -1) abort();
64 while (pos <
sizeof(seed))
66 int amt = read(fp, reinterpret_cast<char *>(&seed) + pos,
sizeof(seed) - pos);
67 if (amt <= 0) abort();
94 auto part = getenv(
"ARTDAQ_PARTITION_NUMBER");
99 auto part_s = std::string(part);
100 part_u =
static_cast<uint32_t
>(std::stoll(part_s,
nullptr, 0));
102 catch (
const std::invalid_argument &)
104 catch (
const std::out_of_range &)
110 return (part_u & 0x7F);
166 #endif // ARTDAQ_DAQDATA_GLOBALS_HH
static int getPartitionNumber_()
Get the current partition number, as defined by the ARTDAQ_PARTITION_NUMBER environment variable...
static uint32_t seedAndRandom_()
Seed the C random number generator with the current time (if that has not been done already) and gene...
static std::unique_ptr< MetricManager > metricMan_
A handle to MetricManager.
static int my_rank_
The rank of the current application.
static std::string app_name_
The name of the current application, to be used in logging and metrics.
static void CleanUpGlobals()
Clean up statically-allocated Manager class instances.
static std::string GetMFIteration_()
Get the current iteration for MessageFacility messages.
static std::mutex mftrace_mutex_
Mutex to protect mftrace_module_ and mftrace_iteration_.
static void SetMFIteration_(std::string const &name)
Set the current iteration for MessageFacility messages.
static void SetMFModuleName_(std::string const &name)
Set the current module name for MessageFacility messages.
static std::string mftrace_iteration_
MessageFacility's module and iteration are thread-local, but we want to use them to represent global ...
static std::unique_ptr< PortManager > portMan_
A handle to PortManager.
The artdaq::Globals class contains several variables which are useful across the entire artdaq system...
static std::string mftrace_module_
MessageFacility's module and iteration are thread-local, but we want to use them to represent global ...
static int partition_number_
The partition number of the current application.
static std::string GetMFModuleName_()
Get the current module name for MessageFacility messages.