Geant4 VMC Version 6.6
Loading...
Searching...
No Matches
TG4ModelConfiguration.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
16
17#include <G4AnalysisUtilities.hh>
18
19#include <algorithm>
20
21namespace
22{
23
24G4bool Contains(const G4String& name, const G4String& nameList)
25{
26 // Append a space to both searched name and the list
27 // in order to exclude a match for names which are only substrings of
28 // some name present in the list.
29 // Eg. when Air2 is in the list and Air is checked for a presence
30
31 G4String checkName(name);
32 checkName.append(" ");
33
34 G4String checkNameList(nameList);
35 checkNameList.append(" ");
36
37 return (checkNameList.find(checkName) != std::string::npos);
38}
39
40void PrintNamesVector(const std::vector<G4String> names)
41{
42 std::vector<G4String>::const_iterator it;
43 for (it = names.begin(); it != names.end(); it++) {
44 G4cout << (*it) << " ";
45 }
46}
47
48} // namespace
49
50//_____________________________________________________________________________
52 : fModelName(modelName),
53 fParticles(),
54 fRegionsMedia(),
55 fRegions(),
56 fFastSimulationModel(0)
57{
59}
60
61//_____________________________________________________________________________
62void TG4ModelConfiguration::SetRegionsMedia(const G4String& regionsMedia)
63{
68
69 std::vector<G4String> mediaVector;
70 if (regionsMedia.size()) {
71 // use analysis utility to tokenize regions
72 G4Analysis::Tokenize(regionsMedia, mediaVector);
73 }
74
75 // append the medias
76 fRegionsMedia.insert(
77 fRegionsMedia.end(), mediaVector.begin(), mediaVector.end());
78}
79
80//_____________________________________________________________________________
81void TG4ModelConfiguration::SetOneRegionMedium(const G4String& regionMedium)
82{
83 // append the medium
84 fRegionsMedia.push_back(regionMedium);
85}
86
87//_____________________________________________________________________________
88void TG4ModelConfiguration::SetOneRegion(const G4String& region)
89{
90 // append the region
91 fRegions.push_back(region);
92}
93
94//_____________________________________________________________________________
96{
98
99 G4cout << "Model configuration: " << fModelName << G4endl;
100 G4cout << "particles: " << fParticles << G4endl;
101 G4cout << "media: ";
102 PrintNamesVector(fRegionsMedia);
103 G4cout << G4endl;
104 G4cout << "regions: ";
105 PrintNamesVector(fRegions);
106 G4cout << G4endl;
107}
108
109//_____________________________________________________________________________
110G4bool TG4ModelConfiguration::HasParticle(const G4String& particleName)
111{
113
114 return Contains(particleName, fParticles);
115}
116
117//_____________________________________________________________________________
118G4bool TG4ModelConfiguration::HasRegion(const G4String& regionName)
119{
121
122 return (
123 std::find(fRegions.begin(), fRegions.end(), regionName) != fRegions.end());
124}
Definition of the TG4ModelConfiguration class.
void SetOneRegionMedium(const G4String &regionMedium)
std::vector< G4String > fRegionsMedia
the vector of regions media
G4String fParticles
the list of particle names
void SetRegionsMedia(const G4String &regionsMedia)
TG4ModelConfiguration(const G4String &modelName)
std::vector< G4String > fRegions
the vector of created regions (per materials)
void SetOneRegion(const G4String &region)
G4String fModelName
the EM model name
G4bool HasParticle(const G4String &particleName)
G4bool HasRegion(const G4String &regionName)