ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrk::PhaseIIPixelClusteringTool Class Reference

#include <PixelClusteringTool.h>

Inheritance diagram for ActsTrk::PhaseIIPixelClusteringTool:
Collaboration diagram for ActsTrk::PhaseIIPixelClusteringTool:

Public Types

using IClusteringToolType
using base_class

Public Member Functions

virtual StatusCode initialize () override
virtual std::pair< unsigned int, unsigned int > countCells (const PhaseIIPixelRawDataContainer &rdo_collection, const std::vector< IdentifierHash > &listOfIds, const InDetDD::SiDetectorElementCollection &detector_elements) const override
virtual StatusCode clusterize (const EventContext &ctx, const ActsTrk::RDOContainerTraits< PhaseIIPixelRawDataContainer >::PerModuleRDOs &RDOs, const InDet::SiDetectorElementStatus &pixelDetElStatus, const InDetDD::SiDetectorElement &element, typename IClusteringToolType::CellContainer &cellContainer) const override
virtual std::any createEventDataCache (xAOD::PixelClusterContainer &cont, std::size_t nClusterRDOs) const override
virtual StatusCode makeClusters (const EventContext &ctx, const PhaseIIPixelRawDataContainer &rdo_container, const typename IClusteringToolType::CellContainer &cellContainer, unsigned int module_i, const InDetDD::SiDetectorElement &element, unsigned int icluster, xAOD::PixelClusterContainer &cont, std::any &vars) const override

Private Types

using ClusterProxy
using Cell

Private Member Functions

std::pair< unsigned int, unsigned int > countCellsImpl (const PhaseIIPixelRawDataContainer &rdo_collection, const std::vector< IdentifierHash > &listOfIds, const InDetDD::SiDetectorElementCollection &detector_elements) const
std::span< typename IClusteringToolType::CellContainer::Cell > unpackRDOs (const ActsTrk::RDOContainerTraits< PhaseIIPixelRawDataContainer >::PerModuleRDOs &RDOs, const InDet::SiDetectorElementStatus &pixelDetElStatus, const InDetDD::SiDetectorElement &element, typename IClusteringToolType::CellContainer &cellContainer) const
StatusCode makeCluster (size_t icluster, const PixelClusteringToolImpl::ClusterProxy &cluster, const InDetDD::SiDetectorElement &element, const InDetDD::PixelModuleDesign &design, const ActsTrk::RDOContainerTraits< PhaseIIPixelRawDataContainer >::PerModuleRDOs &RDOs, const PixelChargeCalibCondData *calibData, const PixelChargeCalibCondData::CalibrationStrategy calibStrategy, const double lorentz_shift, xAOD::PixelCluster::ClusterVars &clusterVars) const

Private Attributes

ToolHandle< ISiLorentzAngleToolm_pixelLorentzAngleTool
SG::ReadCondHandleKey< PixelChargeCalibCondDatam_chargeDataKey
Gaudi::Property< std::string > m_idHelperName
Gaudi::Property< bool > m_addCorners
Gaudi::Property< bool > m_useWeightedPos
Gaudi::Property< bool > m_broadErrors
Gaudi::Property< bool > m_checkGanged
Gaudi::Property< bool > m_isITk
const PixelIDm_pixelID

Detailed Description

Definition at line 115 of file PixelClusteringTool.h.

Member Typedef Documentation

◆ base_class

Definition at line 30 of file PixelClusteringTool.h.

◆ Cell

Definition at line 76 of file PixelClusteringTool.h.

◆ ClusterProxy

using ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::ClusterProxy
privateinherited

Definition at line 75 of file PixelClusteringTool.h.

◆ IClusteringToolType

using ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::IClusteringToolType
inherited

Definition at line 29 of file PixelClusteringTool.h.

Member Function Documentation

◆ clusterize()

StatusCode ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::clusterize ( const EventContext & ctx,
const ActsTrk::RDOContainerTraits< PhaseIIPixelRawDataContainer >::PerModuleRDOs & RDOs,
const InDet::SiDetectorElementStatus & pixelDetElStatus,
const InDetDD::SiDetectorElement & element,
typename IClusteringToolType::CellContainer & cellContainer ) const
overridevirtualinherited

Definition at line 43 of file PixelClusteringTool.cxx.

