11#include "CLHEP/Units/SystemOfUnits.h"
12#include "CLHEP/Matrix/SymMatrix.h"
13#include "GaudiKernel/ToolHandle.h"
14#include "GaudiKernel/ServiceHandle.h"
31using CLHEP::micrometer;
35inline double square(
const double x){
49 std::vector<Identifier>&& rdoList,
51 std::vector<int>&& totList,
52 std::vector<float>&& chargeList,
68 std::move(chargeList),
83class AddNewxAODpixelCluster {
86 : m_cluster(&cluster) {}
91 const std::vector<Identifier>& rdoList,
93 const std::vector<int>& totList,
94 const std::vector<float>& chargeList,
95 const InDet::SiWidth&
width,
96 const InDetDD::SiDetectorElement* detEl,
103 Eigen::Matrix<float,2,1> localPosition(locpos.x(), locpos.y());
104 Eigen::Matrix<float,2,2> localCovariance = Eigen::Matrix<float,2,2>::Zero();
105 localCovariance(0, 0) = locErrMat(0, 0);
106 localCovariance(1, 1) = locErrMat(1, 1);
108 m_cluster->setMeasurement<2>(idHash, localPosition, localCovariance);
109 m_cluster->setRDOlist(rdoList);
110 m_cluster->globalPosition() = globpos.cast<
float>();
111 m_cluster->setToTlist(totList);
112 m_cluster->setChargelist(chargeList);
113 m_cluster->setLVL1A(lvl1a);
114 m_cluster->setChannelsInPhiEta(
width.colRow()[0],
width.colRow()[1]);
115 m_cluster->setWidthInEta(
static_cast<float>(
width.widthPhiRZ()[1]));
134 const std::string& n,
135 const IInterface* p) :
138 declareInterface<ClusterMakerTool>(
this);
160 return StatusCode::SUCCESS;
184template <
typename ClusterType,
typename IdentifierVec,
typename ToTList>
188 IdentifierVec&& rdoList,
201 const EventContext& ctx,
210 throw std::runtime_error(
"Dynamic cast failed for design in ClusterMakerTool.cxx");
212 int rowMin = design->
rows();
214 int colMin = design->
columns();
216 float qRowMin = 0;
float qRowMax = 0;
217 float qColMin = 0;
float qColMax = 0;
218 std::vector<float> chargeList;
219 int nRDO=rdoList.size();
221 chargeList.reserve(nRDO);
223 for (
int i=0; i<nRDO; i++) {
229 std::array<InDetDD::PixelDiodeTree::CellIndexType,2> diode_idx
233 std::uint32_t feValue = design->
getFE(si_param);
242 charge = ToT/8.0*(8000.0-1200.0)+1200.0;
244 chargeList.push_back(
charge);
248 for (
int i=0; i<nRDO; i++) {
253 if (calibData) {
charge=chargeList[i]; }
258 if (row == rowMin) qRowMin +=
charge;
264 if (row == rowMax) qRowMax +=
charge;
269 if (col == colMin) qColMin +=
charge;
275 if (col == colMax) qColMax +=
charge;
287 if(qRowMin+qRowMax > 0) omegax = qRowMax/float(qRowMin+qRowMax);
288 if(qColMin+qColMax > 0) omegay = qColMax/float(qColMin+qColMax);
297 double Ax[3] = {T(0,0),T(1,0),T(2,0)};
298 double Ay[3] = {T(0,1),T(1,1),T(2,1)};
299 double R [3] = {T(0,3),T(1,3),T(2,3)};
302 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]);
308 errorMatrix.setIdentity();
313 double eta = std::abs(globalPos.eta());
314 double zPitch =
width.z()/colRow.y();
319 throw std::runtime_error(
"Wrong helper type in ClusterMakerTool.cxx.");
322 int layer = pid->layer_disk(clusterID);
323 int phimod = pid->phi_module(clusterID);
324 switch (errorStrategy){
326 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
327 errorMatrix.fillSymmetric(1,1,square(
width.z())*ONE_TWELFTH);
330 errorMatrix.fillSymmetric(0,0,square(
width.phiR()/colRow.x())*ONE_TWELFTH);
331 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
337 if (!ganged && zPitch>399*micrometer && zPitch<401*micrometer) {
338 if (offlineCalibData) {
343 errorMatrix.fillSymmetric(0,0,pow(phiError,2));
344 errorMatrix.fillSymmetric(1,1,pow(etaError,2));
350 errorMatrix.fillSymmetric(0,0,square(phiError));
351 errorMatrix.fillSymmetric(1,1,square(etaError));
355 errorMatrix.fillSymmetric(0,0,square(
width.phiR()/colRow.x())*ONE_TWELFTH);
356 errorMatrix.fillSymmetric(1,1,square(zPitch)*ONE_TWELFTH);
362 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
366 errorMatrix.fillSymmetric(0,0,square(
width.phiR()/colRow.x())*ONE_TWELFTH);
367 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
375 static_assert(std::is_same_v<ClusterType, PixelCluster> ||
376 std::is_same_v<std::remove_pointer_t<ClusterType>,
378 "Not an InDet::PixelCluster or xAOD::PixelCluster");
379 if constexpr (std::is_same<ClusterType, InDet::PixelCluster>::value) {
380 return newInDetpixelCluster(newClusterID, locpos,
382 std::forward<IdentifierVec>(rdoList),
384 std::forward<ToTList>(totList),
385 std::move(chargeList),
388 std::move(errorMatrix),
395 return AddNewxAODpixelCluster(*cluster)(newClusterID,
398 std::forward<IdentifierVec>(rdoList),
400 std::forward<ToTList>(totList),
414 std::vector<Identifier>&& rdoList,
416 std::vector<int>&& totList,
427 const EventContext& ctx)
const
451 const std::vector<Identifier>& rdoList,
453 const std::vector<int>& totList,
464 const EventContext& ctx)
const
504 std::vector<Identifier>&& rdoList,
507 int errorStrategy)
const
519 errorMatrix.setIdentity();
525 switch (errorStrategy){
527 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
528 errorMatrix.fillSymmetric(1,1,square(
width.z())*ONE_TWELFTH);
535 errorMatrix.fillSymmetric(0,0,square(1.05*
width.phiR())*ONE_TWELFTH);
537 else if(colRow.x() == 2){
538 errorMatrix.fillSymmetric(0,0,square(0.27*
width.phiR())*ONE_TWELFTH);
541 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
543 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
549 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
551 else if(colRow.x() == 2){
552 errorMatrix.fillSymmetric(0,0,square(0.27*
width.phiR())*ONE_TWELFTH);
555 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
557 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
568 double v0 = (errorMatrix)(0,0)*w*w;
569 double v1 = (errorMatrix)(1,1);
570 errorMatrix.fillSymmetric(0,0,cs2*v0+sn2*v1);
571 errorMatrix.fillSymmetric(0,1,sn*sqrt(cs2)*(v0-v1));
572 errorMatrix.fillSymmetric(1,1,sn2*v0+cs2*v1);
575 return SCT_Cluster(clusterID, locpos, std::move(rdoList),
width, element, std::move(errorMatrix));
582 int phiClusterSize)
const{
584 double sigmaL0Phi1[3] = { 8.2*micrometer, 9.7*micrometer, 14.6*micrometer};
585 double sigmaL1Phi1[3] = {14.6*micrometer, 9.3*micrometer, 14.6*micrometer};
586 double sigmaL2Phi1[3] = {14.6*micrometer, 8.6*micrometer, 14.6*micrometer};
587 double sigmaL0Phi0[3] = {14.6*micrometer, 13.4*micrometer, 13.0*micrometer};
588 double sigmaL1Phi0[3] = {14.6*micrometer, 8.5*micrometer, 11.0*micrometer};
589 double sigmaL2Phi0[3] = {14.6*micrometer, 11.6*micrometer, 9.3*micrometer};
591 if(phiClusterSize > 3)
return 14.6*micrometer;
593 if(layer == 0 &&
phi == 0)
return sigmaL0Phi0[phiClusterSize-1];
594 if(layer == 1 &&
phi == 0)
return sigmaL1Phi0[phiClusterSize-1];
595 if(layer == 2 &&
phi == 0)
return sigmaL2Phi0[phiClusterSize-1];
596 if(layer == 0 &&
phi == 1)
return sigmaL0Phi1[phiClusterSize-1];
597 if(layer == 1 &&
phi == 1)
return sigmaL1Phi1[phiClusterSize-1];
598 if(layer == 2 &&
phi == 1)
return sigmaL2Phi1[phiClusterSize-1];
602 << layer <<
" and phi = " <<
phi);
603 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.
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
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.
Helper class to access parameters of a diode.