Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4MaterialPropertiesTable.cc
Go to the documentation of this file.
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 66811 2013-01-12 16:04:23Z gcosmo $
28 //
29 //
30 ////////////////////////////////////////////////////////////////////////
31 // G4MaterialPropertiesTable Implementation
32 ////////////////////////////////////////////////////////////////////////
33 //
34 // File: G4MaterialPropertiesTable.cc
35 // Version: 1.0
36 // Created: 1996-02-08
37 // Author: Juliet Armstrong
38 // Updated: 2005-05-12 add SetGROUPVEL(), courtesy of
39 // Horton-Smith (bug report #741), by P. Gumplinger
40 // 2002-11-05 add named material constants by P. Gumplinger
41 // 1999-11-05 Migration from G4RWTPtrHashDictionary to STL
42 // by John Allison
43 // 1997-03-26 by Peter Gumplinger
44 // > cosmetics (only)
45 // mail: gum@triumf.ca
46 //
47 ////////////////////////////////////////////////////////////////////////
48 
49 #include "globals.hh"
51 #include "G4PhysicalConstants.hh"
52 
53 /////////////////
54 // Constructors
55 /////////////////
56 
58 {
59 }
60 
61 ////////////////
62 // Destructor
63 ////////////////
64 
66 {
67  MPTiterator i;
68  for (i = MPT.begin(); i != MPT.end(); ++i)
69  {
70  delete (*i).second;
71  }
72  MPT.clear();
73  MPTC.clear();
74 }
75 
76 ////////////
77 // Methods
78 ////////////
79 
81 {
82  MPTiterator i;
83  for (i = MPT.begin(); i != MPT.end(); ++i)
84  {
85  G4cout << (*i).first << G4endl;
86  if ( (*i).second != 0 )
87  {
88  (*i).second->DumpValues();
89  }
90  else
91  {
92  G4Exception("G4MaterialPropertiesTable::DumpTable()", "mat204",
93  JustWarning, "NULL Material Property Vector Pointer.");
94  }
95  }
96  MPTCiterator j;
97  for (j = MPTC.begin(); j != MPTC.end(); ++j)
98  {
99  G4cout << j->first << G4endl;
100  if ( j->second != 0 )
101  {
102  G4cout << j->second << G4endl;
103  }
104  else
105  {
106  G4Exception("G4MaterialPropertiesTable::DumpTable()", "mat202",
107  JustWarning, "No Material Constant Property.");
108  }
109  }
110 }
111 
112 G4MaterialPropertyVector* G4MaterialPropertiesTable::SetGROUPVEL()
113 {
114  // fetch RINDEX data, give up if unavailable
115  //
116  G4MaterialPropertyVector *rindex = this->GetProperty("RINDEX");
117  if (rindex==0) { return 0; }
118 
119  // RINDEX exists but has no entries, give up
120  //
121  if ( rindex->GetVectorLength() == 0 ) { return 0; }
122 
123  // add GROUPVEL vector
124  //
126 
127  this->AddProperty( "GROUPVEL", groupvel );
128 
129  // fill GROUPVEL vector using RINDEX values
130  // rindex built-in "iterator" was advanced to first entry above
131  //
132  G4double E0 = rindex->Energy(0);
133  G4double n0 = (*rindex)[0];
134 
135  if (E0 <= 0.)
136  {
137  G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "mat205",
138  FatalException, "Optical Photon Energy <= 0");
139  }
140 
141  if ( rindex->GetVectorLength() >= 2 )
142  {
143  // good, we have at least two entries in RINDEX
144  // get next energy/value pair
145 
146  G4double E1 = rindex->Energy(1);
147  G4double n1 = (*rindex)[1];
148 
149  if (E1 <= 0.)
150  {
151  G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "mat205",
152  FatalException, "Optical Photon Energy <= 0");
153  }
154 
155  G4double vg;
156 
157  // add entry at first photon energy
158  //
159  vg = c_light/(n0+(n1-n0)/std::log(E1/E0));
160 
161  // allow only for 'normal dispersion' -> dn/d(logE) > 0
162  //
163  if((vg<0) || (vg>c_light/n0)) { vg = c_light/n0; }
164 
165  groupvel->InsertValues( E0, vg );
166 
167  // add entries at midpoints between remaining photon energies
168  //
169 
170  for (size_t i = 2; i < rindex->GetVectorLength(); i++)
171  {
172  vg = c_light/( 0.5*(n0+n1)+(n1-n0)/std::log(E1/E0));
173 
174  // allow only for 'normal dispersion' -> dn/d(logE) > 0
175  //
176  if((vg<0) || (vg>c_light/(0.5*(n0+n1)))) { vg = c_light/(0.5*(n0+n1)); }
177  groupvel->InsertValues( 0.5*(E0+E1), vg );
178 
179  // get next energy/value pair, or exit loop
180  //
181  E0 = E1;
182  n0 = n1;
183  E1 = rindex->Energy(i);
184  n1 = (*rindex)[i];
185 
186  if (E1 <= 0.)
187  {
188  G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "mat205",
189  FatalException, "Optical Photon Energy <= 0");
190  }
191  }
192 
193  // add entry at last photon energy
194  //
195  vg = c_light/(n1+(n1-n0)/std::log(E1/E0));
196 
197  // allow only for 'normal dispersion' -> dn/d(logE) > 0
198  //
199  if((vg<0) || (vg>c_light/n1)) { vg = c_light/n1; }
200  groupvel->InsertValues( E1, vg );
201  }
202  else // only one entry in RINDEX -- weird!
203  {
204  groupvel->InsertValues( E0, c_light/n0 );
205  }
206 
207  return groupvel;
208 }
G4MaterialPropertyVector * GetProperty(const char *key)
void InsertValues(G4double energy, G4double value)
size_t GetVectorLength() const
G4MaterialPropertyVector * AddProperty(const char *key, G4double *PhotonEnergies, G4double *PropertyValues, G4int NumEntries)
G4GLOB_DLL std::ostream G4cout
G4PhysicsOrderedFreeVector G4MaterialPropertyVector
G4double Energy(size_t index) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
float c_light
Definition: hepunit.py:257