| 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 | // $Id: G4Material.hh,v 1.27 2008/11/14 15:14:24 gcosmo Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $
|
|---|
| 29 | //
|
|---|
| 30 |
|
|---|
| 31 | // class description
|
|---|
| 32 | //
|
|---|
| 33 | // Materials defined via the G4Material class are used to define the
|
|---|
| 34 | // composition of Geant volumes.
|
|---|
| 35 | // a Material is always made of Elements. It can be defined directly
|
|---|
| 36 | // from scratch (defined by an implicit, single element), specifying :
|
|---|
| 37 | // its name,
|
|---|
| 38 | // density,
|
|---|
| 39 | // state informations,
|
|---|
| 40 | // and Z,A of the underlying Element.
|
|---|
| 41 | //
|
|---|
| 42 | // or in terms of a collection of constituent Elements with specified weights
|
|---|
| 43 | // (composition specified either by fractional mass or atom counts).
|
|---|
| 44 | //
|
|---|
| 45 | // Quantities, with physical meaning or not, which are constant in a given
|
|---|
| 46 | // material are computed and stored here as Derived data members.
|
|---|
| 47 | //
|
|---|
| 48 | // The class contains as a private static member the Table of defined
|
|---|
| 49 | // materials (an ordered vector of materials).
|
|---|
| 50 | //
|
|---|
| 51 |
|
|---|
| 52 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 53 |
|
|---|
| 54 | // 10-07-96, new data members added by L.Urban
|
|---|
| 55 | // 12-12-96, new data members added by L.Urban
|
|---|
| 56 | // 20-01-97, aesthetic rearrangement. RadLength calculation modified
|
|---|
| 57 | // Data members Zeff and Aeff REMOVED (i.e. passed to the Elements).
|
|---|
| 58 | // (local definition of Zeff in DensityEffect and FluctModel...)
|
|---|
| 59 | // Vacuum defined as a G4State. Mixture flag removed, M.Maire
|
|---|
| 60 | // 29-01-97, State=Vacuum automatically set density=0 in the contructors.
|
|---|
| 61 | // Subsequent protections have been put in the calculation of
|
|---|
| 62 | // MeanExcEnergy, ShellCorrectionVector, DensityEffect, M.Maire
|
|---|
| 63 | // 20-03-97, corrected initialization of pointers, M.Maire
|
|---|
| 64 | // 10-06-97, new data member added by V.Grichine (fSandiaPhotoAbsCof)
|
|---|
| 65 | // 27-06-97, new function GetElement(int), M.Maire
|
|---|
| 66 | // 24-02-98, fFractionVector become fMassFractionVector
|
|---|
| 67 | // 28-05-98, kState=kVacuum removed:
|
|---|
| 68 | // The vacuum is an ordinary gas vith very low density, M.Maire
|
|---|
| 69 | // 12-06-98, new method AddMaterial() allowing mixture of materials, M.Maire
|
|---|
| 70 | // 09-07-98, Ionisation parameters removed from the class, M.Maire
|
|---|
| 71 | // 04-08-98, new method GetMaterial(materialName), M.Maire
|
|---|
| 72 | // 05-10-98, change name: NumDensity -> NbOfAtomsPerVolume
|
|---|
| 73 | // 18-11-98, SandiaTable interface modified.
|
|---|
| 74 | // 19-07-99, new data member (chemicalFormula) added by V.Ivanchenko
|
|---|
| 75 | // 12-03-01, G4bool fImplicitElement (mma)
|
|---|
| 76 | // 30-03-01, suppression of the warning message in GetMaterial
|
|---|
| 77 | // 17-07-01, migration to STL. M. Verderi.
|
|---|
| 78 | // 14-09-01, Suppression of the data member fIndexInTable
|
|---|
| 79 | // 31-10-01, new function SetChemicalFormula() (mma)
|
|---|
| 80 | // 26-02-02, fIndexInTable renewed
|
|---|
| 81 | // 06-08-02, remove constructors with ChemicalFormula (mma)
|
|---|
| 82 | // 15-11-05, GetMaterial(materialName, G4bool warning=true)
|
|---|
| 83 |
|
|---|
| 84 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 85 |
|
|---|
| 86 | #ifndef G4MATERIAL_HH
|
|---|
| 87 | #define G4MATERIAL_HH
|
|---|
| 88 |
|
|---|
| 89 | #include "globals.hh"
|
|---|
| 90 | #include "G4ios.hh"
|
|---|
| 91 | #include <vector>
|
|---|
| 92 | #include "G4Element.hh"
|
|---|
| 93 | #include "G4MaterialPropertiesTable.hh"
|
|---|
| 94 | #include "G4IonisParamMat.hh"
|
|---|
| 95 | #include "G4SandiaTable.hh"
|
|---|
| 96 | #include "G4ElementVector.hh"
|
|---|
| 97 | #include "G4MaterialTable.hh"
|
|---|
| 98 |
|
|---|
| 99 | enum G4State { kStateUndefined, kStateSolid, kStateLiquid, kStateGas };
|
|---|
| 100 |
|
|---|
| 101 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 102 |
|
|---|
| 103 | class G4Material
|
|---|
| 104 | {
|
|---|
| 105 | public: // with description
|
|---|
| 106 |
|
|---|
| 107 | //
|
|---|
| 108 | // Constructor to create a material from scratch.
|
|---|
| 109 | //
|
|---|
| 110 | G4Material(const G4String& name, //its name
|
|---|
| 111 | G4double z, //atomic number
|
|---|
| 112 | G4double a, //mass of mole
|
|---|
| 113 | G4double density, //density
|
|---|
| 114 | G4State state = kStateUndefined, //solid,gas
|
|---|
| 115 | G4double temp = STP_Temperature, //temperature
|
|---|
| 116 | G4double pressure = STP_Pressure); //pressure
|
|---|
| 117 |
|
|---|
| 118 | //
|
|---|
| 119 | // Constructor to create a material from a combination of elements
|
|---|
| 120 | // and/or materials subsequently added via AddElement and/or AddMaterial
|
|---|
| 121 | //
|
|---|
| 122 | G4Material(const G4String& name, //its name
|
|---|
| 123 | G4double density, //density
|
|---|
| 124 | G4int nComponents, //nbOfComponents
|
|---|
| 125 | G4State state = kStateUndefined, //solid,gas
|
|---|
| 126 | G4double temp = STP_Temperature, //temperature
|
|---|
| 127 | G4double pressure = STP_Pressure); //pressure
|
|---|
| 128 |
|
|---|
| 129 | //
|
|---|
| 130 | // Add an element, giving number of atoms
|
|---|
| 131 | //
|
|---|
| 132 | void AddElement(G4Element* element, //the element
|
|---|
| 133 | G4int nAtoms); //nb of atoms in
|
|---|
| 134 | // a molecule
|
|---|
| 135 | //
|
|---|
| 136 | // Add an element or material, giving fraction of mass
|
|---|
| 137 | //
|
|---|
| 138 | void AddElement (G4Element* element , //the element
|
|---|
| 139 | G4double fraction); //fractionOfMass
|
|---|
| 140 |
|
|---|
| 141 | void AddMaterial(G4Material* material, //the material
|
|---|
| 142 | G4double fraction); //fractionOfMass
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 | virtual ~G4Material();
|
|---|
| 146 |
|
|---|
| 147 | void SetChemicalFormula (const G4String& chF) {fChemicalFormula=chF;}
|
|---|
| 148 |
|
|---|
| 149 | //
|
|---|
| 150 | // retrieval methods
|
|---|
| 151 | //
|
|---|
| 152 | const G4String& GetName() const {return fName;}
|
|---|
| 153 | const G4String& GetChemicalFormula() const {return fChemicalFormula;}
|
|---|
| 154 | G4double GetDensity() const {return fDensity;}
|
|---|
| 155 | G4State GetState() const {return fState;}
|
|---|
| 156 | G4double GetTemperature() const {return fTemp;}
|
|---|
| 157 | G4double GetPressure() const {return fPressure;}
|
|---|
| 158 |
|
|---|
| 159 | //number of elements constituing this material:
|
|---|
| 160 | size_t GetNumberOfElements() const {return fNumberOfElements;}
|
|---|
| 161 |
|
|---|
| 162 | //vector of pointers to elements constituing this material:
|
|---|
| 163 | const
|
|---|
| 164 | G4ElementVector* GetElementVector() const {return theElementVector;}
|
|---|
| 165 |
|
|---|
| 166 | //vector of fractional mass of each element:
|
|---|
| 167 | const G4double* GetFractionVector() const {return fMassFractionVector;}
|
|---|
| 168 |
|
|---|
| 169 | //vector of atom count of each element:
|
|---|
| 170 | const G4int* GetAtomsVector() const {return fAtomsVector;}
|
|---|
| 171 |
|
|---|
| 172 | //return a pointer to an element, given its index in the material:
|
|---|
| 173 | const
|
|---|
| 174 | G4Element* GetElement(G4int iel) const {return (*theElementVector)[iel];}
|
|---|
| 175 |
|
|---|
| 176 | //vector of nb of atoms per volume of each element in this material:
|
|---|
| 177 | const
|
|---|
| 178 | G4double* GetVecNbOfAtomsPerVolume() const {return VecNbOfAtomsPerVolume;}
|
|---|
| 179 | //total number of atoms per volume:
|
|---|
| 180 | G4double GetTotNbOfAtomsPerVolume() const {return TotNbOfAtomsPerVolume;}
|
|---|
| 181 | //total number of electrons per volume:
|
|---|
| 182 | G4double GetTotNbOfElectPerVolume() const {return TotNbOfElectPerVolume;}
|
|---|
| 183 |
|
|---|
| 184 | //obsolete names (5-10-98) see the 2 functions above
|
|---|
| 185 | const
|
|---|
| 186 | G4double* GetAtomicNumDensityVector() const {return VecNbOfAtomsPerVolume;}
|
|---|
| 187 | G4double GetElectronDensity() const {return TotNbOfElectPerVolume;}
|
|---|
| 188 |
|
|---|
| 189 | // Radiation length:
|
|---|
| 190 | G4double GetRadlen() const {return fRadlen;}
|
|---|
| 191 |
|
|---|
| 192 | // Nuclear interaction length:
|
|---|
| 193 | G4double GetNuclearInterLength() const {return fNuclInterLen;}
|
|---|
| 194 |
|
|---|
| 195 | // ionisation parameters:
|
|---|
| 196 | G4IonisParamMat* GetIonisation() const {return fIonisation;}
|
|---|
| 197 |
|
|---|
| 198 | // Sandia table:
|
|---|
| 199 | G4SandiaTable* GetSandiaTable() const {return fSandiaTable;}
|
|---|
| 200 |
|
|---|
| 201 | //meaningful only for single material:
|
|---|
| 202 | G4double GetZ() const;
|
|---|
| 203 | G4double GetA() const;
|
|---|
| 204 |
|
|---|
| 205 | //the MaterialPropertiesTable (if any) attached to this material:
|
|---|
| 206 | void SetMaterialPropertiesTable(G4MaterialPropertiesTable* anMPT)
|
|---|
| 207 | {fMaterialPropertiesTable = anMPT;}
|
|---|
| 208 |
|
|---|
| 209 | G4MaterialPropertiesTable* GetMaterialPropertiesTable() const
|
|---|
| 210 | {return fMaterialPropertiesTable;}
|
|---|
| 211 |
|
|---|
| 212 | //the (static) Table of Materials:
|
|---|
| 213 | //
|
|---|
| 214 | static
|
|---|
| 215 | const G4MaterialTable* GetMaterialTable();
|
|---|
| 216 |
|
|---|
| 217 | static
|
|---|
| 218 | size_t GetNumberOfMaterials();
|
|---|
| 219 |
|
|---|
| 220 | //the index of this material in the Table:
|
|---|
| 221 | size_t GetIndex() const {return fIndexInTable;}
|
|---|
| 222 |
|
|---|
| 223 | //return pointer to a material, given its name:
|
|---|
| 224 | static G4Material* GetMaterial(G4String name, G4bool warning=true);
|
|---|
| 225 |
|
|---|
| 226 | //
|
|---|
| 227 | //printing methods
|
|---|
| 228 | //
|
|---|
| 229 | friend std::ostream& operator<<(std::ostream&, G4Material*);
|
|---|
| 230 | friend std::ostream& operator<<(std::ostream&, G4Material&);
|
|---|
| 231 | friend std::ostream& operator<<(std::ostream&, G4MaterialTable);
|
|---|
| 232 |
|
|---|
| 233 | public: // without description
|
|---|
| 234 |
|
|---|
| 235 | G4int operator==(const G4Material&) const;
|
|---|
| 236 | G4int operator!=(const G4Material&) const;
|
|---|
| 237 | G4Material(__void__&);
|
|---|
| 238 | // Fake default constructor for usage restricted to direct object
|
|---|
| 239 | // persistency for clients requiring preallocation of memory for
|
|---|
| 240 | // persistifiable objects.
|
|---|
| 241 |
|
|---|
| 242 | void SetName (const G4String& name) {fName=name;}
|
|---|
| 243 |
|
|---|
| 244 | private:
|
|---|
| 245 |
|
|---|
| 246 | G4Material(const G4Material&);
|
|---|
| 247 | const G4Material& operator=(const G4Material&);
|
|---|
| 248 |
|
|---|
| 249 | void InitializePointers();
|
|---|
| 250 |
|
|---|
| 251 | // Header routine for all derived quantities
|
|---|
| 252 | void ComputeDerivedQuantities();
|
|---|
| 253 |
|
|---|
| 254 | // Compute Radiation length
|
|---|
| 255 | void ComputeRadiationLength();
|
|---|
| 256 |
|
|---|
| 257 | // Compute Nuclear interaction length
|
|---|
| 258 | void ComputeNuclearInterLength();
|
|---|
| 259 |
|
|---|
| 260 | private:
|
|---|
| 261 |
|
|---|
| 262 | //
|
|---|
| 263 | // Basic data members ( To define a material)
|
|---|
| 264 | //
|
|---|
| 265 |
|
|---|
| 266 | G4String fName; // Material name
|
|---|
| 267 | G4String fChemicalFormula; // Material chemical formula
|
|---|
| 268 | G4double fDensity; // Material density
|
|---|
| 269 |
|
|---|
| 270 | G4State fState; // Material state (determined
|
|---|
| 271 | // internally based on density)
|
|---|
| 272 | G4double fTemp; // Temperature (defaults: STP)
|
|---|
| 273 | G4double fPressure; // Pressure (defaults: STP)
|
|---|
| 274 |
|
|---|
| 275 | G4int maxNbComponents; // totalNbOfComponentsInTheMaterial
|
|---|
| 276 | G4int fArrayLength; // the length of FAtomVector
|
|---|
| 277 | size_t fNumberOfComponents; // Nb of components declared so far
|
|---|
| 278 |
|
|---|
| 279 | size_t fNumberOfElements; // Nb of Elements in the material
|
|---|
| 280 | G4ElementVector* theElementVector; // vector of constituent Elements
|
|---|
| 281 | G4bool fImplicitElement; // implicit Element created by this?
|
|---|
| 282 | G4double* fMassFractionVector; // composition by fractional mass
|
|---|
| 283 | G4int* fAtomsVector; // composition by atom count
|
|---|
| 284 |
|
|---|
| 285 | G4MaterialPropertiesTable* fMaterialPropertiesTable;
|
|---|
| 286 |
|
|---|
| 287 | static
|
|---|
| 288 | G4MaterialTable theMaterialTable; // the material table
|
|---|
| 289 | size_t fIndexInTable; // the position in the table
|
|---|
| 290 |
|
|---|
| 291 | //
|
|---|
| 292 | // Derived data members (computed from the basic data members)
|
|---|
| 293 | //
|
|---|
| 294 | // some general atomic properties
|
|---|
| 295 |
|
|---|
| 296 | G4double* VecNbOfAtomsPerVolume; // vector of nb of atoms per volume
|
|---|
| 297 | G4double TotNbOfAtomsPerVolume; // total nb of atoms per volume
|
|---|
| 298 | G4double TotNbOfElectPerVolume; // total nb of electrons per volume
|
|---|
| 299 | G4double fRadlen; // Radiation length
|
|---|
| 300 | G4double fNuclInterLen; // Nuclear interaction length
|
|---|
| 301 |
|
|---|
| 302 | G4IonisParamMat* fIonisation; // ionisation parameters
|
|---|
| 303 | G4SandiaTable* fSandiaTable; // Sandia table
|
|---|
| 304 | };
|
|---|
| 305 |
|
|---|
| 306 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 307 |
|
|---|
| 308 | inline
|
|---|
| 309 | G4double G4Material::GetZ() const
|
|---|
| 310 | {
|
|---|
| 311 | if (fNumberOfElements > 1) {
|
|---|
| 312 | G4cerr << "WARNING in GetZ. The material: " << fName << " is a mixture."
|
|---|
| 313 | << G4endl;
|
|---|
| 314 | G4Exception ( " the Atomic number is not well defined." );
|
|---|
| 315 | }
|
|---|
| 316 | return (*theElementVector)[0]->GetZ();
|
|---|
| 317 | }
|
|---|
| 318 |
|
|---|
| 319 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 320 |
|
|---|
| 321 | inline
|
|---|
| 322 | G4double G4Material::GetA() const
|
|---|
| 323 | {
|
|---|
| 324 | if (fNumberOfElements > 1) {
|
|---|
| 325 | G4cerr << "WARNING in GetA. The material: " << fName << " is a mixture."
|
|---|
| 326 | << G4endl;
|
|---|
| 327 | G4Exception ( " the Atomic mass is not well defined." );
|
|---|
| 328 | }
|
|---|
| 329 | return (*theElementVector)[0]->GetA();
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 333 |
|
|---|
| 334 | #endif
|
|---|