30using CLHEP::micrometer;
34 template <
typename T1,
typename T2>
35 T1 check_integer_cast(T2
a) {
36 assert( std::in_range<T1>(
a) );
37 return static_cast<T1
>(
a);
44 template <
typename IndexType>
45 inline std::optional<std::array<std::int16_t,2> >
46 getGangedCoordinates(
const std::array<IndexType,2> &coordinates,
50 InDetDD::SiCellId cellId(check_integer_cast<int>(coordinates[0]),check_integer_cast<int>(coordinates[1]));
54 return std::array<std::int16_t,2>{
static_cast<std::int16_t
>(gangedCellId.
phiIndex()),
55 static_cast<std::int16_t
>(gangedCellId.
etaIndex())};
61 std::array<std::int16_t,2>
62 makeCellCoordinates(
const std::array<InDetDD::PixelDiodeTree::CellIndexType,2> &diode_idx) {
63 return std::array<std::int16_t,2>{
64 check_integer_cast<std::int16_t>(diode_idx[0]),
65 check_integer_cast<std::int16_t>(diode_idx[1])};
68 const std::array<InDetDD::PixelDiodeTree::CellIndexType,2> &
69 makeDiodeIdx(
const std::array<InDetDD::PixelDiodeTree::CellIndexType,2> &diode_idx) {
74 std::array<std::int16_t,2>
75 makeCellCoordinates(
const std::array<std::int16_t,2> &diode_idx) {
79 std::array<InDetDD::PixelDiodeTree::CellIndexType,2>
80 makeDiodeIdx(
const std::array<std::int16_t,2> &diode_idx) {
81 return std::array<InDetDD::PixelDiodeTree::CellIndexType,2>{
82 check_integer_cast<InDetDD::PixelDiodeTree::CellIndexType>(diode_idx[0]),
83 check_integer_cast<InDetDD::PixelDiodeTree::CellIndexType>(diode_idx[1])};
90template <
typename T_RDOContainer>
110 return StatusCode::SUCCESS;
113template <
typename T_RDOContainer>
115 const std::string&
type,
const std::string& name,
const IInterface* parent)
120template <
typename T_RDOContainer>
121template <
bool GANGED>
122std::pair<unsigned int, unsigned int>
124 const std::vector<IdentifierHash> &listOfIds,
131 unsigned int n_hits = RDOs.size();
132 if constexpr(GANGED) {
133 assert(elements.at(RDOs.identifyHash()));
136 if (isFEI3(design)) {
138 if (rdo.isGanged(design, *pixelID)) {
146 unsigned int n_hits=0u;
147 if (listOfIds.empty()) {
149 assert( RDOs.isValid());
150 n_hits += getNHits(*RDOs, detector_elements,
m_pixelID);
155 if (not
id.is_valid())
continue;
157 if (RDOs.has_value()) {
158 n_hits += getNHits(*(RDOs.value()), detector_elements,
m_pixelID);
166 return {n_hits,n_hits};
169template <
typename T_RDOContainer>
170std::pair<unsigned int, unsigned int>
172 const std::vector<IdentifierHash> &listOfIds,
182template <
typename T_RDOContainer>
191 const double lorentzShift,
218 std::optional<Identifier::value_type> first_rdo_id;
219 int cluster_lvl1min = std::numeric_limits<int>::max();
220 float totalCharge = 0.f;
223 for (CellProxy cellProxy : cluster) {
233 assert(cellProxy.srcIndex() < rdos.size());
236 if constexpr(std::is_same_v<T_RDOContainer, PhaseIIPixelRawDataContainer>) {
237 assert( rdo.index() >= rdos.beginIndex() && rdo.index() < rdos.endIndex() );
241 if (!first_rdo_id.has_value()) {
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()) );
248 const int tot = rdo.getToT();
251 std::array<InDetDD::PixelDiodeTree::CellIndexType,2> diode_idx
253 cellProxy.coordinates()[1]);
259 std::uint32_t feValue = design.
getFE(si_param);
265 return StatusCode::FAILURE;
281 charge = tot/8.0*(8000.0-1200.0)+1200.0;
295 rowmax_diode = si_param;
299 rowmin_diode = si_param;
303 colmax_diode = si_param;
307 colmin_diode = si_param;
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;
330 assert(std::in_range<int>(diffCol));
331 assert(std::in_range<int>(diffRow));
332 const int colWidth =
static_cast<int>(diffCol);
333 const int rowWidth =
static_cast<int>(diffRow);
335 double etaWidth = colmax_diode.
xEtaMax() - colmin_diode.
xEtaMin();
336 double phiWidth = rowmax_diode.
xPhiMax() - rowmin_diode.
xPhiMin();
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)};
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]);
351 float width0, width1;
358 width0 = phiWidth / rowWidth;
359 width1 = etaWidth / colWidth;
364 Eigen::Matrix<float,2,1> localPosition(locpos.x(), locpos.y());
365 Eigen::Matrix<float,2,2> localCovariance = Eigen::Matrix<float,2,2>::Zero();
366 localCovariance(0, 0) = width0 * width0 / 12.0f;
367 localCovariance(1, 1) = width1 * width1 / 12.0f;
369 clusterVars.identifierHash[icluster] = idHash;
371 xAOD::MatrixMap<2>(clusterVars.localCovarianceDim2[icluster].data()) = localCovariance;
372 assert( first_rdo_id.has_value());
373 clusterVars.identifier[icluster] = *first_rdo_id;
375 xAOD::VectorMap<3>(clusterVars.globalPosition[icluster].data()) = globalPos.cast<
float>();
378 clusterVars.totalCharge[icluster] = totalCharge;
379 clusterVars.lvl1a[icluster] = cluster_lvl1min;
380 clusterVars.channelsInPhi[icluster] = rowWidth;
381 clusterVars.channelsInEta[icluster] = colWidth;
382 clusterVars.widthInEta[icluster] = etaWidth;
384 return StatusCode::SUCCESS;
387template <
typename T_RDOContainer>
396 typename IClusteringToolType::CellContainer::ModuleRangeGuard rangeGuard(cellContainer.startNewModule(idHash));
397 if ( pixelDetElStatus.
isGood(idHash) ) {
399 std::span<typename IClusteringToolType::CellContainer::Cell>
400 cellRange =
unpackRDOs(RDOs, pixelDetElStatus, element, cellContainer);
402 static constexpr unsigned int SORT_BY_LOCAL_X=0u;
404 CL::clusterize<SORT_BY_LOCAL_X, std::uint16_t>(cellRange,
405 CL::defaultConnectionHelper<CL::EConnectionType::CommonEdgeOrCorner>(cellRange));
408 [&cellContainer](std::span<typename IClusteringToolType::CellContainer::Cell> &,
409 unsigned int idx_begin,
410 unsigned int idx_end) {
411 cellContainer.registerNewCluster(idx_begin,idx_end);
416 cellContainer.registerClustersForNewModule(rangeGuard.range());
418 return StatusCode::SUCCESS;
422template <
typename T_RDOContainer>
424 [[maybe_unused]] std::size_t nClusterRDOs)
const
430template <
typename T_RDOContainer>
433 const EventContext& ctx,
434 const T_RDOContainer &rdoContainer,
436 unsigned int imodule,
438 unsigned int icluster,
440 std::any& cache)
const
446 calibData = calibDataHandle.
cptr();
450 return StatusCode::FAILURE;
465 auto* clusterVars = std::any_cast<xAOD::PixelCluster::ClusterVars> (&cache);
466 if (!clusterVars)
throw std::bad_any_cast();
469 if (!rdos_optional.has_value())
return StatusCode::FAILURE;
475 CellContainerProxy cellContainerProxy(&cellContainer);
476 ModuleProxy moduleProxy(cellContainerProxy[imodule]);
490 return StatusCode::SUCCESS;
493template <
typename T_RDOContainer>
494std::span<typename ActsTrk::RDOContainerTraits<T_RDOContainer>::IClusteringToolType::CellContainer::Cell>
507 typename IClusteringToolType::CellContainer::ModuleRangeGuard rangeGuard(cellContainer, RDOs.identifyHash() );
508 unsigned int rdo_i=0;
510 auto coordinates=rdo.coordinates(*
m_pixelID);
512 std::uint32_t fe = design.
getFE(si_param);
516 if (pixelDetElStatus.
isChipGood(rangeGuard.identifyHash(), fe)) {
517 cellContainer.emplace_back_cell(makeCellCoordinates(coordinates), rdo_i);
519 if ( check_ganged ) {
520 std::optional<std::array<std::int16_t,2> > gangedCoordinates = getGangedCoordinates(coordinates, design);
521 if (gangedCoordinates.has_value()) {
522 cellContainer.emplace_back_cell(*gangedCoordinates, rdo_i);
529 return rangeGuard.moduleCellSpan();
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
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)
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()
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
Tell the compiler to optimize assuming that FP may trap.
#define CXXUTILS_TRAPPING_FP