11 #include "G4GeometryManager.hh"
12 #include "G4PhysicalVolumeStore.hh"
13 #include "G4LogicalVolumeStore.hh"
14 #include "G4SolidStore.hh"
15 #include "G4SDManager.hh"
17 #include "G4GDMLParser.hh"
34 _physicalWorld(NULL), _geometry(NULL), _library(library), _configDataCard(configDataCard), _gdml(
"") {
40 const G4String &configDataCard,
bool) :
41 _physicalWorld(NULL), _geometry(NULL), _library(library), _configDataCard(configDataCard), _gdml(
"") {
48 _physicalWorld(NULL), _geometry(NULL), _library(
""), _configDataCard(
""), _gdml(gdml) {
61 static const std::string routineName(
"GGSDetectorConstruction::Construct");
67 COUT(ERROR) <<
"Impossible to load geometry library " << _library <<
ENDL;
68 throw std::runtime_error(
"Impossible to load geometry library");
72 COUT(ERROR) <<
"Can't create the geometry." <<
ENDL;
75 COUT(INFO) <<
"Construct the detector." <<
ENDL;
79 const std::string geoVersion = _geometry->
GetVersion();
80 if (geoVersion !=
"") {
81 COUT(INFO) <<
"Geometry version: " << geoVersion <<
ENDL;
84 COUT(INFO) <<
"No geometry version available" <<
ENDL;
88 throw(std::runtime_error(
"Error while exporting geometry parameters"));
94 if(intParams.size() + boolParams.size() + realParams.size() + stringParams.size() > 0) {
95 COUT(INFO) <<
"Geometry parameters:\n";
96 for(
auto &par : intParams) {
97 CCOUT(INFO) << par.first <<
": " << par.second <<
"\n";
99 for(
auto &par : boolParams) {
100 CCOUT(INFO) << par.first <<
": " << (par.second ?
"true" :
"false") <<
"\n";
102 for(
auto &par : realParams) {
103 CCOUT(INFO) << par.first <<
": " << par.second <<
"\n";
105 for(
auto &par : stringParams) {
106 CCOUT(INFO) << par.first <<
": " << par.second <<
"\n";
113 G4GDMLParser gdmlParser;
114 gdmlParser.SetOverlapCheck(
false);
116 gdmlParser.Read(_gdml,
false);
119 COUT(ERROR) <<
"G4GDML: " << ge <<
", missing network connection? wrong schema URL?"
126 gdmlParser.StripNamePointers();
127 _physicalWorld = gdmlParser.GetWorldVolume();
128 if (!_physicalWorld) {
129 COUT(ERROR) <<
"Cannot build the GMDL geometry." <<
ENDL;
130 throw std::runtime_error(
"Cannot build the GMDL geometry.");
138 const G4LogicalVolumeStore* logicalVolumeStore = G4LogicalVolumeStore::GetInstance();
139 std::vector<G4LogicalVolume*>::const_iterator i;
141 for (i = logicalVolumeStore->begin(); i != logicalVolumeStore->end(); i++) {
142 std::string logVolName = (*i)->GetName();
143 auto detVolName = logVolName.substr(0, logVolName.find_first_of(
' '));
144 auto spacePos = logVolName.find_last_of(
' ');
145 std::string scorerName(
"");
146 if (spacePos != std::string::npos)
147 scorerName = logVolName.substr(spacePos + 1);
150 COUT(WARNING) <<
"This version of GGS does not support the definition of sensitive volumes by name ("
151 << detVolName <<
").\n";
152 CCOUT(WARNING) <<
"Please change the name of the volume and make it active using a datacard command." <<
ENDL;
153 throw std::runtime_error(
"Use of removed feature: definition of sensitive volume by name.");
157 return _physicalWorld;
GGSDetectorConstruction(const G4String &library, const G4String &configDataCard)
Constructor.
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.
#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::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.
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.