ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
GeoMaterial2G4
src
Geo2G4MatPropTableFactory.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CxxUtils/checker_macros.h
"
6
#include "
GeoMaterial2G4/Geo2G4MatPropTableFactory.h
"
7
#include "G4MaterialPropertiesTable.hh"
8
#include "G4MaterialPropertyVector.hh"
9
10
#include "
GeoModelUtilities/GeoMaterialPropertiesTable.h
"
11
#include "
GeoModelUtilities/GeoMaterialPropertyVector.h
"
12
13
#include <mutex>
14
#include <unordered_map>
15
16
namespace
{
17
typedef
std::unordered_map<const GeoMaterialPropertiesTable*, G4MaterialPropertiesTable*> TableMap;
18
}
19
20
21
G4MaterialPropertiesTable*
Geo2G4MatPropTableFactory::Build
(
const
GeoMaterialPropertiesTable
* thePropTable)
22
{
23
static
TableMap definedTables
ATLAS_THREAD_SAFE
;
24
25
// For now just use a global lock. If this turns out to be a bottleneck
26
// switch to a concurrent map or similar.
27
static
std::mutex tableMutex;
28
std::scoped_lock
lock
(tableMutex);
29
30
//
31
// Check if this material has already been defined.
32
//
33
const
auto
itr = definedTables.find(thePropTable);
34
if
(itr != definedTables.end())
35
return
itr->second;
36
37
G4MaterialPropertiesTable* newTable =
new
G4MaterialPropertiesTable();
38
39
// Add properties to the table ...
40
41
// 1. Const properties
42
GeoMaterialPropertiesTable::GeoMatPMap_ConstIt
it1_first = thePropTable->
beginPMap
();
43
GeoMaterialPropertiesTable::GeoMatPMap_ConstIt
it1_last = thePropTable->
endPMap
();
44
45
for
(;it1_first!=it1_last;++it1_first)
46
newTable->AddConstProperty((it1_first->first).c_str(),it1_first->second);
47
48
// 2. Vector properties
49
GeoMaterialPropertiesTable::GeoMatPVMap_ConstIt
it2_first = thePropTable->
beginPVMap
();
50
GeoMaterialPropertiesTable::GeoMatPVMap_ConstIt
it2_last = thePropTable->
endPVMap
();
51
52
for
(;it2_first!=it2_last;++it2_first)
53
{
54
GeoMaterialPropertyVector
* geoMPV = it2_first->second;
55
//from G4 9.6 G4MaterialPropertyVector is now a typedef of G4PhysicsOrderedFreeVector
56
G4MaterialPropertyVector* g4MPV =
new
G4MaterialPropertyVector();
57
58
geoMPV->
ResetIterator
();
59
60
while
((*geoMPV).operator++())
61
{
62
//g4MPV->AddElement(geoMPV->GetPhotonMomentum(),geoMPV->GetProperty()); // G4 9.4 syntax
63
//assume G4PhysicsOrderedFreeVector::InsertValues is equivalent to G4MaterialPropertyVector::AddElement
64
g4MPV->InsertValues(geoMPV->
GetPhotonMomentum
(),geoMPV->
GetProperty
());
// G4 9.6 syntax
65
}
66
67
newTable->AddProperty((it2_first->first).c_str(),g4MPV);
68
}
69
70
// Save new table to the map
71
definedTables[thePropTable]=newTable;
72
73
return
newTable;
74
}
Geo2G4MatPropTableFactory.h
GeoMaterialPropertiesTable.h
GeoMaterialPropertyVector.h
lock
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
checker_macros.h
Define macros for attributes used to control the static checker.
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition
checker_macros.h:211
Geo2G4MatPropTableFactory::Build
G4MaterialPropertiesTable * Build(const GeoMaterialPropertiesTable *)
Definition
Geo2G4MatPropTableFactory.cxx:21
GeoMaterialPropertiesTable
Definition
GeoMaterialPropertiesTable.h:20
GeoMaterialPropertiesTable::GeoMatPVMap_ConstIt
GeoMatPVMap::const_iterator GeoMatPVMap_ConstIt
Definition
GeoMaterialPropertiesTable.h:32
GeoMaterialPropertiesTable::endPMap
GeoMatPMap_ConstIt endPMap() const
Definition
GeoMaterialPropertiesTable.cxx:85
GeoMaterialPropertiesTable::beginPVMap
GeoMatPVMap_ConstIt beginPVMap() const
Definition
GeoMaterialPropertiesTable.cxx:70
GeoMaterialPropertiesTable::GeoMatPMap_ConstIt
GeoMatPMap::const_iterator GeoMatPMap_ConstIt
Definition
GeoMaterialPropertiesTable.h:33
GeoMaterialPropertiesTable::beginPMap
GeoMatPMap_ConstIt beginPMap() const
Definition
GeoMaterialPropertiesTable.cxx:80
GeoMaterialPropertiesTable::endPVMap
GeoMatPVMap_ConstIt endPVMap() const
Definition
GeoMaterialPropertiesTable.cxx:75
GeoMaterialPropertyVector
Definition
GeoMaterialPropertyVector.h:12
GeoMaterialPropertyVector::ResetIterator
void ResetIterator()
Definition
GeoMaterialPropertyVector.cxx:70
GeoMaterialPropertyVector::GetPhotonMomentum
double GetPhotonMomentum() const
Definition
GeoMaterialPropertyVector.cxx:93
GeoMaterialPropertyVector::GetProperty
double GetProperty() const
Definition
GeoMaterialPropertyVector.cxx:85
Generated on
for ATLAS Offline Software by
1.17.0