ATLAS Offline Software
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 
15 #include "InDetIdentifier/TRT_ID.h"
16 //
17 #include "GaudiKernel/ISvcLocator.h"
18 #include "StoreGate/DataHandle.h"
19 
20 
21 
22 namespace 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());
39  if (m_roiSeeded.value()) {
41  ATH_CHECK(m_regionSelector.retrieve());
42  }else{
44  m_regionSelector.disable();
45  }
46 
47  ATH_CHECK( m_rdoContainerKey.initialize() );
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
InDet::TRT_RIO_Maker::m_driftcircle_tool
ToolHandle< ITRT_DriftCircleTool > m_driftcircle_tool
Definition: TRT_RIO_Maker.h:67
InDet::TRT_RIO_Maker::m_rioContainerKey
SG::WriteHandleKey< InDet::TRT_DriftCircleContainer > m_rioContainerKey
Definition: TRT_RIO_Maker.h:80
InDet::TRT_RIO_Maker::m_regionSelector
ToolHandle< IRegSelTool > m_regionSelector
region selector tool
Definition: TRT_RIO_Maker.h:69
InDet::TRT_RIO_Maker::m_rdoContainerKey
SG::ReadHandleKey< TRT_RDO_Container > m_rdoContainerKey
Definition: TRT_RIO_Maker.h:62
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
InDet::TRT_RIO_Maker::m_mode_rio_production
IntegerProperty m_mode_rio_production
Definition: TRT_RIO_Maker.h:72
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
InDet::TRT_RIO_Maker::~TRT_RIO_Maker
virtual ~TRT_RIO_Maker()
no-op destructor
TRT_ID::straw_layer_hash_max
size_type straw_layer_hash_max(void) const
Definition: TRT_ID.h:920
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
InDet::TRT_RIO_Maker::m_trtBadChannels
BooleanProperty m_trtBadChannels
Definition: TRT_RIO_Maker.h:73
DataHandle.h
SG::VarHandleBase::setConst
StatusCode setConst()
Set the 'const' bit for the bound proxy in the store.
Definition: StoreGate/src/VarHandleBase.cxx:606
InDet::TRT_RIO_Maker::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: TRT_RIO_Maker.cxx:60
SG::UpdateHandle::ptr
pointer_type ptr()
Dereference the pointer.
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
InDetRawDataCollection::identifyHash
virtual IdentifierHash identifyHash() const override final
IdentifiableContainerMT::hasExternalCache
virtual bool hasExternalCache() const override final
Definition: IdentifiableContainerMT.h:152
TRT_RIO_Maker.h
InDet::TRT_RIO_Maker::m_useDataPoolWithCache
BooleanProperty m_useDataPoolWithCache
Definition: TRT_RIO_Maker.h:77
InDet::TRT_RIO_Maker::m_pTRTHelper
const TRT_ID * m_pTRTHelper
Definition: TRT_RIO_Maker.h:61
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
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
InDet::TRT_RIO_Maker::m_roiCollectionKey
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
Definition: TRT_RIO_Maker.h:64
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::UpdateHandle
Definition: UpdateHandle.h:94
InDet::TRT_RIO_Maker::m_rioContainerCacheKey
SG::UpdateHandleKey< InDet::TRT_DriftCircleContainerCache > m_rioContainerCacheKey
Definition: TRT_RIO_Maker.h:83
EventContainers::Mode::OfflineFast
@ OfflineFast
IdentifiableContainerMT::indexFindPtr
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
Definition: IdentifiableContainerMT.h:289
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
InDet::TRT_RIO_Maker::initialize
virtual StatusCode initialize() override
Definition: TRT_RIO_Maker.cxx:35
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
DEBUG
#define DEBUG
Definition: page_access.h:11
InDet::TRT_RIO_Maker::finalize
virtual StatusCode finalize() override
Definition: TRT_RIO_Maker.cxx:137
AthCommonMsg< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
InDet::TRT_RIO_Maker::m_roiSeeded
BooleanProperty m_roiSeeded
Definition: TRT_RIO_Maker.h:76
InDet::TRT_RIO_Maker::TRT_RIO_Maker
TRT_RIO_Maker()=delete