Skip to content
Snippets Groups Projects
Commit a8b7de53 authored by adrien-matta's avatar adrien-matta
Browse files

* Adding option to export the current geometry to a gdml file

parent 9924154b
No related branches found
No related tags found
No related merge requests found
*.cmake
*.G4Table
*CMakeFiles*
*.ninja*
*.swp
Makefiles
*.gitignore
CMakeCache.txt
*.dylib
*.so
*.gdml
*.root
*.wrl
install_manifest.txt
.DS_store
*NPAnalysis*
.last_*
......@@ -42,6 +42,11 @@ EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE}
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${root_cflags}")
if(Geant4_gdml_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNPS_GDML")
endif()
# If the compiler is Clang, silence the unrecognised flags
if(${CMAKE_CXX_COMPILER_ID} MATCHES ".*Clang.*")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics -Wno-deprecated-register -Wno-shadow")
......
......@@ -52,7 +52,10 @@
#include "G4SolidStore.hh"
#include "G4RunManager.hh"
#include "G4SDManager.hh"
// Detector class
#ifdef NPS_GDML
#include"G4GDMLParser.hh"
#endif
// STL
#include<cstdlib>
......@@ -293,3 +296,10 @@ void DetectorConstruction::RedefineGeometry(std::string file){
G4RunManager::GetRunManager()->GeometryHasBeenModified();
G4RunManager::GetRunManager()->Initialize();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::ExportGeometry(string file){
G4GDMLParser parser ;
parser.Write(file.c_str(),world_log);
}
......@@ -42,45 +42,46 @@ class G4VPhysicalVolume;
// ROOT headers
#include "TTree.h"
class DetectorConstruction : public G4VUserDetectorConstruction
{
public:
DetectorConstruction();
virtual ~DetectorConstruction();
class DetectorConstruction : public G4VUserDetectorConstruction{
public:
DetectorConstruction();
virtual ~DetectorConstruction();
G4VPhysicalVolume* Construct();
G4LogicalVolume* GetWorldLogic();
// Delete every existing bit
void ClearGeometry();
// Reload the file configuration
void RedefineGeometry(string file="");
public:
G4VPhysicalVolume* ReadConfigurationFile();
void AddDetector(NPS::VDetector*);
void ReadAllSensitive(const G4Event*);
G4VPhysicalVolume* Construct();
G4LogicalVolume* GetWorldLogic();
// Delete every existing bit
void ClearGeometry();
// Reload the file configuration
void RedefineGeometry(string file="");
// Export the geometry to a gdml file
void ExportGeometry(string);
public:
G4VPhysicalVolume* ReadConfigurationFile();
void AddDetector(NPS::VDetector*);
void ReadAllSensitive(const G4Event*);
private:
// Logical volumes
G4LogicalVolume* world_log;
//G4LogicalVolume* Chamber_log;
// Physical volumes
G4VPhysicalVolume* world_phys;
//G4VPhysicalVolume* Chamber_phys;
private:
// Logical volumes
G4LogicalVolume* world_log;
//G4LogicalVolume* Chamber_log;
// Virtual Detector Vector
vector<NPS::VDetector*> m_Detectors;
// Physical volumes
G4VPhysicalVolume* world_phys;
//G4VPhysicalVolume* Chamber_phys;
// Virtual Detector Vector
vector<NPS::VDetector*> m_Detectors;
private: // Data about the target
Target* m_Target;
Chamber* m_Chamber;
DetectorMessenger* m_Messenger;
public: // Getter and Setter
Target* GetTarget() {return m_Target;}
Chamber* GetChamber() {return m_Chamber;}
private: // Data about the target
Target* m_Target;
Chamber* m_Chamber;
DetectorMessenger* m_Messenger;
public: // Getter and Setter
Target* GetTarget() {return m_Target;}
Chamber* GetChamber() {return m_Chamber;}
};
#endif
......
......@@ -42,6 +42,10 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction* Det):Detector(Det){
UpdateCmd->SetGuidance("Update detector geometry.");
UpdateCmd->SetGuidance("Apply this command after editing your geometry file ");
UpdateCmd->AvailableForStates(G4State_Idle);
ExportCmd = new G4UIcmdWithAString("/det/export_gdml",this);
ExportCmd->SetGuidance("export current geomtry to gdml");
ExportCmd->AvailableForStates(G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
......@@ -53,9 +57,13 @@ DetectorMessenger::~DetectorMessenger(){
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String){
if( command == UpdateCmd )
{ Detector->RedefineGeometry(""); }
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String value){
if( command == UpdateCmd ){
Detector->RedefineGeometry("");
}
else if(command ==ExportCmd ){
Detector->ExportGeometry(value);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
......@@ -48,6 +48,7 @@ class DetectorMessenger: public G4UImessenger{
G4UIdirectory* detDir;
G4UIcmdWithoutParameter* UpdateCmd;
G4UIcmdWithAString* ExportCmd;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment