00001 #ifndef ARTDAQ_DAQDATA_GLOBALS_HH
00002 #define ARTDAQ_DAQDATA_GLOBALS_HH
00003
00004 #include <sstream>
00005 #include "artdaq-utilities/Plugins/MetricManager.hh"
00006
00007 #define my_rank artdaq::Globals::my_rank_
00008 #define app_name artdaq::Globals::app_name_
00009 #define metricMan artdaq::Globals::metricMan_
00010 #define seedAndRandom() artdaq::Globals::seedAndRandom_()
00011
00012 #define mftrace_iteration artdaq::Globals::mftrace_iteration_
00013 #define mftrace_module artdaq::Globals::mftrace_module_
00014 #define SetMFModuleName(name) mftrace_module = name
00015 #define SetMFIteration(name) mftrace_iteration = name
00016
00017
00018 #include <fcntl.h>
00019 #include <unistd.h>
00020 #include <stdlib.h>
00021
00022
00026 namespace artdaq
00027 {
00031 class Globals
00032 {
00033 public:
00034 static int my_rank_;
00035 static MetricManager* metricMan_;
00036 static std::string app_name_;
00037
00038
00039 static std::string mftrace_module_;
00040 static std::string mftrace_iteration_;
00041
00046 static uint32_t seedAndRandom_()
00047 {
00048 static bool initialized_ = false;
00049 if (!initialized_)
00050 {
00051 int fp = open("/dev/random", O_RDONLY);
00052 if (fp == -1) abort();
00053 unsigned seed;
00054 unsigned pos = 0;
00055 while (pos < sizeof(seed))
00056 {
00057 int amt = read(fp, (char *)&seed + pos, sizeof(seed) - pos);
00058 if (amt <= 0) abort();
00059 pos += amt;
00060 }
00061 srand(seed);
00062 close(fp);
00063 initialized_ = true;
00064 }
00065 return rand();
00066 }
00067
00072 static int GetPartitionNumber()
00073 {
00074 auto part = getenv("ARTDAQ_PARTITION_NUMBER");
00075 uint32_t part_u = 0;
00076 if (part != nullptr)
00077 {
00078 try
00079 {
00080 auto part_s = std::string(part);
00081 part_u = static_cast<uint32_t>(std::stoll(part_s, 0, 0));
00082 }
00083 catch (std::invalid_argument) {}
00084 catch (std::out_of_range) {}
00085 }
00086
00087 return (part_u & 0x7F);
00088 }
00089 };
00090 }
00091
00092 #include "artdaq-core/Utilities/configureMessageFacility.hh"
00093 #include "tracemf.h"
00094 #include "artdaq-core/Utilities/TimeUtils.hh"
00095 #include "fhiclcpp/ParameterSet.h"
00096 #include "fhiclcpp/types/Atom.h"
00097 #include "fhiclcpp/types/Table.h"
00098 #include "fhiclcpp/types/Sequence.h"
00099 #include "fhiclcpp/types/TableFragment.h"
00100 #if MESSAGEFACILITY_HEX_VERSION >= 0x20103
00101 # include "fhiclcpp/types/ConfigurationTable.h"
00102 #endif
00103 #endif // ARTDAQ_DAQDATA_GLOBALS_HH