ATLAS Offline Software
Loading...
Searching...
No Matches
AFPSiClusterTool Class Reference

This class reconstructs clusters of pixels. More...

#include <AFPSiClusterTool.h>

Inheritance diagram for AFPSiClusterTool:
Collaboration diagram for AFPSiClusterTool:

Public Member Functions

 AFPSiClusterTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~AFPSiClusterTool () override
virtual StatusCode initialize () override
virtual StatusCode finalize () override
 does nothing
StatusCode clusterHits (std::unique_ptr< xAOD::AFPSiHitsClusterContainer > &clustr, const EventContext &ctx) const override
 Run clusters reconstruction.

Private Member Functions

StatusCode clearAllLayers (std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers) const
 Runs AFPSiClusterLayerBasicObj::clearHitsAndClusters() on all layers in #my_layers.
StatusCode fillLayersWithHits (std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers, const EventContext &ctx) const
 Reads hits from StoreGate and saves them to appropriate layers in #my_layers.
StatusCode clusterEachLayer (std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers) const
 Runs tool reconstructing clusters on each layer.
StatusCode saveToXAOD (std::unique_ptr< xAOD::AFPSiHitsClusterContainer > &clustr, std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers, const EventContext &ctx) const
 Save clusters in xAOD::AFPSiHitsClusterContainer.
std::vector< std::vector< AFPSiClusterLayerBasicObj > > initLayers (const std::vector< int > &layersInStations) const
 Initialise size as well as station and layer ID for #my_layers.

Private Attributes

SG::ReadHandleKey< xAOD::AFPSiHitContainerm_AFPSiHitContainerKey { this, "AFPSiHitsContainerName", "AFPSiHitContainer", "name of AFPSiHit container" }
ToolHandle< IAFPSiClusterAlgToolm_clusterAlgToolHandle {this,"clusterAlgTool", "AFPSiClusterAlgTool","Tool with algorithm to perform actual clustering"}
 Tool that does the clustering on hits.
ToolHandle< IAFPSiRowColToLocalCSToolm_rowColToLocalCSToolHandle {this,"rowColToLocalCSTool", "AFPSiRowColToLocalCSTool","Tool to rewrite clusters to xAOD and transform rows and columns to station local coordinates"}
 Tool that creates xAOD and transforms rows and pixels to local coordinate system.
ToolHandle< GenericMonitoringToolm_monTool {this, "MonTool", "", "Monitoring tool"}
 @ brief Monitoring tool
ToolHandle< AFP::ISiLocAlignDBToolm_siLocAlignDBTool {this, "siLocAlignDBTool", "AFP__SiLocAlignDBTool", "Tool to access DB to get the local alignment constants"}
 @ brief Tool for accessing DB to get the local alignment constants
ToolHandle< AFP::ISiGlobAlignDBToolm_siGlobAlignDBTool {this, "siGlobAlignDBTool", "AFP__SiGlobAlignDBTool", "Tool to access DB to get the global alignment constants"}
 @ brief Tool for accessing DB to get the global alignment constants
Gaudi::Property< std::vector< int > > m_numberOfLayersInStations {this, "numberOfLayersInStations",{4,4,4,4}, "The size of the array in argument defines number of stations, the value in each entry defines number of layers in the station."}
 Array defining number of stations and layers in each station.

Detailed Description

This class reconstructs clusters of pixels.

The clustering algorithm is defined in a tool that is used and can be changed.

Definition at line 53 of file AFPSiClusterTool.h.

Constructor & Destructor Documentation

◆ AFPSiClusterTool()

AFPSiClusterTool::AFPSiClusterTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 18 of file AFPSiClusterTool.cxx.

21 : base_class(type, name, parent)
22{
23}

◆ ~AFPSiClusterTool()

virtual AFPSiClusterTool::~AFPSiClusterTool ( )
inlineoverridevirtual

Definition at line 59 of file AFPSiClusterTool.h.

59{}

Member Function Documentation

◆ clearAllLayers()

StatusCode AFPSiClusterTool::clearAllLayers ( std::vector< std::vector< AFPSiClusterLayerBasicObj > > & my_layers) const
private

