ATLAS Offline Software
Loading...
Searching...
No Matches
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
8
9#include <iostream>
10
16
17void
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 }
25}
26void
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 }
34}
35
37AGDDMaterialStore::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}
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
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
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
82void 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
90void 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}
void RegisterElement(AGDDElement *)
AGDDMaterialMap m_theMaterials
void RegisterMaterial(AGDDSimpleMaterial *)
AGDDSimpleMaterial * GetMaterial(std::string_view)
void PrintElement(const std::string &n)
AGDDElementMap m_theElements
AGDDElement * GetElement(std::string_view)
void PrintMaterial(const std::string &n)