ATLAS Offline Software
PadClusterizationAlg.cxx
Go to the documentation of this file.
1 
9 #include "PadClusterizationAlg.h"
10 
12 #include "StoreGate/WriteHandle.h"
14 
15 namespace HGTD {
16 
18  ISvcLocator* pSvcLocator)
19  : AthReentrantAlgorithm(name, pSvcLocator) {}
20 
22 
23  ATH_CHECK(m_clusterization_tool.retrieve());
24 
26  ATH_CHECK(m_prd_wh_key.initialize());
27 
29  ATH_CHECK(m_monTool.retrieve(EnableTool{not m_monTool.empty()}));
30 
31  return StatusCode::SUCCESS;
32 }
33 
34 StatusCode PadClusterizationAlg::execute(const EventContext& ctx) const {
35  auto timer = Monitored::Timer<std::chrono::milliseconds>( "TIME_execute" );
37 
38  // retrieve the RDOs
39  SG::ReadHandle<HGTD_RDO_Container> rdo_container_handle(m_rdo_rh_key, ctx);
40 
41  const HGTD_RDO_Container* rdo_container = rdo_container_handle.cptr();
42 
43  if (not rdo_container) {
44  //assume this is fast digi input and ignore
45  return StatusCode::SUCCESS;
46  }
47 
48  // register the PRD container in storegate
49  SG::WriteHandle<HGTD_ClusterContainer> prd_container_handle(
50  m_prd_wh_key, ctx);
51 
52  ATH_CHECK(
53  prd_container_handle.record(std::make_unique<HGTD_ClusterContainer>(
55 
56  HGTD_ClusterContainer* locp_prd_container = prd_container_handle.ptr();
57 
58  std::unique_ptr<DataPool<HGTD_Cluster>> dataItemsPool = nullptr;
59  const bool hasExternalCache = rdo_container->hasExternalCache();
60  if (!hasExternalCache) {
61  dataItemsPool = std::make_unique<DataPool<HGTD_Cluster>>(ctx);
62  dataItemsPool->reserve(10000); // Some large default size
63  }
64 
65 
66  // Transform the RDOs collection by collection
67  for (const auto rdo_collection : *rdo_container) {
68  if (rdo_collection->empty()) {
69  continue;
70  }
71 
72  std::unique_ptr<HGTD_ClusterCollection> prd_collection =
73  m_clusterization_tool->clusterize(*rdo_collection,dataItemsPool.get());
74 
75  // can happen if some channels are masked, not really relevant currently
76  if (prd_collection->empty()) {
77  continue;
78  }
79  const IdentifierHash identifyHash{prd_collection->identifyHash()};
80  if (locp_prd_container
81  ->addCollection(prd_collection.release(),identifyHash)
82  .isFailure()) {
83  ATH_MSG_WARNING("Could not add ClusterCollection to container!");
84  }
85  } // END LOOP over container
86 
87  return StatusCode::SUCCESS;
88 }
89 
90 } // namespace HGTD
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
HGTD::PadClusterizationAlg::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: PadClusterizationAlg.h:40
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
HGTD::PadClusterizationAlg::initialize
virtual StatusCode initialize() override final
Definition: PadClusterizationAlg.cxx:21
HGTD_RDO_Container
Definition: HGTD_RDO_Container.h:18
HGTD::PadClusterizationAlg::PadClusterizationAlg
PadClusterizationAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PadClusterizationAlg.cxx:17
python.utils.AtlRunQueryTimer.timer
def timer(name, disabled=False)
Definition: AtlRunQueryTimer.py:86
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
IdentifiableContainerMT::hasExternalCache
virtual bool hasExternalCache() const override final
Definition: IdentifiableContainerMT.h:155
WriteHandle.h
Handle class for recording to StoreGate.
HGTD
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
Definition: Clustering.h:28
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.
Trk::PrepRawDataCollection::identifyHash
virtual IdentifierHash identifyHash() const override final
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
HGTD::PadClusterizationAlg::m_rdo_rh_key
SG::ReadHandleKey< HGTD_RDO_Container > m_rdo_rh_key
Definition: PadClusterizationAlg.h:42
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
HGTD_ID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: HGTD_ID.cxx:832
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
Muon::IDC_Helper::addCollection
IDC::IDENTIFIABLE * addCollection(const Identifier collId, IDC *idc, const IDHELPER &idHelper, MsgStream &log)
HGTD_ID.h
PadClusterizationAlg.h
HGTD::PadClusterizationAlg::m_hgtd_idhelper
const HGTD_ID * m_hgtd_idhelper
Definition: PadClusterizationAlg.h:45
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.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::PrepRawDataContainer
Definition: PrepRawDataContainer.h:26
plotBeamSpotMon.mon
mon
Definition: plotBeamSpotMon.py:67
HGTD::PadClusterizationAlg::m_clusterization_tool
ToolHandle< IHGTD_PadClusterizationTool > m_clusterization_tool
Definition: PadClusterizationAlg.h:39
HGTD::PadClusterizationAlg::m_prd_wh_key
SG::WriteHandleKey< HGTD_ClusterContainer > m_prd_wh_key
Definition: PadClusterizationAlg.h:43
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
Monitored::Timer
A monitored timer.
Definition: MonitoredTimer.h:32
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
HGTD::PadClusterizationAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: PadClusterizationAlg.cxx:34