ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
HeavyIonRec
HIGlobal
src
HIEventShapeMaker.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <
HIGlobal/HIEventShapeMaker.h
>
6
#include <
xAODHIEvent/HIEventShape.h
>
7
#include <
xAODHIEvent/HIEventShapeContainer.h
>
8
#include <
xAODHIEvent/HIEventShapeAuxContainer.h
>
9
10
#include <GaudiKernel/ServiceHandle.h>
11
#include "
StoreGate/ReadHandle.h
"
12
#include "
StoreGate/WriteHandle.h
"
13
14
HIEventShapeMaker::HIEventShapeMaker
(
const
std::string& name, ISvcLocator* pSvcLocator) :
AthReentrantAlgorithm
(name, pSvcLocator)
15
{
16
}
17
18
19
StatusCode
HIEventShapeMaker::initialize
()
20
{
21
ATH_MSG_INFO
(
"Inside HIEventShapeMaker::initialize()"
);
22
23
//First we initialize keys - after initialization they are frozen
24
ATH_CHECK
(
m_towerContainerKey
.initialize(
SG::AllowEmpty
));
25
ATH_CHECK
(
m_naviContainerKey
.initialize(
SG::AllowEmpty
));
26
ATH_CHECK
(
m_cellContainerKey
.initialize(
SG::AllowEmpty
));
27
ATH_CHECK
(
m_outputKey
.initialize(!
m_summaryOnly
));
28
ATH_CHECK
(
m_readExistingKey
.initialize(
m_summaryOnly
));
29
ATH_CHECK
(
m_summaryKey
.initialize(!
m_summaryKey
.key().empty()));
30
31
// assure consistent setup of the input
32
ATH_CHECK
(
m_naviContainerKey
.empty() !=
m_cellContainerKey
.empty());
33
34
//Create the HIEventShapeFillerTool
35
if
(!
m_summaryOnly
)
36
{
37
ATH_CHECK
(
m_HIEventShapeFillerTool
.retrieve());
38
m_HIEventShapeFillerTool
->setContainerName(
m_outputKey
.key());
39
ATH_CHECK
(
m_HIEventShapeFillerTool
->initializeIndex());
40
}
41
if
(
m_summaryKey
.key().compare(
""
) != 0)
ATH_CHECK
(
m_summaryTool
->initialize());
42
43
return
StatusCode::SUCCESS;
44
}
45
46
StatusCode
HIEventShapeMaker::execute
(
const
EventContext& ctx)
const
47
{
48
const
xAOD::HIEventShapeContainer
* evtShape_const =
nullptr
;
49
if
(
m_summaryOnly
) {
50
SG::ReadHandle<xAOD::HIEventShapeContainer>
readHandleEvtShape(
m_readExistingKey
, ctx);
51
if
(!readHandleEvtShape.
isValid
()) {
52
ATH_MSG_FATAL
(
"Could not find HI event shape! ("
<<
m_readExistingKey
.key() <<
")."
);
53
return
(StatusCode::FAILURE);
54
}
55
evtShape_const = readHandleEvtShape.
cptr
();
56
}
57
else
58
{
59
auto
evtShape=std::make_unique<xAOD::HIEventShapeContainer>();
60
auto
evtShapeAux=std::make_unique<xAOD::HIEventShapeAuxContainer>();
61
evtShape->setStore(evtShapeAux.get());
62
63
ATH_CHECK
(
m_HIEventShapeFillerTool
->initializeEventShapeContainer(evtShape));
64
65
if
(not
m_cellContainerKey
.empty()) {
66
ATH_CHECK
(
m_HIEventShapeFillerTool
->fillCollectionFromCells(evtShape,
m_cellContainerKey
, ctx));
67
}
else
{
68
ATH_CHECK
(
m_HIEventShapeFillerTool
->fillCollectionFromTowers(evtShape,
m_towerContainerKey
,
m_naviContainerKey
, ctx));
69
}
70
71
SG::WriteHandle<xAOD::HIEventShapeContainer>
writeHandleEvtShape(
m_outputKey
, ctx);
72
ATH_CHECK
( writeHandleEvtShape.
record
(std::move(evtShape), std::move(evtShapeAux)) );
73
74
evtShape_const = writeHandleEvtShape.
cptr
();
75
}
76
77
ATH_MSG_DEBUG
(
PrintHIEventShapeContainer
(evtShape_const));
78
79
if
(!
m_summaryKey
.empty())
80
{
81
SG::WriteHandle<xAOD::HIEventShapeContainer>
write_handle_esSummary(
m_summaryKey
,ctx);
82
ATH_CHECK
(write_handle_esSummary.
record
(std::make_unique<xAOD::HIEventShapeContainer>(),
83
std::make_unique<xAOD::HIEventShapeAuxContainer>()));
84
if
(
m_summaryOnly
) {
85
ATH_CHECK
(
m_summaryTool
->summarize(evtShape_const, write_handle_esSummary.
ptr
()));
86
}
else
{
87
ATH_CHECK
(
m_summaryTool
->summarize(evtShape_const, write_handle_esSummary.
ptr
()));
88
}
89
}
90
return
StatusCode::SUCCESS;
91
}
92
93
94
StatusCode
HIEventShapeMaker::finalize
()
95
{
96
return
StatusCode::SUCCESS;
97
}
98
99
100
std::string
HIEventShapeMaker::PrintHIEventShapeContainer
(
const
xAOD::HIEventShapeContainer
*
Container
)
const
101
{
102
std::stringstream buffer;
103
buffer << std::endl <<
"|############|############|############|############|############|"
<< std::endl;
104
buffer <<
"|"
<< std::setw(10) <<
"EtaMin"
<<
" |"
\
105
<< std::setw(10) <<
"EtaMax"
<<
" |"
\
106
<< std::setw(10) <<
"Layer"
<<
" |"
\
107
<< std::setw(10) <<
"NCells"
<<
" |"
\
108
<< std::setw(10) <<
"Et"
<<
" |"
<< std::endl;
109
unsigned
int
size
=
Container
->size();
110
for
(
unsigned
int
i = 0;i <
size
;i++) {
111
const
xAOD::HIEventShape
*
sh
=
Container
->at(i);
112
int
NCells =
sh
->nCells();
113
int
Layer =
sh
->layer();
114
float
Et =
sh
->et();
115
float
EtaMin =
sh
->etaMin();
116
float
EtaMax =
sh
->etaMax();
117
118
if
(Et == 0)
continue
;
119
buffer <<
"|"
<< std::setw(10) << EtaMin <<
" |"
\
120
<< std::setw(10) << EtaMax <<
" |"
\
121
<< std::setw(10) << Layer <<
" |"
\
122
<< std::setw(10) << NCells <<
" |"
\
123
<< std::setw(10) << Et <<
" |"
<<std::endl;
124
}
125
buffer <<
"|############|############|############|############|############|"
<< std::endl;
126
127
return
buffer.str();
128
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
HIEventShapeAuxContainer.h
HIEventShapeContainer.h
HIEventShapeMaker.h
HIEventShape.h
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
size
size_t size() const
Number of registered mappings.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
HIEventShapeMaker::m_cellContainerKey
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
Definition
HIEventShapeMaker.h:46
HIEventShapeMaker::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
HIEventShapeMaker.cxx:46
HIEventShapeMaker::HIEventShapeMaker
HIEventShapeMaker(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition
HIEventShapeMaker.cxx:14
HIEventShapeMaker::m_summaryKey
SG::WriteHandleKey< xAOD::HIEventShapeContainer > m_summaryKey
Definition
HIEventShapeMaker.h:49
HIEventShapeMaker::m_outputKey
SG::WriteHandleKey< xAOD::HIEventShapeContainer > m_outputKey
Definition
HIEventShapeMaker.h:48
HIEventShapeMaker::PrintHIEventShapeContainer
std::string PrintHIEventShapeContainer(const xAOD::HIEventShapeContainer *Container) const
Definition
HIEventShapeMaker.cxx:100
HIEventShapeMaker::initialize
virtual StatusCode initialize() override
Definition
HIEventShapeMaker.cxx:19
HIEventShapeMaker::m_towerContainerKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_towerContainerKey
Definition
HIEventShapeMaker.h:44
HIEventShapeMaker::m_readExistingKey
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_readExistingKey
Definition
HIEventShapeMaker.h:47
HIEventShapeMaker::m_HIEventShapeFillerTool
ToolHandle< IHIEventShapeFiller > m_HIEventShapeFillerTool
Definition
HIEventShapeMaker.h:53
HIEventShapeMaker::m_summaryOnly
Gaudi::Property< bool > m_summaryOnly
Definition
HIEventShapeMaker.h:51
HIEventShapeMaker::finalize
virtual StatusCode finalize() override
Definition
HIEventShapeMaker.cxx:94
HIEventShapeMaker::m_naviContainerKey
SG::ReadHandleKey< INavigable4MomentumCollection > m_naviContainerKey
Definition
HIEventShapeMaker.h:45
HIEventShapeMaker::m_summaryTool
ToolHandle< IHIEventShapeSummaryTool > m_summaryTool
Definition
HIEventShapeMaker.h:54
Container
storage of the time histories of all the cells
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::cptr
const_pointer_type cptr() const
Dereference the pointer.
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
RCU::Shell
Definition
ShellExec.cxx:25
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
xAOD::HIEventShapeContainer
HIEventShapeContainer_v2 HIEventShapeContainer
Define the latest version of the container.
Definition
HIEventShapeContainer.h:17
xAOD::HIEventShape
HIEventShape_v2 HIEventShape
Definition of the latest event info version.
Definition
HIEventShape.h:16
Generated on
for ATLAS Offline Software by
1.17.0