ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
SampleHandler
Root
SampleComposite.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
// includes
9
//
10
11
#include <
SampleHandler/SampleComposite.h
>
12
13
#include <stdexcept>
14
#include <
RootCoreUtils/Assert.h
>
15
#include <
SampleHandler/SampleLocal.h
>
16
17
//
18
// method implementations
19
//
20
21
ClassImp
(
SH::SampleComposite
)
22
23
namespace
SH
24
{
25
void
SampleComposite ::
26
testInvariant ()
const
27
{
28
for
(
const
auto
& sample : m_samples)
29
{
30
RCU_INVARIANT
(sample !=
nullptr
);
31
}
32
}
33
34
35
36
SampleComposite ::
37
SampleComposite ()
38
: Sample (
"unnamed"
)
39
{
40
RCU_NEW_INVARIANT
(
this
);
41
}
42
43
44
45
SampleComposite ::
46
SampleComposite (
const
std::string& name)
47
: Sample (name)
48
{
49
RCU_NEW_INVARIANT
(
this
);
50
}
51
52
53
54
void
SampleComposite ::
55
add (std::shared_ptr<Sample> sample)
56
{
57
RCU_CHANGE_INVARIANT
(
this
);
58
RCU_REQUIRE_SOFT
(sample !=
nullptr
);
59
if
(
contains
(sample->name()))
60
throw
std::runtime_error (
"trying to add sample "
+ sample->name() +
" to sample "
+ name() +
", which already contains a sample "
+ sample->name());
61
m_samples.push_back (std::move (sample));
62
}
63
64
65
66
std::size_t SampleComposite ::
67
getNumFiles ()
const
68
{
69
RCU_READ_INVARIANT
(
this
);
70
throw
std::runtime_error (
"Sample::numFiles not supported for SampleComposite"
);
71
}
72
73
74
75
std::string SampleComposite ::
76
getFileName (
const
std::size_t
/*index*/
)
const
77
{
78
RCU_READ_INVARIANT
(
this
);
79
throw
std::runtime_error (
"Sample::fileName not supported for SampleComposite"
);
80
}
81
82
83
84
std::vector<std::string> SampleComposite ::
85
doMakeFileList ()
const
86
{
87
RCU_READ_INVARIANT
(
this
);
88
89
std::vector<std::string> result;
90
for
(
const
auto
& sample : m_samples)
91
{
92
std::vector<std::string> subresult = sample->makeFileList();
93
result.insert (result.end(), subresult.begin(), subresult.end());
94
}
95
return
result;
96
}
97
98
99
100
std::unique_ptr<SampleLocal> SampleComposite ::
101
doMakeLocal ()
const
102
{
103
RCU_READ_INVARIANT
(
this
);
104
throw
std::runtime_error (
"Sample::makeLocal not supported for SampleComposite"
);
105
}
106
107
108
109
void
SampleComposite ::
110
doUpdateLocation (
const
std::string& from,
const
std::string& to)
111
{
112
RCU_READ_INVARIANT
(
this
);
113
for
(
const
auto
& sample : m_samples)
114
{
115
sample->updateLocation (from, to);
116
}
117
}
118
119
120
121
bool
SampleComposite ::
122
getContains (
const
std::string& name)
const
123
{
124
RCU_READ_INVARIANT
(
this
);
125
for
(
const
auto
& sample : m_samples)
126
{
127
if
(sample->contains (name))
128
return
true
;
129
}
130
return
false
;
131
}
132
133
134
135
void
SampleComposite ::
136
doAddSamples (SampleHandler& result,
const
std::shared_ptr<Sample>&
/*self*/
)
137
{
138
RCU_READ_INVARIANT
(
this
);
139
for
(
auto
& sample : m_samples)
140
{
141
sample->addSamples (result, sample);
142
}
143
}
144
}
Assert.h
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition
Assert.h:187
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition
Assert.h:219
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition
Assert.h:221
RCU_REQUIRE_SOFT
#define RCU_REQUIRE_SOFT(x)
Definition
Assert.h:141
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition
Assert.h:217
ClassImp
ClassImp(SH::SampleComposite) namespace SH
Definition
SampleComposite.cxx:21
SampleComposite.h
SampleLocal.h
SH::SampleComposite
This module defines an implementation of Sample that contains composite samples.
Definition
SampleComposite.h:24
contains
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Definition
hcg.cxx:116
SH
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition
PrunDriver.h:15
Generated on
for ATLAS Offline Software by
1.17.0