ATLAS Offline Software
eventloop_exec_worker.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <EventLoop/Driver.h>
9 #include <TSystem.h>
10 #include <xAODRootAccess/Init.h>
11 #include <fstream>
12 
13 int main (int argc, char **argv)
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
Driver.h
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
ShellExec.h
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
FullCPAlgorithmsTest_eljob.submitDir
submitDir
Definition: FullCPAlgorithmsTest_eljob.py:160
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MessageCheck.h
macros for messaging and checking status codes
calibdata.exception
exception
Definition: calibdata.py:496
Init.h
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
main
int main(int argc, char **argv)
Definition: eventloop_exec_worker.cxx:13
ThrowMsg.h
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