ATLAS Offline Software
PixelClusterization.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
12 // Silicon trackers includes
15 
16 #include "Identifier/Identifier.h"
20 
21 #include "StoreGate/WriteHandle.h"
22 
23 
24 namespace InDet{
25  using namespace InDet;
26  // Constructor with parameters:
27  PixelClusterization::PixelClusterization(const std::string &name, ISvcLocator *pSvcLocator) :
28  AthReentrantAlgorithm(name, pSvcLocator),
29  m_idHelper(nullptr) {}
30 
31  //-----------------------------------------------------------------------------
32  // Initialize method:
34  // get the InDet::MergedPixelsTool
35  ATH_CHECK(m_clusteringTool.retrieve());
36  // get the InDet::PixelGangedAmbiguitiesFinder
38  // Get the Pixel helper
39  ATH_CHECK(detStore()->retrieve(m_idHelper,"PixelID"));
41  if (m_roiSeeded) {
43  ATH_CHECK(m_regionSelector.retrieve());
44  }else{
45  m_regionSelector.disable();
47  }
48 
50 
55 
56  if ( !m_monTool.empty() ) {
57  ATH_CHECK(m_monTool.retrieve() );
58  }
59 
60  return StatusCode::SUCCESS;
61  }
62 
63  //----------------------------------------------------------------------------
64  // Execute method:
65  StatusCode PixelClusterization::execute(const EventContext& ctx) const {
66  //Monitoring Tool Configuration
67  auto mnt_timer_Total = Monitored::Timer<std::chrono::milliseconds>("TIME_Total");
68 
69 
70 
72  if(m_clusterContainercacheKey.key().empty()){
73  ATH_CHECK( clusterContainer.record (std::make_unique<PixelClusterContainer>(m_idHelper->wafer_hash_max(), EventContainers::Mode::OfflineFast)) );
74  }else{
76  ATH_CHECK(clusterContainercache.isValid());
77  ATH_CHECK( clusterContainer.record (std::make_unique<PixelClusterContainer>(clusterContainercache.ptr() )));
78  }
79 
80  ATH_CHECK(clusterContainer.isValid());
81  ATH_MSG_DEBUG( "Container '" << clusterContainer->name() << "' initialised" );
82 
83  ATH_CHECK( clusterContainer.symLink (m_clusterContainerLinkKey) );
84  ATH_MSG_DEBUG( "Pixel clusters '" << clusterContainer.name() << "' symlinked in StoreGate");
85 
86  ATH_MSG_DEBUG( "Creating the ganged ambiguities map");
88  ambiguitiesMap = std::make_unique<PixelGangedClusterAmbiguities>();
89 
91 
92  ATH_CHECK(rdoContainer.isValid());
93 
94  ATH_MSG_DEBUG( "Data object " << rdoContainer.name() << " found" );
95 
96  std::unique_ptr<DataPool<PixelCluster>> dataItemsPool = nullptr;
97  const bool hasExternalCache = rdoContainer->hasExternalCache();
98  if (!hasExternalCache) {
99  dataItemsPool = std::make_unique<DataPool<PixelCluster>>(ctx);
100  dataItemsPool->reserve(20000); // Some large default size
101  }else if (m_useDataPoolWithCache){
102  dataItemsPool = std::make_unique<DataPool<PixelCluster>>(ctx);
103  //Default size for now 1024 let it expand on its own
104  }
105 
106 
107  if (!m_roiSeeded) {//Full-scan mode
108  PixelRDO_Container::const_iterator rdoCollections = rdoContainer->begin();
109  PixelRDO_Container::const_iterator rdoCollectionsEnd = rdoContainer->end();
110 
111  for(; rdoCollections!=rdoCollectionsEnd; ++rdoCollections){
112  const COLLECTION* RDO_Collection(*rdoCollections);
113  if (!RDO_Collection || RDO_Collection->empty()) continue;
114  PixelClusterContainer::IDC_WriteHandle lock = clusterContainer->getWriteHandle(rdoCollections.hashId());
115  if( lock.OnlineAndPresentInAnotherView() ) continue;
116 
117  // Use one of the specific clustering AlgTools to make clusters
118  std::unique_ptr<PixelClusterCollection> clusterCollection(
119  m_clusteringTool->clusterize(*RDO_Collection, *m_idHelper,
120  dataItemsPool.get(), ctx));
121 
122  if (clusterCollection && !clusterCollection->empty()){
123 
124  m_gangedAmbiguitiesFinder->execute(clusterCollection.get(),*ambiguitiesMap);
125  ATH_CHECK(lock.addOrDelete( std::move(clusterCollection) ));
126  }else{
127  ATH_MSG_DEBUG("No PixelClusterCollection to write");
128  }
129  }
130  }
131  else {//enter RoI-seeded mode
132 
134  ATH_CHECK(roiCollection.isValid());
135 
136  TrigRoiDescriptorCollection::const_iterator roi = roiCollection->begin();
137  TrigRoiDescriptorCollection::const_iterator roiE = roiCollection->end();
138 
139  std::vector<IdentifierHash> listOfPixIds;
140  for (; roi!=roiE; ++roi) {
141 
142  listOfPixIds.clear();//Prevents needless memory reallocations
143  m_regionSelector->lookup(ctx)->HashIDList( **roi, listOfPixIds );
144 
145  ATH_MSG_VERBOSE(**roi);
146  ATH_MSG_VERBOSE( "REGTEST: Pixel : Roi contains "
147  << listOfPixIds.size() << " det. Elements" );
148  for (auto & listOfPixId : listOfPixIds) {
149  const InDetRawDataCollection<PixelRDORawData>* RDO_Collection (rdoContainer->indexFindPtr(listOfPixId));
150 
151  if (!RDO_Collection) continue;
152  PixelClusterContainer::IDC_WriteHandle lock = clusterContainer->getWriteHandle(listOfPixId);
153  if( lock.OnlineAndPresentInAnotherView() ) continue;
154 
155  // Use one of the specific clustering AlgTools to make clusters
156  std::unique_ptr<PixelClusterCollection> clusterCollection(
157  m_clusteringTool->clusterize(*RDO_Collection, *m_idHelper,
158  dataItemsPool.get(), ctx));
159  if (clusterCollection && !clusterCollection->empty()) {
160  ATH_MSG_VERBOSE( "REGTEST: Pixel : clusterCollection contains "
161  << clusterCollection->size() << " clusters" );
162  m_gangedAmbiguitiesFinder->execute(clusterCollection.get(),*ambiguitiesMap);
163  ATH_CHECK(lock.addOrDelete( std::move(clusterCollection) ));
164 
165  } else {
166  ATH_MSG_DEBUG("No PixelClusterCollection to write");
167  }
168  }
169  }
170  }
171  ATH_CHECK(clusterContainer.setConst());
172  ATH_MSG_DEBUG("clusterContainer->numberOfCollections() " << clusterContainer->numberOfCollections());
173  ATH_CHECK(ambiguitiesMap.isValid());
174  ATH_MSG_DEBUG( "PixelClusterAmbiguitiesMap recorded in StoreGate");
175  auto monTime = Monitored::Group(m_monTool, mnt_timer_Total);
176  return StatusCode::SUCCESS;
177  }
178 
179 }// namespace closure
180 
181 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
InDet::PixelClusterization::m_clusteringTool
ToolHandle< IPixelClusteringTool > m_clusteringTool
Definition: PixelClusterization.h:82
InDet::PixelClusterization::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: PixelClusterization.cxx:65
InDet::PixelClusterization::m_roiCollectionKey
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
Definition: PixelClusterization.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
InDet::PixelClusterization::m_idHelper
const PixelID * m_idHelper
Definition: PixelClusterization.h:93
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
SG::WriteHandle::symLink
StatusCode symLink(const WriteHandleKey< U > &key)
Make an explicit link.
SG::UpdateHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
InDet::PixelClusterization::m_clusterContainercacheKey
SG::UpdateHandleKey< InDet::PixelClusterContainerCache > m_clusterContainercacheKey
Definition: PixelClusterization.h:104
InDet::PixelClusterization::m_regionSelector
ToolHandle< IRegSelTool > m_regionSelector
Definition: PixelClusterization.h:87
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleBase::setConst
StatusCode setConst()
Set the 'const' bit for the bound proxy in the store.
Definition: StoreGate/src/VarHandleBase.cxx:606
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
IdentifiableContainerMT::hasExternalCache
virtual bool hasExternalCache() const override final
Definition: IdentifiableContainerMT.h:152
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
WriteHandle.h
Handle class for recording to StoreGate.
PixelRDORawData.h
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::PixelClusterization::m_useDataPoolWithCache
BooleanProperty m_useDataPoolWithCache
Definition: PixelClusterization.h:107
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:239
IdentifiableContainerMT::const_iterator
Definition: IdentifiableContainerMT.h:79
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition: IdentifiableContainerMT.h:233
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::PixelClusterization::m_rdoContainerKey
SG::ReadHandleKey< PixelRDO_Container > m_rdoContainerKey
Definition: PixelClusterization.h:77
PixelClusterCollection.h
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
IdentifiableContainerMT::const_iterator::hashId
IdentifierHash hashId() const
hashId of the pointed-to element
Definition: IdentifiableContainerMT.h:127
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
InDet::PixelClusterization::m_ambiguitiesMapKey
SG::WriteHandleKey< PixelGangedClusterAmbiguities > m_ambiguitiesMapKey
Definition: PixelClusterization.h:100
SG::UpdateHandle
Definition: UpdateHandle.h:94
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:831
EventContainers::Mode::OfflineFast
@ OfflineFast
InDet::PixelClusterization::initialize
virtual StatusCode initialize() override
Definition: PixelClusterization.cxx:33
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
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::PixelClusterization::m_clusterContainerKey
SG::WriteHandleKey< PixelClusterContainer > m_clusterContainerKey
Definition: PixelClusterization.h:95
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
InDet::PixelClusterization::m_roiSeeded
BooleanProperty m_roiSeeded
Definition: PixelClusterization.h:92
InDet::PixelClusterization::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: PixelClusterization.h:89
InDet::PixelClusterization::m_clusterContainerLinkKey
SG::WriteHandleKey< SiClusterContainer > m_clusterContainerLinkKey
Definition: PixelClusterization.h:97
PixelClusterization.h
InDet::PixelClusterization::m_gangedAmbiguitiesFinder
ToolHandle< PixelGangedAmbiguitiesFinder > m_gangedAmbiguitiesFinder
class to find out which clusters shares ganged pixels
Definition: PixelClusterization.h:85
Monitored::Timer
A monitored timer.
Definition: MonitoredTimer.h:32
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
InDet::PixelClusterization::PixelClusterization
PixelClusterization()=delete