ATLAS Offline Software
McEnergyLossUpdator.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 // class header
6 #include "McEnergyLossUpdator.h"
7 
8 // Trk
11 
12 #include "CLHEP/Random/RandLandau.h"
13 #include "CLHEP/Random/RandGaussZiggurat.h"
15 
16 
17 
18 iFatras::McEnergyLossUpdator::McEnergyLossUpdator( const std::string& type, const std::string& name, const IInterface* parent )
19  :
20  base_class( type, name, parent )
21 {
22 }
23 
24 
26 {
27  ATH_MSG_VERBOSE( "initialize()" );
28 
29  // Retrieve the energy loss updator tool
30  ATH_CHECK ( m_energyLossUpdator.retrieve() );
31 
32  // get the random generator serice
33  ATH_CHECK ( m_rndGenSvc.retrieve() );
34 
35  //Get own engine with own seeds:
36  m_randomEngine = m_rndGenSvc->GetEngine(m_randomEngineName);
37  if (!m_randomEngine) {
38  ATH_MSG_FATAL( "Could not get random engine '" << m_randomEngineName << "'" );
39  return StatusCode::FAILURE;
40  }
41 
42  return StatusCode::SUCCESS;
43 }
44 
45 
47  double momentum,
48  Trk::ParticleHypothesis particleHypothesis ) const
49 {
50  // simply forward the dEdX from the standard energy loss updator
51  return m_energyLossUpdator->dEdX( materialProperties, momentum, particleHypothesis );
52 }
53 
56  const Trk::MaterialProperties& materialProperties,
57  double momentum,
58  double pathCorrection,
59  Trk::PropDirection direction,
60  Trk::ParticleHypothesis particleHypothesis,
61  bool) const
62 {
63 
64 
65  // get the number of the material effects distribution
66  Trk::EnergyLoss sampledEloss =
67  m_energyLossUpdator->energyLoss(materialProperties,
68  momentum,
69  pathCorrection,
70  direction,
71  particleHypothesis,
72  m_usePDGformula);
73 
74 
75  // smear according to preselected distribution
76  switch (m_energyLossDistribution) {
77  // no straggling
78  case 0 : { } break;
79  // gaussian smearing
80  case 1 : {
81  float deIoni = sampledEloss.sigmaIoni() * CLHEP::RandGaussZiggurat::shoot(m_randomEngine);
82  float deRad = sampledEloss.sigmaRad() * CLHEP::RandGaussZiggurat::shoot(m_randomEngine);
83  sampledEloss.update(deIoni,0.,deRad,0.,false);
84  } break;
85  case 2 : {
86  float deIoni = -sampledEloss.sigmaIoni() * CLHEP::RandLandau::shoot(m_randomEngine); // TODO :check sign
87  sampledEloss.update(deIoni,0.,0.,0.,false);
88  } break;
89  // landau smearing
90  default : {
91  float deIoni = -sampledEloss.sigmaIoni() * CLHEP::RandLandau::shoot(m_randomEngine); // TODO :check sign
92  float deRad = -sampledEloss.sigmaRad() * CLHEP::RandLandau::shoot(m_randomEngine); // TODO :check sign
93  sampledEloss.update(deIoni,0.,deRad,0.,false);
94  } break;
95  }
96 
97  // protection due to straggling - maximum energy loss is E-m
98  double m = Trk::ParticleMasses::mass[particleHypothesis];
99  double E = sqrt(momentum*momentum+m*m);
100 
101  if (sampledEloss.deltaE()+E<m ) { // particle stopping - rest energy
102  float dRad_rest = m-E-sampledEloss.deltaE();
103  sampledEloss.update(0.,0.,dRad_rest,0.,false);
104  }
105 
106  return sampledEloss;
107 }
Trk::EnergyLoss::update
void update(double ioni, double sigi, double rad, double sigr, bool mpv=false)
EnergyLoss.h
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
iFatras::McEnergyLossUpdator::McEnergyLossUpdator
McEnergyLossUpdator(const std::string &, const std::string &, const IInterface *)
Constructor with AlgTool parameters.
Definition: McEnergyLossUpdator.cxx:18
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
MaterialProperties.h
Trk::EnergyLoss::sigmaRad
double sigmaRad() const
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Trk::ParticleHypothesis
ParticleHypothesis
Definition: ParticleHypothesis.h:25
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
iFatras::McEnergyLossUpdator::initialize
virtual StatusCode initialize() override
AlgTool initialise method.
Definition: McEnergyLossUpdator.cxx:25
McEnergyLossUpdator.h
Trk::EnergyLoss::deltaE
double deltaE() const
returns the
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ParticleHypothesis.h
Trk::ParticleMasses::mass
constexpr double mass[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:53
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
iFatras::McEnergyLossUpdator::dEdX
virtual double dEdX(const Trk::MaterialProperties &materialProperties, double momentum, Trk::ParticleHypothesis particleHypothesis=Trk::pion) const override
IEnergyLossUpdator public method to compute dEdX.
Definition: McEnergyLossUpdator.cxx:46
Trk::EnergyLoss
This class describes energy loss material effects in the ATLAS tracking EDM.
Definition: EnergyLoss.h:34
iFatras::McEnergyLossUpdator::energyLoss
virtual Trk::EnergyLoss energyLoss(const Trk::MaterialProperties &materialProperties, double momentum, double pathCorrection, Trk::PropDirection direction=Trk::alongMomentum, Trk::ParticleHypothesis particleHypothesis=Trk::pion, bool usePDGformula=false) const override
IEnergyLossUpdator public method to compute the mean and variance of the energy loss.
Definition: McEnergyLossUpdator.cxx:55
Trk::MaterialProperties
Definition: MaterialProperties.h:40
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79
Trk::EnergyLoss::sigmaIoni
double sigmaIoni() const