ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ActsTrk::PixelClusteringTool Class Reference

#include <PixelClusteringTool.h>

Inheritance diagram for ActsTrk::PixelClusteringTool:
Collaboration diagram for ActsTrk::PixelClusteringTool:

Classes

struct  Cluster
 

Public Types

using Cell = InDet::UnpackedPixelRDO
 
using CellCollection = std::vector< Cell >
 
using ClusterCollection = std::vector< Cluster >
 

Public Member Functions

 PixelClusteringTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual StatusCode clusterize (const InDetRawDataCollection< PixelRDORawData > &RDOs, const PixelID &pixelID, const EventContext &ctx, xAOD::PixelClusterContainer &container) const override
 
virtual StatusCode initialize () override
 

Private Member Functions

StatusCode makeCluster (const EventContext &ctx, const PixelClusteringTool::Cluster &cluster, const PixelID &pixelID, const InDetDD::SiDetectorElement *element, xAOD::PixelCluster &container) const
 

Private Attributes

ServiceHandle< InDetDD::IPixelReadoutManagerm_pixelReadout
 
ToolHandle< InDet::PixelRDOToolm_pixelRDOTool {this, "PixelRDOTool", "", "The Pixel RDO tool"}
 
ToolHandle< ISiLorentzAngleToolm_pixelLorentzAngleTool {this, "PixelLorentzAngleTool", "", "Tool to retreive Lorentz angle of Pixel"}
 
SG::ReadCondHandleKey< PixelChargeCalibCondDatam_chargeDataKey
 
Gaudi::Property< bool > m_addCorners {this, "AddCorners", true}
 
Gaudi::Property< bool > m_useWeightedPos {this, "UseWeightedPosition", true}
 
Gaudi::Property< bool > m_broadErrors {this, "UseBroadErrors", false}
 

Detailed Description

Definition at line 47 of file PixelClusteringTool.h.

Member Typedef Documentation

◆ Cell

Definition at line 50 of file PixelClusteringTool.h.

◆ CellCollection

Definition at line 51 of file PixelClusteringTool.h.

◆ ClusterCollection

Definition at line 62 of file PixelClusteringTool.h.

Constructor & Destructor Documentation

◆ PixelClusteringTool()

ActsTrk::PixelClusteringTool::PixelClusteringTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 43 of file PixelClusteringTool.cxx.

45  : base_class(type,name,parent)
46 {}

Member Function Documentation

◆ clusterize()

StatusCode ActsTrk::PixelClusteringTool::clusterize ( const InDetRawDataCollection< PixelRDORawData > &  RDOs,
const PixelID pixelID,
const EventContext &  ctx,
xAOD::PixelClusterContainer container 
) const
overridevirtual

Definition at line 224 of file PixelClusteringTool.cxx.

228 {
229  const InDetDD::SiDetectorElement* element = m_pixelRDOTool->checkCollection(RDOs, ctx);
230  if (element == nullptr)
231  return StatusCode::FAILURE;
232 
233  std::vector<InDet::UnpackedPixelRDO> cells =
234  m_pixelRDOTool->getUnpackedPixelRDOs(RDOs, pixelID, element, ctx);
235 
237  Acts::Ccl::createClusters<CellCollection, ClusterCollection, 2>
238  (cells, Acts::Ccl::DefaultConnect<Cell, 2>(m_addCorners));
239 
240  std::size_t previousSizeContainer = container.size();
241  // Fast insertion trick
242  std::vector<xAOD::PixelCluster*> toAddCollection;
243  toAddCollection.reserve(clusters.size());
244  for (std::size_t i(0); i<clusters.size(); ++i)
245  toAddCollection.push_back(new xAOD::PixelCluster());
246  container.insert(container.end(), toAddCollection.begin(), toAddCollection.end());
247 
248  for (std::size_t i(0); i<clusters.size(); ++i) {
249  const Cluster& cluster = clusters[i];
250  ATH_CHECK(makeCluster(ctx, cluster, pixelID, element, *container[previousSizeContainer+i]));
251  }
252 
253  return StatusCode::SUCCESS;
254 }

