ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
RootCoreUtils
Root
hadd.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
7
8
//
9
// includes
10
//
11
12
#include <
RootCoreUtils/hadd.h
>
13
14
#include <sstream>
15
#include <
TFileMerger.h
>
16
#include <TList.h>
17
#include <TSystem.h>
18
#include <
RootCoreUtils/Assert.h
>
19
#include <
RootCoreUtils/MessageCheck.h
>
20
#include <filesystem>
21
#include <stdexcept>
22
23
//
24
// method implementations
25
//
26
27
namespace
RCU
28
{
29
void
hadd
(
const
std::string& output_file,
30
const
std::vector<std::string>& input_files,
31
unsigned
max_files)
32
{
33
using namespace
msgRootCoreUtils;
34
35
if
(input_files.size() == 1)
36
{
37
// if there is only one input file, create a symlink instead of merging
38
std::filesystem::create_symlink (input_files.front(), output_file);
39
return
;
40
}
41
42
TFileMerger merger (
false
,
false
);
43
44
merger.SetMsgPrefix (
"rcu_hadd"
);
45
merger.SetPrintLevel (98);
46
47
if
(max_files > 0)
48
{
49
merger.SetMaxOpenedFiles (max_files);
50
}
51
52
if
(!merger.OutputFile (output_file.c_str(),
false
, 1) )
53
{
54
throw
std::runtime_error (
"error opening target file: "
+ output_file);
55
}
56
57
for
(
const
std::string& input : input_files)
58
{
59
if
(!merger.AddFile (input.c_str()))
60
{
61
throw
std::runtime_error (
"error adding input file: "
+ input);
62
}
63
}
64
merger.SetNotrees (
false
);
65
66
bool
status = merger.Merge();
67
68
if
(status)
69
{
70
ANA_MSG_INFO
(
"merged "
<< merger.GetMergeList()->GetEntries() <<
" input files into "
<< output_file);
71
}
else
72
{
73
throw
std::runtime_error (
"hadd failure during the merge"
);
74
}
75
}
76
}
Assert.h
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg,...)
Macro printing info messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:291
MessageCheck.h
TFileMerger.h
hadd.h
RCU
This module defines a variety of assert style macros.
Definition
Assert.cxx:23
RCU::hadd
void hadd(const std::string &output_file, const std::vector< std::string > &input_files, unsigned max_files)
effects: perform the hadd functionality guarantee: basic failures: out of memory III failures: i/o er...
Definition
hadd.cxx:29
Generated on
for ATLAS Offline Software by
1.17.0