22using CLHEP::micrometer;
26 template <
typename T1,
typename T2>
27 T1 check_integer_cast(T2
a) {
28 assert( std::in_range<T1>(
a) );
29 return static_cast<T1>(
a);
36 template <
typename IndexType>
37 inline std::optional<std::array<std::int16_t,2> >
38 getGangedCoordinates(
const std::array<IndexType,2> &coordinates,
42 InDetDD::SiCellId cellId(check_integer_cast<int>(coordinates[0]),check_integer_cast<int>(coordinates[1]));
46 return std::array<std::int16_t,2>{
static_cast<std::int16_t
>(gangedCellId.
phiIndex()),
47 static_cast<std::int16_t
>(gangedCellId.
etaIndex())};
53 std::array<std::int16_t,2>
54 makeCellCoordinates(
const std::array<InDetDD::PixelDiodeTree::CellIndexType,2> &diode_idx) {
55 return std::array<std::int16_t,2>{
56 check_integer_cast<std::int16_t>(diode_idx[0]),
57 check_integer_cast<std::int16_t>(diode_idx[1])};
60 const std::array<InDetDD::PixelDiodeTree::CellIndexType,2> &
61 makeDiodeIdx(
const std::array<InDetDD::PixelDiodeTree::CellIndexType,2> &diode_idx) {
66 std::array<std::int16_t,2>
67 makeCellCoordinates(
const std::array<std::int16_t,2> &diode_idx) {
71 std::array<InDetDD::PixelDiodeTree::CellIndexType,2>
72 makeDiodeIdx(
const std::array<std::int16_t,2> &diode_idx) {
73 return std::array<InDetDD::PixelDiodeTree::CellIndexType,2>{
74 check_integer_cast<InDetDD::PixelDiodeTree::CellIndexType>(diode_idx[0]),
75 check_integer_cast<InDetDD::PixelDiodeTree::CellIndexType>(diode_idx[1])};
82template <
typename T_RDOContainer>
102 return StatusCode::SUCCESS;
105template <
typename T_RDOContainer>
107 const std::string&
type,
const std::string& name,
const IInterface* parent)
112template <
typename T_RDOContainer>
113template <
bool GANGED>
114std::pair<unsigned int, unsigned int>
116 const std::vector<IdentifierHash> &listOfIds,
123 unsigned int n_hits = RDOs.size();
124 if constexpr(GANGED) {
125 assert(detector_elements.
at(RDOs.identifyHash()));
128 if (isFEI3(design)) {
130 if (rdo.isGanged(design, *pixelID)) {
138 unsigned int n_hits=0u;
139 if (listOfIds.empty()) {
141 assert( RDOs.isValid());
142 n_hits += getNHits(*RDOs, detector_elements,
m_pixelID);
147 if (not
id.is_valid())
continue;
149 if (RDOs.has_value()) {
150 n_hits += getNHits(*(RDOs.value()), detector_elements,
m_pixelID);
158 return {n_hits,n_hits};
161template <
typename T_RDOContainer>
162std::pair<unsigned int, unsigned int>
164 const std::vector<IdentifierHash> &listOfIds,
174template <
typename T_RDOContainer>
183 const double lorentzShift,
208 std::optional<Identifier::value_type> first_rdo_id;
209 int cluster_lvl1min = std::numeric_limits<int>::max();
212 for (CellProxy cellProxy : cluster) {
222 assert(cellProxy.srcIndex() < rdos.size());
225 if constexpr(std::is_same_v<T_RDOContainer, PhaseIIPixelRawDataContainer>) {
226 assert( rdo.index() >= rdos.beginIndex() && rdo.index() < rdos.endIndex() );
230 if (!first_rdo_id.has_value()) {
234 assert(rdo.getLVL1A()>=0 && rdo.getLVL1A() < std::numeric_limits<uint8_t>::max());
235 cluster_lvl1min = std::min(cluster_lvl1min,
static_cast<int>(rdo.getLVL1A()) );
237 const int tot = rdo.getToT();
240 std::array<InDetDD::PixelDiodeTree::CellIndexType,2> diode_idx
242 cellProxy.coordinates()[1]);
248 std::uint32_t feValue = design.
getFE(si_param);
254 return StatusCode::FAILURE;
270 charge = tot/8.0*(8000.0-1200.0)+1200.0;
283 rowmax_diode = si_param;
287 rowmin_diode = si_param;
291 colmax_diode = si_param;
295 colmin_diode = si_param;
317 const int colWidth = colmax - colmin + 1;
318 const int rowWidth = rowmax - rowmin + 1;
320 double etaWidth = colmax_diode.
xEtaMax() - colmin_diode.
xEtaMin();
321 double phiWidth = rowmax_diode.
xPhiMax() - rowmin_diode.
xPhiMin();
328 double Ax[3] = {T(0,0),T(1,0),T(2,0)};
329 double Ay[3] = {T(0,1),T(1,1),T(2,1)};
330 double R [3] = {T(0,3),T(1,3),T(2,3)};
333 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]);
336 float width0, width1;
343 width0 = phiWidth / rowWidth;
344 width1 = etaWidth / colWidth;
349 Eigen::Matrix<float,2,1> localPosition(locpos.x(), locpos.y());
350 Eigen::Matrix<float,2,2> localCovariance = Eigen::Matrix<float,2,2>::Zero();
351 localCovariance(0, 0) = width0 * width0 / 12.0f;
352 localCovariance(1, 1) = width1 * width1 / 12.0f;
354 clusterVars.identifierHash[icluster] = idHash;
356 xAOD::MatrixMap<2>(clusterVars.localCovarianceDim2[icluster].data()) = localCovariance;
357 assert( first_rdo_id.has_value());
358 clusterVars.identifier[icluster] = *first_rdo_id;
360 xAOD::VectorMap<3>(clusterVars.globalPosition[icluster].data()) = globalPos.cast<
float>();
363 clusterVars.lvl1a[icluster] = cluster_lvl1min;
364 clusterVars.channelsInPhi[icluster] = rowWidth;
365 clusterVars.channelsInEta[icluster] = colWidth;
366 clusterVars.widthInEta[icluster] = etaWidth;
368 return StatusCode::SUCCESS;
371template <
typename T_RDOContainer>
380 typename IClusteringToolType::CellContainer::ModuleRangeGuard rangeGuard(cellContainer.startNewModule(idHash));
381 if ( pixelDetElStatus.
isGood(idHash) ) {
383 std::span<typename IClusteringToolType::CellContainer::Cell>
384 cellRange =
unpackRDOs(RDOs, pixelDetElStatus, element, cellContainer);
386 static constexpr unsigned int SORT_BY_LOCAL_X=0u;
388 CL::clusterize<SORT_BY_LOCAL_X, std::uint16_t>(cellRange,
389 CL::defaultConnectionHelper<CL::EConnectionType::CommonEdgeOrCorner>(cellRange));
392 [&cellContainer](std::span<typename IClusteringToolType::CellContainer::Cell> &,
393 unsigned int idx_begin,
394 unsigned int idx_end) {
395 cellContainer.registerNewCluster(idx_begin,idx_end);
400 cellContainer.registerClustersForNewModule(rangeGuard.range());
402 return StatusCode::SUCCESS;
406template <
typename T_RDOContainer>
408 [[maybe_unused]] std::size_t nClusterRDOs)
const
414template <
typename T_RDOContainer>
417 const EventContext& ctx,
418 const T_RDOContainer &rdoContainer,
420 unsigned int imodule,
422 unsigned int icluster,
424 std::any& cache)
const
430 calibData = calibDataHandle.
cptr();
434 return StatusCode::FAILURE;
449 auto* clusterVars = std::any_cast<xAOD::PixelCluster::ClusterVars> (&cache);
450 if (!clusterVars)
throw std::bad_any_cast();
453 if (!rdos_optional.has_value())
return StatusCode::FAILURE;
459 CellContainerProxy cellContainerProxy(&cellContainer);
460 ModuleProxy moduleProxy(cellContainerProxy[imodule]);
474 return StatusCode::SUCCESS;
477template <
typename T_RDOContainer>
478std::span<typename ActsTrk::RDOContainerTraits<T_RDOContainer>::IClusteringToolType::CellContainer::Cell>
491 typename IClusteringToolType::CellContainer::ModuleRangeGuard rangeGuard(cellContainer, RDOs.identifyHash() );
492 unsigned int rdo_i=0;
494 auto coordinates=rdo.coordinates(*
m_pixelID);
496 std::uint32_t fe = design.
getFE(si_param);
500 if (pixelDetElStatus.
isChipGood(rangeGuard.identifyHash(), fe)) {
501 cellContainer.emplace_back_cell(makeCellCoordinates(coordinates), rdo_i);
503 if ( check_ganged ) {
504 std::optional<std::array<std::int16_t,2> > gangedCoordinates = getGangedCoordinates(coordinates, design);
505 if (gangedCoordinates.has_value()) {
506 cellContainer.emplace_back_cell(*gangedCoordinates, rdo_i);
513 return rangeGuard.moduleCellSpan();
#define ATH_CHECK
Evaluate an expression and check for errors.
double charge(const T &p)
static const T_RDOContainer & range(const T_RDOContainer &rdo_container)
static std::optional< RDOCollectionAdapter > make(const T_RDOContainer &rdo_container, const IdentifierHash &id_hash)
const T * at(size_type n) const
Access an element, as an rvalue.
This is a "hash" representation of an Identifier.
value_type get_compact() const
Get the compact id.
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.
Class used to describe the design of a module (diode segmentation and readout scheme).
PixelDiodeTree::DiodeProxyWithPosition diodeProxyFromIdxCachePosition(const std::array< PixelDiodeTree::IndexType, 2 > &idx) const
virtual int numberOfConnectedCells(const SiReadoutCellId &readoutId) const
readout id -> id of connected diodes
PixelReadoutTechnology getReadoutTechnology() const
PixelDiodeTree::DiodeProxy diodeProxyFromIdx(const std::array< PixelDiodeTree::IndexType, 2 > &idx) const
virtual SiReadoutCellId readoutIdOfCell(const SiCellId &cellId) const
diode id -> readout id
static InDetDD::PixelDiodeType getDiodeType(const PixelDiodeTree::DiodeProxy &diode_proxy)
virtual SiCellId connectedCell(const SiReadoutCellId &readoutId, int number) const
readout id -> id of connected diodes.
static unsigned int getFE(const PixelDiodeTree::DiodeProxy &diode_proxy)
Identifier for the strip or pixel cell.
int phiIndex() const
Get phi index. Equivalent to strip().
int etaIndex() const
Get eta index.
Class to hold the SiDetectorElement objects to be put in the detector store.
Class to hold geometrical description of a silicon detector element.
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
Identifier for the strip or pixel readout cell.
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
virtual Identifier identify() const override final
identifier of this detector element (inline)
Trk::Surface & surface()
Element Surface.
bool isChipGood(IdentifierHash hash, unsigned int chip) const
bool isGood(IdentifierHash hash) const
unsigned int identifyHash() const
CalibrationStrategy getCalibrationStrategy(unsigned int moduleHash) const
float getCharge(InDetDD::PixelDiodeType type, unsigned int moduleHash, unsigned int FE, float ToT) const
This is an Identifier helper class for the Pixel subdetector.
const_pointer_type cptr()
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
void updateEndIndex(unsigned int obj_i, unsigned int elm_i)
unsigned int getBeginIndex(unsigned int obj_i) const
void setValue(unsigned int elm_i, T &&value)
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
void for_each_cluster(cell_collection_t &cells, func_t func)
call the given function for each cluster of a label sorted cell collection.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
PixelClusterContainer_v1 PixelClusterContainer
Define the version of the pixel cluster container.
Eigen::Map< MeasVector< N > > VectorMap
Eigen::Map< MeasMatrix< N > > MatrixMap
typename T_RDO_Container::base_value_type PerModuleRDOs
A diode proxy which caches the position of a diode.
double xPhiMax() const
for backward compatibility, return the position of the lower edge of the diode in local-y(phi,...
double xEtaMin() const
for backward compatibility, return the position of the lower edge of the diode in local-y(eta,...
double xPhiMin() const
for backward compatibility, return the position of the lower edge of the diode in local-x(phi,...
const Vector2D & position() const
get the cached position of this diode
double xEtaMax() const
for backward compatibility, return the position of the upper edge of the diode in local-y(eta,...
Helper class to access parameters of a diode.
xAOD::xAODInDetMeasurement::Utilities::JaggedVecEltCache< float > chargeList
xAOD::xAODInDetMeasurement::Utilities::JaggedVecEltCache< int > totList
xAOD::xAODInDetMeasurement::Utilities::JaggedVecEltCache< Identifier::value_type > rdoList