◆ initialize()

StatusCode ActsTrk::PixelClusteringTool::initialize ( )
overridevirtual

Definition at line 30 of file PixelClusteringTool.cxx.

31 {
32  ATH_MSG_DEBUG("Initializing " << name() << " ...");
33  ATH_CHECK(m_pixelRDOTool.retrieve());
35  if (not m_chargeDataKey.empty()) ATH_CHECK(m_pixelReadout.retrieve());
36 
38 
39  ATH_MSG_DEBUG(name() << " successfully initialized");
40  return StatusCode::SUCCESS;
41 }

◆ makeCluster()

StatusCode ActsTrk::PixelClusteringTool::makeCluster ( const EventContext &  ctx,
const PixelClusteringTool::Cluster cluster,
const PixelID pixelID,
const InDetDD::SiDetectorElement element,
xAOD::PixelCluster container 
) const
private

Definition at line 49 of file PixelClusteringTool.cxx.

54 {
55  const PixelChargeCalibCondData *calibData = nullptr;
56  if (not m_chargeDataKey.empty()) {
58  calibData = calibDataHandle.cptr();
59  }
60 
61  const InDetDD::PixelModuleDesign& design =
62  dynamic_cast<const InDetDD::PixelModuleDesign&>(element->design());
63 
64  InDetDD::SiLocalPosition pos_acc(0,0);
65  int tot_acc = 0;
66 
67  std::vector<float> chargeList;
68  if (calibData) chargeList.reserve(cluster.ids.size());
69 
70  int colmax = std::numeric_limits<int>::min();
71  int rowmax = std::numeric_limits<int>::min();
72  int colmin = std::numeric_limits<int>::max();
73  int rowmin = std::numeric_limits<int>::max();
74 
75  float qRowMin = 0.f;
76  float qRowMax = 0.f;
77  float qColMin = 0.f;
78  float qColMax = 0.f;
79 
80  bool hasGanged = false;
81 
82  for (size_t i = 0; i < cluster.ids.size(); i++) {
83  Identifier id = cluster.ids.at(i);
84  hasGanged = hasGanged ||
85  m_pixelRDOTool->isGanged(id, element).has_value();
86 
87  int tot = cluster.tots.at(i);
88  float charge = tot;
89 
90  if (calibData) {
91  Identifier moduleID = pixelID.wafer_id(id);
92  IdentifierHash moduleHash = pixelID.wafer_hash(moduleID);
93  charge = calibData->getCharge(m_pixelReadout->getDiodeType(id),
94  moduleHash,
95  m_pixelReadout->getFE(id, moduleID),
96  tot);
97 
98  // These numbers are taken from the Cluster Maker Tool
99  if (design.getReadoutTechnology() != InDetDD::PixelReadoutTechnology::RD53 && (moduleHash < 12 or moduleHash > 2035)) {
100  charge = tot/8.0*(8000.0-1200.0)+1200.0;
101  }
102  chargeList.push_back(charge);
103  }
104 
105  const int row = pixelID.phi_index(id);
106  if (row > rowmax) {
107  rowmax = row;
108  qRowMax = charge;
109  } else if (row == rowmax) {
110  qRowMax += charge;
111  }
112 
113  if (row < rowmin) {
114  rowmin = row;
115  qRowMin = charge;
116  } else if (row == rowmin) {
117  qRowMin += charge;
118  }
119 
120  const int col = pixelID.eta_index(id);
121  if (col > colmax) {
122  colmax = col;
123  qColMax = charge;
124  } else if (col == colmax) {
125  qColMax += charge;
126  }
127 
128  if (col < colmin) {
129  colmin = col;
130  qColMin = charge;
131  } else if (col == colmin) {
132  qColMin += charge;
133  }
134 
135  InDetDD::SiCellId si_cell = element->cellIdFromIdentifier(id);
137 
138  if (m_useWeightedPos) {
139  pos_acc += tot * pos;
140  tot_acc += tot;
141  } else {
142  pos_acc += pos;
143  tot_acc += 1;
144  }
145  }
146 
147  if (tot_acc > 0)
148  pos_acc /= tot_acc;
149 
150  // Compute omega for charge interpolation correction (if required)
151  // Two pixels may have charge=0 (very rarely, hopefully)
152  float omegax = -1.f;
153  float omegay = -1.f;
154  if(qRowMin + qRowMax > 0) omegax = qRowMax/(qRowMin + qRowMax);
155  if(qColMin + qColMax > 0) omegay = qColMax/(qColMin + qColMax);
156 
157 
158  const int colWidth = colmax - colmin + 1;
159  const int rowWidth = rowmax - rowmin + 1;
160  double etaWidth = design.widthFromColumnRange(colmin, colmax);
161  double phiWidth = design.widthFromRowRange(rowmin, rowmax);
162  InDet::SiWidth siWidth(Amg::Vector2D(rowWidth,colWidth), Amg::Vector2D(phiWidth,etaWidth));
163 
164  // ask for Lorentz correction, get global position
165  double shift = m_pixelLorentzAngleTool->getLorentzShift(element->identifyHash(), ctx);
166  const Amg::Vector2D localPos = pos_acc;
167  Amg::Vector2D locpos(localPos[Trk::locX]+shift, localPos[Trk::locY]);
168  // find global position of element
169  const Amg::Transform3D& T = element->surface().transform();
170  double Ax[3] = {T(0,0),T(1,0),T(2,0)};
171  double Ay[3] = {T(0,1),T(1,1),T(2,1)};
172  double R [3] = {T(0,3),T(1,3),T(2,3)};
173 
174  const Amg::Vector2D& M = locpos;
175  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]);
176 
177  // Compute error matrix
178  float width0, width1;
179  if (m_broadErrors) {
180  // Use cluster width
181  width0 = siWidth.phiR();
182  width1 = siWidth.z();
183  } else {
184  // Use pixel width
185  width0 = siWidth.phiR() / siWidth.colRow().x();
186  width1 = siWidth.z() / siWidth.colRow().y();
187  }
188 
189  auto errorMatrix = Amg::MatrixX(2,2);
190  errorMatrix.setIdentity();
191  // Assume uniform distribution
192  errorMatrix.fillSymmetric(0,0, width0 * width0 / 12.0);
193  errorMatrix.fillSymmetric(1,1, width1 * width1 / 12.0);
194 
195  // Actually create the cluster (i.e. fill the values)
196  IdentifierHash idHash = element->identifyHash();
197 
198  Eigen::Matrix<float,2,1> localPosition(locpos.x(), locpos.y());
199  Eigen::Matrix<float,2,2> localCovariance = Eigen::Matrix<float,2,2>::Zero();
200  localCovariance(0, 0) = errorMatrix(0, 0);
201  localCovariance(1, 1) = errorMatrix(1, 1);
202 
203  xaodcluster.setMeasurement<2>(idHash, localPosition, localCovariance);
204  xaodcluster.setIdentifier( element->identifierOfPosition(locpos).get_compact() );
205  xaodcluster.setRDOlist(cluster.ids);
206  xaodcluster.globalPosition() = globalPos.cast<float>();
207  xaodcluster.setToTlist(cluster.tots);
208  xaodcluster.setTotalToT( xAOD::xAODInDetMeasurement::Utilities::computeTotalToT(cluster.tots) );
209  xaodcluster.setChargelist(chargeList);
210  xaodcluster.setTotalCharge( xAOD::xAODInDetMeasurement::Utilities::computeTotalCharge(chargeList) );
211  xaodcluster.setLVL1A(cluster.lvl1min);
212  xaodcluster.setChannelsInPhiEta(siWidth.colRow()[0],
213  siWidth.colRow()[1]);
214  xaodcluster.setWidthInEta(static_cast<float>(siWidth.widthPhiRZ()[1]));
215  xaodcluster.setOmegas(omegax, omegay);
216  xaodcluster.setIsSplit(false);
217  xaodcluster.setSplitProbabilities(0.0, 0.0);
218 
219  return StatusCode::SUCCESS;
220 }

