artdaq  v3_00_03
EventBuilderMain.cc
1 #include <iostream>
2 #include <memory>
3 #include <boost/program_options.hpp>
4 #include <boost/lexical_cast.hpp>
5 #include "artdaq/DAQdata/Globals.hh"
6 #include "artdaq/Application/TaskType.hh"
7 #include "artdaq/Application/EventBuilderApp.hh"
8 #include "artdaq/Application/LoadParameterSet.hh"
9 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
10 #include "artdaq/Application/MPI2/MPISentry.hh"
12 #include "artdaq/BuildInfo/GetPackageBuildInfo.hh"
13 #include "cetlib_except/exception.h"
14 
15 int main(int argc, char* argv[])
16 {
17  // initialization
18 
19  int const wanted_threading_level{ MPI_THREAD_MULTIPLE };
20  MPI_Comm local_group_comm;
21  std::unique_ptr<artdaq::MPISentry> mpiSentry;
22 
23  try
24  {
25  mpiSentry.reset(new artdaq::MPISentry(&argc, &argv, wanted_threading_level, artdaq::TaskType::EventBuilderTask, local_group_comm));
26  }
27  catch (cet::exception& errormsg)
28  {
29  TLOG_ERROR("EventBuilderMain") << errormsg << TLOG_ENDL;
30  TLOG_ERROR("EventBuilderMain") << "MPISentry error encountered in EventBuilderMain; exiting..." << TLOG_ENDL;
31  throw errormsg;
32  }
33 
34  fhicl::ParameterSet config = LoadParameterSet(argc, argv);
35  app_name = config.get<std::string>("application_name", "EventBuilder");
36  std::string mf_app_name = artdaq::setMsgFacAppName(app_name, config.get<int>("id"));
37  artdaq::configureMessageFacility(mf_app_name.c_str());
38  TLOG_DEBUG(app_name + "Main") << "Setting application name to " << mf_app_name << TLOG_ENDL;
39 
40 
41  TLOG_INFO(app_name + "Main") << "artdaq version " <<
43  << ", built " <<
44  artdaq::GetPackageBuildInfo::getPackageBuildInfo().getBuildTimestamp() << TLOG_ENDL;
45 
46  // create the EventBuilderApp
47  artdaq::EventBuilderApp evb_app(mpiSentry->rank(), app_name);
48 
49  TLOG_DEBUG(app_name + "Main") << "Creating EventBuilder Commander plugin" << TLOG_ENDL;
50  auto commander = artdaq::MakeCommanderPlugin(config, evb_app);
51 
52  TLOG_INFO(app_name + "Main") << "Running Commmander Server" << TLOG_ENDL;
53  commander->run_server();
54  TLOG_INFO(app_name + "Main") << "Commandable Server ended, exiting..." << TLOG_ENDL;
55 }
The MPISentry class initializes and finalizes the MPI context that the artdaq applciations run in...
Definition: MPISentry.hh:15
int rank() const
Get the MPI rank of the application.
Definition: MPISentry.cc:113
static artdaq::PackageBuildInfo getPackageBuildInfo()
Gets the version number and build timestmap for artdaq.
EventBuilderApp is an artdaq::Commandable derived class which controls the EventBuilderCore.
std::unique_ptr< artdaq::CommanderInterface > MakeCommanderPlugin(const fhicl::ParameterSet &commander_pset, artdaq::Commandable &commandable)
Load a CommanderInterface plugin.