Geant4 VMC Version 6.7
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),
56{
58
59 if (userGeometry != "geomVMCtoGeant4" && userGeometry != "geomVMCtoRoot" &&
60 userGeometry != "geomRoot" && userGeometry != "geomRootToGeant4" &&
61 userGeometry != "geomVMC+RootToGeant4" && userGeometry != "geomGeant4") {
62
63 TG4Globals::Exception("TG4RunConfiguration", "TG4RunConfiguration",
64 "User geometry " + userGeometry + " not recognized." +
65 TG4Globals::Endl() + "Available options:" + TG4Globals::Endl() +
66 "geomVMCtoGeant4 geomVMCtoRoot geomRoot geomRootToGeant4 "
67 "geomVMC+RootToGeant4 geomGeant4");
68 }
69
70 G4int itoken = 0;
71 G4String token;
72 do {
73 token = TG4Globals::GetToken(itoken++, physicsList);
74
78
79 TG4Globals::Exception("TG4RunConfiguration", "TG4RunConfiguration",
80 "Physics list selection " + physicsList + " not recognized." +
81 TG4Globals::Endl() + "Available options:" + TG4Globals::Endl() +
82 "EMonly, EMonly+Extra, Hadron_EM, Hadron_EM+Extra" +
83 TG4Globals::Endl() + " where EMonly = " +
85 TG4Globals::Endl() + " Hadron = " +
87 TG4Globals::Endl() + " EM = " +
89 TG4Globals::Endl() + " Extra = " +
92 " The Extra selections are cumulative, while Hadron selections are "
93 "exlusive." +
95 }
96 } while (token != "");
97
98 G4String g4SpecialProcess(specialProcess.Data());
99
100 if (G4StrUtil::contains(g4SpecialProcess, "specialControls")) {
101 fSpecialControls = true;
102 // remove "specialControls" from the string passsed to special physics list
103 g4SpecialProcess.erase(g4SpecialProcess.find("specialControls"), 15);
104 if (g4SpecialProcess.find("++") != std::string::npos)
105 g4SpecialProcess.erase(g4SpecialProcess.find("++"), 1);
106 }
107 fSpecialProcessSelection = g4SpecialProcess;
108
109 if (G4StrUtil::contains(g4SpecialProcess, "specialCuts")) {
110 fSpecialCuts = true;
111 }
112
113 if (!TG4SpecialPhysicsList::IsAvailableSelection(g4SpecialProcess)) {
114
115 TG4Globals::Exception("TG4RunConfiguration", "TG4RunConfiguration",
116 "Special process selection " + specialProcess + " is not recognized." +
117 TG4Globals::Endl() + "Available options:" + TG4Globals::Endl() +
119 }
120
121#ifdef USE_VGM
122 // instantiate XML messengers
123 fAGDDMessenger = new TG4VGMMessenger("AGDD", userGeometry.Data());
124 fGDMLMessenger = new TG4VGMMessenger("GDML", userGeometry.Data());
125#endif
126}
127
128//_____________________________________________________________________________
136
137//
138// public methods
139//
140
141//_____________________________________________________________________________
150
151//_____________________________________________________________________________
153{
155
157
158 // Decompose physics list selection
159 G4int itoken = 0;
160 G4String emSelection;
161 G4String hadronSelection;
162 G4String extraSelection;
163 G4String token;
164 G4bool isValid = true;
165 while (
166 (token = TG4Globals::GetToken(itoken++, fPhysicsListSelection)) != "") {
167 // The first token must be either EM or Hadronic physics list
168 if (itoken == 1) {
170 emSelection = token;
171 }
173 hadronSelection = token;
174 }
175 else {
176 isValid = false;
177 }
178 }
179 // The next tokens are Extra physics selections
180 else {
182 extraSelection += token;
183 extraSelection += " ";
184 }
185 else {
186 isValid = false;
187 }
188 }
189 }
190
191 if (!isValid) {
192 TG4Globals::Exception("TG4RunConfiguration", "TG4RunConfiguration",
193 "Physics list selection " + fPhysicsListSelection + " is not valid." +
195 "The EMonly selections cannot be combined with Hadron selections." +
197 }
198
199 if (emSelection != "") {
200 G4cout << "Adding EMPhysicsList " << emSelection << G4endl;
201 builder->AddPhysicsList(new TG4EmPhysicsList(emSelection));
202 }
203
204 if (hadronSelection != "") {
205 G4cout << "Adding HadronPhysicsList " << hadronSelection << G4endl;
206 builder->AddPhysicsList(new TG4HadronPhysicsList(hadronSelection));
207 }
208
209 if (extraSelection != "") {
210 G4cout << "Adding ExtraPhysicsList " << extraSelection << G4endl;
211 builder->AddPhysicsList(
212 new TG4ExtraPhysicsList(extraSelection, fParameters));
213 }
214
215 // add option here
216 G4cout << "Adding SpecialPhysicsList " << fSpecialProcessSelection.Data()
217 << G4endl;
218 builder->AddPhysicsList(
220
221 return builder;
222}
223
224//_____________________________________________________________________________
231
232//_____________________________________________________________________________
239
240//_____________________________________________________________________________
247
248//_____________________________________________________________________________
255
256//_____________________________________________________________________________
263
264//_____________________________________________________________________________
273
274//_____________________________________________________________________________
281
282//_____________________________________________________________________________
290
291//_____________________________________________________________________________
298
299//_____________________________________________________________________________
301{
303
304 fMTApplication = mtApplication;
305}
306
307//_____________________________________________________________________________
308void TG4RunConfiguration::SetParameter(const TString& name, Double_t value)
309{
313
314 std::map<TString, Double_t>::iterator it = fParameters.find(name);
315
316 if (it != fParameters.end()) {
317 it->second = value;
318 }
319 else {
320 fParameters[name] = value;
321 }
322}
323
324//_____________________________________________________________________________
326{
329
330 G4cout
331 << "### Special cuts old activated: production cuts will be set by ranges."
332 << G4endl;
333
334 fSpecialCutsOld = true;
335}
336
337//_____________________________________________________________________________
339{
341
342 // strip out "geom"from the name
343 TString userGeometry = fUserGeometry;
344 userGeometry = userGeometry.Remove(0, 4);
345
346 return userGeometry;
347}
348
349//_____________________________________________________________________________
351{
353
354 return fSpecialStacking;
355}
356
357//_____________________________________________________________________________
359{
361
362 return fSpecialControls;
363}
364
365//_____________________________________________________________________________
367{
369
370 return fSpecialCuts;
371}
372
373//_____________________________________________________________________________
375{
377
378 return fSpecialCutsOld;
379}
380
381//_____________________________________________________________________________
383{
385
386 return fMTApplication;
387}
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
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.