27#include "G4PhysicalConstants.hh"
28#include "G4SystemOfUnits.hh"
33 :
VGM::IMaterial(), fMaterial(0)
44 std::cerr <<
" Geant4GM::Material::Material: " << std::endl;
45 std::cerr <<
" No element defined.";
46 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
56 if (density < universe_mean_density || isVacuum) {
58 density = universe_mean_density;
61 fMaterial =
new G4Material(
62 name, density, 1, kStateGas, 2.73 * kelvin, 3.e-18 * pascal);
66 fMaterial =
new G4Material(name, density, 1);
71 fMaterial->AddElement(g4Element, 1.);
77 double pressure,
bool isVacuum)
78 :
VGM::IMaterial(), fMaterial(0)
92 std::cerr <<
" Geant4GM::Material::Material: " << std::endl;
93 std::cerr <<
" No element defined.";
94 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
102 G4State g4State = GetG4State(state);
107 if (density < universe_mean_density || isVacuum) {
109 density = universe_mean_density;
112 fMaterial =
new G4Material(
113 name, density, 1, kStateGas, 2.73 * kelvin, 3.e-18 * pascal);
118 new G4Material(name, density, 1, g4State, temperature, pressure);
123 fMaterial->AddElement(g4Element, 1.);
129 :
VGM::IMaterial(), fMaterial(0)
142 if (!elements.size()) {
143 std::cerr <<
" Geant4GM::Material::Material: " << std::endl;
144 std::cerr <<
" No elements defined.";
145 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
150 if (elements.size() != fractions.size()) {
151 std::cerr <<
" Geant4GM::Material::Material: " << std::endl;
152 std::cerr <<
" Elements size and fractions size differ.";
153 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
161 if (density < universe_mean_density) {
163 density = universe_mean_density;
167 fMaterial =
new G4Material(name, density, elements.size());
170 for (
unsigned int i = 0; i < elements.size(); i++) {
172 fMaterial->AddElement(g4Element, fractions[i]);
180 :
VGM::IMaterial(), fMaterial(0)
196 if (!elements.size()) {
197 std::cerr <<
" Geant4GM::Material::Material: " << std::endl;
198 std::cerr <<
" No elements defined.";
199 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
204 if (elements.size() != fractions.size()) {
205 std::cerr <<
" Geant4GM::Material::Material: " << std::endl;
206 std::cerr <<
" Elements size and fractions size differ.";
207 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
215 G4State g4State = GetG4State(state);
218 if (density < universe_mean_density) {
220 density = universe_mean_density;
224 fMaterial =
new G4Material(
225 name, density, elements.size(), g4State, temperature, pressure);
228 for (
unsigned int i = 0; i < elements.size(); i++) {
230 fMaterial->AddElement(g4Element, fractions[i]);
237 :
VGM::IMaterial(), fMaterial(0)
250 if (!elements.size()) {
251 std::cerr <<
" Geant4GM::Material::Material: " << std::endl;
252 std::cerr <<
" No elements defined.";
253 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
258 if (elements.size() != atomCounts.size()) {
259 std::cerr <<
" Geant4GM::Material::Material: " << std::endl;
260 std::cerr <<
" Elements size and atomCounts size differ.";
261 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
269 if (density < universe_mean_density) {
271 density = universe_mean_density;
275 fMaterial =
new G4Material(name, density, elements.size());
278 for (
unsigned int i = 0; i < elements.size(); i++) {
280 fMaterial->AddElement(g4Element, atomCounts[i]);
288 :
VGM::IMaterial(), fMaterial(0)
304 if (!elements.size()) {
305 std::cerr <<
" Geant4GM::Material::Material: " << std::endl;
306 std::cerr <<
" No elements defined.";
307 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
312 if (elements.size() != atomCounts.size()) {
313 std::cerr <<
" Geant4GM::Material::Material: " << std::endl;
314 std::cerr <<
" Elements size and atomCounts size differ.";
315 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
323 G4State g4State = GetG4State(state);
326 if (density < universe_mean_density) {
328 density = universe_mean_density;
332 fMaterial =
new G4Material(
333 name, density, elements.size(), g4State, temperature, pressure);
336 for (
unsigned int i = 0; i < elements.size(); i++) {
338 fMaterial->AddElement(g4Element, atomCounts[i]);
344 :
VGM::IMaterial(), fMaterial(material)
372void Geant4GM::Material::CheckIndex(
int iel)
const
374 if (iel < 0 || iel >= NofElements()) {
375 std::cerr <<
" Geant4GM::Material::CheckIndex: " << std::endl;
376 std::cerr <<
" In material: " << Name() << std::endl;
377 std::cerr <<
" Index of element " << iel <<
" outside limits."
379 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
389 return kStateUndefined;
397 return kStateUndefined;
400 return kStateUndefined;
407 case kStateUndefined:
450 return GetVGMState(fMaterial->GetState());
468 return fMaterial->GetNumberOfElements();
476 G4Element* g4Element =
const_cast<G4Element*
>((*fMaterial->GetElementVector())[iel]);
485 return fMaterial->GetFractionVector()[iel];
493 if (NofElements() == 1)
return 1.0;
495 return fMaterial->GetVecNbOfAtomsPerVolume()[iel] /
496 fMaterial->GetTotNbOfAtomsPerVolume();
static double Temperature()
Return CLHEP default temperature unit in VGM unit.
static double MassDensity()
Return CLHEP default mass density unit in VGM units.
static double Pressure()
Return CLHEP default pressure unit in VGM unit.
static double Length()
Return CLHEP default length unit in VGM units.
static ElementMap * Instance()
G4Element * GetElement(VGM::IElement *iElement) const
VGM implementation for Geant4 material.
virtual double MassFraction(int iel) const
Return the mass fraction of the i-th element constituing this material.
virtual VGM::IElement * Element(int iel) const
Return the i-th element constituing this material.
virtual double Pressure() const
Return the density in atmosphere.
virtual double Temperature() const
Return the temperature in kelvins.
virtual double Density() const
Return the density in g/cm3.
virtual std::string Name() const
Return the name of this element.
virtual double AtomCount(int iel) const
Return the atom count of the i-th element constituing this material.
virtual VGM::MaterialState State() const
Return the material state.
virtual double RadiationLength() const
Return the radiation length in mm.
virtual double NuclearInterLength() const
Return the nuclear interaction length in mm.
virtual int NofElements() const
Return the number of elements constituing this material.
The VGM interface to elements.
std::vector< int > AtomCountVector
std::vector< double > MassFractionVector
std::vector< IElement * > ElementVector
@ kLiquid
Liquid material.
@ kUndefined
Undefined material state.