ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
11
12// Silicon trackers includes
15
16#include "Identifier/Identifier.h"
20
22
23
24namespace 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"));
40 ATH_CHECK( m_rdoContainerKey.initialize() );
41 if (m_roiSeeded) {
42 ATH_CHECK( m_roiCollectionKey.initialize() );
43 ATH_CHECK(m_regionSelector.retrieve());
44 }else{
45 m_regionSelector.disable();
46 ATH_CHECK( m_roiCollectionKey.initialize(false) );
47 }
48
50
51 ATH_CHECK( m_clusterContainerKey.initialize() );
53 ATH_CHECK( m_ambiguitiesMapKey.initialize() );
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
(c) ATLAS Detector software
This is an Identifier helper class for the Pixel subdetector.
Handle class for recording to StoreGate.
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
bool empty() const noexcept
IdentifierHash hashId() const
hashId of the pointed-to element
SG::WriteHandleKey< PixelClusterContainer > m_clusterContainerKey
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
SG::ReadHandleKey< PixelRDO_Container > m_rdoContainerKey
ToolHandle< GenericMonitoringTool > m_monTool
virtual StatusCode execute(const EventContext &ctx) const override
ToolHandle< IPixelClusteringTool > m_clusteringTool
SG::WriteHandleKey< SiClusterContainer > m_clusterContainerLinkKey
ToolHandle< PixelGangedAmbiguitiesFinder > m_gangedAmbiguitiesFinder
class to find out which clusters shares ganged pixels
virtual StatusCode initialize() override
InDetRawDataCollection< PixelRDORawData > COLLECTION
SG::WriteHandleKey< PixelGangedClusterAmbiguities > m_ambiguitiesMapKey
SG::UpdateHandleKey< InDet::PixelClusterContainerCache > m_clusterContainercacheKey
ToolHandle< IRegSelTool > m_regionSelector
Group of local monitoring quantities and retain correlation when filling histograms
A monitored timer.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
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 symLink(const WriteHandleKey< U > &key)
Make an explicit link.
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?
Primary Vertex Finder.