GGS(GenericGEANT4Simulation)Software  2.6.0
All Data Structures Namespaces Files Functions Variables Typedefs Macros
Public Member Functions
GGSDetectorConstruction Class Reference

Class for GGS detector construction. More...

#include <GGSDetectorConstruction.h>

Inheritance diagram for GGSDetectorConstruction:
Inheritance graph
[legend]
Collaboration diagram for GGSDetectorConstruction:
Collaboration graph
[legend]

Public Member Functions

 GGSDetectorConstruction (const G4String &library, const G4String &configDataCard)
 Constructor. More...
 
 GGSDetectorConstruction (const G4String &library, const G4String &detectorFlags, const G4String &configDataCard, bool verbose)
 Constructor. More...
 
 GGSDetectorConstruction (const G4String &gdml)
 Constructor. More...
 
 ~GGSDetectorConstruction ()
 Destructor.
 
G4VPhysicalVolume * Construct ()
 Override of the Construct method. More...
 
const G4VPhysicalVolume * GetPhysicalWorld () const
 Returns a pointer to the physical world volume. More...
 
const GGSVGeometryConstructionGetGeometry () const
 Returns a pointer to the geometry. More...
 

Detailed Description

Class for GGS detector construction.

This class inherits from G4VUserDetectorConstruction and handles the detector construction. It loads the externally defined geometry, then finds the sensitive volumes and associate the corresponding hit type to each of them.

Definition at line 29 of file GGSDetectorConstruction.h.

Constructor & Destructor Documentation

GGSDetectorConstruction::GGSDetectorConstruction ( const G4String &  library,
const G4String &  configDataCard 
)

Constructor.

Constructor for geometry provided by a shared library.

Parameters
libraryThe shared library containing the concrete implementation of GGSVGeometryConstruction.
configDataCardData card for geometry configuration (behavior is geometry-dependent).

Definition at line 33 of file GGSDetectorConstruction.cpp.

33  :
34  _physicalWorld(NULL), _geometry(NULL), _library(library), _configDataCard(configDataCard), _gdml("") {
35 }
GGSDetectorConstruction::GGSDetectorConstruction ( const G4String &  library,
const G4String &  detectorFlags,
const G4String &  configDataCard,
bool  verbose 
)

Constructor.

Old constructor maintained for backward compatibility. The detector and verbosity flags are ignored (if needed, their functionalities can be implemented using a messenger for the geometry and a geometry datacard).

Parameters
libraryThe shared library containing the concrete implementation of GGSVGeometryConstruction.
detectorFlagsIgnored.
configDataCardData card for geometry configuration (behavior is geometry-dependent).
verboseIgnored.

Definition at line 39 of file GGSDetectorConstruction.cpp.

40  :
41  _physicalWorld(NULL), _geometry(NULL), _library(library), _configDataCard(configDataCard), _gdml("") {
42 
43 }
GGSDetectorConstruction::GGSDetectorConstruction ( const G4String &  gdml)

Constructor.

Constructor for geometry provided by a gdml file.

Parameters
gdmlThe gdml file.

Definition at line 47 of file GGSDetectorConstruction.cpp.

47  :
48  _physicalWorld(NULL), _geometry(NULL), _library(""), _configDataCard(""), _gdml(gdml) {
49 
50 }

Member Function Documentation

G4VPhysicalVolume * GGSDetectorConstruction::Construct ( )

Override of the Construct method.

This override constructs the geometry by loading the external geometry library, then identifies the sensitive volumes and associate the corresponding hits to them.

Returns
Pointer to the physical world volume.

Definition at line 59 of file GGSDetectorConstruction.cpp.

59  {
60 
61  static const std::string routineName("GGSDetectorConstruction::Construct");
62 
63  // 1. Construct the geometry
64  if (_library != "") {
65  // 1.1 Load the concrete GGSVGeometryConstruction from a shared library
66  if (!(GGSGeoPluginManager::GetInstance().LoadGeoPlugin(_library))) {
67  COUT(ERROR) << "Impossible to load geometry library " << _library << ENDL;
68  throw std::runtime_error("Impossible to load geometry library");
69  }
71  if (!_geometry) {
72  COUT(ERROR) << "Can't create the geometry." << ENDL;
73 
74  }
75  COUT(INFO) << "Construct the detector." << ENDL;
76  _geometry->SetGeoDataCard(_configDataCard);
77  _physicalWorld = _geometry->Construct();
78  // Print geometry version
79  const std::string geoVersion = _geometry->GetVersion();
80  if (geoVersion != "") {
81  COUT(INFO) << "Geometry version: " << geoVersion << ENDL;
82  }
83  else {
84  COUT(INFO) << "No geometry version available" << ENDL;
85  }
86  // Print geometry parameters
87  if(!_geometry->ExportParameters()) {
88  throw(std::runtime_error("Error while exporting geometry parameters"));
89  }
90  auto intParams = _geometry->GetIntParameters();
91  auto boolParams = _geometry->GetBoolParameters();
92  auto realParams = _geometry->GetRealParameters();
93  auto stringParams = _geometry->GetStringParameters();
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";
98  }
99  for(auto &par : boolParams) {
100  CCOUT(INFO) << par.first <<": " << (par.second ? "true" : "false") << "\n";
101  }
102  for(auto &par : realParams) {
103  CCOUT(INFO) << par.first <<": " << par.second << "\n";
104  }
105  for(auto &par : stringParams) {
106  CCOUT(INFO) << par.first <<": " << par.second << "\n";
107  }
108  }
109  }
110 #ifdef USE_GDML
111  else {
112  // 1.2 Build the geometry from a GDML file
113  G4GDMLParser gdmlParser;
114  gdmlParser.SetOverlapCheck(false);
115  try {
116  gdmlParser.Read(_gdml, false);
117  }
118  catch (int &ge) {
119  COUT(ERROR) << "G4GDML: " << ge << ", missing network connection? wrong schema URL?"
120  << ENDL;
121  //G4COUT << "Try to read GDML file _WITHOUT_ schema validation" << G4ENDL;
122  // error, try without schema validation
123  //gdmlParser.ValidateSchema(false);
124  //gdmlParser.Read(_gdml, false);
125  }
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.");
131  }
132  }
133 #endif
134 
135  // 2. Construct the standard SDs
136  // This feature is removed from GGS, so print an error message and throw an exception.
137 
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);
148  // check if it is a sensitive volume
149  if (nameDecoder.IsSensitive(detVolName)) {
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.");
154  }
155  }
156 
157  return _physicalWorld;
158 
159 }
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.
#define ENDL
Definition: GGSSmartLog.h:93
#define COUT(level)
Smart log macro. It writes on stdout only if the specified verbosity level is lesser than the maximum...
Definition: GGSSmartLog.h:66
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.
Definition: GGSSmartLog.h:88
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.
const GGSVGeometryConstruction* GGSDetectorConstruction::GetGeometry ( ) const
inline

Returns a pointer to the geometry.

Returns
Pointer to the geometry construction object.

Definition at line 86 of file GGSDetectorConstruction.h.

86  {
87  return _geometry;
88  }
const G4VPhysicalVolume* GGSDetectorConstruction::GetPhysicalWorld ( ) const
inline

Returns a pointer to the physical world volume.

Returns
Pointer to the physical world volume.

Definition at line 78 of file GGSDetectorConstruction.h.

78  {
79  return _physicalWorld;
80  }

The documentation for this class was generated from the following files: