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< ISiLorentzAngleTool > m_pixelLorentzAngleTool
SG::ReadCondHandleKey< PixelChargeCalibCondData > m_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 PixelID * m_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.

394{
395 IdentifierHash idHash = RDOs.identifyHash();
397 if ( pixelDetElStatus.isGood(idHash) ) {
398 // Retrieve the cells from the detector element
401
402 static constexpr unsigned int SORT_BY_LOCAL_X=0u;
406 // set the cell range per cluster
409 unsigned int idx_begin,
410 unsigned int idx_end) {
411 cellContainer.registerNewCluster(idx_begin,idx_end);
412 });
413 }
414 // must add a range for every call otherwise the cell container and
415 // the list of processed modules get out of sync.
416 cellContainer.registerClustersForNewModule(rangeGuard.range());
417
418 return StatusCode::SUCCESS;
419}
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.

173 {
174 if (m_isITk || !m_checkGanged ) {
176 }
177 else {
179 }
180}
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.

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

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

◆ makeCluster()

Definition at line 84 of file PixelClusteringTool.cxx.

193{
195 float tot_acc = 0.f;
196 //to start, set max to the min possible int and min to the max possible int
199 //
208
209 // We temporary comment this since it is not used
210 // bool hasGanged = false;
211 unsigned int n_rdos = clusterVars.rdoList.getBeginIndex(icluster);
212 assert( clusterVars.totList.getBeginIndex(icluster)==n_rdos );
213 assert( calibData==nullptr || clusterVars.chargeList.getBeginIndex(icluster)==n_rdos );
214
215 IdentifierHash idHash = element.identifyHash();
216 assert( idHash == cluster.identifyHash());
217 Identifier module_id = element.identify();
220 float totalCharge = 0.f;
221
223 for (CellProxy cellProxy : cluster) {
224
225 //Construct the identifier class
226
227 // We temporary comment this since it is not used
228 // TODO: Check how the ganged info is used in legacy
229 // if (multiChip) {
230 // hasGanged = hasGanged ||
231 // m_pixelRDOTool->isGanged(id, element).has_value();
232 // }
233 assert(cellProxy.srcIndex() < rdos.size());
234
237 assert( rdo.index() >= rdos.beginIndex() && rdo.index() < rdos.endIndex() );
238 }
239
240 Identifier rdo_id = rdo.computeIdentifier(*m_pixelID,module_id, cellProxy);
241 if (!first_rdo_id.has_value()) {
242 first_rdo_id=rdo_id.get_compact();
243 }
244
245 assert(rdo.getLVL1A()>=0 && rdo.getLVL1A() < std::numeric_limits<uint8_t>::max());
246 cluster_lvl1min = std::min(cluster_lvl1min, static_cast<int>(rdo.getLVL1A()) );
247
248 const int tot = rdo.getToT();
249 float charge = tot;
250
253 cellProxy.coordinates()[1]);
255
256 if (calibData) {
257 // Retrieving the calibration only depends on FE and not per cell (can be further optimized)
258 // Single FE modules could have an optimized getCharge function where the calib constants are cached
260 auto diode_type = design.getDiodeType(si_param);
261 if (m_isITk){
262 // @TODO only check in makeClusters or check at all ?
263 if (design.getReadoutTechnology() != InDetDD::PixelReadoutTechnology::RD53) {
264 ATH_MSG_ERROR("Chip type is not recognized!");
265 return StatusCode::FAILURE;
266 }
267
268 charge = calibData->getCharge(diode_type,
270 idHash,
271 feValue,
272 tot);
273 } else {
274 charge = calibData->getCharge(diode_type,
275 idHash,
276 feValue,
277 tot);
278
279 // These numbers are taken from the Cluster Maker Tool
280 if (design.getReadoutTechnology() != InDetDD::PixelReadoutTechnology::RD53 && (idHash < 12 or idHash > 2035)) {
281 charge = tot/8.0*(8000.0-1200.0)+1200.0;
282 }
283 }
284 clusterVars.chargeList.setValue(n_rdos,charge);
285 }
286 clusterVars.rdoList.setValue(n_rdos,rdo_id.get_compact());
287 clusterVars.totList.setValue(n_rdos,tot);
289 ++n_rdos;
290
293 if (row>rowmax) {
294 rowmax=row;
296 }
297 if (row<rowmin) {
298 rowmin=row;
300 }
301 if (col>colmax) {
302 colmax=col;
304 }
305 if (col<colmin) {
306 colmin=col;
308 }
309
310 // We compute the digital position as a sum of all RDO positions
311 // all with the same weight of 1
312 // We do not compute a charge-weighted center of gravity here (by default) since
313 // we observe it to be worse than the digital position
314 // ToT-weighted center of gravity must not be used
315 if (m_useWeightedPos) {
316 pos_acc += charge * si_param.position();
317 tot_acc += charge;
318 } else {
319 pos_acc += si_param.position();
320 tot_acc += 1;
321 }
322
323 } // loop on cluster's cells
324 assert(n_rdos>0); // clusters must not be empty
325 if (tot_acc > 0)
326 pos_acc /= tot_acc;
327
328 const long long diffCol = static_cast<long long>(colmax) - static_cast<long long>(colmin) + 1LL;
329 const long long diffRow = static_cast<long long>(rowmax) - static_cast<long long>(rowmin) + 1LL;
332 const int colWidth = static_cast<int>(diffCol);
333 const int rowWidth = static_cast<int>(diffRow);
334
335 double etaWidth = colmax_diode.xEtaMax() - colmin_diode.xEtaMin(); // design.widthFromColumnRange(colmin, colmax);
336 double phiWidth = rowmax_diode.xPhiMax() - rowmin_diode.xPhiMin(); // design.widthFromColumnRange(colmin, colmax);
337
338 // ask for Lorentz correction, get global position
341 // find global position of element
342 const Amg::Transform3D& T = element.surface().transform();
343 double Ax[3] = {T(0,0),T(1,0),T(2,0)};
344 double Ay[3] = {T(0,1),T(1,1),T(2,1)};
345 double R [3] = {T(0,3),T(1,3),T(2,3)};
346
347 const Amg::Vector2D& M = locpos;
348 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]);
349
350 // Compute error matrix
351 float width0, width1;
352 if (m_broadErrors) {
353 // Use cluster width
356 } else {
357 // Use average pixel width
360 }
361
362 // Actually create the cluster (i.e. fill the values)
363
366 localCovariance(0, 0) = width0 * width0 / 12.0f;
367 localCovariance(1, 1) = width1 * width1 / 12.0f;
368
369 clusterVars.identifierHash[icluster] = idHash;
370 xAOD::VectorMap<2>(clusterVars.localPositionDim2[icluster].data()) = localPosition;
371 xAOD::MatrixMap<2>(clusterVars.localCovarianceDim2[icluster].data()) = localCovariance;
372 assert( first_rdo_id.has_value());
373 clusterVars.identifier[icluster] = *first_rdo_id;
374 clusterVars.rdoList.updateEndIndex(icluster,n_rdos);
375 xAOD::VectorMap<3>(clusterVars.globalPosition[icluster].data()) = globalPos.cast<float>();
376 clusterVars.totList.updateEndIndex(icluster,n_rdos);
377 clusterVars.chargeList.updateEndIndex(icluster, (calibData ? n_rdos : 0u));
378 clusterVars.totalCharge[icluster] = totalCharge;
380 clusterVars.channelsInPhi[icluster] = rowWidth;
381 clusterVars.channelsInEta[icluster] = colWidth;
382 clusterVars.widthInEta[icluster] = etaWidth;
383
384 return StatusCode::SUCCESS;
385}
#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.