386{
387 IdentifierHash idHash = RDOs.identifyHash();
389 if ( pixelDetElStatus.isGood(idHash) ) {
390 // Retrieve the cells from the detector element
393
394 static constexpr unsigned int SORT_BY_LOCAL_X=0u;
398 // set the cell range per cluster
401 unsigned int idx_begin,
402 unsigned int idx_end) {
403 cellContainer.registerNewCluster(idx_begin,idx_end);
404 });
405 }
406 // must add a range for every call otherwise the cell container and
407 // the list of processed modules get out of sync.
408 cellContainer.registerClustersForNewModule(rangeGuard.range());
409
410 return StatusCode::SUCCESS;
411}
std::span< typename IClusteringToolType::CellContainer::Cell > unpackRDOs(const ActsTrk::RDOContainerTraits< PhaseIIPixelRawDataContainer >::PerModuleRDOs &RDOs, const InDet::SiDetectorElementStatus &pixelDetElStatus, const InDetDD::SiDetectorElement &element, typename IClusteringToolType::CellContainer &cellContainer) const
void for_each_cluster(cell_collection_t &cells, func_t func)
call the given function for each cluster of a label sorted cell collection.

◆ countCells()

std::pair< unsigned int, unsigned int > ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::countCells ( const PhaseIIPixelRawDataContainer & rdo_collection,
const std::vector< IdentifierHash > & listOfIds,
const InDetDD::SiDetectorElementCollection & detector_elements ) const
overridevirtualinherited

Definition at line 38 of file PixelClusteringTool.cxx.

171 {
172 if (m_isITk || !m_checkGanged ) {
174 }
175 else {
177 }
178}
std::pair< unsigned int, unsigned int > countCellsImpl(const PhaseIIPixelRawDataContainer &rdo_collection, const std::vector< IdentifierHash > &listOfIds, const InDetDD::SiDetectorElementCollection &detector_elements) const

◆ countCellsImpl()

std::pair< unsigned int, unsigned int > ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::countCellsImpl ( const PhaseIIPixelRawDataContainer & rdo_collection,
const std::vector< IdentifierHash > & listOfIds,
const InDetDD::SiDetectorElementCollection & detector_elements ) const
privateinherited

Definition at line 71 of file PixelClusteringTool.cxx.

123 {
126 const PixelID* pixelID)
127 -> unsigned int
128 {
129 unsigned int n_hits = RDOs.size();
130 if constexpr(GANGED) {
131 assert(detector_elements.at(RDOs.identifyHash()));
132 assert(dynamic_cast<const InDetDD::PixelModuleDesign *>(&detector_elements.at(RDOs.identifyHash())->design()) != nullptr);
133 const InDetDD::PixelModuleDesign &design = static_cast<const InDetDD::PixelModuleDesign &>(detector_elements.at(RDOs.identifyHash())->design());
134 if (isFEI3(design)) {
136 if (rdo.isGanged(design, *pixelID)) {
137 ++n_hits;
138 }
139 }
140 }
141 }
142 return n_hits;
143 };
144 unsigned int n_hits=0u;
145 if (listOfIds.empty()) {
147 assert( RDOs.isValid());
149 }
150 }
151 else {
152 for (const IdentifierHash& id : listOfIds) {
153 if (not id.is_valid()) continue;
155 if (RDOs.has_value()) {
157 }
158 }
159 }
160 // the total number of hits is the best estimate of the maximum number of clusters.
161 // @TODO could apply a factor for the number clusters or only if the number of hits
162 // are above a certain threshold to reduce memory consumption though impact
163 // is likely small.
164 return {n_hits,n_hits};
165}
static std::optional< RDOCollectionAdapter > make(const T_RDOContainer &rdo_container, const IdentifierHash &id_hash)

◆ createEventDataCache()

std::any ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::createEventDataCache ( xAOD::PixelClusterContainer & cont,
std::size_t nClusterRDOs ) const
overridevirtualinherited

Definition at line 49 of file PixelClusteringTool.cxx.

◆ initialize()

StatusCode ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::initialize ( )
overridevirtualinherited

Definition at line 35 of file PixelClusteringTool.cxx.

