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

moved relevant files from GeoModelUtilities to GeoMaterial2G4

parent f68ea78b
No related branches found
No related tags found
No related merge requests found
Showing
with 588 additions and 6 deletions
......@@ -28,7 +28,7 @@ include(${Geant4_USE_FILE})
# Set target and properties
add_library( GeoMaterial2G4 SHARED ${HEADERS} ${SOURCES} )
target_link_libraries( GeoMaterial2G4 PUBLIC ${Geant4_LIBRARIES} GeoModelKernel GeoModelUtilities )
target_link_libraries( GeoMaterial2G4 PUBLIC ${Geant4_LIBRARIES} GeoModelKernel )
target_include_directories( GeoMaterial2G4 SYSTEM PUBLIC ${GeoModelCore_INCLUDE_DIRS} )
target_include_directories( GeoMaterial2G4 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GeoExtendedMaterial_h
#define GeoExtendedMaterial_h 1
#include "GeoModelKernel/GeoMaterial.h"
#include "GeoMaterial2G4/GeoMaterialPropertiesTable.h"
// Physical constants
#include "GeoModelKernel/Units.h"
#define SYSTEM_OF_UNITS GeoModelKernelUnits // --> 'GeoModelKernelUnits::STP_Temperature'
enum GeoMaterialState { stateUndefined, stateSolid, stateLiquid, stateGas };
class GeoExtendedMaterial : public GeoMaterial
{
public:
GeoExtendedMaterial(const std::string &Name,
double Density,
GeoMaterialState State = stateUndefined,
double Temperature = SYSTEM_OF_UNITS::STP_Temperature,
double Pressure = SYSTEM_OF_UNITS::STP_Pressure);
virtual ~GeoExtendedMaterial();
const GeoMaterialState& getState() const;
const double& getTemperature() const;
const double& getPressure() const;
void SetMaterialPropertiesTable(GeoMaterialPropertiesTable* MPT);
GeoMaterialPropertiesTable* GetMaterialPropertiesTable() const;
private:
GeoExtendedMaterial(const GeoExtendedMaterial &right);
GeoExtendedMaterial & operator=(const GeoExtendedMaterial &right);
GeoMaterialState m_state;
double m_temperature;
double m_pressure;
GeoMaterialPropertiesTable* m_properties;
};
inline const GeoMaterialState& GeoExtendedMaterial::getState() const
{
return m_state;
}
inline const double& GeoExtendedMaterial::getTemperature() const
{
return m_temperature;
}
inline const double& GeoExtendedMaterial::getPressure() const
{
return m_pressure;
}
inline void GeoExtendedMaterial::SetMaterialPropertiesTable(GeoMaterialPropertiesTable* MPT)
{
m_properties = MPT;
m_properties->ref();
}
inline GeoMaterialPropertiesTable* GeoExtendedMaterial::GetMaterialPropertiesTable() const
{
return m_properties;
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GeoMPVEntry_h
#define GeoMPVEntry_h 1
class GeoMPVEntry
{
public:
bool operator <(const GeoMPVEntry &right) const;
bool operator ==(const GeoMPVEntry &right) const;
GeoMPVEntry& operator =(const GeoMPVEntry &right);
GeoMPVEntry(double aPhotonMomentum, double aPropertyValue);
GeoMPVEntry(const GeoMPVEntry &right);
~GeoMPVEntry();
double GetPhotonMomentum();
double GetProperty();
void DumpEntry();
private:
double m_thePhotonMomentum;
double m_theProperty;
};
inline double GeoMPVEntry::GetPhotonMomentum()
{
return m_thePhotonMomentum;
}
inline double GeoMPVEntry::GetProperty()
{
return m_theProperty;
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GeoMaterialPropertiesTable_h
#define GeoMaterialPropertiesTable_h 1
#include "GeoMaterial2G4/GeoMaterialPropertyVector.h"
#include "GeoModelKernel/RCBase.h"
#include <map>
#include <string>
class GeoMaterialPropertyVector;
class GeoMaterialPropertiesTable : public RCBase
{
public:
GeoMaterialPropertiesTable();
~GeoMaterialPropertiesTable();
public:
// ******** Typedefs
// Maps
typedef std::map<std::string, GeoMaterialPropertyVector*, std::less<std::string> > GeoMatPVMap;
typedef std::map< std::string, double, std::less<std::string> > GeoMatPMap;
// Iterators
typedef GeoMatPVMap::const_iterator GeoMatPVMap_ConstIt;
typedef GeoMatPMap::const_iterator GeoMatPMap_ConstIt;
public:
// Add a new property to the table by giving a key-name and value
void AddConstProperty(const char *key,
double PropertyValue);
// Add a new property to the table by giving a key-name and the
// arrays x and y of size NumEntries.
void AddProperty(const char *key,
double *PhotonMomenta,
double *PropertyValues,
int NumEntries);
// Add a new property to the table by giving a key-name and an
// already constructed GeoMaterialPropertyVector.
void AddProperty(const char *key, GeoMaterialPropertyVector *opv);
// Remove a constant property from the table.
void RemoveConstProperty(const char *key);
// Remove a property from the table.
void RemoveProperty(const char *key);
// Add a new entry (pair of numbers) to the table for a given key.
void AddEntry(const char *key, double aPhotonMomentum,
double aPropertyValue);
// Access to the contents
GeoMatPVMap_ConstIt beginPVMap() const;
GeoMatPVMap_ConstIt endPVMap() const;
GeoMatPMap_ConstIt beginPMap() const;
GeoMatPMap_ConstIt endPMap() const;
// Dump contents
void DumpTable() const;
private:
GeoMatPVMap m_MPT;
GeoMatPMap m_MPTC;
typedef GeoMatPVMap::iterator MPTiterator;
typedef GeoMatPMap::iterator MPTCiterator;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GeoMaterialPropertyVector_h
#define GeoMaterialPropertyVector_h 1
#include "GeoMaterial2G4/GeoMPVEntry.h"
#include <vector>
class GeoMaterialPropertyVector
{
public:
bool operator ++();
GeoMaterialPropertyVector&
operator =(const GeoMaterialPropertyVector &right);
GeoMaterialPropertyVector(): m_MPV(0)
{
m_CurrentEntry = -1;
m_NumEntries = 0;
};
GeoMaterialPropertyVector(double *PhotonMomenta,
double *PropertyValues,
int NumElements);
GeoMaterialPropertyVector(const GeoMaterialPropertyVector &right);
~GeoMaterialPropertyVector();
void ResetIterator();
// Add a new element (pair of numbers) to the GeoMaterialPropertyVector.
void AddElement(double aPhotonMomentum,
double aPropertyValue);
double GetProperty() const;
double GetPhotonMomentum() const;
// Dump contents
void DumpVector();
private:
GeoMPVEntry GetEntry(int i) const;
std::vector<GeoMPVEntry*> m_MPV;
int m_NumEntries;
int m_CurrentEntry;
};
#endif
......@@ -71,3 +71,10 @@ make install
```bash
cmake -DGeant4_DIR=../install/lib/Geant4-10.5.0/ -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=RelWithDebInfo ../GeoMaterial2G4/
```
Alternatively, you can source the Geant4 setup, before running cmake:
```bash
source <path_to_geant4_install>/bin/geant4.sh
cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=RelWithDebInfo ../GeoMaterial2G4
```
......@@ -3,11 +3,12 @@
*/
#include "GeoMaterial2G4/Geo2G4MatPropTableFactory.h"
#include "GeoMaterial2G4/GeoMaterialPropertiesTable.h"
#include "GeoMaterial2G4/GeoMaterialPropertyVector.h"
#include "G4MaterialPropertiesTable.hh"
#include "G4MaterialPropertyVector.hh"
#include "GeoModelUtilities/GeoMaterialPropertiesTable.h"
#include "GeoModelUtilities/GeoMaterialPropertyVector.h"
Geo2G4MatPropTableFactory* Geo2G4MatPropTableFactory::m_instance = 0;
......
......@@ -7,11 +7,13 @@
#include "GeoMaterial2G4/Geo2G4MatPropTableFactory.h"
#include "GeoModelKernel/GeoMaterial.h"
#include "GeoModelUtilities/GeoExtendedMaterial.h"
#include "GeoModelUtilities/GeoMaterialPropertiesTable.h"
#include "GeoMaterial2G4/GeoExtendedMaterial.h"
#include "GeoMaterial2G4/GeoMaterialPropertiesTable.h"
#include "G4Material.hh"
// Geo2G4MaterialFactory::Geo2G4MaterialFactory(): m_msg("Geo2G4MaterialFactory")
Geo2G4MaterialFactory::Geo2G4MaterialFactory()
{
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoMaterial2G4/GeoExtendedMaterial.h"
#include "GeoMaterial2G4/GeoMaterialPropertiesTable.h"
GeoExtendedMaterial::GeoExtendedMaterial(const std::string &Name,
double Density,
GeoMaterialState State,
double Temperature,
double Pressure):
GeoMaterial(Name,Density),
m_state(State),
m_temperature(Temperature),
m_pressure(Pressure),
m_properties(0)
{
}
GeoExtendedMaterial::~GeoExtendedMaterial()
{
m_properties->unref();
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoMaterial2G4/GeoMPVEntry.h"
#include <iostream>
bool GeoMPVEntry::operator ==(const GeoMPVEntry &right) const
{
if (m_thePhotonMomentum == right.m_thePhotonMomentum)
return true;
else
return false;
}
bool GeoMPVEntry::operator <(const GeoMPVEntry &right) const
{
if (m_thePhotonMomentum < right.m_thePhotonMomentum)
return true;
else
return false;
}
GeoMPVEntry& GeoMPVEntry::operator =(const GeoMPVEntry& right)
{
if (this == &right) return *this;
m_thePhotonMomentum = right.m_thePhotonMomentum;
m_theProperty = right.m_theProperty;
return *this;
}
GeoMPVEntry::GeoMPVEntry(double aPhotonMomentum, double aProperty)
{
m_thePhotonMomentum = aPhotonMomentum;
m_theProperty = aProperty;
}
GeoMPVEntry::GeoMPVEntry(const GeoMPVEntry &right)
{
m_thePhotonMomentum = right.m_thePhotonMomentum;
m_theProperty = right.m_theProperty;
}
GeoMPVEntry::~GeoMPVEntry(){}
void GeoMPVEntry::DumpEntry()
{
std::cout << "("
<< m_thePhotonMomentum
<< ", "
<< m_theProperty
<< ")\n";
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoMaterial2G4/GeoMaterialPropertiesTable.h"
#include "GeoMaterial2G4/GeoMaterialPropertyVector.h"
#include <stdexcept>
#include <iostream>
GeoMaterialPropertiesTable::GeoMaterialPropertiesTable()
{
}
GeoMaterialPropertiesTable::~GeoMaterialPropertiesTable()
{
MPTiterator i;
for(i = m_MPT.begin(); i!= m_MPT.end(); i++)
delete (*i).second;
m_MPT.clear();
m_MPTC.clear();
}
void GeoMaterialPropertiesTable::AddConstProperty(const char *key,
double PropertyValue)
{
m_MPTC [std::string(key)] = PropertyValue;
}
void GeoMaterialPropertiesTable::AddProperty(const char *key,
double* PhotonMomenta,
double* PropertyValues,
int NumEntries)
{
GeoMaterialPropertyVector *mpv =
new GeoMaterialPropertyVector(PhotonMomenta,
PropertyValues,
NumEntries);
m_MPT[std::string(key)] = mpv;
}
void GeoMaterialPropertiesTable::AddProperty(const char *key,
GeoMaterialPropertyVector *mpv)
{
m_MPT [std::string(key)] = mpv;
}
void GeoMaterialPropertiesTable::RemoveConstProperty(const char *key)
{
m_MPTC.erase(std::string(key));
}
void GeoMaterialPropertiesTable::RemoveProperty(const char *key)
{
m_MPT.erase(std::string(key));
}
void GeoMaterialPropertiesTable::AddEntry(const char *key,
double aPhotonMomentum,
double aPropertyValue)
{
GeoMaterialPropertyVector *targetVector=m_MPT[std::string(key)];
if(targetVector != 0)
targetVector->AddElement(aPhotonMomentum, aPropertyValue);
else
throw std::runtime_error("GeoMaterialPropertiesTable::AddEntry ==> Material Property Vector not found.");
}
GeoMaterialPropertiesTable::GeoMatPVMap_ConstIt GeoMaterialPropertiesTable::beginPVMap() const
{
return m_MPT.begin();
}
GeoMaterialPropertiesTable::GeoMatPVMap_ConstIt GeoMaterialPropertiesTable::endPVMap() const
{
return m_MPT.end();
}
GeoMaterialPropertiesTable::GeoMatPMap_ConstIt GeoMaterialPropertiesTable::beginPMap() const
{
return m_MPTC.begin();
}
GeoMaterialPropertiesTable::GeoMatPMap_ConstIt GeoMaterialPropertiesTable::endPMap() const
{
return m_MPTC.end();
}
void GeoMaterialPropertiesTable::DumpTable() const
{
for(GeoMatPVMap_ConstIt i=m_MPT.begin(); i!=m_MPT.end(); i++)
{
std::cout << (*i).first << "\n";
if((*i).second != 0)
(*i).second->DumpVector();
else
std::cout << "NULL Material Property Vector Pointer." << "\n";
}
for (GeoMatPMap_ConstIt j = m_MPTC.begin(); j != m_MPTC.end(); ++j)
{
std::cout << j->first << "\n";
if(j->second != 0)
std::cout << j->second << "\n";
else
std::cout << "No Material Constant Property." << "\n";
}
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoMaterial2G4/GeoMaterialPropertyVector.h"
#include <stdexcept>
#include <iostream>
bool GeoMaterialPropertyVector::operator ++()
{
m_CurrentEntry++;
if(m_CurrentEntry < m_NumEntries)
return true;
else
return false;
}
GeoMaterialPropertyVector& GeoMaterialPropertyVector::operator =(const GeoMaterialPropertyVector& right)
{
if (this == &right) return *this;
for(unsigned i=0; i<m_MPV.size(); ++i)
delete m_MPV[i];
m_MPV.clear();
m_NumEntries = 0;
m_CurrentEntry = -1;
for(int i = 0 ; i < right.m_NumEntries; i++)
{
GeoMPVEntry *newElement = new GeoMPVEntry(right.GetEntry(i));
m_MPV.push_back(newElement);
m_NumEntries++;
}
return *this;
}
GeoMaterialPropertyVector::GeoMaterialPropertyVector(double *PhotonMomenta,
double *PropertyValues,
int NumElements)
{
m_NumEntries = 0;
m_CurrentEntry = -1;
for(int i = 0; i < NumElements; i++)
AddElement(PhotonMomenta[i], PropertyValues[i]);
}
GeoMaterialPropertyVector::GeoMaterialPropertyVector(const GeoMaterialPropertyVector &right)
{
m_NumEntries = 0;
m_CurrentEntry = -1;
for(int i = 0 ; i < right.m_NumEntries; i++)
{
GeoMPVEntry *newElement = new GeoMPVEntry(right.GetEntry(i));
m_MPV.push_back(newElement);
m_NumEntries++;
}
}
GeoMaterialPropertyVector::~GeoMaterialPropertyVector()
{
for(unsigned i=0; i<m_MPV.size(); ++i)
delete m_MPV[i];
m_MPV.clear();
}
void GeoMaterialPropertyVector::ResetIterator()
{
m_CurrentEntry = -1;
}
void GeoMaterialPropertyVector::AddElement(double aPhotonMomentum,
double aPropertyValue)
{
GeoMPVEntry *newElement;
newElement = new GeoMPVEntry(aPhotonMomentum, aPropertyValue);
m_MPV.push_back(newElement);
m_NumEntries++;
}
double GeoMaterialPropertyVector::GetProperty() const
{
if(m_CurrentEntry == -1 || m_CurrentEntry >= m_NumEntries)
throw std::runtime_error("GeoMaterialPropertyVector::GetProperty ==>Iterator attempted to Retrieve Property out of range");
else
return m_MPV[m_CurrentEntry]->GetProperty();
}
double GeoMaterialPropertyVector::GetPhotonMomentum() const
{
if(m_CurrentEntry == -1 || m_CurrentEntry >= m_NumEntries)
throw std::runtime_error("GeoMaterialPropertyVector::GetPhotonMomentum ==>Iterator attempted to Retrieve Photon Momentum out of range");
else
return m_MPV[m_CurrentEntry]->GetPhotonMomentum();
}
void GeoMaterialPropertyVector::DumpVector()
{
if (m_MPV.empty())
{
std::cerr << "nothing to dump\n";
throw std::runtime_error("GeoMaterialPropertyVector::DumpVector ==>Nothing to dump! Vector is empty");
}
for (int i = 0; i < m_NumEntries; i++)
{
std::cout << "m_MPV["<< i << "]: ";
m_MPV[i]->DumpEntry();
}
std::cout << " Done DumpVector of " << m_NumEntries << " entries\n";
}
GeoMPVEntry GeoMaterialPropertyVector::GetEntry(int i) const
{
return *m_MPV[i];
}
......@@ -44,7 +44,7 @@ include(${Geant4_USE_FILE})
add_library( GeoModel2G4 SHARED ${HEADERS} ${SOURCES} )
target_link_libraries( GeoModel2G4
PUBLIC ${GEANT4_LIBRARIES}
PRIVATE ${CLHEP_LIBRARIES} GeoMaterial2G4 GeoModelUtilities )
PRIVATE ${CLHEP_LIBRARIES} GeoMaterial2G4 )
target_include_directories( GeoModel2G4 SYSTEM PUBLIC ${GEANT4_INCLUDE_DIRS} PRIVATE ${CLHEP_INCLUDE_DIRS} ${GeoModelCore_INCLUDE_DIRS} )
target_include_directories( GeoModel2G4 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
......
# GeoModelG4
GeoModelG4 contains tools to interface GeoModel with the [Geant4](https://geant4.web.cern.ch) detector simulation toolkit.
```bash
cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=RelWithDebInfo ../GeoModelG4/
make
make install
```
**NOTE:** If you experience issues with CMake not finding Geant4 properly, try to pass the Geant4 lib installation dir to CMake, to let it correctly find the Geant4Config.cmake file:
```bash
cmake -DGeant4_DIR=<path_to_geant4_install_dir>/lib/Geant4-10.5.0/ -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=RelWithDebInfo ../GeoModelG4/
```
Alternatively, you can source the Geant4 setup, before running cmake:
```bash
source <path_to_geant4_install_dir>/bin/geant4.sh
cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=RelWithDebInfo ../GeoModelG4
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment