00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id: G4Material.hh,v 1.25 2006/06/29 19:11:13 gunter Exp $ 00028 // GEANT4 tag $Name: geant4-09-01-patch-01 $ 00029 // 00030 00031 // class description 00032 // 00033 // Materials defined via the G4Material class are used to define the 00034 // composition of Geant volumes. 00035 // a Material is always made of Elements. It can be defined directly 00036 // from scratch (defined by an implicit, single element), specifying : 00037 // its name, 00038 // density, 00039 // state informations, 00040 // and Z,A of the underlying Element. 00041 // 00042 // or in terms of a collection of constituent Elements with specified weights 00043 // (composition specified either by fractional mass or atom counts). 00044 // 00045 // Quantities, with physical meaning or not, which are constant in a given 00046 // material are computed and stored here as Derived data members. 00047 // 00048 // The class contains as a private static member the Table of defined 00049 // materials (an ordered vector of materials). 00050 // 00051 00052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 00053 00054 // 10-07-96, new data members added by L.Urban 00055 // 12-12-96, new data members added by L.Urban 00056 // 20-01-97, aesthetic rearrangement. RadLength calculation modified 00057 // Data members Zeff and Aeff REMOVED (i.e. passed to the Elements). 00058 // (local definition of Zeff in DensityEffect and FluctModel...) 00059 // Vacuum defined as a G4State. Mixture flag removed, M.Maire 00060 // 29-01-97, State=Vacuum automatically set density=0 in the contructors. 00061 // Subsequent protections have been put in the calculation of 00062 // MeanExcEnergy, ShellCorrectionVector, DensityEffect, M.Maire 00063 // 20-03-97, corrected initialization of pointers, M.Maire 00064 // 10-06-97, new data member added by V.Grichine (fSandiaPhotoAbsCof) 00065 // 27-06-97, new function GetElement(int), M.Maire 00066 // 24-02-98, fFractionVector become fMassFractionVector 00067 // 28-05-98, kState=kVacuum removed: 00068 // The vacuum is an ordinary gas vith very low density, M.Maire 00069 // 12-06-98, new method AddMaterial() allowing mixture of materials, M.Maire 00070 // 09-07-98, Ionisation parameters removed from the class, M.Maire 00071 // 04-08-98, new method GetMaterial(materialName), M.Maire 00072 // 05-10-98, change name: NumDensity -> NbOfAtomsPerVolume 00073 // 18-11-98, SandiaTable interface modified. 00074 // 19-07-99, new data member (chemicalFormula) added by V.Ivanchenko 00075 // 12-03-01, G4bool fImplicitElement (mma) 00076 // 30-03-01, suppression of the warning message in GetMaterial 00077 // 17-07-01, migration to STL. M. Verderi. 00078 // 14-09-01, Suppression of the data member fIndexInTable 00079 // 31-10-01, new function SetChemicalFormula() (mma) 00080 // 26-02-02, fIndexInTable renewed 00081 // 06-08-02, remove constructors with ChemicalFormula (mma) 00082 // 15-11-05, GetMaterial(materialName, G4bool warning=true) 00083 00084 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 00085 00086 #ifndef G4MATERIAL_HH 00087 #define G4MATERIAL_HH 00088 00089 #include "globals.hh" 00090 #include "G4ios.hh" 00091 #include <vector> 00092 #include "G4Element.hh" 00093 #include "G4MaterialPropertiesTable.hh" 00094 #include "G4IonisParamMat.hh" 00095 #include "G4SandiaTable.hh" 00096 #include "G4ElementVector.hh" 00097 #include "G4MaterialTable.hh" 00098 00099 enum G4State { kStateUndefined, kStateSolid, kStateLiquid, kStateGas }; 00100 00101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 00102 00103 class G4Material 00104 { 00105 public: // with description 00106 00107 // 00108 // Constructor to create a material from scratch. 00109 // 00110 G4Material(const G4String& name, //its name 00111 G4double z, //atomic number 00112 G4double a, //mass of mole 00113 G4double density, //density 00114 G4State state = kStateUndefined, //solid,gas 00115 G4double temp = STP_Temperature, //temperature 00116 G4double pressure = STP_Pressure); //pressure 00117 00118 // 00119 // Constructor to create a material from a combination of elements 00120 // and/or materials subsequently added via AddElement and/or AddMaterial 00121 // 00122 G4Material(const G4String& name, //its name 00123 G4double density, //density 00124 G4int nComponents, //nbOfComponents 00125 G4State state = kStateUndefined, //solid,gas 00126 G4double temp = STP_Temperature, //temperature 00127 G4double pressure = STP_Pressure); //pressure 00128 00129 // 00130 // Add an element, giving number of atoms 00131 // 00132 void AddElement(G4Element* element, //the element 00133 G4int nAtoms); //nb of atoms in 00134 // a molecule 00135 // 00136 // Add an element or material, giving fraction of mass 00137 // 00138 void AddElement (G4Element* element , //the element 00139 G4double fraction); //fractionOfMass 00140 00141 void AddMaterial(G4Material* material, //the material 00142 G4double fraction); //fractionOfMass 00143 00144 00145 virtual ~G4Material(); 00146 00147 void SetChemicalFormula(const G4String& chF) {fChemicalFormula=chF;}; 00148 00149 // 00150 // retrieval methods 00151 // 00152 G4String GetName() const {return fName;}; 00153 G4String GetChemicalFormula() const {return fChemicalFormula;}; 00154 G4double GetDensity() const {return fDensity;}; 00155 00156 G4State GetState() const {return fState;}; 00157 G4double GetTemperature() const {return fTemp;}; 00158 G4double GetPressure() const {return fPressure;}; 00159 00160 //number of elements constituing this material: 00161 size_t GetNumberOfElements() const {return fNumberOfElements;}; 00162 00163 //vector of pointers to elements constituing this material: 00164 const 00165 G4ElementVector* GetElementVector() const {return theElementVector;}; 00166 00167 //vector of fractional mass of each element: 00168 const G4double* GetFractionVector() const {return fMassFractionVector;}; 00169 00170 //vector of atom count of each element: 00171 const G4int* GetAtomsVector() const {return fAtomsVector;}; 00172 00173 //return a pointer to an element, given its index in the material: 00174 const 00175 G4Element* GetElement(G4int iel) const {return (*theElementVector)[iel];}; 00176 00177 //vector of nb of atoms per volume of each element in this material: 00178 const 00179 G4double* GetVecNbOfAtomsPerVolume() const {return VecNbOfAtomsPerVolume;}; 00180 //total number of atoms per volume: 00181 G4double GetTotNbOfAtomsPerVolume() const {return TotNbOfAtomsPerVolume;}; 00182 //total number of electrons per volume: 00183 G4double GetTotNbOfElectPerVolume() const {return TotNbOfElectPerVolume;}; 00184 00185 //obsolete names (5-10-98) see the 2 functions above 00186 const 00187 G4double* GetAtomicNumDensityVector() const {return VecNbOfAtomsPerVolume;}; 00188 G4double GetElectronDensity() const {return TotNbOfElectPerVolume;}; 00189 00190 // Radiation length: 00191 G4double GetRadlen() const {return fRadlen;}; 00192 00193 // Nuclear interaction length: 00194 G4double GetNuclearInterLength() const {return fNuclInterLen;}; 00195 00196 // ionisation parameters: 00197 G4IonisParamMat* GetIonisation() const {return fIonisation;}; 00198 00199 // Sandia table: 00200 G4SandiaTable* GetSandiaTable() const {return fSandiaTable;}; 00201 00202 //meaningful only for single material: 00203 G4double GetZ() const; 00204 G4double GetA() const; 00205 00206 //the MaterialPropertiesTable (if any) attached to this material: 00207 void SetMaterialPropertiesTable(G4MaterialPropertiesTable* anMPT) 00208 {fMaterialPropertiesTable = anMPT;}; 00209 00210 G4MaterialPropertiesTable* GetMaterialPropertiesTable() const 00211 {return fMaterialPropertiesTable;}; 00212 00213 //the (static) Table of Materials: 00214 // 00215 static 00216 const G4MaterialTable* GetMaterialTable(); 00217 00218 static 00219 size_t GetNumberOfMaterials(); 00220 00221 //the index of this material in the Table: 00222 size_t GetIndex() const {return fIndexInTable;}; 00223 00224 //return pointer to a material, given its name: 00225 static G4Material* GetMaterial(G4String name, G4bool warning=true); 00226 00227 // 00228 //printing methods 00229 // 00230 friend std::ostream& operator<<(std::ostream&, G4Material*); 00231 friend std::ostream& operator<<(std::ostream&, G4Material&); 00232 friend std::ostream& operator<<(std::ostream&, G4MaterialTable); 00233 00234 public: // without description 00235 00236 G4int operator==(const G4Material&) const; 00237 G4int operator!=(const G4Material&) const; 00238 G4Material(__void__&); 00239 // Fake default constructor for usage restricted to direct object 00240 // persistency for clients requiring preallocation of memory for 00241 // persistifiable objects. 00242 00243 private: 00244 00245 G4Material(const G4Material&); 00246 const G4Material& operator=(const G4Material&); 00247 00248 void InitializePointers(); 00249 00250 // Header routine for all derived quantities 00251 void ComputeDerivedQuantities(); 00252 00253 // Compute Radiation length 00254 void ComputeRadiationLength(); 00255 00256 // Compute Nuclear interaction length 00257 void ComputeNuclearInterLength(); 00258 00259 private: 00260 00261 // 00262 // Basic data members ( To define a material) 00263 // 00264 00265 G4String fName; // Material name 00266 G4String fChemicalFormula; // Material chemical formula 00267 G4double fDensity; // Material density 00268 00269 G4State fState; // Material state (determined 00270 // internally based on density) 00271 G4double fTemp; // Temperature (defaults: STP) 00272 G4double fPressure; // Pressure (defaults: STP) 00273 00274 G4int maxNbComponents; // totalNbOfComponentsInTheMaterial 00275 size_t fNumberOfComponents; // Nb of components declared so far 00276 00277 size_t fNumberOfElements; // Nb of Elements in the material 00278 G4ElementVector* theElementVector; // vector of constituent Elements 00279 G4bool fImplicitElement; // implicit Element created by this? 00280 G4double* fMassFractionVector; // composition by fractional mass 00281 G4int* fAtomsVector; // composition by atom count 00282 00283 G4MaterialPropertiesTable* fMaterialPropertiesTable; 00284 00285 static 00286 G4MaterialTable theMaterialTable; // the material table 00287 size_t fIndexInTable; // the position in the table 00288 00289 // 00290 // Derived data members (computed from the basic data members) 00291 // 00292 // some general atomic properties 00293 00294 G4double* VecNbOfAtomsPerVolume; // vector of nb of atoms per volume 00295 G4double TotNbOfAtomsPerVolume; // total nb of atoms per volume 00296 G4double TotNbOfElectPerVolume; // total nb of electrons per volume 00297 G4double fRadlen; // Radiation length 00298 G4double fNuclInterLen; // Nuclear interaction length 00299 00300 G4IonisParamMat* fIonisation; // ionisation parameters 00301 G4SandiaTable* fSandiaTable; // Sandia table 00302 }; 00303 00304 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 00305 00306 inline 00307 G4double G4Material::GetZ() const 00308 { 00309 if (fNumberOfElements > 1) { 00310 G4cerr << "WARNING in GetZ. The material: " << fName << " is a mixture." 00311 << G4endl; 00312 G4Exception ( " the Atomic number is not well defined." ); 00313 } 00314 return (*theElementVector)[0]->GetZ(); 00315 } 00316 00317 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 00318 00319 inline 00320 G4double G4Material::GetA() const 00321 { 00322 if (fNumberOfElements > 1) { 00323 G4cerr << "WARNING in GetA. The material: " << fName << " is a mixture." 00324 << G4endl; 00325 G4Exception ( " the Atomic mass is not well defined." ); 00326 } 00327 return (*theElementVector)[0]->GetA(); 00328 } 00329 00330 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 00331 00332 #endif
1.4.7