ATLAS Offline Software
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$
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 
23 using CLHEP::microsecond;
24 using CLHEP::second;
25 
26 
33  ISvcLocator* pSvcLocator)
34  : AthReentrantAlgorithm(name, pSvcLocator),
35  m_caloCellMakerTools(this),
36  m_caloCellsOutputKey(""),
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() );
58 
59  ATH_MSG_DEBUG( "Successfully retrieved CaloConstCellMakerTools: "
61 
62  ATH_MSG_INFO( " Output CaloConstCellContainer Name "
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 
77 StatusCode 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 
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloConstCellMaker::m_caloCellMakerTools
ToolHandleArray< ICaloConstCellMakerTool > m_caloCellMakerTools
Property: List of tools to run.
Definition: CaloConstCellMaker.h:59
ICaloConstCellMakerTool.h
Operate on pointers to const CaloCell.
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
python.SystemOfUnits.microsecond
int microsecond
Definition: SystemOfUnits.py:122
CaloConstCellMaker::m_chrono
ServiceHandle< IChronoStatSvc > m_chrono
For timekeeping.
Definition: CaloConstCellMaker.h:65
Chrono.h
Exception-safe IChronoSvc caller.
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
CaloConstCellMaker::execute
virtual StatusCode execute(const EventContext &ctx) const override
Standard Gaudi execute method.
Definition: CaloConstCellMaker.cxx:77
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Athena::Chrono
Exception-safe IChronoSvc caller.
Definition: Chrono.h:50
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
CaloConstCellMaker::CaloConstCellMaker
CaloConstCellMaker(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: CaloConstCellMaker.cxx:32
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
CaloConstCellMaker.h
CaloConstCellMaker::m_ownPolicy
int m_ownPolicy
Property: Will the new CellContainer will own its cells (default no)?
Definition: CaloConstCellMaker.h:56
CaloConstCellMaker::m_caloCellsOutputKey
SG::WriteHandleKey< CaloConstCellContainer > m_caloCellsOutputKey
Property: Output container key.
Definition: CaloConstCellMaker.h:62
CaloConstCellMaker::initialize
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Definition: CaloConstCellMaker.cxx:51
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
errorcheck.h
Helpers for checking error return status codes and reporting errors.
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.