9#include <simulation/kernel/EnergyLossForExtrapolator.h>
11#include <CLHEP/Units/PhysicalConstants.h>
12#include <CLHEP/Units/SystemOfUnits.h>
14#include <G4PhysicsLogVector.hh>
15#include <G4ParticleDefinition.hh>
16#include <G4Material.hh>
17#include <G4MaterialCutsCouple.hh>
18#include <G4ParticleTable.hh>
19#include <G4LossTableBuilder.hh>
20#include <G4MollerBhabhaModel.hh>
21#include <G4BetheBlochModel.hh>
22#include <G4eBremsstrahlungRelModel.hh>
23#include <G4MuPairProductionModel.hh>
24#include <G4MuBremsstrahlungModel.hh>
25#include <G4ProductionCuts.hh>
26#include <G4LossTableManager.hh>
27#include <G4WentzelVIModel.hh>
29#include <framework/logging/Logger.h>
32using namespace Belle2::Simulation;
45 m_AntiProton(nullptr),
47 m_AntiDeuteron(nullptr),
48 m_ProductionCuts(nullptr),
49 m_DedxElectron(nullptr),
50 m_DedxPositron(nullptr),
54 m_DedxProton(nullptr),
55 m_DedxDeuteron(nullptr),
56 m_RangeElectron(nullptr),
57 m_RangePositron(nullptr),
61 m_RangeProton(nullptr),
62 m_RangeDeuteron(nullptr),
63 m_InvRangeElectron(nullptr),
64 m_InvRangePositron(nullptr),
65 m_InvRangeMuon(nullptr),
66 m_InvRangePion(nullptr),
67 m_InvRangeKaon(nullptr),
68 m_InvRangeProton(nullptr),
69 m_InvRangeDeuteron(nullptr),
70 m_MscatElectron(nullptr),
83 m_UserTmin(1.*CLHEP::MeV),
84 m_UserTmax(10.*CLHEP::TeV),
85 m_UserMaxEnergyTransfer(DBL_MAX),
118 for (
const G4MaterialCutsCouple* couple :
m_Couples)
delete couple;
124 const G4Material* mat,
125 const G4ParticleDefinition* part)
128 G4double kinEnergyFinal = kinEnergy;
133 kinEnergyFinal = 0.0;
135 kinEnergyFinal -= step *
ComputeDEDX(kinEnergy, part);
137 G4double r1 = r - step;
141 return kinEnergyFinal;
146 const G4Material* mat,
147 const G4ParticleDefinition* part)
150 G4double kinEnergyFinal = kinEnergy;
157 kinEnergyFinal += step *
ComputeDEDX(kinEnergy, part);
159 G4double r1 = r + step;
163 return kinEnergyFinal;
168 const G4Material* mat,
169 const G4ParticleDefinition* part)
171 G4double res = stepLength;
176 if (x < 0.2) res *= (1.0 + 0.5 * x + x * x / 3.0);
177 else if (x < 0.9999) res = -std::log(1.0 - x) * stepLength / x;
188 const G4Material* mat,
191 if (!part || !mat || kinEnergy < CLHEP::keV)
return false;
197 m_Mass = part->GetPDGMass();
198 G4double q = part->GetPDGCharge() / CLHEP::eplus;
202 G4int i = mat->GetIndex();
204 B2WARNING(
"EnergyLossForExtrapolator: index i= " << i <<
" is out of table - NO extrapolation");
215 G4double tau = kinEnergy /
m_Mass;
223 G4double r = CLHEP::electron_mass_c2 /
m_Mass;
234 B2DEBUG(20,
"EnergyLossForExtrapolator::Initialisation");
239 m_Electron = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_e-");
240 m_Positron = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_e+");
241 m_MuonPlus = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_mu+");
242 m_MuonMinus = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_mu-");
243 m_PionPlus = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_pi+");
244 m_PionMinus = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_pi-");
245 m_KaonPlus = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_kaon+");
246 m_KaonMinus = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_kaon-");
247 m_Proton = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_proton");
248 m_AntiProton = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_anti_proton");
249 m_Deuteron = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_deuteron");
250 m_AntiDeuteron = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_anti_deuteron");
253 const G4MaterialTable* mtable = G4Material::GetMaterialTable();
286 G4LossTableBuilder& builder = *(G4LossTableManager::Instance()->GetTableBuilder());
287 builder.SetBaseMaterialActive(
false);
289 B2DEBUG(20,
"EnergyLossForExtrapolator Builds electron tables");
294 B2DEBUG(20,
"EnergyLossForExtrapolator Builds positron tables");
299 B2DEBUG(20,
"EnergyLossForExtrapolator Builds muon tables");
304 B2DEBUG(20,
"EnergyLossForExtrapolator Builds pion tables");
309 B2DEBUG(20,
"EnergyLossForExtrapolator Builds kaon tables");
314 B2DEBUG(20,
"EnergyLossForExtrapolator Builds proton tables");
319 B2DEBUG(20,
"EnergyLossForExtrapolator Builds deuteron tables");
329 G4PhysicsTable* table =
new G4PhysicsTable();
340 const G4ParticleDefinition* part)
358 B2FATAL(
"EnergyLossForExtrapolator::ComputeDEDX has no table for particle " << part->GetParticleName());
364 const G4ParticleDefinition* part)
382 B2FATAL(
"EnergyLossForExtrapolator::ComputeRange has no table for particle " << part->GetParticleName());
388 const G4ParticleDefinition* part)
406 B2FATAL(
"EnergyLossForExtrapolator::ComputeEnergy has no table for particle " << part->GetParticleName());
412 G4PhysicsTable* table)
414 G4MollerBhabhaModel* ioni =
new G4MollerBhabhaModel();
415 G4eBremsstrahlungRelModel* brem =
new G4eBremsstrahlungRelModel();
416 G4ParticleChange* ioniPC =
new G4ParticleChange();
417 ioni->SetParticleChange(ioniPC);
418 G4ParticleChange* bremPC =
new G4ParticleChange();
419 brem->SetParticleChange(bremPC);
420 ioni->Initialise(part,
m_Cuts);
421 brem->Initialise(part,
m_Cuts);
422 m_Mass = CLHEP::electron_mass_c2;
425 B2DEBUG(20,
"EnergyLossForExtrapolator::ComputeElectronDEDX"
426 <<
LogVar(
"particle", part->GetParticleName())
429 const G4MaterialCutsCouple* couple =
m_Couples[i];
430 const G4Material* material = couple->GetMaterial();
432 assert((*G4Material::GetMaterialTable())[i] == material);
433 B2DEBUG(20,
"EnergyLossForExtrapolator::ComputeElectronDEDX()"
434 <<
LogVar(
"material index", i)
435 <<
LogVar(
"material name", material->GetName())
436 <<
LogVar(
"density [g/cm3]", material->GetDensity() * CLHEP::cm3 / CLHEP::g)
438 G4PhysicsVector* aVector = (*table)[i];
439 for (G4int j = 0; j <=
m_Nbins; j++) {
440 G4double e = aVector->Energy(j);
441 G4double dedx = ioni->ComputeDEDXPerVolume(material, part, e, e)
442 + brem->ComputeDEDXPerVolume(material, part, e, e);
443 B2DEBUG(20,
"EnergyLossForExtrapolator::ComputeElectronDEDX()"
445 <<
LogVar(
"energy [MeV]", e / CLHEP::MeV)
446 <<
LogVar(
"dE/dx [Mev/cm]", dedx * CLHEP::cm / CLHEP::MeV)
447 <<
LogVar(
"dE/dx [Mev/(g/cm2)]", dedx / ((CLHEP::MeV * material->GetDensity()) / (CLHEP::g / CLHEP::cm2)))
449 aVector->PutValue(j, dedx);
451 aVector->FillSecondDerivatives();
460 G4PhysicsTable* table)
462 G4BetheBlochModel* ioni =
new G4BetheBlochModel();
463 G4MuPairProductionModel* pair =
new G4MuPairProductionModel();
464 G4MuBremsstrahlungModel* brem =
new G4MuBremsstrahlungModel();
465 G4ParticleChange* ioniPC =
new G4ParticleChange();
466 ioni->SetParticleChange(ioniPC);
467 G4ParticleChange* pairPC =
new G4ParticleChange();
468 pair->SetParticleChange(pairPC);
469 G4ParticleChange* bremPC =
new G4ParticleChange();
470 brem->SetParticleChange(bremPC);
471 ioni->Initialise(part,
m_Cuts);
472 pair->Initialise(part,
m_Cuts);
473 brem->Initialise(part,
m_Cuts);
474 m_Mass = part->GetPDGMass();
477 B2DEBUG(20,
"EnergyLossForExtrapolator::ComputeMuonDEDX"
478 <<
LogVar(
"particle", part->GetParticleName())
481 const G4MaterialCutsCouple* couple =
m_Couples[i];
482 const G4Material* material = couple->GetMaterial();
483 B2DEBUG(20,
"EnergyLossForExtrapolator::ComputeMuonDEDX()"
484 <<
LogVar(
"material index", i)
485 <<
LogVar(
"material name", material->GetName())
486 <<
LogVar(
"density [g/cm3]", material->GetDensity() * CLHEP::cm3 / CLHEP::g)
488 G4PhysicsVector* aVector = (*table)[i];
489 for (G4int j = 0; j <=
m_Nbins; j++) {
490 G4double e = aVector->Energy(j);
491 G4double dedx = ioni->ComputeDEDXPerVolume(material, part, e, e)
492 + pair->ComputeDEDXPerVolume(material, part, e, e)
493 + brem->ComputeDEDXPerVolume(material, part, e, e);
494 aVector->PutValue(j, dedx);
495 B2DEBUG(20,
"EnergyLossForExtrapolator::ComputeMuonDEDX()"
497 <<
LogVar(
"energy [MeV]", e / CLHEP::MeV)
498 <<
LogVar(
"dE/dx [Mev/cm]", dedx * CLHEP::cm / CLHEP::MeV)
499 <<
LogVar(
"dE/dx [Mev/(g/cm2)]", dedx / ((CLHEP::MeV * material->GetDensity()) / (CLHEP::g / CLHEP::cm2)))
502 aVector->FillSecondDerivatives();
513 G4PhysicsTable* table)
515 G4BetheBlochModel* ioni =
new G4BetheBlochModel();
516 G4ParticleChange* ioniPC =
new G4ParticleChange();
517 ioni->SetParticleChange(ioniPC);
518 ioni->Initialise(part,
m_Cuts);
519 m_Mass = part->GetPDGMass();
520 double q = part->GetPDGCharge() / CLHEP::eplus;
523 B2DEBUG(20,
"EnergyLossForExtrapolator::ComputeHadronDEDX"
524 <<
LogVar(
"particle", part->GetParticleName())
527 const G4MaterialCutsCouple* couple =
m_Couples[i];
528 const G4Material* material = couple->GetMaterial();
529 B2DEBUG(20,
"EnergyLossForExtrapolator::ComputeHadronDEDX()"
530 <<
LogVar(
"material index", i)
531 <<
LogVar(
"material name", material->GetName())
532 <<
LogVar(
"density [g/cm3]", material->GetDensity() * CLHEP::cm3 / CLHEP::g)
534 G4PhysicsVector* aVector = (*table)[i];
535 for (G4int j = 0; j <=
m_Nbins; j++) {
536 G4double e = aVector->Energy(j);
537 G4double dedx = ioni->ComputeDEDXPerVolume(material, part, e, e);
538 aVector->PutValue(j, dedx);
539 B2DEBUG(20,
"EnergyLossForExtrapolator::ComputeHadronDEDX()"
541 <<
LogVar(
"energy [MeV]", e / CLHEP::MeV)
542 <<
LogVar(
"dE/dx [Mev/cm]", dedx * CLHEP::cm / CLHEP::MeV)
543 <<
LogVar(
"dE/dx [Mev/(g/cm2)]", dedx / ((CLHEP::MeV * material->GetDensity()) / (CLHEP::g / CLHEP::cm2)))
546 aVector->FillSecondDerivatives();
553 G4PhysicsTable* table)
555 G4WentzelVIModel* msc =
new G4WentzelVIModel();
556 G4ParticleChange* mscPC =
new G4ParticleChange();
557 msc->SetParticleChange(mscPC);
558 msc->SetPolarAngleLimit(CLHEP::pi);
559 msc->Initialise(part,
m_Cuts);
560 m_Mass = part->GetPDGMass();
561 double q = part->GetPDGCharge() / CLHEP::eplus;
564 const G4MaterialTable* mtable = G4Material::GetMaterialTable();
565 B2DEBUG(20,
"EnergyLossForExtrapolator::ComputeTransportXS"
566 <<
LogVar(
"particle", part->GetParticleName())
569 const G4Material* material = (*mtable)[i];
571 B2DEBUG(20,
"EnergyLossForExtrapolator::ComputeTransportXS()"
572 <<
LogVar(
"material index", i)
573 <<
LogVar(
"material name", material->GetName())
575 G4PhysicsVector* aVector = (*table)[i];
576 for (G4int j = 0; j <=
m_Nbins; j++) {
577 G4double e = aVector->Energy(j);
578 G4double xs = msc->CrossSectionPerVolume(material, part, e);
579 aVector->PutValue(j, xs);
580 B2DEBUG(20,
"EnergyLossForExtrapolator::ComputeTransportXS()"
582 <<
LogVar(
"energy [MeV]", e / CLHEP::MeV)
583 <<
LogVar(
"xs [1/mm]", xs * CLHEP::mm)
586 aVector->FillSecondDerivatives();
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.