ATLAS Offline Software
Loading...
Searching...
No Matches
eflowTrackCaloExtensionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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_theTrackExtrapolatorTool("Trk::ParticleCaloExtensionTool",this),
35 m_trackParametersIdHelper(std::make_unique<Trk::TrackParametersIdHelper>())
36{
37 declareInterface<eflowTrackExtrapolatorBaseAlgTool>(this);
38 declareProperty("TrackCaloExtensionTool", m_theTrackExtrapolatorTool, "TrackCaloExtension Tool Handle");
39}
40
42
44
45 if (m_theTrackExtrapolatorTool.retrieve().isFailure()) {
46 ATH_MSG_WARNING("Cannot find Extrapolation tool "
47 << m_theTrackExtrapolatorTool.typeAndName());
48 return StatusCode::SUCCESS;
49 } else {
50 ATH_MSG_VERBOSE("Successfully retrieved Extrapolation tool "
51 << m_theTrackExtrapolatorTool.typeAndName());
52 }
53
54 if (!m_ParticleCacheKey.key().empty()) ATH_CHECK(m_ParticleCacheKey.initialize());
55 else m_useOldCalo = true;
56
57 if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve());
58
59 return StatusCode::SUCCESS;
60}
61
62std::unique_ptr<eflowTrackCaloPoints> eflowTrackCaloExtensionTool::execute(const xAOD::TrackParticle* track) const {
63
64 ATH_MSG_VERBOSE(" Now running eflowTrackCaloExtensionTool");
65
66 auto execution_timer = Monitored::Timer<std::chrono::microseconds>( "TIME_execute" );
67 Monitored::ScopedTimer execution_time(execution_timer);
68 auto extrapolation_timer = Monitored::Timer<std::chrono::microseconds>( "TIME_extrapolation" );
69 auto track_pt = Monitored::Scalar<float>("track_pt");
70 auto group = Monitored::Group(m_monTool, execution_timer, extrapolation_timer, track_pt);
71
72 track_pt = track->pt() * m_invGeV ;
73
74 /*Create a map to index the TrackParameters at calo (owned by the extension) wrt to layers*/
75 std::map<eflowCalo::LAYER, const Trk::TrackParameters*> parametersMap;
76 std::map<CaloCell_ID::CaloSample,const Trk::TrackParameters*> tileParametersMap;
77
78 /*get the CaloExtension object*/
79 const Trk::CaloExtension * extension = nullptr;
80 std::unique_ptr<Trk::CaloExtension> uniqueExtension;
81 const int index = track->index();
82 ATH_MSG_VERBOSE("Getting element " << index << " from the particleCache");
83
84 extrapolation_timer.start();
85 if (m_useOldCalo) {
86 /* If CaloExtensionBuilder is unavailable, use the calo extension tool */
87 ATH_MSG_VERBOSE("Using the CaloExtensionTool");
88 uniqueExtension = m_theTrackExtrapolatorTool->caloExtension(
89 Gaudi::Hive::currentContext(), *track);
90 extension = uniqueExtension.get();
91 } else {
92 /*get the CaloExtension object*/
94 ATH_MSG_VERBOSE("Using the CaloExtensionBuilder Cache");
95 extension = (*particleCache)[index];
96 ATH_MSG_VERBOSE("Getting element " << index << " from the particleCache");
97 if( not extension ){
98 ATH_MSG_VERBOSE("Cache does not contain a calo extension -> Calculating with the a CaloExtensionTool" );
99 uniqueExtension = m_theTrackExtrapolatorTool->caloExtension(
100 Gaudi::Hive::currentContext(), *track);
101 extension = uniqueExtension.get();
102 }
103 }
104 extrapolation_timer.stop();
105
106 if (extension != nullptr) {
107
108 /*extract the CurvilinearParameters*/
109 const std::vector<Trk::CurvilinearParameters>& clParametersVector = extension->caloLayerIntersections();
110
111 /*The parameters are owned by the CaloExtension so are handled by it the eflowTrackCaloPoints does
112 * not take ownership */
113 for ( const Trk::CurvilinearParameters& clParameter : clParametersVector) {
114 if (parametersMap[getLayer(&clParameter)] == nullptr) {
115 parametersMap[getLayer(&clParameter)] = &clParameter;
116 } else if (m_trackParametersIdHelper->isEntryToVolume(clParameter.cIdentifier())) {
117 parametersMap[getLayer(&clParameter)] = &clParameter;
118 }
119
120 CaloCell_ID::CaloSample caloSample = m_trackParametersIdHelper->caloSample(clParameter.cIdentifier());
121
122 if (tileParametersMap[caloSample] == nullptr){
123 tileParametersMap[caloSample] = &clParameter;
124 } else if (m_trackParametersIdHelper->isEntryToVolume(clParameter.cIdentifier())){
125 tileParametersMap[caloSample] = &clParameter;
126 }
127
128 }
129
130
131 /*
132 parametersMap may have several entries for Tile1,2,3.
133 The impact is negligible as the eta/phi of these entries are very similar
134 https://its.cern.ch/jira/browse/ATLJETMET-242
135 */
136
137 return std::make_unique<eflowTrackCaloPoints>(parametersMap,tileParametersMap);
138
139 }
140 else{
141 if (track->pt() > 3*Gaudi::Units::GeV) ATH_MSG_WARNING("TrackExtension failed for track with pt and eta " << track->pt() << " and " << track->eta());
142 parametersMap[eflowCalo::LAYER::Unknown] = nullptr;
143 return std::make_unique<eflowTrackCaloPoints>(parametersMap);
144 }
145}
146
148 return StatusCode::SUCCESS;
149}
150
151/*This function translates the information embedded within the CurvilinearParameters of the CaloExtension object into an eflowCaloLayer*/
153 unsigned int parametersIdentifier = clParameter->cIdentifier();
154
155 /*Return unknown when the identifier is invalid */
156 if (!m_trackParametersIdHelper->isValid(parametersIdentifier)) {
157 ATH_MSG_ERROR("invalid Track Identifier");
159 };
160
161 if(m_trackParametersIdHelper->isEntryToVolume(parametersIdentifier)) {
162 ATH_MSG_VERBOSE("is Volume Entry");
163 } else {
164 ATH_MSG_VERBOSE("is Volume Exit");
165 }
166
167 return eflowCalo::translateSampl(m_trackParametersIdHelper->caloSample(parametersIdentifier));
168}
#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:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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)
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 std::unique_ptr< eflowTrackCaloPoints > execute(const xAOD::TrackParticle *track) const override
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: