11 #include "G4GeometryManager.hh"
12 #include "G4LogicalVolumeStore.hh"
13 #include "G4PhysicalVolumeStore.hh"
14 #include "G4SDManager.hh"
15 #include "G4SolidStore.hh"
17 #include "G4GDMLParser.hh"
34 : _physicalWorld(NULL), _geometry(NULL), _library(library), _configDataCard(configDataCard), _gdml(
"") {}
39 const G4String &configDataCard,
bool)
40 : _physicalWorld(NULL), _geometry(NULL), _library(library), _configDataCard(configDataCard), _gdml(
"") {}
45 : _physicalWorld(NULL), _geometry(NULL), _library(
""), _configDataCard(
""), _gdml(gdml) {}
55 static const std::string routineName(
"GGSDetectorConstruction::Construct");
61 COUT(ERROR) <<
"Impossible to load geometry library " << _library <<
ENDL;
62 throw std::runtime_error(
"Impossible to load geometry library");
66 COUT(ERROR) <<
"Can't create the geometry." <<
ENDL;
68 COUT(INFO) <<
"Construct the detector." <<
ENDL;
72 const std::string geoVersion = _geometry->
GetVersion();
73 if (geoVersion !=
"") {
74 COUT(INFO) <<
"Geometry version: " << geoVersion <<
ENDL;
76 COUT(INFO) <<
"No geometry version available" <<
ENDL;
88 if (intParams.size() + boolParams.size() + realParams.size() + stringParams.size() > 0) {
89 COUT(INFO) <<
"Geometry parameters:\n";
90 for (
auto &par : intParams) {
91 CCOUT(INFO) << par.first <<
": " << par.second <<
"\n";
93 for (
auto &par : boolParams) {
94 CCOUT(INFO) << par.first <<
": " << (par.second ?
"true" :
"false") <<
"\n";
96 for (
auto &par : realParams) {
97 CCOUT(INFO) << par.first <<
": " << par.second <<
"\n";
99 for (
auto &par : stringParams) {
100 CCOUT(INFO) << par.first <<
": " << par.second <<
"\n";
102 for (
auto &par : vectIntParams) {
103 CCOUT(INFO) << par.first <<
": {";
104 for (
size_t iVal = 0; iVal < par.second.size() - 1; ++iVal) {
105 std::cout << par.second[iVal] <<
", ";
107 std::cout << par.second.back() <<
"}\n";
109 for (
auto &par : vectRealParams) {
110 CCOUT(INFO) << par.first <<
": {";
111 for (
size_t iVal = 0; iVal < par.second.size() - 1; ++iVal) {
112 std::cout << par.second[iVal] <<
", ";
114 std::cout << par.second.back() <<
"}\n";
116 for (
auto &par : vectBoolParams) {
117 CCOUT(INFO) << par.first <<
": {";
118 for (
size_t iVal = 0; iVal < par.second.size() - 1; ++iVal) {
119 std::cout << par.second[iVal] <<
", ";
121 std::cout << par.second.back() <<
"}\n";
123 for (
auto &par : vectStringParams) {
124 CCOUT(INFO) << par.first <<
": {";
125 for (
size_t iVal = 0; iVal < par.second.size() - 1; ++iVal) {
126 std::cout << par.second[iVal] <<
", ";
128 std::cout << par.second.back() <<
"}\n";
135 G4GDMLParser gdmlParser;
136 gdmlParser.SetOverlapCheck(
false);
138 gdmlParser.Read(_gdml,
false);
140 COUT(ERROR) <<
"G4GDML: " << ge <<
", missing network connection? wrong schema URL?" <<
ENDL;
146 gdmlParser.StripNamePointers();
147 _physicalWorld = gdmlParser.GetWorldVolume();
148 if (!_physicalWorld) {
149 COUT(ERROR) <<
"Cannot build the GMDL geometry." <<
ENDL;
150 throw std::runtime_error(
"Cannot build the GMDL geometry.");
158 const G4LogicalVolumeStore *logicalVolumeStore = G4LogicalVolumeStore::GetInstance();
159 std::vector<G4LogicalVolume *>::const_iterator i;
161 for (i = logicalVolumeStore->begin(); i != logicalVolumeStore->end(); i++) {
162 std::string logVolName = (*i)->GetName();
163 auto detVolName = logVolName.substr(0, logVolName.find_first_of(
' '));
164 auto spacePos = logVolName.find_last_of(
' ');
165 std::string scorerName(
"");
166 if (spacePos != std::string::npos)
167 scorerName = logVolName.substr(spacePos + 1);
170 COUT(WARNING) <<
"This version of GGS does not support the definition of sensitive volumes by name ("
171 << detVolName <<
").\n";
172 CCOUT(WARNING) <<
"Please change the name of the volume and make it active using a datacard command." <<
ENDL;
173 throw std::runtime_error(
"Use of removed feature: definition of sensitive volume by name.");
177 return _physicalWorld;
180 void GGSDetectorConstruction::ConstructSDandField() { _geometry->ConstructSDandField(); }
GGSDetectorConstruction(const G4String &library, const G4String &configDataCard)
Constructor.
const std::map< std::string, std::vector< bool > > & GetVectBoolParameters()
Getter method for vector-of-booleans geometry parameters.
const std::map< std::string, int > & GetIntParameters()
Getter method for integer geometry parameters.
const std::map< std::string, double > & GetRealParameters()
Getter method for real geometry parameters.
static GGSGeoPluginManager & GetInstance()
Get the singleton instance.
G4VPhysicalVolume * Construct()
Override of the Construct method.
const std::map< std::string, std::vector< std::string > > & GetVectStringParameters()
Getter method for vector-of-strings geometry parameters.
#define COUT(level)
Smart log macro. It writes on stdout only if the specified verbosity level is lesser than the maximum...
virtual G4VPhysicalVolume * Construct()=0
Construct the detector - virtual method.
const std::map< std::string, std::vector< int > > & GetVectIntParameters()
Getter method for vector-of-integers geometry parameters.
const std::map< std::string, std::string > & GetStringParameters()
Getter method for string geometry parameters.
#define CCOUT(level)
Smart log utility which prints no header at the beginning of the line.
~GGSDetectorConstruction()
Destructor.
const std::map< std::string, std::vector< double > > & GetVectRealParameters()
Getter method for vector-of-reals geometry parameters.
virtual const std::string GetVersion()
Getter method for geometry version.
const std::map< std::string, bool > & GetBoolParameters()
Getter method for boolean geometry parameters.
virtual bool ExportParameters()
Function for exporting the geometry parameters.
GGSVGeometryConstruction * GetGeoConstruction()
Returns the geometry construction object.
static GGSNameDecoder & GetInstance()
Get instance of the singleton.
bool IsSensitive(const std::string &volumeName)
Check if the logical volume is sensitive.
Class needed to decode sensitive volume names.
void SetGeoDataCard(const G4String &dataCard)
Sets the geometry configuration datacard.