ATLAS Offline Software
Functions
eventloop_exec_worker.cxx File Reference
#include <AsgMessaging/MessageCheck.h>
#include <EventLoop/Driver.h>
#include <RootCoreUtils/ShellExec.h>
#include <RootCoreUtils/ThrowMsg.h>
#include <TSystem.h>
#include <xAODRootAccess/Init.h>
#include <fstream>
Include dependency graph for eventloop_exec_worker.cxx:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 13 of file eventloop_exec_worker.cxx.

14 {
15  using namespace asg::msgUserCode;
16  ANA_CHECK_SET_TYPE (int);
17 
18  ANA_CHECK (xAOD::Init ());
19 
20  if (argc != 3)
21  {
22  ANA_MSG_ERROR ("invalid number of arguments");
23  return -1;
24  }
25 
26  std::string submitDir = argv[1];
27  std::size_t maxIndex = std::stoul (argv[2]);
28 
29  std::ostringstream basedirName;
30  basedirName << submitDir << "/tmp";
31  {
32  if (gSystem->MakeDirectory (basedirName.str().c_str()) != 0)
33  RCU_THROW_MSG ("failed to create directory " + basedirName.str());
34  }
35  auto submitSingle = [&] (std::size_t index) noexcept -> StatusCode
36  {
37  try
38  {
39  std::ostringstream dirName;
40  dirName << basedirName.str() << "/" << index;
41  if (gSystem->MakeDirectory (dirName.str().c_str()) != 0)
42  {
43  ANA_MSG_ERROR ("failed to create directory " + dirName.str());
44  return StatusCode::FAILURE;
45  }
46 
47  std::ostringstream cmd;
48  cmd << "cd " << dirName.str() << " && ";
49  cmd << RCU::Shell::quote (submitDir) << "/submit/run " << index;
50  RCU::Shell::exec (cmd.str());
51  } catch (std::exception& e)
52  {
53  ANA_MSG_ERROR ("exception in job " << index << ": " << e.what());
54  return StatusCode::FAILURE;
55  }
56  return StatusCode::SUCCESS;
57  };
58  for (std::size_t index = 0u; index != maxIndex; ++ index)
59  {
60  if (submitSingle (index).isFailure())
61  return EXIT_FAILURE;
62  }
63  // this particular file can be checked to see if a job has
64  // been submitted successfully.
65  std::ofstream ((submitDir + "/submitted").c_str());
67  return 0;
68 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
EL::Driver::retrieve
static bool retrieve(const std::string &location)
retrieve all the output for the job in the given location
index
Definition: index.py:1
rerun_display.cmd
string cmd
Definition: rerun_display.py:67
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
FullCPAlgorithmsTest_eljob.submitDir
submitDir
Definition: FullCPAlgorithmsTest_eljob.py:164
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
calibdata.exception
exception
Definition: calibdata.py:496
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
DeMoScan.index
string index
Definition: DeMoScan.py:364
ANA_CHECK_SET_TYPE
#define ANA_CHECK_SET_TYPE(TYPE)
set the type for ANA_CHECK to report failures
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:314
RCU::Shell::exec
void exec(const std::string &cmd)
effects: execute the given command guarantee: strong failures: out of memory II failures: system fail...
Definition: ShellExec.cxx:29
RCU_THROW_MSG
#define RCU_THROW_MSG(message)
Definition: PrintMsg.h:58
RCU::Shell::quote
std::string quote(const std::string &name)
effects: quote the given name to protect it from the shell returns: the quoted name guarantee: strong...
Definition: ShellExec.cxx:75
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31