11#include "CLHEP/Units/SystemOfUnits.h"
12#include "CLHEP/Matrix/SymMatrix.h"
13#include "GaudiKernel/ToolHandle.h"
14#include "GaudiKernel/ServiceHandle.h"
32using CLHEP::micrometer;
36inline double square(
const double x){
50 std::vector<Identifier>&& rdoList,
52 std::vector<int>&& totList,
53 std::vector<float>&& chargeList,
69 std::move(chargeList),
84class AddNewxAODpixelCluster {
87 : m_cluster(&cluster) {}
92 const std::vector<Identifier>& rdoList,
94 const std::vector<int>& totList,
95 const std::vector<float>& chargeList,
96 const InDet::SiWidth&
width,
97 const InDetDD::SiDetectorElement* detEl,
104 Eigen::Matrix<float,2,1> localPosition(locpos.x(), locpos.y());
105 Eigen::Matrix<float,2,2> localCovariance = Eigen::Matrix<float,2,2>::Zero();
106 localCovariance(0, 0) = locErrMat(0, 0);
107 localCovariance(1, 1) = locErrMat(1, 1);
109 m_cluster->setMeasurement<2>(idHash, localPosition, localCovariance);
110 m_cluster->setRDOlist(rdoList);
111 m_cluster->globalPosition() = globpos.cast<
float>();
112 m_cluster->setToTlist(totList);
113 m_cluster->setChargelist(chargeList);
115 m_cluster->setLVL1A(lvl1a);
116 m_cluster->setChannelsInPhiEta(
width.colRow()[0],
width.colRow()[1]);
117 m_cluster->setWidthInEta(
static_cast<float>(
width.widthPhiRZ()[1]));
136 const std::string& n,
137 const IInterface* p) :
140 declareInterface<ClusterMakerTool>(
this);
162 return StatusCode::SUCCESS;
186template <
typename ClusterType,
typename IdentifierVec,
typename ToTList>
190 IdentifierVec&& rdoList,
203 const EventContext& ctx,
212 throw std::runtime_error(
"Dynamic cast failed for design in ClusterMakerTool.cxx");
214 int rowMin = design->
rows();
216 int colMin = design->
columns();
218 float qRowMin = 0;
float qRowMax = 0;
219 float qColMin = 0;
float qColMax = 0;
220 std::vector<float> chargeList;
221 int nRDO=rdoList.size();
223 chargeList.reserve(nRDO);
225 for (
int i=0; i<nRDO; i++) {
231 std::array<InDetDD::PixelDiodeTree::CellIndexType,2> diode_idx
235 std::uint32_t feValue = design->
getFE(si_param);
244 charge = ToT/8.0*(8000.0-1200.0)+1200.0;
246 chargeList.push_back(
charge);
250 for (
int i=0; i<nRDO; i++) {
255 if (calibData) {
charge=chargeList[i]; }
260 if (row == rowMin) qRowMin +=
charge;
266 if (row == rowMax) qRowMax +=
charge;
271 if (col == colMin) qColMin +=
charge;
277 if (col == colMax) qColMax +=
charge;
289 if(qRowMin+qRowMax > 0) omegax = qRowMax/float(qRowMin+qRowMax);
290 if(qColMin+qColMax > 0) omegay = qColMax/float(qColMin+qColMax);
299 double Ax[3] = {T(0,0),T(1,0),T(2,0)};
300 double Ay[3] = {T(0,1),T(1,1),T(2,1)};
301 double R [3] = {T(0,3),T(1,3),T(2,3)};
304 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]);
310 errorMatrix.setIdentity();
315 double eta = std::abs(globalPos.eta());
316 double zPitch =
width.z()/colRow.y();
321 throw std::runtime_error(
"Wrong helper type in ClusterMakerTool.cxx.");
324 int layer = pid->layer_disk(clusterID);
325 int phimod = pid->phi_module(clusterID);
326 switch (errorStrategy){
328 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
329 errorMatrix.fillSymmetric(1,1,square(
width.z())*ONE_TWELFTH);
332 errorMatrix.fillSymmetric(0,0,square(
width.phiR()/colRow.x())*ONE_TWELFTH);
333 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
339 if (!ganged && zPitch>399*micrometer && zPitch<401*micrometer) {
340 if (offlineCalibData) {
345 errorMatrix.fillSymmetric(0,0,pow(phiError,2));
346 errorMatrix.fillSymmetric(1,1,pow(etaError,2));
352 errorMatrix.fillSymmetric(0,0,square(phiError));
353 errorMatrix.fillSymmetric(1,1,square(etaError));
357 errorMatrix.fillSymmetric(0,0,square(
width.phiR()/colRow.x())*ONE_TWELFTH);
358 errorMatrix.fillSymmetric(1,1,square(zPitch)*ONE_TWELFTH);
364 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
368 errorMatrix.fillSymmetric(0,0,square(
width.phiR()/colRow.x())*ONE_TWELFTH);
369 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
377 static_assert(std::is_same_v<ClusterType, PixelCluster> ||
378 std::is_same_v<std::remove_pointer_t<ClusterType>,
380 "Not an InDet::PixelCluster or xAOD::PixelCluster");
381 if constexpr (std::is_same<ClusterType, InDet::PixelCluster>::value) {
382 return newInDetpixelCluster(newClusterID, locpos,
384 std::forward<IdentifierVec>(rdoList),
386 std::forward<ToTList>(totList),
387 std::move(chargeList),
390 std::move(errorMatrix),
397 return AddNewxAODpixelCluster(*cluster)(newClusterID,
400 std::forward<IdentifierVec>(rdoList),
402 std::forward<ToTList>(totList),
416 std::vector<Identifier>&& rdoList,
418 std::vector<int>&& totList,
429 const EventContext& ctx)
const
453 const std::vector<Identifier>& rdoList,
455 const std::vector<int>& totList,
466 const EventContext& ctx)
const
506 std::vector<Identifier>&& rdoList,
509 int errorStrategy)
const
521 errorMatrix.setIdentity();
527 switch (errorStrategy){
529 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
530 errorMatrix.fillSymmetric(1,1,square(
width.z())*ONE_TWELFTH);
537 errorMatrix.fillSymmetric(0,0,square(1.05*
width.phiR())*ONE_TWELFTH);
539 else if(colRow.x() == 2){
540 errorMatrix.fillSymmetric(0,0,square(0.27*
width.phiR())*ONE_TWELFTH);
543 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
545 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
551 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
553 else if(colRow.x() == 2){
554 errorMatrix.fillSymmetric(0,0,square(0.27*
width.phiR())*ONE_TWELFTH);
557 errorMatrix.fillSymmetric(0,0,square(
width.phiR())*ONE_TWELFTH);
559 errorMatrix.fillSymmetric(1,1,square(
width.z()/colRow.y())*ONE_TWELFTH);
570 double v0 = (errorMatrix)(0,0)*w*w;
571 double v1 = (errorMatrix)(1,1);
572 errorMatrix.fillSymmetric(0,0,cs2*v0+sn2*v1);
573 errorMatrix.fillSymmetric(0,1,sn*sqrt(cs2)*(v0-v1));
574 errorMatrix.fillSymmetric(1,1,sn2*v0+cs2*v1);
577 return SCT_Cluster(clusterID, locpos, std::move(rdoList),
width, element, std::move(errorMatrix));
584 int phiClusterSize)
const{
586 double sigmaL0Phi1[3] = { 8.2*micrometer, 9.7*micrometer, 14.6*micrometer};
587 double sigmaL1Phi1[3] = {14.6*micrometer, 9.3*micrometer, 14.6*micrometer};
588 double sigmaL2Phi1[3] = {14.6*micrometer, 8.6*micrometer, 14.6*micrometer};
589 double sigmaL0Phi0[3] = {14.6*micrometer, 13.4*micrometer, 13.0*micrometer};
590 double sigmaL1Phi0[3] = {14.6*micrometer, 8.5*micrometer, 11.0*micrometer};
591 double sigmaL2Phi0[3] = {14.6*micrometer, 11.6*micrometer, 9.3*micrometer};
593 if(phiClusterSize > 3)
return 14.6*micrometer;
595 if(layer == 0 &&
phi == 0)
return sigmaL0Phi0[phiClusterSize-1];
596 if(layer == 1 &&
phi == 0)
return sigmaL1Phi0[phiClusterSize-1];
597 if(layer == 2 &&
phi == 0)
return sigmaL2Phi0[phiClusterSize-1];
598 if(layer == 0 &&
phi == 1)
return sigmaL0Phi1[phiClusterSize-1];
599 if(layer == 1 &&
phi == 1)
return sigmaL1Phi1[phiClusterSize-1];
600 if(layer == 2 &&
phi == 1)
return sigmaL2Phi1[phiClusterSize-1];
604 << layer <<
" and phi = " <<
phi);
605 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
float computeTotalCharge(const SG::AuxElement &cluster)
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.
Helper class to access parameters of a diode.