source: trunk/examples/extended/field/field04/src/F04Materials.cc

Last change on this file was 1230, checked in by garnier, 15 years ago

update to geant4.9.3

File size: 3.2 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27//
28
29#include "F04Materials.hh"
30
31F04Materials::F04Materials()
32{
33  nistMan = G4NistManager::Instance();
34
35  nistMan->SetVerbose(2);
36
37  CreateMaterials();
38}
39
40F04Materials::~F04Materials()
41{
42  delete    Vacuum;
43  delete    Air;
44  delete    Sci;
45  delete    BeO;
46}
47
48F04Materials* F04Materials::instance = 0;
49
50F04Materials* F04Materials::GetInstance()
51{
52  if (instance == 0)
53    {
54      instance = new F04Materials();
55    }
56  return instance;
57}
58
59G4Material* F04Materials::GetMaterial(const G4String material) 
60{
61  G4Material* mat =  nistMan->FindOrBuildMaterial(material);
62
63  if (!mat) mat = G4Material::GetMaterial(material);
64  if (!mat) {G4cout << material << "Not Found, Please Retry"<< G4endl;}
65
66  return mat;
67}
68
69void F04Materials::CreateMaterials()
70{
71  G4double density;           
72  std::vector<G4int>  natoms;
73  std::vector<G4double> fractionMass;
74  std::vector<G4String> elements;
75
76  // Materials Definitions
77  // =====================
78
79  // Define Vacuum
80
81  Vacuum = nistMan->FindOrBuildMaterial("G4_Galactic");
82
83  // Define Air
84
85  Air = nistMan->FindOrBuildMaterial("G4_AIR");
86
87  // Define BeO
88
89  BeO = nistMan->FindOrBuildMaterial("G4_BERYLLIUM_OXIDE");
90
91  // Define Scintillator
92
93  elements.push_back("C");     natoms.push_back(9);
94  elements.push_back("H");     natoms.push_back(10);
95
96  density = 1.032*g/cm3;;
97
98  Sci = nistMan->
99          ConstructNewMaterial("Scintillator", elements, natoms, density);
100
101  elements.clear();
102  natoms.clear();
103
104  G4cout << G4endl << "The materials defined are: " << G4endl << G4endl;
105 
106  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
107}
Note: See TracBrowser for help on using the repository browser.