Skip to content

Commit

Permalink
fix: Geant4SurfaceProvider gdml schema validation fix (#2956)
Browse files Browse the repository at this point in the history
Making the validation of the GDML file schema optional when parsing the files. 

Mainly added so that the tests could be decoupled from the state of the servers with the .xsd files.
  • Loading branch information
ssdetlab authored Feb 18, 2024
1 parent 003a0e8 commit 0c753b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class Geant4SurfaceProvider : public Acts::Experimental::ISurfacesProvider {
///@param config The configuration struct
///@param options The optional configuration for KDTree
Geant4SurfaceProvider(const Config& config,
const kdtOptions& options = kdtOptions()) {
const kdtOptions& options = kdtOptions(),
bool validateGDMLschema = true) {
if (config.gdmlPath.empty()) {
throw std::invalid_argument(
"Geant4SurfaceProvider: no gdml file provided");
Expand All @@ -101,7 +102,7 @@ class Geant4SurfaceProvider : public Acts::Experimental::ISurfacesProvider {

/// Read the gdml file and get the world volume
G4GDMLParser parser;
parser.Read(m_cfg.gdmlPath);
parser.Read(m_cfg.gdmlPath, validateGDMLschema);
m_g4World = parser.GetWorldVolume();

if (m_g4World == nullptr) {
Expand Down
14 changes: 8 additions & 6 deletions Tests/UnitTests/Plugins/Geant4/Geant4SurfaceProviderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ BOOST_AUTO_TEST_CASE(Geant4SurfaceProviderNames) {
std::make_shared<Acts::Geant4PhysicalVolumeSelectors::NameSelector>(names,
true);

auto spFull =
std::make_shared<Acts::Experimental::Geant4SurfaceProvider<>>(spFullCfg);
auto spFull = std::make_shared<Acts::Experimental::Geant4SurfaceProvider<>>(
spFullCfg, Acts::Experimental::Geant4SurfaceProvider<>::kdtOptions(),
false);

auto lbFullCfg = Acts::Experimental::LayerStructureBuilder::Config();
lbFullCfg.surfacesProvider = spFull;
Expand Down Expand Up @@ -161,7 +162,8 @@ BOOST_AUTO_TEST_CASE(Geant4SurfaceProviderNames) {

auto spLeftArm =
std::make_shared<Acts::Experimental::Geant4SurfaceProvider<>>(
spLeftArmCfg);
spLeftArmCfg,
Acts::Experimental::Geant4SurfaceProvider<>::kdtOptions(), false);

auto lbCfg = Acts::Experimental::LayerStructureBuilder::Config();
lbCfg.surfacesProvider = spLeftArm;
Expand Down Expand Up @@ -196,7 +198,7 @@ BOOST_AUTO_TEST_CASE(Geant4SurfaceProviderRanges) {
kdt1DOpt.binningValues = {Acts::BinningValue::binZ};

auto sp1D = std::make_shared<Acts::Experimental::Geant4SurfaceProvider<1>>(
sp1DCfg, kdt1DOpt);
sp1DCfg, kdt1DOpt, false);

auto lb1DCfg = Acts::Experimental::LayerStructureBuilder::Config();
lb1DCfg.surfacesProvider = sp1D;
Expand Down Expand Up @@ -231,7 +233,7 @@ BOOST_AUTO_TEST_CASE(Geant4SurfaceProviderRanges) {
kdt2DOpt.binningValues = {Acts::BinningValue::binZ};

auto sp2D = std::make_shared<Acts::Experimental::Geant4SurfaceProvider<2>>(
sp2DCfg, kdt2DOpt);
sp2DCfg, kdt2DOpt, false);

auto lb2DCfg = Acts::Experimental::LayerStructureBuilder::Config();
lb2DCfg.surfacesProvider = sp2D;
Expand Down Expand Up @@ -270,7 +272,7 @@ BOOST_AUTO_TEST_CASE(Geant4SurfaceProviderRanges) {
ranges);

auto sp2DPos = std::make_shared<Acts::Experimental::Geant4SurfaceProvider<1>>(
sp2DPosCfg, kdt1DOpt);
sp2DPosCfg, kdt1DOpt, false);

auto lb2DPosCfg = Acts::Experimental::LayerStructureBuilder::Config();
lb2DPosCfg.surfacesProvider = sp2DPos;
Expand Down

0 comments on commit 0c753b1

Please sign in to comment.