Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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, PixelClusteringTool::Cluster &cluster, const PixelID &pixelID, const InDetDD::SiDetectorElement *element, const InDetDD::PixelModuleDesign &design, const PixelChargeCalibCondData *calibData, const PixelChargeCalibCondData::CalibrationStrategy calibStrategy, 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", false}
 
Gaudi::Property< bool > m_broadErrors {this, "UseBroadErrors", false}
 

Detailed Description

Definition at line 23 of file PixelClusteringTool.h.

Member Typedef Documentation

◆ Cell

Definition at line 26 of file PixelClusteringTool.h.

◆ CellCollection

Definition at line 27 of file PixelClusteringTool.h.

◆ ClusterCollection

Definition at line 35 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 53 of file PixelClusteringTool.cxx.

55  : base_class(type,name,parent)
56 {}

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 246 of file PixelClusteringTool.cxx.

250 {
251 
252  // Retrieve the detector element
253  const InDetDD::SiDetectorElement* element = m_pixelRDOTool->checkCollection(RDOs, ctx);
254  if (element == nullptr) {
255  // the RDO tool will return nullptr if the module is flagged bad, which is not a failure.
256  return StatusCode::SUCCESS;
257  }
258 
259  // Retrieve the calibration data
260  const PixelChargeCalibCondData *calibData = nullptr;
261  if (not m_chargeDataKey.empty()) {
263  calibData = calibDataHandle.cptr();
264 
265  if (!calibData) {
266  ATH_MSG_ERROR("PixelChargeCalibCondData requested but couldn't be retrieved from " << m_chargeDataKey.key());
267  return StatusCode::FAILURE;
268  }
269  }
270 
271  // Retrieve the cells from the detector element
272  std::vector<InDet::UnpackedPixelRDO> cells =
273  m_pixelRDOTool->getUnpackedPixelRDOs(RDOs, pixelID, element, ctx);
274 
275  // Get the calibration strategy for this module.
276  // Default to RD53 if the calibData is not available. That is fine because it won't be used anyway
277  auto calibrationStrategy = calibData ? calibData->getCalibrationStrategy(element->identifyHash()) : PixelChargeCalibCondData::CalibrationStrategy::RD53;
278 
279  // Get the element design
280  const InDetDD::PixelModuleDesign& design =
281  static_cast<const InDetDD::PixelModuleDesign&>(element->design());
282 
284  Acts::Ccl::createClusters<CellCollection, ClusterCollection, 2>
285  (cells, Acts::Ccl::DefaultConnect<Cell, 2>(m_addCorners));
286 
287 
288  std::size_t previousSizeContainer = container.size();
289  // Fast insertion trick
290  std::vector<xAOD::PixelCluster*> toAddCollection;
291  toAddCollection.reserve(clusters.size());
292  for (std::size_t i(0); i<clusters.size(); ++i)
293  toAddCollection.push_back(new xAOD::PixelCluster());
294  container.insert(container.end(), toAddCollection.begin(), toAddCollection.end());
295 
296  for (std::size_t i(0); i<clusters.size(); ++i) {
297  Cluster& cluster = clusters[i];
298 
300  cluster,
301  pixelID,
302  element,
303  design,
304  calibData,
305  calibrationStrategy,
306  *container[previousSizeContainer+i]));
307  }
308 
309  return StatusCode::SUCCESS;
310 }

◆ initialize()

StatusCode ActsTrk::PixelClusteringTool::initialize ( )
overridevirtual

Definition at line 40 of file PixelClusteringTool.cxx.

41 {
42  ATH_MSG_DEBUG("Initializing " << name() << " ...");
43  ATH_CHECK(m_pixelRDOTool.retrieve());
45  if (not m_chargeDataKey.empty()) ATH_CHECK(m_pixelReadout.retrieve());
46 
48 
49  ATH_MSG_DEBUG(name() << " successfully initialized");
50  return StatusCode::SUCCESS;
51 }

◆ makeCluster()

StatusCode ActsTrk::PixelClusteringTool::makeCluster ( const EventContext &  ctx,
PixelClusteringTool::Cluster cluster,
const PixelID pixelID,
const InDetDD::SiDetectorElement element,
const InDetDD::PixelModuleDesign design,
const PixelChargeCalibCondData calibData,
const PixelChargeCalibCondData::CalibrationStrategy  calibStrategy,
xAOD::PixelCluster container 
) const
private

Definition at line 59 of file PixelClusteringTool.cxx.

