ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
EventShapes
EventShapeTools
Root
EventShapeCopier.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// EventShapeCopier.cxx
6
7
#include "
EventShapeTools/EventShapeCopier.h
"
8
9
#include "
xAODEventShape/EventShape.h
"
10
#include "
xAODEventShape/EventShapeAuxInfo.h
"
11
#include "
AsgDataHandles/ReadHandle.h
"
12
#include "
AsgDataHandles/WriteHandle.h
"
13
#include "
AthContainers/Accessor.h
"
14
#include "
AthContainers/ConstAccessor.h
"
15
16
//**********************************************************************
17
18
EventShapeCopier::EventShapeCopier
(
const
std::string& name)
19
:
asg
::
AsgTool
(name),
20
m_inputEventShape
(
"LCTopoEventShape"
),
m_outputEventShape
(
""
),
m_eventDensityName
(
""
) {
21
declareProperty
(
"InputEventShape"
,
m_inputEventShape
);
22
declareProperty
(
"OutputEventShape"
,
m_outputEventShape
);
23
declareProperty
(
"EventDensityName"
,
m_eventDensityName
);
24
25
}
26
27
//**********************************************************************
28
29
EventShapeCopier::~EventShapeCopier
() {}
30
31
//**********************************************************************
32
33
StatusCode
EventShapeCopier::initialize
() {
34
35
// Handles
36
ATH_CHECK
(
m_inputEventShape
.initialize() );
37
ATH_CHECK
(
m_outputEventShape
.initialize() );
38
m_outputEventShapeIn
=
m_outputEventShape
.key();
39
ATH_CHECK
(
m_outputEventShapeIn
.initialize() );
40
41
return
StatusCode::SUCCESS;
42
}
43
44
//**********************************************************************
45
46
StatusCode
EventShapeCopier::fillEventShape
()
const
{
47
48
ATH_MSG_DEBUG
(
"Begin fillEventShape()"
);
49
50
// check if not already existing
51
auto
handle_inOut =
SG::makeHandle
(
m_outputEventShapeIn
);
52
if
( handle_inOut.isValid() ) {
53
ATH_MSG_WARNING
(
"EventShape with key "
<<
m_outputEventShapeIn
.key() <<
" already exists. Not overwriting it."
);
54
return
StatusCode::SUCCESS;
55
}
56
57
xAOD::EventShape
*evs =
new
xAOD::EventShape
();
58
std::unique_ptr<xAOD::EventShape> evs_ptr(evs);
59
60
xAOD::EventShapeAuxInfo
* evsaux =
new
xAOD::EventShapeAuxInfo
();
61
std::unique_ptr<xAOD::EventShapeAuxInfo> evsaux_ptr( evsaux);
62
evs->setStore( evsaux );
63
64
ATH_CHECK
(
fillEventShape
(evs));
65
66
auto
h_out = makeHandle(
m_outputEventShape
);
67
if
( ! h_out.record(std::move(evs_ptr), std::move(evsaux_ptr)) ) {
68
ATH_MSG_WARNING
(
"Unable to write new Jet collection and aux store to event store: "
<<
m_outputEventShape
.key());
69
}
else
{
70
ATH_MSG_DEBUG
(
"Created new EventShape container: "
<<
m_outputEventShape
.key());
71
}
72
73
return
StatusCode::SUCCESS;
74
}
75
76
//**********************************************************************
77
StatusCode
EventShapeCopier::fillEventShape
(
xAOD::EventShape
*evs)
const
{
78
const
xAOD::EventShape
* inputES;
79
80
SG::ReadHandle<xAOD::EventShape>
handle_in(
m_inputEventShape
);
81
if
( handle_in.
isValid
() ) {
82
inputES = handle_in.
cptr
();
83
}
else
{
84
ATH_MSG_WARNING
(
"Unable to read: "
<<
m_inputEventShape
.key());
85
return
StatusCode::FAILURE;
86
}
87
88
SG::ConstAccessor<float>
InputDensityAcc (
m_eventDensityName
) ;
89
SG::ConstAccessor<float>
InputDensitySigmaAcc (
m_eventDensityName
+
"Sigma"
) ;
90
SG::ConstAccessor<float>
InputDensityAreaAcc (
m_eventDensityName
+
"Area"
) ;
91
static
const
SG::Accessor<float>
DensityAcc (
"Density"
) ;
92
static
const
SG::Accessor<float>
DensitySigmaAcc (
"DensitySigma"
) ;
93
static
const
SG::Accessor<float>
DensityAreaAcc (
"DensityArea"
) ;
94
DensityAcc(*evs) = InputDensityAcc(*inputES);
95
DensitySigmaAcc(*evs) = InputDensitySigmaAcc(*inputES);
96
DensityAreaAcc(*evs) = InputDensityAreaAcc(*inputES);
97
98
return
StatusCode::SUCCESS;
99
}
100
101
//**********************************************************************
102
103
#ifdef XAOD_ANALYSIS
104
void
EventShapeCopier::renameEventDensities
(){
105
setProperty
(
"InputEventShape"
,
"LCTopoEventShape"
).ignore();
106
setProperty
(
"OutputEventShape"
,
"Kt4LCTopoEventShape"
).ignore();
107
setProperty
(
"EventDensityName"
,
"DensityForJetsR4"
).ignore();
108
109
fillEventShape
().ignore();
110
111
setProperty
(
"InputEventShape"
,
"LCTopoEventShape"
).ignore();
112
setProperty
(
"OutputEventShape"
,
"Kt6LCTopoEventShape"
).ignore();
113
setProperty
(
"EventDensityName"
,
"DensityForJetsR6"
).ignore();
114
115
fillEventShape
().ignore();
116
}
117
#else
118
// In Athena, do nothing. Use an Athena alg as defined in python/EventDensityConfig.py
119
void
EventShapeCopier::renameEventDensities
(){}
120
#endif
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
Accessor.h
Helper class to provide type-safe access to aux data.
EventShapeAuxInfo.h
EventShapeCopier.h
EventShape.h
setProperty
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
Definition
NanobindBindings.cxx:75
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
EventShapeCopier::~EventShapeCopier
~EventShapeCopier()
Destructor:
Definition
EventShapeCopier.cxx:29
EventShapeCopier::m_outputEventShapeIn
SG::ReadHandleKey< xAOD::EventShape > m_outputEventShapeIn
Definition
EventShapeCopier.h:62
EventShapeCopier::renameEventDensities
void renameEventDensities()
This function is only a convenience function for use in Standalone Analysis it avoids the need of con...
Definition
EventShapeCopier.cxx:119
EventShapeCopier::initialize
StatusCode initialize()
Initialization.
Definition
EventShapeCopier.cxx:33
EventShapeCopier::m_outputEventShape
SG::WriteHandleKey< xAOD::EventShape > m_outputEventShape
Definition
EventShapeCopier.h:64
EventShapeCopier::fillEventShape
StatusCode fillEventShape() const
Action.
Definition
EventShapeCopier.cxx:46
EventShapeCopier::m_inputEventShape
SG::ReadHandleKey< xAOD::EventShape > m_inputEventShape
Definition
EventShapeCopier.h:63
EventShapeCopier::EventShapeCopier
EventShapeCopier(const std::string &name)
Constructor with parameters:
Definition
EventShapeCopier.cxx:18
EventShapeCopier::m_eventDensityName
std::string m_eventDensityName
Definition
EventShapeCopier.h:66
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition
Control/AthContainers/AthContainers/Accessor.h:68
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
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.
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
asg
Definition
DataHandleTestTool.h:28
xAOD::EventShape
EventShape_v1 EventShape
Definition of the current event format version.
Definition
EventShape.h:16
xAOD::EventShapeAuxInfo
EventShapeAuxInfo_v1 EventShapeAuxInfo
Definition of the latest event shape auxiliary info version.
Definition
EventShapeAuxInfo.h:16
Generated on
for ATLAS Offline Software by
1.17.0