ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DetectorDescription
AGDD
AGDDModel
src
AGDDMaterialStore.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
AGDDModel/AGDDSimpleMaterial.h
"
6
#include "
AGDDModel/AGDDElement.h
"
7
#include "
AGDDModel/AGDDMaterialStore.h
"
8
9
#include <iostream>
10
11
AGDDMaterialStore::AGDDMaterialStore
():
m_nrOfMaterials
(0),
m_nrOfElements
(0)
12
{
13
m_theMaterials
.clear();
14
m_theElements
.clear();
15
}
16
17
void
18
AGDDMaterialStore::RegisterElement
(
AGDDElement
* el){
19
const
auto
&[it, inserted] =
m_theElements
.try_emplace(el->GetName(), el);
20
if
(!inserted) {
21
std::cout <<
"Element "
<< el->GetName()<<
" already defined: skipping\n"
;
22
return
;
23
}
24
++
m_nrOfElements
;
25
}
26
void
27
AGDDMaterialStore::RegisterMaterial
(
AGDDSimpleMaterial
* mat){
28
const
auto
&[it, inserted] =
m_theMaterials
.try_emplace(mat->GetName(), mat);
29
if
(!inserted) {
30
std::cout <<
"Material "
<< mat->GetName() <<
" already defined: skipping\n"
;
31
return
;
32
}
33
++
m_nrOfMaterials
;
34
}
35
36
AGDDSimpleMaterial
*
37
AGDDMaterialStore::GetMaterial
(std::string_view mat){
38
const
auto
it =
m_theMaterials
.find(mat);
39
if
(it ==
m_theMaterials
.end()) {
40
std::cout <<
" Material "
<< mat <<
" not found!\n"
;
41
return
nullptr
;
42
}
43
return
it->second;
44
}
45
AGDDElement
*
AGDDMaterialStore::GetElement
(std::string_view el){
46
const
auto
it =
m_theElements
.find(el);
47
if
(it ==
m_theElements
.end()){
48
std::cout<<
" Element "
<<el<<
" not found!"
<<std::endl;
49
return
nullptr
;
50
}
51
return
it->second;
52
}
53
54
void
AGDDMaterialStore::PrintElementNames
()
55
{
56
std::cout<<
"List of elements so far defined: "
<<
57
std::endl<<
"-----> "
;
58
AGDDElementMap::const_iterator it;
59
int
i=0;
60
for
(it=
m_theElements
.begin();it!=
m_theElements
.end();++it)
61
{
62
i++;
63
if
(!(i%5)) std::cout<<std::endl<<
"-----> "
;
64
std::cout<<(*it).first<<
","
;
65
}
66
}
67
68
void
AGDDMaterialStore::PrintMaterialNames
()
69
{
70
std::cout<<
"List of materials so far defined: "
<<
71
std::endl<<
"-----> "
;
72
AGDDMaterialMap::const_iterator it;
73
int
i=0;
74
for
(it=
m_theMaterials
.begin();it!=
m_theMaterials
.end();++it)
75
{
76
i++;
77
if
(!(i%5)) std::cout<<std::endl<<
"-----> "
;
78
std::cout<<(*it).first<<
","
;
79
}
80
}
81
82
void
AGDDMaterialStore::PrintElement
(
const
std::string& n)
83
{
84
if
(
m_theElements
.find(n)!=
m_theElements
.end())
85
std::cout<<*(
m_theElements
[n]);
86
else
87
std::cout<<
"Element "
<<n<<
" not found!"
<<std::endl;
88
}
89
90
void
AGDDMaterialStore::PrintMaterial
(
const
std::string& n)
91
{
92
if
(
m_theMaterials
.find(n)!=
m_theMaterials
.end())
93
std::cout<<*(
m_theMaterials
[n]);
94
else
95
std::cout<<
"Material "
<<n<<
" not found!"
<<std::endl;
96
}
AGDDElement.h
AGDDMaterialStore.h
AGDDSimpleMaterial.h
AGDDElement
Definition
AGDDElement.h:11
AGDDMaterialStore::RegisterElement
void RegisterElement(AGDDElement *)
Definition
AGDDMaterialStore.cxx:18
AGDDMaterialStore::PrintElementNames
void PrintElementNames()
Definition
AGDDMaterialStore.cxx:54
AGDDMaterialStore::m_theMaterials
AGDDMaterialMap m_theMaterials
Definition
AGDDMaterialStore.h:46
AGDDMaterialStore::RegisterMaterial
void RegisterMaterial(AGDDSimpleMaterial *)
Definition
AGDDMaterialStore.cxx:27
AGDDMaterialStore::m_nrOfMaterials
int m_nrOfMaterials
Definition
AGDDMaterialStore.h:49
AGDDMaterialStore::m_nrOfElements
int m_nrOfElements
Definition
AGDDMaterialStore.h:50
AGDDMaterialStore::GetMaterial
AGDDSimpleMaterial * GetMaterial(std::string_view)
Definition
AGDDMaterialStore.cxx:37
AGDDMaterialStore::PrintElement
void PrintElement(const std::string &n)
Definition
AGDDMaterialStore.cxx:82
AGDDMaterialStore::m_theElements
AGDDElementMap m_theElements
Definition
AGDDMaterialStore.h:47
AGDDMaterialStore::AGDDMaterialStore
AGDDMaterialStore()
Definition
AGDDMaterialStore.cxx:11
AGDDMaterialStore::PrintMaterialNames
void PrintMaterialNames()
Definition
AGDDMaterialStore.cxx:68
AGDDMaterialStore::GetElement
AGDDElement * GetElement(std::string_view)
Definition
AGDDMaterialStore.cxx:45
AGDDMaterialStore::PrintMaterial
void PrintMaterial(const std::string &n)
Definition
AGDDMaterialStore.cxx:90
AGDDSimpleMaterial
Definition
AGDDSimpleMaterial.h:14
Generated on
for ATLAS Offline Software by
1.17.0