1 #include "otsdaq-core/ConfigurationPluginDataFormats/ARTDAQAggregatorConfiguration.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 "aggregator"
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 ARTDAQAggregatorConfiguration::ARTDAQAggregatorConfiguration(
void)
36 ARTDAQAggregatorConfiguration::~ARTDAQAggregatorConfiguration(
void)
43 mkdir((ARTDAQ_FCL_PATH).c_str(), 0755);
45 __MOUT__ <<
"*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << std::endl;
46 __MOUT__ << configManager->__SELF_NODE__ << std::endl;
49 std::vector<const XDAQContextConfiguration::XDAQContext *> aggContexts =
50 contextConfig->getAggregatorContexts();
54 for(
auto &aggContext: aggContexts)
56 ConfigurationTree aggConfigNode = contextConfig->getSupervisorConfigNode(configManager,
57 aggContext->contextUID_, aggContext->applications_[0].applicationUID_);
59 __MOUT__ <<
"Path for this aggregator config is " <<
60 aggContext->contextUID_ <<
"/" <<
61 aggContext->applications_[0].applicationUID_ <<
"/" <<
62 aggConfigNode.getValueAsString() <<
65 outputFHICL(aggConfigNode,
66 contextConfig->getARTDAQAppRank(aggContext->contextUID_),
72 std::string ARTDAQAggregatorConfiguration::getFHICLFilename(
const ConfigurationTree &aggregatorNode)
74 __MOUT__ <<
"ARTDAQ Aggregator UID: " << aggregatorNode.getValue() << std::endl;
75 std::string filename = ARTDAQ_FCL_PATH + ARTDAQ_FILE_PREAMBLE +
"-";
76 std::string uid = aggregatorNode.getValue();
77 for(
unsigned int i=0;i<uid.size();++i)
78 if((uid[i] >=
'a' && uid[i] <=
'z') ||
79 (uid[i] >=
'A' && uid[i] <=
'Z') ||
80 (uid[i] >=
'0' && uid[i] <=
'9'))
85 __MOUT__ <<
"fcl: " << filename << std::endl;
91 void ARTDAQAggregatorConfiguration::outputFHICL(
const ConfigurationTree &aggregatorNode,
92 unsigned int selfRank,
238 std::string filename = getFHICLFilename(aggregatorNode);
240 __MOUT__ <<
"selfRank = " << selfRank << std::endl;
247 std::string tabStr =
"";
248 std::string commentStr =
"";
250 out.open(filename, std::fstream::out | std::fstream::trunc);
253 __SS__ <<
"Failed to open ARTDAQ Builder fcl file: " << filename << std::endl;
254 throw std::runtime_error(ss.str());
258 if(aggregatorNode.isDisconnected())
268 auto services = aggregatorNode.getNode(
"servicesLink");
269 if(!services.isDisconnected())
271 OUT <<
"services: {\n";
275 OUT <<
"scheduler: {\n";
278 OUT <<
"fileMode: " << services.getNode(
"schedulerFileMode").getValue() <<
280 OUT <<
"errorOnFailureToPut: " <<
281 (services.getNode(
"schedulerErrorOnFailtureToPut").getValue<
bool>()?
"true":
"false") <<
289 OUT <<
"NetMonTransportServiceInterface: {\n";
292 OUT <<
"service_provider: " <<
294 services.getNode(
"NetMonTrasportServiceInterfaceServiceProvider").getValue()
307 auto daq = aggregatorNode.getNode(
"daqLink");
308 if(!daq.isDisconnected())
314 OUT <<
"aggregator: {\n";
317 auto parametersLink = daq.getNode(
"daqAggregatorParametersLink");
318 if(!parametersLink.isDisconnected())
321 auto parameters = parametersLink.getChildren();
322 for(
auto ¶meter:parameters)
324 if(!parameter.second.getNode(
"Status").getValue<
bool>())
327 auto comment = parameter.second.getNode(
"CommentDescription");
328 OUT << parameter.second.getNode(
"daqParameterKey").getValue() <<
330 parameter.second.getNode(
"daqParameterValue").getValue()
332 (comment.isDefaultValue()?
"":(
"\t # " + comment.getValue())) <<
335 if(!parameter.second.getNode(
"Status").getValue<
bool>())
341 OUT <<
"sources: {\n";
344 auto sourcesGroup = daq.getNode(
"daqAggregatorSourcesLink");
345 if(!sourcesGroup.isDisconnected())
347 auto sources = sourcesGroup.getChildren();
348 for(
auto &source:sources)
350 unsigned int sourceRank =
351 contextConfig->getARTDAQAppRank(
352 source.second.getNode(
"sourceARTDAQContextLink").getValue());
354 OUT << source.second.getNode(
"sourceKey").getValue() <<
356 " transferPluginType: " <<
357 source.second.getNode(
"transferPluginType").getValue() <<
360 " max_fragment_size_words: " <<
361 source.second.getNode(
"ARTDAQGlobalConfigurationLink/maxFragmentSizeWords").getValue<
unsigned int>() <<
372 OUT <<
"metrics: {\n";
375 auto metricsGroup = daq.getNode(
"daqMetricsLink");
376 if(!metricsGroup.isDisconnected())
378 auto metrics = metricsGroup.getChildren();
380 for(
auto &metric:metrics)
382 if(!metric.second.getNode(
"Status").getValue<
bool>())
385 OUT << metric.second.getNode(
"metricKey").getValue() <<
389 OUT <<
"metricPluginType: " <<
390 metric.second.getNode(
"metricPluginType").getValue()
393 metric.second.getNode(
"metricLevel").getValue()
396 auto metricParametersGroup = metric.second.getNode(
"metricParametersLink");
397 if(!metricParametersGroup.isDisconnected())
399 auto metricParameters = metricParametersGroup.getChildren();
400 for(
auto &metricParameter:metricParameters)
402 if(!metricParameter.second.getNode(
"Status").getValue<
bool>())
405 auto comment = metricParameter.second.getNode(
"CommentDescription");
406 OUT << metricParameter.second.getNode(
"metricParameterKey").getValue() <<
408 metricParameter.second.getNode(
"metricParameterValue").getValue()
410 (comment.isDefaultValue()?
"":(
"\t # " + comment.getValue())) <<
413 if(!metricParameter.second.getNode(
"Status").getValue<
bool>())
421 if(!metric.second.getNode(
"Status").getValue<
bool>())
429 auto destinationsGroup = daq.getNode(
"daqAggregatorDestinationsLink");
430 if(!destinationsGroup.isDisconnected())
432 auto destinations = destinationsGroup.getChildren();
433 for(
auto &destination:destinations)
435 unsigned int destinationRank = contextConfig->getARTDAQAppRank(
436 destination.second.getNode(
"destinationARTDAQContextLink").getValueAsString());
438 OUT << destination.second.getNode(
"destinationKey").getValue() <<
440 " transferPluginType: " <<
441 destination.second.getNode(
"transferPluginType").getValue() <<
444 " destination_rank: " <<
446 " max_fragment_size_words: " <<
447 destination.second.getNode(
"ARTDAQGlobalConfigurationLink/maxFragmentSizeWords").getValue<
unsigned int>() <<
459 auto source = aggregatorNode.getNode(
"sourceLink");
460 if(!source.isDisconnected())
462 OUT <<
"source: {\n";
465 OUT <<
"module_type: " << source.getNode(
"sourceModuleType").getValue() <<
473 auto outputs = aggregatorNode.getNode(
"outputsLink");
474 if(!outputs.isDisconnected())
476 OUT <<
"outputs: {\n";
480 auto outputPlugins = outputs.getChildren();
481 for(
auto &outputPlugin:outputPlugins)
483 if(!outputPlugin.second.getNode(
"Status").getValue<
bool>())
486 OUT << outputPlugin.second.getNode(
"outputKey").getValue() <<
489 OUT <<
"module_type: " <<
490 outputPlugin.second.getNode(
"outputModuleType").getValue() <<
492 auto pluginParameterLink = outputPlugin.second.getNode(
"outputModuleParameterLink");
493 if(!pluginParameterLink.isDisconnected())
495 auto pluginParameters = pluginParameterLink.getChildren();
496 for(
auto &pluginParameter:pluginParameters)
498 if(!pluginParameter.second.getNode(
"Status").getValue<
bool>())
501 auto comment = pluginParameter.second.getNode(
"CommentDescription");
502 OUT << pluginParameter.second.getNode(
"outputParameterKey").getValue() <<
504 pluginParameter.second.getNode(
"outputParameterValue").getValue()
506 (comment.isDefaultValue()?
"":(
"\t # " + comment.getValue())) <<
509 if(!pluginParameter.second.getNode(
"Status").getValue<
bool>())
516 if(!outputPlugin.second.getNode(
"Status").getValue<
bool>())
527 auto physics = aggregatorNode.getNode(
"physicsLink");
528 if(!physics.isDisconnected())
531 OUT <<
"physics: {\n";
535 auto analyzers = physics.getNode(
"analyzersLink");
536 if(!analyzers.isDisconnected())
539 OUT <<
"analyzers: {\n";
542 auto modules = analyzers.getChildren();
543 for(
auto &module:modules)
545 if(!module.second.getNode(
"Status").getValue<
bool>())
548 OUT << module.second.getNode(
"analyzerKey").getValue() <<
551 OUT <<
"module_type: " <<
552 module.second.getNode(
"analyzerModuleType").getValue() <<
554 auto moduleParameterLink = module.second.getNode(
"analyzerModuleParameterLink");
555 if(!moduleParameterLink.isDisconnected())
557 auto moduleParameters = moduleParameterLink.getChildren();
558 for(
auto &moduleParameter:moduleParameters)
560 if(!moduleParameter.second.getNode(
"Status").getValue<
bool>())
563 auto comment = moduleParameter.second.getNode(
"CommentDescription");
564 OUT << moduleParameter.second.getNode(
"analyzerParameterKey").getValue() <<
566 moduleParameter.second.getNode(
"analyzerParameterValue").getValue()
568 (comment.isDefaultValue()?
"":(
"\t # " + comment.getValue())) <<
571 if(!moduleParameter.second.getNode(
"Status").getValue<
bool>())
578 if(!module.second.getNode(
"Status").getValue<
bool>())
585 auto producers = physics.getNode(
"producersLink");
586 if(!producers.isDisconnected())
589 OUT <<
"producers: {\n";
592 auto modules = producers.getChildren();
593 for(
auto &module:modules)
595 if(!module.second.getNode(
"Status").getValue<
bool>())
598 OUT << module.second.getNode(
"producerKey").getValue() <<
601 OUT <<
"module_type: " <<
602 module.second.getNode(
"producerModuleType").getValue() <<
604 auto moduleParameterLink = module.second.getNode(
"producerModuleParameterLink");
605 if(!moduleParameterLink.isDisconnected())
607 auto moduleParameters = moduleParameterLink.getChildren();
608 for(
auto &moduleParameter:moduleParameters)
610 if(!moduleParameter.second.getNode(
"Status").getValue<
bool>())
613 auto comment = moduleParameter.second.getNode(
"CommentDescription");
614 OUT << moduleParameter.second.getNode(
"producerParameterKey").getValue() <<
616 moduleParameter.second.getNode(
"producerParameterValue").getValue()
618 (comment.isDefaultValue()?
"":(
"\t # " + comment.getValue())) <<
621 if(!moduleParameter.second.getNode(
"Status").getValue<
bool>())
628 if(!module.second.getNode(
"Status").getValue<
bool>())
636 auto filters = physics.getNode(
"filtersLink");
637 if(!filters.isDisconnected())
640 OUT <<
"filters: {\n";
643 auto modules = filters.getChildren();
644 for(
auto &module:modules)
646 if(!module.second.getNode(
"Status").getValue<
bool>())
649 OUT << module.second.getNode(
"filterKey").getValue() <<
652 OUT <<
"module_type: " <<
653 module.second.getNode(
"filterModuleType").getValue() <<
655 auto moduleParameterLink = module.second.getNode(
"filterModuleParameterLink");
656 if(!moduleParameterLink.isDisconnected())
658 auto moduleParameters = moduleParameterLink.getChildren();
659 for(
auto &moduleParameter:moduleParameters)
661 if(!moduleParameter.second.getNode(
"Status").getValue<
bool>())
664 auto comment = moduleParameter.second.getNode(
"CommentDescription");
665 OUT << moduleParameter.second.getNode(
"filterParameterKey").getValue()
667 moduleParameter.second.getNode(
"filterParameterValue").getValue()
669 (comment.isDefaultValue()?
"":(
"\t # " + comment.getValue())) <<
672 if(!moduleParameter.second.getNode(
"Status").getValue<
bool>())
679 if(!module.second.getNode(
"Status").getValue<
bool>())
687 auto otherParameterLink = physics.getNode(
"physicsOtherParametersLink");
688 if(!otherParameterLink.isDisconnected())
691 auto physicsParameters = otherParameterLink.getChildren();
692 for(
auto ¶meter:physicsParameters)
694 if(!parameter.second.getNode(
"Status").getValue<
bool>())
697 auto comment = parameter.second.getNode(
"CommentDescription");
698 OUT << parameter.second.getNode(
"physicsParameterKey").getValue() <<
700 parameter.second.getNode(
"physicsParameterValue").getValue()
702 (comment.isDefaultValue()?
"":(
"\t # " + comment.getValue())) <<
705 if(!parameter.second.getNode(
"Status").getValue<
bool>())
716 OUT <<
"process_name: " <<
717 aggregatorNode.getNode(
"ARTDAQGlobalConfigurationForProcessNameLink/processNameForAggregators")