441{
442 // Retrieve the calibration data
443 const PixelChargeCalibCondData *calibData = nullptr;
444 if (not m_chargeDataKey.empty()) {
446 calibData = calibDataHandle.cptr();
447
448 if (!calibData) {
449 ATH_MSG_ERROR("PixelChargeCalibCondData requested but couldn't be retrieved from " << m_chargeDataKey.key());
450 return StatusCode::FAILURE;
451 }
452 }
453
454 // Get the element design
456 static_cast<const InDetDD::PixelModuleDesign&>(element.design());
457
458 // Get the calibration strategy for this module.
459 // Default to RD53 if the calibData is not available. That is fine because it won't be used anyway
461
462 IdentifierHash idHash = element.identifyHash();
463 double lorentzShift = m_pixelLorentzAngleTool->getLorentzShift(idHash, ctx);
464
466 if (!clusterVars) throw std::bad_any_cast();
467
469 if (!rdos_optional.has_value()) return StatusCode::FAILURE;
471
477
481 element,
482 design,
483 *rdos,
484 calibData,
487 *clusterVars));
488 }
489
490 return StatusCode::SUCCESS;
491}
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.

500{
501 // Get the element design
503 static_cast<const InDetDD::PixelModuleDesign&>(element.design());
504
506
508 unsigned int rdo_i=0;
510 auto coordinates=rdo.coordinates(*m_pixelID);
513
514 // check if good RDO
515 // the pixel RDO tool here says always good if m_useModuleMap is false
516 if (pixelDetElStatus.isChipGood(rangeGuard.identifyHash(), fe)) {
518
519 if ( check_ganged ) {
521 if (gangedCoordinates.has_value()) {
522 cellContainer.emplace_back_cell(*gangedCoordinates, rdo_i);
523 }
524 }
525 }
526 ++rdo_i;
527 }
528
529 return rangeGuard.moduleCellSpan();
530}

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: