ATLAS Offline Software
Loading...
Searching...
No Matches
CaloConstCellMaker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id$
12
13
14#include "CaloConstCellMaker.h"
16
17#include "AthenaKernel/Chrono.h"
19#include "GaudiKernel/IChronoStatSvc.h"
20#include "CLHEP/Units/SystemOfUnits.h"
21#include <memory>
22
23using CLHEP::microsecond;
24using CLHEP::second;
25
26
33 ISvcLocator* pSvcLocator)
34 : AthReentrantAlgorithm(name, pSvcLocator),
37 m_chrono("ChronoStatSvc", name)
38{
39 declareProperty("OwnPolicy", m_ownPolicy = static_cast<int>(SG::VIEW_ELEMENTS),
40 "Will the new container own its cells? Default is no.");
41 declareProperty("CaloCellMakerTools", m_caloCellMakerTools,
42 "List of tools to run.");
43 declareProperty("CaloCellsOutputName", m_caloCellsOutputKey,
44 "Output container name.");
45}
46
47
52{
53 ATH_CHECK( m_chrono.retrieve() );
54
55 // access tools and store them
56 ATH_CHECK( m_caloCellMakerTools.retrieve() );
57 ATH_CHECK( m_caloCellsOutputKey.initialize());
58
59 ATH_MSG_DEBUG( "Successfully retrieved CaloConstCellMakerTools: "
61
62 ATH_MSG_INFO( " Output CaloConstCellContainer Name "
63 << m_caloCellsOutputKey.key() );
65 ATH_MSG_INFO( "...will OWN its cells." );
66 } else {
67 ATH_MSG_INFO( "...will VIEW its cells." );
68 }
69
70 return StatusCode::SUCCESS;
71}
72
73
77StatusCode CaloConstCellMaker::execute (const EventContext& ctx) const
78{
79 // Create empty container.
80
82 ATH_CHECK( theContainer.record (std::make_unique<CaloConstCellContainer>(static_cast<SG::OwnershipPolicy>(m_ownPolicy))) );
83
84 // Loop on tools.
85 // Note that finalization and checks are also done with tools.
86 for (const auto & tool : m_caloCellMakerTools) {
87 // For performance reasons want to remove the cell-checker tool
88 // from the list of tools after the fifth event.
89 if (ctx.evt() > 5) {
90 if (tool.typeAndName() == "CaloCellContainerCheckerTool/CaloCellContainerCheckerTool")
91 continue;
92 }
93
94 ATH_MSG_DEBUG( "Calling tool " << tool.name() );
95
96 std::string chronoName = this->name() + "_" + tool.name();
97
98 StatusCode sc;
99 sc.ignore();
100 {
101 Athena::Chrono give_me_a_name (chronoName, &*m_chrono);
102 sc = tool->process(theContainer.ptr(), ctx);
103 }
104
105 ATH_MSG_DEBUG( "Chrono stop : delta "
106 << m_chrono->chronoDelta(chronoName, IChronoStatSvc::USER) * (microsecond / second)
107 << " second " );
108
109 if (sc.isFailure()) {
110 ATH_MSG_ERROR( "Error executing tool " << tool.name() );
111 }
112 }
113
114
115 return StatusCode::SUCCESS;
116}
117
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Exception-safe IChronoSvc caller.
Helpers for checking error return status codes and reporting errors.
Operate on pointers to const CaloCell.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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.
int m_ownPolicy
Property: Will the new CellContainer will own its cells (default no)?
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.
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
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts