Geant4 VMC Version 6.8
Loading...
Searching...
No Matches
TG4RunConfiguration.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Geant4 Virtual Monte Carlo package
3// Copyright (C) 2007 - 2015 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
14
15#include "TG4RunConfiguration.h"
17#include "TG4DetConstruction.h"
18#include "TG4EmPhysicsList.h"
19#include "TG4EventAction.h"
20#include "TG4ExtraPhysicsList.h"
21#include "TG4Globals.h"
24#include "TG4RunAction.h"
27#include "TG4SteppingAction.h"
28#include "TG4TrackingAction.h"
30
31#include <G4UImessenger.hh>
32//#include <G4PhysListFactory.hh>
33
34#ifdef USE_VGM
35#include "TG4VGMMessenger.h"
36#include <XmlVGM/AGDDExporter.h>
37#include <XmlVGM/GDMLExporter.h>
38#endif
39
40//_____________________________________________________________________________
41TG4RunConfiguration::TG4RunConfiguration(const TString& userGeometry,
42 const TString& physicsList, const TString& specialProcess,
43 Bool_t specialStacking, Bool_t mtApplication)
44 : fUserGeometry(userGeometry),
45 fPhysicsListSelection(physicsList),
47 fSpecialStacking(specialStacking),
48 fMTApplication(mtApplication),
49 fSpecialControls(false),
50 fSpecialCuts(false),
51 fSpecialCutsOld(false),
52 fUseOfG4Scoring(false),
57{
59
60 if (userGeometry != "geomVMCtoGeant4" && userGeometry != "geomVMCtoRoot" &&
61 userGeometry != "geomRoot" && userGeometry != "geomRootToGeant4" &&
62 userGeometry != "geomVMC+RootToGeant4" && userGeometry != "geomGeant4") {
63
64 TG4Globals::Exception("TG4RunConfiguration", "TG4RunConfiguration",
65 "User geometry " + userGeometry + " not recognized." +
66 TG4Globals::Endl() + "Available options:" + TG4Globals::Endl() +
67 "geomVMCtoGeant4 geomVMCtoRoot geomRoot geomRootToGeant4 "
68 "geomVMC+RootToGeant4 geomGeant4");
69 }
70
71 G4int itoken = 0;
72 G4String token;
73 do {
74 token = TG4Globals::GetToken(itoken++, physicsList);
75
79
80 TG4Globals::Exception("TG4RunConfiguration", "TG4RunConfiguration",
81 "Physics list selection " + physicsList + " not recognized." +
82 TG4Globals::Endl() + "Available options:" + TG4Globals::Endl() +
83 "EMonly, EMonly+Extra, Hadron_EM, Hadron_EM+Extra" +
84 TG4Globals::Endl() + " where EMonly = " +
86 TG4Globals::Endl() + " Hadron = " +
88 TG4Globals::Endl() + " EM = " +
90 TG4Globals::Endl() + " Extra = " +
93 " The Extra selections are cumulative, while Hadron selections are "
94 "exlusive." +
96 }
97 } while (token != "");
98
99 G4String g4SpecialProcess(specialProcess.Data());
100
101 if (G4StrUtil::contains(g4SpecialProcess, "specialControls")) {
102 fSpecialControls = true;
103 // remove "specialControls" from the string passsed to special physics list
104 g4SpecialProcess.erase(g4SpecialProcess.find("specialControls"), 15);
105 if (g4SpecialProcess.find("++") != std::string::npos)
106 g4SpecialProcess.erase(g4SpecialProcess.find("++"), 1);
107 }
108 fSpecialProcessSelection = g4SpecialProcess;
109
110 if (G4StrUtil::contains(g4SpecialProcess, "specialCuts")) {
111 fSpecialCuts = true;
112 }
113
114 if (!TG4SpecialPhysicsList::IsAvailableSelection(g4SpecialProcess)) {
115
116 TG4Globals::Exception("TG4RunConfiguration", "TG4RunConfiguration",
117 "Special process selection " + specialProcess + " is not recognized." +
118 TG4Globals::Endl() + "Available options:" + TG4Globals::Endl() +
120 }
121
122#ifdef USE_VGM
123 // instantiate XML messengers
124 fAGDDMessenger = new TG4VGMMessenger("AGDD", userGeometry.Data());
125 fGDMLMessenger = new TG4VGMMessenger("GDML", userGeometry.Data());
126#endif
127}
128
129//_____________________________________________________________________________
137
138//
139// public methods
140//
141
142//_____________________________________________________________________________
151
152//_____________________________________________________________________________
154{
156
158
159 // Decompose physics list selection
160 G4int itoken = 0;
161 G4String emSelection;
162 G4String hadronSelection;
163 G4String extraSelection;
164 G4String token;
165 G4bool isValid = true;
166 while (
167 (token = TG4Globals::GetToken(itoken++, fPhysicsListSelection)) != "") {
168 // The first token must be either EM or Hadronic physics list
169 if (itoken == 1) {
171 emSelection = token;
172 }
174 hadronSelection = token;
175 }
176 else {
177 isValid = false;
178 }
179 }
180 // The next tokens are Extra physics selections
181 else {
183 extraSelection += token;
184 extraSelection += " ";
185 }
186 else {
187 isValid = false;
188 }
189 }
190 }
191
192 if (!isValid) {
193 TG4Globals::Exception("TG4RunConfiguration", "TG4RunConfiguration",
194 "Physics list selection " + fPhysicsListSelection + " is not valid." +
196 "The EMonly selections cannot be combined with Hadron selections." +
198 }
199
200 if (emSelection != "") {
201 G4cout << "Adding EMPhysicsList " << emSelection << G4endl;
202 builder->AddPhysicsList(new TG4EmPhysicsList(emSelection));
203 }
204
205 if (hadronSelection != "") {
206 G4cout << "Adding HadronPhysicsList " << hadronSelection << G4endl;
207 builder->AddPhysicsList(new TG4HadronPhysicsList(hadronSelection));
208 }
209
210 if (extraSelection != "") {
211 G4cout << "Adding ExtraPhysicsList " << extraSelection << G4endl;
212 builder->AddPhysicsList(
213 new TG4ExtraPhysicsList(extraSelection, fParameters));
214 }
215
216 // add option here
217 G4cout << "Adding SpecialPhysicsList " << fSpecialProcessSelection.Data()
218 << G4endl;
219 builder->AddPhysicsList(
221
222 return builder;
223}
224
225//_____________________________________________________________________________
232
233//_____________________________________________________________________________
240
241//_____________________________________________________________________________
248
249//_____________________________________________________________________________
256
257//_____________________________________________________________________________
264
265//_____________________________________________________________________________
274
275//_____________________________________________________________________________
282
283//_____________________________________________________________________________
291
292//_____________________________________________________________________________
299
300//_____________________________________________________________________________
302{
304
305 fMTApplication = mtApplication;
306}
307
308//_____________________________________________________________________________
309void TG4RunConfiguration::SetParameter(const TString& name, Double_t value)
310{
314
315 std::map<TString, Double_t>::iterator it = fParameters.find(name);
316
317 if (it != fParameters.end()) {
318 it->second = value;
319 }
320 else {
321 fParameters[name] = value;
322 }
323}
324
325//_____________________________________________________________________________
327{
330
331 G4cout
332 << "### Special cuts old activated: production cuts will be set by ranges."
333 << G4endl;
334
335 fSpecialCutsOld = true;
336}
337
338//_____________________________________________________________________________
340{
342
343 // strip out "geom"from the name
344 TString userGeometry = fUserGeometry;
345 userGeometry = userGeometry.Remove(0, 4);
346
347 return userGeometry;
348}
349
350//_____________________________________________________________________________
352{
354
355 return fSpecialStacking;
356}
357
358//_____________________________________________________________________________
360{
362
363 return fSpecialControls;
364}
365
366//_____________________________________________________________________________
368{
370
371 return fSpecialCuts;
372}
373
374//_____________________________________________________________________________
376{
378
379 return fSpecialCutsOld;
380}
381
382//_____________________________________________________________________________
384{
386
387 return fMTApplication;
388}
Definition of the TG4ComposedPhysicsList class.
Definition of the TG4DetConstruction class.
Definition of the TG4EmPhysicsList class.
Definition of the TG4EventAction class.
Definition of the TG4ExtraPhysicsList class.
Definition of the TG4Globals class and basic container types.
Definition of the TG4HadronPhysicsList class.
Definition of the TG4PrimaryGeneratorAction class.
Definition of the TG4RunAction class.
Definition of the TG4RunConfiguration class.
Definition of the TG4SpecialPhysicsList class.
Definition of the TG4SpecialStackingAction class.
Definition of the TG4SteppingAction class.
Definition of the TG4TrackingAction class.
Definition of the TG4VGMMessenger class.
Definition of the TG4VUserRegionConstruction class.
The Geant4 VMC physics list builder.
void AddPhysicsList(G4VUserPhysicsList *physicsList)
Detector construction for building geometry using TVirtualMCApplication.
The standard EM physics list.
static G4bool IsAvailableSelection(const G4String &selection)
static G4String AvailableSelections()
Actions at the beginning and the end of event.
The physics list with extra physics builders.
static G4bool IsAvailableSelection(const G4String &selection)
static G4String AvailableSelections()
static G4String GetToken(Int_t i, const TString &s)
static void Exception(const TString &className, const TString &methodName, const TString &text)
static TString Endl()
Definition TG4Globals.h:101
The hadron physics list helper class.
static G4String AvailableHadronSelections()
static G4String AvailableEMSelections()
static G4bool IsAvailableSelection(const G4String &selection)
Primary generator action defined via TVirtualMCStack and TVirtualMCApplication.
Actions at the beginning and the end of run.
std::map< TString, Double_t > fParameters
Bool_t fUseOfScoreWeighting
option to activate score weighting
virtual G4VUserPhysicsList * CreatePhysicsList()
TG4RunConfiguration()
Not implemented.
TString fPhysicsListSelection
physics list selection
virtual TG4SteppingAction * CreateSteppingAction()
virtual G4UserStackingAction * CreateStackingAction()
virtual TG4VUserFastSimulation * CreateUserFastSimulation()
Bool_t fSpecialStacking
option for special stacking
virtual G4VUserDetectorConstruction * CreateDetectorConstruction()
G4UImessenger * fAGDDMessenger
XML messenger.
Bool_t fMTApplication
option for MT mode if available
virtual TG4VUserRegionConstruction * CreateUserRegionConstruction()
virtual G4UserEventAction * CreateEventAction()
virtual TG4TrackingAction * CreateTrackingAction()
Bool_t fSpecialCuts
option for special cuts
Bool_t fSpecialCutsOld
option for special cuts old
virtual G4VUserPrimaryGeneratorAction * CreatePrimaryGenerator()
TString GetUserGeometry() const
TString fUserGeometry
way of building geometry
Bool_t fSpecialControls
option for special controls
Bool_t fUseOfG4Scoring
option to activate G4 commmand-line scoring
TString fSpecialProcessSelection
special process selection
void SetMTApplication(Bool_t mtApplication)
virtual TG4VUserPostDetConstruction * CreateUserPostDetConstruction()
virtual G4UserRunAction * CreateRunAction()
G4UImessenger * fGDMLMessenger
XML messenger.
void SetParameter(const TString &name, Double_t value)
The Geant4 VMC special physics list helper class.
static G4String AvailableSelections()
static G4bool IsAvailableSelection(const G4String &selection)
Defines a special stacking mechanism.
Actions at each step.
Actions at the beginnig and at the end of track.
Messenger class that defines commands for VGM XML Exporter.
The abstract base class which is used to build fast simulation models.
The abstract base class for user defined class to customize geometry.
The abstract base class for user defined regions.