ATLAS Offline Software
SinglePadClusterTool.cxx
Go to the documentation of this file.
1 
11 #include "SinglePadClusterTool.h"
12 
14 
15 namespace HGTD {
16 
18  const std::string& name,
19  const IInterface* parent)
20  : base_class(type, name, parent) {}
21 
23 
25 
26  ATH_CHECK(m_cluster_maker.retrieve());
27 
29 
30  return StatusCode::SUCCESS;
31 }
32 
33 std::unique_ptr<HGTD_ClusterCollection>
35  DataPool<HGTD_Cluster>* dataItemsPool) const {
36 
37  Identifier identifier = rdo_coll.identify();
38  IdentifierHash id_hash = rdo_coll.identifierHash();
39 
40  std::unique_ptr<HGTD_ClusterCollection> cluster_collection =
41  std::make_unique<HGTD_ClusterCollection>(id_hash);
42 
43  if(dataItemsPool){
44  cluster_collection->clear(SG::VIEW_ELEMENTS);
45  }
46 
47  cluster_collection->setIdentifier(identifier);
48  cluster_collection->reserve(rdo_coll.size());
49 
52 
53  for (const auto *const rdo : rdo_coll) {
54 
55  Identifier rdo_id = rdo->identify();
56  ATH_MSG_DEBUG("Using RDO: " << rdo_id);
57 
58  // get the local position from the detector design
59  InDetDD::SiCellId si_cell_id = element->cellIdFromIdentifier(rdo_id);
60  const InDetDD::HGTD_ModuleDesign& det_design = element->design();
62  det_design.localPositionOfCell(si_cell_id);
63  Amg::Vector2D loc_pos(si_pos.xPhi(), si_pos.xEta());
64  ATH_MSG_DEBUG("Local position: x=" << loc_pos.x() << " y=" << loc_pos.y());
65 
66  // a cluster consists only of the pad itself
67  std::vector<Identifier> rdo_list = {rdo_id};
68 
69  // From SiWidth header:
70  // Constructor with parameters: <col, row> in units of RDOs (so should be
71  // int),
72  // <phiR width in mm, Z width in mm>
73  // NOTE: without a clustering of the pads, the width of each "cluster" is 1
74  // in col and row direction
75  int col_width = 1;
76  int row_width = 1;
77  //FIXME there is a bug in the detector design! should not be hardcoded here
78  // double eta_width = det_design.etaPitch();
79  // double phi_width = det_design.phiPitch();
80  double eta_width = 1.3;
81  double phi_width = 1.3;
82  ATH_MSG_DEBUG("eta_width=" << eta_width << " phi_width=" << phi_width);
83 
84  InDet::SiWidth si_width(Amg::Vector2D(col_width, row_width),
85  Amg::Vector2D(phi_width, eta_width));
86 
87  // retrieve the time of arrival
88  float time_of_arrival = rdo->getTOA();
89 
90  // this would hold the vector of all cluster components. Only size 1 if RDO
91  // gets transformed to cluster directly
92  std::vector<int> time_over_threshold = {static_cast<int>(rdo->getTOT())};
93 
94  HGTD_Cluster* cluster = nullptr;
95  if (dataItemsPool) {
96  // data Item pool owns the element. The collection
97  // is view. Just move assign to it.
98  cluster = dataItemsPool->nextElementPtr();
99  } else {
100  // collection will own the element release
101  cluster = new HGTD_Cluster();
102  }
103  (*cluster) = m_cluster_maker->createCluster(
104  rdo_id,
105  loc_pos,
106  std::move(rdo_list),
107  si_width,
108  element,
109  time_of_arrival,
110  std::move(time_over_threshold));
111 
112  cluster->setHashAndIndex(cluster_collection->identifyHash(),
113  cluster_collection->size());
114 
115  cluster_collection->push_back(cluster);
116  }
117  return cluster_collection;
118 }
119 
120 } // namespace HGTD
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SinglePadClusterTool.h
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration.
InDetDD::HGTD_DetectorElement::cellIdFromIdentifier
SiCellId cellIdFromIdentifier(const Identifier &identifier) const override final
SiCellId from Identifier.
Definition: HGTD_DetectorElement.cxx:51
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
initialize
void initialize()
Definition: run_EoverP.cxx:894
InDetDD::HGTD_ModuleDesign::localPositionOfCell
virtual SiLocalPosition localPositionOfCell(const SiCellId &cellId) const
readout or diode id -> position.
Definition: HGTD_ModuleDesign.cxx:145
InDetDD::HGTD_DetectorElement
Definition: HGTD_DetectorElement.h:40
xAOD::identifier
identifier
Definition: UncalibratedMeasurement_v1.cxx:15
HGTD::SinglePadClusterTool::SinglePadClusterTool
SinglePadClusterTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SinglePadClusterTool.cxx:17
InDetDD::HGTD_DetectorElement::design
const HGTD_ModuleDesign & design() const override final
access to the local description:
Definition: HGTD_DetectorElement.h:121
HGTD_RDO_Collection
Definition: HGTD_RDO_Collection.h:19
HGTD_Cluster
Definition: HGTD_Cluster.h:35
InDetDD::SiLocalPosition
Definition: SiLocalPosition.h:31
InDetDD::SiLocalPosition::xPhi
double xPhi() const
position along phi direction:
Definition: SiLocalPosition.h:123
HGTD::SinglePadClusterTool::m_cluster_maker
ToolHandle< HGTD_ClusterMakerTool > m_cluster_maker
Definition: SinglePadClusterTool.h:41
HGTD
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
Definition: Clustering.h:28
InDetDD::SiLocalPosition::xEta
double xEta() const
position along eta direction:
Definition: SiLocalPosition.h:118
Trk::PrepRawData::setHashAndIndex
void setHashAndIndex(unsigned short collHash, unsigned short objIndex)
TEMP for testing: might make some classes friends later ...
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
Trk::PrepRawDataCollection::identifyHash
virtual IdentifierHash identifyHash() const override final
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataPool::nextElementPtr
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
DataVector::clear
void clear()
Erase all the elements in the collection.
HGTD::SinglePadClusterTool::initialize
virtual StatusCode initialize() override final
Definition: SinglePadClusterTool.cxx:22
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
HGTD_RDO_Collection::identifierHash
const IdentifierHash & identifierHash() const
Definition: HGTD_RDO_Collection.h:31
HGTD::SinglePadClusterTool::clusterize
virtual std::unique_ptr< HGTD_ClusterCollection > clusterize(const HGTD_RDO_Collection &rdo_coll, DataPool< HGTD_Cluster > *dataItemsPool) const override final
Definition: SinglePadClusterTool.cxx:34
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
InDetDD::SiCellId
Definition: SiCellId.h:29
HGTD_DetectorManager::getDetectorElement
InDetDD::HGTD_DetectorElement * getDetectorElement(const Identifier &id) const
access to individual elements : via Identifier
Definition: HGTD_DetectorManager.cxx:57
HGTD_ModuleDesign.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
HGTD::SinglePadClusterTool::m_hgtd_det_mgr
const HGTD_DetectorManager * m_hgtd_det_mgr
Definition: SinglePadClusterTool.h:42
InDet::SiWidth
Definition: SiWidth.h:25
DataPool
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
Definition: DataPool.h:47
InDetDD::HGTD_ModuleDesign
Definition: HGTD_ModuleDesign.h:43
HGTD_RDO_Collection::identify
const Identifier & identify() const
Definition: HGTD_RDO_Collection.h:32
IdentifierHash
Definition: IdentifierHash.h:38
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
Trk::PrepRawDataCollection::setIdentifier
void setIdentifier(Identifier id)