Loading...
Searching...
No Matches
F01RunAction.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26#include "F01RunAction.hh"
27#include "globals.hh"
28#include "G4SystemOfUnits.hh"
29#include "G4Run.hh"
30
31#include "G4ParticleDefinition.hh"
32#include "G4Electron.hh"
33#include "G4ProcessManager.hh"
34#include "G4Transportation.hh"
35#include "G4CoupledTransportation.hh"
36
37//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
38
40 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
41
42 G4cout << " Calling F01RunAction::ChangeLooperParameters() " << G4endl;
43 ChangeLooperParameters( G4Electron::Definition() );
44}
45
46//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47
50{
51 if( particleDef == nullptr )
52 particleDef = G4Electron::Definition();
53 auto transport= FindTransportation( particleDef );
54
55 // Note that all particles that share the same Transportation
56 // (or Coupled Transportation) process (with this particle)
57 // will be affected by this change
58 // -- to change these parameters by particle type, the values
59 // must instead be changed/reset in a (Start) Tracking Action.
60
61 G4cout << " ChangeLooperParameters called with particle type "
62 << particleDef->GetParticleName()
63 << " transport process: ";
64 if( transport != nullptr ) {
65 G4cout << transport->GetProcessName();
66 } else {
67 G4cout << " UNKNOWN -- it is neither G4Transportation nor G4CoupledTransportation";
68 }
69 G4cout << G4endl;
70
71 if( transport != nullptr ) {
72 if( fWarningEnergy >= 0.0 ){
73 transport->SetThresholdWarningEnergy( fWarningEnergy );
74 G4cout << "-- Changed Threshold Warning Energy (for loopers) = "
75 << fWarningEnergy / CLHEP::MeV << " MeV " << G4endl;
76 }
77 if( fImportantEnergy >= 0.0 ) {
78 transport->SetThresholdImportantEnergy( fImportantEnergy );
79
80 G4cout << "-- Changed Threshold Important Energy (for loopers) = "
81 << fImportantEnergy / CLHEP::MeV << " MeV " << G4endl;
82 }
83
84 if( fNumberOfTrials > 0 ) {
85 transport->SetThresholdTrials( fNumberOfTrials );
86
87 G4cout << "-- Changed number of Trials (for loopers) = " << fNumberOfTrials << G4endl;
88 }
89 }
90
91 if( transport == nullptr ) {
92 if( fWarningEnergy >= 0.0 )
93 G4cerr << " Unknown transport process> Cannot change Warning Energy. " << G4endl;
94 if( fImportantEnergy >= 0.0 )
95 G4cerr << " Unknown transport process> Cannot change 'Important' Energy. " << G4endl;
96 if( fNumberOfTrials > 0 )
97 G4cerr << " Unknown transport process> Cannot change number of trials. " << G4endl;
98 }
99}
100
101//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
102
104 if( fVerboseLevel > 1 )
105 G4cout << G4endl << G4endl
106 << " ########### Track Statistics for Transportation process(es) "
107 << " ########### " << G4endl
108 << " ############################################## "
109 << " ####################### " << G4endl << G4endl;
110
111 auto transport= FindTransportation( G4Electron::Definition() );
112 if( transport) {
113 transport->PrintStatistics(G4cout);
114 }
115}
116
117//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118
121 bool reportError )
122{
123 const auto *partPM= particleDef->GetProcessManager();
124
125 G4VProcess* partTransport = partPM->GetProcess("Transportation");
126 auto transport= dynamic_cast<G4Transportation*>(partTransport);
127
128 if( !transport ){
129 partTransport = partPM->GetProcess("CoupledTransportation");
130 auto coupledTransport=
131 dynamic_cast<G4CoupledTransportation*>(partTransport);
132 if( coupledTransport ) {
133 transport= coupledTransport;
134 } else {
135 partTransport = partPM->GetProcess("TransportationWithMsc");
136 auto transportWithMsc=
137 dynamic_cast<G4CoupledTransportation*>(partTransport);
138 if( transportWithMsc ) {
139 transport= transportWithMsc;
140 }
141 }
142 }
143
144 if( reportError && !transport )
145 {
146 G4cerr << "Unable to find Transportation process for particle type "
147 << particleDef->GetParticleName()
148 << " ( PDG code = " << particleDef->GetPDGEncoding() << " ) "
149 << G4endl;
150 }
151
152 return transport;
153}
G4int fNumberOfTrials
G4double fImportantEnergy
G4int fVerboseLevel
void BeginOfRunAction(const G4Run *aRun) override
void ChangeLooperParameters(const G4ParticleDefinition *particleDef)
G4Transportation * FindTransportation(const G4ParticleDefinition *particleDef, bool reportError=true)
void EndOfRunAction(const G4Run *aRun) override
G4double fWarningEnergy

Applications | User Support | Publications | Collaboration