Skip to content
Snippets Groups Projects
Commit f1e8a84d authored by Riccardo Maria Bianchi's avatar Riccardo Maria Bianchi :sunny:
Browse files

initial multi-packages version

parents
Branches
Tags
No related merge requests found
Showing
with 1364 additions and 0 deletions
cmake_minimum_required( VERSION 3.1 )
# Set up the project.
project( "GeoModelG4" VERSION 1.0.0 LANGUAGES CXX )
# Add sub-packages.
add_subdirectory(GeoMaterial2G4)
add_subdirectory(GeoModel2G4)
install(EXPORT GeoMaterial2G4-export FILE GeoModelG4-GeoMaterial2G4.cmake DESTINATION lib/GeoModelG4)
install(EXPORT GeoModel2G4-export FILE GeoModelG4-GeoModel2G4.cmake DESTINATION lib/GeoModelG4)
install(FILES cmake/GeoModelG4Config.cmake DESTINATION lib/GeoModelG4)
################################################################################
# Package: GeoMaterial2G4
################################################################################
cmake_minimum_required(VERSION 3.10)
# Declare the package name
project( "GeoMaterial2G4" VERSION 1.0.0 LANGUAGES CXX )
# External dependencies:
find_package( Geant4 REQUIRED )
find_package( GeoModelCore REQUIRED )
# Project's Settings
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Use the GNU install directory names.
include( GNUInstallDirs ) # it defines CMAKE_INSTALL_LIBDIR
# Find the header and source files.
file( GLOB SOURCES src/*.cxx )
file( GLOB HEADERS GeoMaterial2G4/*.h )
# include Geant4 headers
include(${Geant4_USE_FILE})
# Set target and properties
add_library( GeoMaterial2G4 SHARED ${HEADERS} ${SOURCES} )
target_link_libraries( GeoMaterial2G4 PUBLIC ${Geant4_LIBRARIES} GeoModelKernel GeoModelUtilities )
target_include_directories( GeoMaterial2G4 SYSTEM PUBLIC ${GeoModelCore_INCLUDE_DIRS} )
target_include_directories( GeoMaterial2G4 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include> )
# Set installation of library headers
set_property( TARGET GeoMaterial2G4 PROPERTY PUBLIC_HEADER ${HEADERS} )
# # Install the library and set export target
# install( TARGETS GeoMaterial2G4
# EXPORT GeoMaterial2G4Config
# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
# PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GeoMaterial2G4
# )
#
# # Install a CMake description of the project/library.
# install( EXPORT GeoMaterial2G4Config DESTINATION cmake )
# new test GeoModelG4
install( TARGETS GeoMaterial2G4 EXPORT GeoMaterial2G4-export LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GeoMaterial2G4 )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEOMATERIAL2G4_Geo2G4MatPropTableFactory_h
#define GEOMATERIAL2G4_Geo2G4MatPropTableFactory_h
#include <map>
class G4MaterialPropertiesTable;
class GeoMaterialPropertiesTable;
typedef std::map<const GeoMaterialPropertiesTable* , G4MaterialPropertiesTable*, std::less<const GeoMaterialPropertiesTable*> > TableMap;
class Geo2G4MatPropTableFactory
{
public:
static Geo2G4MatPropTableFactory* instance();
G4MaterialPropertiesTable* Build(const GeoMaterialPropertiesTable*);
private:
Geo2G4MatPropTableFactory();
static Geo2G4MatPropTableFactory* m_instance;
TableMap m_definedTables;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEOMATERIAL2G4_Geo2G4MaterialFactory_h
#define GEOMATERIAL2G4_Geo2G4MaterialFactory_h
#include "G4Material.hh"
#include "GeoModelKernel/GeoMaterial.h"
#include <map>
#include <string>
typedef std::map<const GeoMaterial* , G4Material*, std::less<const GeoMaterial*> > matList;
typedef std::map<std::string, const GeoMaterial*, std::less<std::string> > matNames;
class Geo2G4MaterialFactory {
public:
Geo2G4MaterialFactory();
G4Material* Build(const GeoMaterial*);
private:
matList m_definedMaterials;
matNames m_definedMatNames;
};
#endif
# GeoMaterial2G4 build
## Dependencies
### Build external dependencies
#### CLEHP
We checkout and build the latest release of CLHEP:
```bash
git clone https://gitlab.cern.ch/CLHEP/CLHEP.git
cd CLHEP
git checkout CLHEP_2_4_1_0
cd ../
mkdir build_clhep
cd build_clhep
cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=RelWithDebInfo ../CLHEP/
make -j 4
make install
```
#### Geant4
We checkout and build the latest release of Geant4:
```bash
git clone https://gitlab.cern.ch/geant4/geant4.git
cd geant4
git checkout v10.5.0
cd ../
mkdir build_geant4
cd build_geant4
cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=RelWithDebInfo ../geant4/
make -j 4
make install
```
### Build GeoModel dependencies
#### GeoModelKernel
**NOTE!** Here, we are currently using a development branch.
```bash
git clone --recurse-submodules ssh://git@gitlab.cern.ch:7999/GeoModelDev/GeoModelKernel.git
cd GeoModelKernel
git checkout master-geomodel-standalone-cmake
cd ../
mkdir build_gmk
cd build_gmk
cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=RelWithDebInfo ../GeoModelKernel
make -j 4
make install
```
## Build GeoMaterial2G4
```bash
git clone ssh://git@gitlab.cern.ch:7999/GeoModelDev/GeoModelG4Utils/GeoMaterial2G4.git
mkdir build_gmat2g4
cd build_gmat2g4
cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=RelWithDebInfo ../GeoMaterial2G4
make -j4
make install
```
**NOTE:** If you experience issues with CMake, try to pass the Geant4 lib installation dir to CMake, to let it correctly find the Geant4Config.cmake file:
```bash
cmake -DGeant4_DIR=../install/lib/Geant4-10.5.0/ -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=RelWithDebInfo ../GeoMaterial2G4/
```
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "Geo2G4ElementFactory.h"
#include "G4Element.hh"
#include "GeoModelKernel/GeoElement.h"
#include <iostream>
#include <map>
Geo2G4ElementFactory::Geo2G4ElementFactory()
{
}
G4Element *Geo2G4ElementFactory::Build(const GeoElement* theEle)
{
//
// Check if this element has already been defined.
//
G4Element* elm;
std::string sym = theEle->getSymbol();
if (m_definedElements.find(sym) != m_definedElements.end())
{
return m_definedElements[sym];
}
elm = new G4Element(theEle->getName(),
sym,
theEle->getZ(),
theEle->getA());
m_definedElements[sym]=elm;
return elm;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEOMATERIAL2G4_ElementFactory_H
#define GEOMATERIAL2G4_ElementFactory_H
class G4Element;
class GeoElement;
#include <map>
#include <string>
typedef std::map<std::string, G4Element*, std::less<std::string> > elList;
class Geo2G4ElementFactory {
public:
Geo2G4ElementFactory();
G4Element* Build(const GeoElement*);
private:
elList m_definedElements;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoMaterial2G4/Geo2G4MatPropTableFactory.h"
#include "G4MaterialPropertiesTable.hh"
#include "G4MaterialPropertyVector.hh"
#include "GeoModelUtilities/GeoMaterialPropertiesTable.h"
#include "GeoModelUtilities/GeoMaterialPropertyVector.h"
Geo2G4MatPropTableFactory* Geo2G4MatPropTableFactory::m_instance = 0;
Geo2G4MatPropTableFactory* Geo2G4MatPropTableFactory::instance()
{
if(!m_instance)
m_instance = new Geo2G4MatPropTableFactory();
return m_instance;
}
Geo2G4MatPropTableFactory::Geo2G4MatPropTableFactory()
{
}
G4MaterialPropertiesTable* Geo2G4MatPropTableFactory::Build(const GeoMaterialPropertiesTable* thePropTable)
{
//
// Check if this material has already been defined.
//
if(m_definedTables.find(thePropTable) != m_definedTables.end())
return m_definedTables[thePropTable];
G4MaterialPropertiesTable* newTable = new G4MaterialPropertiesTable();
// Add properties to the table ...
// 1. Const properties
GeoMaterialPropertiesTable::GeoMatPMap_ConstIt it1_first = thePropTable->beginPMap();
GeoMaterialPropertiesTable::GeoMatPMap_ConstIt it1_last = thePropTable->endPMap();
for(;it1_first!=it1_last;it1_first++)
newTable->AddConstProperty((it1_first->first).c_str(),it1_first->second);
// 2. Vector properties
GeoMaterialPropertiesTable::GeoMatPVMap_ConstIt it2_first = thePropTable->beginPVMap();
GeoMaterialPropertiesTable::GeoMatPVMap_ConstIt it2_last = thePropTable->endPVMap();
for(;it2_first!=it2_last;it2_first++)
{
GeoMaterialPropertyVector* geoMPV = it2_first->second;
//from G4 9.6 G4MaterialPropertyVector is now a typedef of G4PhysicsOrderedFreeVector
G4MaterialPropertyVector* g4MPV = new G4MaterialPropertyVector();
geoMPV->ResetIterator();
while((*geoMPV).operator++())
{
//g4MPV->AddElement(geoMPV->GetPhotonMomentum(),geoMPV->GetProperty()); // G4 9.4 syntax
//assume G4PhysicsOrderedFreeVector::InsertValues is equivalent to G4MaterialPropertyVector::AddElement
g4MPV->InsertValues(geoMPV->GetPhotonMomentum(),geoMPV->GetProperty()); // G4 9.6 syntax
}
newTable->AddProperty((it2_first->first).c_str(),g4MPV);
}
// Save new table to the map
m_definedTables[thePropTable]=newTable;
return newTable;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoMaterial2G4/Geo2G4MaterialFactory.h"
#include "Geo2G4ElementFactory.h"
#include "GeoMaterial2G4/Geo2G4MatPropTableFactory.h"
#include "GeoModelKernel/GeoMaterial.h"
#include "GeoModelUtilities/GeoExtendedMaterial.h"
#include "GeoModelUtilities/GeoMaterialPropertiesTable.h"
#include "G4Material.hh"
// Geo2G4MaterialFactory::Geo2G4MaterialFactory(): m_msg("Geo2G4MaterialFactory")
Geo2G4MaterialFactory::Geo2G4MaterialFactory()
{
}
G4Material* Geo2G4MaterialFactory::Build(const GeoMaterial* theMat)
{
static Geo2G4ElementFactory eFactory;
Geo2G4MatPropTableFactory* tFactory = Geo2G4MatPropTableFactory::instance();
//
// Check if this material has already been defined.
//
std::string nam = theMat->getName();
if(m_definedMaterials.find(theMat) != m_definedMaterials.end())
return m_definedMaterials[theMat];
int nelements = theMat->getNumElements();
// Different actions depending whether we are dealing with
// standard or extended materials
const GeoExtendedMaterial* extMat = dynamic_cast<const GeoExtendedMaterial*>(theMat);
G4Material* newmaterial = 0;
if(extMat) {
G4State state = kStateUndefined;
switch(extMat->getState())
{
case stateUndefined:
state = kStateUndefined;
break;
case stateSolid:
state = kStateSolid;
break;
case stateLiquid:
state = kStateLiquid;
break;
case stateGas:
state = kStateGas;
break;
default:
break;
}
double temperature = extMat->getTemperature();
double pressure = extMat->getPressure();
newmaterial= new G4Material(nam,
extMat->getDensity(),
nelements,
state,
temperature,
pressure);
// Build G4MaterialPropertiesTable if needed
GeoMaterialPropertiesTable* geoPropTable = extMat->GetMaterialPropertiesTable();
if(geoPropTable) {
G4MaterialPropertiesTable* g4PropTable = tFactory->Build(geoPropTable);
if(g4PropTable)
newmaterial->SetMaterialPropertiesTable(g4PropTable);
}
}
else
newmaterial= new G4Material(nam,
theMat->getDensity(),
nelements);
for (int ii = 0; ii< nelements; ii++) {
G4Element* theG4Ele = eFactory.Build(theMat->getElement(ii));
newmaterial->AddElement(theG4Ele, theMat->getFraction(ii));
}
m_definedMaterials[theMat]=newmaterial;
// Check if we have the situation when on GeoModel side two different
// materials share the same name.
// Print an INFO message if so.
if(m_definedMatNames.find(nam)==m_definedMatNames.end())
m_definedMatNames[nam] = theMat;
else if(m_definedMatNames[nam] != theMat)
std::cout << "!!! On GeoModel side two different materials share the name: " << std::endl;
return newmaterial;
}
################################################################################
# Package: GeoModel2G4
################################################################################
cmake_minimum_required(VERSION 3.10)
# Declare the package name
project( "GeoModel2G4" VERSION 1.0.0 LANGUAGES CXX )
# External dependencies:
find_package( Geant4 REQUIRED )
find_package( CLHEP )
find_package( ROOT COMPONENTS MathCore RIO Core Tree Hist pthread )
find_package( XercesC )
# GeoModel dependencies
find_package( GeoModelCore REQUIRED )
##########################################################
# NOTE! The original package also needs this Athena stuff:
#
# DetectorDescription/GeoModel/GeoModelInterfaces
# DetectorDescription/GeoModel/GeoSpecialShapes
# DetectorDescription/GeoPrimitives
# Simulation/G4Atlas/G4AtlasInterfaces
# Simulation/G4Atlas/G4AtlasTools
# Simulation/G4Sim/SimHelpers
# Project's Settings
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Use the GNU install directory names.
include( GNUInstallDirs ) # it defines CMAKE_INSTALL_LIBDIR
# Find the header and source files.
file( GLOB SOURCES src/*.cxx )
file( GLOB HEADERS GeoModel2G4/*.h )
# include Geant4 headers
include(${Geant4_USE_FILE})
# Set target and properties
add_library( GeoModel2G4 SHARED ${HEADERS} ${SOURCES} )
target_link_libraries( GeoModel2G4
PUBLIC ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${ROOT_LIBRARIES}
PRIVATE ${CLHEP_LIBRARIES} GeoMaterial2G4 GeoModelUtilities )
target_include_directories( GeoModel2G4 SYSTEM PUBLIC ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} PRIVATE ${CLHEP_INCLUDE_DIRS} ${GeoModelCore_INCLUDE_DIRS} )
target_include_directories( GeoModel2G4 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include> )
# Set installation of library headers
set_property( TARGET GeoModel2G4 PROPERTY PUBLIC_HEADER ${HEADERS} )
# # Install the library.
# install( TARGETS GeoModel2G4
# EXPORT GeoModel2G4
# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
# PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GeoModel2G4 )
#
# install( TARGETS GeoModel2G4
# EXPORT GeoModel2G4Config
# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
# PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GeoModel2G4 )
#
# # Install a CMake description of the project/library.
# install( EXPORT GeoModel2G4Config DESTINATION cmake )
# new test GeoModelG4
install( TARGETS GeoModel2G4 EXPORT GeoModel2G4-export LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GeoModel2G4 )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/*
* CLHEPtoEigenConverter.h
*
* Created on: Jun 26, 2013
* Author: rlangenb
*
* update: rbianchi - Feb 25 2014
*/
#ifndef CLHEPTOEIGENCONVERTER_H_
#define CLHEPTOEIGENCONVERTER_H_
// Make it clear that this header is not for standalone usage:
#ifdef XAOD_STANDALONE
#error "This header is not meant to be used in standalone mode"
#endif // XAOD_STANDALONE
#include "CLHEP/Geometry/Transform3D.h"
#include "CLHEP/Geometry/Point3D.h"
#include "CLHEP/Vector/Rotation.h"
#include "CLHEP/Vector/ThreeVector.h"
namespace Amg {
typedef Eigen::Quaternion<double> Rotation3D;
typedef Eigen::Translation<double, 3> Translation3D;
typedef Eigen::AngleAxisd AngleAxis3D;
typedef Eigen::Affine3d Transform3D;
typedef Eigen::Matrix<double, 3, 1> Vector3D;
typedef Eigen::Matrix<double, 2, 1> Vector2D;
typedef Eigen::Matrix<double, 3, 3> RotationMatrix3D;
inline Amg::Transform3D CLHEPTransformToEigen(
const HepGeom::Transform3D& CLHEPtransf) {
Amg::Transform3D t = Amg::Transform3D();
//loop unrolled for performance
t(0, 0) = CLHEPtransf(0, 0);
t(0, 1) = CLHEPtransf(0, 1);
t(0, 2) = CLHEPtransf(0, 2);
t(1, 0) = CLHEPtransf(1, 0);
t(1, 1) = CLHEPtransf(1, 1);
t(1, 2) = CLHEPtransf(1, 2);
t(2, 0) = CLHEPtransf(2, 0);
t(2, 1) = CLHEPtransf(2, 1);
t(2, 2) = CLHEPtransf(2, 2);
t(0, 3) = CLHEPtransf(0, 3);
t(1, 3) = CLHEPtransf(1, 3);
t(2, 3) = CLHEPtransf(2, 3);
return t;
}
inline RotationMatrix3D CLHEPRotationToEigen(
const CLHEP::HepRotation& CLHEProtation) {
Amg::RotationMatrix3D t;
t(0, 0) = CLHEProtation(0, 0);
t(0, 1) = CLHEProtation(0, 1);
t(0, 2) = CLHEProtation(0, 2);
t(1, 0) = CLHEProtation(1, 0);
t(1, 1) = CLHEProtation(1, 1);
t(1, 2) = CLHEProtation(1, 2);
t(2, 0) = CLHEProtation(2, 0);
t(2, 1) = CLHEProtation(2, 1);
t(2, 2) = CLHEProtation(2, 2);
return t;
}
inline Translation3D CLHEPTranslationToEigen(
const CLHEP::Hep3Vector& CLHEPtranslation) {
return Translation3D(
Vector3D(CLHEPtranslation[0], CLHEPtranslation[1],
CLHEPtranslation[2]));
}
// from: http://proj-clhep.web.cern.ch/proj-clhep/doc/CLHEP_2_0_4_7/doxygen/html/classHepGeom_1_1Translate3D.html#f2df65781931c7df9cc2858de2c89151
//Amg::Transform3D(1, 0, 0, CLHEPtranslate3D[0],
// 0, 1, 0, CLHEPtranslate3D[1],
// 0, 0, 1, CLHEPtranslate3D[2]);
inline Amg::Transform3D CLHEPTranslate3DToEigen(
const HepGeom::Translate3D& CLHEPtranslate3D)
{
Amg::Transform3D t = Amg::Transform3D();
t.setIdentity();
t(0, 3) = CLHEPtranslate3D(0, 3);
t(1, 3) = CLHEPtranslate3D(1, 3);
t(2, 3) = CLHEPtranslate3D(2, 3);
return t;
}
inline HepGeom::Transform3D EigenTransformToCLHEP(
const Amg::Transform3D& eigenTransf) {
CLHEP::HepRotation rotation(
CLHEP::Hep3Vector(eigenTransf(0, 0), eigenTransf(1, 0), eigenTransf(2, 0)),
CLHEP::Hep3Vector(eigenTransf(0, 1), eigenTransf(1, 1), eigenTransf(2, 1)),
CLHEP::Hep3Vector(eigenTransf(0, 2), eigenTransf(1, 2), eigenTransf(2, 2)));
CLHEP::Hep3Vector translation(eigenTransf(0, 3), eigenTransf(1, 3), eigenTransf(2, 3));
HepGeom::Transform3D t(rotation, translation);
return t;
}
inline Amg::Vector3D Hep3VectorToEigen(const CLHEP::Hep3Vector& CLHEPvector) {
return Vector3D(CLHEPvector[0], CLHEPvector[1], CLHEPvector[2]);
}
inline CLHEP::Hep3Vector EigenToHep3Vector(const Amg::Vector3D& eigenvector) {
return CLHEP::Hep3Vector(eigenvector[0], eigenvector[1], eigenvector[2]);
}
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEO2G4_ExtParameterisedVolumeBuilder_H
#define GEO2G4_ExtParameterisedVolumeBuilder_H
#include "VolumeBuilder.h"
#include <string>
class Geo2G4AssemblyVolume;
class GeoMaterial;
class ExtParameterisedVolumeBuilder: public VolumeBuilder
{
public:
ExtParameterisedVolumeBuilder(std::string n);
///
G4LogicalVolume* Build(GeoPVConstLink pv) const;
///
Geo2G4AssemblyVolume* BuildAssembly(GeoPVConstLink pv) const;
private:
/// Prints info when some PhysVol contains both types (PV and ST) of daughters
void PrintSTInfo(std::string volume) const;
///
void getMatEther() const;
mutable bool m_getMatEther;
mutable const GeoMaterial* m_matEther;
mutable const GeoMaterial* m_matHypUr;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEO2G4_Geo2G4AssemblyFactory_h
#define GEO2G4_Geo2G4AssemblyFactory_h
#include "GeoModelKernel/GeoVPhysVol.h"
class Geo2G4AssemblyVolume;
class Geo2G4AssemblyFactory
{
public:
Geo2G4AssemblyFactory();
Geo2G4AssemblyVolume* Build(const PVConstLink,
bool&) const;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEO2G4_ASSEMBLYTRIPLET_H
#define GEO2G4_ASSEMBLYTRIPLET_H
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
class G4LogicalVolume;
class Geo2G4AssemblyVolume;
class Geo2G4AssemblyTriplet
{
public: // with description
Geo2G4AssemblyTriplet();
// Default constructor
Geo2G4AssemblyTriplet( G4LogicalVolume* pVolume,
G4ThreeVector& translation,
G4RotationMatrix* pRotation,
G4bool isReflection = false);
// An explicit constructor for a logical volume
Geo2G4AssemblyTriplet( Geo2G4AssemblyVolume* pAssembly,
G4ThreeVector& translation,
G4RotationMatrix* pRotation,
G4bool isReflection = false);
// An explicit constructor for an assembly volume
Geo2G4AssemblyTriplet( const Geo2G4AssemblyTriplet& second );
// Copy constructor
~Geo2G4AssemblyTriplet();
// Destructor
Geo2G4AssemblyTriplet& operator=( const Geo2G4AssemblyTriplet& second );
// Assignment operator
G4LogicalVolume* GetVolume() const;
// Retrieve the logical volume reference
void SetVolume( G4LogicalVolume* pVolume );
// Update the logical volume reference
Geo2G4AssemblyVolume* GetAssembly() const;
// Retrieve the assembly volume reference
void SetAssembly( Geo2G4AssemblyVolume* pAssembly );
// Update the assembly volume reference
G4ThreeVector GetTranslation() const;
// Retrieve the logical volume translation
void SetTranslation( G4ThreeVector& pVolume );
// Update the logical volume translation
G4RotationMatrix* GetRotation() const;
// Retrieve the logical volume rotation
void SetRotation( G4RotationMatrix* pVolume );
// Update the logical volume rotation
G4bool IsReflection() const;
// Return true if the logical or assembly volume has reflection
private:
G4LogicalVolume* m_volume;
// A logical volume
G4ThreeVector m_translation;
// A logical volume translation
G4RotationMatrix* m_rotation;
// A logical volume rotation
private:
// Member data for handling assemblies of assemblies and reflections
Geo2G4AssemblyVolume* m_assembly;
// An assembly volume
G4bool m_isReflection;
// True if the logical or assembly volume has reflection
};
inline
Geo2G4AssemblyTriplet::Geo2G4AssemblyTriplet()
: m_volume( 0 ), m_rotation( 0 ), m_assembly(0), m_isReflection(false)
{
G4ThreeVector v(0.,0.,0.);
m_translation = v;
}
inline
Geo2G4AssemblyTriplet::Geo2G4AssemblyTriplet( G4LogicalVolume* pVolume,
G4ThreeVector& translation,
G4RotationMatrix* pRotation,
G4bool isReflection )
: m_volume( pVolume ), m_translation( translation ), m_rotation( pRotation ),
m_assembly( 0 ), m_isReflection(isReflection)
{
}
inline
Geo2G4AssemblyTriplet::Geo2G4AssemblyTriplet( Geo2G4AssemblyVolume* pAssembly,
G4ThreeVector& translation,
G4RotationMatrix* pRotation,
G4bool isReflection )
: m_volume( 0 ), m_translation( translation ), m_rotation( pRotation ),
m_assembly( pAssembly ), m_isReflection(isReflection)
{
}
inline
Geo2G4AssemblyTriplet::Geo2G4AssemblyTriplet( const Geo2G4AssemblyTriplet& second )
{
m_volume = second.GetVolume();
m_rotation = second.GetRotation();
m_translation = second.GetTranslation();
m_assembly = second.GetAssembly();
m_isReflection = second.IsReflection();
}
inline
Geo2G4AssemblyTriplet::~Geo2G4AssemblyTriplet()
{
}
inline
G4LogicalVolume* Geo2G4AssemblyTriplet::GetVolume() const
{
return m_volume;
}
inline
void Geo2G4AssemblyTriplet::SetVolume( G4LogicalVolume* pVolume )
{
if ( m_assembly )
{
G4Exception("Geo2G4AssemblyTriplet::SetVolume()",
"IllegalCall", JustWarning,
"There is an assembly already set, it will be ignored.");
}
m_volume = pVolume;
m_assembly = 0;
}
inline
Geo2G4AssemblyVolume* Geo2G4AssemblyTriplet::GetAssembly() const
{
return m_assembly;
}
inline
void Geo2G4AssemblyTriplet::SetAssembly( Geo2G4AssemblyVolume* pAssembly )
{
if ( m_volume )
{
G4Exception("Geo2G4AssemblyTriplet::SetAssembly()",
"IllegalCall", JustWarning,
"There is a volume already set, it will be ignored.");
}
m_assembly = pAssembly;
m_volume = 0;
}
inline
G4ThreeVector Geo2G4AssemblyTriplet::GetTranslation() const
{
return m_translation;
}
inline
void Geo2G4AssemblyTriplet::SetTranslation( G4ThreeVector& translation )
{
m_translation = translation;
}
inline
G4RotationMatrix* Geo2G4AssemblyTriplet::GetRotation() const
{
return m_rotation;
}
inline
void Geo2G4AssemblyTriplet::SetRotation( G4RotationMatrix* pRotation )
{
m_rotation = pRotation;
}
inline
G4bool Geo2G4AssemblyTriplet::IsReflection() const
{
return m_isReflection;
}
inline
Geo2G4AssemblyTriplet&
Geo2G4AssemblyTriplet::operator=( const Geo2G4AssemblyTriplet& second )
{
if( this != &second )
{
m_volume = second.GetVolume();
m_rotation = second.GetRotation();
m_translation = second.GetTranslation();
m_assembly = second.GetAssembly();
m_isReflection = second.IsReflection();
}
return *this;
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEO2G4_ASSEMBLYVOLUME_H
#define GEO2G4_ASSEMBLYVOLUME_H
#include "Geo2G4AssemblyTriplet.h"
#include "G4Transform3D.hh"
#include <vector>
class G4VPhysicalVolume;
class Geo2G4AssemblyVolume
{
public: // with description
Geo2G4AssemblyVolume();
Geo2G4AssemblyVolume( G4LogicalVolume* volume,
G4ThreeVector& translation,
G4RotationMatrix* rotation);
~Geo2G4AssemblyVolume();
//
// Constructors & destructor.
// At destruction all the generated physical volumes and associated
// rotation matrices of the imprints will be destroyed.
//
// The rotation matrix passed as argument can be 0 (identity) or an address
// even of an object on the upper stack frame. During assembly imprint, a
// new matrix is created anyway and it is kept track of it so it can be
// automatically deleted later at the end of the application.
// This policy is adopted since user has no control on the way the
// rotations are combined.
void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
G4ThreeVector& translation,
G4RotationMatrix* rotation,
int copyNo=0,G4String userComment="");
//
// Place the given volume 'pPlacedVolume' inside the assembly.
//
// The adopted approach:
//
// - Place it w.r.t. the assembly coordinate system.
// This step is applied to each of the participating volumes.
//
// The other possible approaches:
//
// - Place w.r.t. the firstly added volume.
// When placed the first, the virtual coordinate system becomes
// the coordinate system of the first one.
// Every next volume being added into the assembly will be placed
// w.r.t to the first one.
//
// - Place w.r.t the last placed volume.
// When placed the first, the virtual coordinate system becomes
// the coordinate system of the first one.
// Every next volume being added into the assembly will be placed
// w.r.t to the previous one.
//
// The rotation matrix passed as argument can be 0 (identity) or an address
// even of an object on the upper stack frame. During assembly imprint, a
// new matrix is created anyway and it is kept track of it so it can be
// automatically deleted later at the end of the application.
// This policy is adopted since user has no control on the way the
// rotations are combined.
void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
G4Transform3D& transformation,
int copyNo=0,G4String userComment="");
//
// The same as previous, but takes complete 3D transformation in space
// as its argument.
void AddPlacedAssembly( Geo2G4AssemblyVolume* pAssembly,
G4Transform3D& transformation);
//
// The same as previous AddPlacedVolume(), but takes an assembly volume
// as its argument.
void AddPlacedAssembly( Geo2G4AssemblyVolume* pAssembly,
G4ThreeVector& translation,
G4RotationMatrix* rotation);
//
// The same as above AddPlacedVolume(), but takes an assembly volume
// as its argument with translation and rotation.
void MakeImprint( G4LogicalVolume* pMotherLV,
G4ThreeVector& translationInMother,
G4RotationMatrix* pRotationInMother,
G4int copyNumBase = 0,
G4bool ITkScheme = false,
G4bool surfCheck = false );
//
// Creates instance of an assembly volume inside the given mother volume.
void MakeImprint( G4LogicalVolume* pMotherLV,
G4Transform3D& transformation,
G4int copyNumBase = 0,
G4bool ITkScheme = false,
G4bool surfCheck = false );
//
// The same as previous Imprint() method, but takes complete 3D
// transformation in space as its argument.
inline std::vector<G4VPhysicalVolume*>::iterator GetVolumesIterator();
inline unsigned int TotalImprintedVolumes() const;
//
// Methods to access the physical volumes imprinted with the assembly.
unsigned int GetImprintsCount() const;
//
// Return the number of made imprints.
unsigned int GetInstanceCount() const;
//
// Return the number of existing instance of Geo2G4AssemblyVolume class.
unsigned int GetAssemblyID() const;
//
// Return instance number of this concrete object.
protected:
void SetInstanceCount( unsigned int value );
void SetAssemblyID( unsigned int value );
void InstanceCountPlus();
void InstanceCountMinus();
void SetImprintsCount( unsigned int value );
void ImprintsCountPlus();
void ImprintsCountMinus();
//
// Internal counting mechanism, used to compute unique the names of
// physical volumes created by MakeImprint() methods.
private:
void MakeImprint( Geo2G4AssemblyVolume* pAssembly,
G4LogicalVolume* pMotherLV,
G4Transform3D& transformation,
G4int copyNumBase = 0,
G4bool ITkScheme = false,
G4bool surfCheck = false );
//
// Function for placement of the given assembly in the given mother
// (called recursively if the assembly contains an assembly).
private:
std::vector<Geo2G4AssemblyTriplet> m_triplets;
std::vector<int> m_copyNumbers;
std::vector<G4String> m_userComments;
//
// Participating volumes represented as a vector of
// <logical volume, translation, rotation>.
std::vector<G4VPhysicalVolume*> m_PVStore;
//
// We need to keep list of physical volumes created by MakeImprint() method
// in order to be able to cleanup the objects when not needed anymore.
// This requires the user to keep assembly objects in memory during the
// whole job or during the life-time of G4Navigator, logical volume store
// and physical volume store keep pointers to physical volumes generated by
// the assembly volume.
// When an assembly object is about to die it will destroy all its
// generated physical volumes and rotation matrices as well !
unsigned int m_imprintsCounter;
//
// Number of imprints of the given assembly volume.
static unsigned int s_instanceCounter;
//
// Class instance counter.
unsigned int m_assemblyID;
//
// Assembly object ID derived from instance counter at construction time.
};
inline
unsigned int Geo2G4AssemblyVolume::GetImprintsCount() const
{
return m_imprintsCounter;
}
inline
void Geo2G4AssemblyVolume::SetImprintsCount( unsigned int value )
{
m_imprintsCounter = value;
}
inline
void Geo2G4AssemblyVolume::ImprintsCountPlus()
{
m_imprintsCounter++;
}
inline
void Geo2G4AssemblyVolume::ImprintsCountMinus()
{
m_imprintsCounter--;
}
inline
unsigned int Geo2G4AssemblyVolume::GetAssemblyID() const
{
return m_assemblyID;
}
inline
void Geo2G4AssemblyVolume::SetAssemblyID( unsigned int value )
{
m_assemblyID = value;
}
inline
std::vector<G4VPhysicalVolume*>::iterator
Geo2G4AssemblyVolume::GetVolumesIterator()
{
std::vector<G4VPhysicalVolume*>::iterator iterator = m_PVStore.begin();
return iterator;
}
inline
unsigned int Geo2G4AssemblyVolume::TotalImprintedVolumes() const
{
return m_PVStore.size();
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEO2G4_Geo2G4LVFactory_h
#define GEO2G4_Geo2G4LVFactory_h
#include "GeoModelKernel/GeoVPhysVol.h"
// Units
#include "GeoModelKernel/Units.h"
#define SYSTEM_OF_UNITS GeoModelKernelUnits
class G4LogicalVolume;
class GeoLogVol;
class Geo2G4LVFactory
{
public:
Geo2G4LVFactory();
G4LogicalVolume* Build(const PVConstLink,
bool&) const;
GeoMaterial* Air;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEO2G4_Geo2G4STParameterisation_H
#define GEO2G4_Geo2G4STParameterisation_H
#include "globals.hh"
#include "G4VPVParameterisation.hh"
#include "G4RotationMatrix.hh"
#include "GeoModelKernel/GeoXF.h"
class G4VPhysicalVolume;
// Dummy declarations. To avoid warnings
class G4Box;
class G4Trd;
class G4Trap;
class G4Cons;
class G4Sphere;
class G4Torus;
class G4Para;
class G4Hype;
class G4Tubs;
class G4Orb;
class G4Polyhedra;
class G4Polycone;
class G4Ellipsoid;
class Geo2G4STParameterisation : public G4VPVParameterisation
{
public:
Geo2G4STParameterisation(const GeoXF::Function* func,
unsigned int copies);
virtual ~Geo2G4STParameterisation();
void ComputeTransformation (const G4int copyNo,
G4VPhysicalVolume* physVol) const;
private:
// Declaring, but not defining private copy-constructor and
// assignment operator, as an object of this class should never be
// copied.
Geo2G4STParameterisation(const Geo2G4STParameterisation&);
Geo2G4STParameterisation& operator= (const Geo2G4STParameterisation&);
// Dummy declarations. To avoid warnings
void ComputeDimensions (G4Box&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Trd&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Trap&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Cons&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Sphere&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Torus&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Para&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Hype&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Tubs&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Orb&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Polyhedra&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Polycone&,const G4int,const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Ellipsoid&,const G4int,const G4VPhysicalVolume*) const {}
const GeoXF::Function *m_function;
G4RotationMatrix* m_rotation;
unsigned int m_nCopies;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEO2G4_Geo2G4SolidFactory_h
#define GEO2G4_Geo2G4SolidFactory_h
#include <map>
#include <string>
//#include "LArWheelSolid_type.h"
class G4VSolid;
class GeoShape;
class Geo2G4SolidFactory
{
public:
//typedef ServiceHandle<StoreGateSvc> StoreGateSvc_t;
//typedef std::pair<LArWheelSolid_t, int> LArWheelSolidDef_t;
//typedef std::map<std::string, LArWheelSolidDef_t> LArWheelSolid_typemap;
Geo2G4SolidFactory();
G4VSolid* Build(const GeoShape*, std::string name=std::string("")) const;
/** @brief The standard @c StoreGateSvc/DetectorStore
* Returns (kind of) a pointer to the @c StoreGateSvc
*/
//StoreGateSvc_t& detStore() const;
private:
//G4VSolid* createLArWheelSolid(const std::string& name, const LArWheelSolidDef_t & lwsdef) const;
//static const LArWheelSolid_typemap s_lwsTypes;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEO2G4_VolumeBuilder_H
#define GEO2G4_VolumeBuilder_H
#include "G4LogicalVolume.hh"
//#include "Geo2G4SvcAccessor.h"
//#include "GeoModelUtilities/GeoOpticalPhysVol.h"
#include "G4VPhysicalVolume.hh"
#include <string>
#include <iostream>
#include <map>
//typedef std::map< const GeoOpticalPhysVol*, G4VPhysicalVolume*,std::less< const GeoOpticalPhysVol*> > OpticalVolumesMap;
class GeoPVConstLink;
class VolumeBuilder
{
public:
VolumeBuilder(std::string k): m_paramOn(false), m_key(k)
{
}
virtual ~VolumeBuilder()
{
}
std::string GetKey() const {return m_key;}
// flag controlling Parameterization to Parameterization translation
void SetParam(bool flag){m_paramOn = flag;}
bool GetParam(){return m_paramOn;}
//virtual G4LogicalVolume* Build(PVConstLink pv, OpticalVolumesMap* optical_volumes = 0) const = 0;
virtual G4LogicalVolume* Build(GeoPVConstLink pv) const = 0;
protected:
bool m_paramOn;
private:
std::string m_key;
};
#endif
################################################################################
# Package: Geo2G4
################################################################################
cmake_minimum_required(VERSION 3.10)
# Declare the package name
project( "Geo2G4" VERSION 1.0.0 LANGUAGES CXX )
# External dependencies:
find_package( Geant4 REQUIRED )
find_package( Boost COMPONENTS filesystem thread system )
find_package( CLHEP )
find_package( ROOT COMPONENTS MathCore RIO Core Tree Hist pthread )
find_package( XercesC )
# GeoModel dependencies
find_package( GeoModelKernel REQUIRED )
find_package( GeoModelUtilities REQUIRED )
find_package( GeoMaterial2G4 REQUIRED )
##########################################################
# NOTE! The original package also needs this Athena stuff:
#
# DetectorDescription/GeoModel/GeoModelInterfaces
# DetectorDescription/GeoModel/GeoSpecialShapes
# DetectorDescription/GeoPrimitives
# Simulation/G4Atlas/G4AtlasInterfaces
# Simulation/G4Atlas/G4AtlasTools
# Simulation/G4Sim/SimHelpers
# Project's Settings
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Use the GNU install directory names.
include( GNUInstallDirs ) # it defines CMAKE_INSTALL_LIBDIR
# Find the header and source files.
file( GLOB SOURCES src/*.cxx )
file( GLOB HEADERS GeoMaterial2G4/*.h )
# include Geant4 headers
include(${Geant4_USE_FILE})
# Set target and properties
add_library( Geo2G4Lib SHARED ${HEADERS} ${SOURCES} )
target_link_libraries( Geo2G4Lib
PUBLIC ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${ROOT_LIBRARIES}
PRIVATE ${Boost_LIBRARIES} ${CLHEP_LIBRARIES} ${GEOMODEL_LIBRARIES} GeoSpecialShapes G4AtlasToolsLib SimHelpers GeoMaterial2G4 GeoModelUtilities )
target_include_directories( Geo2G4Lib SYSTEM PUBLIC ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} PRIVATE ${Boost_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${GEOMODEL_INCLUDE_DIRS} )
target_include_directories( Geo2G4Lib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include> )
### TODO: do we need this from Athena? Maybe not...
# atlas_add_component( Geo2G4 ... )
### TODO: do we need this from Athena? Maybe not...
# atlas_add_dictionary( LArWheelSolidCheckerDict ... )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment