ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_RIO_Maker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
13
16//
17#include "GaudiKernel/ISvcLocator.h"
19
20
21
22namespace InDet {
23
25 // Constructior
28 (const std::string& name,ISvcLocator* pSvcLocator) :
29 AthReentrantAlgorithm(name,pSvcLocator),
30 m_pTRTHelper(nullptr){}
31
33 // Initialisation
36 // Get TRT_DriftCircle tool
37 ATH_CHECK(m_driftcircle_tool.retrieve());
38 ATH_CHECK(detStore()->retrieve(m_pTRTHelper,"TRT_ID"));
39 if (m_roiSeeded.value()) {
40 ATH_CHECK(m_roiCollectionKey.initialize());
41 ATH_CHECK(m_regionSelector.retrieve());
42 }else{
43 ATH_CHECK(m_roiCollectionKey.initialize(false));
44 m_regionSelector.disable();
45 }
46
47 ATH_CHECK( m_rdoContainerKey.initialize() );
48 ATH_CHECK( m_rioContainerKey.initialize() );
49 ATH_CHECK( m_rioContainerCacheKey.initialize(!m_rioContainerCacheKey.key().empty()) );
50 msg(MSG::DEBUG) << "getTRTBadChannels on or off (1/0)" <<m_trtBadChannels<< endmsg;
51 return StatusCode::SUCCESS;
52 }
53
54 //no-op destructor
56
58 // Execute
60 StatusCode TRT_RIO_Maker::execute(const EventContext& ctx) const {
61 // TRT_DriftCircle container registration
63 if(m_rioContainerCacheKey.key().empty()){
64 rioContainer = std::make_unique<InDet::TRT_DriftCircleContainer>(m_pTRTHelper->straw_layer_hash_max(),EventContainers::Mode::OfflineFast);
65 }else{
67 ATH_CHECK( rioContainer.record (std::make_unique<TRT_DriftCircleContainer>(clusterContainercache.ptr()) ));
68 }
69
70 ATH_CHECK(rioContainer.isValid());
71 ATH_MSG_DEBUG( "Container "<< rioContainer.name() << " initialised" );
73 ATH_CHECK(rdoContainer.isValid());
74
75 const bool hasExternalCache = rdoContainer->hasExternalCache();
76 std::unique_ptr<DataPool<TRT_DriftCircle>> dataItemsPool = nullptr;
77 if (!hasExternalCache) {
78 dataItemsPool = std::make_unique<DataPool<TRT_DriftCircle>>(ctx);
79 dataItemsPool->reserve(100000); // Some large default size
80 }else if(m_useDataPoolWithCache){
81 dataItemsPool = std::make_unique<DataPool<TRT_DriftCircle>>(ctx);
82 //Default size for now 1024 let it expand on its own
83 }
84
85 // Get TRT_RDO and produce TRT_RIO collections
86 if (!m_roiSeeded) {//Full-scan mode
87
88 for(const auto *const rdoCollections : *rdoContainer) {
89 const InDetRawDataCollection<TRT_RDORawData>* currentCollection(rdoCollections);
90 InDet::TRT_DriftCircleContainer::IDC_WriteHandle lock = rioContainer->getWriteHandle(currentCollection->identifyHash());
91 if (lock.OnlineAndPresentInAnotherView()) {
92 continue;
93 }
94 std::unique_ptr<TRT_DriftCircleCollection> p_rio(
96 currentCollection, ctx, dataItemsPool.get(),
98 if (p_rio && !p_rio->empty()) {
99 ATH_CHECK(lock.addOrDelete(std::move(p_rio)));
100 }
101 }
102 }else{
104 ATH_CHECK(roiCollection.isValid());
105 std::vector<IdentifierHash> listOfTRTIds;
106 for(const TrigRoiDescriptor* roi : *roiCollection){
107
108 listOfTRTIds.clear(); //Prevents needless memory reallocations
109 m_regionSelector->lookup(ctx)->HashIDList( *roi, listOfTRTIds);
110 for(auto &id : listOfTRTIds){
111 const InDetRawDataCollection<TRT_RDORawData>* RDO_Collection (rdoContainer->indexFindPtr(id));
112 if (!RDO_Collection) continue;
113 InDet::TRT_DriftCircleContainer::IDC_WriteHandle lock = rioContainer->getWriteHandle(id);
114 if( lock.OnlineAndPresentInAnotherView() ) {
115 continue;
116 }
117
118 // Use one of the specific clustering AlgTools to make clusters
119 std::unique_ptr<TRT_DriftCircleCollection> p_rio(
121 RDO_Collection, ctx, dataItemsPool.get(),
123 if (p_rio && !p_rio->empty()) {
124 ATH_CHECK(lock.addOrDelete(std::move(p_rio)));
125 }
126 }
127 }
128 }
129 ATH_MSG_DEBUG("rioContainer->numberOfCollections() " << rioContainer->numberOfCollections());
130 ATH_CHECK(rioContainer.setConst());
131 return StatusCode::SUCCESS;
132 }
133
135 // Finalize
138 return StatusCode::SUCCESS;
139 }
140}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
defines an "iterator" over instances of a given type in StoreGateSvc
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.