Line data Source code
1 : #include "TRACE/tracemf.h"
2 : #include "artdaq/DAQdata/Globals.hh" // include these 2 first -
3 : #define TRACE_NAME (app_name + "_DataLoggerCore").c_str()
4 :
5 : #include "artdaq/Application/DataLoggerCore.hh"
6 :
7 : #include "fhiclcpp/ParameterSet.h"
8 :
9 0 : bool artdaq::DataLoggerCore::initialize(fhicl::ParameterSet const& pset)
10 : {
11 0 : TLOG(TLVL_DEBUG + 32) << "initialize method called with DAQ "
12 0 : << "ParameterSet = \"" << pset.to_string() << "\".";
13 :
14 : // pull out the relevant parts of the ParameterSet
15 0 : fhicl::ParameterSet daq_pset;
16 : try
17 : {
18 0 : daq_pset = pset.get<fhicl::ParameterSet>("daq");
19 : }
20 0 : catch (...)
21 : {
22 0 : TLOG(TLVL_ERROR)
23 0 : << "Unable to find the DAQ parameters in the initialization "
24 0 : << "ParameterSet: \"" + pset.to_string() + "\".";
25 0 : return false;
26 0 : }
27 0 : fhicl::ParameterSet agg_pset;
28 : try
29 : {
30 0 : agg_pset = daq_pset.get<fhicl::ParameterSet>("datalogger", daq_pset.get<fhicl::ParameterSet>("aggregator"));
31 : }
32 0 : catch (...)
33 : {
34 0 : TLOG(TLVL_ERROR)
35 0 : << "Unable to find the DataLogger parameters in the DAQ "
36 0 : << "initialization ParameterSet: \"" + daq_pset.to_string() + "\".";
37 0 : return false;
38 0 : }
39 :
40 0 : auto shared_memory_ordering = agg_pset.get<bool>("shared_memory_ordering", true);
41 0 : if (shared_memory_ordering && !agg_pset.has_key("shared_memory_ordering"))
42 : {
43 0 : TLOG(TLVL_INFO) << "Setting shared_memory_ordering to true by default for DataLogger. If this is not desired, set shared_memory_ordering to false in the configuration. Note that multiple art processes may not be served events evenly";
44 0 : agg_pset.put<bool>("shared_memory_ordering", true);
45 : }
46 :
47 0 : auto art_analyzer_count = agg_pset.get<size_t>("art_analyzer_count", 1);
48 0 : if (art_analyzer_count > 1 && shared_memory_ordering)
49 : {
50 0 : TLOG(TLVL_WARNING) << "Multiple art analyzers are configured to receive events from the DataLogger! This is generally not recommended. For more detail, see the TRACEs printed to " << TRACE_NAME << " level 50.";
51 0 : TLOG(50) << "The Datalogger uses \"shared_memory_ordering\", which uses the event ID to help sort events in the shared memory. This interferes with SharedMemoryManager's round-robin code, and can cause issues where no art process receives events.";
52 0 : TLOG(50) << "It is generally recommended to start additional DataLogger processes if additional disk-writing bandwidth is needed, this also allows for targeting different disk areas.";
53 0 : TLOG(50) << "In any case, if you are using multiple art analyzers, make sure to set \"shared_memory_ordering\" to false in the DataLogger configuration to avoid issues with events not being received by the art analyzers.";
54 : }
55 :
56 0 : if (!agg_pset.has_key("init_fragment_count"))
57 : {
58 0 : TLOG(TLVL_ERROR) << "ERROR: init_fragment_count must be set for the DataLogger to function properly. Please set `init_fragment_count: 0` in the DataLogger configuration. (Will be book-kept by DAQInterface)";
59 0 : return false;
60 : }
61 :
62 : // initialize the MetricManager and the names of our metrics
63 0 : fhicl::ParameterSet metric_pset = daq_pset.get<fhicl::ParameterSet>("metrics", fhicl::ParameterSet());
64 :
65 0 : return initializeDataReceiver(pset, agg_pset, metric_pset);
66 0 : }
|