ATLAS Offline Software
egammaTraversedMaterialFillerTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
19 #include "CLHEP/Units/SystemOfUnits.h"
20 #include <vector>
21 
22 
23 using CLHEP::GeV;
24 
25 
26 namespace 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 
58  {
59  }
60 
62  {
63  CHECK( m_extrapolator.retrieve() );
64  CHECK( m_caloSurfaceBuilder.retrieve() );
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
114  &vx->trackParticle(0)->perigeeParameters();
115 
116  if (vx->nTrackParticles() > 1 && parameters) {
117  const Trk::TrackParameters* p2 =
118  &vx->trackParticle(1)->perigeeParameters();
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
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 
157  if (fabs(cl->eta()) < 1.5)
159  else //if (fabs(cl->eta()) < 1.8)
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
xAOD::Vertex_v1::nTrackParticles
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Definition: Vertex_v1.cxx:270
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
TrackParameters.h
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ParticleTest.eg
eg
Definition: ParticleTest.py:29
IExtrapolator.h
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
D3PD::AddVariable::addVariable
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Add a variable to the tuple.
Definition: AddVariable.cxx:85
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
D3PD::egammaTraversedMaterialFillerTool::~egammaTraversedMaterialFillerTool
virtual ~egammaTraversedMaterialFillerTool()
Definition: egammaTraversedMaterialFillerTool.cxx:57
D3PD::egammaTraversedMaterialFillerTool::m_materialTraversed
float * m_materialTraversed
Variable: Material traversed between vertex (conversion vertex) and the entrance of the calorimeter (...
Definition: egammaTraversedMaterialFillerTool.h:91
CaloCell_ID.h
xAOD::TrackParticle_v1::perigeeParameters
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
Definition: TrackParticle_v1.cxx:485
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
D3PD::egammaTraversedMaterialFillerTool::m_extrapolator
ToolHandle< Trk::IExtrapolator > m_extrapolator
Property: The extrapolator tool.
Definition: egammaTraversedMaterialFillerTool.h:94
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
D3PD::BlockFillerTool< Types< xAOD::Electron, xAOD::Photon > >
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
xAOD::Vertex_v1::trackParticle
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
Definition: Vertex_v1.cxx:249
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::muon
@ muon
Definition: ParticleHypothesis.h:28
D3PD::egammaTraversedMaterialFillerTool::fill
virtual StatusCode fill(const xAOD::Electron &p) override
Fill one block — type-safe version.
Definition: egammaTraversedMaterialFillerTool.cxx:90
ICaloSurfaceBuilder.h
Trk::ParametersBase::pT
double pT() const
Access method for transverse momentum.
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
D3PD::egammaTraversedMaterialFillerTool::egammaTraversedMaterialFillerTool
egammaTraversedMaterialFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition: egammaTraversedMaterialFillerTool.cxx:35
errorcheck.h
Helpers for checking error return status codes and reporting errors.
D3PD::egammaTraversedMaterialFillerTool::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: egammaTraversedMaterialFillerTool.h:99
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
xAOD::Electron_v1
Definition: Electron_v1.h:34
D3PD::egammaTraversedMaterialFillerTool::book
virtual StatusCode book() final
Book variables for this block.
Definition: egammaTraversedMaterialFillerTool.cxx:72
python.PyAthena.v
v
Definition: PyAthena.py:157
D3PD::egammaTraversedMaterialFillerTool::m_minPt
float m_minPt
Property: Minimum track pT to do the extrapolation.
Definition: egammaTraversedMaterialFillerTool.h:106
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
D3PD::egammaTraversedMaterialFillerTool::m_caloSurfaceBuilder
ToolHandle< ICaloSurfaceBuilder > m_caloSurfaceBuilder
Property: CaloSurfaceBuilder tool.
Definition: egammaTraversedMaterialFillerTool.h:97
xAOD::Photon_v1
Definition: Photon_v1.h:37
CaloCell_ID_FCS::PreSamplerE
@ PreSamplerE
Definition: FastCaloSim_CaloCell_ID.h:23
CaloCell_ID_FCS::PreSamplerB
@ PreSamplerB
Definition: FastCaloSim_CaloCell_ID.h:19
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
D3PD::egammaTraversedMaterialFillerTool::initialize
virtual StatusCode initialize() override
Definition: egammaTraversedMaterialFillerTool.cxx:61
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
egammaTraversedMaterialFillerTool.h
Block filler tool for the material traversed by a photon/electron until the entrance of the calorimet...