Import Geant4 11.2.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2023-06-30 09:09:57 +02:00
parent aef78ca386
commit dd1f179cda
3780 changed files with 212808 additions and 142780 deletions
@@ -52,6 +52,12 @@ G4GDMLMessenger::G4GDMLMessenger(G4GDMLParser* myPars)
gdmlDir = new G4UIdirectory("/persistency/gdml/");
gdmlDir->SetGuidance("GDML parser and writer.");
ReaderSchema = new G4UIcmdWithAString("/persistency/gdml/schema", this);
ReaderSchema->SetGuidance("Set alternative GDML schema file for import validation.");
ReaderSchema->SetParameterName("schema_path_and_filename", false);
ReaderSchema->AvailableForStates(G4State_PreInit, G4State_Idle);
ReaderSchema->SetToBeBroadcasted(false);
ReaderCmd = new G4UIcmdWithAString("/persistency/gdml/read", this);
ReaderCmd->SetGuidance("Read GDML file.");
ReaderCmd->SetParameterName("filename", false);
@@ -121,6 +127,7 @@ G4GDMLMessenger::G4GDMLMessenger(G4GDMLParser* myPars)
// --------------------------------------------------------------------
G4GDMLMessenger::~G4GDMLMessenger()
{
delete ReaderSchema;
delete ReaderCmd;
delete WriterCmd;
delete ClearCmd;
@@ -149,6 +156,11 @@ void G4GDMLMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
myParser->SetAddPointerToName(pFlag);
}
if(command == ReaderSchema)
{
myParser->SetImportSchema(newValue);
}
if(command == ReaderCmd)
{
G4GeometryManager::GetInstance()->OpenGeometry();
+37
View File
@@ -38,6 +38,8 @@
#include "G4SolidStore.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4EnvironmentUtils.hh"
#include "G4Exception.hh"
// --------------------------------------------------------------------
G4GDMLRead::G4GDMLRead()
@@ -418,6 +420,18 @@ void G4GDMLRead::ExtensionRead(const xercesc::DOMElement* const)
error_msg);
}
// --------------------------------------------------------------------
const G4String& G4GDMLRead::GetSchemaFile() const
{
return schema;
}
// --------------------------------------------------------------------
void G4GDMLRead::SetSchemaFile(const G4String& schemaFile)
{
schema = schemaFile;
}
// --------------------------------------------------------------------
void G4GDMLRead::Read(const G4String& fileName, G4bool validation,
G4bool isModule, G4bool strip)
@@ -442,6 +456,29 @@ void G4GDMLRead::Read(const G4String& fileName, G4bool validation,
if(validate)
{
parser->setValidationScheme(xercesc::XercesDOMParser::Val_Always);
// Load alternative schema path if specified by user in
// 1. environment variable, or
// 2. `schema` data member, or
// Will fall back to default validation otherwise (`xsi:noNamespaceSchemaLocation` in input file)
if(auto schemaPath = G4GetEnv<G4String>("G4GDML_SCHEMA_FILE", schema); schemaPath != "")
{
// Pre-parse grammar to check it's present/valid
if(parser->loadGrammar(schemaPath.c_str(), xercesc::Grammar::SchemaGrammarType, true) != nullptr)
{
G4cout << "G4GDML: Loaded alternative schema URI: " << schemaPath << G4endl;
}
else
{
G4Exception("G4GDMLRead::Read()",
"InvalidGDMLSchemaFile",
FatalException,
G4String("Failed to load/parse schema file '" + schemaPath + "'").c_str());
}
parser->useCachedGrammarInParse(true);
// If the schema has been set manually then we want to ignore path set in input file, if any
parser->setExternalNoNamespaceSchemaLocation(schemaPath.c_str());
}
}
parser->setValidationSchemaFullChecking(validate);
parser->setCreateEntityReferenceNodes(false);
@@ -890,7 +890,7 @@ void G4GDMLWriteStructure::SetSDExport(G4bool fsd)
// --------------------------------------------------------------------
void G4GDMLWriteStructure::ExportSD(const G4LogicalVolume* const lvol)
{
G4VSensitiveDetector* sd = lvol->GetSensitiveDetector();
G4VSensitiveDetector* sd = lvol->GetMasterSensitiveDetector();
if(sd != nullptr)
{