Skip to content

Commit a3da28c

Browse files
authored
Merge pull request #122 from mnovak42/corretProcessInterface
Miscellaneous modifications on the example application.
2 parents 8e246a7 + e326eba commit a3da28c

File tree

8 files changed

+112
-31
lines changed

8 files changed

+112
-31
lines changed

G4HepEm/G4HepEm/src/G4HepEmTrackingManager.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ void G4HepEmTrackingManager::BuildPhysicsTable(const G4ParticleDefinition &part)
175175
if (G4Threading::IsMasterThread() && fVerbose > 0) {
176176
ReportExtraProcesses(particleID);
177177
}
178+
// Report the configuration (as e+ is the last among the 3 particles in a normal g4 flow)
179+
if (G4Threading::IsMasterThread() && fVerbose > 0) {
180+
fConfig->Dump();
181+
}
178182
} else if (&part == G4Gamma::Definition()) {
179183
int particleID = 2;
180184
fRunManager->Initialize(fRandomEngine, particleID, fConfig->GetG4HepEmParameters());
@@ -202,10 +206,6 @@ void G4HepEmTrackingManager::BuildPhysicsTable(const G4ParticleDefinition &part)
202206
if (G4Threading::IsMasterThread() && fVerbose > 0) {
203207
ReportExtraProcesses(particleID);
204208
}
205-
// Report the configuration
206-
if (G4Threading::IsMasterThread() && fVerbose > 0) {
207-
fConfig->Dump();
208-
}
209209
} else {
210210
std::cerr
211211
<< " **** ERROR in G4HepEmProcess::BuildPhysicsTable: unknown particle "

apps/examples/TestEm3/ATLASbar.mac

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,36 @@
2424
##/testem/det/setField 0 0 2.0 tesla
2525
##
2626
## -----------------------------------------------------------------------------
27-
## Set the physics list (more exactly, the EM physics constructor):
28-
## = 'HepEm' : the G4HepEm EM physics c.t.r.
29-
## = 'G4Em' : the G4 EM physics c.t.r. that corresponds to G4HepEm
30-
## = 'emstandard_opt0' : the original, G4 EM-Opt0 physics c.t.r.
27+
## Set the physics list (more exactly, the EM physics constructor e-/e+, gamma):
28+
##
29+
## NOTE: the full-fledged G4HepEm physics with its special tracking, i.e.
30+
## `HepEmTracking` below, is the recommended usage of G4HepEm through its
31+
## `G4HepEmTrackingManager`. This provides correct and complete physics
32+
## (i.e. including nuclear interactions as well if attached to the particles)
33+
## combined with maximal computing performance benefits, it requires at least
34+
## Geant4-11.0. The other option is `HepEm`, i.e. connecting only the G4HepEm
35+
## physics (through the `G4VProcess` interface), is incomplete (e.g. nuclear
36+
## interactions aren't incorporated properly) and not efficient as it doesn't
37+
## contain the special tracking component).
38+
##
39+
## 1. 'HepEmTracking' : full-fleged `G4HepEmTrackingManager`(G4HepEm physics with its special tracking)
40+
## 2. 'G4Em' : native G4 EM physics that corresponds to the G4HepEm physics
41+
## 3. 'G4 EM-opt0' : the native G4 EM standard opt0 physics constructor
42+
## 4. 'HepEm' : G4HepEm physics using the `G4VProcess` interface (only for )
43+
##
44+
## NOTE: nuclear interactions are also added to e-/e+ and gamma through the
45+
## `G4EmExtraPhysics` constructor (see the `PhysicsList`).
46+
## -----------------------------------------------------------------------------
47+
/testem/phys/addPhysics HepEmTracking
48+
##/testem/phys/addPhysics G4Em
49+
##/testem/phys/addPhysics emstandard_opt0
50+
## NOTE: `HepEm` is only for development!
51+
##/testem/phys/addPhysics HepEm
52+
##
53+
## -----------------------------------------------------------------------------
54+
## Set the verbosity of the physics list (parameters, setting, configuration)
3155
## -----------------------------------------------------------------------------
32-
/testem/phys/addPhysics HepEmTracking
33-
##/testem/phys/addPhysics G4Em
56+
/testem/phys/verbose 1
3457
##
3558
## -----------------------------------------------------------------------------
3659
## Use the gamma-general process in Geant4 (similarly to HepEmTracking)

apps/examples/TestEm3/include/PhysicsListMessenger.hh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,29 @@ class PhysicsList;
4141
class G4UIdirectory;
4242
class G4UIcmdWithADoubleAndUnit;
4343
class G4UIcmdWithAString;
44+
class G4UIcmdWithAnInteger;
4445

4546
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
4647

4748
class PhysicsListMessenger: public G4UImessenger
4849
{
4950
public:
50-
51+
5152
PhysicsListMessenger(PhysicsList* );
5253
~PhysicsListMessenger();
53-
54+
5455
virtual void SetNewValue(G4UIcommand*, G4String);
55-
56+
5657
private:
57-
58+
5859
PhysicsList* fPhysicsList;
59-
60-
G4UIdirectory* fPhysDir;
60+
61+
G4UIdirectory* fPhysDir;
6162
G4UIcmdWithAString* fListCmd;
62-
63+
G4UIcmdWithAnInteger* fVerboseCmd;
64+
6365
};
6466

6567
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
6668

6769
#endif
68-

apps/examples/TestEm3/src/G4HepEmProcess.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "G4ProcessType.hh"
2020
#include "G4EmProcessSubType.hh"
21+
#include "G4HadronicProcessType.hh"
2122

2223
#include "G4Threading.hh"
2324
#include "G4Track.hh"
@@ -59,6 +60,8 @@ G4HepEmProcess::G4HepEmProcess()
5960
fGammaNoProcessVector.push_back(new G4HepEmNoProcess("conv", G4ProcessType::fElectromagnetic, G4EmProcessSubType::fGammaConversion));
6061
fGammaNoProcessVector.push_back(new G4HepEmNoProcess("compt", G4ProcessType::fElectromagnetic, G4EmProcessSubType::fComptonScattering));
6162
fGammaNoProcessVector.push_back(new G4HepEmNoProcess("phot", G4ProcessType::fElectromagnetic, G4EmProcessSubType::fPhotoElectricEffect));
63+
fGammaNoProcessVector.push_back(new G4HepEmNoProcess("photonNuclear", G4ProcessType::fHadronic, G4HadronicProcessType::fHadronInelastic));
64+
6265
}
6366

