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)
37 ARTDAQBuilderConfiguration::~ARTDAQBuilderConfiguration(
void)
43 configManager_ = configManager;
45 mkdir((ARTDAQ_FCL_PATH).c_str(), 0755);
47 __MOUT__ <<
"*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << std::endl;
48 __MOUT__ << configManager->__SELF_NODE__ << std::endl;
52 auto childrenMap = configManager->__SELF_NODE__.getChildren();
54 for(
auto &child:childrenMap)
55 if(child.second.getNode(
"Status").getValue<
bool>())
56 outputFHICL(child.second, contextConfig);
60 std::string ARTDAQBuilderConfiguration::getFHICLFilename(
const ConfigurationTree &builderNode)
62 __MOUT__ <<
"ARTDAQ Builder UID: " << builderNode.getValue() << std::endl;
63 std::string filename = ARTDAQ_FCL_PATH + ARTDAQ_FILE_PREAMBLE +
"-";
64 std::string uid = builderNode.getValue();
65 for(
unsigned int i=0;i<uid.size();++i)
66 if((uid[i] >=
'a' && uid[i] <=
'z') ||
67 (uid[i] >=
'A' && uid[i] <=
'Z') ||
68 (uid[i] >=
'0' && uid[i] <=
'9'))
73 __MOUT__ <<
"fcl: " << filename << std::endl;
79 void ARTDAQBuilderConfiguration::outputFHICL(
const ConfigurationTree &builderNode,
201 std::string filename = getFHICLFilename(builderNode);
207 std::string tabStr =
"";
208 std::string commentStr =
"";
210 out.open(filename, std::fstream::out | std::fstream::trunc);
213 __SS__ <<
"Failed to open ARTDAQ Builder fcl file: " << filename << std::endl;
214 throw std::runtime_error(ss.str());
219 auto services = builderNode.getNode(
"servicesLink");
220 if(!services.isDisconnected())
222 OUT <<
"services: {\n";
226 OUT <<
"scheduler: {\n";
229 OUT <<
"fileMode: " << services.getNode(
"schedulerFileMode").getValue() <<
231 OUT <<
"errorOnFailureToPut: " <<
232 (services.getNode(
"schedulerErrorOnFailtureToPut").getValue<
bool>()?
"true":
"false") <<
240 OUT <<
"NetMonTransportServiceInterface: {\n";
243 OUT <<
"service_provider: " <<
245 services.getNode(
"NetMonTrasportServiceInterfaceServiceProvider").getValue()
247 OUT <<
"destinations: {\n";
250 auto destinationsGroup = services.getNode(
"NetMonTrasportServiceInterfaceDestinationsLink");
251 if(!destinationsGroup.isDisconnected())
253 auto destinations = destinationsGroup.getChildren();
254 for(
auto &destination:destinations)
256 unsigned int destinationRank =
257 contextConfig->getARTDAQAppRank(
258 destination.second.getNode(
"destinationARTDAQContextLink").getValue());
259 OUT << destination.second.getNode(
"destinationKey").getValue() <<
261 " transferPluginType: " <<
262 destination.second.getNode(
"transferPluginType").getValue() <<
263 " destination_rank: " <<
265 " max_fragment_size_words: " <<
266 destination.second.getNode(
"ARTDAQGlobalConfigurationLink/maxFragmentSizeWords").getValue<
unsigned int>() <<
283 auto daq = builderNode.getNode(
"daqLink");
284 if(!daq.isDisconnected())
291 OUT <<
"event_builder: {\n";
294 auto parametersLink = daq.getNode(
"daqEventBuilderParametersLink");
295 if(!parametersLink.isDisconnected())
298 auto parameters = parametersLink.getChildren();
299 for(
auto ¶meter:parameters)
301 if(!parameter.second.getNode(
"Enabled").getValue<
bool>())
304 OUT << parameter.second.getNode(
"daqParameterKey").getValue() <<
306 parameter.second.getNode(
"daqParameterValue").getValue()
309 if(!parameter.second.getNode(
"Enabled").getValue<
bool>())
316 OUT <<
"sources: {\n";
319 auto sourcesGroup = daq.getNode(
"daqEventBuilderSourcesLink");
320 if(!sourcesGroup.isDisconnected())
322 auto sources = sourcesGroup.getChildren();
323 for(
auto &source:sources)
325 unsigned int sourceRank =
326 contextConfig->getARTDAQAppRank(
327 source.second.getNode(
"sourceARTDAQContextLink").getValue());
329 OUT << source.second.getNode(
"sourceKey").getValue() <<
331 " transferPluginType: " <<
332 source.second.getNode(
"transferPluginType").getValue() <<
335 " max_fragment_size_words: " <<
336 source.second.getNode(
"ARTDAQGlobalConfigurationLink/maxFragmentSizeWords").getValue<
unsigned int>() <<
347 OUT <<
"metrics: {\n";
350 auto metricsGroup = daq.getNode(
"daqMetricsLink");
351 if(!metricsGroup.isDisconnected())
353 auto metrics = metricsGroup.getChildren();
355 for(
auto &metric:metrics)
357 if(!metric.second.getNode(
"Status").getValue<
bool>())
360 OUT << metric.second.getNode(
"metricKey").getValue() <<
364 OUT <<
"metricPluginType: " <<
365 metric.second.getNode(
"metricPluginType").getValue()
368 metric.second.getNode(
"metricLevel").getValue()
371 auto metricParametersGroup = metric.second.getNode(
"metricParametersLink");
372 if(!metricParametersGroup.isDisconnected())
374 auto metricParameters = metricParametersGroup.getChildren();
375 for(
auto &metricParameter:metricParameters)
377 if(!metricParameter.second.getNode(
"Enabled").getValue<
bool>())
380 OUT << metricParameter.second.getNode(
"metricParameterKey").getValue() <<
382 metricParameter.second.getNode(
"metricParameterValue").getValue()
385 if(!metricParameter.second.getNode(
"Enabled").getValue<
bool>())
393 if(!metric.second.getNode(
"Status").getValue<
bool>())
406 auto outputs = builderNode.getNode(
"outputsLink");
407 if(!outputs.isDisconnected())
409 OUT <<
"outputs: {\n";
413 auto outputPlugins = outputs.getChildren();
414 for(
auto &outputPlugin:outputPlugins)
416 if(!outputPlugin.second.getNode(
"Status").getValue<
bool>())
419 OUT << outputPlugin.second.getNode(
"outputKey").getValue() <<
422 OUT <<
"module_type: " <<
423 outputPlugin.second.getNode(
"outputModuleType").getValue() <<
425 auto pluginParameterLink = outputPlugin.second.getNode(
"outputModuleParameterLink");
426 if(!pluginParameterLink.isDisconnected())
428 auto pluginParameters = pluginParameterLink.getChildren();
429 for(
auto &pluginParameter:pluginParameters)
431 if(!pluginParameter.second.getNode(
"Enabled").getValue<
bool>())
434 OUT << pluginParameter.second.getNode(
"outputParameterKey").getValue() <<
436 pluginParameter.second.getNode(
"outputParameterValue").getValue()
439 if(!pluginParameter.second.getNode(
"Enabled").getValue<
bool>())
446 if(!outputPlugin.second.getNode(
"Status").getValue<
bool>())
457 auto physics = builderNode.getNode(
"physicsLink");
458 if(!physics.isDisconnected())
461 OUT <<
"physics: {\n";
465 auto analyzers = physics.getNode(
"analyzersLink");
466 if(!analyzers.isDisconnected())
469 OUT <<
"analyzers: {\n";
472 auto modules = analyzers.getChildren();
473 for(
auto &module:modules)
475 if(!module.second.getNode(
"Status").getValue<
bool>())
478 OUT << module.second.getNode(
"analyzerKey").getValue() <<
481 OUT <<
"module_type: " <<
482 module.second.getNode(
"analyzerModuleType").getValue() <<
484 auto moduleParameterLink = module.second.getNode(
"analyzerModuleParameterLink");
485 if(!moduleParameterLink.isDisconnected())
487 auto moduleParameters = moduleParameterLink.getChildren();
488 for(
auto &moduleParameter:moduleParameters)
490 if(!moduleParameter.second.getNode(
"Enabled").getValue<
bool>())
493 OUT << moduleParameter.second.getNode(
"analyzerParameterKey").getValue() <<
495 moduleParameter.second.getNode(
"analyzerParameterValue").getValue()
498 if(!moduleParameter.second.getNode(
"Enabled").getValue<
bool>())
505 if(!module.second.getNode(
"Status").getValue<
bool>())
512 auto producers = physics.getNode(
"producersLink");
513 if(!producers.isDisconnected())
516 OUT <<
"producers: {\n";
519 auto modules = producers.getChildren();
520 for(
auto &module:modules)
522 if(!module.second.getNode(
"Status").getValue<
bool>())
525 OUT << module.second.getNode(
"producerKey").getValue() <<
528 OUT <<
"module_type: " <<
529 module.second.getNode(
"producerModuleType").getValue() <<
531 auto moduleParameterLink = module.second.getNode(
"producerModuleParameterLink");
532 if(!moduleParameterLink.isDisconnected())
534 auto moduleParameters = moduleParameterLink.getChildren();
535 for(
auto &moduleParameter:moduleParameters)
537 if(!moduleParameter.second.getNode(
"Enabled").getValue<
bool>())
540 OUT << moduleParameter.second.getNode(
"producerParameterKey").getValue() <<
542 moduleParameter.second.getNode(
"producerParameterValue").getValue()
545 if(!moduleParameter.second.getNode(
"Enabled").getValue<
bool>())
552 if(!module.second.getNode(
"Status").getValue<
bool>())
560 auto filters = physics.getNode(
"filtersLink");
561 if(!filters.isDisconnected())
564 OUT <<
"filters: {\n";
567 auto modules = filters.getChildren();
568 for(
auto &module:modules)
570 if(!module.second.getNode(
"Status").getValue<
bool>())
573 OUT << module.second.getNode(
"filterKey").getValue() <<
576 OUT <<
"module_type: " <<
577 module.second.getNode(
"filterModuleType").getValue() <<
579 auto moduleParameterLink = module.second.getNode(
"filterModuleParameterLink");
580 if(!moduleParameterLink.isDisconnected())
582 auto moduleParameters = moduleParameterLink.getChildren();
583 for(
auto &moduleParameter:moduleParameters)
585 if(!moduleParameter.second.getNode(
"Enabled").getValue<
bool>())
588 OUT << moduleParameter.second.getNode(
"filterParameterKey").getValue()
590 moduleParameter.second.getNode(
"filterParameterValue").getValue()
593 if(!moduleParameter.second.getNode(
"Enabled").getValue<
bool>())
600 if(!module.second.getNode(
"Status").getValue<
bool>())
608 auto otherParameterLink = physics.getNode(
"physicsOtherParametersLink");
609 if(!otherParameterLink.isDisconnected())
612 auto physicsParameters = otherParameterLink.getChildren();
613 for(
auto ¶meter:physicsParameters)
615 if(!parameter.second.getNode(
"Enabled").getValue<
bool>())
618 OUT << parameter.second.getNode(
"physicsParameterKey").getValue() <<
620 parameter.second.getNode(
"physicsParameterValue").getValue()
623 if(!parameter.second.getNode(
"Enabled").getValue<
bool>())
634 auto source = builderNode.getNode(
"sourceLink");
635 if(!source.isDisconnected())
637 OUT <<
"source: {\n";
640 OUT <<
"module_type: " << source.getNode(
"sourceModuleType").getValue() <<
642 OUT <<
"waiting_time: " << source.getNode(
"sourceWaitingTime").getValue() <<
644 OUT <<
"resume_after_timeout: " <<
645 (source.getNode(
"sourceResumeAfterTimeout").getValue<
bool>()?
"true":
"false") <<
653 OUT <<
"process_name: " <<
654 builderNode.getNode(
"ARTDAQGlobalConfigurationForProcessNameLink/processNameForBuilders")