15 #include <simulation/kernel/EnergyLossForExtrapolator.h>
17 #include <CLHEP/Units/PhysicalConstants.h>
18 #include <CLHEP/Units/SystemOfUnits.h>
20 #include <G4PhysicsLogVector.hh>
21 #include <G4ParticleDefinition.hh>
22 #include <G4Material.hh>
23 #include <G4MaterialCutsCouple.hh>
24 #include <G4ParticleTable.hh>
25 #include <G4LossTableBuilder.hh>
26 #include <G4MollerBhabhaModel.hh>
27 #include <G4BetheBlochModel.hh>
28 #include <G4Version.hh>
29 #if G4VERSION_NUMBER < 1001
30 #include <G4eBremsstrahlungModel.hh>
32 #include <G4eBremsstrahlungRelModel.hh>
34 #include <G4MuPairProductionModel.hh>
35 #include <G4MuBremsstrahlungModel.hh>
36 #include <G4ProductionCuts.hh>
37 #include <G4LossTableManager.hh>
38 #include <G4WentzelVIModel.hh>
40 #include <framework/logging/Logger.h>
43 using namespace Belle2::Simulation;
58 m_AntiProton(nullptr),
60 m_AntiDeuteron(nullptr),
61 m_ProductionCuts(nullptr),
62 m_DedxElectron(nullptr),
63 m_DedxPositron(nullptr),
67 m_DedxProton(nullptr),
68 m_DedxDeuteron(nullptr),
69 m_RangeElectron(nullptr),
70 m_RangePositron(nullptr),
74 m_RangeProton(nullptr),
75 m_RangeDeuteron(nullptr),
76 m_InvRangeElectron(nullptr),
77 m_InvRangePositron(nullptr),
78 m_InvRangeMuon(nullptr),
79 m_InvRangePion(nullptr),
80 m_InvRangeKaon(nullptr),
81 m_InvRangeProton(nullptr),
82 m_InvRangeDeuteron(nullptr),
83 m_MscatElectron(nullptr),
96 m_UserTmin(1.*CLHEP::MeV),
97 m_UserTmax(10.*CLHEP::TeV),
98 m_UserMaxEnergyTransfer(DBL_MAX),
133 for (
const G4MaterialCutsCouple* couple :
m_Couples)
delete couple;
141 const G4Material* mat,
142 const G4ParticleDefinition* part)
145 G4double kinEnergyFinal = kinEnergy;
150 kinEnergyFinal = 0.0;
152 kinEnergyFinal -= step *
ComputeDEDX(kinEnergy, part);
154 G4double r1 = r - step;
158 return kinEnergyFinal;
165 const G4Material* mat,
166 const G4ParticleDefinition* part)
169 G4double kinEnergyFinal = kinEnergy;
176 kinEnergyFinal += step *
ComputeDEDX(kinEnergy, part);
178 G4double r1 = r + step;
182 return kinEnergyFinal;
189 const G4Material* mat,
190 const G4ParticleDefinition* part)
192 G4double res = stepLength;
197 if (x < 0.2) res *= (1.0 + 0.5 * x + x * x / 3.0);
198 else if (x < 0.9999) res = -std::log(1.0 - x) * stepLength / x;
211 const G4Material* mat,
214 if (!part || !mat || kinEnergy < CLHEP::keV)
return false;
220 m_Mass = part->GetPDGMass();
221 G4double q = part->GetPDGCharge() / CLHEP::eplus;
225 G4int i = mat->GetIndex();
227 B2WARNING(
"EnergyLossForExtrapolator: index i= " << i <<
" is out of table - NO extrapolation");
238 G4double tau = kinEnergy /
m_Mass;
246 G4double r = CLHEP::electron_mass_c2 /
m_Mass;
259 B2DEBUG(10,
"EnergyLossForExtrapolator::Initialisation");
264 m_Electron = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_e-");
265 m_Positron = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_e+");
266 m_MuonPlus = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_mu+");
267 m_MuonMinus = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_mu-");
268 m_PionPlus = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_pi+");
269 m_PionMinus = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_pi-");
270 m_KaonPlus = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_kaon+");
271 m_KaonMinus = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_kaon-");
272 m_Proton = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_proton");
273 m_AntiProton = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_anti_proton");
274 m_Deuteron = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_deuteron");
275 m_AntiDeuteron = G4ParticleTable::GetParticleTable()->FindParticle(
"g4e_anti_deuteron");
278 const G4MaterialTable* mtable = G4Material::GetMaterialTable();
311 G4LossTableBuilder& builder = *(G4LossTableManager::Instance()->GetTableBuilder());
313 B2DEBUG(10,
"EnergyLossForExtrapolator Builds electron tables");
318 B2DEBUG(10,
"EnergyLossForExtrapolator Builds positron tables");
323 B2DEBUG(10,
"EnergyLossForExtrapolator Builds muon tables");
328 B2DEBUG(10,
"EnergyLossForExtrapolator Builds pion tables");
333 B2DEBUG(10,
"EnergyLossForExtrapolator Builds kaon tables");
338 B2DEBUG(10,
"EnergyLossForExtrapolator Builds proton tables");
343 B2DEBUG(10,
"EnergyLossForExtrapolator Builds deuteron tables");
355 G4PhysicsTable* table =
new G4PhysicsTable();
369 const G4ParticleDefinition* part)
387 B2FATAL(
"EnergyLossForExtrapolator::ComputeDEDX has no table for particle " << part->GetParticleName());
395 const G4ParticleDefinition* part)
413 B2FATAL(
"EnergyLossForExtrapolator::ComputeRange has no table for particle " << part->GetParticleName());
421 const G4ParticleDefinition* part)
439 B2FATAL(
"EnergyLossForExtrapolator::ComputeEnergy has no table for particle " << part->GetParticleName());
447 G4PhysicsTable* table)
449 G4MollerBhabhaModel* ioni =
new G4MollerBhabhaModel();
450 #if G4VERSION_NUMBER < 1001
451 G4eBremsstrahlungModel* brem =
new G4eBremsstrahlungModel();
453 G4eBremsstrahlungRelModel* brem =
new G4eBremsstrahlungRelModel();
455 G4ParticleChange* ioniPC =
new G4ParticleChange();
456 ioni->SetParticleChange(ioniPC);
457 G4ParticleChange* bremPC =
new G4ParticleChange();
458 brem->SetParticleChange(bremPC);
460 ioni->Initialise(part,
m_Cuts);
461 brem->Initialise(part,
m_Cuts);
463 m_Mass = CLHEP::electron_mass_c2;
467 B2DEBUG(1,
"EnergyLossForExtrapolator::ComputeElectronDEDX for " << part->GetParticleName());
471 B2DEBUG(10,
"EnergyLossForExtrapolator::ComputeElectronDEDX(): i= " << i <<
" mat= " <<
472 (*G4Material::GetMaterialTable())[i]->GetName());
473 const G4MaterialCutsCouple* couple =
m_Couples[i];
474 G4PhysicsVector* aVector = (*table)[i];
476 for (G4int j = 0; j <=
m_Nbins; j++) {
478 G4double e = aVector->Energy(j);
479 G4double dedx = ioni->ComputeDEDX(couple, part, e, e) +
480 brem->ComputeDEDX(couple, part, e, e);
481 B2DEBUG(10,
"EnergyLossForExtrapolator::ComputeElectronDEDX(): j= " << j
482 <<
" e(MeV)= " << e / CLHEP::MeV
483 <<
" dedx(Mev/cm)= " << dedx * CLHEP::cm / CLHEP::MeV
484 <<
" dedx(Mev.cm2/g)= "
485 << dedx / ((CLHEP::MeV * (*G4Material::GetMaterialTable())[i]->GetDensity()) / (CLHEP::g / CLHEP::cm2)));
486 aVector->PutValue(j, dedx);
488 aVector->FillSecondDerivatives();
490 delete ioni;
delete ioniPC;
491 delete brem;
delete bremPC;
497 G4PhysicsTable* table)
499 G4BetheBlochModel* ioni =
new G4BetheBlochModel();
500 G4MuPairProductionModel* pair =
new G4MuPairProductionModel();
501 G4MuBremsstrahlungModel* brem =
new G4MuBremsstrahlungModel();
503 G4ParticleChange* ioniPC =
new G4ParticleChange();
504 ioni->SetParticleChange(ioniPC);
505 G4ParticleChange* pairPC =
new G4ParticleChange();
506 pair->SetParticleChange(pairPC);
507 G4ParticleChange* bremPC =
new G4ParticleChange();
508 brem->SetParticleChange(bremPC);
510 ioni->Initialise(part,
m_Cuts);
511 pair->Initialise(part,
m_Cuts);
512 brem->Initialise(part,
m_Cuts);
514 m_Mass = part->GetPDGMass();
518 B2DEBUG(1,
"EnergyLossForExtrapolator::ComputeMuonDEDX for " << part->GetParticleName());
522 B2DEBUG(10,
"EnergyLossForExtrapolator::ComputeMuonDEDX(): i= " << i <<
" mat= " <<
523 (*G4Material::GetMaterialTable())[i]->GetName());
524 const G4MaterialCutsCouple* couple =
m_Couples[i];
525 G4PhysicsVector* aVector = (*table)[i];
526 for (G4int j = 0; j <=
m_Nbins; j++) {
528 G4double e = aVector->Energy(j);
529 G4double dedx = ioni->ComputeDEDX(couple, part, e, e) +
530 pair->ComputeDEDX(couple, part, e, e) +
531 brem->ComputeDEDX(couple, part, e, e);
532 aVector->PutValue(j, dedx);
533 B2DEBUG(10,
"EnergyLossForExtrapolator::ComputeMuonDEDX(): j= " << j
534 <<
" e(MeV)= " << e / CLHEP::MeV
535 <<
" dedx(Mev/cm)= " << dedx * CLHEP::cm / CLHEP::MeV
536 <<
" dedx(Mev/(g/cm2)= "
537 << dedx / ((CLHEP::MeV * (*G4Material::GetMaterialTable())[i]->GetDensity()) / (CLHEP::g / CLHEP::cm2)));
539 aVector->FillSecondDerivatives();
541 delete ioni;
delete ioniPC;
542 delete pair;
delete pairPC;
543 delete brem;
delete bremPC;
549 G4PhysicsTable* table)
551 G4BetheBlochModel* ioni =
new G4BetheBlochModel();
552 G4ParticleChange* ioniPC =
new G4ParticleChange();
553 ioni->SetParticleChange(ioniPC);
554 ioni->Initialise(part,
m_Cuts);
556 m_Mass = part->GetPDGMass();
557 double q = part->GetPDGCharge() / CLHEP::eplus;
561 B2DEBUG(1,
"EnergyLossForExtrapolator::ComputeHadronDEDX for " << part->GetParticleName());
565 B2DEBUG(10,
"EnergyLossForExtrapolator::ComputeHadronDEDX(): i= " << i <<
" mat= " <<
566 (*G4Material::GetMaterialTable())[i]->GetName());
567 const G4MaterialCutsCouple* couple =
m_Couples[i];
568 G4PhysicsVector* aVector = (*table)[i];
569 for (G4int j = 0; j <=
m_Nbins; j++) {
571 G4double e = aVector->Energy(j);
572 G4double dedx = ioni->ComputeDEDX(couple, part, e, e);
573 aVector->PutValue(j, dedx);
574 B2DEBUG(10,
"EnergyLossForExtrapolator::ComputeHadronDEDX(): j= " << j
575 <<
" e(MeV)= " << e / CLHEP::MeV
576 <<
" dedx(Mev/cm)= " << dedx * CLHEP::cm / CLHEP::MeV
577 <<
" dedx(Mev.cm2/g)= "
578 << dedx / (((*G4Material::GetMaterialTable())[i]->GetDensity()) / (CLHEP::g / CLHEP::cm2)));
580 aVector->FillSecondDerivatives();
582 delete ioni;
delete ioniPC;
588 G4PhysicsTable* table)
590 G4WentzelVIModel* msc =
new G4WentzelVIModel();
591 G4ParticleChange* mscPC =
new G4ParticleChange();
592 msc->SetParticleChange(mscPC);
593 msc->SetPolarAngleLimit(CLHEP::pi);
594 msc->Initialise(part,
m_Cuts);
596 m_Mass = part->GetPDGMass();
597 double q = part->GetPDGCharge() / CLHEP::eplus;
601 const G4MaterialTable* mtable = G4Material::GetMaterialTable();
602 B2DEBUG(1,
"EnergyLossForExtrapolator::ComputeTransportXS for " << part->GetParticleName());
606 const G4Material* mat = (*mtable)[i];
608 B2DEBUG(10,
"EnergyLossForExtrapolator::ComputeTransportXS(): i= " << i <<
" mat= " << mat->GetName());
609 G4PhysicsVector* aVector = (*table)[i];
610 for (G4int j = 0; j <=
m_Nbins; j++) {
612 G4double e = aVector->Energy(j);
613 G4double xs = msc->CrossSectionPerVolume(mat, part, e);
614 aVector->PutValue(j, xs);
615 B2DEBUG(10,
"EnergyLossForExtrapolator::ComputeTransportXS(): j= " << j <<
" e(MeV)= " << e / CLHEP::MeV
616 <<
" xs(1/mm)= " << xs * CLHEP::mm);
618 aVector->FillSecondDerivatives();
620 delete msc;
delete mscPC;