Runs AFPSiClusterLayerBasicObj::clearHitsAndClusters() on all layers in #my_layers.

Definition at line 109 of file AFPSiClusterTool.cxx.

110{
111 for (std::vector<AFPSiClusterLayerBasicObj>& station : my_layers)
112 for (AFPSiClusterLayerBasicObj& layer : station)
113 layer.clearHitsAndClusters();
114
115 return StatusCode::SUCCESS;
116}
@ layer
Definition HitInfo.h:79

◆ clusterEachLayer()

StatusCode AFPSiClusterTool::clusterEachLayer ( std::vector< std::vector< AFPSiClusterLayerBasicObj > > & my_layers) const
private

Runs tool reconstructing clusters on each layer.

Definition at line 155 of file AFPSiClusterTool.cxx.

156{
157 for (std::vector<AFPSiClusterLayerBasicObj>& station : my_layers)
158 for (AFPSiClusterLayerBasicObj& layer : station)
159 m_clusterAlgToolHandle->doClustering(layer.hits(), layer.clusters()).ignore();
160
161 return StatusCode::SUCCESS;
162}
ToolHandle< IAFPSiClusterAlgTool > m_clusterAlgToolHandle
Tool that does the clustering on hits.

◆ clusterHits()

StatusCode AFPSiClusterTool::clusterHits ( std::unique_ptr< xAOD::AFPSiHitsClusterContainer > & clustr,
const EventContext & ctx ) const
override

Run clusters reconstruction.

This method does full reconstruction from xAOD hits to xAOD clusters. It reads silicon detector hits from StoreGate, runs clustering algorithm, assigns clusters positions in station local coordinate system and saves them in xAOD format to StoreGate.

Definition at line 75 of file AFPSiClusterTool.cxx.

76{
77 std::vector< std::vector<AFPSiClusterLayerBasicObj> > my_layers=initLayers(m_numberOfLayersInStations);
78
79 if(clearAllLayers(my_layers).isFailure())
80 {
81 ATH_MSG_WARNING("clearAllLayers failed");
82 return StatusCode::FAILURE;
83 }
84
85 if(fillLayersWithHits(my_layers, ctx).isFailure())
86 {
87 ATH_MSG_WARNING("fillLayersWithHits failed");
88 return StatusCode::FAILURE;
89 }
90
91 if(clusterEachLayer(my_layers).isFailure())
92 {
93 ATH_MSG_WARNING("clusterEachLayer failed");
94 return StatusCode::FAILURE;
95 }
96
97 if(saveToXAOD(clustr, my_layers, ctx).isFailure())
98 {
99 ATH_MSG_WARNING("saveToXAOD failed");
100 return StatusCode::FAILURE;
101 }
102
103 auto clusterSize = Monitored::Scalar("ClusterSize", clustr->size());
104 Monitored::Group( m_monTool, clusterSize);
105
106 return StatusCode::SUCCESS;
107}
#define ATH_MSG_WARNING(x)
StatusCode clusterEachLayer(std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers) const
Runs tool reconstructing clusters on each layer.
std::vector< std::vector< AFPSiClusterLayerBasicObj > > initLayers(const std::vector< int > &layersInStations) const
Initialise size as well as station and layer ID for my_layers.
StatusCode fillLayersWithHits(std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers, const EventContext &ctx) const
Reads hits from StoreGate and saves them to appropriate layers in my_layers.
ToolHandle< GenericMonitoringTool > m_monTool
@ brief Monitoring tool
Gaudi::Property< std::vector< int > > m_numberOfLayersInStations
Array defining number of stations and layers in each station.
StatusCode saveToXAOD(std::unique_ptr< xAOD::AFPSiHitsClusterContainer > &clustr, std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers, const EventContext &ctx) const
Save clusters in xAOD::AFPSiHitsClusterContainer.
StatusCode clearAllLayers(std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers) const
Runs AFPSiClusterLayerBasicObj::clearHitsAndClusters() on all layers in my_layers.

◆ fillLayersWithHits()

StatusCode AFPSiClusterTool::fillLayersWithHits ( std::vector< std::vector< AFPSiClusterLayerBasicObj > > & my_layers,
const EventContext & ctx ) const
private

Reads hits from StoreGate and saves them to appropriate layers in #my_layers.

Definition at line 118 of file AFPSiClusterTool.cxx.

119{
120 // retrieve hits
121 if (m_AFPSiHitContainerKey.empty()) {
122 ATH_MSG_DEBUG("AFPSiClusterTool, no input siHitContainer");
123 // this is allowed, there might be no AFP data in the input
124 return StatusCode::SUCCESS;
125 }
126
127 SG::ReadHandle<xAOD::AFPSiHitContainer> siHitContainer( m_AFPSiHitContainerKey, ctx );
128 if(!siHitContainer.isValid()) {
129 ATH_MSG_WARNING("AFPSiClusterTool failed to retrieve siHitContainer, "<<m_AFPSiHitContainerKey<<", exiting gracefully");
130 // unexpected absence of Si hits ?
131 return StatusCode::SUCCESS;
132 }
133 else
134 {
135 ATH_MSG_DEBUG("AFPSiClusterTool::fillLayersWithHits(), successfully got siHitContainer, there are "<<siHitContainer->size()<<" hits");
136
137 auto hitsSize = Monitored::Scalar("HitsSize", siHitContainer->size());
138 Monitored::Group( m_monTool, hitsSize);
139
140 try {
141 // fill layers with hits
142 for(const auto *const theHit : *siHitContainer)
143 my_layers.at(theHit->stationID()).at(theHit->pixelLayerID()).hits().push_back(theHit);
144 }
145 catch (const std::out_of_range& outOfRange) {
146 ATH_MSG_WARNING("Hit with station or pixel ID outside expected range. Aborting pixels clustering.");
147 clearAllLayers(my_layers).ignore();
148 return StatusCode::FAILURE;
149 }
150 }
151
152 return StatusCode::SUCCESS;
153}
#define ATH_MSG_DEBUG(x)
SG::ReadHandleKey< xAOD::AFPSiHitContainer > m_AFPSiHitContainerKey

◆ finalize()

StatusCode AFPSiClusterTool::finalize ( )
overridevirtual

does nothing

Definition at line 70 of file AFPSiClusterTool.cxx.

71{
72 return StatusCode::SUCCESS;
73}

◆ initialize()

StatusCode AFPSiClusterTool::initialize ( )
overridevirtual

Definition at line 49 of file AFPSiClusterTool.cxx.

50{
51 ATH_MSG_DEBUG("Initializing " << name() << "...");
52
54
55 // retrieve tools
56 CHECK( m_clusterAlgToolHandle.retrieve() );
58 CHECK( m_siLocAlignDBTool.retrieve() );
59 CHECK( m_siGlobAlignDBTool.retrieve() );
60
61 // monitoring
62 if (!(m_monTool.name().empty())) {
63 CHECK( m_monTool.retrieve() );
64 ATH_MSG_DEBUG("m_monTool name: " << m_monTool);
65 }
66
67 return StatusCode::SUCCESS;
68}
#define CHECK(...)
Evaluate an expression and check for errors.
ToolHandle< IAFPSiRowColToLocalCSTool > m_rowColToLocalCSToolHandle
Tool that creates xAOD and transforms rows and pixels to local coordinate system.
ToolHandle< AFP::ISiLocAlignDBTool > m_siLocAlignDBTool
@ brief Tool for accessing DB to get the local alignment constants
ToolHandle< AFP::ISiGlobAlignDBTool > m_siGlobAlignDBTool
@ brief Tool for accessing DB to get the global alignment constants

◆ initLayers()

std::vector< std::vector< AFPSiClusterLayerBasicObj > > AFPSiClusterTool::initLayers ( const std::vector< int > & layersInStations) const
private

Initialise size as well as station and layer ID for #my_layers.

The size of the array in argument defines number of stations, the value in each entry defines number of layers in the station.

Definition at line 25 of file AFPSiClusterTool.cxx.

26{
27 // set number of stations
28 std::vector< std::vector<AFPSiClusterLayerBasicObj> > my_layers;
29 my_layers.resize(layersInStations.size());
30
31 // initialise number of layers in each station
32 int stationID = 0;
33 std::vector<std::vector<AFPSiClusterLayerBasicObj> >::iterator layersIter = my_layers.begin();
34 for (const int layersN : layersInStations) {
35 int layerID = 0;
36 std::vector<AFPSiClusterLayerBasicObj>& layersVec = (*layersIter++);
37 layersVec.resize(layersN);
38 // set station and layer ID numbers
39 for (AFPSiClusterLayerBasicObj& theLayer : layersVec) {
40 theLayer.setStationID(stationID);
41 theLayer.setLayerID(layerID++);
42 }
43 stationID++;
44 } // close for over layersN
45
46 return my_layers;
47}
constexpr uint8_t stationID
Large or Small wedge.

◆ saveToXAOD()

StatusCode AFPSiClusterTool::saveToXAOD ( std::unique_ptr< xAOD::AFPSiHitsClusterContainer > & clustr,
std::vector< std::vector< AFPSiClusterLayerBasicObj > > & my_layers,
const EventContext & ctx ) const
private

Save clusters in xAOD::AFPSiHitsClusterContainer.

Calls m_rowColToLocalCSToolHandle on each reconstructed cluster in each layer. The tool calculates cluster coordinates based on row and column information and creates new xAOD::AFPSiHitsCluster object, which is added to the container.

Definition at line 164 of file AFPSiClusterTool.cxx.

165{
166
167 if (m_AFPSiHitContainerKey.empty()) {
168 // this is allowed, there might be no AFP data in the input
169 return StatusCode::SUCCESS;
170 }
171
172 SG::ReadHandle<xAOD::AFPSiHitContainer> siHitContainer( m_AFPSiHitContainerKey, ctx );
173 if(!siHitContainer.isValid())
174 {
175 // this is allowed, there might be no AFP data in the input
176 return StatusCode::SUCCESS;
177 }
178
179 // fill xAOD container
180
181 nlohmann::json dataLA, dataGA;
182 bool dataLA_init{false}, dataGA_init{false};
183
184 for (std::vector<AFPSiClusterLayerBasicObj>& station : my_layers)
185 for (AFPSiClusterLayerBasicObj& layer : station) {
186 if(layer.clusters().empty()) continue;
187
188 const int stationID = layer.stationID();
189 const int layerID = layer.layerID();
190
191 if(!dataLA_init)
192 {
193 // read from DB only if necessary
194 dataLA=m_siLocAlignDBTool->alignmentData(ctx);
195 dataLA_init=true;
196 }
197 if(!dataGA_init)
198 {
199 // read from DB only if necessary
200 dataGA=m_siGlobAlignDBTool->alignmentData(ctx);
201 dataGA_init=true;
202 }
203
204 const AFP::SiLocAlignData LA=m_siLocAlignDBTool->alignment(dataLA, stationID, layerID);
205 const AFP::SiGlobAlignData GA=m_siGlobAlignDBTool->alignment(dataGA, stationID);
206
207 for (const AFPSiClusterBasicObj& theCluster : layer.clusters()) {
208 // create xAOD object and set cluster coordinates and errors
209 xAOD::AFPSiHitsCluster* xAODCluster = m_rowColToLocalCSToolHandle->newXAODLocal(stationID, layerID, LA, GA, theCluster, clusterContainer);
210
211 ATH_MSG_DEBUG("have xAODCluster: pixelLayerID "<<xAODCluster->pixelLayerID()<<", xLocal "<<xAODCluster->xLocal()<<", yLocal "<<xAODCluster->yLocal()<<", zLocal "<<xAODCluster->zLocal()<<", nHits "<<xAODCluster->nHits());
212
213 // add links to hits
214 for (const xAOD::AFPSiHit* theHit : theCluster.hits()) {
215 ElementLink< xAOD::AFPSiHitContainer > hitLink;
216 hitLink.toContainedElement(*siHitContainer, theHit);
217 xAODCluster->addHitLink(hitLink);
218 }
219 } // end for over layers
220 } // end for over stations
221
222 return StatusCode::SUCCESS;
223}
void addHitLink(const AFPHitLink_t &newHit)
Add a link to a pixel in this cluster.
int pixelLayerID() const
Index of the silicon layer with the cluster.
int nHits() const
Number of fired pixels (hits) in cluster.
float zLocal() const
Cluster position along Z axis in station local coordinate system.
float xLocal() const
Cluster position along X axis in station local coordinate system.
float yLocal() const
Cluster position along Y axis in station local coordinate system.
AFPSiHit_v2 AFPSiHit
Definition AFPSiHit.h:12
AFPSiHitsCluster_v1 AFPSiHitsCluster

Member Data Documentation

◆ m_AFPSiHitContainerKey

SG::ReadHandleKey<xAOD::AFPSiHitContainer> AFPSiClusterTool::m_AFPSiHitContainerKey { this, "AFPSiHitsContainerName", "AFPSiHitContainer", "name of AFPSiHit container" }
private

Definition at line 71 of file AFPSiClusterTool.h.

71{ this, "AFPSiHitsContainerName", "AFPSiHitContainer", "name of AFPSiHit container" };

◆ m_clusterAlgToolHandle

ToolHandle<IAFPSiClusterAlgTool> AFPSiClusterTool::m_clusterAlgToolHandle {this,"clusterAlgTool", "AFPSiClusterAlgTool","Tool with algorithm to perform actual clustering"}
private

Tool that does the clustering on hits.

Definition at line 74 of file AFPSiClusterTool.h.

74{this,"clusterAlgTool", "AFPSiClusterAlgTool","Tool with algorithm to perform actual clustering"};

◆ m_monTool

ToolHandle<GenericMonitoringTool> AFPSiClusterTool::m_monTool {this, "MonTool", "", "Monitoring tool"}
private

@ brief Monitoring tool

Definition at line 80 of file AFPSiClusterTool.h.

80{this, "MonTool", "", "Monitoring tool"};

◆ m_numberOfLayersInStations

Gaudi::Property<std::vector<int> > AFPSiClusterTool::m_numberOfLayersInStations {this, "numberOfLayersInStations",{4,4,4,4}, "The size of the array in argument defines number of stations, the value in each entry defines number of layers in the station."}
private

Array defining number of stations and layers in each station.

The size of the array in argument defines number of stations, the value in each entry defines number of layers in the station. Default is 4 stations times 4 layers.

Definition at line 93 of file AFPSiClusterTool.h.

93{this, "numberOfLayersInStations",{4,4,4,4}, "The size of the array in argument defines number of stations, the value in each entry defines number of layers in the station."};

◆ m_rowColToLocalCSToolHandle

ToolHandle<IAFPSiRowColToLocalCSTool> AFPSiClusterTool::m_rowColToLocalCSToolHandle {this,"rowColToLocalCSTool", "AFPSiRowColToLocalCSTool","Tool to rewrite clusters to xAOD and transform rows and columns to station local coordinates"}
private

Tool that creates xAOD and transforms rows and pixels to local coordinate system.

Definition at line 77 of file AFPSiClusterTool.h.

77{this,"rowColToLocalCSTool", "AFPSiRowColToLocalCSTool","Tool to rewrite clusters to xAOD and transform rows and columns to station local coordinates"};

◆ m_siGlobAlignDBTool

ToolHandle<AFP::ISiGlobAlignDBTool> AFPSiClusterTool::m_siGlobAlignDBTool {this, "siGlobAlignDBTool", "AFP__SiGlobAlignDBTool", "Tool to access DB to get the global alignment constants"}
private

@ brief Tool for accessing DB to get the global alignment constants

Definition at line 87 of file AFPSiClusterTool.h.

87{this, "siGlobAlignDBTool", "AFP__SiGlobAlignDBTool", "Tool to access DB to get the global alignment constants"};

◆ m_siLocAlignDBTool

ToolHandle<AFP::ISiLocAlignDBTool> AFPSiClusterTool::m_siLocAlignDBTool {this, "siLocAlignDBTool", "AFP__SiLocAlignDBTool", "Tool to access DB to get the local alignment constants"}
private

@ brief Tool for accessing DB to get the local alignment constants

Definition at line 84 of file AFPSiClusterTool.h.

84{this, "siLocAlignDBTool", "AFP__SiLocAlignDBTool", "Tool to access DB to get the local alignment constants"};

The documentation for this class was generated from the following files: