ATLAS Offline Software
PhysicsAnalysis
D3PDMaker
D3PDMakerReader
src
MultiReaderAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
// Gaudi/Athena include(s):
7
#include "
AthenaKernel/errorcheck.h
"
8
9
// Local include(s):
10
#include "
MultiReaderAlg.h
"
11
#include "
IReaderD3PD.h
"
12
13
namespace
D3PD
{
14
15
MultiReaderAlg::MultiReaderAlg
(
const
std::string&
name
, ISvcLocator* svcloc )
16
:
AthAlgorithm
(
name
, svcloc ),
17
m_d3pdSvc(
"D3PD::RootReaderD3PDSvc"
,
name
),
18
m_tools( this ),
19
m_metadataTools( this ),
20
m_d3pds(),
21
m_booked( false ) {
22
23
declareProperty
(
"D3PDSvc"
,
m_d3pdSvc
,
24
"The D3PD creation service."
);
25
declareProperty
(
"Tools"
,
m_tools
,
26
"List of IObjFillerTool instances to run."
);
27
declareProperty
(
"MetadataTools"
,
m_metadataTools
,
28
"List of IMetadataTool instances to run."
);
29
declareProperty
(
"TuplePath"
,
m_tuplePath
=
"dummy"
,
30
"The name of the tuple. The interpretation of this "
31
"depends on the D3PDSvc."
);
32
33
declareProperty
(
"Prefixes"
,
m_prefixes
,
34
"Common prefix to the D3PD variable names"
);
35
declareProperty
(
"ClassNames"
,
m_classnames
,
36
"Name of the C++ classes to be generated"
);
37
38
declareProperty
(
"Directory"
,
m_dir
=
"./"
,
39
"Output directory for the generated sources"
);
40
}
41
42
StatusCode
MultiReaderAlg::initialize
ATLAS_NOT_THREAD_SAFE
() {
43
44
CHECK
( m_d3pdSvc.retrieve() );
45
CHECK
( m_tools.retrieve() );
46
47
// Check if the configuration looks okay:
48
if
( ( m_tools.size() != m_prefixes.size() ) ||
49
( m_tools.size() != m_classnames.size() ) ) {
50
REPORT_MESSAGE
( MSG::ERROR ) <<
"The configuration is inconsistent: "
51
<< m_tools.size() <<
" tools, "
52
<< m_prefixes.size() <<
" prefixes "
53
<< m_classnames.size() <<
" classnames"
;
54
return
StatusCode::FAILURE;
55
}
56
57
// Create a new D3PD for each object filled tool:
58
for
(
size_t
i
= 0;
i
< m_tools.size(); ++
i
) {
59
60
// Generate a name for the class if it doesn't have one yet:
61
if
( m_classnames[
i
] ==
""
) {
62
static
int
counter
= 1;
63
std::ostringstream classname;
64
classname <<
"D3PDObject"
<<
counter
;
65
m_classnames[
i
] = classname.str();
66
++
counter
;
67
}
68
69
ID3PD* d3pd = 0;
70
CHECK
( m_d3pdSvc->make( m_tuplePath + m_classnames[
i
], d3pd ) );
71
72
ATH_MSG_DEBUG
(
"Creating D3PD object with name: "
<< m_tuplePath
73
<< m_classnames[
i
] );
74
75
// Check that the service created the correct type of D3PD object:
76
IReaderD3PD* rd3pd =
dynamic_cast<
IReaderD3PD*
>
( d3pd );
77
if
( ! rd3pd ) {
78
REPORT_MESSAGE
( MSG::ERROR ) <<
"The configured service ("
79
<< m_d3pdSvc <<
") did not create a "
80
<<
"D3PD::IReaderD3PD object!"
;
81
return
StatusCode::FAILURE;
82
}
83
84
// Configure the D3PD object:
85
rd3pd->setIsContainer( m_tools[
i
]->isContainerFiller() );
86
rd3pd->setPrefix( m_prefixes[
i
] );
87
88
// Remember this D3PD object:
89
m_d3pds.push_back( rd3pd );
90
91
}
92
93
// Configure each tool.
94
for
(
size_t
i
= 0;
i
< m_tools.size(); ++
i
) {
95
if
( m_classnames[
i
] ==
""
)
continue
;
96
CHECK
( m_tools[
i
]->configureD3PD( m_d3pds[
i
] ) );
97
}
98
99
m_booked =
false
;
100
return
StatusCode::SUCCESS;
101
}
102
103
StatusCode
MultiReaderAlg::finalize
() {
104
105
// Let the D3PD generate the source code that can read it back:
106
for
(
size_t
i
= 0;
i
<
m_tools
.size(); ++
i
) {
107
if
(
m_classnames
[
i
] ==
""
)
continue
;
108
CHECK
(
m_d3pds
[
i
]->createReader(
m_classnames
[
i
],
m_dir
) );
109
}
110
111
return
StatusCode::SUCCESS;
112
}
113
114
StatusCode
MultiReaderAlg::execute
() {
115
116
// Instruct all the tools to declare their variables to the D3PD object:
117
if
( !
m_booked
) {
118
m_booked
=
true
;
119
for
(
size_t
i
= 0;
i
<
m_tools
.size(); ++
i
) {
120
if
(
m_classnames
[
i
] ==
""
)
continue
;
121
CHECK
(
m_tools
[
i
]->
book
() );
122
}
123
}
124
125
return
StatusCode::SUCCESS;
126
}
127
128
}
// namespace D3PD
D3PD::MultiReaderAlg::m_tuplePath
std::string m_tuplePath
The D3PD base name.
Definition:
MultiReaderAlg.h:65
D3PD::MultiReaderAlg::execute
virtual StatusCode execute()
Standard Gaudi execute method.
Definition:
MultiReaderAlg.cxx:114
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition:
AthCommonDataStore.h:145
initialize
void initialize()
Definition:
run_EoverP.cxx:894
IReaderD3PD.h
D3PD::MultiReaderAlg::MultiReaderAlg
MultiReaderAlg(const std::string &name, ISvcLocator *svcloc)
Standard algorithm constructor.
Definition:
MultiReaderAlg.cxx:15
D3PD::MultiReaderAlg::m_tools
ToolHandleArray< IObjFillerTool > m_tools
Property: List of object filler tools to run.
Definition:
MultiReaderAlg.h:61
D3PD::MultiReaderAlg::m_d3pds
std::vector< IReaderD3PD * > m_d3pds
The created tuples. Note: we don't take ownership.
Definition:
MultiReaderAlg.h:73
D3PD
Block filler tool for noisy FEB information.
Definition:
InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
book
T * book(const std::string &n, const std::string &t, unsigned nbins)
Definition:
main_benchmark.cxx:138
lumiFormat.i
int i
Definition:
lumiFormat.py:92
D3PD::MultiReaderAlg::m_classnames
std::vector< std::string > m_classnames
Reader class names.
Definition:
MultiReaderAlg.h:68
D3PD::MultiReaderAlg::finalize
virtual StatusCode finalize()
Standard Gaudi finalize method.
Definition:
MultiReaderAlg.cxx:103
D3PD::MultiReaderAlg::m_prefixes
std::vector< std::string > m_prefixes
Variable name prefixes.
Definition:
MultiReaderAlg.h:67
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition:
AthMsgStreamMacros.h:29
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition:
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::ATLAS_NOT_THREAD_SAFE
StatusCode DummyInitAlg::initialize ATLAS_NOT_THREAD_SAFE()
Standard Gaudi initialize method.
Definition:
DummyInitAlg.cxx:69
D3PD::MultiReaderAlg::m_dir
std::string m_dir
Directory where the sources should be put.
Definition:
MultiReaderAlg.h:70
AthAlgorithm
Definition:
AthAlgorithm.h:47
D3PD::MultiReaderAlg::m_d3pdSvc
ServiceHandle< ID3PDSvc > m_d3pdSvc
Property: The D3PD creation service.
Definition:
MultiReaderAlg.h:59
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:195
MultiReaderAlg.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition:
Control/AthenaKernel/AthenaKernel/errorcheck.h:365
D3PD::MultiReaderAlg::m_metadataTools
ToolHandleArray< IMetadataTool > m_metadataTools
Property: List of metadata tools to run.
Definition:
MultiReaderAlg.h:63
test_pyathena.counter
counter
Definition:
test_pyathena.py:15
D3PD::MultiReaderAlg::m_booked
bool m_booked
Flag that we've called book().
Definition:
MultiReaderAlg.h:75
Generated on Fri Jul 5 2024 21:22:30 for ATLAS Offline Software by
1.8.18