8#include <tracking/trackFindingCDC/eventdata/utils/EnergyLossEstimator.h>
10#include <tracking/trackFindingCDC/eventdata/trajectories/CDCBFieldUtil.h>
12#include <tracking/trackFindingCDC/numerics/ESign.h>
14#include <geometry/GeometryManager.h>
16#include <framework/gearbox/Unit.h>
17#include <framework/gearbox/Const.h>
18#include <framework/logging/Logger.h>
20#include "G4ThreeVector.hh"
21#include "G4Navigator.hh"
22#include "G4VPhysicalVolume.hh"
23#include "G4Material.hh"
26using namespace TrackFindingCDC;
34 g4Nav.SetWorldVolume(g4World);
41 G4ThreeVector g4Pos(posX * CLHEP::cm, posY * CLHEP::cm, posZ * CLHEP::cm);
42 const G4VPhysicalVolume* g4Volume = g4Nav.LocateGlobalPointAndSetup(g4Pos);
43 const G4Material* g4Mat = g4Volume->GetLogicalVolume()->GetMaterial();
48 if (g4Mat->GetNumberOfElements() == 1) {
49 A = g4Mat->GetA() * CLHEP::mole / CLHEP::g;
53 for (
unsigned i = 0; i < g4Mat->GetNumberOfElements(); ++i) {
54 const G4Element* element = (*g4Mat->GetElementVector())[i];
55 const double elementA = element->GetA() * CLHEP::mole / CLHEP::g;
56 const double elementZ = element->GetZ();
57 const double frac = g4Mat->GetFractionVector()[i];
58 B2RESULT(
"Part " << i <<
" Z=" << elementZ <<
" A=" << elementA <<
" (" << frac <<
")");
66 const double density = g4Mat->GetDensity() / CLHEP::g * CLHEP::cm3;
67 const double radiationLength = g4Mat->GetRadlen() / CLHEP::cm;
68 const double mEE = g4Mat->GetIonisation()->GetMeanExcitationEnergy() / CLHEP::GeV;
70 B2RESULT(
"Received Z " << Z);
71 B2RESULT(
"Received A " << A);
72 B2RESULT(
"Received density " << density);
73 B2RESULT(
"Received radiation length " << radiationLength);
74 B2RESULT(
"Received mean excitation energy " << mEE);
76 const double eDensity = Z * density / A;
77 B2RESULT(
"Received electron density " << eDensity);
87 const double electronMass = 0.511 *
Unit::MeV;
89 }
else if (std::abs(pdgCode) ==
Const::muon.getPDGCode()) {
90 const double muonMass = 105.658 *
Unit::MeV;
92 }
else if (std::abs(pdgCode) ==
Const::kaon.getPDGCode()) {
93 const double kaonMass = 0.493677;
95 }
else if (std::abs(pdgCode) ==
Const::pion.getPDGCode()) {
96 const double pionMass = 0.13957;
99 const double protonMass = 0.938272;
108 return -sign(pdgCode);
109 }
else if (std::abs(pdgCode) ==
Const::muon.getPDGCode()) {
110 return -sign(pdgCode);
111 }
else if (std::abs(pdgCode) ==
Const::kaon.getPDGCode()) {
112 return sign(pdgCode);
113 }
else if (std::abs(pdgCode) ==
Const::pion.getPDGCode()) {
114 return sign(pdgCode);
115 }
else if (std::abs(pdgCode) ==
Const::proton.getPDGCode()) {
116 return sign(pdgCode);
122 : m_eDensity(eDensity)
130 static const double eMass =
getMass(11);
132 const double M =
getMass(pdgCode);
134 const double E = std::sqrt(p * p + M * M);
135 const double gamma =
E / M;
136 const double beta = p /
E;
138 const double beta2 = beta * beta;
139 const double gamma2 = gamma * gamma;
141 const double Wmax = 2 * eMass * beta2 * gamma2 / (1 + 2 * gamma * eMass / M);
142 const double I2 =
m_I *
m_I;
146 (1.0 / 2.0 * std::log(2 * eMass * beta2 * gamma2 * Wmax / I2) - beta2);
153 const double eLoss = arcLength * dEdx;
160 return (p - eLoss) / p;
162 const double mass =
getMass(pdgCode);
164 const double eBefore = std::sqrt(p * p + mass * mass);
165 const double eAfter = eBefore - eLoss;
166 const double pAfter = std::sqrt(eAfter * eAfter - mass * mass);
172 const double eLoss =
getEnergyLoss(pt, pdgCode, arcLength2D);
176 return radius * eLoss / (pt - eLoss);
static const ChargedStable muon
muon particle
static const ChargedStable pion
charged pion particle
static const ChargedStable proton
proton particle
static const ChargedStable kaon
charged kaon particle
static const ChargedStable electron
electron particle
static double getBFieldZ()
Getter for the signed magnetic field strength in z direction at the origin ( in Tesla )
static double absMom2DToBendRadius(double absMom2D, double bZ)
Conversion helper for momenta to two dimensional (absolute) bend radius.
Helper struct to provide consistent energy loss estimation throughout the CDC track finding.
double getLossDist2D(double pt, int pdgCode, double arcLength2D) const
Calculates a correction term for the two dimensional distance undoing the energy loss after the given...
double getMomentumLossFactor(double p, int pdgCode, double arcLength) const
Calculates a factor applicable scaling the current momentum to the momentum after traveling given arc...
static EnergyLossEstimator forCDC()
Create an energy loss estimator with the material properties of the CDC.
double m_eDensity
Electron density in mol / cm^3.
double m_bZ
B field to be used for the distance translation.
static int getCharge(int pdgCode)
Lookup the charge for the given pdg code.
double getEnergyLoss(double p, int pdgCode, double arcLength) const
Calculates the total energy loss after travelling the given distance.
static double getMass(int pdgCode)
Lookup the mass for the given pdg code.
double m_I
Mean excitation energy in GeV.
EnergyLossEstimator(double eDensity, double I, double bZ=NAN)
Constructor from the material properties.
double getBetheStoppingPower(double p, int pdgCode) const
Stopping power aka energy loss / arc length.
static const double MeV
[megaelectronvolt]
static const double cm2
[square centimeters]
G4VPhysicalVolume * getTopVolume()
Return a pointer to the top volume.
static GeometryManager & getInstance()
Return a reference to the instance.
Abstract base class for different kinds of events.