11 #include "CLHEP/Units/SystemOfUnits.h"
12 #include "CLHEP/Matrix/SymMatrix.h"
13 #include "GaudiKernel/ToolHandle.h"
14 #include "GaudiKernel/ServiceHandle.h"
37 inline double square(
const double x){
51 std::vector<Identifier>&& rdoList,
53 std::vector<int>&& totList,
54 std::vector<float>&& chargeList,
70 std::move(chargeList),
85 class AddNewxAODpixelCluster {
88 : m_cluster(&cluster) {}
93 const std::vector<Identifier>& rdoList,
95 const std::vector<int>& totList,
96 const std::vector<float>& chargeList,
105 Eigen::Matrix<float,2,1> localPosition(locpos.x(), locpos.y());
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);
170 return StatusCode::SUCCESS;
194 template <
typename ClusterType,
typename IdentifierVec,
typename ToTList>
198 IdentifierVec&& rdoList,
211 const EventContext& ctx,
220 throw std::runtime_error(
"Dynamic cast failed for design in ClusterMakerTool.cxx");
222 int rowMin = design->rows();
224 int colMin = design->columns();
226 float qRowMin = 0;
float qRowMax = 0;
227 float qColMin = 0;
float qColMax = 0;
228 std::vector<float> chargeList;
229 int nRDO=rdoList.size();
231 chargeList.reserve(nRDO);
232 for (
int i=0;
i<nRDO;
i++) {
243 charge = ToT/8.0*(8000.0-1200.0)+1200.0;
245 chargeList.push_back(
charge);
249 for (
int i=0;
i<nRDO;
i++) {
254 if (calibData) {
charge=chargeList[
i]; }
270 if (col == colMin) qColMin +=
charge;
276 if (col == colMax) qColMax +=
charge;
288 if(qRowMin+qRowMax > 0) omegax = qRowMax/
float(qRowMin+qRowMax);
289 if(qColMin+qColMax > 0) omegay = qColMax/
float(qColMin+qColMax);
298 double Ax[3] = {T(0,0),T(1,0),T(2,0)};
299 double Ay[3] = {T(0,1),T(1,1),T(2,1)};
300 double R [3] = {T(0,3),T(1,3),T(2,3)};
303 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]);
309 errorMatrix.setIdentity();
314 double eta = std::abs(globalPos.eta());
315 double zPitch =
width.z()/colRow.y();
320 throw std::runtime_error(
"Wrong helper type in ClusterMakerTool.cxx.");
323 int layer =
pid->layer_disk(clusterID);
325 switch (errorStrategy){
339 if (offlineCalibData) {
344 errorMatrix.fillSymmetric(0,0,
pow(phiError,2));
351 errorMatrix.fillSymmetric(0,0,square(phiError));
352 errorMatrix.fillSymmetric(1,1,square(
etaError));
357 errorMatrix.fillSymmetric(1,1,square(zPitch)*
ONE_TWELFTH);
376 static_assert(std::is_same_v<ClusterType, PixelCluster> ||
377 std::is_same_v<std::remove_pointer_t<ClusterType>,
379 "Not an InDet::PixelCluster or xAOD::PixelCluster");
381 return newInDetpixelCluster(newClusterID, locpos,
383 std::forward<IdentifierVec>(rdoList),
385 std::forward<ToTList>(totList),
386 std::move(chargeList),
389 std::move(errorMatrix),
396 return AddNewxAODpixelCluster(*cluster)(newClusterID,
399 std::forward<IdentifierVec>(rdoList),
401 std::forward<ToTList>(totList),
415 std::vector<Identifier>&& rdoList,
417 std::vector<int>&& totList,
428 const EventContext& ctx)
const
430 return makePixelCluster<PixelCluster>(
452 const std::vector<Identifier>& rdoList,
454 const std::vector<int>& totList,
465 const EventContext& ctx)
const
467 return makePixelCluster<xAOD::PixelCluster*>(
505 std::vector<Identifier>&& rdoList,
508 int errorStrategy)
const
520 errorMatrix.setIdentity();
526 switch (errorStrategy){
538 else if(colRow.x() == 2){
552 else if(colRow.x() == 2){
569 double v0 = (errorMatrix)(0,0)*
w*
w;
570 double v1 = (errorMatrix)(1,1);
571 errorMatrix.fillSymmetric(0,0,cs2*
v0+sn2*v1);
572 errorMatrix.fillSymmetric(0,1,sn*sqrt(cs2)*(
v0-v1));
573 errorMatrix.fillSymmetric(1,1,sn2*
v0+cs2*v1);
576 return SCT_Cluster(clusterID, locpos, std::move(rdoList),
width, element, std::move(errorMatrix));
583 int phiClusterSize)
const{
592 if(phiClusterSize > 3)
return 14.6*
micrometer;
594 if(
layer == 0 && phi == 0)
return sigmaL0Phi0[phiClusterSize-1];
595 if(
layer == 1 && phi == 0)
return sigmaL1Phi0[phiClusterSize-1];
596 if(
layer == 2 && phi == 0)
return sigmaL2Phi0[phiClusterSize-1];
597 if(
layer == 0 && phi == 1)
return sigmaL0Phi1[phiClusterSize-1];
598 if(
layer == 1 && phi == 1)
return sigmaL1Phi1[phiClusterSize-1];
599 if(
layer == 2 && phi == 1)
return sigmaL2Phi1[phiClusterSize-1];
603 <<
layer <<
" and phi = " << phi);