ATLAS Offline Software
MuidMaterialEffectsOnTrackProvider.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // MuidMaterialEffectsOnTrackProvider.cxx, (c) ATLAS Detector software
8 
10 
13 #include "TrkGeometry/DiscLayer.h"
14 // #include "TrkGeometry/HomogenousLayerMaterial.h"
21 #include "TrkSurfaces/DiscBounds.h"
24 #include "muonEvent/CaloEnergy.h"
25 
26 // constructor
28  const IInterface* p) :
29  AthAlgTool(t, n, p) {
30  m_cosmics = false;
31  declareProperty("Cosmics", m_cosmics);
32  declareInterface<IMaterialEffectsOnTrackProvider>(this);
33 }
34 
35 // destructor
37 
38 // Athena standard methods
39 // initialize
41  if (!m_cosmics) {
42  ATH_CHECK(m_calotsos.retrieve());
43  ATH_MSG_INFO("Retrieved tool " << m_calotsos.name());
44 
45  if (!m_calotsosparam.empty()) {
46  ATH_CHECK(m_calotsosparam.retrieve());
47  ATH_MSG_INFO("Retrieved tool " << m_calotsosparam.name());
48  }
49 
50  ATH_CHECK(m_scattool.retrieve());
51  }
52  return StatusCode::SUCCESS;
53 }
54 
55 // finalize
57  ATH_MSG_DEBUG(name() << " finalize() successful");
58  return StatusCode::SUCCESS;
59 }
60 
62  const Trk::TrackingVolume& /*vol*/, const Trk::IPropagator& /*prop*/, const Trk::TrackParameters& parm, const Trk::Surface& /*surf*/,
63  Trk::PropDirection /*dir*/, Trk::ParticleHypothesis /*mateffects*/) const {
64  const EventContext& ctx = Gaudi::Hive::currentContext();
65  std::vector<Trk::MaterialEffectsOnTrack> meots;
66  if (m_cosmics) {
67  static const Trk::CylinderSurface outersurf(3700, 5000);
68  static const Trk::CylinderSurface innersurf(2000, 5000);
69  static const Trk::CylinderSurface middlesurf(2850, 5000);
70 
71  Amg::Vector3D position(0, -3700, 0);
72  double X0outer{60}, X0inner{60};
73 
75  std::pair<double, double> energy{-3000, 500};
76  ATH_MSG_DEBUG("first x0: " << X0inner << " second x0: " << X0outer << " eloss: " << energy.first << " sigma: " << energy.second);
77 
78  Trk::MaterialProperties matprop(X0outer, 1., 0., 0., 0., 0.);
79  double sigmascat = std::sqrt(m_scattool->sigmaSquare(matprop, std::abs(1. / parm.parameters()[Trk::qOverP]), 1., Trk::muon));
80 
81  Trk::ScatteringAngles newsa {0, 0, sigmascat / std::sin(parm.parameters()[Trk::theta]), sigmascat};
82  Trk::ScatteringAngles newsa2 {0, 0, sigmascat / std::sin(parm.parameters()[Trk::theta]), sigmascat};
83 
84  meots.emplace_back(X0inner, newsa, innersurf);
85  meots.emplace_back(
86  0,
87  std::make_unique<Trk::EnergyLoss>(energy.first, energy.second),
88  middlesurf,
90  meots.emplace_back(X0outer, newsa2, outersurf);
91 
92  } else {
93  std::vector<std::unique_ptr<const Trk::TrackStateOnSurface>> tsosvec = m_calotsos->caloTSOS(ctx, parm);
94  if (tsosvec.size() != 3 && !m_calotsosparam.empty()) { tsosvec = m_calotsosparam->caloTSOS(ctx, parm); }
95  for (const std::unique_ptr<const Trk::TrackStateOnSurface>& c_tsos : tsosvec) {
96  const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>(c_tsos->materialEffectsOnTrack());
97  if (!meot) continue;
98  double sintheta = std::sin(c_tsos->trackParameters()->parameters()[Trk::theta]);
99  double qoverp = c_tsos->trackParameters()->parameters()[Trk::qOverP];
100  const CaloEnergy* eloss = meot ? dynamic_cast<const CaloEnergy*>(meot->energyLoss()) : nullptr;
101 
102  std::unique_ptr<Trk::EnergyLoss> neweloss = nullptr;
103  std::optional<Trk::ScatteringAngles> newsa = std::nullopt;
104  if (eloss)
105  neweloss = std::make_unique<CaloEnergy>(*eloss);
106  else {
107  Trk::MaterialProperties matprop(meot->thicknessInX0(), 1., 0., 0., 0., 0.);
108  double sigmascat = std::sqrt(m_scattool->sigmaSquare(matprop, std::abs(1. / qoverp), 1., Trk::muon));
109  newsa = Trk::ScatteringAngles(0, 0, sigmascat / sintheta, sigmascat);
110  }
111  meots.emplace_back(meot->thicknessInX0(), newsa, std::move(neweloss), c_tsos->trackParameters()->associatedSurface());
112  }
113  }
114  if (meots.size() < 3) meots.clear();
115  return meots;
116 }
EnergyLoss.h
ScatteringAngles.h
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
DiscBounds.h
TrackParameters.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloEnergy
class extending the basic Trk::EnergyLoss to describe the measured or parameterised muon energy loss ...
Definition: CaloEnergy.h:28
Rec::MuidMaterialEffectsOnTrackProvider::initialize
StatusCode initialize()
AlgTool initailize method.
Definition: MuidMaterialEffectsOnTrackProvider.cxx:40
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DiscLayer.h
Trk::ScatteringAngles
represents a deflection of the track caused through multiple scattering in material.
Definition: ScatteringAngles.h:26
Trk::MaterialEffectsBase::thicknessInX0
double thicknessInX0() const
returns the actually traversed material .
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::ParticleHypothesis
ParticleHypothesis
Definition: ParticleHypothesis.h:25
GeoPrimitives.h
Trk::MaterialEffectsOnTrack
represents the full description of deflection and e-loss of a track in material.
Definition: MaterialEffectsOnTrack.h:40
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
beamspotman.n
n
Definition: beamspotman.py:731
Trk::theta
@ theta
Definition: ParamDefs.h:72
Trk::IPropagator
Definition: IPropagator.h:55
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
Trk::CylinderSurface
Definition: CylinderSurface.h:55
CylinderSurface.h
Rec::MuidMaterialEffectsOnTrackProvider::m_cosmics
bool m_cosmics
Definition: MuidMaterialEffectsOnTrackProvider.h:67
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CylinderLayer.h
Rec::MuidMaterialEffectsOnTrackProvider::MuidMaterialEffectsOnTrackProvider
MuidMaterialEffectsOnTrackProvider(const std::string &, const std::string &, const IInterface *)
AlgTool like constructor.
Definition: MuidMaterialEffectsOnTrackProvider.cxx:27
Trk::ParametersBase
Definition: ParametersBase.h:55
Rec::MuidMaterialEffectsOnTrackProvider::extrapolationSurfacesAndEffects
std::vector< Trk::MaterialEffectsOnTrack > extrapolationSurfacesAndEffects(const Trk::TrackingVolume &, const Trk::IPropagator &, const Trk::TrackParameters &, const Trk::Surface &, Trk::PropDirection, Trk::ParticleHypothesis) const
return all MaterialLayers associated to this track
Definition: MuidMaterialEffectsOnTrackProvider.cxx:61
Trk::muon
@ muon
Definition: ParticleHypothesis.h:28
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::MaterialEffectsBase::EnergyLossEffects
@ EnergyLossEffects
contains energy loss corrections
Definition: MaterialEffectsBase.h:48
CylinderBounds.h
Trk::MaterialProperties
Definition: MaterialProperties.h:40
TrackingVolume.h
Trk::MaterialEffectsOnTrack::energyLoss
const EnergyLoss * energyLoss() const
returns the energy loss object.
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:73
DiscSurface.h
MuidMaterialEffectsOnTrackProvider.h
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
AthAlgTool
Definition: AthAlgTool.h:26
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::TrackingVolume
Definition: TrackingVolume.h:121
Rec::MuidMaterialEffectsOnTrackProvider::~MuidMaterialEffectsOnTrackProvider
virtual ~MuidMaterialEffectsOnTrackProvider()
Virtual destructor.
Definition: MuidMaterialEffectsOnTrackProvider.cxx:36
TrackStateOnSurface.h
Rec::MuidMaterialEffectsOnTrackProvider::finalize
StatusCode finalize()
AlgTool finalize method.
Definition: MuidMaterialEffectsOnTrackProvider.cxx:56
CaloEnergy.h