28using CLHEP::micrometer;
32 template <
typename T1,
typename T2>
33 T1 check_integer_cast(T2
a) {
34 assert( std::in_range<T1>(
a) );
35 return static_cast<T1
>(
a);
42 template <
typename IndexType>
43 inline std::optional<std::array<std::int16_t,2> >
44 getGangedCoordinates(
const std::array<IndexType,2> &coordinates,
48 InDetDD::SiCellId cellId(check_integer_cast<int>(coordinates[0]),check_integer_cast<int>(coordinates[1]));
52 return std::array<std::int16_t,2>{
static_cast<std::int16_t
>(gangedCellId.
phiIndex()),
53 static_cast<std::int16_t
>(gangedCellId.
etaIndex())};
59 std::array<std::int16_t,2>
60 makeCellCoordinates(
const std::array<InDetDD::PixelDiodeTree::CellIndexType,2> &diode_idx) {
61 return std::array<std::int16_t,2>{
62 check_integer_cast<std::int16_t>(diode_idx[0]),
63 check_integer_cast<std::int16_t>(diode_idx[1])};
66 const std::array<InDetDD::PixelDiodeTree::CellIndexType,2> &
67 makeDiodeIdx(
const std::array<InDetDD::PixelDiodeTree::CellIndexType,2> &diode_idx) {
72 std::array<std::int16_t,2>
73 makeCellCoordinates(
const std::array<std::int16_t,2> &diode_idx) {
77 std::array<InDetDD::PixelDiodeTree::CellIndexType,2>
78 makeDiodeIdx(
const std::array<std::int16_t,2> &diode_idx) {
79 return std::array<InDetDD::PixelDiodeTree::CellIndexType,2>{
80 check_integer_cast<InDetDD::PixelDiodeTree::CellIndexType>(diode_idx[0]),
81 check_integer_cast<InDetDD::PixelDiodeTree::CellIndexType>(diode_idx[1])};
88template <
typename T_RDOContainer>
108 return StatusCode::SUCCESS;
111template <
typename T_RDOContainer>
113 const std::string&
type,
const std::string& name,
const IInterface* parent)
118template <
typename T_RDOContainer>
119template <
bool GANGED>
120std::pair<unsigned int, unsigned int>
122 const std::vector<IdentifierHash> &listOfIds,
129 unsigned int n_hits = RDOs.size();
130 if constexpr(GANGED) {
131 assert(detector_elements.
at(RDOs.identifyHash()));
134 if (isFEI3(design)) {
136 if (rdo.isGanged(design, *pixelID)) {
144 unsigned int n_hits=0u;
145 if (listOfIds.empty()) {
147 assert( RDOs.isValid());
148 n_hits += getNHits(*RDOs, detector_elements,
m_pixelID);
153 if (not
id.is_valid())
continue;
155 if (RDOs.has_value()) {
156 n_hits += getNHits(*(RDOs.value()), detector_elements,
m_pixelID);
164 return {n_hits,n_hits};
167template <
typename T_RDOContainer>
168std::pair<unsigned int, unsigned int>
170 const std::vector<IdentifierHash> &listOfIds,
180template <
typename T_RDOContainer>
189 const double lorentzShift,
213 std::optional<Identifier::value_type> first_rdo_id;
214 int cluster_lvl1min = std::numeric_limits<int>::max();
215 float totalCharge = 0.f;
218 for (CellProxy cellProxy : cluster) {
228 assert(cellProxy.srcIndex() < rdos.size());
231 if constexpr(std::is_same_v<T_RDOContainer, PhaseIIPixelRawDataContainer>) {
232 assert( rdo.index() >= rdos.beginIndex() && rdo.index() < rdos.endIndex() );
236 if (!first_rdo_id.has_value()) {
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()) );
243 const int tot = rdo.getToT();
246 std::array<InDetDD::PixelDiodeTree::CellIndexType,2> diode_idx
248 cellProxy.coordinates()[1]);
254 std::uint32_t feValue = design.
getFE(si_param);
260 return StatusCode::FAILURE;
276 charge = tot/8.0*(8000.0-1200.0)+1200.0;
290 rowmax_diode = si_param;
294 rowmin_diode = si_param;
298 colmax_diode = si_param;
302 colmin_diode = si_param;
324 const int colWidth = colmax - colmin + 1;
325 const int rowWidth = rowmax - rowmin + 1;
327 double etaWidth = colmax_diode.
xEtaMax() - colmin_diode.
xEtaMin();
328 double phiWidth = rowmax_diode.
xPhiMax() - rowmin_diode.
xPhiMin();
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)};
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]);
343 float width0, width1;
350 width0 = phiWidth / rowWidth;
351 width1 = etaWidth / colWidth;
356 Eigen::Matrix<float,2,1> localPosition(locpos.x(), locpos.y());
357 Eigen::Matrix<float,2,2> localCovariance = Eigen::Matrix<float,2,2>::Zero();
358 localCovariance(0, 0) = width0 * width0 / 12.0f;
359 localCovariance(1, 1) = width1 * width1 / 12.0f;
361 clusterVars.identifierHash[icluster] = idHash;
363 xAOD::MatrixMap<2>(clusterVars.localCovarianceDim2[icluster].data()) = localCovariance;
364 assert( first_rdo_id.has_value());
365 clusterVars.identifier[icluster] = *first_rdo_id;
367 xAOD::VectorMap<3>(clusterVars.globalPosition[icluster].data()) = globalPos.cast<
float>();
370 clusterVars.totalCharge[icluster] = totalCharge;
371 clusterVars.lvl1a[icluster] = cluster_lvl1min;
372 clusterVars.channelsInPhi[icluster] = rowWidth;
373 clusterVars.channelsInEta[icluster] = colWidth;
374 clusterVars.widthInEta[icluster] = etaWidth;
376 return StatusCode::SUCCESS;
379template <
typename T_RDOContainer>
388 typename IClusteringToolType::CellContainer::ModuleRangeGuard rangeGuard(cellContainer.startNewModule(idHash));
389 if ( pixelDetElStatus.
isGood(idHash) ) {
391 std::span<typename IClusteringToolType::CellContainer::Cell>
392 cellRange =
unpackRDOs(RDOs, pixelDetElStatus, element, cellContainer);
394 static constexpr unsigned int SORT_BY_LOCAL_X=0u;
396 CL::clusterize<SORT_BY_LOCAL_X, std::uint16_t>(cellRange,
397 CL::defaultConnectionHelper<CL::EConnectionType::CommonEdgeOrCorner>(cellRange));
400 [&cellContainer](std::span<typename IClusteringToolType::CellContainer::Cell> &,
401 unsigned int idx_begin,
402 unsigned int idx_end) {
403 cellContainer.registerNewCluster(idx_begin,idx_end);
408 cellContainer.registerClustersForNewModule(rangeGuard.range());
410 return StatusCode::SUCCESS;
414template <
typename T_RDOContainer>
416 [[maybe_unused]] std::size_t nClusterRDOs)
const
422template <
typename T_RDOContainer>
425 const EventContext& ctx,
426 const T_RDOContainer &rdoContainer,
428 unsigned int imodule,
430 unsigned int icluster,
432 std::any& cache)
const
438 calibData = calibDataHandle.
cptr();
442 return StatusCode::FAILURE;
457 auto* clusterVars = std::any_cast<xAOD::PixelCluster::ClusterVars> (&cache);
458 if (!clusterVars)
throw std::bad_any_cast();
461 if (!rdos_optional.has_value())
return StatusCode::FAILURE;
467 CellContainerProxy cellContainerProxy(&cellContainer);
468 ModuleProxy moduleProxy(cellContainerProxy[imodule]);
482 return StatusCode::SUCCESS;
485template <
typename T_RDOContainer>
486std::span<typename ActsTrk::RDOContainerTraits<T_RDOContainer>::IClusteringToolType::CellContainer::Cell>
499 typename IClusteringToolType::CellContainer::ModuleRangeGuard rangeGuard(cellContainer, RDOs.identifyHash() );
500 unsigned int rdo_i=0;
502 auto coordinates=rdo.coordinates(*
m_pixelID);
504 std::uint32_t fe = design.
getFE(si_param);
508 if (pixelDetElStatus.
isChipGood(rangeGuard.identifyHash(), fe)) {
509 cellContainer.emplace_back_cell(makeCellCoordinates(coordinates), rdo_i);
511 if ( check_ganged ) {
512 std::optional<std::array<std::int16_t,2> > gangedCoordinates = getGangedCoordinates(coordinates, design);
513 if (gangedCoordinates.has_value()) {
514 cellContainer.emplace_back_cell(*gangedCoordinates, rdo_i);
521 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
Tell the compiler to optimize assuming that FP may trap.
#define CXXUTILS_TRAPPING_FP