8#include <geometry/Materials.h>
9#include <gtest/gtest.h>
13#include <framework/gearbox/Gearbox.h>
14#include <framework/gearbox/GearDir.h>
15#include <framework/utilities/TestHelpers.h>
17#include <G4Element.hh>
18#include <G4Material.hh>
19#include <G4OpticalSurface.hh>
20#include <G4MaterialPropertiesTable.hh>
36 G4Element* e1 = m.getElement(
"H");
38 EXPECT_EQ(
"H", e1->GetName());
39 EXPECT_EQ(
"H", e1->GetSymbol());
40 EXPECT_EQ(1., e1->GetZ());
52 EXPECT_EQ(
"G4_AIR", m1->GetName());
62 vector<string> backends;
63 backends.emplace_back(
"string:<Material name='Test'><state>Gas</state><Components>"
64 "<Material fraction='1.5'>Si</Material>"
65 "<Material fraction='2.5612'>Au</Material>"
66 "</Components></Material>");
75 G4Material* mat = m.createMaterial(
GearDir(
"/Material"));
77 EXPECT_EQ(
"Test", mat->GetName());
78 EXPECT_DOUBLE_EQ((2.5612 * au->GetDensity() + 1.5 * si->GetDensity()) / 4.0612, mat->GetDensity());
87 vector<string> backends;
88 backends.emplace_back(
"string:<Material name='Test1'><state>Solid</state><Components>"
89 "<Material fraction='0.5'>Si</Material>"
90 "<Element fraction='0.5'>Au</Element>"
91 "</Components></Material>");
96 G4Material* mat = m.createMaterial(
GearDir(
"/Material"));
106 vector<string> backends;
107 backends.emplace_back(
"string:<Material name='Test2'><state>Liquid</state><density>1</density><Components>"
108 "<Material>Si</Material>"
109 "<Element>Au</Element>"
110 "</Components></Material>");
115 G4Material* mat = m.createMaterial(
GearDir(
"/Material"));
125 vector<string> backends;
126 backends.emplace_back(
"string:<Material name='Test3'><Components>"
127 "<Material>Foo</Material>"
128 "</Components></Material>");
133 G4Material* mat = m.createMaterial(
GearDir(
"/Material"));
143 vector<string> backends;
144 backends.emplace_back(
"string:<Material name='Test4'><density>1</density><Components>"
145 "<Element>Foo</Element>"
146 "</Components></Material>");
151 G4Material* mat = m.createMaterial(
GearDir(
"/Material"));
161 vector<string> backends;
162 backends.emplace_back(
"string:<test><Surface/>"
163 "<Surface name='test'><Model>unified</Model><Finish>Ground</Finish>"
164 "<Type>x_ray</Type><Value>2.0</Value></Surface>"
165 "<Surface><Model>not existing</Model></Surface>"
166 "<Surface><Finish>not existing</Finish></Surface>"
167 "<Surface><Type>not existing</Type></Surface></test>"
174 G4OpticalSurface* surf1 = m.createOpticalSurface(
GearDir(
"/test/Surface[1]"));
176 EXPECT_EQ(
"OpticalSurface", surf1->GetName());
177 EXPECT_EQ(glisur, surf1->GetModel());
178 EXPECT_EQ(polished, surf1->GetFinish());
179 EXPECT_EQ(dielectric_dielectric, surf1->GetType());
180 EXPECT_EQ(1.0, surf1->GetPolish());
182 G4OpticalSurface* surf2 = m.createOpticalSurface(
GearDir(
"/test/Surface[2]"));
184 EXPECT_EQ(
"test", surf2->GetName());
185 EXPECT_EQ(unified, surf2->GetModel());
186 EXPECT_EQ(ground, surf2->GetFinish());
187 EXPECT_EQ(x_ray, surf2->GetType());
188 EXPECT_EQ(2.0, surf2->GetSigmaAlpha());
190 EXPECT_B2FATAL(m.createOpticalSurface(
GearDir(
"/test/Surface[3]")));
191 EXPECT_B2FATAL(m.createOpticalSurface(
GearDir(
"/test/Surface[4]")));
192 EXPECT_B2FATAL(m.createOpticalSurface(
GearDir(
"/test/Surface[5]")));
200 vector<string> backends;
201 backends.emplace_back(
"string:<Material name='TestProperties'>"
202 "<Components><Material>Si</Material></Components>"
203 "<Property name='RINDEX' unit='eV'>"
204 "<value energy='1.0'>1.40</value>"
205 "<value energy='1.5'>1.41</value>"
206 "<value energy='2.0'>1.42</value>"
207 "<value energy='3.5'>1.43</value>"
214 G4Material* mat = m.createMaterial(
GearDir(
"/Material"));
216 G4MaterialPropertiesTable* properties = mat->GetMaterialPropertiesTable();
217 ASSERT_TRUE(properties);
218 G4MaterialPropertyVector*
property = properties->GetProperty(
"RINDEX");
219 ASSERT_TRUE(property);
220 EXPECT_EQ(4u, property->GetVectorLength());
221 EXPECT_DOUBLE_EQ(1.40, property->GetMinValue());
222 EXPECT_DOUBLE_EQ(1.43, property->GetMaxValue());
223 EXPECT_DOUBLE_EQ(1 * CLHEP::eV, property->GetMinEnergy());
224 EXPECT_DOUBLE_EQ(3.5 * CLHEP::eV, property->GetMaxEnergy());
225 EXPECT_DOUBLE_EQ(1.0 * CLHEP::eV, property->Energy(0));
226 EXPECT_DOUBLE_EQ(1.5 * CLHEP::eV, property->Energy(1));
227 EXPECT_DOUBLE_EQ(2.0 * CLHEP::eV, property->Energy(2));
228 EXPECT_DOUBLE_EQ(3.5 * CLHEP::eV, property->Energy(3));
229 EXPECT_DOUBLE_EQ(1.40, (*property)[0]);
230 EXPECT_DOUBLE_EQ(1.41, (*property)[1]);
231 EXPECT_DOUBLE_EQ(1.42, (*property)[2]);
232 EXPECT_DOUBLE_EQ(1.43, (*property)[3]);
GearDir is the basic class used for accessing the parameter store.
Singleton class responsible for loading detector parameters from an XML file.
virtual int getNumberNodes(const std::string &path="") const override
Return the number of nodes a given path will expand to.
Thin wrapper around the Geant4 Material system.
static G4Material * get(const std::string &name)
Find given material.
static Materials & getInstance()
Get a reference to the singleton instance.
static Gearbox & getInstance()
Return reference to the Gearbox instance.
void close()
Free internal structures of previously parsed tree and clear cache.
void setBackends(const std::vector< std::string > &backends)
Select the backends to use to find resources.
void open(const std::string &name="Belle2.xml", size_t cacheSize=c_DefaultCacheSize)
Open connection to backend and parse tree.
Abstract base class for different kinds of events.