67 {
68 
69  InDetDD::SiLocalPosition pos_acc(0,0);
70  int tot_acc = 0;
71 
72  std::vector<float> chargeList;
73  if (calibData) chargeList.reserve(cluster.ids.size());
74 
75  int colmax = std::numeric_limits<int>::min();
76  int rowmax = std::numeric_limits<int>::min();
77  int colmin = std::numeric_limits<int>::max();
78  int rowmin = std::numeric_limits<int>::max();
79 
80  float qRowMin = 0.f;
81  float qRowMax = 0.f;
82  float qColMin = 0.f;
83  float qColMax = 0.f;
84 
85  // We temporary comment this since it is not used
86  // bool hasGanged = false;
87 
88  Identifier moduleID = element->identify();
89  IdentifierHash moduleHash = element->identifyHash();
90 
91  // This could be moved outside the cluster loop
92  bool multiChip = design.numberOfCircuits() > 1;
93 
94  for (size_t i = 0; i < cluster.ids.size(); i++) {
95 
96  //Construct the identifier class
97  Identifier id = Identifier(cluster.ids[i]);
98 
99  // We temporary comment this since it is not used
100  // TODO: Check how the ganged info is used in legacy
101  // if (multiChip) {
102  // hasGanged = hasGanged ||
103  // m_pixelRDOTool->isGanged(id, element).has_value();
104  // }
105 
106  int tot = cluster.tots.at(i);
107  float charge = tot;
108 
109  if (calibData) {
110 
112  ATH_MSG_ERROR("Chip type is not recognized!");
113  return StatusCode::FAILURE;
114  }
115 
116  // The calibration strategy is updated for each element
117  // Retrieving the calibration only depends on FE and not per cell (can be further optimized)
118  // Single FE modules could have an optimized getCharge function where the calib constants are cached
119  int feValue = multiChip ? m_pixelReadout->getFE(id, moduleID, element) : 0;
120  charge = calibData->getCharge(m_pixelReadout->getDiodeType(id,element),
121  calibStrategy,
122  moduleHash,
123  feValue,
124  tot);
125  chargeList.push_back(charge);
126  }
127 
128  const int row = pixelID.phi_index(id);
129  if (row > rowmax) {
130  rowmax = row;
131  qRowMax = charge;
132  } else if (row == rowmax) {
133  qRowMax += charge;
134  }
135 
136  if (row < rowmin) {
137  rowmin = row;
138  qRowMin = charge;
139  } else if (row == rowmin) {
140  qRowMin += charge;
141  }
142 
143  const int col = pixelID.eta_index(id);
144  if (col > colmax) {
145  colmax = col;
146  qColMax = charge;
147  } else if (col == colmax) {
148  qColMax += charge;
149  }
150 
151  if (col < colmin) {
152  colmin = col;
153  qColMin = charge;
154  } else if (col == colmin) {
155  qColMin += charge;
156  }
157 
158  InDetDD::SiCellId si_cell = element->cellIdFromIdentifier(id);
160 
161  // We compute the digital position as a sum of all RDO positions
162  // all with the same weight of 1
163  // We do not compute a charge-weighted center of gravity here (by default) since
164  // we observe it to be worse than the digital position
165  // ToT-weighted center of gravity must not be used
166  if (m_useWeightedPos) {
167  pos_acc += charge * pos;
168  tot_acc += charge;
169  } else {
170  pos_acc += pos;
171  tot_acc += 1;
172  }
173 
174  }
175 
176  if (tot_acc > 0)
177  pos_acc /= tot_acc;
178 
179  // Compute omega for charge interpolation correction (if required)
180  // Two pixels may have charge=0 (very rarely, hopefully)
181  float omegax = -1.f;
182  float omegay = -1.f;
183  if(qRowMin + qRowMax > 0) omegax = qRowMax/(qRowMin + qRowMax);
184  if(qColMin + qColMax > 0) omegay = qColMax/(qColMin + qColMax);
185 
186 
187  const int colWidth = colmax - colmin + 1;
188  const int rowWidth = rowmax - rowmin + 1;
189  double etaWidth = design.widthFromColumnRange(colmin, colmax);
190  double phiWidth = design.widthFromRowRange(rowmin, rowmax);
191  InDet::SiWidth siWidth(Amg::Vector2D(rowWidth,colWidth), Amg::Vector2D(phiWidth,etaWidth));
192 
193  // ask for Lorentz correction, get global position
194  double shift = m_pixelLorentzAngleTool->getLorentzShift(moduleHash, ctx);
195  const Amg::Vector2D localPos = pos_acc;
196  Amg::Vector2D locpos(localPos[Trk::locX]+shift, localPos[Trk::locY]);
197  // find global position of element
198  const Amg::Transform3D& T = element->surface().transform();
199  double Ax[3] = {T(0,0),T(1,0),T(2,0)};
200  double Ay[3] = {T(0,1),T(1,1),T(2,1)};
201  double R [3] = {T(0,3),T(1,3),T(2,3)};
202 
203  const Amg::Vector2D& M = locpos;
204  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]);
205 
206  // Compute error matrix
207  float width0, width1;
208  if (m_broadErrors) {
209  // Use cluster width
210  width0 = siWidth.phiR();
211  width1 = siWidth.z();
212  } else {
213  // Use average pixel width
214  width0 = siWidth.phiR() / siWidth.colRow().x();
215  width1 = siWidth.z() / siWidth.colRow().y();
216  }
217 
218  // Actually create the cluster (i.e. fill the values)
219 
220  Eigen::Matrix<float,2,1> localPosition(locpos.x(), locpos.y());
221  Eigen::Matrix<float,2,2> localCovariance = Eigen::Matrix<float,2,2>::Zero();
222  localCovariance(0, 0) = width0 * width0 / 12.0;
223  localCovariance(1, 1) = width1 * width1 / 12.0;
224 
225  xaodcluster.setMeasurement<2>(moduleHash, localPosition, localCovariance);
226  xaodcluster.setIdentifier( element->identifierOfPosition(locpos).get_compact() );
227  xaodcluster.setRDOlist(std::move(cluster.ids));
228  xaodcluster.globalPosition() = globalPos.cast<float>();
229  xaodcluster.setTotalToT( xAOD::xAODInDetMeasurement::Utilities::computeTotalToT(cluster.tots) );
230  xaodcluster.setToTlist(std::move(cluster.tots));
231  xaodcluster.setTotalCharge( xAOD::xAODInDetMeasurement::Utilities::computeTotalCharge(chargeList) );
232  xaodcluster.setChargelist(std::move(chargeList));
233  xaodcluster.setLVL1A(cluster.lvl1min);
234  xaodcluster.setChannelsInPhiEta(siWidth.colRow()[0],
235  siWidth.colRow()[1]);
236  xaodcluster.setWidthInEta(static_cast<float>(siWidth.widthPhiRZ()[1]));
237  xaodcluster.setOmegas(omegax, omegay);
238  xaodcluster.setIsSplit(false);
239  xaodcluster.setSplitProbabilities(0.0, 0.0);
240 
241  return StatusCode::SUCCESS;
242 }

Member Data Documentation

◆ m_addCorners

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

Definition at line 72 of file PixelClusteringTool.h.

◆ m_broadErrors

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

Definition at line 74 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 69 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 67 of file PixelClusteringTool.h.

◆ m_pixelRDOTool

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

Definition at line 66 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 63 of file PixelClusteringTool.h.

◆ m_useWeightedPos

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

Definition at line 73 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:74
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:280
PixelID::phi_index
int phi_index(const Identifier &id) const
Definition: PixelID.h:658
ActsTrk::PixelClusteringTool::makeCluster
StatusCode makeCluster(const EventContext &ctx, PixelClusteringTool::Cluster &cluster, const PixelID &pixelID, const InDetDD::SiDetectorElement *element, const InDetDD::PixelModuleDesign &design, const PixelChargeCalibCondData *calibData, const PixelChargeCalibCondData::CalibrationStrategy calibStrategy, xAOD::PixelCluster &container) const
Definition: PixelClusteringTool.cxx:59
ActsTrk::PixelClusteringTool::m_pixelLorentzAngleTool
ToolHandle< ISiLorentzAngleTool > m_pixelLorentzAngleTool
Definition: PixelClusteringTool.h:67
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:167
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
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
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.
PixelChargeCalibCondData::CalibrationStrategy::RD53
@ RD53
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
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:73
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
InDetDD::SolidStateDetectorElementBase::identifyHash
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
ActsTrk::PixelClusteringTool::m_addCorners
Gaudi::Property< bool > m_addCorners
Definition: PixelClusteringTool.h:72
InDetDD::PixelReadoutTechnology::RD53
@ RD53
InDetDD::SiLocalPosition
Definition: SiLocalPosition.h:31
ActsTrk::PixelClusteringTool::m_chargeDataKey
SG::ReadCondHandleKey< PixelChargeCalibCondData > m_chargeDataKey
Definition: PixelClusteringTool.h:69
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:63
InDetDD::PixelModuleDesign::widthFromColumnRange
double widthFromColumnRange(const int colMin, const int colMax) const
Method to calculate eta width from a column range.
Definition: PixelModuleDesign.cxx:155
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
columnar::ContainerId::cluster
@ cluster
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
InDetDD::PixelModuleDesign::numberOfCircuits
int numberOfCircuits() const
Total number of circuits:
Definition: PixelModuleDesign.h:315
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:108
test_pyathena.parent
parent
Definition: test_pyathena.py:15
PixelID::eta_index
int eta_index(const Identifier &id) const
Definition: PixelID.h:664
PixelChargeCalibCondData::getCalibrationStrategy
CalibrationStrategy getCalibrationStrategy(unsigned int moduleHash) const
Definition: PixelChargeCalibCondData.cxx:254
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
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:240
charge
double charge(const T &p)
Definition: AtlasPID.h:931
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:386
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:35
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:66
InDet::SiWidth
Definition: SiWidth.h:25
PixelChargeCalibCondData::getCharge
float getCharge(InDetDD::PixelDiodeType type, unsigned int moduleHash, unsigned int FE, float ToT) const
Definition: PixelChargeCalibCondData.cxx:223
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.
InDetDD::SolidStateDetectorElementBase::identify
virtual Identifier identify() const override final
identifier of this detector element (inline)
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