22#include "GaudiKernel/EventContext.h"
40 rescaled << trkPB.d0(), trkPB.z0(), trkPB.phi0(), trkPB.
theta(),
41 trkPB.
charge() / cluster.e();
47template <
std::
size_t N>
53 if (cluster.hasSampling(lay)) {
54 destLayers.emplace_back(lay);
62 const std::string& name,
63 const IInterface* parent)
67 declareInterface<IEMExtrapolationTools>(
this);
82 if (
sc.isFailure() || !
m_trtId->is_valid()) {
91 return StatusCode::SUCCESS;
94std::pair<std::vector<CaloSampling::CaloSample>,
95 std::vector<std::unique_ptr<Trk::Surface>>>
104 constexpr std::array<CaloSampling::CaloSample, 4> barrelLayers = {
105 CaloSampling::PreSamplerB,
110 constexpr std::array<CaloSampling::CaloSample, 4> endcapLayers = {
111 CaloSampling::PreSamplerE,
116 constexpr std::array<CaloSampling::CaloSample, 4> endcapLayersAboveEta2p5 = {
120 constexpr std::array<CaloSampling::CaloSample, 1> forwardLayers = {
124 std::vector<CaloSampling::CaloSample> clusterLayers;
125 clusterLayers.reserve(4);
128 cluster.
eSample(CaloSampling::EMB2) >=
129 cluster.
eSample(CaloSampling::EME2))) {
130 getClusterLayers(barrelLayers, clusterLayers, cluster);
132 else if (cluster.
eSample(CaloSampling::EME2) >
133 cluster.
eSample(CaloSampling::FCAL0)) {
134 if(std::abs(cluster.
eta()) < 2.5){
135 getClusterLayers(endcapLayers, clusterLayers, cluster);
138 getClusterLayers(endcapLayersAboveEta2p5, clusterLayers, cluster);
142 getClusterLayers(forwardLayers, clusterLayers, cluster);
145 std::vector<std::unique_ptr<Trk::Surface>> caloSurfaces =
147 clusterLayers, cluster.
eta(), caloDD);
149 return { std::move(clusterLayers), std::move(caloSurfaces) };
158 const EventContext& ctx,
161 const std::vector<CaloSampling::CaloSample>& samples,
162 const std::vector<std::unique_ptr<Trk::Surface>>& surfaces,
163 std::array<double, 4>&
eta,
164 std::array<double, 4>&
phi,
165 std::array<double, 4>& deltaEta,
167 unsigned int extrapFrom)
const
179 if (cluster.
e() < 10 && trkPB.
pt() < 10) {
181 << cluster.
e() <<
" , or too small track pt" << trkPB.
pt());
182 return StatusCode::FAILURE;
185 bool didExtension =
false;
187 intersections.reserve(samples.size());
189 switch (extrapFrom) {
191 Trk::Perigee trkPar = getRescaledPerigee(trkPB, cluster);
194 didExtension = !extension.empty();
195 for (
const auto& i : extension) {
196 intersections.emplace_back(
197 i.first, i.second->position().eta(), i.second->position().phi());
204 didExtension = !extension.empty();
205 for (
const auto& i : extension) {
206 intersections.emplace_back(
207 i.first, i.second->position().eta(), i.second->position().phi());
212 unsigned int index(0);
218 if (position.perp() > 1550. || std::abs(position.z()) > 3750.) {
220 didExtension =
false;
222 const auto extension =
225 didExtension = !extension.empty();
226 for (
const auto& i : extension) {
227 intersections.emplace_back(
228 i.first, i.second->position().eta(), i.second->position().phi());
243 << extrapFrom <<
" for a track with : "
244 <<
" Track Pt " << trkPB.
pt() <<
" Track Eta " << trkPB.
eta()
245 <<
" Track Phi " << trkPB.
phi() <<
" Track Fitter "
247 return StatusCode::FAILURE;
251 const bool flipSign = trkPB.
charge() > 0;
253 for (
const auto& p : intersections) {
256 if (sample == CaloSampling::PreSamplerE ||
257 sample == CaloSampling::PreSamplerB) {
259 }
else if (sample == CaloSampling::EME1 || sample == CaloSampling::EMB1) {
261 }
else if (sample == CaloSampling::EME2 || sample == CaloSampling::EMB2 || sample == CaloSampling::FCAL0) {
263 }
else if (sample == CaloSampling::EME3 || sample == CaloSampling::EMB3) {
268 eta[i] = std::get<1>(p);
269 phi[i] = std::get<2>(p);
270 deltaEta[i] = cluster.
etaSample(sample) - std::get<1>(p);
278 << i <<
" " <<
eta[i] <<
" " <<
phi[i] <<
" " << deltaEta[i]
281 return StatusCode::SUCCESS;
293 float phiAtCalo)
const
295 if (!cluster || !vertex) {
298 float deltaEta = fabs(etaAtCalo - cluster->
etaBE(2));
307 if ((TRTsection == 2 && (cluster->
eta() <= 0.6 || cluster->
eta() >= 2.4)) ||
309 (cluster->
eta() >= -0.6 || cluster->
eta() <= -2.4)) ||
310 (TRTsection == 1 && (cluster->
eta() <= -0.1 || cluster->
eta() >= 1.3)) ||
311 (TRTsection == -1 && (cluster->
eta() >= 0.1 || cluster->
eta() <= -1.3))) {
323 return (deltaEta < dEtaV[abs(TRTsection)] &&
335 float* phiAtCalo)
const
341 if (momentum.mag() < 1e-5) {
351 vertex->position(), momentum.unit() * 1.e10, +1, surface, std::nullopt);
360 float* phiAtCalo)
const
365 if (fabs(trkPar->
eta()) < 1.425) {
367 layersToSelect.insert(CaloSampling::EMB2);
370 layersToSelect.insert(CaloSampling::EME2);
373 std::unique_ptr<Trk::CaloExtension> extension =
nullptr;
377 ATH_MSG_WARNING(
"Could not create an extension from getEtaPhiAtCalo ");
382 *extension, intersections, &layersToSelect);
384 for (
const auto& p : intersections) {
386 auto sample = std::get<0>(p);
387 if ((sample == CaloSampling::EME2 || sample == CaloSampling::EMB2)) {
388 *etaAtCalo = std::get<1>(p);
389 *phiAtCalo = std::get<2>(p);
393 << i <<
" " << std::get<1>(p) <<
" " << std::get<2>(p));
403 unsigned int index)
const
406 if (vertex.nTrackParticles() <=
index) {
408 }
else if (vertex.vxTrackAtVertexAvailable() &&
409 !vertex.vxTrackAtVertex().empty()) {
412 ATH_MSG_DEBUG(
"getMomentumAtVertex : getting from vxTrackAtVertex");
413 const auto& trkAtVertex = vertex.vxTrackAtVertex()[
index];
415 if (!paramAtVertex) {
420 }
else if (vertex.nTrackParticles() == 1) {
423 "getMomentumAtVertex : 1 track only, getting from first measurement");
425 unsigned int paramindex(0);
430 momentum += tp->curvilinearParameters(paramindex).momentum();
434 ATH_MSG_DEBUG(
"getMomentumAtVertex : extrapolating to perigee surface");
440 std::unique_ptr<const Trk::TrackParameters> params =
441 m_extrapolator->extrapolate(ctx, tp->perigeeParameters(), surface,
446 momentum += params->momentum();
462 if (vertex.nTrackParticles() == 0) {
463 ATH_MSG_WARNING(
"getMomentumAtVertex : vertex has no track particles!");
470 return { accPx(vertex), accPy(vertex), accPz(vertex) };
472 for (
unsigned int i = 0; i < vertex.nTrackParticles(); ++i) {
490 "No trt ID guessing TRT section based on eta: " << trkPB->
eta());
491 return (trkPB->
eta() > 0 ? 1 : -1) * (fabs(trkPB->
eta()) < 0.6 ? 1 : 2);
504 rItTSoS = trackStates->
rbegin();
505 rItTSoS != trackStates->
rend();
509 (*rItTSoS)->measurementOnTrack() !=
nullptr &&
510 !((*rItTSoS)->measurementOnTrack()->type(
512 trkPar = (*rItTSoS)->measurementOnTrack();
523 const Identifier tid = sf.associatedDetectorElementIdentifier();
524 return m_trtId->barrel_ec(tid);
Scalar eta() const
pseudorapidity method
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
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)
CaloCell_ID::CaloSample CaloSample
This is an Identifier helper class for the TRT subdetector.
const ServiceHandle< StoreGateSvc > & detStore() const
Principal data class for CaloCell clusters.
This class provides the client interface for accessing the detector description information common to...
provides Calorimeter Sampling enum
const_reverse_iterator rend() const noexcept
Return a const_reverse_iterator pointing at the beginning of the collection.
const_reverse_iterator rbegin() const noexcept
Return a const_reverse_iterator pointing past the end of the collection.
std::reverse_iterator< const_iterator > const_reverse_iterator
bool isValid() const
Test to see if the link can be dereferenced.
SG::Accessor< T, ALLOC > Accessor
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
This class is the pure abstract base class for all fittable tracking measurements.
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
double eta() const
Access method for pseudorapidity - from momentum.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
Class describing the Line to which the Perigee refers to.
Abstract Base Class for tracking surfaces.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
const Trk::TrackStates * trackStateOnSurfaces() const
return a pointer to a const DataVector of const TrackStateOnSurfaces.
float phiSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
bool inBarrel() const
Returns true if at least one clustered cell in the barrel.
float eSample(const CaloSample sampling) const
bool inEndcap() const
Returns true if at least one clustered cell in the endcap.
virtual double phi() const
The azimuthal angle ( ) of the particle.
float etaSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
const ElementLink< TrackCollection > & trackLink() const
Returns a link (which can be invalid) to the Trk::Track which was used to make this TrackParticle.
bool indexOfParameterAtPosition(unsigned int &index, ParameterPosition position) const
Function to determine if this TrackParticle contains track parameters at a certain position,...
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
const Trk::CurvilinearParameters curvilinearParameters(unsigned int index) const
Returns a curvilinear representation of the parameters at 'index'.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
float charge() const
Returns the charge.
TrackFitter trackFitter() const
Returns the fitter.
void setParameters(T *h, TGraphAsymmErrors *tg)
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Eigen::Matrix< double, 3, 1 > Vector3D
std::set< CaloSampling::CaloSample > LayersToSelect
void midPointEtaPhiPerLayerVector(const Trk::CaloExtension &extension, EtaPhiPerLayerVector &result, const LayersToSelect *selection=nullptr)
std::vector< std::tuple< CaloSampling::CaloSample, double, double > > EtaPhiPerLayerVector
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
@ PseudoMeasurementOnTrack
DataVector< const Trk::TrackStateOnSurface > TrackStates
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
ParametersBase< TrackParametersDim, Charged > TrackParameters
std::size_t numberOfSiTracks(const xAOD::Photon *eg)
return the number of Si tracks in the conversion
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
@ FirstMeasurement
Parameter defined at the position of the 1st measurement.
@ LastMeasurement
Parameter defined at the position of the last measurement.