17#include "GaudiKernel/SystemOfUnits.h"
26phiVariance(
double clusterE,
double absEta)
29 const double EinGeV = clusterE * 1
e-3;
37 return (0.14 * 0.14) / (EinGeV * EinGeV) + 0.001 * 0.001;
40 return (0.15 * 0.15) / (EinGeV * EinGeV) + 0.001 * 0.001;
43 return (0.19 * 0.19) / (EinGeV * EinGeV) + 0.001 * 0.001;
46 return (0.26 * 0.26) / (EinGeV * EinGeV) + 0.001 * 0.001;
49 return (0.36 * 0.36) / (EinGeV * EinGeV) + 0.001 * 0.001;
52 return (0.52 * 0.52) / (EinGeV * EinGeV) + 0.003 * 0.003;
55 return (0.46 * 0.46) / (EinGeV * EinGeV) + 0.004 * 0.004;
58 return (0.35 * 0.35) / (EinGeV * EinGeV) + 0.004 * 0.004;
61 return (0.38 * 0.38) / (EinGeV * EinGeV) + 0.005 * 0.005;
63 return (0.47 * 0.47) / (EinGeV * EinGeV) + 0.006 * 0.006;
72 declareInterface<ICaloCluster_OnTrackBuilder>(
this);
78 m_eg_resol = std::make_unique<eg_resolution>(
"run2_R21_v1");
81 return StatusCode::SUCCESS;
87 return StatusCode::SUCCESS;
90std::unique_ptr<Trk::CaloCluster_OnTrack>
92 const EventContext& ctx,
100 ATH_MSG_WARNING(
"CaloCluster_OnTrackBuilder is configured incorrectly");
110 std::unique_ptr<Trk::Surface> surface =
getCaloSurface(cluster, caloDDMgr);
121 return std::make_unique<Trk::CaloCluster_OnTrack>(std::move(lp), std::move(em), *surface);
125std::unique_ptr<Trk::Surface>
131 std::unique_ptr<Trk::Surface> destinationSurface =
nullptr;
137 destinationSurface.reset(
m_calosurf->CreateUserSurface(
138 CaloCell_ID::EMB2, 0., cluster->
eta(), caloDDMgr));
140 destinationSurface.reset(
m_calosurf->CreateUserSurface(
141 CaloCell_ID::EME2, 0., cluster->
eta(), caloDDMgr));
143 return destinationSurface;
154 double eta = cluster->
eta();
155 double phi = cluster->
phi();
156 double clusterQoverE = cluster->
e() != 0 ? (double)
charge / cluster->
e() : 0;
162 double r = surfRefPoint.perp();
163 std::vector<Trk::DefinedParameter> defPar;
166 defPar.push_back(locRPhi);
170 double tantheta = tan(
theta);
171 double z = tantheta == 0 ? 0. :
r / tantheta;
173 defPar.push_back(locZ);
177 defPar.push_back(qOverP);
184 double z = surfRefPoint.z();
185 std::vector<Trk::DefinedParameter> defPar;
188 double tantheta = tan(
theta);
189 double r =
z * tantheta;
191 defPar.push_back(locR);
195 defPar.push_back(locPhi);
199 defPar.push_back(qOverP);
217 const double clusterE = cluster->
e();
218 const double clusterEta = cluster->
eta();
221 double phivariance = phiVariance(clusterE, std::abs(clusterEta));
222 if (phivariance < 1e-5) {
228 const double sigmaP_over_P =
m_eg_resol->getResolution(0,
233 const double qOverP = 1. / clusterE;
234 const double qOverP_variance =
235 (qOverP * qOverP) * (sigmaP_over_P * sigmaP_over_P);
241 constexpr double zvariance = 400;
248 double r = surfRefPoint.perp();
252 covMatrix(indexCount, indexCount) = phivariance * r2;
256 covMatrix(indexCount, indexCount) = zvariance;
260 covMatrix(indexCount, indexCount) = qOverP_variance;
270 covMatrix(indexCount, indexCount) = zvariance;
274 covMatrix(indexCount, indexCount) = phivariance;
278 covMatrix(indexCount, indexCount) = qOverP_variance;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
double charge(const T &p)
Calculate total energy, position, etc. for a given layer of a cluster.
Handle class for reading from StoreGate.
CaloCluster_OnTrackBuilder()
Trk::LocalParameters getClusterLocalParameters(const xAOD::CaloCluster *cluster, const Trk::Surface *surf, int charge) const
Gaudi::Property< bool > m_useClusterEta
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
std::unique_ptr< Trk::Surface > getCaloSurface(const xAOD::CaloCluster *cluster, const CaloDetDescrManager *caloDDMgr) const
Amg::MatrixX getClusterErrorMatrix(const xAOD::CaloCluster *cluster, const Trk::Surface &surf, int charge) const
ToolHandle< ICaloSurfaceBuilder > m_calosurf
Tool to build calorimeter layer surfaces.
virtual StatusCode finalize() override final
virtual StatusCode initialize() override final
Gaudi::Property< bool > m_useClusterEnergy
Which cluster measurements to use in order to add constraints by default we are interested in the one...
Gaudi::Property< bool > m_useClusterPhi
virtual std::unique_ptr< Trk::CaloCluster_OnTrack > buildClusterOnTrack(const EventContext &ctx, const xAOD::CaloCluster *cl, int charge=0) const override final
std::unique_ptr< eg_resolution > m_eg_resol
helper for returning energy resolution
This class provides the client interface for accessing the detector description information common to...
Abstract Base Class for tracking surfaces.
virtual const Amg::Vector3D & globalReferencePoint() const
Returns a global reference point on the surface, for PlaneSurface, StraightLineSurface,...
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D
std::pair< double, ParamDefs > DefinedParameter
Typedef to of a std::pair<double, ParamDefs> to identify a passed-through double as a specific type o...
bool isBarrel(const xAOD::Egamma *eg)
return true if the cluster is in the barrel
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.