diff --git a/FullSimLight/CMakeLists.txt b/FullSimLight/CMakeLists.txt index 3ebc8a6c3bd70dfa9b779d31d6be220b3c00fa32..a758278193b8347318f37ee12ea53a5031aac161 100644 --- a/FullSimLight/CMakeLists.txt +++ b/FullSimLight/CMakeLists.txt @@ -100,6 +100,7 @@ target_link_libraries(FullSimLight_obj nlohmann_json::nlohmann_json GeoModel2G4 GeoModelCore::GeoModelKernel + GeoModelCore::GeoModelFuncSnippets GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite ${HEPMC3_LIB} diff --git a/FullSimLight/include/FSLDetectorConstruction.hh b/FullSimLight/include/FSLDetectorConstruction.hh index f470a69a23526168d0ca5f9eaba78ad1615c565c..5c1295b039aea1120be0be3936a5b71912712b23 100644 --- a/FullSimLight/include/FSLDetectorConstruction.hh +++ b/FullSimLight/include/FSLDetectorConstruction.hh @@ -89,7 +89,6 @@ public: static G4double GetFieldValue() { return gFieldValue; } G4double GetTolerance (){return fTolerance;} - GeoVPhysVol* CreateTheWorld(GeoVPhysVol* world); /// Clean the geometry from Unidentified volumes before dumping it in GDML format void PullUnidentifiedVolumes( G4LogicalVolume* v ); diff --git a/FullSimLight/src/FSLDetectorConstruction.cc b/FullSimLight/src/FSLDetectorConstruction.cc index bcbd24fdea38fe2f97496dff8c34373c4c010836..a253ab31a60a7ff60411b7f6f145a481e2c769d9 100644 --- a/FullSimLight/src/FSLDetectorConstruction.cc +++ b/FullSimLight/src/FSLDetectorConstruction.cc @@ -31,7 +31,7 @@ #include "G4GDMLParser.hh" //#include "G4LogicalVolumeStore.hh" - +#include <algorithm> // Geant4 steppers #if G4VERSION_NUMBER>=1040 #include "G4BogackiShampine23.hh" @@ -72,6 +72,8 @@ #include "GeoModelKernel/GeoVGeometryPlugin.h" #include "GeoModelKernel/GeoGeometryPluginLoader.h" #include "GeoModelKernel/GeoVolumeCursor.h" +#include "GeoModelKernel/GeoAlignableTransform.h" +#include "GeoModelFuncSnippets/defineWorld.h" // For Sensitive Detector plugins: #include "FullSimLight/FSLSensitiveDetectorPlugin.h" @@ -112,33 +114,6 @@ FSLDetectorConstruction::~FSLDetectorConstruction() delete fDetectorMessenger; } -GeoVPhysVol* FSLDetectorConstruction::CreateTheWorld(GeoVPhysVol* world) -{ - if (world == nullptr) - { - // Setup the 'World' volume from which everything else will be suspended - // Get the materials that we shall use. - // -------------------------------------// - GeoMaterial* Air = new GeoMaterial("Air", 1.290*SYSTEM_OF_UNITS::mg/SYSTEM_OF_UNITS::cm3); - GeoElement* Oxygen = new GeoElement("Oxygen", "O", 8.0, 15.9949*SYSTEM_OF_UNITS::g/SYSTEM_OF_UNITS::mole); - GeoElement* Nitrogen = new GeoElement("Nitrogen", "N", 7., 14.0031*SYSTEM_OF_UNITS::g/SYSTEM_OF_UNITS::mole); - GeoElement* Argon = new GeoElement("Argon", "Ar", 18., 39.9624*SYSTEM_OF_UNITS::g/SYSTEM_OF_UNITS::mole); - GeoElement* Hydrogen = new GeoElement("Hydrogen", "H", 1., 1.00782503081372*SYSTEM_OF_UNITS::g/SYSTEM_OF_UNITS::mole); - - Air->add(Nitrogen, 0.7494); - Air->add(Oxygen, 0.2369); - Air->add(Argon, 0.0129); - Air->add(Hydrogen, 0.0008); - - Air->lock(); - const GeoBox* worldBox = new GeoBox(2000*SYSTEM_OF_UNITS::cm, 2000*SYSTEM_OF_UNITS::cm, 4000*SYSTEM_OF_UNITS::cm); - const GeoLogVol* worldLog = new GeoLogVol("WorldLog", worldBox, Air); - //const GeoLogVol* worldLog = new GeoLogVol("WorldLog", worldBox, Ether); - world = new GeoPhysVol(worldLog); - } - return world; -} - G4VPhysicalVolume *FSLDetectorConstruction::Construct() { fTimer.Start(); @@ -156,10 +131,11 @@ G4VPhysicalVolume *FSLDetectorConstruction::Construct() } - GeoVPhysVol* worldTmp = CreateTheWorld(nullptr); + GeoIntrusivePtr<GeoPhysVol> worldTmp{createGeoWorld()}; factory->create(worldTmp); - world = worldTmp; - + GeoIntrusivePtr<GeoPhysVol> world = resizeGeoWorld(worldTmp); + G4cout << "World resized correctly." << G4endl; + G4cout << "ReadGeoModel::buildGeoModel() done." << G4endl; fTimer.Stop(); G4cout << "First step done. GeoModelTree built from the SQLite file." << G4endl; @@ -169,7 +145,7 @@ G4VPhysicalVolume *FSLDetectorConstruction::Construct() fTimer.Start(); // build the Geant4 geometry and get an hanlde to the world' volume - ExtParameterisedVolumeBuilder* builder = new ExtParameterisedVolumeBuilder("ATLAS"); + ExtParameterisedVolumeBuilder* builder = new ExtParameterisedVolumeBuilder("Detector"); std::cout << "Building G4 geometry."<<std::endl; envelope = builder->Build(world); diff --git a/GeoModelCore/CMakeLists.txt b/GeoModelCore/CMakeLists.txt index d96b29665216e71d5de39bea36917bef6ae8eef0..814e20f8db35c7897030b6e37787ea61f0f1251c 100644 --- a/GeoModelCore/CMakeLists.txt +++ b/GeoModelCore/CMakeLists.txt @@ -8,6 +8,7 @@ project( "GeoModelCore" VERSION ${GeoModel_VERSION} LANGUAGES CXX ) # Set up the build of the two libraries of the (sub-)project. add_subdirectory( GeoGenericFunctions ) add_subdirectory( GeoModelKernel ) +add_subdirectory( GeoModelFuncSnippets ) # Create and install the version description of the project. include( WriteBasicConfigVersionFile ) diff --git a/GeoModelCore/GeoModelFuncSnippets/.DS_Store b/GeoModelCore/GeoModelFuncSnippets/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ae5c8ecde22999e8b2b13eb4d697826d2742b328 Binary files /dev/null and b/GeoModelCore/GeoModelFuncSnippets/.DS_Store differ diff --git a/GeoModelTools/GeoModelFuncSnippets/CMakeLists.txt b/GeoModelCore/GeoModelFuncSnippets/CMakeLists.txt similarity index 91% rename from GeoModelTools/GeoModelFuncSnippets/CMakeLists.txt rename to GeoModelCore/GeoModelFuncSnippets/CMakeLists.txt index f7665ef21894f8ac9e1daaf45f719c33513bea78..e30ae17d92585799d0130a3af30c8dc09410c8ca 100644 --- a/GeoModelTools/GeoModelFuncSnippets/CMakeLists.txt +++ b/GeoModelCore/GeoModelFuncSnippets/CMakeLists.txt @@ -21,7 +21,7 @@ set_target_properties( GeoModelFuncSnippets PROPERTIES # Set up an alias with the same name that you would get by "finding" a pre-built # version of the library. -add_library( GeoModelTools::GeoModelFuncSnippets ALIAS GeoModelFuncSnippets ) +add_library( GeoModelCore::GeoModelFuncSnippets ALIAS GeoModelFuncSnippets ) # Install the library. install(TARGETS GeoModelFuncSnippets @@ -52,7 +52,7 @@ foreach(_exeFile ${files}) endif() add_executable(${_theExec} ${_exeFile}) - target_link_libraries( ${_theExec} GeoModelTools::GeoModelFuncSnippets GeoModelCore::GeoModelKernel) + target_link_libraries( ${_theExec} GeoModelCore::GeoModelFuncSnippets GeoModelCore::GeoModelKernel) add_test(NAME ${_theExec} COMMAND ${_theExec}) diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/FileUtils.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/FileUtils.h similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/FileUtils.h rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/FileUtils.h diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoLogVolSorter.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoLogVolSorter.h similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoLogVolSorter.h rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoLogVolSorter.h diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoPhysVolSorter.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoPhysVolSorter.h similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoPhysVolSorter.h rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoPhysVolSorter.h diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeSorter.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeSorter.h similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeSorter.h rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeSorter.h diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeUtils.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeUtils.h similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeUtils.h rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/GeoShapeUtils.h diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.h similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.h rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.h diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.icc b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.icc similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.icc rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/StringUtils.icc diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformSorter.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformSorter.h similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformSorter.h rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformSorter.h diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformToStringConverter.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformToStringConverter.h similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformToStringConverter.h rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/TransformToStringConverter.h diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/defineWorld.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/defineWorld.h similarity index 86% rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/defineWorld.h rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/defineWorld.h index 2e32a64597b1a0f9d6a52430ce27bfeaded4fc32..fbfe4779d63c9672a6e73795a2e146ec3e0f9118 100644 --- a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/defineWorld.h +++ b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/defineWorld.h @@ -20,4 +20,6 @@ GeoIntrusivePtr<GeoPhysVol> createGeoWorld(const double worldBoxX = GeoWorldDim: const double worldBoxY = GeoWorldDim::worldBoxY, const double worldBoxZ = GeoWorldDim::worldBoxZ); -#endif \ No newline at end of file +/// Resize the world volume to be the needed size +GeoIntrusivePtr<GeoPhysVol> resizeGeoWorld(GeoIntrusivePtr<GeoPhysVol> world); +#endif diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/getChildNodesWithTrf.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/getChildNodesWithTrf.h similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/getChildNodesWithTrf.h rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/getChildNodesWithTrf.h diff --git a/GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/throwExcept.h b/GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/throwExcept.h similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/GeoModelFuncSnippets/throwExcept.h rename to GeoModelCore/GeoModelFuncSnippets/GeoModelFuncSnippets/throwExcept.h diff --git a/GeoModelTools/GeoModelFuncSnippets/src/FileUtils.cxx b/GeoModelCore/GeoModelFuncSnippets/src/FileUtils.cxx similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/src/FileUtils.cxx rename to GeoModelCore/GeoModelFuncSnippets/src/FileUtils.cxx diff --git a/GeoModelTools/GeoModelFuncSnippets/src/GeoLogVolSorter.cxx b/GeoModelCore/GeoModelFuncSnippets/src/GeoLogVolSorter.cxx similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/src/GeoLogVolSorter.cxx rename to GeoModelCore/GeoModelFuncSnippets/src/GeoLogVolSorter.cxx diff --git a/GeoModelTools/GeoModelFuncSnippets/src/GeoPhysVolSorter.cxx b/GeoModelCore/GeoModelFuncSnippets/src/GeoPhysVolSorter.cxx similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/src/GeoPhysVolSorter.cxx rename to GeoModelCore/GeoModelFuncSnippets/src/GeoPhysVolSorter.cxx diff --git a/GeoModelTools/GeoModelFuncSnippets/src/GeoShapeSorter.cxx b/GeoModelCore/GeoModelFuncSnippets/src/GeoShapeSorter.cxx similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/src/GeoShapeSorter.cxx rename to GeoModelCore/GeoModelFuncSnippets/src/GeoShapeSorter.cxx diff --git a/GeoModelTools/GeoModelFuncSnippets/src/GeoShapeUtils.cxx b/GeoModelCore/GeoModelFuncSnippets/src/GeoShapeUtils.cxx similarity index 99% rename from GeoModelTools/GeoModelFuncSnippets/src/GeoShapeUtils.cxx rename to GeoModelCore/GeoModelFuncSnippets/src/GeoShapeUtils.cxx index 741af766605915e3029e79d24c5c5a1a40b7f85a..4ba5bffcb0eb43375ab05daebe600bdfa756beec 100644 --- a/GeoModelTools/GeoModelFuncSnippets/src/GeoShapeUtils.cxx +++ b/GeoModelCore/GeoModelFuncSnippets/src/GeoShapeUtils.cxx @@ -4,12 +4,12 @@ #include "GeoModelFuncSnippets/GeoShapeUtils.h" #include "GeoModelFuncSnippets/TransformToStringConverter.h" - /// Boolean volume shapes #include "GeoModelKernel/GeoShapeUnion.h" #include "GeoModelKernel/GeoShapeSubtraction.h" #include "GeoModelKernel/GeoShapeIntersection.h" #include "GeoModelKernel/GeoShapeShift.h" +#include "GeoModelKernel/GeoShape.h" /// Ordinary shapes #include "GeoModelKernel/GeoBox.h" #include "GeoModelKernel/GeoTrd.h" @@ -22,6 +22,8 @@ #include "GeoModelKernel/Units.h" +#include <vector> + std::pair<const GeoShape* , const GeoShape*> getOps(const GeoShape* composed) { if (composed->typeID() == GeoShapeUnion::getClassTypeID()) { const GeoShapeUnion* unionShape = dynamic_cast<const GeoShapeUnion*>(composed); @@ -136,4 +138,4 @@ std::string printGeoShape(const GeoShape* shape) { ostr<<"dPhi="<<torus->getDPhi()*toDeg; } return ostr.str(); -} \ No newline at end of file +} diff --git a/GeoModelTools/GeoModelFuncSnippets/src/StringUtils.cxx b/GeoModelCore/GeoModelFuncSnippets/src/StringUtils.cxx similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/src/StringUtils.cxx rename to GeoModelCore/GeoModelFuncSnippets/src/StringUtils.cxx diff --git a/GeoModelTools/GeoModelFuncSnippets/src/TransformSorter.cxx b/GeoModelCore/GeoModelFuncSnippets/src/TransformSorter.cxx similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/src/TransformSorter.cxx rename to GeoModelCore/GeoModelFuncSnippets/src/TransformSorter.cxx diff --git a/GeoModelTools/GeoModelFuncSnippets/src/TransformToStringConverter.cxx b/GeoModelCore/GeoModelFuncSnippets/src/TransformToStringConverter.cxx similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/src/TransformToStringConverter.cxx rename to GeoModelCore/GeoModelFuncSnippets/src/TransformToStringConverter.cxx diff --git a/GeoModelCore/GeoModelFuncSnippets/src/defineWorld.cxx b/GeoModelCore/GeoModelFuncSnippets/src/defineWorld.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e5185656f6f8364b770f7a39d7088a42675d00e8 --- /dev/null +++ b/GeoModelCore/GeoModelFuncSnippets/src/defineWorld.cxx @@ -0,0 +1,138 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ +#include "GeoModelFuncSnippets/defineWorld.h" +#include "GeoModelKernel/GeoElement.h" +#include "GeoModelKernel/GeoMaterial.h" +#include "GeoModelKernel/GeoBox.h" +#include "GeoModelKernel/GeoPhysVol.h" +#include "GeoModelKernel/GeoFullPhysVol.h" +#include "GeoModelKernel/GeoVolumeCursor.h" +#include "GeoModelKernel/GeoAlignableTransform.h" +#include "GeoModelKernel/Units.h" + +GeoIntrusivePtr<GeoPhysVol> createGeoWorld(const double worldBoxX, + const double worldBoxY, + const double worldBoxZ) { + + + constexpr double gr = GeoModelKernelUnits::gram; + constexpr double mole = GeoModelKernelUnits::mole; + constexpr double cm3 = GeoModelKernelUnits::cm3; + + // Define the chemical elements + GeoIntrusivePtr<GeoElement> Nitrogen{new GeoElement ("Nitrogen" ,"N" , 7.0 , 14.0031 *gr/mole)}; + GeoIntrusivePtr<GeoElement> Oxygen{new GeoElement ("Oxygen" ,"O" , 8.0 , 15.9949 *gr/mole)}; + GeoIntrusivePtr<GeoElement> Argon{new GeoElement ("Argon" ,"Ar" , 18.0 , 39.9624 *gr/mole)}; + GeoIntrusivePtr<GeoElement> Hydrogen{new GeoElement ("Hydrogen" ,"H" , 1.0 , 1.00782503081372 *gr/mole)}; + + constexpr double densityOfAir=0.001290 *gr/cm3; + GeoIntrusivePtr<GeoMaterial> air{new GeoMaterial("GeoModelAir", densityOfAir)}; + air->add(Nitrogen , 0.7494); + air->add(Oxygen, 0.2369); + air->add(Argon, 0.0129); + air->add(Hydrogen, 0.0008); + air->lock(); + + + GeoIntrusivePtr<GeoBox> worldBox{new GeoBox(worldBoxX, worldBoxY, worldBoxZ)}; + GeoIntrusivePtr<GeoLogVol> worldLog{new GeoLogVol("WorldLog", worldBox, air)}; + GeoIntrusivePtr<GeoPhysVol> world{new GeoPhysVol(worldLog)}; + + return world; +} + +GeoIntrusivePtr<GeoPhysVol> resizeGeoWorld(GeoIntrusivePtr<GeoPhysVol> world) +{ + if (world) + { + //resize the world volume to the real needed volume + + // get number of children volumes + unsigned int nChild=world->getNChildVols(); + + //Dimensions of the bounding boxes + double xmin=0.,ymin=0.,zmin=0.,xmax=0.,ymax=0.,zmax=0.; + double xworld=0.,yworld=0.,zworld=0.; + + // loop over all children volumes + for (unsigned int i=0; i<nChild; i++) + { + PVConstLink nodeLink = world->getChildVol(i); + if ( dynamic_cast<const GeoVPhysVol*>( &(*( nodeLink ))) ) + { + const GeoVPhysVol *childVolV = &(*( nodeLink )); + + if ( dynamic_cast<const GeoPhysVol*>(childVolV) ) { + const GeoPhysVol* childVol = dynamic_cast<const GeoPhysVol*>(childVolV); + childVol->getLogVol()->getShape()->extent(xmin, ymin, zmin, xmax, ymax, zmax); + } + else if ( dynamic_cast<const GeoFullPhysVol*>(childVolV) ) { + const GeoFullPhysVol* childVol = dynamic_cast<const GeoFullPhysVol*>(childVolV); + childVol->getLogVol()->getShape()->extent(xmin, ymin, zmin, xmax, ymax, zmax); + + } + xworld=std::max({xworld,std::abs(xmin),std::abs(xmax)}); + yworld=std::max({yworld,std::abs(ymin),std::abs(ymax)}); + zworld=std::max({zworld,std::abs(zmin),std::abs(zmax)}); + } + } + + GeoIntrusivePtr<GeoPhysVol> resizedWorld{createGeoWorld(xworld, yworld, zworld)}; + + for (unsigned int i=0; i< world->getNChildNodes(); i++){ + const GeoGraphNode * node = *(world->getChildNode(i)); + + + if (dynamic_cast<const GeoVPhysVol*>( node )) + { + if ( dynamic_cast<const GeoFullPhysVol*>(node) ){ + const GeoFullPhysVol* nodeFullPhysVol = dynamic_cast<const GeoFullPhysVol*>(node); + resizedWorld->add((GeoGraphNode *)nodeFullPhysVol); + + } + else if ( dynamic_cast<const GeoPhysVol*>(node) ){ + const GeoPhysVol* nodePhysVol = dynamic_cast<const GeoPhysVol*>(node); + resizedWorld->add((GeoGraphNode *)nodePhysVol); + + } + } + else if (dynamic_cast<const GeoNameTag*>( node )){ + const GeoNameTag* nodeTag = dynamic_cast<const GeoNameTag*>(node); + resizedWorld->add((GeoGraphNode *)nodeTag); + + } + + else if (dynamic_cast<const GeoAlignableTransform*>( node )){ + const GeoAlignableTransform* nodeAT = dynamic_cast<const GeoAlignableTransform*>(node); + resizedWorld->add((GeoGraphNode *)nodeAT); + + } + + else if (dynamic_cast<const GeoSerialTransformer*>( node )){ + const GeoSerialTransformer* nodeST = dynamic_cast<const GeoSerialTransformer*>(node); + resizedWorld->add((GeoGraphNode *)nodeST); + + } + + else if (dynamic_cast<const GeoSerialDenominator*>( node )){ + const GeoSerialDenominator* nodeSD = dynamic_cast<const GeoSerialDenominator*>(node); + resizedWorld->add((GeoGraphNode *)nodeSD); + + } + else if (dynamic_cast<const GeoTransform*>( node )){ + const GeoTransform* nodeTransform = dynamic_cast<const GeoTransform*>(node); + resizedWorld->add((GeoGraphNode *)nodeTransform); + + }else if (dynamic_cast<const GeoIdentifierTag*>( node )){ + const GeoIdentifierTag* nodeIT = dynamic_cast<const GeoIdentifierTag*>(node); + resizedWorld->add((GeoGraphNode *)nodeIT); + + } + } + + return resizedWorld; + + } + return world; +} diff --git a/GeoModelTools/GeoModelFuncSnippets/src/getChildNodesWithTrf.cxx b/GeoModelCore/GeoModelFuncSnippets/src/getChildNodesWithTrf.cxx similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/src/getChildNodesWithTrf.cxx rename to GeoModelCore/GeoModelFuncSnippets/src/getChildNodesWithTrf.cxx diff --git a/GeoModelTools/GeoModelFuncSnippets/tests/testGeoShapeSet.cxx b/GeoModelCore/GeoModelFuncSnippets/tests/testGeoShapeSet.cxx similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/tests/testGeoShapeSet.cxx rename to GeoModelCore/GeoModelFuncSnippets/tests/testGeoShapeSet.cxx diff --git a/GeoModelTools/GeoModelFuncSnippets/tests/testStringUtils.cxx b/GeoModelCore/GeoModelFuncSnippets/tests/testStringUtils.cxx similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/tests/testStringUtils.cxx rename to GeoModelCore/GeoModelFuncSnippets/tests/testStringUtils.cxx diff --git a/GeoModelTools/GeoModelFuncSnippets/tests/testTransformSorter.cxx b/GeoModelCore/GeoModelFuncSnippets/tests/testTransformSorter.cxx similarity index 100% rename from GeoModelTools/GeoModelFuncSnippets/tests/testTransformSorter.cxx rename to GeoModelCore/GeoModelFuncSnippets/tests/testTransformSorter.cxx diff --git a/GeoModelExamples/HelloGeoRead2G4/HelloGeoReadG4.cpp b/GeoModelExamples/HelloGeoRead2G4/HelloGeoReadG4.cpp index b656e33e35f172eb3faeaec6bde5a9ee655b880e..41a81541636bd4afaad5c060d87830b12f3d9c02 100644 --- a/GeoModelExamples/HelloGeoRead2G4/HelloGeoReadG4.cpp +++ b/GeoModelExamples/HelloGeoRead2G4/HelloGeoReadG4.cpp @@ -97,7 +97,7 @@ int main(int argc, char* argv[]) { std::cout << "ReadGeoModel set.\n"; /* build the GeoModel geometry */ - GeoPhysVol* world = + const GeoVPhysVol* world = readInGeo.buildGeoModel(); // builds the whole GeoModel tree in memory // and get an handle to the 'world' volume std::cout << "ReadGeoModel::buildGeoModel() done.\n"; diff --git a/GeoModelTools/CMakeLists.txt b/GeoModelTools/CMakeLists.txt index 828183c8aba1302b884cd16546da6963e2eecf03..bed80fb75f6f943b19353885f3239e9281857724 100644 --- a/GeoModelTools/CMakeLists.txt +++ b/GeoModelTools/CMakeLists.txt @@ -47,7 +47,6 @@ include( GNUInstallDirs ) # Set up the build of the libraries of the project. add_subdirectory( GeoModelXML ) -add_subdirectory( GeoModelFuncSnippets ) add_subdirectory( GeoModelXMLParser ) add_subdirectory( GeoModelJSONParser ) add_subdirectory( ExpressionEvaluator ) diff --git a/GeoModelTools/GMCAT/CMakeLists.txt b/GeoModelTools/GMCAT/CMakeLists.txt index 62f3df273a4af424f150874b426c6ff3c9609edd..b3a2ab02cd9aca6715254d346afe956fb9ea7f46 100644 --- a/GeoModelTools/GMCAT/CMakeLists.txt +++ b/GeoModelTools/GMCAT/CMakeLists.txt @@ -3,7 +3,7 @@ # Declare the package's executable. add_executable( gmcat src/gmcat.cxx src/publishMetaData.cpp) target_link_libraries( gmcat PRIVATE GeoModelCore::GeoModelKernel - GeoModelTools::GeoModelFuncSnippets + GeoModelCore::GeoModelFuncSnippets GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite GeoModelIO::GeoModelDBManager ) diff --git a/GeoModelTools/GMCAT/src/gmcat.cxx b/GeoModelTools/GMCAT/src/gmcat.cxx index a7d9c68b8cf4874861e4733004e8f0f00ad614e5..467895fa269931040eb4759803a92fd7a9a17ee2 100644 --- a/GeoModelTools/GMCAT/src/gmcat.cxx +++ b/GeoModelTools/GMCAT/src/gmcat.cxx @@ -115,9 +115,10 @@ int main(int argc, char ** argv) { // - // Create elements and materials for the "World" volume, which is the container: + // Create the "GeoWorld" volume, which is the container: // - GeoIntrusivePtr<GeoVPhysVol> world{createGeoWorld()}; + GeoIntrusivePtr<GeoPhysVol> world{createGeoWorld()}; + // // Loop over plugins, create the geometry and put it under the world: @@ -188,9 +189,12 @@ int main(int argc, char ** argv) { std::cerr << "gmcat -- Error opening the output file: " << outputFile << std::endl; return 7; } + + //resize the world volume to the needed one + GeoIntrusivePtr<GeoPhysVol> resizedWorld = resizeGeoWorld(world); GeoModelIO::WriteGeoModel dumpGeoModelGraph(db); - world->exec(&dumpGeoModelGraph); + resizedWorld->exec(&dumpGeoModelGraph); if (vecPluginsPublishers.size() > 0) { dumpGeoModelGraph.saveToDB(vecPluginsPublishers); diff --git a/GeoModelTools/GMSTATISTICS/CMakeLists.txt b/GeoModelTools/GMSTATISTICS/CMakeLists.txt index cad89c45a5fbf6ac4f2c3f8599ecedd565807fb1..854b50f3ad6a6b929003510977d2bdc631ad7cd5 100644 --- a/GeoModelTools/GMSTATISTICS/CMakeLists.txt +++ b/GeoModelTools/GMSTATISTICS/CMakeLists.txt @@ -6,7 +6,7 @@ target_link_libraries( gmstatistics PRIVATE GeoModelCore::GeoModelKernel GeoModelIO::GeoModelRead GeoModelIO::GeoModelWrite GeoModelIO::GeoModelDBManager - GeoModelTools::GeoModelFuncSnippets ) + GeoModelCore::GeoModelFuncSnippets ) # Tweak how debug information should be attached to the executable, in Debug # builds. diff --git a/GeoModelTools/GeoModelFuncSnippets/src/defineWorld.cxx b/GeoModelTools/GeoModelFuncSnippets/src/defineWorld.cxx deleted file mode 100644 index 9c52a18ceb0cf41923d3584fd2762bdea21ca655..0000000000000000000000000000000000000000 --- a/GeoModelTools/GeoModelFuncSnippets/src/defineWorld.cxx +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration -*/ -#include "GeoModelFuncSnippets/defineWorld.h" -#include "GeoModelKernel/GeoElement.h" -#include "GeoModelKernel/GeoMaterial.h" -#include "GeoModelKernel/GeoBox.h" -#include "GeoModelKernel/GeoPhysVol.h" -#include "GeoModelKernel/Units.h" - -GeoIntrusivePtr<GeoPhysVol> createGeoWorld(const double worldBoxX, - const double worldBoxY, - const double worldBoxZ) { - - - constexpr double gr = GeoModelKernelUnits::gram; - constexpr double mole = GeoModelKernelUnits::mole; - constexpr double cm3 = GeoModelKernelUnits::cm3; - - // Define the chemical elements - GeoIntrusivePtr<GeoElement> Nitrogen{new GeoElement ("Nitrogen" ,"N" , 7.0 , 14.0067 *gr/mole)}; - GeoIntrusivePtr<GeoElement> Oxygen{new GeoElement ("Oxygen" ,"O" , 8.0 , 15.9995 *gr/mole)}; - GeoIntrusivePtr<GeoElement> Argon{new GeoElement ("Argon" ,"Ar" , 18.0 , 39.948 *gr/mole)}; - GeoIntrusivePtr<GeoElement> Hydrogen{new GeoElement ("Hydrogen" ,"H" , 1.0 , 1.00797 *gr/mole)}; - - constexpr double densityOfAir=0.001214 *gr/cm3; - GeoIntrusivePtr<GeoMaterial> air{new GeoMaterial("Air", densityOfAir)}; - air->add(Nitrogen , 0.7494); - air->add(Oxygen, 0.2369); - air->add(Argon, 0.0129); - air->add(Hydrogen, 0.0008); - air->lock(); - - - - GeoIntrusivePtr<GeoBox> worldBox{new GeoBox(worldBoxX, worldBoxY, worldBoxZ)}; - GeoIntrusivePtr<GeoLogVol> worldLog{new GeoLogVol("WorldLog", worldBox, air)}; - GeoIntrusivePtr<GeoPhysVol> world{new GeoPhysVol(worldLog)}; - - return world; -} \ No newline at end of file diff --git a/GeoModelTools/GeoModelXML/GeoModelXml/CMakeLists.txt b/GeoModelTools/GeoModelXML/GeoModelXml/CMakeLists.txt index 374cc28c8e865e5d3dfd009495036acb67cbcd34..67c34087f1161b1006d1895b35ec8f5449390562 100644 --- a/GeoModelTools/GeoModelXML/GeoModelXml/CMakeLists.txt +++ b/GeoModelTools/GeoModelXML/GeoModelXml/CMakeLists.txt @@ -13,7 +13,7 @@ find_package( ZLIB REQUIRED ) # Create the library. add_library( GeoModelXml SHARED ${HEADERS} ${SOURCES} ) # link libraries -target_link_libraries( GeoModelXml PUBLIC GeoModelCore::GeoModelKernel GeoModelTools::GeoModelFuncSnippets GeoModelTools::ExpressionEvaluator XercesC::XercesC PRIVATE ZLIB::ZLIB ) +target_link_libraries( GeoModelXml PUBLIC GeoModelCore::GeoModelKernel GeoModelCore::GeoModelFuncSnippets GeoModelTools::ExpressionEvaluator XercesC::XercesC PRIVATE ZLIB::ZLIB ) target_include_directories( GeoModelXml PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include> )