22 #include "GaudiKernel/EventContext.h"
40 rescaled << trkPB.
d0(), trkPB.
z0(), trkPB.
phi0(), trkPB.
theta(),
54 destLayers.emplace_back(lay);
62 const std::string&
name,
67 declareInterface<IEMExtrapolationTools>(
this);
91 return StatusCode::SUCCESS;
94 std::pair<std::vector<CaloSampling::CaloSample>,
95 std::vector<std::unique_ptr<Trk::Surface>>>
104 constexpr std::array<CaloSampling::CaloSample, 4> barrelLayers = {
110 constexpr std::array<CaloSampling::CaloSample, 4> endcapLayers = {
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);
127 if (cluster.inBarrel() && (!cluster.inEndcap() ||
130 getClusterLayers(barrelLayers, clusterLayers, cluster);
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,
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) {
268 eta[
i] = std::get<1>(
p);
269 phi[
i] = std::get<2>(
p);
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
351 vertex->position(),
momentum.unit() * 1.e10, +1, surface, std::nullopt);
360 float* phiAtCalo)
const
365 if (fabs(trkPar->
eta()) < 1.425) {
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) {
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
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 =
462 if (
vertex.nTrackParticles() == 0) {
463 ATH_MSG_WARNING(
"getMomentumAtVertex : vertex has no track particles!");
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();