ATLAS Offline Software
Loading...
Searching...
No Matches
TauTrackCaloExtrapolator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef XAOD_ANALYSIS
6
8
10
12 TauRecToolBase(name),
14 m_HadSamplings {CaloSampling::TileBar1, CaloSampling::HEC1, CaloSampling::TileExt1}
15{}
16
18
19// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
21
23 if(!m_caloExtensionTool.empty()) {
24 ATH_CHECK( m_caloExtensionTool.retrieve() );
25 }
26
27 return StatusCode::SUCCESS;
28}
29
30// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
32 const EventContext& ctx,
33 xAOD::TauTrackContainer& tauTrackCon) const
34{
36
37 int trackIndex = -1;
38 const Trk::CaloExtension * caloExtension = nullptr;
39 std::unique_ptr<Trk::CaloExtension> uniqueExtension;
40
41
42
43 for(const ElementLink<xAOD::TauTrackContainer>& trackLink : pTau.allTauTrackLinks())
44 {
45 assert (trackLink.getStorableObjectPointer() == &tauTrackCon);
46 xAOD::TauTrack* tauTrack = tauTrackCon[trackLink.index()];
47
48 // if requested, run extrapolation only for charged tau-tracks
50 continue;
51 }
52
53 const xAOD::TrackParticle *orgTrack = tauTrack->track();
54 if( !orgTrack ) continue;
55 trackIndex = orgTrack->index();
56
57 // set default values
58 float etaEM = -10.0;
59 float phiEM = -10.0;
60 float etaHad = -10.0;
61 float phiHad = -10.0;
62
63 // get the extrapolation into the calo
64 ATH_MSG_DEBUG( "Try extrapolation of track with pt = " << orgTrack->pt()
65 << ", eta " << orgTrack->eta()
66 << ", phi" << orgTrack->phi() );
67
68 if(!m_ParticleCacheKey.key().empty()){
69 /*get the CaloExtension object*/
70 ATH_MSG_VERBOSE("Using the CaloExtensionBuilder Cache");
72 caloExtension = (*particleCache)[trackIndex];
73 ATH_MSG_VERBOSE("Getting element " << trackIndex << " from the particleCache");
74 if( not caloExtension ){
75 ATH_MSG_VERBOSE("Cache does not contain a calo extension -> "
76 "Calculating with the a CaloExtensionTool");
77 uniqueExtension = m_caloExtensionTool->caloExtension(ctx, *orgTrack);
78 caloExtension = uniqueExtension.get();
79 }
80 }
81 else {
82 /* If CaloExtensionBuilder is unavailable, use the calo extension tool */
83 ATH_MSG_VERBOSE("Using the CaloExtensionTool");
84 uniqueExtension = m_caloExtensionTool->caloExtension(ctx, *orgTrack);
85 caloExtension = uniqueExtension.get();
86 }
87
88 if (!caloExtension)
89 {
90 ATH_MSG_DEBUG("Track extrapolation failed");
91 }
92 else {
93 const std::vector<Trk::CurvilinearParameters>& clParametersVector = caloExtension->caloLayerIntersections();
94 if (clParametersVector.empty()) {
95 ATH_MSG_DEBUG("Track extrapolation failed");
96 }
97
98 ATH_MSG_DEBUG("Scanning samplings");
99 bool validECal = false;
100 bool validHCal = false;
101 for( const Trk::CurvilinearParameters& cur : clParametersVector ){
102 ATH_MSG_DEBUG("Sampling " << parsIdHelper.caloSample(cur.cIdentifier()) );
103
104 // only use entry layer
105 if( not parsIdHelper.isEntryToVolume(cur.cIdentifier()) ) continue;
106
107 CaloSampling::CaloSample sample = parsIdHelper.caloSample(cur.cIdentifier());
108
109 // ECal
110 if( not validECal and m_EMSamplings.count(sample))
111 {
112 validECal = true;
113 etaEM = cur.position().eta();
114 phiEM = cur.position().phi();
115 ATH_MSG_DEBUG("Extrapolated to ECal layer " << sample);
116 }
117
118 // HCal
119 if( not validHCal and m_HadSamplings.count(sample))
120 {
121 validHCal = true;
122 etaHad = cur.position().eta();
123 phiHad = cur.position().phi();
124 ATH_MSG_DEBUG("Extrapolated to HCal layer " << sample);
125 }
126 if( validECal and validHCal ) break;
127 }
128 // EM failure warn if within acceptance
129 if( not validECal and std::abs(orgTrack->pt()) < 2.48 ){
130 ATH_MSG_DEBUG("Failed extrapolation to ECal");
131 }
132 // Had failure warn if enough pt to reach HCal
133 if( not validHCal and orgTrack->pt() > 2000. ){
134 ATH_MSG_DEBUG("Failed extrapolation to HCal");
135 }
136
137 ATH_MSG_DEBUG( "Extrapolated track with eta=" << orgTrack->eta()
138 << " phi="<<orgTrack->phi()
139 << " to ECal eta=" << etaEM
140 << " phi="<< phiEM
141 << " HCal eta=" << etaHad
142 << " phi="<< phiHad
143 );
144 }
149 }
150
151 return StatusCode::SUCCESS;
152
153}
154#endif
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_VERBOSE(x,...)
TauRecToolBase(const std::string &name)
virtual StatusCode initialize() override
Algorithm functions.
ToolHandle< Trk::IParticleCaloExtensionTool > m_caloExtensionTool
tools
virtual StatusCode executeTool(xAOD::TauJet &pTau, const EventContext &ctx, xAOD::TauTrackContainer &tauTrackCon) const override
std::set< CaloSampling::CaloSample > m_HadSamplings
SG::ReadHandleKey< CaloExtensionCollection > m_ParticleCacheKey
TauTrackCaloExtrapolator(const std::string &name)
Constructor and Destructor.
std::set< CaloSampling::CaloSample > m_EMSamplings
Gaudi::Property< bool > m_extrapOnlyChargedTracks
Tracking class to hold the extrapolation through calorimeter Layers Both the caloEntryLayerIntersecti...
const std::vector< CurvilinearParameters > & caloLayerIntersections() const
access to the intersections with the calorimeter layers.
helper class to encode and decode a TrackParametersIdentifier
bool isEntryToVolume(TrackParametersIdentifier id) const
returns true if the id belongs to the volume entrance
CaloSampling::CaloSample caloSample(TrackParametersIdentifier id) const
CaloSample encoded in id, returns CaloSampling::Unknown if id is not valid.
const TauTrackLinks_t & allTauTrackLinks() const
bool flag(TauJetParameters::TauTrackFlag flag) const
void setDetail(TauJetParameters::TrackDetail detail, float value)
const TrackParticle * track() const
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.
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TauTrack_v1 TauTrack
Definition of the current version.
Definition TauTrack.h:16
TauJet_v3 TauJet
Definition of the current "tau version".
Definition TauJet.h:17
TauTrackContainer_v1 TauTrackContainer
Definition of the current TauTrack container version.