ATLAS Offline Software
CaloCellMaker.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /********************************************************************
6 
7 
8  NAME: CaloCellMaker.h
9  PACKAGE: offline/Calorimeter/CaloRec
10 
11  AUTHORS: David Rousseau
12  CREATED: May 11, 2004
13 
14  PURPOSE: Create a CaloCellContainer by calling a set of tools
15  sharing interface CaloInterface/ICaloCellMakerTool.h
16  FIXME : should see how Chronostat and MemStat report could still be obtained
17  ********************************************************************/
18 
19 // Gaudi includes
20 #include "GaudiKernel/IChronoStatSvc.h"
21 
22 // Athena includes
24 #include "StoreGate/WriteHandle.h"
25 
26 // Calo includes
27 #include "CaloCellMaker.h"
29 #include "CaloEvent/CaloCell.h"
31 
32 #include "CLHEP/Units/SystemOfUnits.h"
33 
34 using CLHEP::microsecond;
35 using CLHEP::second;
36 
37 
39 
40  // Retrieve ChronoStatSvc
41  if (m_doChronoStat) {
42  ATH_CHECK( m_chrono.retrieve() );
43  }
44 
45  // access tools and store them
46  CHECK( m_caloCellMakerTools.retrieve() );
47  ATH_MSG_DEBUG( "Successfully retrieve CaloCellMakerTools: " << m_caloCellMakerTools );
48 
50 
52 
53  ATH_MSG_INFO( " Output CaloCellContainer Name " << m_caloCellsOutputKey.key() );
55  ATH_MSG_INFO( "...will OWN its cells." );
56  } else {
57  ATH_MSG_INFO( "...will VIEW its cells." );
58  }
59  return StatusCode::SUCCESS;
60 
61 }
62 
63 StatusCode CaloCellMaker::execute (const EventContext& ctx) const {
64 
66 
67  ATH_CHECK( caloCellsOutput.record(std::make_unique<CaloCellContainer>(static_cast<SG::OwnershipPolicy>(m_ownPolicy))) );
68 
69  // loop on tools
70  // note that finalization and checks are also done with tools
71  for (const ToolHandle<ICaloCellMakerTool>& tool : m_caloCellMakerTools) {
72  ATH_MSG_DEBUG( "Calling tool " << tool.name() );
73 
74  std::string chronoName = this->name() + "_" + tool.name();
75 
76  if(m_doChronoStat) {
77  m_chrono->chronoStart(chronoName);
78  }
79  StatusCode sc = tool->process(caloCellsOutput.ptr(), ctx);
80  if(m_doChronoStat) {
81  m_chrono->chronoStop(chronoName);
82 
83  ATH_MSG_DEBUG( "Chrono stop : delta " << m_chrono->chronoDelta(chronoName, IChronoStatSvc::USER) * (microsecond / second) << " second " );
84  }
85 
86  if (sc.isFailure()) {
87  ATH_MSG_ERROR( "Error executing tool " << tool.name() );
88  }
89  }
90 
91  return StatusCode::SUCCESS;
92 }
93 
95 
96  return StatusCode::SUCCESS;
97 
98 }
99 
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
python.SystemOfUnits.microsecond
int microsecond
Definition: SystemOfUnits.py:122
CaloCell.h
CaloCellMaker::m_ownPolicy
SG::OwnershipPolicy m_ownPolicy
Definition: CaloCellMaker.h:54
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
CaloCellMaker::initialize
virtual StatusCode initialize() override
Definition: CaloCellMaker.cxx:38
CaloCellMaker::m_ownPolicyProp
Gaudi::Property< bool > m_ownPolicyProp
Definition: CaloCellMaker.h:53
WriteHandle.h
Handle class for recording to StoreGate.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
CaloCellMaker::m_chrono
ServiceHandle< IChronoStatSvc > m_chrono
ChronoStatSvc.
Definition: CaloCellMaker.h:49
CaloCellMaker::m_caloCellsOutputKey
SG::WriteHandleKey< CaloCellContainer > m_caloCellsOutputKey
Output cell continer to be used.
Definition: CaloCellMaker.h:57
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
CaloCellMaker::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: CaloCellMaker.cxx:63
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
errorcheck.h
Helpers for checking error return status codes and reporting errors.
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
CaloCellContainer.h
ICaloCellMakerTool.h
SG::WriteHandle< CaloCellContainer >
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
CaloCellMaker::m_doChronoStat
Gaudi::Property< bool > m_doChronoStat
Definition: CaloCellMaker.h:50
CaloCellMaker.h
CaloCellMaker::finalize
virtual StatusCode finalize() override
Definition: CaloCellMaker.cxx:94
CaloCellMaker::m_caloCellMakerTools
ToolHandleArray< ICaloCellMakerTool > m_caloCellMakerTools
Array of CellMaker (and corrector) AlgTools.
Definition: CaloCellMaker.h:60