Skip to content
Snippets Groups Projects
Commit 8b3efaf1 authored by Marilena Bandieramonte's avatar Marilena Bandieramonte
Browse files

Merge branch 'updateGeoModelExamples' of...

Merge branch 'updateGeoModelExamples' of https://gitlab.cern.ch/GeoModelDev/GeoModel into updateGeoModelExamples
parents 37b519d7 43c16899
Branches
Tags
1 merge request!199Update GeoModelExamples
......@@ -253,6 +253,26 @@ mac-gm-fullsimlight:
CMAKE_ARGS: ${CMAKE_BASE_ARGS}
CMAKE_CONFIG_FLAGS: -DGEOMODEL_BUILD_FULLSIMLIGHT=TRUE
mac-gm-fsl:
<<: *macos-job
<<: *geomodel-job
stage: step-A
variables:
CMAKE_ARGS: ${CMAKE_BASE_ARGS}
CMAKE_EXTRA_FLAGS: -DGEOMODEL_BUILD_FSL=TRUE
mac-gm-all:
<<: *macos-job
<<: *geomodel-job
stage: step-C
needs: ["mac-coin", "mac-soqt"]
variables:
CMAKE_ARGS: ${CMAKE_BASE_ARGS}
CMAKE_EXTRA_FLAGS: -DGEOMODEL_BUILD_ALL=TRUE
mac-gm-atlasextras:
<<: *macos-job
<<: *geomodel-job
......@@ -347,6 +367,27 @@ ubu-gm-fullsimlight:
CMAKE_ARGS: ${CMAKE_BASE_ARGS}
CMAKE_CONFIG_FLAGS: -DGEOMODEL_BUILD_FULLSIMLIGHT=TRUE
ubu-gm-fsl:
<<: *ubuntu-job
<<: *geomodel-job
stage: step-B
needs: ["ubu-geant4"]
variables:
CMAKE_ARGS: ${CMAKE_BASE_ARGS}
CMAKE_CONFIG_FLAGS: -DGEOMODEL_BUILD_FSL=TRUE
ubu-gm-all:
<<: *ubuntu-job
<<: *geomodel-job
stage: step-C
needs: ["ubu-coin", "ubu-soqt", "ubu-geant4"]
variables:
CMAKE_ARGS: ${CMAKE_BASE_ARGS}
CMAKE_CONFIG_FLAGS: -DGEOMODEL_BUILD_ALL=TRUE
ubu-gm-atlasextras:
<<: *ubuntu-job
<<: *geomodel-job
......
......@@ -52,6 +52,13 @@ option(GEOMODEL_BUILD_FULLSIMLIGHT_PROFILING "Enable FullSimLight profiling targ
option(GEOMODEL_BUILD_FSL "Enable the build of FSL and FullSimLight" OFF)
option(GEOMODEL_BUILD_ATLASEXTENSIONS "Build the Custom ATLAS Extensions" OFF)
if(GEOMODEL_BUILD_FSL AND GEOMODEL_BUILD_FULLSIMLIGHT)
message(STATUS "==> NOTE: You enabled both BUILD_FSL and BUILD_FULLSIMLIGHT. Since BUILD_FSL triggers the build of the FullSimLight package as well, I set BUILD_FULLSIMLIGHT to FALSE to avoid errors of 'double inclusion'")
set(GEOMODEL_BUILD_FULLSIMLIGHT FALSE)
endif()
if(GEOMODEL_BUILD_FULLSIMLIGHT_PROFILING)
set(GEOMODEL_BUILD_FULLSIMLIGHT ON CACHE BOOL "Enable the build of FullSimLight" FORCE)
include(CTest) # needs to be included at the top level
......@@ -68,7 +75,6 @@ list( APPEND BUILT_PACKAGES "GeoModelIO")
if(GEOMODEL_BUILD_ALL)
set(GEOMODEL_BUILD_TOOLS TRUE)
set(GEOMODEL_BUILD_VISUALIZATION TRUE)
set(GEOMODEL_BUILD_FULLSIMLIGHT TRUE)
set(GEOMODEL_BUILD_FSL TRUE)
endif()
......
// Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
// Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
/*
* HelloGeo.cpp
* HelloGeoRead.cpp
*
* Author: Riccardo Maria BIANCHI @ CERN
* Created on: Nov, 2018
* Updated on: Jul, 2023
*
*/
// GeoModel includes
#include "GeoModelDBManager/GMDBManager.h"
#include "GeoModelRead/ReadGeoModel.h"
#include "GeoModelKernel/GeoBox.h"
#include "GeoModelKernel/GeoPhysVol.h"
#include "GeoModelKernel/GeoFullPhysVol.h"
#include "GeoModelKernel/GeoNameTag.h"
#include "GeoModelKernel/GeoPhysVol.h"
#include "GeoModelRead/ReadGeoModel.h"
// C++ includes
#include <iostream>
#include <cstdlib> // EXIT_FAILURE
#include <fstream>
#include <cstdlib> // EXIT_FAILURE
#include <iostream>
// Units
#include "GeoModelKernel/Units.h"
#define SYSTEM_OF_UNITS GeoModelKernelUnits // so we will get, e.g., 'GeoModelKernelUnits::cm'
GeoPhysVol* createTheWorld(GeoPhysVol* world)
{
if (world == nullptr)
{
//-----------------------------------------------------------------------------------//
// Define the materials that we shall use. //
// ----------------------------------------------------------------------------------//
// Define the units
#define gr SYSTEM_OF_UNITS::gram
#define mole SYSTEM_OF_UNITS::mole
#define cm3 SYSTEM_OF_UNITS::cm3
// Define the chemical elements
GeoElement* Nitrogen = new GeoElement ("Nitrogen" ,"N" , 7.0 , 14.0067 *gr/mole);
GeoElement* Oxygen = new GeoElement ("Oxygen" ,"O" , 8.0 , 15.9995 *gr/mole);
GeoElement* Argon = new GeoElement ("Argon" ,"Ar" , 18.0 , 39.948 *gr/mole);
GeoElement* Hydrogen = new GeoElement ("Hydrogen" ,"H" , 1.0 , 1.00797 *gr/mole);
// Define the materials
double densityOfAir=0.001214 *gr/cm3;
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();
const GeoBox* worldBox = new GeoBox(1000*SYSTEM_OF_UNITS::cm, 1000*SYSTEM_OF_UNITS::cm, 1000*SYSTEM_OF_UNITS::cm);
const GeoLogVol* worldLog = new GeoLogVol("WorldLog", worldBox, air);
world = new GeoPhysVol(worldLog);
}
return world;
#define SYSTEM_OF_UNITS \
GeoModelKernelUnits // so we will get, e.g., 'GeoModelKernelUnits::cm'
GeoPhysVol* createTheWorld(GeoPhysVol* world) {
if (world == nullptr) {
//-----------------------------------------------------------------------------------//
// Define the materials that we shall use. //
// ----------------------------------------------------------------------------------//
// Define the units
#define gr SYSTEM_OF_UNITS::gram
#define mole SYSTEM_OF_UNITS::mole
#define cm3 SYSTEM_OF_UNITS::cm3
// Define the chemical elements
GeoElement* Nitrogen =
new GeoElement("Nitrogen", "N", 7.0, 14.0067 * gr / mole);
GeoElement* Oxygen =
new GeoElement("Oxygen", "O", 8.0, 15.9995 * gr / mole);
GeoElement* Argon =
new GeoElement("Argon", "Ar", 18.0, 39.948 * gr / mole);
GeoElement* Hydrogen =
new GeoElement("Hydrogen", "H", 1.0, 1.00797 * gr / mole);
// Define the materials
double densityOfAir = 0.001214 * gr / cm3;
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();
const GeoBox* worldBox =
new GeoBox(1000 * SYSTEM_OF_UNITS::cm, 1000 * SYSTEM_OF_UNITS::cm,
1000 * SYSTEM_OF_UNITS::cm);
const GeoLogVol* worldLog = new GeoLogVol("WorldLog", worldBox, air);
world = new GeoPhysVol(worldLog);
}
return world;
}
int main(int argc, char *argv[])
{
if(argc != 2)
{
fprintf(stderr, "\nERROR!\nUsage: %s geometry.db\n\n", argv[0]);
int main(int argc, char* argv[]) {
if (argc != 2) {
fprintf(stderr, "\nERROR!\nUsage: %s <geometry.db>\n\n", argv[0]);
return 1;
}
// Get the input SQLite '.db' file containing the geometry
std::string line;
std::string fileName;
fileName = argv[1];
std::cout << "Using this SQLite '.db' file:" << fileName << std::endl;
// check if DB file exists. If not, return.
// FIXME: TODO: this check should go in the 'GMDBManager' constructor.
std::ifstream infile(fileName.c_str());
if (!infile.good()) {
std::cout << "\n\tERROR!! A '" << fileName
<< "' file does not exist!! Please, check the path of the "
"input file before running this program. Exiting...";
exit(EXIT_FAILURE);
}
infile.close();
// GET GEOMETRY FROM LOCAL DB
// open the DB
GMDBManager* db = new GMDBManager(fileName);
/* Open database */
if (db->checkIsDBOpen()) {
std::cout << "OK! Database is open!\n";
} else {
std::cout << "Database is not open!\n";
// return;
throw;
}
// -- testing the input database
// std::cout << "Printing the list of all GeoMaterial nodes" << std::endl;
// db->printAllMaterials();
// std::cout << "Printing the list of all GeoElement nodes" << std::endl;
// db->printAllElements();
/* setup the GeoModel reader */
GeoModelIO::ReadGeoModel geoReader = GeoModelIO::ReadGeoModel(db);
std::cout << "OK! ReadGeoModel is set." << std::endl;
/* build the GeoModel geometry */
GeoPhysVol* dbPhys =
geoReader.buildGeoModel(); // builds the whole GeoModel tree in memory
std::cout << "ReadGeoModel::buildGeoModel() done." << std::endl;
std::cout << "Reading records from the imported geometry DB file..."
<< std::endl;
geoReader.printDBTable("SerialIdentifiers");
geoReader.printDBTable("IdentifierTags");
// create the world volume container and
// get the 'world' volume, i.e. the root volume of the GeoModel tree
std::cout << "Getting the 'world' GeoPhysVol, i.e. the root volume of the "
"GeoModel tree"
<< std::endl;
GeoPhysVol* world = createTheWorld(dbPhys);
std::cout << "Getting the GeoLogVol used by the 'world' volume"
<< std::endl;
const GeoLogVol* logVol = world->getLogVol();
std::cout << "'world' GeoLogVol name: " << logVol->getName() << std::endl;
std::cout << "'world' GeoMaterial name: "
<< logVol->getMaterial()->getName() << std::endl;
// --- testing the imported Geometry
// get number of children volumes
unsigned int nChil = world->getNChildVols();
std::cout << "'world' number of children: " << nChil << std::endl;
// loop over all children nodes
std::cout << "Looping over all 'volume' children (i.e., GeoPhysVol and "
"GeoFullPhysVol)..."
<< std::endl;
for (unsigned int idx = 0; idx < nChil; ++idx) {
PVConstLink nodeLink = world->getChildVol(idx);
if (dynamic_cast<const GeoVPhysVol*>(&(*(nodeLink)))) {
std::cout << "\t"
<< "the child n. " << idx << " ";
const GeoVPhysVol* childVolV = &(*(nodeLink));
if (dynamic_cast<const GeoPhysVol*>(childVolV)) {
const GeoPhysVol* childVol =
dynamic_cast<const GeoPhysVol*>(childVolV);
std::cout << "is a GeoPhysVol, whose GeoLogVol name is: "
<< childVol->getLogVol()->getName();
std::cout << " and it has " << childVol->getNChildVols()
<< " child volumes" << std::endl;
} else if (dynamic_cast<const GeoFullPhysVol*>(childVolV)) {
const GeoFullPhysVol* childVol =
dynamic_cast<const GeoFullPhysVol*>(childVolV);
std::cout << "is a GeoFullPhysVol, whose GeoLogVol name is: "
<< childVol->getLogVol()->getName();
std::cout << " and it has " << childVol->getNChildVols()
<< " child volumes" << std::endl;
}
} else if (dynamic_cast<const GeoNameTag*>(&(*(nodeLink)))) {
std::cout << "\t"
<< "the child n. " << idx << " is a GeoNameTag"
<< std::endl;
const GeoNameTag* childVol =
dynamic_cast<const GeoNameTag*>(&(*(nodeLink)));
std::cout << "\t\t GeoNameTag's name: " << childVol->getName()
<< std::endl;
} else if (dynamic_cast<const GeoMaterial*>(&(*(nodeLink)))) {
std::cout << "\t"
<< "the child n. " << idx << " is a GeoMaterial"
<< std::endl;
const GeoMaterial* childVol =
dynamic_cast<const GeoMaterial*>(&(*(nodeLink)));
std::cout << "\t\t GeoMaterial's name: " << childVol->getName()
<< std::endl;
std::cout << "\t\t GeoMaterial's number of elements: "
<< childVol->getNumElements() << std::endl;
}
}
std::cout << "Everything done." << std::endl;
// check if DB file exists. If not, return.
// FIXME: TODO: this check should go in the 'GMDBManager' constructor.
std::ifstream infile(fileName.c_str());
if ( ! infile.good() ) {
std::cout << "\n\tERROR!! A '" << fileName << "' file does not exist!! Please, check the path of the input file before running this program. Exiting...";
exit(EXIT_FAILURE);
}
infile.close();
// GET GEOMETRY FROM LOCAL DB
// open the DB
GMDBManager* db = new GMDBManager(fileName);
/* Open database */
if (db->checkIsDBOpen()) {
std::cout << "OK! Database is open!\n";
}
else {
std::cout << "Database is not open!\n";
// return;
throw;
}
// -- testing the input database
// std::cout << "Printing the list of all GeoMaterial nodes" << std::endl;
// db->printAllMaterials();
// std::cout << "Printing the list of all GeoElement nodes" << std::endl;
// db->printAllElements();
/* setup the GeoModel reader */
GeoModelIO::ReadGeoModel geoReader = GeoModelIO::ReadGeoModel(db);
std::cout << "OK! ReadGeoModel is set." << std::endl;
/* build the GeoModel geometry */
GeoPhysVol* dbPhys = geoReader.buildGeoModel(); // builds the whole GeoModel tree in memory
std::cout << "ReadGeoModel::buildGeoModel() done." << std::endl;
std::cout << "Reading records from the imported geometry DB file..." << std::endl;
geoReader.printDBTable("SerialIdentifiers");
geoReader.printDBTable("IdentifierTags");
// create the world volume container and
// get the 'world' volume, i.e. the root volume of the GeoModel tree
std::cout << "Getting the 'world' GeoPhysVol, i.e. the root volume of the GeoModel tree" << std::endl;
GeoPhysVol* world = createTheWorld(dbPhys);
std::cout << "Getting the GeoLogVol used by the 'world' volume" << std::endl;
const GeoLogVol* logVol = world->getLogVol();
std::cout << "'world' GeoLogVol name: " << logVol->getName() << std::endl;
std::cout << "'world' GeoMaterial name: " << logVol->getMaterial()->getName() << std::endl;
// --- testing the imported Geometry
// get number of children volumes
unsigned int nChil = world->getNChildVols();
std:: cout << "'world' number of children: " << nChil << std::endl;
// loop over all children nodes
std::cout << "Looping over all 'volume' children (i.e., GeoPhysVol and GeoFullPhysVol)..." << std::endl;
for (unsigned int idx=0; idx<nChil; ++idx) {
PVConstLink nodeLink = world->getChildVol(idx);
if ( dynamic_cast<const GeoVPhysVol*>( &(*( nodeLink ))) ) {
std::cout << "\t" << "the child n. " << idx << " ";
const GeoVPhysVol *childVolV = &(*( nodeLink ));
if ( dynamic_cast<const GeoPhysVol*>(childVolV) ) {
const GeoPhysVol* childVol = dynamic_cast<const GeoPhysVol*>(childVolV);
std::cout << "is a GeoPhysVol, whose GeoLogVol name is: " << childVol->getLogVol()->getName();
std::cout<< " and it has "<<childVol->getNChildVols()<<" child volumes" << std::endl;
}
else if ( dynamic_cast<const GeoFullPhysVol*>(childVolV) ) {
const GeoFullPhysVol* childVol = dynamic_cast<const GeoFullPhysVol*>(childVolV);
std::cout << "is a GeoFullPhysVol, whose GeoLogVol name is: " << childVol->getLogVol()->getName();
std::cout<< " and it has "<<childVol->getNChildVols()<<" child volumes" << std::endl;
}
}
else if ( dynamic_cast<const GeoNameTag*>( &(*( nodeLink ))) ) {
std::cout << "\t" << "the child n. " << idx << " is a GeoNameTag" << std::endl;
const GeoNameTag *childVol = dynamic_cast<const GeoNameTag*>(&(*( nodeLink )));
std::cout << "\t\t GeoNameTag's name: " << childVol->getName() << std::endl;
}
else if ( dynamic_cast<const GeoMaterial*>( &(*( nodeLink ))) ) {
std::cout << "\t" << "the child n. " << idx << " is a GeoMaterial" << std::endl;
const GeoMaterial *childVol = dynamic_cast<const GeoMaterial*>(&(*( nodeLink )));
std::cout << "\t\t GeoMaterial's name: " << childVol->getName() << std::endl;
std::cout << "\t\t GeoMaterial's number of elements: " << childVol->getNumElements() << std::endl;
}
}
std::cout << "Everything done." << std::endl;
// return app.exec();
return 0;
// return app.exec();
return 0;
}
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
################################################################################
# Package: HelloGeoRead2G4
# author: Riccardo Maria BIANCHI @ CERN - Nov, 2018
# update: Riccardo Maria BIANCHI @ CERN - Jul, 2023
################################################################################
cmake_minimum_required(VERSION 3.16...3.26)
#project(HelloGeoRead2G4)
project(HelloGeoRead2G4)
# Find includes in current dir
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Find the needed dependencies, when building individually
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
message(STATUS "Compiling the example '${PROJECT_NAME}' as a standalone project...")
find_package( GeoModelCore REQUIRED )
find_package( GeoModelIO REQUIRED )
find_package( GeoModelG4 REQUIRED )
find_package( Eigen3 REQUIRED )
endif()
## External dependencies.
......@@ -24,10 +28,10 @@ find_package( Geant4 REQUIRED )
include(${Geant4_USE_FILE})
# Populate a CMake variable with the sources
set( SRCS main.cpp )
set( SRCS HelloGeoReadG4.cpp )
# Tell CMake to create the helloworld executable
add_executable( hellogeoRead2G4 ${SRCS} )
# Link all needed libraries
target_link_libraries( hellogeoRead2G4 GeoModelDBManager GeoModelRead GeoModelKernel GeoModel2G4 ${Geant4_LIBRARIES})
target_link_libraries( hellogeoRead2G4 GeoModelIO::GeoModelDBManager GeoModelIO::GeoModelRead GeoModelCore::GeoModelKernel GeoModel2G4 Eigen3::Eigen ${Geant4_LIBRARIES})
// Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
/*
* HelloGeoReadG4.cpp
*
* Author: Riccardo Maria BIANCHI @ CERN
* Created on: Nov, 2018
*
*/
// GeoModel includes
#include "GeoModel2G4/ExtParameterisedVolumeBuilder.h"
#include "GeoModelDBManager/GMDBManager.h"
#include "GeoModelKernel/GeoBox.h"
#include "GeoModelKernel/GeoFullPhysVol.h"
#include "GeoModelKernel/GeoNameTag.h"
#include "GeoModelKernel/GeoPhysVol.h"
#include "GeoModelRead/ReadGeoModel.h"
// Geant4 includes
#include "G4LogicalVolume.hh"
// C++ includes
#include <cstdlib> // EXIT_FAILURE
#include <fstream>
#include <iostream>
// Units
#include "GeoModelKernel/Units.h"
#define SYSTEM_OF_UNITS \
GeoModelKernelUnits // so we will get, e.g., 'GeoModelKernelUnits::cm'
/*
// TODO: int main(int argc, char *argv[])
int main() {
// Set a valid local geometry db path before first run
static const std::string path = "../geometry.db";
std::cout << "Using this DB file:" << path << std::endl;
// check if DB file exists. If not, return.
// FIXME: TODO: this check should go in the 'GMDBManager' constructor.
std::ifstream infile(path.c_str());
if (infile.good()) {
std::cout << "\n\tERROR!! A '" << path
<< "' file exists already!! Please, remove, move, or rename "
"it before running this program. Exiting...";
exit(EXIT_FAILURE);
}
infile.close();
*/
int main(int argc, char* argv[]) {
if (argc != 2) {
fprintf(stderr, "\nERROR!\nusage: %s <input_database.db>\n\n", argv[0]);
return 1;
}
// Get the input SQLite '.db' file containing the geometry
std::string line;
std::string fileName;
fileName = argv[1];
std::cout << "Using this SQLite '.db' file:" << fileName << std::endl;
// check if DB file exists. If not, return.
// FIXME: TODO: this check should go in the 'GMDBManager' constructor.
std::ifstream infile(fileName.c_str());
if (!infile.good()) {
std::cout << "\n\tERROR!! A '" << fileName
<< "' file does not exist!! Please, check the path of the "
"input file before running this program. Exiting...";
exit(EXIT_FAILURE);
}
infile.close();
// open the DB
GMDBManager* db = new GMDBManager(fileName);
/* Open database */
if (db->checkIsDBOpen()) {
std::cout << "OK! Database is open!\n";
} else {
std::cout << "Database is not open!\n";
exit(EXIT_FAILURE);
}
// -- testing the input database
std::cout << "\n=== Printing the list of all tables in the input DB:"
<< std::endl;
db->printAllDBTables();
std::cout << "\n=== Printing the list of all GeoMaterial nodes:"
<< std::endl;
db->printAllMaterials();
std::cout << "\n=== Printing the list of all GeoLogVol nodes:" << std::endl;
db->printAllLogVols();
/* setup the GeoModel reader */
GeoModelIO::ReadGeoModel readInGeo = GeoModelIO::ReadGeoModel(db);
std::cout << "ReadGeoModel set.\n";
/* build the GeoModel geometry */
GeoPhysVol* world =
readInGeo.buildGeoModel(); // builds the whole GeoModel tree in memory
// and get an handle to the 'world' volume
std::cout << "ReadGeoModel::buildGeoModel() done.\n";
// --- testing the imported ATLAS Geometry
// get the GeoLogVol used for the 'world' volume
std::cout << "Getting the GeoLogVol used by the 'world' volume"
<< std::endl;
const GeoLogVol* logVol = world->getLogVol();
std::cout << "'world' GeoLogVol name: " << logVol->getName() << std::endl;
std::cout << "'world' GeoMaterial name: "
<< logVol->getMaterial()->getName() << std::endl;
// get number of children volumes
unsigned int nChil = world->getNChildVols();
std::cout << "'world' number of children: " << nChil << std::endl;
// loop over all children nodes
std::cout << "Looping over all 'volume' children (i.e., GeoPhysVol and "
"GeoFullPhysVol)..."
<< std::endl;
for (unsigned int idx = 0; idx < nChil; ++idx) {
PVConstLink nodeLink = world->getChildVol(idx);
if (dynamic_cast<const GeoVPhysVol*>(&(*(nodeLink)))) {
std::cout << "\t"
<< "the child n. " << idx << " ";
const GeoVPhysVol* childVolV = &(*(nodeLink));
if (dynamic_cast<const GeoPhysVol*>(childVolV))
{
const GeoPhysVol* childVol =
dynamic_cast<const GeoPhysVol*>(childVolV);
std::cout << "is a GeoPhysVol, whose GeoLogVol name is: "
<< childVol->getLogVol()->getName() << std::endl;
std::cout << " and it has " << childVol->getNChildVols()
<< " child volumes\n";
} else if (dynamic_cast<const GeoFullPhysVol*>(childVolV)) {
const GeoFullPhysVol* childVol =
dynamic_cast<const GeoFullPhysVol*>(childVolV);
std::cout << "is a GeoFullPhysVol, whose GeoLogVol name is: "
<< childVol->getLogVol()->getName() << std::endl;
std::cout << " and it has " << childVol->getNChildVols()
<< " child volumes\n";
}
} else if (dynamic_cast<const GeoNameTag*>(&(*(nodeLink)))) {
std::cout << "\t"
<< "the child n. " << idx << " is a GeoNameTag\n";
const GeoNameTag* childVol =
dynamic_cast<const GeoNameTag*>(&(*(nodeLink)));
std::cout << "\t\tGeoNameTag's name: " << childVol->getName()
<< std::endl;
// std::cout<< " and it has "<<childVol->getNChildVols()<<" child
// volumes\n";
}
}
// build the Geant4 geometry and get an hanlde to the world' volume
ExtParameterisedVolumeBuilder* builder =
new ExtParameterisedVolumeBuilder("ATLAS");
std::cout << "Building G4 geometry." << std::endl;
G4LogicalVolume* g4World = builder->Build(world);
std::cout << "This is the newly-created Geant4 G4LogicalVolume, ready to "
"be used: "
<< g4World << std::endl;
std::cout << "Everything done.\n";
return 0;
}
// Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
/*
* HelloGeoReadG4.cpp
*
* Author: Riccardo Maria BIANCHI @ CERN
* Created on: Nov, 2018
* Updated on: Jul, 2023 by Marilena Bandieramonte
*
*/
// GeoModel includes
#include "GeoModel2G4/ExtParameterisedVolumeBuilder.h"
#include "GeoModelDBManager/GMDBManager.h"
#include "GeoModelRead/ReadGeoModel.h"
#include "GeoModelKernel/GeoBox.h"
#include "GeoModelKernel/GeoPhysVol.h"
#include "GeoModelKernel/GeoFullPhysVol.h"
#include "GeoModelKernel/GeoNameTag.h"
// Geant4 includes
#include "G4LogicalVolume.hh"
// C++ includes
#include <iostream>
#include <fstream>
#include <cstdlib> // EXIT_FAILURE
// Units
#include "GeoModelKernel/Units.h"
#define SYSTEM_OF_UNITS GeoModelKernelUnits // so we will get, e.g., 'GeoModelKernelUnits::cm'
int main(int argc, char *argv[])
{
if(argc != 2)
{
fprintf(stderr, "\nERROR!\nUsage: %s geometry.db\n\n", argv[0]);
return 1;
}
// Get the input SQLite '.db' file containing the geometry
std::string line;
std::string fileName;
fileName = argv[1];
std::cout << "Using this SQLite '.db' file:" << fileName << std::endl;
// check if DB file exists. If not, return.
// FIXME: TODO: this check should go in the 'GMDBManager' constructor.
std::ifstream infile(fileName.c_str());
if ( ! infile.good() ) {
std::cout << "\n\tERROR!! A '" << fileName << "' file does not exist!! Please, check the path of the input file before running this program. Exiting...";
exit(EXIT_FAILURE);
}
infile.close();
// open the DB
GMDBManager* db = new GMDBManager(fileName);
/* Open database */
if (db->checkIsDBOpen()) {
std::cout << "OK! Database is open!\n";
}
else {
std::cout << "Database is not open!\n";
exit(EXIT_FAILURE);
}
// -- testing the input database
std::cout << "Printing the list of all GeoMaterial nodes" << std::endl;
db->printAllMaterials();
/* setup the GeoModel reader */
GeoModelIO::ReadGeoModel readInGeo = GeoModelIO::ReadGeoModel(db);
std::cout << "ReadGeoModel set.\n";
/* build the GeoModel geometry */
GeoPhysVol* world = readInGeo.buildGeoModel(); // builds the whole GeoModel tree in memory and get an handle to the 'world' volume
std::cout << "ReadGeoModel::buildGeoModel() done.\n";
// --- testing the imported ATLAS Geometry
// get the GeoLogVol used for the 'world' volume
std::cout << "Getting the GeoLogVol used by the 'world' volume" << std::endl;
const GeoLogVol* logVol = world->getLogVol();
std::cout << "'world' GeoLogVol name: " << logVol->getName() << std::endl;
std::cout << "'world' GeoMaterial name: " << logVol->getMaterial()->getName() << std::endl;
// get number of children volumes
unsigned int nChil = world->getNChildVols();
std:: cout << "'world' number of children: " << nChil << std::endl;
// loop over all children nodes
std::cout << "Looping over all 'volume' children (i.e., GeoPhysVol and GeoFullPhysVol)..." << std::endl;
for (unsigned int idx=0; idx<nChil; ++idx) {
PVConstLink nodeLink = world->getChildVol(idx);
if ( dynamic_cast<const GeoVPhysVol*>( &(*( nodeLink ))) ) {
std::cout << "\t" << "the child n. " << idx << " ";
const GeoVPhysVol *childVolV = &(*( nodeLink ));
if ( dynamic_cast<const GeoPhysVol*>(childVolV) )
{
const GeoPhysVol* childVol = dynamic_cast<const GeoPhysVol*>(childVolV);
std::cout << "is a GeoPhysVol, whose GeoLogVol name is: " << childVol->getLogVol()->getName() << std::endl;
std::cout<< " and it has "<<childVol->getNChildVols()<<" child volumes\n";
} else if ( dynamic_cast<const GeoFullPhysVol*>(childVolV) ) {
const GeoFullPhysVol* childVol = dynamic_cast<const GeoFullPhysVol*>(childVolV);
std::cout << "is a GeoFullPhysVol, whose GeoLogVol name is: " << childVol->getLogVol()->getName() << std::endl;
std::cout<< " and it has "<<childVol->getNChildVols()<<" child volumes\n";
}
} else if ( dynamic_cast<const GeoNameTag*>( &(*( nodeLink ))) ) {
std::cout << "\t" << "the child n. " << idx << " is a GeoNameTag\n";
const GeoNameTag *childVol = dynamic_cast<const GeoNameTag*>(&(*( nodeLink )));
std::cout << "\t\tGeoNameTag's name: " << childVol->getName() << std::endl;
//std::cout<< " and it has "<<childVol->getNChildVols()<<" child volumes\n";
}
}
// build the Geant4 geometry and get an hanlde to the world' volume
ExtParameterisedVolumeBuilder* builder = new ExtParameterisedVolumeBuilder("ATLAS");
std::cout << "Building G4 geometry."<<std::endl;
G4LogicalVolume* g4World = builder->Build(world);
std::cout << "This is the newly-created Geant4 G4LogicalVolume, ready to be used: " << g4World << std::endl;
std::cout << "Everything done.\n";
return 0;
}
......@@ -189,8 +189,16 @@ class GMDBManager {
void printAllDBTables();
/// Get tables and tables' columns from the input DB, if any,
/// and populate the cache that stores them
void createTableDataCaches();
/// Get all tables from the input DB, if any,
/// and populate the cache that stores them
void getAllDBTables();
/// Get tables' columns from the input DB, if any,
/// and populate the cache that stores them
void getAllDBTableColumns();
int execQuery(std::string queryStr);
......@@ -247,12 +255,12 @@ class GMDBManager {
/// methods to dump the DB
std::vector<std::vector<std::string>> getChildrenTable();
//Table names for Aux tables are of the form prefix_suffix
//where prefix depends on the type of data in the table
//and suffix depends on the plugin/publisher that provided it
// Table names for Aux tables are of the form prefix_suffix
// where prefix depends on the type of data in the table
// and suffix depends on the plugin/publisher that provided it
//These two require only the suffix, the prefix is already specified based on the
//table type being accessed
// These two require only the suffix, the prefix is already specified based
// on the table type being accessed
std::vector<std::vector<std::string>> getPublishedFPVTable(
std::string suffix = "");
std::vector<std::vector<std::string>> getPublishedAXFTable(
......@@ -264,10 +272,11 @@ class GMDBManager {
std::unordered_map<unsigned int, std::string> getAll_TableIDsNodeTypes();
std::unordered_map<std::string, unsigned int> getAll_NodeTypesTableIDs();
std::vector<std::vector<std::string>> getTableRecords(std::string tableName) const; // TODO: should be private?
std::vector<std::vector<std::string>> getTableRecords(
std::string tableName) const; // TODO: should be private?
//Test if a given table exists
//This requires the *full* table name (i.e. prefix_suffix)
// Test if a given table exists
// This requires the *full* table name (i.e. prefix_suffix)
bool checkTable(std::string tableName) const;
/**
......@@ -347,12 +356,14 @@ class GMDBManager {
// verbosity level
int m_verbose;
std::unordered_map<std::string, std::vector<std::string>>
m_tableNames; /// stores the column names for each table
/// stores the column names for each table
std::unordered_map<std::string, std::vector<std::string>> m_tableNames;
std::unordered_map<std::string, std::string> m_childType_tableName;
std::vector<std::string>
m_cache_tables; /// cache for the list of tables in the DB
/// cache for the list of tables in the DB
std::vector<std::string> m_cache_tables;
std::unordered_map<unsigned int, std::string>
m_cache_tableId_tableName; /// cache for tableID-->tableName
std::unordered_map<unsigned int, std::string>
......
This diff is collapsed.
......@@ -10,6 +10,18 @@ If, after starting `gmex`, you get a window that tells you that was not possible
* try to restart your machine. Seriously! :-) Sometimes, after updates to the graphical packages (those can happen behind the scene, without you to notice them), the system needs to be restarted. I experienced that personally: `gmex` was failing to start, when I was trying a new version of our 3D engine, Coin3D, and I was trying to find for the cause in the code of Coin3D itself... But then my OpenGL-accelerated terminal emulator, Alacritty, had stopped working as well; and that gave me a hint that something global was happening... So, I Googled, and I found a suggestion to resart the machine to get the graphics drivers sync between each others. Try that first, it can help! ;-)
* your OpenGL installation / support is not correct / fully-installed. In that case, you should look for instructions to install proper OpenGL support on your system.
### GMEX crashes on the latest Ubuntu
The GeoModelExplorer (GMEX) application appears to crash when run on the latest version of the Ubuntu "Wayland" window manager.
The problem is that the SoQt/Coin third-party packages we use in GMEX have not been ported to work to the latest Wayland yet. As far as we know, all applications that use the Coin/SoQt graphics layers as their graphics interface crash on the latest Wayland.
The Coin3D community is aware of the problem but there are no fixes, yet.
Therefore, we strongly suggest to use the alternative X11 window manager when running GEMX (or all other SoQt/Coin3D-based applications) on Ubuntu, for the time being.
## Packages
### macOS / Homebrew
......
......@@ -42,6 +42,13 @@ sudo apt install geomodel-visualization-dev
If you have outdated packages, these commands will replace those packages with the most recent version.
!!! warning
The GeoModelExplorer (GMEX) application appears to crash when run on the latest version of the Ubuntu "Wayland" window manager. The problem is that the SoQt/Coin third-party packages we use in GMEX have not been ported to work to the latest Wayland yet. As far as we know, all applications that use the Coin/SoQt graphics layers as their graphics interface crash on the latest Wayland. The Coin3D community is aware of the problem but there are no fixes, yet.
We strongly suggest to use the alternative X11 window manager when running GEMX (or all other SoQt/Coin3D-based applications) on Ubuntu, for the time being.
## macOS
On macOS, we use the [Homebrew package manager](http://brew.sh) to handle and install the GeoModel packages. If you don't have Homebrew installed on your machine, you should first install it by following the instructions on the Homebrew website: <http://brew.sh>. Please be attentive to any instructions printed after the installation procedure; there might be environment variables to set.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment