ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 More...
 
StatusCode clusterHits (std::unique_ptr< xAOD::AFPSiHitsClusterContainer > &clustr, const EventContext &ctx) const override
 Run clusters reconstruction. More...
 

Private Member Functions

StatusCode clearAllLayers (std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers) const
 Runs AFPSiClusterLayerBasicObj::clearHitsAndClusters() on all layers in #my_layers. More...
 
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. More...
 
StatusCode clusterEachLayer (std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers) const
 Runs tool reconstructing clusters on each layer. More...
 
StatusCode saveToXAOD (std::unique_ptr< xAOD::AFPSiHitsClusterContainer > &clustr, std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers, const EventContext &ctx) const
 Save clusters in xAOD::AFPSiHitsClusterContainer. More...
 
std::vector< std::vector< AFPSiClusterLayerBasicObj > > initLayers (const std::vector< int > &layersInStations) const
 Initialise size as well as station and layer ID for #my_layers. More...
 

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. More...
 
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. More...
 
ToolHandle< GenericMonitoringToolm_monTool {this, "MonTool", "", "Monitoring tool"}
 @ brief Monitoring tool More...
 
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 More...
 
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 More...
 
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. More...
 

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 }

◆ 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 }

◆ 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 }

◆ 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 
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 }

◆ 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() );
57  CHECK( m_rowColToLocalCSToolHandle.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 }

◆ 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 }

◆ 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 
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()) {
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 }

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.

◆ 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.

◆ m_monTool

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

@ brief Monitoring tool

Definition at line 80 of file AFPSiClusterTool.h.

◆ 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.

◆ 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.

◆ 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.

◆ 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.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AFPSiClusterLayerBasicObj
Class representing basic silicon layer with pixels and their clusters to be used for creating the clu...
Definition: AFPSiClusterLayerBasicObj.h:30
AFPSiClusterTool::clearAllLayers
StatusCode clearAllLayers(std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers) const
Runs AFPSiClusterLayerBasicObj::clearHitsAndClusters() on all layers in #my_layers.
Definition: AFPSiClusterTool.cxx:109
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
json
nlohmann::json json
Definition: HistogramDef.cxx:9
xAOD::AFPSiHitsCluster_v1::pixelLayerID
int pixelLayerID() const
Index of the silicon layer with the cluster.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AFPSiClusterTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
@ brief Monitoring tool
Definition: AFPSiClusterTool.h:80
xAOD::AFPSiHit_v2
Class representing a hit in silicon detector.
Definition: AFPSiHit_v2.h:30
AFPSiClusterTool::fillLayersWithHits
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.
Definition: AFPSiClusterTool.cxx:118
AFPSiClusterBasicObj
Class representing basic silicon pixels cluster, designed to be used for creating the clusters.
Definition: AFPSiClusterBasicObj.h:28
AFPSiClusterTool::m_numberOfLayersInStations
Gaudi::Property< std::vector< int > > m_numberOfLayersInStations
Array defining number of stations and layers in each station.
Definition: AFPSiClusterTool.h:93
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
AFPSiClusterTool::saveToXAOD
StatusCode saveToXAOD(std::unique_ptr< xAOD::AFPSiHitsClusterContainer > &clustr, std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers, const EventContext &ctx) const
Save clusters in xAOD::AFPSiHitsClusterContainer.
Definition: AFPSiClusterTool.cxx:164
AFPSiClusterTool::m_siLocAlignDBTool
ToolHandle< AFP::ISiLocAlignDBTool > m_siLocAlignDBTool
@ brief Tool for accessing DB to get the local alignment constants
Definition: AFPSiClusterTool.h:84
AFPSiClusterTool::initLayers
std::vector< std::vector< AFPSiClusterLayerBasicObj > > initLayers(const std::vector< int > &layersInStations) const
Initialise size as well as station and layer ID for #my_layers.
Definition: AFPSiClusterTool.cxx:25
AFPSiClusterTool::m_AFPSiHitContainerKey
SG::ReadHandleKey< xAOD::AFPSiHitContainer > m_AFPSiHitContainerKey
Definition: AFPSiClusterTool.h:71
test_pyathena.parent
parent
Definition: test_pyathena.py:15
Muon::nsw::STGTPSegments::moduleIDBits::stationID
constexpr uint8_t stationID
Large or Small wedge.
Definition: NSWSTGTPDecodeBitmaps.h:152
xAOD::AFPSiHitsCluster_v1::xLocal
float xLocal() const
Cluster position along X axis in station local coordinate system.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
AFPSiClusterTool::clusterEachLayer
StatusCode clusterEachLayer(std::vector< std::vector< AFPSiClusterLayerBasicObj > > &my_layers) const
Runs tool reconstructing clusters on each layer.
Definition: AFPSiClusterTool.cxx:155
AFP::SiGlobAlignData
Definition: SiGlobAlignData.h:23
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
AFPSiClusterTool::m_clusterAlgToolHandle
ToolHandle< IAFPSiClusterAlgTool > m_clusterAlgToolHandle
Tool that does the clustering on hits.
Definition: AFPSiClusterTool.h:74
xAOD::AFPSiHitsCluster_v1::addHitLink
void addHitLink(const AFPHitLink_t &newHit)
Add a link to a pixel in this cluster.
Definition: AFPSiHitsCluster_v1.cxx:40
AFPSiClusterTool::m_rowColToLocalCSToolHandle
ToolHandle< IAFPSiRowColToLocalCSTool > m_rowColToLocalCSToolHandle
Tool that creates xAOD and transforms rows and pixels to local coordinate system.
Definition: AFPSiClusterTool.h:77
AFP::SiLocAlignData
Class storing information about alignment.
Definition: SiLocAlignData.h:24
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::AFPSiHitsCluster_v1::nHits
int nHits() const
Number of fired pixels (hits) in cluster.
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
xAOD::AFPSiHitsCluster_v1
Class representing a cluster of AFP pixel hits.
Definition: AFPSiHitsCluster_v1.h:32
xAOD::AFPSiHitsCluster_v1::yLocal
float yLocal() const
Cluster position along Y axis in station local coordinate system.
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
AFPSiClusterTool::m_siGlobAlignDBTool
ToolHandle< AFP::ISiGlobAlignDBTool > m_siGlobAlignDBTool
@ brief Tool for accessing DB to get the global alignment constants
Definition: AFPSiClusterTool.h:87
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::AFPSiHitsCluster_v1::zLocal
float zLocal() const
Cluster position along Z axis in station local coordinate system.