29#include <G4EmProcessSubType.hh>
30#include <G4GammaGeneralProcess.hh>
31#include <G4OpBoundaryProcess.hh>
32#include <G4OpProcessSubType.hh>
33#include <G4OpticalPhoton.hh>
34#include <G4ParticleDefinition.hh>
35#include <G4ParticleTable.hh>
36#include <G4ProcessManager.hh>
37#include <G4ProcessTable.hh>
38#include <G4TransportationProcessType.hh>
39#include <G4VProcess.hh>
40#include <G4VUserPhysicsList.hh>
41#include <G4Version.hh>
43#if G4VERSION_NUMBER == 1100
45#include <G4Cerenkov.hh>
46#include <G4Electron.hh>
47#include <G4OpticalParameters.hh>
50#include <TDatabasePDG.h>
51#include <TVirtualMCApplication.h>
55#include <G4SystemOfUnits.hh>
67 fCutForGamma(fgkDefautCut),
68 fCutForElectron(fgkDefautCut),
69 fCutForPositron(fgkDefautCut),
70 fCutForProton(fgkDefautCut),
77 "Cannot create two instances of singleton.");
82 G4bool isMaster = !G4Threading::IsWorkerThread();
103 G4bool isMaster = !G4Threading::IsWorkerThread();
128 TString text =
"mediumId=";
131 "TG4PhysicsManager",
"GstparCut",
"Medium with " + text +
" not found.");
144 G4cout <<
"TG4PhysicsManager::GstparCut: new TG4Limits() for medium "
145 << itmed <<
" has been created." << G4endl;
175 TString text =
"mediumId=";
178 "Medium with " + text +
" not found.");
192 G4cout <<
"TG4PhysicsManager::GstparControl: new TG4Limits() for medium"
193 << itmed <<
" has been created." << G4endl;
206 G4int pdgEncoding)
const
211 G4ParticleTable::GetParticleTable()->FindParticle(pdgEncoding);
213 if (!particleDefinition) {
214 TString text =
"PDG=";
217 "Particle with " + text +
" not found.");
220 return particleDefinition;
225 G4ProcessManager* processManager, G4int subType)
const
230 auto processVector = processManager->GetProcessList();
231 for (
size_t i = 0; i < processVector->length(); ++i) {
232 if ((*processVector)[i]->GetProcessSubType() == subType) {
233 return (*processVector)[i];
241 G4ProcessManager* processManager, G4int processId, G4bool activation)
245 G4String strActivation =
"Activate ";
246 if (!activation) strActivation =
"Inactivate ";
249 G4cout << strActivation <<
" process "
250 << (*processManager->GetProcessList())[processId]->GetProcessName()
251 <<
" for " << processManager->GetParticleType()->GetParticleName()
255 processManager->SetProcessActivation(processId, activation);
267 if (!controlVector) {
269 "Vectors of processes controls is not set.");
273 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
274 for (G4int i = 0; i < G4int(particleTable->size()); ++i) {
277 if (!particle)
continue;
279 G4ProcessManager* processManager = particle->GetProcessManager();
280 if (!processManager)
continue;
282 G4ProcessVector* processVector = processManager->GetProcessList();
287 for (
size_t j = 0; j < processVector->length(); j++) {
290 if ((*processVector)[j]->GetProcessSubType() == fGammaGeneralProcess) {
293 auto gammaGeneralProcess =
static_cast<G4GammaGeneralProcess*
>((*processVector)[j]);
294 auto gammaNuclear = gammaGeneralProcess->GetGammaNuclear();
295 auto pfisControl = (*controlVector)[
kPFIS];
296 if (pfisControl ==
kInActivate && gammaNuclear !=
nullptr ) {
300 gammaGeneralProcess->AddHadProcess(
nullptr);
302 if (pfisControl ==
kActivate && gammaNuclear ==
nullptr ) {
304 "Cannot activate PFIS control, the process is not built.");
312 "Cannot apply PAIR, COMP, PHOT controls when using G4GammaGeneralProcess.\n"
313 "Usage of G4GammaGeneralProcess can be inactivated with: \n"
314 "/process/em/UseGeneralProcess false");
322 G4bool activation = processManager->GetProcessActivation(j);
352 "Vector of isCut booleans is not set.");
356 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
357 for (G4int i = 0; i < G4int(particleTable->size()); ++i) {
360 if (!particle)
continue;
364 (particleWSP !=
kAny)) {
369 G4ProcessManager* processManager = particle->GetProcessManager();
375 processManager->SetProcessActivation(
376 process, (*isCutVector)[particleWSP]);
380 "The special cut process for " +
381 TString(particle->GetParticleName()) +
" is not defined");
414 G4cout <<
"TG4PhysicsManager::Gstpar " << param <<
" " << parval << G4endl;
427 name, parval, control, controlValue)) {
434 if (TString(param) ==
"STRA") {
436 text +=
" parameter is supported via /mcPhysics/emModel commands.\n";
437 text +=
" Setting via Gstpar is ignored.";
442 TString(name) +
" parameter is not yet implemented.");
461 "Parameter " + TString(cutName) +
" is not implemented.");
497 "Parameter " + TString(controlName) +
" is not implemented.");
506 TMCParticleType mcType, Double_t mass, Double_t charge, Double_t lifetime,
507 const TString& pType, Double_t width, Int_t iSpin, Int_t iParity,
508 Int_t iConjugation, Int_t iIsospin, Int_t iIsospinZ, Int_t gParity,
509 Int_t lepton, Int_t baryon, Bool_t stable, Bool_t shortlived,
510 const TString& subType, Int_t antiEncoding, Double_t magMoment,
517 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
520 particleDefinition = particleTable->FindParticle(pdg);
522 G4String particleName(name);
523 if (particleName ==
"Rootino")
524 particleDefinition = particleTable->FindParticle(
"geantino");
527 if (particleDefinition) {
528 TString text =
"Particle with PDG=";
531 text +=
"is defined in Geant4 as \"";
532 text += particleDefinition->GetParticleName().c_str();
534 text +=
"User definition will be ignored.";
542 pType, width, iSpin, iParity, iConjugation, iIsospin, iIsospinZ, gParity,
543 lepton, baryon, stable, shortlived, subType, antiEncoding, magMoment,
560 Int_t pdg, Float_t bratio[6], Int_t mode[6][3])
571 Double_t excEnergy, Double_t )
586 char* , Float_t , Int_t , Int_t )
621 return TString(particle->GetParticleName());
660 return particle->GetPDGLifeTime();
674 "TG4PhysicsManager",
"ParticleMCType",
"Not yet implemented.");
690 TVirtualMCApplication::Instance()->AddIons();
719 G4ProcessManager* processManager = photon->GetProcessManager();
721 G4int nofProcesses = processManager->GetProcessListLength();
722 G4ProcessVector* processList = processManager->GetProcessList();
723 for (G4int i = 0; i < nofProcesses; i++) {
724 if ((*processList)[i]->GetProcessSubType() == fOpBoundary) {
726 dynamic_cast<G4OpBoundaryProcess*
>((*processList)[i]);
737 if (!process)
return kPNoProcess;
750 "OpBoundary process is not defined.");
756 case FresnelReflection:
757 case TotalInternalReflection:
758 case LambertianReflection:
760 case SpikeReflection:
762 case PolishedLumirrorAirReflection:
763 case PolishedLumirrorGlueReflection:
764 case PolishedAirReflection:
765 case PolishedTeflonAirReflection:
766 case PolishedTiOAirReflection:
767 case PolishedTyvekAirReflection:
768 case PolishedVM2000AirReflection:
769 case PolishedVM2000GlueReflection:
770 case EtchedLumirrorAirReflection:
771 case EtchedLumirrorGlueReflection:
772 case EtchedAirReflection:
773 case EtchedTeflonAirReflection:
774 case EtchedTiOAirReflection:
775 case EtchedTyvekAirReflection:
776 case EtchedVM2000AirReflection:
777 case EtchedVM2000GlueReflection:
778 case GroundLumirrorAirReflection:
779 case GroundLumirrorGlueReflection:
780 case GroundAirReflection:
781 case GroundTeflonAirReflection:
782 case GroundTiOAirReflection:
783 case GroundTyvekAirReflection:
784 case GroundVM2000AirReflection:
785 case GroundVM2000GlueReflection:
786#if G4VERSION_NUMBER >= 1110
787 case CoatedDielectricReflection:
789 return kPLightReflection;
794 case FresnelRefraction:
795#if G4VERSION_NUMBER >= 1000
798#if G4VERSION_NUMBER >= 1010
801#if G4VERSION_NUMBER >= 1110
802 case CoatedDielectricRefraction:
804#if G4VERSION_NUMBER >= 1110
805 case CoatedDielectricFrustratedTransmission:
807 return kPLightRefraction;
813 return kPLightAbsorption;
818 return kPLightDetection;
836#if G4VERSION_NUMBER == 1100
838void TG4PhysicsManager::StoreCerenkovMaxBetaChangeValue()
841 fCerenkovMaxBetaChange =
842 G4OpticalParameters::Instance()->GetCerenkovMaxBetaChange();
843 G4cout <<
"Saved fCerenkovMaxBetaChange " << fCerenkovMaxBetaChange << G4endl;
847void TG4PhysicsManager::ApplyCerenkovMaxBetaChangeValue()
852 if (fCerenkovMaxBetaChange == 0.)
return;
855 G4Electron::Definition()->GetProcessManager()->GetProcess(
"Cerenkov");
856 if (cerenkov !=
nullptr) {
857 auto maxBetaChangeAfter =
858 G4OpticalParameters::Instance()->GetCerenkovMaxBetaChange();
859 G4cout <<
"Applying correction to CerenkovMaxBetaChange "
860 <<
"from " << maxBetaChangeAfter <<
" to " << fCerenkovMaxBetaChange
862 static_cast<G4Cerenkov*
>(cerenkov)->SetMaxBetaChangePerStep(
863 fCerenkovMaxBetaChange);
864 G4cout <<
"New value: "
865 <<
static_cast<G4Cerenkov*
>(cerenkov)->GetMaxBetaChangePerStep()
Definition of the enumerations TG4G3Control, TG4G3ControlValue.
Definition of the enumeration TG4G3Cut.
Definition of the TG4G3PhysicsManager class.
Definition of the TG4G3Units class.
Definition of the TG4GeometryServices class.
Definition of the TG4Limits class.
Definition of the TG4MediumMap class.
Definition of the TG4Medium class.
Definition of the TG4ParticlesManager class.
Definition of the TG4PhysicsManager class.
Definition of the TG4ProcessMap class.
Definition of the TG4SpecialPhysicsList class.
Definition of the TG4StateManager class.
Vector of control process values with convenient set/get methods.
static TG4G3Control GetControl(const G4String &controlName)
static TG4G3ControlValue GetControlValue(G4int value, TG4G3Control control)
static TG4G3Cut GetCut(const G4String &cutName)
Provides a Geant3 way control to Geant4 physics.
TG4G3ControlVector * GetControlVector() const
G4bool CheckControlWithTheVector(G4String name, G4double value, TG4G3Control &control, TG4G3ControlValue &controlValue)
void SetCut(TG4G3Cut cut, G4double cutValue)
static TG4G3PhysicsManager * Instance()
TG4G3ParticleWSP GetG3ParticleWSP(G4ParticleDefinition *particle) const
void SetProcess(TG4G3Control control, TG4G3ControlValue controlValue)
TG4boolVector * GetIsCutVector() const
TG4G3CutVector * GetCutVector() const
G4bool CheckCutWithTheVector(G4String name, G4double value, TG4G3Cut &cut)
static G4double InverseCharge()
static G4double InverseEnergy()
G4String CutName(const char *name) const
static TG4GeometryServices * Instance()
TG4Limits * GetLimits(G4UserLimits *limits) const
TG4MediumMap * GetMediumMap() const
static void Warning(const TString &className, const TString &methodName, const TString &text)
static void Exception(const TString &className, const TString &methodName, const TString &text)
static G4bool Compare(G4bool activation, TG4G3ControlValue controlValue)
Extended G4UserLimits class.
void SetG3Cut(TG4G3Cut cut, G4double cutValue)
void SetG3Control(TG4G3Control control, TG4G3ControlValue controlValue)
TG4Medium * GetMedium(G4int mediumID, G4bool warn=true) const
Helper class to keep medium data.
G4UserLimits * GetLimits() const
void SetLimits(G4UserLimits *limits)
Provides mapping between TDatabasePDG and Geant4 particles.
void AddIon(const G4String &name, G4int Z, G4int A, G4int Q, G4double excEnergy)
Bool_t SetDecayMode(Int_t pdg, Float_t bratio[6], Int_t mode[6][3])
void AddParticle(Int_t pdg, const TString &name, TMCParticleType mcType, Double_t mass, Double_t charge, Double_t lifetime, const TString &pType, Double_t width, Int_t iSpin, Int_t iParity, Int_t iConjugation, Int_t iIsospin, Int_t iIsospinZ, Int_t gParity, Int_t lepton, Int_t baryon, Bool_t stable, Bool_t shortlived=kFALSE, const TString &subType="", Int_t antiEncoding=0, Double_t magMoment=0.0, Double_t excitation=0.0)
void SetUserDecay(Int_t pdg)
Geant4 implementation of the TVirtualMC interface methods for building Geant4 physics and access to i...
TG4ParticlesManager * fParticlesManager
particles manager
Bool_t SetDecayMode(Int_t pdg, Float_t bratio[6], Int_t mode[6][3])
Double_t ParticleCharge(Int_t pdg) const
TMCParticleType ParticleMCType(Int_t pdg) const
Int_t PDGFromId(Int_t mcID) const
void SetSpecialControlsActivation()
Double_t ParticleMass(Int_t pdg) const
void GstparControl(G4int itmed, TG4G3Control control, TG4G3ControlValue parval)
static const G4double fgkDefautCut
the default range cut value
Double_t ParticleLifeTime(Int_t pdg) const
Bool_t SetCut(const char *cutName, Float_t cutValue)
void SetUserDecay(Int_t pdg)
TString ParticleName(Int_t pdg) const
TG4G3PhysicsManager * fG3PhysicsManager
G3 physics manager.
std::set< TString > fNotImplParNames
set of not implemented Gstpar parameters
Bool_t DefineIon(const char *name, Int_t Z, Int_t A, Int_t Q, Double_t excEnergy, Double_t mass)
void GstparCut(G4int itmed, TG4G3Cut par, G4double parval)
Bool_t SetProcess(const char *controlName, Int_t controlValue)
TMCProcess GetMCProcess(const G4VProcess *process)
void SetSpecialCutsActivation()
Int_t IdFromPDG(Int_t pdgID) const
void RetrieveOpBoundaryProcess()
G4ParticleDefinition * GetParticleDefinition(G4int pdgEncoding) const
void SetProcessActivation()
virtual ~TG4PhysicsManager()
TMCProcess GetOpBoundaryStatus()
G4VProcess * GetProcess(G4ProcessManager *processManager, G4int subType) const
Bool_t DefineParticle(Int_t pdg, const char *name, TMCParticleType mcType, Double_t mass, Double_t charge, Double_t lifetime, const TString &pType, Double_t width, Int_t iSpin, Int_t iParity, Int_t iConjugation, Int_t iIsospin, Int_t iIsospinZ, Int_t gParity, Int_t lepton, Int_t baryon, Bool_t stable, Bool_t shortlived=kFALSE, const TString &subType="", Int_t antiEncoding=0, Double_t magMoment=0.0, Double_t excitation=0.0)
G4OpBoundaryProcess * fOpBoundaryProcess
optical boundary process
Float_t Xsec(char *reac, Float_t energy, Int_t part, Int_t mate)
static TG4ProcessMap * fgProcessMap
the mapping between G4 processes and G3 process controls
void Gstpar(Int_t itmed, const char *param, Float_t parval)
static TG4PhysicsManager * fgInstance
this instance
Maps G4 process sub types to TMCProcess and TG4G3Control codes.
TMCProcess GetMCProcess(const G4VProcess *process) const
static TG4SpecialPhysicsList * Instance()
void SetNewState(TG4ApplicationState state)
static TG4StateManager * Instance()
Base class for defining the verbose level and a common messenger.
virtual G4int VerboseLevel() const
TG4G3ControlValue
Enumeration for G3 processes control values.
TG4G3Cut
Enumeration for G3 types of kinetic energy cuts.
std::vector< G4bool > TG4boolVector
TG4G3Control
Enumeration for G3 types of physics processes controls.
@ kInActivate
process is not activated
@ kActivate
process is activated WITH generation of secondaries
@ kUnsetControlValue
value not set
@ kNoG3Cuts
Invalid value.
@ kNotInApplication
not in VMC application
@ kNoG3Controls
No process control.
TG4G3ParticleWSP
The particles types which a special process (cuts, controls) is applicable for.
@ kNofParticlesWSP
not a particle with a special control
@ kEplus
kDRAY, kBREM, kMULS, kG3LOSS, kANNI