ATLAS Offline Software
HgtdTimedClusteringTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "Acts/Clusterization/TimedClusterization.hpp"
8 
9 
10 namespace Hgtd {
11  static inline int getCellRow(const Hgtd::UnpackedHgtdRDO& cell)
12  { return cell.ROW; }
13 
14  static inline int getCellColumn(const Hgtd::UnpackedHgtdRDO& cell)
15  { return cell.COL; }
16 
17  static inline double getCellTime(const Hgtd::UnpackedHgtdRDO& cell)
18  { return cell.TOA; }
19 
20  static inline void clusterAddCell(ActsTrk::HgtdTimedClusteringTool::Cluster& cl,
22  {
23  cl.ids.push_back(cell.ID);
24  cl.tots.push_back(cell.TOT);
25  cl.times.push_back(cell.TOA);
26  }
27 }
28 
29 
30 namespace ActsTrk {
32  const std::string& name,
33  const IInterface* parent)
34  : base_class(type, name, parent)
35  {}
36 
38  {
39  ATH_MSG_DEBUG("Initializing " << name() << "...");
40 
42  ATH_CHECK(detStore()->retrieve(m_hgtd_id, "HGTD_ID"));
43 
45 
46  return StatusCode::SUCCESS;
47  }
48 
50  const RawDataCollection& RDOs,
51  ClusterContainer& container) const
52  {
53  // Unpack RDOs (would need a proper function here)
55  cells.reserve(RDOs.size());
56  for (const HGTD_RDO* rdo : RDOs) {
57  Identifier id = rdo->identify();
58  cells.emplace_back(-1,
59  m_hgtd_id->phi_index(id),
60  m_hgtd_id->eta_index(id),
61  rdo->getTOA(),
62  rdo->getTOT(),
63  id);
64  }
65 
66  ATH_MSG_DEBUG("Clustering on " << RDOs.size() << " RDOs using time information");
67  Acts::Ccl::ClusteringData data;
69  Acts::Ccl::createClusters<CellCollection, ClusterCollection, 2>
70  (data, cells, clusters, Acts::Ccl::TimedConnect<Cell, 2ul>(m_timeTollerance.value(), m_addCorners.value()));
71  ATH_MSG_DEBUG(" \\_ " << clusters.size() << " clusters reconstructed");
72 
73  // Fast insertion trick
74  std::size_t previousSizeContainer = container.size();
75  std::vector<xAOD::HGTDCluster*> toAdd;
76  toAdd.reserve(clusters.size());
77  for (std::size_t i(0), n(clusters.size()); i < n; ++i)
78  toAdd.push_back( new xAOD::HGTDCluster() );
79  container.insert(container.end(), toAdd.begin(), toAdd.end());
80 
81  for (std::size_t i(0); i<clusters.size(); ++i) {
82  const typename HgtdTimedClusteringTool::Cluster& cluster = clusters[i];
83  ATH_CHECK(makeCluster(ctx, cluster, *container[previousSizeContainer+i]));
84  }
85 
86  return StatusCode::SUCCESS;
87  }
88 
89  StatusCode HgtdTimedClusteringTool::makeCluster(const EventContext& /*ctx*/,
90  const typename HgtdTimedClusteringTool::Cluster &cluster,
91  xAOD::HGTDCluster& xaodcluster) const
92  {
93  if (cluster.ids.empty()) return StatusCode::SUCCESS;
94 
95  InDetDD::SiLocalPosition pos_acc(0,0);
96  double tot_time = 0;
97 
98  for (size_t i = 0; i < cluster.ids.size(); i++) {
99  Identifier rdo_id = cluster.ids[i];
100 
102  InDetDD::SiCellId si_cell_id = element->cellIdFromIdentifier(rdo_id);
103  InDetDD::SiLocalPosition si_pos = element->design().localPositionOfCell(si_cell_id);
104 
105  pos_acc += si_pos;
106  tot_time += cluster.times[i];
107  }
108 
109  pos_acc /= cluster.ids.size();
110  tot_time /= cluster.ids.size();
111 
112  // Create the cluster
113  Eigen::Matrix<float, 3, 1> loc_pos(pos_acc.xPhi(), pos_acc.xEta(), tot_time);
114  Eigen::Matrix<float, 3, 3> cov_matrix= Eigen::Matrix<float, 3, 3>::Zero();
115 
116  constexpr float xWidth = 1.3;
117  constexpr float yWidth = 1.3;
118  cov_matrix(0,0) = xWidth * xWidth / 12 / cluster.ids.size(); // i.e. Cov XX
119  cov_matrix(1,1) = yWidth * yWidth / 12 / cluster.ids.size(); // i.e. Cov YY
120  constexpr float time_of_arrival_err = 0.035;
121  cov_matrix(2,2) = time_of_arrival_err * time_of_arrival_err / cluster.ids.size(); // i.e. Cov TT
122 
123  IdentifierHash id_hash = m_hgtd_det_mgr->getDetectorElement(cluster.ids.front())->identifyHash();
124 
125  // Fill
126  xaodcluster.setMeasurement<3>(id_hash,loc_pos,cov_matrix);
127  xaodcluster.setIdentifier(cluster.ids.front().get_compact());
128  xaodcluster.setRDOlist(std::move(cluster.ids));
129  xaodcluster.setToTlist(std::move(cluster.tots));
130 
131  return StatusCode::SUCCESS;
132  }
133 
134 } // namespace
135 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ActsTrk::HgtdTimedClusteringTool::m_hgtd_id
const HGTD_ID * m_hgtd_id
Definition: HgtdTimedClusteringTool.h:65
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:281
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
ActsTrk::HgtdTimedClusteringTool::HgtdTimedClusteringTool
HgtdTimedClusteringTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: HgtdTimedClusteringTool.cxx:31
InDetDD::HGTD_DetectorElement::cellIdFromIdentifier
SiCellId cellIdFromIdentifier(const Identifier &identifier) const override final
SiCellId from Identifier.
Definition: HGTD_DetectorElement.cxx:51
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
ActsTrk::HgtdTimedClusteringTool::Cluster::tots
std::vector< int > tots
Definition: HgtdTimedClusteringTool.h:38
ActsTrk::HgtdTimedClusteringTool::clusterize
virtual StatusCode clusterize(const EventContext &ctx, const RawDataCollection &RDOs, ClusterContainer &container) const override
Definition: HgtdTimedClusteringTool.cxx:49
ActsTrk::HgtdTimedClusteringTool::Cluster
Definition: HgtdTimedClusteringTool.h:36
InDetDD::HGTD_ModuleDesign::localPositionOfCell
virtual SiLocalPosition localPositionOfCell(const SiCellId &cellId) const
readout or diode id -> position.
Definition: HGTD_ModuleDesign.cxx:145
ActsTrk::HgtdTimedClusteringTool::m_addCorners
Gaudi::Property< bool > m_addCorners
Definition: HgtdTimedClusteringTool.h:68
xAOD::HGTDCluster_v1::setRDOlist
void setRDOlist(const std::vector< Identifier > &rdolist)
Sets the list of identifiers of the channels building the cluster.
Definition: HGTDCluster_v1.cxx:15
InDetDD::HGTD_DetectorElement
Definition: HGTD_DetectorElement.h:40
ActsTrk::HgtdTimedClusteringTool::m_hgtd_det_mgr
const HGTD_DetectorManager * m_hgtd_det_mgr
Definition: HgtdTimedClusteringTool.h:64
HGTD_ID::eta_index
int eta_index(const Identifier &id) const
Definition: HGTD_ID.h:503
HgtdTimedClusteringTool.h
xAOD::HGTDCluster_v1
Definition: HGTDCluster_v1.h:23
HGTD_RDO
Definition: HGTD_RDO.h:53
Hgtd
Definition: HgtdTimedClusteringTool.cxx:10
ActsTrk::HgtdTimedClusteringTool::initialize
virtual StatusCode initialize() override
Definition: HgtdTimedClusteringTool.cxx:37
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
InDetDD::SolidStateDetectorElementBase::identifyHash
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
InDetDD::HGTD_DetectorElement::design
const HGTD_ModuleDesign & design() const override final
access to the local description:
Definition: HGTD_DetectorElement.h:121
InDetDD::SiLocalPosition
Definition: SiLocalPosition.h:31
InDetDD::SiLocalPosition::xPhi
double xPhi() const
position along phi direction:
Definition: SiLocalPosition.h:123
HGTD_ID::phi_index
int phi_index(const Identifier &id) const
Definition: HGTD_ID.h:496
ActsTrk::HgtdTimedClusteringTool::ClusterCollection
std::vector< Cluster > ClusterCollection
Definition: HgtdTimedClusteringTool.h:44
xAOD::UncalibratedMeasurement_v1::setIdentifier
void setIdentifier(const DetectorIdentType measId)
Sets the full Identifier of the measurement.
HGTD_DetectorManager::getDetectorElement
const InDetDD::HGTD_DetectorElement * getDetectorElement(const Identifier &id) const
access to individual elements : via Identifier
Definition: HGTD_DetectorManager.cxx:50
lumiFormat.i
int i
Definition: lumiFormat.py:85
ActsTrk::HgtdTimedClusteringTool::CellCollection
std::vector< Cell > CellCollection
Definition: HgtdTimedClusteringTool.h:43
InDetDD::SiLocalPosition::xEta
double xEta() const
position along eta direction:
Definition: SiLocalPosition.h:118
beamspotman.n
n
Definition: beamspotman.py:729
ActsTrk::HgtdTimedClusteringTool::m_timeTollerance
Gaudi::Property< double > m_timeTollerance
Definition: HgtdTimedClusteringTool.h:67
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ActsTrk::HgtdTimedClusteringTool::Cluster::ids
std::vector< Identifier > ids
Definition: HgtdTimedClusteringTool.h:37
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::HGTDCluster_v1::setToTlist
void setToTlist(const std::vector< int > &tots)
Sets the list of ToT of the channels building the cluster.
DeMoUpdate.toAdd
bool toAdd
Definition: DeMoUpdate.py:1304
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActsTrk::HgtdTimedClusteringTool::makeCluster
StatusCode makeCluster(const EventContext &ctx, const typename HgtdTimedClusteringTool::Cluster &cluster, xAOD::HGTDCluster &xaodcluster) const
Definition: HgtdTimedClusteringTool.cxx:89
InDetDD::SiCellId
Definition: SiCellId.h:29
xAOD::UncalibratedMeasurement_v1::setMeasurement
void setMeasurement(const DetectorIDHashType idHash, MeasVector< N > locPos, MeasMatrix< N > locCov)
Sets IdentifierHash, local position and local covariance of the measurement.
HGTD_ModuleDesign.h
Hgtd::UnpackedHgtdRDO
Definition: HgtdTimedClusteringTool.h:17
ActsTrk::HgtdTimedClusteringTool::Cluster::times
std::vector< double > times
Definition: HgtdTimedClusteringTool.h:39
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MSTrackingVolumeBuilder.cxx:24
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:25
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
Identifier
Definition: IdentifierFieldParser.cxx:14