90{
91 ATH_MSG_DEBUG("Initializing " << this->name() << " ...");
92
97
98 ATH_CHECK(this->m_pixelLorentzAngleTool.retrieve());
99
101
102 ATH_MSG_INFO(" Charge Data Key:" << m_chargeDataKey);
103 ATH_MSG_INFO(" ID Helper Name:" << m_idHelperName);
104
106
107 ATH_MSG_DEBUG(this->name() << " successfully initialized");
108 return StatusCode::SUCCESS;
109}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
virtual StatusCode initialize() override

◆ makeCluster()

Definition at line 84 of file PixelClusteringTool.cxx.

191{
193 float tot_acc = 0.f;
194
203
204 // We temporary comment this since it is not used
205 // bool hasGanged = false;
206 unsigned int n_rdos = clusterVars.rdoList.getBeginIndex(icluster);
207 assert( clusterVars.totList.getBeginIndex(icluster)==n_rdos );
208 assert( calibData==nullptr || clusterVars.chargeList.getBeginIndex(icluster)==n_rdos );
209
210 IdentifierHash idHash = element.identifyHash();
211 assert( idHash == cluster.identifyHash());
212 Identifier module_id = element.identify();
215 float totalCharge = 0.f;
216
218 for (CellProxy cellProxy : cluster) {
219
220 //Construct the identifier class
221
222 // We temporary comment this since it is not used
223 // TODO: Check how the ganged info is used in legacy
224 // if (multiChip) {
225 // hasGanged = hasGanged ||
226 // m_pixelRDOTool->isGanged(id, element).has_value();
227 // }
228 assert(cellProxy.srcIndex() < rdos.size());
229
232 assert( rdo.index() >= rdos.beginIndex() && rdo.index() < rdos.endIndex() );
233 }
234
235 Identifier rdo_id = rdo.computeIdentifier(*m_pixelID,module_id, cellProxy);
236 if (!first_rdo_id.has_value()) {
237 first_rdo_id=rdo_id.get_compact();
238 }
239
240 assert(rdo.getLVL1A()>=0 && rdo.getLVL1A() < std::numeric_limits<uint8_t>::max());
241 cluster_lvl1min = std::min(cluster_lvl1min, static_cast<int>(rdo.getLVL1A()) );
242
243 const int tot = rdo.getToT();
244 float charge = tot;
245
248 cellProxy.coordinates()[1]);
250
251 if (calibData) {
252 // Retrieving the calibration only depends on FE and not per cell (can be further optimized)
253 // Single FE modules could have an optimized getCharge function where the calib constants are cached
255 auto diode_type = design.getDiodeType(si_param);
256 if (m_isITk){
257 // @TODO only check in makeClusters or check at all ?
258 if (design.getReadoutTechnology() != InDetDD::PixelReadoutTechnology::RD53) {
259 ATH_MSG_ERROR("Chip type is not recognized!");
260 return StatusCode::FAILURE;
261 }
262
263 charge = calibData->getCharge(diode_type,
265 idHash,
266 feValue,
267 tot);
268 } else {
269 charge = calibData->getCharge(diode_type,
270 idHash,
271 feValue,
272 tot);
273
274 // These numbers are taken from the Cluster Maker Tool
275 if (design.getReadoutTechnology() != InDetDD::PixelReadoutTechnology::RD53 && (idHash < 12 or idHash > 2035)) {
276 charge = tot/8.0*(8000.0-1200.0)+1200.0;
277 }
278 }
279 clusterVars.chargeList.setValue(n_rdos,charge);
280 }
281 clusterVars.rdoList.setValue(n_rdos,rdo_id.get_compact());
282 clusterVars.totList.setValue(n_rdos,tot);
284 ++n_rdos;
285
288 if (row>rowmax) {
289 rowmax=row;
291 }
292 if (row<rowmin) {
293 rowmin=row;
295 }
296 if (col>colmax) {
297 colmax=col;
299 }
300 if (col<colmin) {
301 colmin=col;
303 }
304
305 // We compute the digital position as a sum of all RDO positions
306 // all with the same weight of 1
307 // We do not compute a charge-weighted center of gravity here (by default) since
308 // we observe it to be worse than the digital position
309 // ToT-weighted center of gravity must not be used
310 if (m_useWeightedPos) {
311 pos_acc += charge * si_param.position();
312 tot_acc += charge;
313 } else {
314 pos_acc += si_param.position();
315 tot_acc += 1;
316 }
317
318 } // loop on cluster's cells
319 assert(n_rdos>0); // clusters must not be empty
320 if (tot_acc > 0)
321 pos_acc /= tot_acc;
322
323
324 const int colWidth = colmax - colmin + 1;
325 const int rowWidth = rowmax - rowmin + 1;
326
327 double etaWidth = colmax_diode.xEtaMax() - colmin_diode.xEtaMin(); // design.widthFromColumnRange(colmin, colmax);
328 double phiWidth = rowmax_diode.xPhiMax() - rowmin_diode.xPhiMin(); // design.widthFromColumnRange(colmin, colmax);
329
330 // ask for Lorentz correction, get global position
333 // find global position of element
334 const Amg::Transform3D& T = element.surface().transform();
335 double Ax[3] = {T(0,0),T(1,0),T(2,0)};
336 double Ay[3] = {T(0,1),T(1,1),T(2,1)};
337 double R [3] = {T(0,3),T(1,3),T(2,3)};
338
339 const Amg::Vector2D& M = locpos;
340 Amg::Vector3D globalPos(M[0]*Ax[0]+M[1]*Ay[0]+R[0],M[0]*Ax[1]+M[1]*Ay[1]+R[1],M[0]*Ax[2]+M[1]*Ay[2]+R[2]);
341
342 // Compute error matrix
343 float width0, width1;
344 if (m_broadErrors) {
345 // Use cluster width
348 } else {
349 // Use average pixel width
352 }
353
354 // Actually create the cluster (i.e. fill the values)
355
358 localCovariance(0, 0) = width0 * width0 / 12.0f;
359 localCovariance(1, 1) = width1 * width1 / 12.0f;
360
361 clusterVars.identifierHash[icluster] = idHash;
362 xAOD::VectorMap<2>(clusterVars.localPositionDim2[icluster].data()) = localPosition;
363 xAOD::MatrixMap<2>(clusterVars.localCovarianceDim2[icluster].data()) = localCovariance;
364 assert( first_rdo_id.has_value());
365 clusterVars.identifier[icluster] = *first_rdo_id;
366 clusterVars.rdoList.updateEndIndex(icluster,n_rdos);
367 xAOD::VectorMap<3>(clusterVars.globalPosition[icluster].data()) = globalPos.cast<float>();
368 clusterVars.totList.updateEndIndex(icluster,n_rdos);
369 clusterVars.chargeList.updateEndIndex(icluster, (calibData ? n_rdos : 0u));
370 clusterVars.totalCharge[icluster] = totalCharge;
372 clusterVars.channelsInPhi[icluster] = rowWidth;
373 clusterVars.channelsInEta[icluster] = colWidth;
374 clusterVars.widthInEta[icluster] = etaWidth;
375
376 return StatusCode::SUCCESS;
377}
#define ATH_MSG_ERROR(x)
static constexpr std::array< PixelDiodeTree::CellIndexType, 2 > makeCellIndex(T local_x_idx, T local_y_idx)
Create a 2D cell index from the indices in local-x (phi, row) and local-y (eta, column) direction.
Eigen::Map< MeasVector< N > > VectorMap
Eigen::Map< MeasMatrix< N > > MatrixMap

