ATLAS Offline Software
Loading...
Searching...
No Matches
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
9
10#include <GaudiKernel/ServiceHandle.h>
13
14HIEventShapeMaker::HIEventShapeMaker(const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator)
15{
16}
17
18
20{
21 ATH_MSG_INFO("Inside HIEventShapeMaker::initialize()");
22
23 //First we initialize keys - after initialization they are frozen
29 ATH_CHECK(m_summaryKey.initialize(!m_summaryKey.key().empty()));
30
31 // assure consistent setup of the input
33
34 //Create the HIEventShapeFillerTool
35 if (!m_summaryOnly)
36 {
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
46StatusCode HIEventShapeMaker::execute(const EventContext& ctx) const
47{
48 const xAOD::HIEventShapeContainer* evtShape_const = nullptr;
49 if (m_summaryOnly) {
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
72 ATH_CHECK( writeHandleEvtShape.record(std::move(evtShape), std::move(evtShapeAux)) );
73
74 evtShape_const = writeHandleEvtShape.cptr();
75 }
76
78
79 if (!m_summaryKey.empty())
80 {
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
95{
96 return StatusCode::SUCCESS;
97}
98
99
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
virtual StatusCode execute(const EventContext &ctx) const override
HIEventShapeMaker(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
SG::WriteHandleKey< xAOD::HIEventShapeContainer > m_summaryKey
SG::WriteHandleKey< xAOD::HIEventShapeContainer > m_outputKey
std::string PrintHIEventShapeContainer(const xAOD::HIEventShapeContainer *Container) const
virtual StatusCode initialize() override
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_towerContainerKey
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_readExistingKey
ToolHandle< IHIEventShapeFiller > m_HIEventShapeFillerTool
Gaudi::Property< bool > m_summaryOnly
virtual StatusCode finalize() override
SG::ReadHandleKey< INavigable4MomentumCollection > m_naviContainerKey
ToolHandle< IHIEventShapeSummaryTool > m_summaryTool
storage of the time histories of all the cells
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
const_pointer_type cptr() const
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
HIEventShapeContainer_v2 HIEventShapeContainer
Define the latest version of the container.
HIEventShape_v2 HIEventShape
Definition of the latest event info version.