ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_RIO_Maker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
13
16//
17#include "GaudiKernel/ISvcLocator.h"
18
19
20
21namespace InDet {
22
24 // Constructior
27 (const std::string& name,ISvcLocator* pSvcLocator) :
28 AthReentrantAlgorithm(name,pSvcLocator),
29 m_pTRTHelper(nullptr){}
30
32 // Initialisation
35 // Get TRT_DriftCircle tool
36 ATH_CHECK(m_driftcircle_tool.retrieve());
37 ATH_CHECK(detStore()->retrieve(m_pTRTHelper,"TRT_ID"));
38 if (m_roiSeeded.value()) {
39 ATH_CHECK(m_roiCollectionKey.initialize());
40 ATH_CHECK(m_regionSelector.retrieve());
41 }else{
42 ATH_CHECK(m_roiCollectionKey.initialize(false));
43 m_regionSelector.disable();
44 }
45
46 ATH_CHECK( m_rdoContainerKey.initialize() );
47 ATH_CHECK( m_rioContainerKey.initialize() );
48 ATH_CHECK( m_rioContainerCacheKey.initialize(!m_rioContainerCacheKey.key().empty()) );
49 msg(MSG::DEBUG) << "getTRTBadChannels on or off (1/0)" <<m_trtBadChannels<< endmsg;
50 return StatusCode::SUCCESS;
51 }
52
53 //no-op destructor
55
57 // Execute
59 StatusCode TRT_RIO_Maker::execute(const EventContext& ctx) const {
60 // TRT_DriftCircle container registration
62 if(m_rioContainerCacheKey.key().empty()){
63 rioContainer = std::make_unique<InDet::TRT_DriftCircleContainer>(m_pTRTHelper->straw_layer_hash_max(),EventContainers::Mode::OfflineFast);
64 }else{
66 ATH_CHECK( rioContainer.record (std::make_unique<TRT_DriftCircleContainer>(clusterContainercache.ptr()) ));
67 }
68
69 ATH_CHECK(rioContainer.isValid());
70 ATH_MSG_DEBUG( "Container "<< rioContainer.name() << " initialised" );
72 ATH_CHECK(rdoContainer.isValid());
73
74 const bool hasExternalCache = rdoContainer->hasExternalCache();
75 std::unique_ptr<DataPool<TRT_DriftCircle>> dataItemsPool = nullptr;
76 if (!hasExternalCache) {
77 dataItemsPool = std::make_unique<DataPool<TRT_DriftCircle>>(ctx);
78 dataItemsPool->reserve(100000); // Some large default size
79 }else if(m_useDataPoolWithCache){
80 dataItemsPool = std::make_unique<DataPool<TRT_DriftCircle>>(ctx);
81 //Default size for now 1024 let it expand on its own
82 }
83
84 // Get TRT_RDO and produce TRT_RIO collections
85 if (!m_roiSeeded) {//Full-scan mode
86
87 for(const auto *const rdoCollections : *rdoContainer) {
88 const InDetRawDataCollection<TRT_RDORawData>* currentCollection(rdoCollections);
89 InDet::TRT_DriftCircleContainer::IDC_WriteHandle lock = rioContainer->getWriteHandle(currentCollection->identifyHash());
90 if (lock.OnlineAndPresentInAnotherView()) {
91 continue;
92 }
93 std::unique_ptr<TRT_DriftCircleCollection> p_rio(
95 currentCollection, ctx, dataItemsPool.get(),
97 if (p_rio && !p_rio->empty()) {
98 ATH_CHECK(lock.addOrDelete(std::move(p_rio)));
99 }
100 }
101 }else{
103 ATH_CHECK(roiCollection.isValid());
104 std::vector<IdentifierHash> listOfTRTIds;
105 for(const TrigRoiDescriptor* roi : *roiCollection){
106
107 listOfTRTIds.clear(); //Prevents needless memory reallocations
108 m_regionSelector->lookup(ctx)->HashIDList( *roi, listOfTRTIds);
109 for(auto &id : listOfTRTIds){
110 const InDetRawDataCollection<TRT_RDORawData>* RDO_Collection (rdoContainer->indexFindPtr(id));
111 if (!RDO_Collection) continue;
112 InDet::TRT_DriftCircleContainer::IDC_WriteHandle lock = rioContainer->getWriteHandle(id);
113 if( lock.OnlineAndPresentInAnotherView() ) {
114 continue;
115 }
116
117 // Use one of the specific clustering AlgTools to make clusters
118 std::unique_ptr<TRT_DriftCircleCollection> p_rio(
120 RDO_Collection, ctx, dataItemsPool.get(),
122 if (p_rio && !p_rio->empty()) {
123 ATH_CHECK(lock.addOrDelete(std::move(p_rio)));
124 }
125 }
126 }
127 }
128 ATH_MSG_DEBUG("rioContainer->numberOfCollections() " << rioContainer->numberOfCollections());
129 ATH_CHECK(rioContainer.setConst());
130 return StatusCode::SUCCESS;
131 }
132
134 // Finalize
137 return StatusCode::SUCCESS;
138 }
139}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
This is an Identifier helper class for the TRT subdetector.
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
virtual IdentifierHash identifyHash() const override final
virtual StatusCode finalize() override
BooleanProperty m_trtBadChannels
const TRT_ID * m_pTRTHelper
BooleanProperty m_useDataPoolWithCache
SG::ReadHandleKey< TRT_RDO_Container > m_rdoContainerKey
virtual StatusCode initialize() override
ToolHandle< IRegSelTool > m_regionSelector
region selector tool
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteHandleKey< InDet::TRT_DriftCircleContainer > m_rioContainerKey
SG::UpdateHandleKey< InDet::TRT_DriftCircleContainerCache > m_rioContainerCacheKey
BooleanProperty m_roiSeeded
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
IntegerProperty m_mode_rio_production
virtual ~TRT_RIO_Maker()
no-op destructor
ToolHandle< ITRT_DriftCircleTool > m_driftcircle_tool
virtual bool isValid() override final
Can the handle be successfully dereferenced?
pointer_type ptr()
Dereference the pointer.
StatusCode setConst()
Set the 'const' bit for the bound proxy in the store.
const std::string & name() const
Return the StoreGate ID for the referenced object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
Primary Vertex Finder.