◆ makeClusters()

StatusCode ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::makeClusters ( const EventContext & ctx,
const PhaseIIPixelRawDataContainer & rdo_container,
const typename IClusteringToolType::CellContainer & cellContainer,
unsigned int module_i,
const InDetDD::SiDetectorElement & element,
unsigned int icluster,
xAOD::PixelClusterContainer & cont,
std::any & vars ) const
overridevirtualinherited

Definition at line 53 of file PixelClusteringTool.cxx.

433{
434 // Retrieve the calibration data
435 const PixelChargeCalibCondData *calibData = nullptr;
436 if (not m_chargeDataKey.empty()) {
438 calibData = calibDataHandle.cptr();
439
440 if (!calibData) {
441 ATH_MSG_ERROR("PixelChargeCalibCondData requested but couldn't be retrieved from " << m_chargeDataKey.key());
442 return StatusCode::FAILURE;
443 }
444 }
445
446 // Get the element design
448 static_cast<const InDetDD::PixelModuleDesign&>(element.design());
449
450 // Get the calibration strategy for this module.
451 // Default to RD53 if the calibData is not available. That is fine because it won't be used anyway
453
454 IdentifierHash idHash = element.identifyHash();
455 double lorentzShift = m_pixelLorentzAngleTool->getLorentzShift(idHash, ctx);
456
458 if (!clusterVars) throw std::bad_any_cast();
459
461 if (!rdos_optional.has_value()) return StatusCode::FAILURE;
463
469
473 element,
474 design,
475 *rdos,
476 calibData,
479 *clusterVars));
480 }
481
482 return StatusCode::SUCCESS;
483}
StatusCode makeCluster(size_t icluster, const PixelClusteringToolImpl::ClusterProxy &cluster, const InDetDD::SiDetectorElement &element, const InDetDD::PixelModuleDesign &design, const ActsTrk::RDOContainerTraits< PhaseIIPixelRawDataContainer >::PerModuleRDOs &RDOs, const PixelChargeCalibCondData *calibData, const PixelChargeCalibCondData::CalibrationStrategy calibStrategy, const double lorentz_shift, xAOD::PixelCluster::ClusterVars &clusterVars) const
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())

