Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4MaterialPropertiesTable.cc
이 파일의 문서화 페이지로 가기
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 108515 2018-02-16 07:15:12Z gcosmo $
28 //
29 //
31 // G4MaterialPropertiesTable Implementation
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 //
48 
49 #include "globals.hh"
51 #include "G4PhysicalConstants.hh"
52 #include "G4Log.hh"
53 
54 #include <algorithm>
55 
57 // Constructors
59 
61 {
62  // elements of these 2 vectors must be in same order as
63  // the corresponding enums in G4MaterialPropertiesIndex.hh
64  G4MaterialPropertyName.push_back(G4String("RINDEX"));
65  G4MaterialPropertyName.push_back(G4String("REFLECTIVITY"));
66  G4MaterialPropertyName.push_back(G4String("REALRINDEX"));
67  G4MaterialPropertyName.push_back(G4String("IMAGINARYRINDEX"));
68  G4MaterialPropertyName.push_back(G4String("EFFICIENCY"));
69  G4MaterialPropertyName.push_back(G4String("TRANSMITTANCE"));
70  G4MaterialPropertyName.push_back(G4String("SPECULARLOBECONSTANT"));
71  G4MaterialPropertyName.push_back(G4String("SPECULARSPIKECONSTANT"));
72  G4MaterialPropertyName.push_back(G4String("BACKSCATTERCONSTANT"));
73  G4MaterialPropertyName.push_back(G4String("GROUPVEL"));
74  G4MaterialPropertyName.push_back(G4String("MIEHG"));
75  G4MaterialPropertyName.push_back(G4String("RAYLEIGH"));
76  G4MaterialPropertyName.push_back(G4String("WLSCOMPONENT"));
77  G4MaterialPropertyName.push_back(G4String("WLSABSLENGTH"));
78  G4MaterialPropertyName.push_back(G4String("ABSLENGTH"));
79  G4MaterialPropertyName.push_back(G4String("FASTCOMPONENT"));
80  G4MaterialPropertyName.push_back(G4String("SLOWCOMPONENT"));
81  G4MaterialPropertyName.push_back(G4String("PROTONSCINTILLATIONYIELD"));
82  G4MaterialPropertyName.push_back(G4String("DEUTERONSCINTILLATIONYIELD"));
83  G4MaterialPropertyName.push_back(G4String("TRITONSCINTILLATIONYIELD"));
84  G4MaterialPropertyName.push_back(G4String("ALPHASCINTILLATIONYIELD"));
85  G4MaterialPropertyName.push_back(G4String("IONSCINTILLATIONYIELD"));
86  G4MaterialPropertyName.push_back(G4String("ELECTRONSCINTILLATIONYIELD"));
87 
88  G4MaterialConstPropertyName.push_back(G4String("SURFACEROUGHNESS"));
89  G4MaterialConstPropertyName.push_back(G4String("ISOTHERMAL_COMPRESSIBILITY"));
90  G4MaterialConstPropertyName.push_back(G4String("RS_SCALE_FACTOR"));
91  G4MaterialConstPropertyName.push_back(G4String("WLSMEANNUMBERPHOTONS"));
92  G4MaterialConstPropertyName.push_back(G4String("WLSTIMECONSTANT"));
93  G4MaterialConstPropertyName.push_back(G4String("MIEHG_FORWARD"));
94  G4MaterialConstPropertyName.push_back(G4String("MIEHG_BACKWARD"));
95  G4MaterialConstPropertyName.push_back(G4String("MIEHG_FORWARD_RATIO"));
96  G4MaterialConstPropertyName.push_back(G4String("SCINTILLATIONYIELD"));
97  G4MaterialConstPropertyName.push_back(G4String("RESOLUTIONSCALE"));
98  G4MaterialConstPropertyName.push_back(G4String("FASTTIMECONSTANT"));
99  G4MaterialConstPropertyName.push_back(G4String("FASTSCINTILLATIONRISETIME"));
100  G4MaterialConstPropertyName.push_back(G4String("SLOWTIMECONSTANT"));
101  G4MaterialConstPropertyName.push_back(G4String("SLOWSCINTILLATIONRISETIME"));
102  G4MaterialConstPropertyName.push_back(G4String("YIELDRATIO"));
103  G4MaterialConstPropertyName.push_back(G4String("FERMIPOT"));
104  G4MaterialConstPropertyName.push_back(G4String("DIFFUSION"));
105  G4MaterialConstPropertyName.push_back(G4String("SPINFLIP"));
106  G4MaterialConstPropertyName.push_back(G4String("LOSS"));
107  G4MaterialConstPropertyName.push_back(G4String("LOSSCS"));
108  G4MaterialConstPropertyName.push_back(G4String("ABSCS"));
109  G4MaterialConstPropertyName.push_back(G4String("SCATCS"));
110  G4MaterialConstPropertyName.push_back(G4String("MR_NBTHETA"));
111  G4MaterialConstPropertyName.push_back(G4String("MR_NBE"));
112  G4MaterialConstPropertyName.push_back(G4String("MR_RRMS"));
113  G4MaterialConstPropertyName.push_back(G4String("MR_CORRLEN"));
114  G4MaterialConstPropertyName.push_back(G4String("MR_THETAMIN"));
115  G4MaterialConstPropertyName.push_back(G4String("MR_THETAMAX"));
116  G4MaterialConstPropertyName.push_back(G4String("MR_EMIN"));
117  G4MaterialConstPropertyName.push_back(G4String("MR_EMAX"));
118  G4MaterialConstPropertyName.push_back(G4String("MR_ANGNOTHETA"));
119  G4MaterialConstPropertyName.push_back(G4String("MR_ANGNOPHI"));
120  G4MaterialConstPropertyName.push_back(G4String("MR_ANGCUT"));
121 }
122 
124 // Destructor
126 
128 {
129  MPTiterator i;
130  for (i = MPT.begin(); i != MPT.end(); ++i)
131  {
132  delete (*i).second;
133  }
134  MPT.clear();
135  MPTC.clear();
136 
137  MPiterator it;
138  for (it = MP.begin(); it != MP.end(); ++it)
139  {
140  delete (*it).second;
141  }
142  MP.clear();
143  MCP.clear();
144 
145  G4MaterialPropertyName.clear();
147 }
148 
150 // Methods
152 
154  G4bool warning) const
155 {
156  // Returns the constant material property index corresponding to a key
157 
158  size_t index = std::distance(G4MaterialConstPropertyName.begin(),
159  std::find(G4MaterialConstPropertyName.begin(),
160  G4MaterialConstPropertyName.end(), key));
161  if(index < G4MaterialConstPropertyName.size()) return index;
162  if (warning) {
164  ed << "Constant Material Property Index for key " << key << " not found.";
165  G4Exception("G4MaterialPropertiesTable::GetConstPropertyIndex()","mat206",
166  JustWarning, ed);
167  }
168  return -1;
169 }
170 
172  G4bool warning) const
173 {
174  // Returns the material property index corresponding to a key
175  size_t index = std::distance(G4MaterialPropertyName.begin(),
176  std::find(G4MaterialPropertyName.begin(),
177  G4MaterialPropertyName.end(), key));
178  if(index < G4MaterialPropertyName.size()) return index;
179  if (warning) {
181  ed << "Material Property Index for key " << key << " not found.";
182  G4Exception("G4MaterialPropertiesTable::GetPropertyIndex()","mat207",
183  JustWarning, ed);
184  }
185  return -1;
186 }
187 
189 {
190  // Returns the constant material property corresponding to an index
191  // fatal exception if property not found
192 
193  MCPiterator j;
194  j = MCP.find(index);
195  if ( j != MCP.end() ) return j->second;
197  ed << "Constant Material Property Index " << index << " not found.";
198  G4Exception("G4MaterialPropertiesTable::GetConstProperty()","mat202",
199  FatalException, ed);
200  return 0.;
201 }
202 
204 {
205  // Returns the constant material property corresponding to a key
206  // fatal exception if property not found
207 
208  const G4int index = GetConstPropertyIndex(G4String(key));
209  return GetConstProperty(index);
210 }
211 
213 {
214  // Returns true if a const property 'key' exists
215  const G4int index = GetConstPropertyIndex(G4String(key));
216 
217  MCPiterator j;
218  j = MCP.find(index);
219  if ( j != MCP.end() ) return true;
220  return false;
221 }
222 
225 {
226  // Returns a Material Property Vector corresponding to a key
227  const G4int index = GetPropertyIndex(G4String(key), warning);
228  return GetProperty(index);
229 }
230 
233 {
234  // Returns a Material Property Vector corresponding to an index
235  MPiterator i;
236  i = MP.find(index);
237  if ( i != MP.end() ) return i->second;
238  if (warning) {
240  ed << "Material Property for index " << index << " not found.";
241  G4Exception("G4MaterialPropertiesTable::GetPropertyIndex()","mat208",
242  JustWarning, ed);
243  }
244  return nullptr;
245 }
246 
248  const char *key,
249  G4double *PhotonEnergies,
250  G4double *PropertyValues,
251  G4int NumEntries)
252 {
253  // Provides a way of adding a property to the Material Properties
254  // Table given a pair of numbers and a key
255  G4String k(key);
256  // if the key doesn't exist, add it
257  if (std::find(G4MaterialPropertyName.begin(),
258  G4MaterialPropertyName.end(), k) ==
259  G4MaterialPropertyName.end()) {
260  G4MaterialPropertyName.push_back(k);
261  }
262  G4int index = GetPropertyIndex(k);
263 
264  G4MaterialPropertyVector *mpv = new G4MaterialPropertyVector(PhotonEnergies,
265  PropertyValues, NumEntries);
266  MP[index] = mpv;
267 
268  // if key is RINDEX, we calculate GROUPVEL -
269  // contribution from Tao Lin (IHEP, the JUNO experiment)
270  if (k=="RINDEX") {
272  }
273 
274  return mpv;
275 }
276 
278 AddProperty(const char *key, G4MaterialPropertyVector *mpv)
279 {
280  // Provides a way of adding a property to the Material Properties
281  // Table given an G4MaterialPropertyVector Reference and a key
282  G4String k(key);
283  // if the key doesn't exist, add it
284  if (std::find(G4MaterialPropertyName.begin(),
285  G4MaterialPropertyName.end(), k) ==
286  G4MaterialPropertyName.end()) {
287  G4MaterialPropertyName.push_back(k);
288  }
289  G4int index = GetPropertyIndex(k);
290  MP[ index ] = mpv;
291 
292  // if key is RINDEX, we calculate GROUPVEL -
293  // contribution from Tao Lin (IHEP, the JUNO experiment)
294  if (k=="RINDEX") {
296  }
297 }
298 
300  G4double aPhotonEnergy,
301  G4double aPropertyValue)
302 {
303  // Allows to add an entry pair directly to the Material Property Vector
304  // given a key
305  G4String k(key);
306  if (std::find(G4MaterialPropertyName.begin(),
307  G4MaterialPropertyName.end(), k) ==
308  G4MaterialPropertyName.end()) {
309  G4MaterialPropertyName.push_back(k);
310  }
311  G4int index = GetPropertyIndex(k);
312 
313  G4MaterialPropertyVector *targetVector=MP[index];
314  if (targetVector != nullptr)
315  {
316  targetVector->InsertValues(aPhotonEnergy, aPropertyValue);
317  }
318  else
319  {
320  G4Exception("G4MaterialPropertiesTable::AddEntry()", "mat203",
321  FatalException, "Material Property Vector not found.");
322  }
323 }
324 
326 {
327  // material properties
328  MPiterator i;
329  for (i = MP.begin(); i != MP.end(); ++i)
330  {
331  G4cout << (*i).first << ": "<< G4MaterialPropertyName[(*i).first] <<G4endl;
332  if ( (*i).second != 0 )
333  {
334  (*i).second->DumpValues();
335  }
336  else
337  {
338  G4Exception("G4MaterialPropertiesTable::DumpTable()", "mat204",
339  JustWarning, "NULL Material Property Vector Pointer.");
340  }
341  }
342  // material constant properties
343  MCPiterator j;
344  for (j = MCP.begin(); j != MCP.end(); ++j)
345  {
346  G4cout << j->first <<": "<< G4MaterialConstPropertyName[j->first] <<G4endl;
347  if ( j->second != 0 )
348  {
349  G4cout << j->second << G4endl;
350  }
351  else
352  {
353  G4Exception("G4MaterialPropertiesTable::DumpTable()", "mat202",
354  JustWarning, "No Material Constant Property.");
355  }
356  }
357 }
358 
359 #ifdef G4MULTITHREADED
360 #include "G4AutoLock.hh"
361 namespace {
362  G4Mutex materialPropertyTableMutex = G4MUTEX_INITIALIZER;
363 }
364 #endif
365 
367 {
368 #ifdef G4MULTITHREADED
369  G4AutoLock mptm(&materialPropertyTableMutex);
370 #endif
371  // reconsider (i.e, remove) above mutex as this method is likely called only
372  // when RINDEX is added during the detector construction phase (i.e., adding
373  // meterials properties into geometry) on the master thread (Oct. 2017, SYJ)
374 
375  // check if "GROUPVEL" already exists
376  MPiterator itr;
377  itr = MP.find(kGROUPVEL);
378  if(itr != MP.end()) return itr->second;
379 
380  // fetch RINDEX data, give up if unavailable
381  //
382  G4MaterialPropertyVector *rindex = this->GetProperty(kRINDEX);
383  if (rindex==0) { return 0; }
384 
385  // RINDEX exists but has no entries, give up
386  //
387  if ( rindex->GetVectorLength() == 0 ) { return 0; }
388 
389  // add GROUPVEL vector
390  //
392 
393  // fill GROUPVEL vector using RINDEX values
394  // rindex built-in "iterator" was advanced to first entry above
395  //
396  G4double E0 = rindex->Energy(0);
397  G4double n0 = (*rindex)[0];
398 
399  if (E0 <= 0.)
400  {
401  G4Exception("G4MaterialPropertiesTable::CalculateGROUPVEL()", "mat205",
402  FatalException, "Optical Photon Energy <= 0");
403  }
404 
405  if ( rindex->GetVectorLength() >= 2 )
406  {
407  // good, we have at least two entries in RINDEX
408  // get next energy/value pair
409 
410  G4double E1 = rindex->Energy(1);
411  G4double n1 = (*rindex)[1];
412 
413  if (E1 <= 0.)
414  {
415  G4Exception("G4MaterialPropertiesTable::CalculateGROUPVEL()", "mat205",
416  FatalException, "Optical Photon Energy <= 0");
417  }
418 
419  G4double vg;
420 
421  // add entry at first photon energy
422  //
423  vg = c_light/(n0+(n1-n0)/G4Log(E1/E0));
424 
425  // allow only for 'normal dispersion' -> dn/d(logE) > 0
426  //
427  if((vg<0) || (vg>c_light/n0)) { vg = c_light/n0; }
428 
429  groupvel->InsertValues( E0, vg );
430 
431  // add entries at midpoints between remaining photon energies
432  //
433 
434  for (size_t i = 2; i < rindex->GetVectorLength(); i++)
435  {
436  vg = c_light/( 0.5*(n0+n1)+(n1-n0)/G4Log(E1/E0));
437 
438  // allow only for 'normal dispersion' -> dn/d(logE) > 0
439  //
440  if((vg<0) || (vg>c_light/(0.5*(n0+n1)))) { vg = c_light/(0.5*(n0+n1)); }
441  groupvel->InsertValues( 0.5*(E0+E1), vg );
442 
443  // get next energy/value pair, or exit loop
444  //
445  E0 = E1;
446  n0 = n1;
447  E1 = rindex->Energy(i);
448  n1 = (*rindex)[i];
449 
450  if (E1 <= 0.)
451  {
452  G4Exception("G4MaterialPropertiesTable::CalculateGROUPVEL()", "mat205",
453  FatalException, "Optical Photon Energy <= 0");
454  }
455  }
456 
457  // add entry at last photon energy
458  //
459  vg = c_light/(n1+(n1-n0)/G4Log(E1/E0));
460 
461  // allow only for 'normal dispersion' -> dn/d(logE) > 0
462  //
463  if((vg<0) || (vg>c_light/n1)) { vg = c_light/n1; }
464  groupvel->InsertValues( E1, vg );
465  }
466  else // only one entry in RINDEX -- weird!
467  {
468  groupvel->InsertValues( E0, c_light/n0 );
469  }
470 
471  this->AddProperty( "GROUPVEL", groupvel );
472 
473  return groupvel;
474 }
475 
477 {
478  G4String message("SetGROUPVEL will be obsolete from the next release ");
479  message += "Use G4MaterialPropertiesTable::CalculateGROUPVEL() instead";
480 
481  G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "Obsolete",
482  JustWarning, message);
483  return CalculateGROUPVEL();
484 }
485 
486 std::map< G4String, G4MaterialPropertyVector*, std::less<G4String> >*
488 {
489  // warning message
490  G4String message("GetPropertiesMap will be obsolete from the next release ");
491  message += "Use G4MaterialPropertiesTable::GetPropertyMap() instead";
492  G4Exception("G4MaterialPropertiesTable::GetPropertiesMap()", "Obsolete",
493  JustWarning, message);
494 
495  for (MPiterator miter = MP.begin(); miter != MP.end(); miter++)
496  {
497  if(miter->second) {
498  MPT [ G4MaterialPropertyName[miter->first] ] = miter->second;
499  }
500  else {
501  G4Exception("G4MaterialPropertiesTable::GetPropertiesMap()","NullPointer",
502  JustWarning, "Null Pointer for Material Property");
503  continue;
504  }
505  }
506  return &MPT;
507 }
508 
509 std::map< G4String, G4double, std::less<G4String> >* G4MaterialPropertiesTable::GetPropertiesCMap()
510 {
511  // warning message
512  G4String message("GetPropertiesCMap will be obsolete from the next release ");
513  message += "Use G4MaterialPropertiesTable::GetConstPropertyMap() instead";
514  G4Exception("G4MaterialPropertiesTable::GetPropertiesCMap()", "Obsolete",
515  JustWarning, message);
516 
517  for (MCPiterator miter = MCP.begin(); miter != MCP.end(); miter++) {
518  MPTC[ G4MaterialConstPropertyName[miter->first] ] = miter->second;
519  }
520  return &MPTC;
521 }
522 
524 {
525  return G4MaterialPropertyName;;
526 }
527 
529 {
531 }
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
std::map< G4String, G4MaterialPropertyVector *, std::less< G4String > >::const_iterator MPTiterator
G4double GetConstProperty(const char *key) const
std::map< G4int, G4double, std::less< G4int > >::const_iterator MCPiterator
void InsertValues(G4double energy, G4double value)
G4PhysicsOrderedFreeVector G4MaterialPropertyVector
#define G4endl
Definition: G4ios.hh:61
void message(RunManager *runmanager)
Definition: ts_scorers.cc:72
std::vector< G4String > GetMaterialPropertyNames() const
G4double G4Log(G4double x)
Definition: G4Log.hh:230
std::map< G4String, G4double, std::less< G4String > > MPTC
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:88
G4bool ConstPropertyExists(const char *key) const
if(nlines<=0)
G4MaterialPropertyVector * CalculateGROUPVEL()
G4MaterialPropertyVector * AddProperty(const char *key, G4double *PhotonEnergies, G4double *PropertyValues, G4int NumEntries)
void AddEntry(const char *key, G4double aPhotonEnergy, G4double aPropertyValue)
std::map< G4String, G4MaterialPropertyVector *, std::less< G4String > > * GetPropertiesMap()
G4int GetPropertyIndex(const G4String &key, G4bool warning=false) const
std::vector< G4String > G4MaterialConstPropertyName
std::map< G4int, G4MaterialPropertyVector *, std::less< G4int > > MP
std::map< G4String, G4double, std::less< G4String > > * GetPropertiesCMap()
std::map< G4int, G4double, std::less< G4int > > MCP
std::vector< G4String > G4MaterialPropertyName
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
static constexpr double c_light
std::vector< G4String > GetMaterialConstPropertyNames() const
G4MaterialPropertyVector * SetGROUPVEL()
std::map< G4String, G4MaterialPropertyVector *, std::less< G4String > > MPT
G4int GetConstPropertyIndex(const G4String &key, G4bool warning=false) const
G4GLOB_DLL std::ostream G4cout
G4MaterialPropertyVector * GetProperty(const char *key, G4bool warning=false)
std::map< G4int, G4MaterialPropertyVector *, std::less< G4int > >::const_iterator MPiterator
std::mutex G4Mutex
Definition: G4Threading.hh:84