ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
SampleHandler
Root
ToolsJoin.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
//
8
// includes
9
//
10
11
#include <
SampleHandler/ToolsJoin.h
>
12
13
#include <memory>
14
#include <
RootCoreUtils/StringUtil.h
>
15
#include <
SampleHandler/MetaObject.h
>
16
#include <
SampleHandler/SampleHandler.h
>
17
#include <
SampleHandler/SampleLocal.h
>
18
19
//
20
// method implementations
21
//
22
23
namespace
SH
24
{
25
void
mergeSamples
(
SampleHandler
&
sh
,
const
std::string& sampleName,
26
const
std::string& pattern)
27
{
28
SampleHandler
mysh;
29
auto
mysample = std::make_shared<SampleLocal> (sampleName);
30
bool
matched =
false
;
31
32
std::regex mypattern (pattern);
33
for
(
auto
& sample :
sh
.samples())
34
{
35
if
(
RCU::match_expr
(mypattern, sample->name()))
36
{
37
if
(!matched)
38
{
39
// rationale: inherit the metadata (tree name, cross section,
40
// ...) from the first matched sample instead of falling
41
// back to the defaults.
42
*mysample->meta() = *sample->meta();
43
matched =
true
;
44
}
45
for
(
unsigned
file
= 0, end = sample->numFiles();
46
file
!= end; ++
file
)
47
{
48
mysample->add (sample->fileName (
file
));
49
}
50
}
else
51
{
52
mysh.
add
(sample);
53
}
54
}
55
// rationale: only add the merged sample if at least one sample
56
// matched, so we do not create a spurious empty sample.
57
if
(matched)
58
mysh.
add
(mysample);
59
swap
(mysh,
sh
);
60
}
61
}
MetaObject.h
SampleHandler.h
SampleLocal.h
StringUtil.h
ToolsJoin.h
SH::MetaObject::swap
void swap(MetaObject &a, MetaObject &b)
standard swap
SH::SampleHandler
A class that manages a list of Sample objects.
Definition
SampleHandler.h:53
SH::SampleHandler::add
void add(const Sample &sample)
add a copy of the sample to the handler
RCU::Shell
Definition
ShellExec.cxx:26
RCU::match_expr
bool match_expr(const std::regex &expr, std::string_view str)
returns: whether we can match the entire string with the regular expression guarantee: strong failure...
Definition
StringUtil.cxx:30
SH
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition
PrunDriver.h:15
SH::mergeSamples
void mergeSamples(SampleHandler &sh, const std::string &sampleName, const std::string &pattern)
effects: remove all samples matching the name pattern, and join them into a single sample named sampl...
Definition
ToolsJoin.cxx:25
file
TFile * file
Definition
tile_monitor.h:29
Generated on
for ATLAS Offline Software by
1.17.0