◆ unpackRDOs()

std::span< typename ActsTrk::RDOContainerTraits< PhaseIIPixelRawDataContainer >::IClusteringToolType::CellContainer::Cell > ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::unpackRDOs ( const ActsTrk::RDOContainerTraits< PhaseIIPixelRawDataContainer >::PerModuleRDOs & RDOs,
const InDet::SiDetectorElementStatus & pixelDetElStatus,
const InDetDD::SiDetectorElement & element,
typename IClusteringToolType::CellContainer & cellContainer ) const
privateinherited

Definition at line 79 of file PixelClusteringTool.cxx.

492{
493 // Get the element design
495 static_cast<const InDetDD::PixelModuleDesign&>(element.design());
496
498
500 unsigned int rdo_i=0;
502 auto coordinates=rdo.coordinates(*m_pixelID);
505
506 // check if good RDO
507 // the pixel RDO tool here says always good if m_useModuleMap is false
508 if (pixelDetElStatus.isChipGood(rangeGuard.identifyHash(), fe)) {
510
511 if ( check_ganged ) {
513 if (gangedCoordinates.has_value()) {
514 cellContainer.emplace_back_cell(*gangedCoordinates, rdo_i);
515 }
516 }
517 }
518 ++rdo_i;
519 }
520
521 return rangeGuard.moduleCellSpan();
522}

Member Data Documentation

◆ m_addCorners

Gaudi::Property<bool> ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::m_addCorners
privateinherited

Definition at line 101 of file PixelClusteringTool.h.

101{this, "AddCorners", true};

◆ m_broadErrors

Gaudi::Property<bool> ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::m_broadErrors
privateinherited

Definition at line 103 of file PixelClusteringTool.h.

103{this, "UseBroadErrors", false};

◆ m_chargeDataKey

Definition at line 96 of file PixelClusteringTool.h.

96 {this, "PixelChargeCalibCondData", "",
97 "Pixel charge calibration data"};

◆ m_checkGanged

Gaudi::Property<bool> ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::m_checkGanged
privateinherited

Definition at line 104 of file PixelClusteringTool.h.

104{this, "CheckGanged", false};

◆ m_idHelperName

Gaudi::Property<std::string> ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::m_idHelperName
privateinherited

Definition at line 98 of file PixelClusteringTool.h.

98 {this, "IDHelperName", "PixelID",
99 "Pixel-like ID helper name to retrieve from DetectorStore"};

◆ m_isITk

Gaudi::Property<bool> ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::m_isITk
privateinherited

Definition at line 105 of file PixelClusteringTool.h.

105{this, "isITk", true, "True if running in ITk"};

◆ m_pixelID

Definition at line 106 of file PixelClusteringTool.h.

106{nullptr};

◆ m_pixelLorentzAngleTool

ToolHandle< ISiLorentzAngleTool > ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::m_pixelLorentzAngleTool
privateinherited

Definition at line 94 of file PixelClusteringTool.h.

94{this, "PixelLorentzAngleTool", "", "Tool to retreive Lorentz angle of Pixel"};

◆ m_useWeightedPos

Gaudi::Property<bool> ActsTrk::PixelClusteringToolImpl< PhaseIIPixelRawDataContainer >::m_useWeightedPos
privateinherited

Definition at line 102 of file PixelClusteringTool.h.

102{this, "UseWeightedPosition", false};

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