00001 #include <iostream>
00002 #include <memory>
00003 #include <boost/program_options.hpp>
00004 #include <boost/lexical_cast.hpp>
00005 #include "artdaq/DAQdata/Globals.hh"
00006 #include "artdaq/Application/TaskType.hh"
00007 #include "artdaq/Application/EventBuilderApp.hh"
00008 #include "artdaq/Application/LoadParameterSet.hh"
00009 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
00010 #include "artdaq-mpich-plugin/Application/MPISentry.hh"
00011 #include "artdaq/BuildInfo/GetPackageBuildInfo.hh"
00012 #include "cetlib_except/exception.h"
00013
00014 int main(int argc, char* argv[])
00015 {
00016
00017
00018 int const wanted_threading_level{ MPI_THREAD_MULTIPLE };
00019 MPI_Comm local_group_comm;
00020 std::unique_ptr<artdaq::MPISentry> mpiSentry;
00021
00022 try
00023 {
00024 mpiSentry.reset(new artdaq::MPISentry(&argc, &argv, wanted_threading_level, artdaq::TaskType::EventBuilderTask, local_group_comm));
00025 }
00026 catch (cet::exception& errormsg)
00027 {
00028 TLOG_ERROR("EventBuilderMain") << errormsg ;
00029 TLOG_ERROR("EventBuilderMain") << "MPISentry error encountered in EventBuilderMain; exiting..." ;
00030 throw errormsg;
00031 }
00032
00033 struct Config
00034 {
00035 fhicl::TableFragment<artdaq::CommanderInterface::Config> commander_config;
00036 fhicl::Atom<std::string> application_name{ fhicl::Name{ "application_name" }, fhicl::Comment{ "Name of the application for metrics and logging" }, "EventBuilder" };
00037 fhicl::TableFragment<artdaq::PortManager::Config> portsConfig;
00038 };
00039
00040 fhicl::ParameterSet config = LoadParameterSet<Config>(argc, argv, "EventBuilderMain", "This is the EventBuilder's main executable (MPI version)");
00041 app_name = config.get<std::string>("application_name", "EventBuilder");
00042 portMan->UpdateConfiguration(config);
00043 std::string mf_app_name = artdaq::setMsgFacAppName(app_name, config.get<int>("id"));
00044 artdaq::configureMessageFacility(mf_app_name.c_str());
00045 TLOG_DEBUG(app_name + "Main") << "Setting application name to " << mf_app_name ;
00046
00047
00048 if (config.has_key("partition_number"))
00049 {
00050 artdaq::Globals::partition_number_ = config.get<int>("partition_number");
00051 }
00052 TLOG_DEBUG(app_name + "Main") << "Setting partition number to " << artdaq::Globals::partition_number_;
00053
00054 TLOG_INFO(app_name + "Main") << "artdaq version " <<
00055 artdaq::GetPackageBuildInfo::getPackageBuildInfo().getPackageVersion()
00056 << ", built " <<
00057 artdaq::GetPackageBuildInfo::getPackageBuildInfo().getBuildTimestamp() ;
00058
00059
00060 my_rank = mpiSentry->rank();
00061 artdaq::EventBuilderApp evb_app;
00062
00063 TLOG_DEBUG(app_name + "Main") << "Creating EventBuilder Commander plugin" ;
00064 auto commander = artdaq::MakeCommanderPlugin(config, evb_app);
00065
00066 TLOG_INFO(app_name + "Main") << "Running Commmander Server" ;
00067 commander->run_server();
00068 artdaq::Globals::CleanUpGlobals();
00069 TLOG_INFO(app_name + "Main") << "Commandable Server ended, exiting..." ;
00070 }