ATLAS Offline Software
TRT_RIO_Maker.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
16 #include "InDetIdentifier/TRT_ID.h"
17 //
18 #include "GaudiKernel/ISvcLocator.h"
19 #include "StoreGate/DataHandle.h"
20 
21 
22 
23 namespace InDet {
24 
26  // Constructior
29  (const std::string& name,ISvcLocator* pSvcLocator) :
30  AthReentrantAlgorithm(name,pSvcLocator),
31  m_pTRTHelper(nullptr),
32  m_rdoContainerKey("TRT_RDOs"),
33  m_driftcircle_tool("InDet::TRT_DriftCircleTool", this), //made private
34  m_rioContainerKey("TRT_DriftCircles"),
35  m_mode_rio_production(0),
36  m_trtBadChannels(0),
37  m_rioContainerCacheKey("")
38  {
39  // Read TRT_RIO_Maker steering parameters
40  declareProperty("TRTRDOLocation" ,m_rdoContainerKey );
41  declareProperty("ModeRIOProduction" ,m_mode_rio_production);
42  //selection of the TRT bad channels(true/false)
43  declareProperty("TRTBadChannels" ,m_trtBadChannels = true );
44  declareProperty("TRT_DriftCircleTool", m_driftcircle_tool);
45  declareProperty("TRTRIOLocation", m_rioContainerKey);
46  declareProperty("TRT_DriftCircleCache", m_rioContainerCacheKey);
47  }
48 
50  // Initialisation
53  // Get TRT_DriftCircle tool
54  ATH_CHECK(m_driftcircle_tool.retrieve());
56  if (m_roiSeeded.value()) {
58  ATH_CHECK(m_regionSelector.retrieve());
59  }else{
61  m_regionSelector.disable();
62  }
63 
64  ATH_CHECK( m_rdoContainerKey.initialize() );
67  msg(MSG::DEBUG) << "getTRTBadChannels on or off (1/0)" <<m_trtBadChannels<< endmsg;
68  return StatusCode::SUCCESS;
69  }
70 
71  //no-op destructor
73 
75  // Execute
77  StatusCode TRT_RIO_Maker::execute(const EventContext& ctx) const {
78  // TRT_DriftCircle container registration
80  if(m_rioContainerCacheKey.key().empty()){
81  rioContainer = std::make_unique<InDet::TRT_DriftCircleContainer>(m_pTRTHelper->straw_layer_hash_max(),EventContainers::Mode::OfflineFast);
82  }else{
84  ATH_CHECK( rioContainer.record (std::make_unique<TRT_DriftCircleContainer>(clusterContainercache.ptr()) ));
85  }
86 
87  ATH_CHECK(rioContainer.isValid());
88  ATH_MSG_DEBUG( "Container "<< rioContainer.name() << " initialised" );
90  ATH_CHECK(rdoContainer.isValid());
91 
92  const bool hasExternalCache = rdoContainer->hasExternalCache();
93  std::unique_ptr<DataPool<TRT_DriftCircle>> dataItemsPool = nullptr;
94  if (!hasExternalCache) {
95  dataItemsPool = std::make_unique<DataPool<TRT_DriftCircle>>(ctx);
96  dataItemsPool->reserve(100000); // Some large default size
97  }else if(m_useDataPoolWithCache){
98  dataItemsPool = std::make_unique<DataPool<TRT_DriftCircle>>(ctx);
99  //Default size for now 1024 let it expand on its own
100  }
101 
102  // Get TRT_RDO and produce TRT_RIO collections
103  if (!m_roiSeeded) {//Full-scan mode
104 
105  for(const auto *const rdoCollections : *rdoContainer) {
106  const InDetRawDataCollection<TRT_RDORawData>* currentCollection(rdoCollections);
107  InDet::TRT_DriftCircleContainer::IDC_WriteHandle lock = rioContainer->getWriteHandle(currentCollection->identifyHash());
108  if (lock.OnlineAndPresentInAnotherView()) {
109  continue;
110  }
111  std::unique_ptr<TRT_DriftCircleCollection> p_rio(
113  currentCollection, ctx, dataItemsPool.get(),
115  if (p_rio && !p_rio->empty()) {
116  ATH_CHECK(lock.addOrDelete(std::move(p_rio)));
117  }
118  }
119  }else{
121  ATH_CHECK(roiCollection.isValid());
122  std::vector<IdentifierHash> listOfTRTIds;
123  for(const TrigRoiDescriptor* roi : *roiCollection){
124 
125  listOfTRTIds.clear(); //Prevents needless memory reallocations
126  m_regionSelector->HashIDList( *roi, listOfTRTIds);
127  for(auto &id : listOfTRTIds){
128  const InDetRawDataCollection<TRT_RDORawData>* RDO_Collection (rdoContainer->indexFindPtr(id));
129  if (!RDO_Collection) continue;
130  InDet::TRT_DriftCircleContainer::IDC_WriteHandle lock = rioContainer->getWriteHandle(id);
131  if( lock.OnlineAndPresentInAnotherView() ) {
132  continue;
133  }
134 
135  // Use one of the specific clustering AlgTools to make clusters
136  std::unique_ptr<TRT_DriftCircleCollection> p_rio(
138  RDO_Collection, ctx, dataItemsPool.get(),
140  if (p_rio && !p_rio->empty()) {
141  ATH_CHECK(lock.addOrDelete(std::move(p_rio)));
142  }
143  }
144  }
145  }
146  ATH_MSG_DEBUG("rioContainer->numberOfCollections() " << rioContainer->numberOfCollections());
147  ATH_CHECK(rioContainer.setConst());
148  return StatusCode::SUCCESS;
149  }
150 
152  // Finalize
155  return StatusCode::SUCCESS;
156  }
157 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
InDet::TRT_RIO_Maker::m_rioContainerKey
SG::WriteHandleKey< InDet::TRT_DriftCircleContainer > m_rioContainerKey
Definition: TRT_RIO_Maker.h:68
InDet::TRT_RIO_Maker::m_regionSelector
ToolHandle< IRegSelTool > m_regionSelector
region selector tool
Definition: TRT_RIO_Maker.h:77
InDet::TRT_RIO_Maker::m_rdoContainerKey
SG::ReadHandleKey< TRT_RDO_Container > m_rdoContainerKey
Definition: TRT_RIO_Maker.h:66
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
InDet
DUMMY 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
ITRT_DriftCircleTool.h
DataHandle.h
SG::VarHandleBase::setConst
StatusCode setConst()
Set the 'const' bit for the bound proxy in the store.
Definition: StoreGate/src/VarHandleBase.cxx:599
InDet::TRT_RIO_Maker::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: TRT_RIO_Maker.cxx:77
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:155
InDet::TRT_RIO_Maker::m_mode_rio_production
int m_mode_rio_production
Definition: TRT_RIO_Maker.h:69
TRT_RIO_Maker.h
InDet::TRT_RIO_Maker::m_pTRTHelper
const TRT_ID * m_pTRTHelper
Definition: TRT_RIO_Maker.h:65
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
InDet::TRT_RIO_Maker::m_useDataPoolWithCache
Gaudi::Property< bool > m_useDataPoolWithCache
Definition: TRT_RIO_Maker.h:74
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDet::TRT_RIO_Maker::m_trtBadChannels
bool m_trtBadChannels
Definition: TRT_RIO_Maker.h:70
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:72
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:195
SG::UpdateHandle
Definition: UpdateHandle.h:94
InDet::TRT_RIO_Maker::m_rioContainerCacheKey
SG::UpdateHandleKey< InDet::TRT_DriftCircleContainerCache > m_rioContainerCacheKey
Definition: TRT_RIO_Maker.h:78
EventContainers::Mode::OfflineFast
@ OfflineFast
InDet::TRT_RIO_Maker::m_driftcircle_tool
ToolHandle< ITRT_DriftCircleTool > m_driftcircle_tool
Definition: TRT_RIO_Maker.h:67
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:292
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
InDet::TRT_RIO_Maker::initialize
virtual StatusCode initialize() override
Definition: TRT_RIO_Maker.cxx:52
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:154
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:73
InDet::TRT_RIO_Maker::TRT_RIO_Maker
TRT_RIO_Maker()=delete