Warning, file /geant4/examples/extended/field/field01/src/F01RunAction.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #include "F01RunAction.hh"
0027
0028 #include "G4CoupledTransportation.hh"
0029 #include "G4Electron.hh"
0030 #include "G4ParticleDefinition.hh"
0031 #include "G4ProcessManager.hh"
0032 #include "G4Run.hh"
0033 #include "G4SystemOfUnits.hh"
0034 #include "G4Transportation.hh"
0035 #include "globals.hh"
0036
0037
0038
0039 void F01RunAction::BeginOfRunAction(const G4Run* aRun)
0040 {
0041 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
0042
0043 G4cout << " Calling F01RunAction::ChangeLooperParameters() " << G4endl;
0044 ChangeLooperParameters(G4Electron::Definition());
0045 }
0046
0047
0048
0049 void F01RunAction::ChangeLooperParameters(const G4ParticleDefinition* particleDef)
0050 {
0051 if (particleDef == nullptr) particleDef = G4Electron::Definition();
0052 auto transport = FindTransportation(particleDef);
0053
0054
0055
0056
0057
0058
0059
0060 G4cout << " ChangeLooperParameters called with particle type " << particleDef->GetParticleName()
0061 << " transport process: ";
0062 if (transport != nullptr) {
0063 G4cout << transport->GetProcessName();
0064 }
0065 else {
0066 G4cout << " UNKNOWN -- it is neither G4Transportation nor G4CoupledTransportation";
0067 }
0068 G4cout << G4endl;
0069
0070 if (transport != nullptr) {
0071 if (fWarningEnergy >= 0.0) {
0072 transport->SetThresholdWarningEnergy(fWarningEnergy);
0073 G4cout << "-- Changed Threshold Warning Energy (for loopers) = "
0074 << fWarningEnergy / CLHEP::MeV << " MeV " << G4endl;
0075 }
0076 if (fImportantEnergy >= 0.0) {
0077 transport->SetThresholdImportantEnergy(fImportantEnergy);
0078
0079 G4cout << "-- Changed Threshold Important Energy (for loopers) = "
0080 << fImportantEnergy / CLHEP::MeV << " MeV " << G4endl;
0081 }
0082
0083 if (fNumberOfTrials > 0) {
0084 transport->SetThresholdTrials(fNumberOfTrials);
0085
0086 G4cout << "-- Changed number of Trials (for loopers) = " << fNumberOfTrials << G4endl;
0087 }
0088 }
0089
0090 if (transport == nullptr) {
0091 if (fWarningEnergy >= 0.0)
0092 G4cerr << " Unknown transport process> Cannot change Warning Energy. " << G4endl;
0093 if (fImportantEnergy >= 0.0)
0094 G4cerr << " Unknown transport process> Cannot change 'Important' Energy. " << G4endl;
0095 if (fNumberOfTrials > 0)
0096 G4cerr << " Unknown transport process> Cannot change number of trials. " << G4endl;
0097 }
0098 }
0099
0100
0101
0102 void F01RunAction::EndOfRunAction(const G4Run*)
0103 {
0104 if (fVerboseLevel > 1)
0105 G4cout << G4endl << G4endl << " ########### Track Statistics for Transportation process(es) "
0106 << " ########### " << G4endl << " ############################################## "
0107 << " ####################### " << G4endl << G4endl;
0108
0109 auto transport = FindTransportation(G4Electron::Definition());
0110 if (transport) {
0111 transport->PrintStatistics(G4cout);
0112 }
0113 }
0114
0115
0116
0117 G4Transportation* F01RunAction::FindTransportation(const G4ParticleDefinition* particleDef,
0118 bool reportError)
0119 {
0120 const auto* partPM = particleDef->GetProcessManager();
0121
0122 G4VProcess* partTransport = partPM->GetProcess("Transportation");
0123 auto transport = dynamic_cast<G4Transportation*>(partTransport);
0124
0125 if (!transport) {
0126 partTransport = partPM->GetProcess("CoupledTransportation");
0127 auto coupledTransport = dynamic_cast<G4CoupledTransportation*>(partTransport);
0128 if (coupledTransport) {
0129 transport = coupledTransport;
0130 }
0131 else {
0132 partTransport = partPM->GetProcess("TransportationWithMsc");
0133 auto transportWithMsc = dynamic_cast<G4CoupledTransportation*>(partTransport);
0134 if (transportWithMsc) {
0135 transport = transportWithMsc;
0136 }
0137 }
0138 }
0139
0140 if (reportError && !transport) {
0141 G4cerr << "Unable to find Transportation process for particle type "
0142 << particleDef->GetParticleName() << " ( PDG code = " << particleDef->GetPDGEncoding()
0143 << " ) " << G4endl;
0144 }
0145
0146 return transport;
0147 }