ATLAS Offline Software
Loading...
Searching...
No Matches
EventShapeCopier.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EventShapeCopier.cxx
6
8
15
16//**********************************************************************
17
18EventShapeCopier::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
30
31//**********************************************************************
32
34
35 // DataHandles
36 ATH_CHECK( m_inputEventShape.initialize() );
37 ATH_CHECK( m_outputEventShape.initialize() );
39 ATH_CHECK( m_outputEventShapeIn.initialize() );
40
41 return StatusCode::SUCCESS;
42}
43
44//**********************************************************************
45
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
58 std::unique_ptr<xAOD::EventShape> evs_ptr(evs);
59
61 std::unique_ptr<xAOD::EventShapeAuxInfo> evsaux_ptr( evsaux);
62 evs->setStore( evsaux );
63
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//**********************************************************************
78 const xAOD::EventShape * inputES;
79
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
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
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
120#endif
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
Helper class to provide constant type-safe access to aux data.
Helper class to provide type-safe access to aux data.
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
~EventShapeCopier()
Destructor:
SG::ReadHandleKey< xAOD::EventShape > m_outputEventShapeIn
void renameEventDensities()
This function is only a convenience function for use in Standalone Analysis it avoids the need of con...
StatusCode initialize()
Initialization.
SG::WriteHandleKey< xAOD::EventShape > m_outputEventShape
StatusCode fillEventShape() const
Action.
SG::ReadHandleKey< xAOD::EventShape > m_inputEventShape
EventShapeCopier(const std::string &name)
Constructor with parameters:
std::string m_eventDensityName
Helper class to provide type-safe access to aux data.
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
Helper class to provide constant type-safe access to aux data.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
EventShape_v1 EventShape
Definition of the current event format version.
Definition EventShape.h:16
EventShapeAuxInfo_v1 EventShapeAuxInfo
Definition of the latest event shape auxiliary info version.