Member Data Documentation

◆ m_addCorners

Gaudi::Property<bool> ActsTrk::PixelClusteringTool::m_addCorners {this, "AddCorners", true}
private

Definition at line 94 of file PixelClusteringTool.h.

◆ m_broadErrors

Gaudi::Property<bool> ActsTrk::PixelClusteringTool::m_broadErrors {this, "UseBroadErrors", false}
private

Definition at line 96 of file PixelClusteringTool.h.

◆ m_chargeDataKey

SG::ReadCondHandleKey<PixelChargeCalibCondData> ActsTrk::PixelClusteringTool::m_chargeDataKey
private
Initial value:
{this, "PixelChargeCalibCondData", "ITkPixelChargeCalibCondData",
"Pixel charge calibration data"}

Definition at line 91 of file PixelClusteringTool.h.

◆ m_pixelLorentzAngleTool

ToolHandle< ISiLorentzAngleTool > ActsTrk::PixelClusteringTool::m_pixelLorentzAngleTool {this, "PixelLorentzAngleTool", "", "Tool to retreive Lorentz angle of Pixel"}
private

Definition at line 89 of file PixelClusteringTool.h.

◆ m_pixelRDOTool

ToolHandle< InDet::PixelRDOTool > ActsTrk::PixelClusteringTool::m_pixelRDOTool {this, "PixelRDOTool", "", "The Pixel RDO tool"}
private

