11#include "CLHEP/Units/SystemOfUnits.h"
12#include "CLHEP/Matrix/SymMatrix.h"
13#include "GaudiKernel/ToolHandle.h"
14#include "GaudiKernel/ServiceHandle.h"
33using CLHEP::micrometer;
37inline double square(
const double x){
51 std::vector<Identifier>&& rdoList,
53 std::vector<int>&& totList,
54 std::vector<float>&& chargeList,
70 std::move(chargeList),
85class AddNewxAODpixelCluster {
88 : m_cluster(&cluster) {}
93 const std::vector<Identifier>& rdoList,
95 const std::vector<int>& totList,
96 const std::vector<float>& chargeList,
97 const InDet::SiWidth&
width,
98 const InDetDD::SiDetectorElement* detEl,
105 Eigen::Matrix<float,2,1> localPosition(locpos.x(), locpos.y());
106 Eigen::Matrix<float,2,2> localCovariance = Eigen::Matrix<float,2,2>::Zero();
107 localCovariance(0, 0) = locErrMat(0, 0);
108 localCovariance(1, 1) = locErrMat(1, 1);
110 m_cluster->setMeasurement<2>(idHash, localPosition, localCovariance);
111 m_cluster->setRDOlist(rdoList);
112 m_cluster->globalPosition() = globpos.cast<
float>();
113 m_cluster->setToTlist(totList);
115 m_cluster->setChargelist(chargeList);
117 m_cluster->setLVL1A(lvl1a);
118 m_cluster->setChannelsInPhiEta(
width.colRow()[0],
width.colRow()[1]);
119 m_cluster->setWidthInEta(
static_cast<float>(
width.widthPhiRZ()[1]));
120 m_cluster->setIsSplit(
split);
121 m_cluster->setSplitProbabilities(splitProb1, splitProb2);
140 const std::string& n,
141 const IInterface* p) :
144 declareInterface<ClusterMakerTool>(
this);
166 return StatusCode::SUCCESS;
190template <
typename ClusterType,
typename IdentifierVec,
typename ToTList>
194 IdentifierVec&& rdoList,
207 const EventContext& ctx,
216 throw std::runtime_error(
"Dynamic cast failed for design in ClusterMakerTool.cxx");
218 int rowMin = design->
rows();
220 int colMin = design->
columns();
222 float qRowMin = 0;
float qRowMax = 0;
223 float qColMin = 0;
float qColMax = 0;
224 std::vector<float> chargeList;
225 int nRDO=rdoList.size();
227 chargeList.reserve(nRDO);
229 for (
int i=0; i<nRDO; i++) {
235 std::array<InDetDD::PixelDiodeTree::CellIndexType,2> diode_idx
239 std::uint32_t feValue = design->
getFE(si_param);
248 charge = ToT/8.0*(8000.0-1200.0)+1200.0;
250 chargeList.push_back(
charge);
254 for (
int i=0; i<nRDO; i++) {
259 if (calibData) {
charge=chargeList[i]; }
264 if (row == rowMin) qRowMin +=
charge;
270 if (row == rowMax) qRowMax +=
charge;
275 if (col == colMin) qColMin +=
charge;
281 if (col == colMax) qColMax +=
charge;
293 if(qRowMin+qRowMax > 0) omegax = qRowMax/float(qRowMin+qRowMax);
294 if(qColMin+qColMax > 0) omegay = qColMax/float(qColMin+qColMax);
303 double Ax[3] = {T(0,0),T(1,0),T(2,0)};
304 double Ay[3] = {T(0,1),T(1,1),T(2,1)};
305 double R [3] = {T(0,3),T(1,3),T(2,3)};
308 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]);
314 errorMatrix.setIdentity();
319 double eta = std::abs(globalPos.eta());
320 double zPitch =
width.z()/colRow.y();
325 throw std::runtime_error(
"Wrong helper type in ClusterMakerTool.cxx.");
328 int layer = pid->layer_disk(clusterID);
329 int phimod = pid->phi_module(clusterID);
330 switch (errorStrategy){
332 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
333 errorMatrix.fillSymmetric(1,1,square(
width.z())*ONE_TWELFTH);
336 errorMatrix.fillSymmetric(0,0,square(
width.phiR()/colRow.x())*ONE_TWELFTH);
337 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
343 if (!ganged && zPitch>399*micrometer && zPitch<401*micrometer) {
344 if (offlineCalibData) {
349 errorMatrix.fillSymmetric(0,0,
pow(phiError,2));
350 errorMatrix.fillSymmetric(1,1,
pow(etaError,2));
356 errorMatrix.fillSymmetric(0,0,square(phiError));
357 errorMatrix.fillSymmetric(1,1,square(etaError));
361 errorMatrix.fillSymmetric(0,0,square(
width.phiR()/colRow.x())*ONE_TWELFTH);
362 errorMatrix.fillSymmetric(1,1,square(zPitch)*ONE_TWELFTH);
368 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
372 errorMatrix.fillSymmetric(0,0,square(
width.phiR()/colRow.x())*ONE_TWELFTH);
373 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
381 static_assert(std::is_same_v<ClusterType, PixelCluster> ||
382 std::is_same_v<std::remove_pointer_t<ClusterType>,
384 "Not an InDet::PixelCluster or xAOD::PixelCluster");
385 if constexpr (std::is_same<ClusterType, InDet::PixelCluster>::value) {
386 return newInDetpixelCluster(newClusterID, locpos,
388 std::forward<IdentifierVec>(rdoList),
390 std::forward<ToTList>(totList),
391 std::move(chargeList),
394 std::move(errorMatrix),
401 return AddNewxAODpixelCluster(*cluster)(newClusterID,
404 std::forward<IdentifierVec>(rdoList),
406 std::forward<ToTList>(totList),
420 std::vector<Identifier>&& rdoList,
422 std::vector<int>&& totList,
433 const EventContext& ctx)
const
457 const std::vector<Identifier>& rdoList,
459 const std::vector<int>& totList,
470 const EventContext& ctx)
const
510 std::vector<Identifier>&& rdoList,
513 int errorStrategy)
const
525 errorMatrix.setIdentity();
531 switch (errorStrategy){
533 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
534 errorMatrix.fillSymmetric(1,1,square(
width.z())*ONE_TWELFTH);
541 errorMatrix.fillSymmetric(0,0,square(1.05*
width.phiR())*ONE_TWELFTH);
543 else if(colRow.x() == 2){
544 errorMatrix.fillSymmetric(0,0,square(0.27*
width.phiR())*ONE_TWELFTH);
547 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
549 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
555 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
557 else if(colRow.x() == 2){
558 errorMatrix.fillSymmetric(0,0,square(0.27*
width.phiR())*ONE_TWELFTH);
561 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
563 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
574 double v0 = (errorMatrix)(0,0)*w*w;
575 double v1 = (errorMatrix)(1,1);
576 errorMatrix.fillSymmetric(0,0,cs2*v0+sn2*v1);
577 errorMatrix.fillSymmetric(0,1,sn*sqrt(cs2)*(v0-v1));
578 errorMatrix.fillSymmetric(1,1,sn2*v0+cs2*v1);
581 return SCT_Cluster(clusterID, locpos, std::move(rdoList),
width, element, std::move(errorMatrix));
588 int phiClusterSize)
const{
590 double sigmaL0Phi1[3] = { 8.2*micrometer, 9.7*micrometer, 14.6*micrometer};
591 double sigmaL1Phi1[3] = {14.6*micrometer, 9.3*micrometer, 14.6*micrometer};
592 double sigmaL2Phi1[3] = {14.6*micrometer, 8.6*micrometer, 14.6*micrometer};
593 double sigmaL0Phi0[3] = {14.6*micrometer, 13.4*micrometer, 13.0*micrometer};
594 double sigmaL1Phi0[3] = {14.6*micrometer, 8.5*micrometer, 11.0*micrometer};
595 double sigmaL2Phi0[3] = {14.6*micrometer, 11.6*micrometer, 9.3*micrometer};
597 if(phiClusterSize > 3)
return 14.6*micrometer;
599 if(layer == 0 &&
phi == 0)
return sigmaL0Phi0[phiClusterSize-1];
600 if(layer == 1 &&
phi == 0)
return sigmaL1Phi0[phiClusterSize-1];
601 if(layer == 2 &&
phi == 0)
return sigmaL2Phi0[phiClusterSize-1];
602 if(layer == 0 &&
phi == 1)
return sigmaL0Phi1[phiClusterSize-1];
603 if(layer == 1 &&
phi == 1)
return sigmaL1Phi1[phiClusterSize-1];
604 if(layer == 2 &&
phi == 1)
return sigmaL2Phi1[phiClusterSize-1];
608 << layer <<
" and phi = " <<
phi);
609 return 14.6*micrometer;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
double charge(const T &p)
This is an Identifier helper class for the Pixel subdetector.
constexpr int pow(int base, int exp) noexcept
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
virtual HelperType helper() const
Type of helper, defaulted to 'Unimplemented'.
This is a "hash" representation of an Identifier.
virtual DetectorShape shape() const
Shape of element.
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)
virtual int numberOfConnectedCells(const SiReadoutCellId &readoutId) const
readout id -> id of connected diodes
PixelReadoutTechnology getReadoutTechnology() const
int columns() const
Number of cell columns per module:
PixelDiodeTree::DiodeProxy diodeProxyFromIdx(const std::array< PixelDiodeTree::IndexType, 2 > &idx) const
int rows() const
Number of cell rows per module:
virtual SiReadoutCellId readoutIdOfCell(const SiCellId &cellId) const
diode id -> readout id
static InDetDD::PixelDiodeType getDiodeType(const PixelDiodeTree::DiodeProxy &diode_proxy)
static unsigned int getFE(const PixelDiodeTree::DiodeProxy &diode_proxy)
Identifier for the strip or pixel cell.
Class to hold geometrical description of a silicon detector element.
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
double phiPitch() const
Pitch (inline methods)
double sinStereoLocal(const Amg::Vector2D &localPos) const
Angle of strip in local frame with respect to the etaAxis.
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
const AtlasDetectorID * getIdHelper() const
Returns the id helper (inline)
Trk::Surface & surface()
Element Surface.
float getPixelEndcapRError(int ibin) const
float getPixelBarrelEtaError(int ibin) const
int getBarrelBin(double eta, int etaClusterSize, int phiClusterSize) const
int getEndcapBin(int etaClusterSize, int phiClusterSize) const
float getPixelEndcapPhiError(int ibin) const
float getPixelBarrelPhiError(int ibin) const
PixelClusterErrorData * getPixelClusterErrorData()
float getCharge(InDetDD::PixelDiodeType type, unsigned int moduleHash, unsigned int FE, float ToT) const
This is an Identifier helper class for the Pixel subdetector.
int eta_index(const Identifier &id) const
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Identifier pixel_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int phi_index, int eta_index) const
For an individual pixel.
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
int phi_index(const Identifier &id) const
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
std::vector< std::string > split(const std::string &s, const std::string &t=":")
constexpr double ONE_TWELFTH
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
float computeTotalCharge(const SG::AuxElement &cluster)
int computeTotalToT(const SG::AuxElement &cluster)
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.
Helper class to access parameters of a diode.