ATLAS Offline Software
Loading...
Searching...
No Matches
CaloConstCellMaker.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// $Id$
12
13
14#include "CaloConstCellMaker.h"
15
16#include "AthenaKernel/Chrono.h"
18#include "GaudiKernel/IChronoStatSvc.h"
19#include "CLHEP/Units/SystemOfUnits.h"
20#include <memory>
21
22using CLHEP::microsecond;
23using CLHEP::second;
24
25
32 ISvcLocator* pSvcLocator)
33 : AthReentrantAlgorithm(name, pSvcLocator),
34 m_chrono("ChronoStatSvc", name)
35{
36}
37
38
43{
44 ATH_CHECK( m_chrono.retrieve() );
45
46 // access tools and store them
47 ATH_CHECK( m_caloCellMakerTools.retrieve() );
48 ATH_CHECK( m_caloCellsOutputKey.initialize());
49
50 ATH_MSG_DEBUG( "Successfully retrieved CaloConstCellMakerTools: "
52
53 ATH_MSG_INFO( " Output CaloConstCellContainer Name "
54 << m_caloCellsOutputKey.key() );
56 ATH_MSG_INFO( "...will OWN its cells." );
57 } else {
58 ATH_MSG_INFO( "...will VIEW its cells." );
59 }
60
61 return StatusCode::SUCCESS;
62}
63
64
68StatusCode CaloConstCellMaker::execute (const EventContext& ctx) const
69{
70 // Create empty container.
71
73 ATH_CHECK( theContainer.record (std::make_unique<CaloConstCellContainer>(static_cast<SG::OwnershipPolicy>(m_ownPolicy.value()))) );
74
75 // Loop on tools.
76 // Note that finalization and checks are also done with tools.
77 for (const auto & tool : m_caloCellMakerTools) {
78 // For performance reasons want to remove the cell-checker tool
79 // from the list of tools after the fifth event.
80 if (ctx.evt() > 5) {
81 if (tool.typeAndName() == "CaloCellContainerCheckerTool/CaloCellContainerCheckerTool")
82 continue;
83 }
84
85 ATH_MSG_DEBUG( "Calling tool " << tool.name() );
86
87 std::string chronoName = this->name() + "_" + tool.name();
88
89 StatusCode sc;
90 sc.ignore();
91 {
92 Athena::Chrono give_me_a_name (chronoName, &*m_chrono);
93 sc = tool->process(theContainer.ptr(), ctx);
94 }
95
96 ATH_MSG_DEBUG( "Chrono stop : delta "
97 << m_chrono->chronoDelta(chronoName, IChronoStatSvc::USER) * (microsecond / second)
98 << " second " );
99
100 if (sc.isFailure()) {
101 ATH_MSG_ERROR( "Error executing tool " << tool.name() );
102 }
103 }
104
105
106 return StatusCode::SUCCESS;
107}
108
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
Exception-safe IChronoSvc caller.
Helpers for checking error return status codes and reporting errors.
static Double_t sc
An algorithm that can be simultaneously executed in multiple threads.
Exception-safe IChronoSvc caller.
Definition Chrono.h:50
CaloConstCellMaker(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
ServiceHandle< IChronoStatSvc > m_chrono
For timekeeping.
ToolHandleArray< ICaloConstCellMakerTool > m_caloCellMakerTools
Property: List of tools to run.
virtual StatusCode initialize() override
Standard Gaudi initialize method.
virtual StatusCode execute(const EventContext &ctx) const override
Standard Gaudi execute method.
SG::WriteHandleKey< CaloConstCellContainer > m_caloCellsOutputKey
Property: Output container key.
Gaudi::Property< int > m_ownPolicy
Property: Will the new CellContainer will own its cells (default no)?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
OwnershipPolicy
@ OWN_ELEMENTS
this data object owns its elements