ATLAS Offline Software
Loading...
Searching...
No Matches
eflowTrackCaloExtensionTool.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/********************************************************************
6
7 NAME: eflowTrackCaloExtensionTool.cxx
8 PACKAGE: offline/Reconstruction/eflowRec
9
10 AUTHORS: T.Guttenberger
11 CREATED: 19th September, 2014
12
13 ********************************************************************/
14
16
19
20#include "TrkParameters/TrackParameters.h" // typedef
23
25
26#include "GaudiKernel/TypeNameString.h"
27
28#include <map>
29#include <vector>
30#include <utility>
31
32eflowTrackCaloExtensionTool::eflowTrackCaloExtensionTool(const std::string& type, const std::string& name, const IInterface* parent) :
33 AthAlgTool(type, name, parent),
34 m_trackParametersIdHelper(std::make_unique<Trk::TrackParametersIdHelper>())
35{
36 declareInterface<eflowTrackExtrapolatorBaseAlgTool>(this);
37}
38
40
42
43 if (m_theTrackExtrapolatorTool.retrieve().isFailure()) {
44 ATH_MSG_WARNING("Cannot find Extrapolation tool "
45 << m_theTrackExtrapolatorTool.typeAndName());
46 return StatusCode::SUCCESS;
47 } else {
48 ATH_MSG_VERBOSE("Successfully retrieved Extrapolation tool "
49 << m_theTrackExtrapolatorTool.typeAndName());
50 }
51
52 if (!m_ParticleCacheKey.key().empty()) ATH_CHECK(m_ParticleCacheKey.initialize());
53 else m_useOldCalo = true;
54
55 if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve());
56
57 return StatusCode::SUCCESS;
58}
59
60std::unique_ptr<eflowTrackCaloPoints> eflowTrackCaloExtensionTool::execute(const EventContext& ctx, const xAOD::TrackParticle* track) const {
61
62 ATH_MSG_VERBOSE(" Now running eflowTrackCaloExtensionTool");
63
64 auto execution_timer = Monitored::Timer<std::chrono::microseconds>( "TIME_execute" );
65 Monitored::ScopedTimer execution_time(execution_timer);
66 auto extrapolation_timer = Monitored::Timer<std::chrono::microseconds>( "TIME_extrapolation" );
67 auto track_pt = Monitored::Scalar<float>("track_pt");
68 auto group = Monitored::Group(m_monTool, execution_timer, extrapolation_timer, track_pt);
69
70 track_pt = track->pt() * m_invGeV ;
71
72 /*Create a map to index the TrackParameters at calo (owned by the extension) wrt to layers*/
73 std::map<eflowCalo::LAYER, const Trk::TrackParameters*> parametersMap;
74 std::map<CaloCell_ID::CaloSample,const Trk::TrackParameters*> tileParametersMap;
75
76 /*get the CaloExtension object*/
77 const Trk::CaloExtension * extension = nullptr;
78 std::unique_ptr<Trk::CaloExtension> uniqueExtension;
79 const int index = track->index();
80 ATH_MSG_VERBOSE("Getting element " << index << " from the particleCache");
81
82 extrapolation_timer.start();
83 if (m_useOldCalo) {
84 /* If CaloExtensionBuilder is unavailable, use the calo extension tool */
85 ATH_MSG_VERBOSE("Using the CaloExtensionTool");
86 uniqueExtension = m_theTrackExtrapolatorTool->caloExtension(ctx, *track);
87 extension = uniqueExtension.get();
88 } else {
89 /*get the CaloExtension object*/
91 ATH_MSG_VERBOSE("Using the CaloExtensionBuilder Cache");
92 extension = (*particleCache)[index];
93 ATH_MSG_VERBOSE("Getting element " << index << " from the particleCache");
94 if( not extension ){
95 ATH_MSG_VERBOSE("Cache does not contain a calo extension -> Calculating with the a CaloExtensionTool" );
96 uniqueExtension = m_theTrackExtrapolatorTool->caloExtension(ctx, *track);
97 extension = uniqueExtension.get();
98 }
99 }
100 extrapolation_timer.stop();
101
102 if (extension != nullptr) {
103
104 /*extract the CurvilinearParameters*/
105 const std::vector<Trk::CurvilinearParameters>& clParametersVector = extension->caloLayerIntersections();
106
107 /*The parameters are owned by the CaloExtension so are handled by it the eflowTrackCaloPoints does
108 * not take ownership */
109 for ( const Trk::CurvilinearParameters& clParameter : clParametersVector) {
110 if (parametersMap[getLayer(&clParameter)] == nullptr) {
111 parametersMap[getLayer(&clParameter)] = &clParameter;
112 } else if (m_trackParametersIdHelper->isEntryToVolume(clParameter.cIdentifier())) {
113 parametersMap[getLayer(&clParameter)] = &clParameter;
114 }
115
116 CaloCell_ID::CaloSample caloSample = m_trackParametersIdHelper->caloSample(clParameter.cIdentifier());
117
118 if (tileParametersMap[caloSample] == nullptr){
119 tileParametersMap[caloSample] = &clParameter;
120 } else if (m_trackParametersIdHelper->isEntryToVolume(clParameter.cIdentifier())){
121 tileParametersMap[caloSample] = &clParameter;
122 }
123
124 }
125
126
127 /*
128 parametersMap may have several entries for Tile1,2,3.
129 The impact is negligible as the eta/phi of these entries are very similar
130 https://its.cern.ch/jira/browse/ATLJETMET-242
131 */
132
133 return std::make_unique<eflowTrackCaloPoints>(parametersMap,tileParametersMap);
134
135 }
136 else{
137 if (track->pt() > 3*Gaudi::Units::GeV) ATH_MSG_WARNING("TrackExtension failed for track with pt and eta " << track->pt() << " and " << track->eta());
138 parametersMap[eflowCalo::LAYER::Unknown] = nullptr;
139 return std::make_unique<eflowTrackCaloPoints>(parametersMap);
140 }
141}
142
144 return StatusCode::SUCCESS;
145}
146
147/*This function translates the information embedded within the CurvilinearParameters of the CaloExtension object into an eflowCaloLayer*/
149 unsigned int parametersIdentifier = clParameter->cIdentifier();
150
151 /*Return unknown when the identifier is invalid */
152 if (!m_trackParametersIdHelper->isValid(parametersIdentifier)) {
153 ATH_MSG_ERROR("invalid Track Identifier");
155 };
156
157 if(m_trackParametersIdHelper->isEntryToVolume(parametersIdentifier)) {
158 ATH_MSG_VERBOSE("is Volume Entry");
159 } else {
160 ATH_MSG_VERBOSE("is Volume Exit");
161 }
162
163 return eflowCalo::translateSampl(m_trackParametersIdHelper->caloSample(parametersIdentifier));
164}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Declaration of CaloDepthTool.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
CaloSampling::CaloSample CaloSample
Definition CaloCell_ID.h:53
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
Helper class to create a scoped timer.
A monitored timer.
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.
unsigned int cIdentifier() const
the curvilinear parameters identifier
static LAYER translateSampl(CaloCell_ID::CaloSample sampl)
virtual std::unique_ptr< eflowTrackCaloPoints > execute(const EventContext &ctx, const xAOD::TrackParticle *track) const override
ToolHandle< Trk::IParticleCaloExtensionTool > m_theTrackExtrapolatorTool
virtual StatusCode finalize() override
eflowCalo::LAYER getLayer(const Trk::CurvilinearParameters *clParameters) const
std::unique_ptr< Trk::TrackParametersIdHelper > m_trackParametersIdHelper
virtual StatusCode initialize() override
SG::ReadHandleKey< CaloExtensionCollection > m_ParticleCacheKey
eflowTrackCaloExtensionTool(const std::string &type, const std::string &name, const IInterface *parent)
ToolHandle< GenericMonitoringTool > m_monTool
Online monitoring tool for recording histograms of the alg in action.
Ensure that the ATLAS eigen extensions are properly loaded.
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
Definition index.py:1
STL namespace.
TrackParticle_v1 TrackParticle
Reference the current persistent version: