Geant4 VMC Version 6.6
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),
46 fSpecialProcessSelection(),
47 fSpecialStacking(specialStacking),
48 fMTApplication(mtApplication),
49 fSpecialControls(false),
50 fSpecialCuts(false),
51 fSpecialCutsOld(false),
52 fAGDDMessenger(0),
53 fGDMLMessenger(0),
54 fParameters()
55{
57
58 if (userGeometry != "geomVMCtoGeant4" && userGeometry != "geomVMCtoRoot" &&
59 userGeometry != "geomRoot" && userGeometry != "geomRootToGeant4" &&
60 userGeometry != "geomVMC+RootToGeant4" && userGeometry != "geomGeant4") {
61
62 TG4Globals::Exception("TG4RunConfiguration", "TG4RunConfiguration",
63 "User geometry " + userGeometry + " not recognized." +
64 TG4Globals::Endl() + "Available options:" + TG4Globals::Endl() +
65 "geomVMCtoGeant4 geomVMCtoRoot geomRoot geomRootToGeant4 "
66 "geomVMC+RootToGeant4 geomGeant4");
67 }
68
69 G4int itoken = 0;
70 G4String token;
71 do {
72 token = TG4Globals::GetToken(itoken++, physicsList);
73
77
78 TG4Globals::Exception("TG4RunConfiguration", "TG4RunConfiguration",
79 "Physics list selection " + physicsList + " not recognized." +
80 TG4Globals::Endl() + "Available options:" + TG4Globals::Endl() +
81 "EMonly, EMonly+Extra, Hadron_EM, Hadron_EM+Extra" +
82 TG4Globals::Endl() + " where EMonly = " +
84 TG4Globals::Endl() + " Hadron = " +
86 TG4Globals::Endl() + " EM = " +
88 TG4Globals::Endl() + " Extra = " +
91 " The Extra selections are cumulative, while Hadron selections are "
92 "exlusive." +
94 }
95 } while (token != "");
96
97 G4String g4SpecialProcess(specialProcess.Data());
98
99 if (G4StrUtil::contains(g4SpecialProcess, "specialControls")) {
100 fSpecialControls = true;
101 // remove "specialControls" from the string passsed to special physics list
102 g4SpecialProcess.erase(g4SpecialProcess.find("specialControls"), 15);
103 if (g4SpecialProcess.find("++") != std::string::npos)
104 g4SpecialProcess.erase(g4SpecialProcess.find("++"), 1);
105 }
106 fSpecialProcessSelection = g4SpecialProcess;
107
108 if (G4StrUtil::contains(g4SpecialProcess, "specialCuts")) {
109 fSpecialCuts = true;
110 }
111
112 if (!TG4SpecialPhysicsList::IsAvailableSelection(g4SpecialProcess)) {
113
114 TG4Globals::Exception("TG4RunConfiguration", "TG4RunConfiguration",
115 "Special process selection " + specialProcess + " is not recognized." +
116 TG4Globals::Endl() + "Available options:" + TG4Globals::Endl() +
118 }
119
120#ifdef USE_VGM
121 // instantiate XML messengers
122 fAGDDMessenger = new TG4VGMMessenger("AGDD", userGeometry.Data());
123 fGDMLMessenger = new TG4VGMMessenger("GDML", userGeometry.Data());
124#endif
125}
126
127//_____________________________________________________________________________
135
136//
137// public methods
138//
139
140//_____________________________________________________________________________
149
150//_____________________________________________________________________________
152{
154
156
157 // Decompose physics list selection
158 G4int itoken = 0;
159 G4String emSelection;
160 G4String hadronSelection;
161 G4String extraSelection;
162 G4String token;
163 G4bool isValid = true;
164 while (
165 (token = TG4Globals::GetToken(itoken++, fPhysicsListSelection)) != "") {
166 // The first token must be either EM or Hadronic physics list
167 if (itoken == 1) {
169 emSelection = token;
170 }
172 hadronSelection = token;
173 }
174 else {
175 isValid = false;
176 }
177 }
178 // The next tokens are Extra physics selections
179 else {
181 extraSelection += token;
182 extraSelection += " ";
183 }
184 else {
185 isValid = false;
186 }
187 }
188 }
189
190 if (!isValid) {
191 TG4Globals::Exception("TG4RunConfiguration", "TG4RunConfiguration",
192 "Physics list selection " + fPhysicsListSelection + " is not valid." +
194 "The EMonly selections cannot be combined with Hadron selections." +
196 }
197
198 if (emSelection != "") {
199 G4cout << "Adding EMPhysicsList " << emSelection << G4endl;
200 builder->AddPhysicsList(new TG4EmPhysicsList(emSelection));
201 }
202
203 if (hadronSelection != "") {
204 G4cout << "Adding HadronPhysicsList " << hadronSelection << G4endl;
205 builder->AddPhysicsList(new TG4HadronPhysicsList(hadronSelection));
206 }
207
208 if (extraSelection != "") {
209 G4cout << "Adding ExtraPhysicsList " << extraSelection << G4endl;
210 builder->AddPhysicsList(
211 new TG4ExtraPhysicsList(extraSelection, fParameters));
212 }
213
214 // add option here
215 G4cout << "Adding SpecialPhysicsList " << fSpecialProcessSelection.Data()
216 << G4endl;
217 builder->AddPhysicsList(
219
220 return builder;
221}
222
223//_____________________________________________________________________________
230
231//_____________________________________________________________________________
238
239//_____________________________________________________________________________
246
247//_____________________________________________________________________________
254
255//_____________________________________________________________________________
262
263//_____________________________________________________________________________
272
273//_____________________________________________________________________________
280
281//_____________________________________________________________________________
289
290//_____________________________________________________________________________
297
298//_____________________________________________________________________________
300{
302
303 fMTApplication = mtApplication;
304}
305
306//_____________________________________________________________________________
307void TG4RunConfiguration::SetParameter(const TString& name, Double_t value)
308{
312
313 std::map<TString, Double_t>::iterator it = fParameters.find(name);
314
315 if (it != fParameters.end()) {
316 it->second = value;
317 }
318 else {
319 fParameters[name] = value;
320 }
321}
322
323//_____________________________________________________________________________
325{
328
329 G4cout
330 << "### Special cuts old activated: production cuts will be set by ranges."
331 << G4endl;
332
333 fSpecialCutsOld = true;
334}
335
336//_____________________________________________________________________________
338{
340
341 // strip out "geom"from the name
342 TString userGeometry = fUserGeometry;
343 userGeometry = userGeometry.Remove(0, 4);
344
345 return userGeometry;
346}
347
348//_____________________________________________________________________________
350{
352
353 return fSpecialStacking;
354}
355
356//_____________________________________________________________________________
358{
360
361 return fSpecialControls;
362}
363
364//_____________________________________________________________________________
366{
368
369 return fSpecialCuts;
370}
371
372//_____________________________________________________________________________
374{
376
377 return fSpecialCutsOld;
378}
379
380//_____________________________________________________________________________
382{
384
385 return fMTApplication;
386}
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:100
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
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.