1 #include "otsdaq-core/ConfigurationPluginDataFormats/ARTDAQBuilderConfiguration.h"
2 #include "otsdaq-core/Macros/ConfigurationPluginMacros.h"
3 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
4 #include "otsdaq-core/ConfigurationPluginDataFormats/XDAQContextConfiguration.h"
14 #define ARTDAQ_FCL_PATH std::string(getenv("USER_DATA")) + "/"+ "ARTDAQConfigurations/"
15 #define ARTDAQ_FILE_PREAMBLE "builder"
18 #define OUT out << tabStr << commentStr
19 #define PUSHTAB tabStr += "\t"
20 #define POPTAB tabStr.resize(tabStr.size()-1)
21 #define PUSHCOMMENT commentStr += "# "
22 #define POPCOMMENT commentStr.resize(commentStr.size()-2)
26 ARTDAQBuilderConfiguration::ARTDAQBuilderConfiguration(
void)
36 ARTDAQBuilderConfiguration::~ARTDAQBuilderConfiguration(
void)
43 mkdir((ARTDAQ_FCL_PATH).c_str(), 0755);
45 __COUT__ <<
"*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << std::endl;
46 __COUT__ << configManager->__SELF_NODE__ << std::endl;
50 std::vector<const XDAQContextConfiguration::XDAQContext *> builderContexts =
51 contextConfig->getEventBuilderContexts();
55 for (
auto &builderContext : builderContexts)
57 ConfigurationTree builderAppNode = contextConfig->getApplicationNode(configManager,
58 builderContext->contextUID_, builderContext->applications_[0].applicationUID_);
59 ConfigurationTree builderConfigNode = contextConfig->getSupervisorConfigNode(configManager,
60 builderContext->contextUID_, builderContext->applications_[0].applicationUID_);
62 __COUT__ <<
"Path for this aggregator config is " <<
63 builderContext->contextUID_ <<
"/" <<
64 builderContext->applications_[0].applicationUID_ <<
"/" <<
65 builderConfigNode.getValueAsString() <<
68 outputFHICL(configManager, builderConfigNode,
69 contextConfig->getARTDAQAppRank(builderContext->contextUID_),
70 contextConfig->getContextAddress(builderContext->contextUID_),
71 contextConfig->getARTDAQDataPort(configManager,builderContext->contextUID_),
77 std::string ARTDAQBuilderConfiguration::getFHICLFilename(
const ConfigurationTree &builderNode)
79 __COUT__ <<
"ARTDAQ Builder UID: " << builderNode.getValue() << std::endl;
80 std::string filename = ARTDAQ_FCL_PATH + ARTDAQ_FILE_PREAMBLE +
"-";
81 std::string uid = builderNode.getValue();
82 for (
unsigned int i = 0; i < uid.size(); ++i)
83 if ((uid[i] >=
'a' && uid[i] <=
'z') ||
84 (uid[i] >=
'A' && uid[i] <=
'Z') ||
85 (uid[i] >=
'0' && uid[i] <=
'9'))
90 __COUT__ <<
"fcl: " << filename << std::endl;
97 const ConfigurationTree &builderNode,
unsigned int selfRank, std::string selfHost,
unsigned int selfPort,
219 std::string filename = getFHICLFilename(builderNode);
225 std::string tabStr =
"";
226 std::string commentStr =
"";
228 out.open(filename, std::fstream::out | std::fstream::trunc);
231 __SS__ <<
"Failed to open ARTDAQ Builder fcl file: " << filename << std::endl;
232 throw std::runtime_error(ss.str());
237 if (builderNode.isDisconnected())
248 auto services = builderNode.getNode(
"servicesLink");
249 if (!services.isDisconnected())
251 OUT <<
"services: {\n";
255 OUT <<
"scheduler: {\n";
258 OUT <<
"fileMode: " << services.getNode(
"schedulerFileMode").getValue() <<
260 OUT <<
"errorOnFailureToPut: " <<
261 (services.getNode(
"schedulerErrorOnFailtureToPut").getValue<
bool>() ?
"true" :
"false") <<
269 OUT <<
"NetMonTransportServiceInterface: {\n";
272 OUT <<
"service_provider: " <<
274 services.getNode(
"NetMonTrasportServiceInterfaceServiceProvider").getValue()
276 OUT <<
"destinations: {\n";
279 auto destinationsGroup = services.getNode(
"NetMonTrasportServiceInterfaceDestinationsLink");
280 if (!destinationsGroup.isDisconnected())
284 auto destinations = destinationsGroup.getChildren();
285 for (
auto &destination : destinations)
287 auto destinationContextUID = destination.second.getNode(
"destinationARTDAQContextLink").getValueAsString();
289 unsigned int destinationRank = contextConfig->getARTDAQAppRank(destinationContextUID);
290 std::string host = contextConfig->getContextAddress(destinationContextUID);
291 unsigned int port = contextConfig->getARTDAQDataPort(configManager,destinationContextUID);
295 OUT << destination.second.getNode(
"destinationKey").getValue() <<
297 " transferPluginType: " <<
298 destination.second.getNode(
"transferPluginType").getValue() <<
299 " destination_rank: " <<
301 " max_fragment_size_words: " <<
302 destination.second.getNode(
"ARTDAQGlobalConfigurationLink/maxFragmentSizeWords").getValue<
unsigned int>() <<
303 " host_map: [{rank: " << destinationRank <<
" host: \"" << host <<
"\" portOffset: " << std::to_string(port) <<
"}, " <<
304 "{rank: " << selfRank <<
" host: \"" << selfHost <<
"\" portOffset: " << std::to_string(selfPort) <<
"}]" <<
308 catch (
const std::runtime_error& e)
310 __SS__ <<
"Are the Net Monitor Transport Service destinations valid? Error occurred looking for Event Builder transport service destinations for UID '" <<
311 builderNode.getValue() <<
"': " << e.what() << std::endl;
312 __COUT_ERR__ << ss.str() << std::endl;
313 throw std::runtime_error(ss.str());
329 auto daq = builderNode.getNode(
"daqLink");
330 if (!daq.isDisconnected())
337 OUT <<
"event_builder: {\n";
340 auto parametersLink = daq.getNode(
"daqEventBuilderParametersLink");
341 if (!parametersLink.isDisconnected())
344 auto parameters = parametersLink.getChildren();
345 for (
auto ¶meter : parameters)
347 if (!parameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
350 OUT << parameter.second.getNode(
"daqParameterKey").getValue() <<
352 parameter.second.getNode(
"daqParameterValue").getValue()
355 if (!parameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
362 OUT <<
"sources: {\n";
365 auto sourcesGroup = daq.getNode(
"daqEventBuilderSourcesLink");
366 if (!sourcesGroup.isDisconnected())
370 auto sources = sourcesGroup.getChildren();
371 for (
auto &source : sources)
373 auto sourceContextUID = source.second.getNode(
"sourceARTDAQContextLink").getValueAsString();
375 unsigned int sourceRank = contextConfig->getARTDAQAppRank(sourceContextUID);
376 std::string host = contextConfig->getContextAddress(sourceContextUID);
377 unsigned int port = contextConfig->getARTDAQDataPort(configManager,sourceContextUID);
380 OUT << source.second.getNode(
"sourceKey").getValue() <<
382 " transferPluginType: " <<
383 source.second.getNode(
"transferPluginType").getValue() <<
386 " max_fragment_size_words: " <<
387 source.second.getNode(
"ARTDAQGlobalConfigurationLink/maxFragmentSizeWords").getValue<
unsigned int>() <<
388 " host_map: [{rank: " << sourceRank <<
" host: \"" << host <<
"\" portOffset: " << std::to_string(port) <<
"}, " <<
389 "{rank: " << selfRank <<
" host: \"" << selfHost <<
"\" portOffset: " << std::to_string(selfPort) <<
"}]" <<
393 catch (
const std::runtime_error& e)
395 __SS__ <<
"Are the DAQ sources valid? Error occurred looking for Event Builder DAQ sources for UID '" <<
396 builderNode.getValue() <<
"': " << e.what() << std::endl;
397 __COUT_ERR__ << ss.str() << std::endl;
398 throw std::runtime_error(ss.str());
408 OUT <<
"metrics: {\n";
411 auto metricsGroup = daq.getNode(
"daqMetricsLink");
412 if (!metricsGroup.isDisconnected())
414 auto metrics = metricsGroup.getChildren();
416 for (
auto &metric : metrics)
418 if (!metric.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
421 OUT << metric.second.getNode(
"metricKey").getValue() <<
425 OUT <<
"metricPluginType: " <<
426 metric.second.getNode(
"metricPluginType").getValue()
429 metric.second.getNode(
"metricLevel").getValue()
432 auto metricParametersGroup = metric.second.getNode(
"metricParametersLink");
433 if (!metricParametersGroup.isDisconnected())
435 auto metricParameters = metricParametersGroup.getChildren();
436 for (
auto &metricParameter : metricParameters)
438 if (!metricParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
441 OUT << metricParameter.second.getNode(
"metricParameterKey").getValue() <<
443 metricParameter.second.getNode(
"metricParameterValue").getValue()
446 if (!metricParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
454 if (!metric.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
467 auto outputs = builderNode.getNode(
"outputsLink");
468 if (!outputs.isDisconnected())
470 OUT <<
"outputs: {\n";
474 auto outputPlugins = outputs.getChildren();
475 for (
auto &outputPlugin : outputPlugins)
477 if (!outputPlugin.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
480 OUT << outputPlugin.second.getNode(
"outputKey").getValue() <<
483 OUT <<
"module_type: " <<
484 outputPlugin.second.getNode(
"outputModuleType").getValue() <<
486 auto pluginParameterLink = outputPlugin.second.getNode(
"outputModuleParameterLink");
487 if (!pluginParameterLink.isDisconnected())
489 auto pluginParameters = pluginParameterLink.getChildren();
490 for (
auto &pluginParameter : pluginParameters)
492 if (!pluginParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
495 OUT << pluginParameter.second.getNode(
"outputParameterKey").getValue() <<
497 pluginParameter.second.getNode(
"outputParameterValue").getValue()
500 if (!pluginParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
507 if (!outputPlugin.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
518 auto physics = builderNode.getNode(
"physicsLink");
519 if (!physics.isDisconnected())
522 OUT <<
"physics: {\n";
526 auto analyzers = physics.getNode(
"analyzersLink");
527 if (!analyzers.isDisconnected())
530 OUT <<
"analyzers: {\n";
533 auto modules = analyzers.getChildren();
534 for (
auto &module : modules)
536 if (!module.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
539 OUT << module.second.getNode(
"analyzerKey").getValue() <<
542 OUT <<
"module_type: " <<
543 module.second.getNode(
"analyzerModuleType").getValue() <<
545 auto moduleParameterLink = module.second.getNode(
"analyzerModuleParameterLink");
546 if (!moduleParameterLink.isDisconnected())
548 auto moduleParameters = moduleParameterLink.getChildren();
549 for (
auto &moduleParameter : moduleParameters)
551 if (!moduleParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
554 OUT << moduleParameter.second.getNode(
"analyzerParameterKey").getValue() <<
556 moduleParameter.second.getNode(
"analyzerParameterValue").getValue()
559 if (!moduleParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
566 if (!module.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
573 auto producers = physics.getNode(
"producersLink");
574 if (!producers.isDisconnected())
577 OUT <<
"producers: {\n";
580 auto modules = producers.getChildren();
581 for (
auto &module : modules)
583 if (!module.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
586 OUT << module.second.getNode(
"producerKey").getValue() <<
589 OUT <<
"module_type: " <<
590 module.second.getNode(
"producerModuleType").getValue() <<
592 auto moduleParameterLink = module.second.getNode(
"producerModuleParameterLink");
593 if (!moduleParameterLink.isDisconnected())
595 auto moduleParameters = moduleParameterLink.getChildren();
596 for (
auto &moduleParameter : moduleParameters)
598 if (!moduleParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
601 OUT << moduleParameter.second.getNode(
"producerParameterKey").getValue() <<
603 moduleParameter.second.getNode(
"producerParameterValue").getValue()
606 if (!moduleParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
613 if (!module.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
621 auto filters = physics.getNode(
"filtersLink");
622 if (!filters.isDisconnected())
625 OUT <<
"filters: {\n";
628 auto modules = filters.getChildren();
629 for (
auto &module : modules)
631 if (!module.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
634 OUT << module.second.getNode(
"filterKey").getValue() <<
637 OUT <<
"module_type: " <<
638 module.second.getNode(
"filterModuleType").getValue() <<
640 auto moduleParameterLink = module.second.getNode(
"filterModuleParameterLink");
641 if (!moduleParameterLink.isDisconnected())
643 auto moduleParameters = moduleParameterLink.getChildren();
644 for (
auto &moduleParameter : moduleParameters)
646 if (!moduleParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
649 OUT << moduleParameter.second.getNode(
"filterParameterKey").getValue()
651 moduleParameter.second.getNode(
"filterParameterValue").getValue()
654 if (!moduleParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
661 if (!module.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
669 auto otherParameterLink = physics.getNode(
"physicsOtherParametersLink");
670 if (!otherParameterLink.isDisconnected())
673 auto physicsParameters = otherParameterLink.getChildren();
674 for (
auto ¶meter : physicsParameters)
676 if (!parameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
679 OUT << parameter.second.getNode(
"physicsParameterKey").getValue() <<
681 parameter.second.getNode(
"physicsParameterValue").getValue()
684 if (!parameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
695 auto source = builderNode.getNode(
"sourceLink");
696 if (!source.isDisconnected())
698 OUT <<
"source: {\n";
701 OUT <<
"module_type: " << source.getNode(
"sourceModuleType").getValue() <<
703 OUT <<
"waiting_time: " << source.getNode(
"sourceWaitingTime").getValue() <<
705 OUT <<
"resume_after_timeout: " <<
706 (source.getNode(
"sourceResumeAfterTimeout").getValue<
bool>() ?
"true" :
"false") <<
714 OUT <<
"process_name: " <<
715 builderNode.getNode(
"ARTDAQGlobalConfigurationForProcessNameLink/processNameForBuilders")