Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/DetectorConstruction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <G4AssemblyVolume.hh>
#include "fields/BabyMINDMagneticField.hh"
#include <vector>
#include <string>

class G4LogicalVolume;
class DetectorConstructionMessenger;
Expand Down Expand Up @@ -48,7 +49,7 @@ class DetectorConstruction : public G4VUserDetectorConstruction {
DetectorConstructionMessenger* messenger;

G4bool m_saveGdml;
G4String m_fileGdml;
std::string m_fileGdml;
G4bool fCheckOverlap;
G4bool m_addFLArE;
G4bool m_useBabyMIND;
Expand Down
9 changes: 8 additions & 1 deletion src/DetectorConstruction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
#include <G4GDMLParser.hh>
#include <G4SubtractionSolid.hh>

using namespace std;
#include <filesystem>
#include <string>

G4ThreadLocal G4UniformMagField* DetectorConstruction::magField = 0;
G4ThreadLocal G4FieldManager* DetectorConstruction::fieldMgr = 0;
Expand Down Expand Up @@ -272,6 +273,12 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
if (m_saveGdml) {
G4GDMLParser fParser;
G4cout << "Exporting geometry to " << m_fileGdml << G4endl;

if(std::filesystem::exists(m_fileGdml)){
G4cout << " File already exists. Deleting first..." << G4endl;
std::filesystem::remove(m_fileGdml);
}

fParser.Write(m_fileGdml, worldPV, false);
}

Expand Down