| 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: G4MaterialPropertiesTable.cc,v 1.20 2008/06/05 23:38:34 gum Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $
|
|---|
| 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | ////////////////////////////////////////////////////////////////////////
|
|---|
| 32 | // G4MaterialPropertiesTable Implementation
|
|---|
| 33 | ////////////////////////////////////////////////////////////////////////
|
|---|
| 34 | //
|
|---|
| 35 | // File: G4MaterialPropertiesTable.cc
|
|---|
| 36 | // Version: 1.0
|
|---|
| 37 | // Created: 1996-02-08
|
|---|
| 38 | // Author: Juliet Armstrong
|
|---|
| 39 | // Updated: 2005-05-12 add SetGROUPVEL(), courtesy of
|
|---|
| 40 | // Horton-Smith (bug report #741), by P. Gumplinger
|
|---|
| 41 | // 2002-11-05 add named material constants by P. Gumplinger
|
|---|
| 42 | // 1999-11-05 Migration from G4RWTPtrHashDictionary to STL
|
|---|
| 43 | // by John Allison
|
|---|
| 44 | // 1997-03-26 by Peter Gumplinger
|
|---|
| 45 | // > cosmetics (only)
|
|---|
| 46 | // mail: gum@triumf.ca
|
|---|
| 47 | //
|
|---|
| 48 | ////////////////////////////////////////////////////////////////////////
|
|---|
| 49 |
|
|---|
| 50 | #include "globals.hh"
|
|---|
| 51 | #include "G4MaterialPropertiesTable.hh"
|
|---|
| 52 |
|
|---|
| 53 | /////////////////
|
|---|
| 54 | // Constructors
|
|---|
| 55 | /////////////////
|
|---|
| 56 |
|
|---|
| 57 | G4MaterialPropertiesTable::G4MaterialPropertiesTable() {}
|
|---|
| 58 |
|
|---|
| 59 | ////////////////
|
|---|
| 60 | // Destructors
|
|---|
| 61 | ////////////////
|
|---|
| 62 |
|
|---|
| 63 | G4MaterialPropertiesTable::~G4MaterialPropertiesTable()
|
|---|
| 64 | {
|
|---|
| 65 | MPTiterator i;
|
|---|
| 66 | for (i = MPT.begin(); i != MPT.end(); ++i) {
|
|---|
| 67 | delete (*i).second;
|
|---|
| 68 | }
|
|---|
| 69 | MPT.clear();
|
|---|
| 70 | MPTC.clear();
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | ////////////
|
|---|
| 74 | // Methods
|
|---|
| 75 | ////////////
|
|---|
| 76 |
|
|---|
| 77 | void G4MaterialPropertiesTable::AddConstProperty(const char *key,
|
|---|
| 78 | G4double PropertyValue)
|
|---|
| 79 | {
|
|---|
| 80 | // Provides a way of adding a constant property to the Mataerial Properties
|
|---|
| 81 | // Table given a key
|
|---|
| 82 |
|
|---|
| 83 | MPTC [G4String(key)] = PropertyValue;
|
|---|
| 84 |
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | void G4MaterialPropertiesTable::AddProperty(const char *key,
|
|---|
| 88 | G4double *PhotonEnergies,
|
|---|
| 89 | G4double *PropertyValues,
|
|---|
| 90 | G4int NumEntries)
|
|---|
| 91 | {
|
|---|
| 92 | // Privides a way of adding a property to the Material Properties
|
|---|
| 93 | // Table given a pair of numbers and a key
|
|---|
| 94 |
|
|---|
| 95 | G4MaterialPropertyVector *mpv =
|
|---|
| 96 | new G4MaterialPropertyVector(PhotonEnergies,
|
|---|
| 97 | PropertyValues,
|
|---|
| 98 | NumEntries);
|
|---|
| 99 | MPT [G4String(key)] = mpv;
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | void G4MaterialPropertiesTable::AddProperty(const char *key,
|
|---|
| 103 | G4MaterialPropertyVector *mpv)
|
|---|
| 104 | {
|
|---|
| 105 | // Provides a way of adding a property to the Material Properties
|
|---|
| 106 | // Table given an G4MaterialPropertyVector Reference and a key
|
|---|
| 107 |
|
|---|
| 108 | MPT [G4String(key)] = mpv;
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | void G4MaterialPropertiesTable::RemoveConstProperty(const char *key)
|
|---|
| 112 | {
|
|---|
| 113 | MPTC.erase(G4String(key));
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | void G4MaterialPropertiesTable::RemoveProperty(const char *key)
|
|---|
| 117 | {
|
|---|
| 118 | MPT.erase(G4String(key));
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | G4double G4MaterialPropertiesTable::GetConstProperty(const char *key)
|
|---|
| 122 | {
|
|---|
| 123 | // Returns the constant material property corresponding to a key
|
|---|
| 124 |
|
|---|
| 125 | MPTCiterator j;
|
|---|
| 126 | j = MPTC.find(G4String(key));
|
|---|
| 127 | if ( j != MPTC.end() ) {
|
|---|
| 128 | return j->second;
|
|---|
| 129 | }
|
|---|
| 130 | else {
|
|---|
| 131 | G4Exception("G4MaterialPropertiesTable::GetConstProperty ==> "
|
|---|
| 132 | "Constant Material Property not found.");
|
|---|
| 133 | return G4double(0.0);
|
|---|
| 134 | }
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | G4bool G4MaterialPropertiesTable::ConstPropertyExists(const char *key)
|
|---|
| 138 | {
|
|---|
| 139 | // Return true if a const property 'key' exists
|
|---|
| 140 |
|
|---|
| 141 | MPTCiterator j;
|
|---|
| 142 | j = MPTC.find(G4String(key));
|
|---|
| 143 | if ( j != MPTC.end() ) {
|
|---|
| 144 | return true;
|
|---|
| 145 | }
|
|---|
| 146 | else {
|
|---|
| 147 | return false;
|
|---|
| 148 | }
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | G4MaterialPropertyVector* G4MaterialPropertiesTable::GetProperty(const char *key)
|
|---|
| 152 | {
|
|---|
| 153 | // Returns a Material Property Vector corresponding to a key
|
|---|
| 154 |
|
|---|
| 155 | if(MPT[G4String(key)] != 0) {
|
|---|
| 156 | return MPT[G4String(key)];
|
|---|
| 157 | }else{
|
|---|
| 158 | if(G4String(key) == "GROUPVEL") {
|
|---|
| 159 | return SetGROUPVEL();
|
|---|
| 160 | }else{
|
|---|
| 161 | return MPT[G4String(key)];
|
|---|
| 162 | }
|
|---|
| 163 | }
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | void G4MaterialPropertiesTable::AddEntry(const char *key,
|
|---|
| 167 | G4double aPhotonEnergy,
|
|---|
| 168 | G4double aPropertyValue)
|
|---|
| 169 |
|
|---|
| 170 | // Allows to add an entry pair directly to the Material Property Vector
|
|---|
| 171 | // given a key
|
|---|
| 172 |
|
|---|
| 173 | {
|
|---|
| 174 | G4MaterialPropertyVector *targetVector=MPT [G4String(key)];
|
|---|
| 175 | if (targetVector != 0) {
|
|---|
| 176 | targetVector->AddElement(aPhotonEnergy, aPropertyValue);
|
|---|
| 177 | }
|
|---|
| 178 | else {
|
|---|
| 179 | G4Exception("G4MaterialPropertiesTable::AddEntry ==> "
|
|---|
| 180 | "Material Property Vector not found.");
|
|---|
| 181 | }
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | void G4MaterialPropertiesTable::RemoveEntry(const char *key,
|
|---|
| 185 | G4double aPhotonEnergy)
|
|---|
| 186 | {
|
|---|
| 187 | // Allows to remove an entry pair directly from the Material Property Vector
|
|---|
| 188 | // given a key
|
|---|
| 189 |
|
|---|
| 190 | G4MaterialPropertyVector *targetVector=MPT [G4String(key)];
|
|---|
| 191 | if (targetVector) {
|
|---|
| 192 | targetVector->RemoveElement(aPhotonEnergy);
|
|---|
| 193 | }
|
|---|
| 194 | else {
|
|---|
| 195 | G4Exception("G4MaterialPropertiesTable::RemoveEntry ==> "
|
|---|
| 196 | "Material Property Vector not found.");
|
|---|
| 197 | }
|
|---|
| 198 | }
|
|---|
| 199 | void G4MaterialPropertiesTable::DumpTable()
|
|---|
| 200 | {
|
|---|
| 201 | MPTiterator i;
|
|---|
| 202 | for (i = MPT.begin(); i != MPT.end(); ++i) {
|
|---|
| 203 | G4cout << (*i).first << G4endl;
|
|---|
| 204 | if ( (*i).second != 0 ) {
|
|---|
| 205 | (*i).second->DumpVector();
|
|---|
| 206 | }
|
|---|
| 207 | else {
|
|---|
| 208 | G4cout << "NULL Material Property Vector Pointer." << G4endl;
|
|---|
| 209 | }
|
|---|
| 210 | }
|
|---|
| 211 | MPTCiterator j;
|
|---|
| 212 | for (j = MPTC.begin(); j != MPTC.end(); ++j) {
|
|---|
| 213 | G4cout << j->first << G4endl;
|
|---|
| 214 | if ( j->second != 0 ) {
|
|---|
| 215 | G4cout << j->second << G4endl;
|
|---|
| 216 | }
|
|---|
| 217 | else {
|
|---|
| 218 | G4cout << "No Material Constant Property." << G4endl;
|
|---|
| 219 | }
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 | }
|
|---|
| 223 | G4MaterialPropertyVector* G4MaterialPropertiesTable::SetGROUPVEL()
|
|---|
| 224 | {
|
|---|
| 225 | // fetch RINDEX data, give up if unavailable
|
|---|
| 226 | G4MaterialPropertyVector *rindex = this->GetProperty("RINDEX");
|
|---|
| 227 | if (rindex==0) return NULL;
|
|---|
| 228 |
|
|---|
| 229 | rindex->ResetIterator();
|
|---|
| 230 | // RINDEX exists but has no entries, give up
|
|---|
| 231 | if ( (++*rindex) == false ) return NULL;
|
|---|
| 232 |
|
|---|
| 233 | // add GROUPVEL vector
|
|---|
| 234 | G4MaterialPropertyVector* groupvel = new G4MaterialPropertyVector();
|
|---|
| 235 |
|
|---|
| 236 | this->AddProperty( "GROUPVEL", groupvel );
|
|---|
| 237 |
|
|---|
| 238 | // fill GROUPVEL vector using RINDEX values
|
|---|
| 239 | // rindex built-in "iterator" was advanced to first entry above
|
|---|
| 240 | G4double E0 = rindex->GetPhotonEnergy();
|
|---|
| 241 | G4double n0 = rindex->GetProperty();
|
|---|
| 242 |
|
|---|
| 243 | if (E0 <= 0. ) G4Exception("G4MaterialPropertiesTable::SetGROUPVEL ==> "
|
|---|
| 244 | "Optical Photon Energy <= 0");
|
|---|
| 245 |
|
|---|
| 246 | if ( ++*rindex ) {
|
|---|
| 247 | // good, we have at least two entries in RINDEX
|
|---|
| 248 | // get next energy/value pair
|
|---|
| 249 | G4double E1 = rindex->GetPhotonEnergy();
|
|---|
| 250 | G4double n1 = rindex->GetProperty();
|
|---|
| 251 |
|
|---|
| 252 | if (E1 <= 0. ) G4Exception("G4MaterialPropertiesTable::SetGROUPVEL ==> "
|
|---|
| 253 | "Optical Photon Energy <= 0");
|
|---|
| 254 | G4double vg;
|
|---|
| 255 | // add entry at first photon energy
|
|---|
| 256 | vg = c_light/(n0+(n1-n0)/std::log(E1/E0));
|
|---|
| 257 | // allow only for 'normal dispersion' -> dn/d(logE) > 0
|
|---|
| 258 | if(vg<0 || vg>c_light/n0)vg = c_light/n0;
|
|---|
| 259 | groupvel->AddElement( E0, vg );
|
|---|
| 260 | // add entries at midpoints between remaining photon energies
|
|---|
| 261 | while(1) {
|
|---|
| 262 | vg = c_light/( 0.5*(n0+n1)+(n1-n0)/std::log(E1/E0));
|
|---|
| 263 | // allow only for 'normal dispersion' -> dn/d(logE) > 0
|
|---|
| 264 | if(vg<0 || vg>c_light/(0.5*(n0+n1)))vg = c_light/(0.5*(n0+n1));
|
|---|
| 265 | groupvel->AddElement( 0.5*(E0+E1), vg );
|
|---|
| 266 | // get next energy/value pair, or exit loop
|
|---|
| 267 | if (!(++*rindex)) break;
|
|---|
| 268 | E0 = E1;
|
|---|
| 269 | n0 = n1;
|
|---|
| 270 | E1 = rindex->GetPhotonEnergy();
|
|---|
| 271 | n1 = rindex->GetProperty();
|
|---|
| 272 |
|
|---|
| 273 | if (E1 <= 0. ) G4Exception("G4MaterialPropertiesTable::SetGROUPVEL ==> "
|
|---|
| 274 | "Optical Photon Energy <= 0");
|
|---|
| 275 | }
|
|---|
| 276 | // add entry at last photon energy
|
|---|
| 277 | vg = c_light/(n1+(n1-n0)/std::log(E1/E0));
|
|---|
| 278 | // allow only for 'normal dispersion' -> dn/d(logE) > 0
|
|---|
| 279 | if(vg<0 || vg>c_light/n1)vg = c_light/n1;
|
|---|
| 280 | groupvel->AddElement( E1, vg );
|
|---|
| 281 | }else{
|
|---|
| 282 | // only one entry in RINDEX -- weird!
|
|---|
| 283 | groupvel->AddElement( E0, c_light/n0 );
|
|---|
| 284 | }
|
|---|
| 285 |
|
|---|
| 286 | return groupvel;
|
|---|
| 287 | }
|
|---|