Definition at line 88 of file PixelClusteringTool.h.

◆ m_pixelReadout

ServiceHandle< InDetDD::IPixelReadoutManager > ActsTrk::PixelClusteringTool::m_pixelReadout
private
Initial value:
{this, "PixelReadoutManager", "ITkPixelReadoutManager",
"Pixel readout manager" }

Definition at line 85 of file PixelClusteringTool.h.

◆ m_useWeightedPos

Gaudi::Property<bool> ActsTrk::PixelClusteringTool::m_useWeightedPos {this, "UseWeightedPosition", true}
private

Definition at line 95 of file PixelClusteringTool.h.


The documentation for this class was generated from the following files:
ActsTrk::PixelClusteringTool::m_broadErrors
Gaudi::Property< bool > m_broadErrors
Definition: PixelClusteringTool.h:96
InDetDD::SolidStateDetectorElementBase::identifierOfPosition
Identifier identifierOfPosition(const Amg::Vector2D &localPos) const
Full identifier of the cell for a given position: assumes a raw local position (no Lorentz shift)
Definition: SolidStateDetectorElementBase.cxx:217
query_example.row
row
Definition: query_example.py:24
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
PixelID::phi_index
int phi_index(const Identifier &id) const
Definition: PixelID.h:658
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
max
#define max(a, b)
Definition: cfImp.cxx:41
ActsTrk::PixelClusteringTool::m_pixelLorentzAngleTool
ToolHandle< ISiLorentzAngleTool > m_pixelLorentzAngleTool
Definition: PixelClusteringTool.h:89
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Trk::locX
@ locX
Definition: ParamDefs.h:37
InDetDD::PixelModuleDesign::widthFromRowRange
double widthFromRowRange(const int rowMin, const int rowMax) const
Method to calculate phi width from a row range.
Definition: PixelModuleDesign.cxx:144
InDetDD::PixelModuleDesign
Definition: PixelModuleDesign.h:48
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
xAOD::xAODInDetMeasurement::Utilities::computeTotalToT
int computeTotalToT(const SG::AuxElement &cluster)
Definition: Event/xAOD/xAODInDetMeasurement/Root/Utilities.cxx:22
InDetDD::SolidStateDetectorElementBase::surface
Trk::Surface & surface()
Element Surface.
Identifier::get_compact
value_type get_compact() const
Get the compact id.
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
ActsTrk::PixelClusteringTool::m_useWeightedPos
Gaudi::Property< bool > m_useWeightedPos
Definition: PixelClusteringTool.h:95
InDetDD::SolidStateDetectorElementBase::identifyHash
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
PixelID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: PixelID.h:364
ActsTrk::PixelClusteringTool::m_addCorners
Gaudi::Property< bool > m_addCorners
Definition: PixelClusteringTool.h:94
InDetDD::PixelReadoutTechnology::RD53
@ RD53
InDetDD::SiLocalPosition
Definition: SiLocalPosition.h:31
ActsTrk::PixelClusteringTool::m_chargeDataKey
SG::ReadCondHandleKey< PixelChargeCalibCondData > m_chargeDataKey
Definition: PixelClusteringTool.h:91
InDetDD::SiDetectorElement::cellIdFromIdentifier
virtual SiCellId cellIdFromIdentifier(const Identifier &identifier) const override final
SiCellId from Identifier.
Definition: SiDetectorElement.cxx:120
ActsTrk::PixelClusteringTool::m_pixelReadout
ServiceHandle< InDetDD::IPixelReadoutManager > m_pixelReadout
Definition: PixelClusteringTool.h:85
InDetDD::PixelModuleDesign::widthFromColumnRange
double widthFromColumnRange(const int colMin, const int colMax) const
Method to calculate eta width from a column range.
Definition: PixelModuleDesign.cxx:132
PixelID::wafer_hash
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition: PixelID.h:387
lumiFormat.i
int i
Definition: lumiFormat.py:85
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
PixelChargeCalibCondData
Definition: PixelChargeCalibCondData.h:24
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
InDetDD::PixelModuleDesign::localPositionOfCell
virtual SiLocalPosition localPositionOfCell(const SiCellId &cellId) const
readout or diode id -> position.
Definition: PixelModuleDesign.cxx:85
test_pyathena.parent
parent
Definition: test_pyathena.py:15
PixelID::eta_index
int eta_index(const Identifier &id) const
Definition: PixelID.h:664
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector::insert
iterator insert(iterator position, value_type pElem)
Add a new element to the collection.
AnalysisUtils::Delta::R
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)
Definition: AnalysisMisc.h:49
LB_AnalMapSplitter.tot
tot
Definition: LB_AnalMapSplitter.py:46
min
#define min(a, b)
Definition: cfImp.cxx:40
xAOD::xAODInDetMeasurement::Utilities::computeTotalCharge
float computeTotalCharge(const SG::AuxElement &cluster)
Definition: Event/xAOD/xAODInDetMeasurement/Root/Utilities.cxx:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
charge
double charge(const T &p)
Definition: AtlasPID.h:538
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
InDetDD::PixelModuleDesign::getReadoutTechnology
PixelReadoutTechnology getReadoutTechnology() const
Definition: PixelModuleDesign.h:368
query_example.col
col
Definition: query_example.py:7
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
InDetDD::SiCellId
Definition: SiCellId.h:29
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
xAOD::PixelCluster_v1
Definition: PixelCluster_v1.h:17
ActsTrk::PixelClusteringTool::ClusterCollection
std::vector< Cluster > ClusterCollection
Definition: PixelClusteringTool.h:62
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::phiWidth
phiWidth
Definition: RingSetConf_v1.cxx:612
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
ActsTrk::PixelClusteringTool::m_pixelRDOTool
ToolHandle< InDet::PixelRDOTool > m_pixelRDOTool
Definition: PixelClusteringTool.h:88
InDet::SiWidth
Definition: SiWidth.h:25
ActsTrk::PixelClusteringTool::makeCluster
StatusCode makeCluster(const EventContext &ctx, const PixelClusteringTool::Cluster &cluster, const PixelID &pixelID, const InDetDD::SiDetectorElement *element, xAOD::PixelCluster &container) const
Definition: PixelClusteringTool.cxx:49
PixelChargeCalibCondData::getCharge
float getCharge(InDetDD::PixelDiodeType type, unsigned int moduleHash, unsigned int FE, float ToT) const
Definition: PixelChargeCalibCondData.cxx:192
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
InDetDD::SiDetectorElement::design
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
Trk::Surface::transform
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
Identifier
Definition: IdentifierFieldParser.cxx:14