ATLAS Offline Software
Functions
eventloop_grid_merge.cxx File Reference
#include <EventLoop/OutputStream.h>
#include <RootCoreUtils/ThrowMsg.h>
#include <xAODRootAccess/Init.h>
#include <AsgMessaging/MessageCheck.h>
#include <TList.h>
#include <TSystem.h>
#include <TFile.h>
#include <regex>
Include dependency graph for eventloop_grid_merge.cxx:

Go to the source code of this file.

Functions

void try_exec (const std::string &cmd)
 
int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 21 of file eventloop_grid_merge.cxx.

22 {
23  using namespace asg::msgUserCode;
24  ANA_CHECK_SET_TYPE (int);
25 
26  ANA_CHECK (xAOD::Init ());
27 
28  if (argc != 4)
29  {
30  ANA_MSG_ERROR ("invalid number of arguments");
31  return -1;
32  }
33 
34  std::string jobDefFile = argv[1];
35  std::string output = argv[2];
36  std::string input = argv[3];
37 
38  std::string type = "DEFAULT";
39  std::string mergeCmd = "";
40 
41  TFile jd(jobDefFile.c_str());
42 
43  std::unique_ptr<TList> outs{dynamic_cast<TList*>(jd.Get("outputs"))};
44  if (outs.get() == nullptr) {
45  RCU_THROW_MSG("Unable to get list of output streams");
46  }
47  TIter itr(outs.get());
48  TObject* obj;
49  while ((obj = itr())) {
50  EL::OutputStream* os = dynamic_cast<EL::OutputStream*>(obj);
51  if (std::regex_match(output, std::regex(os->label() + "\\.root.*")) ||
52  std::regex_match(output, std::regex(".*\\." + os->label() + "\\.root.*")))
53  {
55  mergeCmd = os->options()->castString(EL::OutputStream::optMergeCmd, "", SH::MetaObject::CAST_NOCAST_DEFAULT);
56  break;
57  }
58  }
59 
60  if (mergeCmd.empty()) {
61  if (type == "xAOD") {
62  mergeCmd = "xAODMerge -s";
63  } else if (type == "xAODNoMeta") {
64  mergeCmd = "xAODMerge";
65  } else {
66  mergeCmd = "hadd -f";
67  }
68  }
69  mergeCmd += " " + output + " " + input;
70  try_exec(mergeCmd);
71 }

◆ try_exec()

void try_exec ( const std::string &  cmd)

Definition at line 14 of file eventloop_grid_merge.cxx.

15 {
16  if (gSystem->Exec(cmd.c_str()) != 0) {
17  RCU_THROW_MSG("command failed: " + cmd);
18  }
19 }
SH::MetaObject::CAST_NOCAST_DEFAULT
@ CAST_NOCAST_DEFAULT
cast and return the default value if the input has the wrong type
Definition: MetaObject.h:78
EL::OutputStream
Definition: OutputStream.h:34
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
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
EL::OutputStream::optMergeCmd
static const std::string optMergeCmd
Definition: OutputStream.h:121
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
try_exec
void try_exec(const std::string &cmd)
Definition: eventloop_grid_merge.cxx:14
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
merge.output
output
Definition: merge.py:17
EL::OutputStream::optType
static const std::string optType
Definition: OutputStream.h:120
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
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
RCU_THROW_MSG
#define RCU_THROW_MSG(message)
Definition: PrintMsg.h:58
python.PyAthena.obj
obj
Definition: PyAthena.py:135
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31