6467
G4HepEmProcess::~G4HepEmProcess() {
@@ -68,8 +71,10 @@ G4HepEmProcess::~G4HepEmProcess() {
6871

6972

7073
void G4HepEmProcess::BuildPhysicsTable(const G4ParticleDefinition& partDef) {
71-
G4cout << " G4HepEmProcess::BuildPhysicsTable for Particle = " << partDef.GetParticleName() << G4endl;
72-
StreamInfo(G4cout, partDef);
74+
if (G4Threading::IsMasterThread() && verboseLevel > 1) {
75+
G4cout << " G4HepEmProcess::BuildPhysicsTable for Particle = " << partDef.GetParticleName() << G4endl;
76+
StreamInfo(G4cout, partDef);
77+
}
7378

7479
// The ptr-s to global data structures created and filled in InitializeGlobal()
7580
// will be copied to the workers and the TL-data structure will be created.
@@ -174,6 +179,7 @@ G4VParticleChange* G4HepEmProcess::PostStepDoIt( const G4Track& track, const G4S
174179
// invoke the physics interactions (all i.e. all along- and post-step as well as possible at rest)
175180
double pStepLength = track.GetStepLength();
176181
if (isGamma) {
182+
G4HepEmGammaManager::SelectInteraction(fTheG4HepEmRunManager->GetHepEmData(), theTLData);
177183
G4HepEmGammaManager::Perform(fTheG4HepEmRunManager->GetHepEmData(), fTheG4HepEmRunManager->GetHepEmParameters(), theTLData);
178184
//
179185
// set dummy G4VProcess pointers to provide (name) information regarding processes limited the step
@@ -184,6 +190,8 @@ G4VParticleChange* G4HepEmProcess::PostStepDoIt( const G4Track& track, const G4S
184190
break;
185191
case 2: theG4PostStepPoint->SetProcessDefinedStep(fGammaNoProcessVector[2]);
186192
break;
193+
case 3: theG4PostStepPoint->SetProcessDefinedStep(fGammaNoProcessVector[3]);
194+
break;
187195
}
188196
} else {
189197
G4HepEmElectronManager::Perform(fTheG4HepEmRunManager->GetHepEmData(), fTheG4HepEmRunManager->GetHepEmParameters(), theTLData);

apps/examples/TestEm3/src/PhysListHepEm.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void PhysListHepEm::ConstructProcess() {
3131

3232
// creae the only one G4HepEm process that will be assigned to e-/e+ and gamma
3333
G4HepEmProcess* hepEmProcess = new G4HepEmProcess();
34+
hepEmProcess->SetVerboseLevel(verboseLevel);
3435

3536
// Add standard EM Processes
3637
//
@@ -58,4 +59,9 @@ void PhysListHepEm::ConstructProcess() {
5859

5960
}
6061
}
62+
63+
if (G4Threading::IsMasterThread() && verboseLevel > 0) {
64+
G4EmParameters::Instance()->Dump();
65+
}
66+
6167
}

apps/examples/TestEm3/src/PhysListHepEmTracking.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ PhysListHepEmTracking::~PhysListHepEmTracking()
3131
void PhysListHepEmTracking::ConstructProcess()
3232
{
3333
// Register custom tracking manager for e-/e+ and gammas.
34-
auto* trackingManager = new G4HepEmTrackingManager;
34+
auto* trackingManager = new G4HepEmTrackingManager(verboseLevel);
3535
// Configuration of G4HepEm
3636
// Several paramaters can be configured per detector region. These are:
3737
// MSC parameters, continuous energy loss step limit function parameters,
@@ -44,4 +44,8 @@ void PhysListHepEmTracking::ConstructProcess()
4444
G4Electron::Definition()->SetTrackingManager(trackingManager);
4545
G4Positron::Definition()->SetTrackingManager(trackingManager);
4646
G4Gamma::Definition()->SetTrackingManager(trackingManager);
47+
48+
if (G4Threading::IsMasterThread() && verboseLevel > 0) {
49+
G4EmParameters::Instance()->Dump();
50+
}
4751
}

apps/examples/TestEm3/src/PhysicsList.cc

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
#include "G4EmStandardPhysics_option2.hh"
5050

5151
#include "G4EmExtraPhysics.hh"
52+
#include "G4HadronicProcessStore.hh"
53+
#if G4VERSION_NUMBER >= 1100
54+
#include "G4HadronicParameters.hh"
55+
#endif
56+
57+
#include "G4HadronicParameters.hh"
5258

5359
#include "G4LossTableManager.hh"
5460

@@ -78,14 +84,29 @@ PhysicsList::PhysicsList() : G4VModularPhysicsList(),
7884
SetDefaultCutValue(1*mm);
7985

8086
fMessenger = new PhysicsListMessenger(this);
81-
SetVerboseLevel(1);
87+
verboseLevel = 0;
8288

83-
// EM physics: set to HepEm by def.
89+
#if G4VERSION_NUMBER >= 1100
90+
// make the `G4HepEmTrackingManager` the default whenever it's available (g4>=11.0)
91+
fEmName = G4String("HepEmTracking");
92+
fEmPhysicsList = new PhysListHepEmTracking(fEmName);
93+
#else
94+
// use the process interface but only as a backup solution as not efficient (g4<11.0)
8495
fEmName = G4String("HepEm");
8596
fEmPhysicsList = new PhysListHepEm(fEmName);
97+
#endif
98+
99+
fEmPhysicsList->SetVerboseLevel(verboseLevel);
100+
G4EmParameters::Instance()->SetVerbose(verboseLevel);
101+
102+
// Hardonic verbose needs to be set before construction
103+
#if G4VERSION_NUMBER >= 1100
104+
G4HadronicParameters::Instance()->SetVerboseLevel(verboseLevel);
105+
#endif
106+
G4HadronicProcessStore::Instance()->SetVerbose(verboseLevel);
86107

87108
// Create the G4EmExtraPhysics to add gamma and lepton nuclear interactions
88-
G4EmExtraPhysics* emExtra = new G4EmExtraPhysics();
109+
G4EmExtraPhysics* emExtra = new G4EmExtraPhysics(verboseLevel);
89110
// During the development: deactiavte electron nuclear till we don't have in HepEm
90111
// emExtra->ElectroNuclear(false);
91112
// Turn off muon nuclear as well (not improtant as no muon production but
@@ -136,11 +157,14 @@ void PhysicsList::ConstructProcess()
136157
{
137158
// Transportation
138159
AddTransportation();
160+
139161
// Electromagnetic Physics List
162+
fEmPhysicsList->SetVerboseLevel(verboseLevel);
163+
140164
fEmPhysicsList->ConstructProcess();
141165
// EM extra physics, i.e. gamma end lepton nuclear
166+
fEmExtraPhysics->SetVerboseLevel(verboseLevel);
142167
fEmExtraPhysics->ConstructProcess();
143-
144168
}
145169

146170
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -205,4 +229,6 @@ void PhysicsList::AddPhysicsList(const G4String& name)
205229
<< " is not defined"
206230
<< G4endl;
207231
}
232+
fEmPhysicsList->SetVerboseLevel(verboseLevel);
233+
G4EmParameters::Instance()->SetVerbose(verboseLevel);
208234
}

apps/examples/TestEm3/src/PhysicsListMessenger.cc

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@
3737
#include "G4UIdirectory.hh"
3838
#include "G4UIcmdWithADoubleAndUnit.hh"
3939
#include "G4UIcmdWithAString.hh"
40+
#include "G4UIcmdWithAnInteger.hh"
4041

4142
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
4243

4344
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
4445
:G4UImessenger(),fPhysicsList(pPhys),
4546
fPhysDir(0),
46-
fListCmd(0)
47+
fListCmd(0),
48+
fVerboseCmd(0)
4749
{
4850
fPhysDir = new G4UIdirectory("/testem/phys/");
4951
fPhysDir->SetGuidance("physics list commands");
@@ -52,23 +54,34 @@ PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
5254
fListCmd->SetGuidance("Add modular physics list.");
5355
fListCmd->SetParameterName("PList",false);
5456
fListCmd->AvailableForStates(G4State_PreInit);
57+
58+
fVerboseCmd = new G4UIcmdWithAnInteger("/testem/phys/verbose", this);
59+
fVerboseCmd->SetGuidance("Set the Verbose level of the PhysicsList");
60+
fVerboseCmd->SetGuidance(" 0 : Silent");
61+
fVerboseCmd->SetGuidance(" 1 : Config info (default)");
62+
fVerboseCmd->SetGuidance(" 2 : Everything");
63+
fVerboseCmd->SetParameterName("level", true);
64+
fVerboseCmd->SetDefaultValue(0);
65+
fVerboseCmd->SetRange("level >=0 && level <=3");
5566
}
5667

5768
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
5869

5970
PhysicsListMessenger::~PhysicsListMessenger()
6071
{
6172
delete fListCmd;
73+
delete fVerboseCmd;
6274
delete fPhysDir;
6375
}
6476

6577
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
6678

67-
void PhysicsListMessenger::SetNewValue(G4UIcommand* command,
68-
G4String newValue)
69-
{
70-
if( command == fListCmd )
71-
{ fPhysicsList->AddPhysicsList(newValue);}
79+
void PhysicsListMessenger::SetNewValue(G4UIcommand* command, G4String newValue) {
80+
if( command == fListCmd ) {
81+
fPhysicsList->AddPhysicsList(newValue);
82+
} else if( command == fVerboseCmd ) {
83+
fPhysicsList->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValue));
84+
}
7285
}
7386

7487
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

0 commit comments

Comments
 (0)