ATLAS Offline Software
Loading...
Searching...
No Matches
egammaTraversedMaterialFillerTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
11
12
19#include "CLHEP/Units/SystemOfUnits.h"
20#include <vector>
21
22
23using CLHEP::GeV;
24
25
26namespace D3PD {
27
35 (const std::string& type,
36 const std::string& name,
37 const IInterface* parent)
38 : Base (type, name, parent),
39 m_extrapolator (this, "Trk::Extrapolator/AtlasExtrapolator"),
40 m_caloSurfaceBuilder ("CaloSurfaceBuilder")
41 {
42 declareProperty ("Extrapolator",
44 "Extrapolator tool.");
45
46 declareProperty ("CaloSurfaceBuilder",
48 "CaloSurfaceBuilder tool.");
49
50 declareProperty ("MinPt",
51 m_minPt = 1 * GeV,
52 "Minimum track pT to do the extrapolation.");
53
54 book().ignore(); // avoid coverity warnings.
55 }
56
60
62 {
63 CHECK( m_extrapolator.retrieve() );
64 CHECK( m_caloSurfaceBuilder.retrieve() );
65 CHECK(m_caloMgrKey.initialize());
66 return StatusCode::SUCCESS;
67 }
68
73 {
74 CHECK( addVariable ("materialTraversed", m_materialTraversed,
75 "Material traversed between vertex "
76 "(conversion vertex) and the entrance of the "
77 "calorimeter (in X0)") );
78 return StatusCode::SUCCESS;
79 }
80
81
91 {
92 const xAOD::TrackParticle* trackParticle = p.trackParticle();
93 if (trackParticle)
94 CHECK( fill (p, trackParticle->perigeeParameters()) );
95 return StatusCode::SUCCESS;
96 }
97
98
108 {
109 const xAOD::Vertex* vx = p.vertex();
110 if (!vx || vx->nTrackParticles() < 1) return StatusCode::SUCCESS;
111
112 // Set as parameters the ones of the highest pT track at the conv. vertex
113 const Trk::TrackParameters* parameters =
115
116 if (vx->nTrackParticles() > 1 && parameters) {
117 const Trk::TrackParameters* p2 =
119 if (p2 && p2->pT() > parameters->pT()) parameters = p2;
120 }
121
122 if(parameters){
123 CHECK( fill (p, *parameters) );
124 }
125 return StatusCode::SUCCESS;
126 }
127
128
134 StatusCode
136 const Trk::TrackParameters& parameters)
137 {
138
140 const CaloDetDescrManager* caloDDMgr = *caloMgrHandle;
141
142 if (parameters.pT() < m_minPt)
143 {
144 ATH_MSG_DEBUG("Momentum too low");
145 return StatusCode::SUCCESS;
146 }
147
148 // Define surface to extrapolate to (PS barrel, endcap or strips)
149 const xAOD::CaloCluster *cl = eg.caloCluster();
150 if (!cl)
151 {
152 ATH_MSG_DEBUG("Invalid pointer to cluster object");
153 return StatusCode::SUCCESS;
154 }
155
156 CaloCell_ID::CaloSample sample = CaloCell_ID::EME1;
157 if (fabs(cl->eta()) < 1.5)
158 sample = CaloCell_ID::PreSamplerB;
159 else //if (fabs(cl->eta()) < 1.8)
160 sample = CaloCell_ID::PreSamplerE;
161
162 // create a surface at the entrance of the sample (0 is the offset)
163 std::unique_ptr<Trk::Surface> surface
164 (m_caloSurfaceBuilder->CreateUserSurface(sample, 0., cl->eta(), caloDDMgr));
165 if (!surface)
166 {
167 ATH_MSG_DEBUG("Could not create surface at entrance of sample " << sample);
168 return StatusCode::SUCCESS;
169 }
170
171 // Extrapolate to surface
172 typedef std::vector<const Trk::TrackStateOnSurface*> tsos_vec_t;
173 std::unique_ptr<const tsos_vec_t> v
174 (m_extrapolator->extrapolateM (
175 Gaudi::Hive::currentContext(),
176 parameters,
177 *surface,
179 true,
180 Trk::muon));
181 if (!v)
182 {
183 ATH_MSG_DEBUG("Extrapolation failed");
184 return StatusCode::SUCCESS;
185 }
186
187 // Sum the amount of material traversed
188 for (const Trk::TrackStateOnSurface* tsos : *v) {
189 if (tsos->materialEffectsOnTrack())
190 {
191 //ATH_MSG_INFO("Material effects");
192 //tsos->materialEffectsOnTrack()->dump( msg(MSG::INFO) );
193 *m_materialTraversed += tsos->materialEffectsOnTrack()->thicknessInX0();
194 }
195 delete tsos;
196 }
197 return StatusCode::SUCCESS;
198 }
199
200
201} // namespace D3PD
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
CaloSampling::CaloSample CaloSample
Definition CaloCell_ID.h:53
This class provides the client interface for accessing the detector description information common to...
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
float * m_materialTraversed
Variable: Material traversed between vertex (conversion vertex) and the entrance of the calorimeter (...
BlockFillerTool< Types< xAOD::Electron, xAOD::Photon > > Base
float m_minPt
Property: Minimum track pT to do the extrapolation.
virtual StatusCode book() final
Book variables for this block.
ToolHandle< Trk::IExtrapolator > m_extrapolator
Property: The extrapolator tool.
ToolHandle< ICaloSurfaceBuilder > m_caloSurfaceBuilder
Property: CaloSurfaceBuilder tool.
virtual StatusCode fill(const xAOD::Electron &p) override
Fill one block — type-safe version.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
egammaTraversedMaterialFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
represents the track state (measurement, material, fit parameters and quality) at a surface.
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
Block filler tool for the material traversed by a photon/electron until the entrance of the calorimet...
Block filler tool for noisy FEB information.
@ alongMomentum
ParametersBase< TrackParametersDim, Charged > TrackParameters
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.
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".