Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/materials/src/G4MaterialPropertiesTable.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /materials/src/G4MaterialPropertiesTable.cc (Version 11.3.0) and /materials/src/G4MaterialPropertiesTable.cc (Version 9.6.p4)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25                                                <<  25 //
                                                   >>  26 //
                                                   >>  27 // $Id: G4MaterialPropertiesTable.cc 67044 2013-01-30 08:50:06Z gcosmo $
                                                   >>  28 //
                                                   >>  29 // 
 26 //////////////////////////////////////////////     30 ////////////////////////////////////////////////////////////////////////
 27 // G4MaterialPropertiesTable Implementation        31 // G4MaterialPropertiesTable Implementation
 28 //////////////////////////////////////////////     32 ////////////////////////////////////////////////////////////////////////
 29 //                                                 33 //
 30 // File: G4MaterialPropertiesTable.cc          <<  34 // File: G4MaterialPropertiesTable.cc 
 31 // Version:     1.0                                35 // Version:     1.0
 32 // Created:     1996-02-08                         36 // Created:     1996-02-08
 33 // Author:      Juliet Armstrong                   37 // Author:      Juliet Armstrong
 34 // Updated:     2005-05-12 add SetGROUPVEL(),      38 // Updated:     2005-05-12 add SetGROUPVEL(), courtesy of
 35 //              Horton-Smith (bug report #741)     39 //              Horton-Smith (bug report #741), by P. Gumplinger
 36 //              2002-11-05 add named material      40 //              2002-11-05 add named material constants by P. Gumplinger
 37 //              1999-11-05 Migration from G4RW     41 //              1999-11-05 Migration from G4RWTPtrHashDictionary to STL
 38 //                         by John Allison         42 //                         by John Allison
 39 //              1997-03-26 by Peter Gumplinger     43 //              1997-03-26 by Peter Gumplinger
 40 //              > cosmetics (only)                 44 //              > cosmetics (only)
                                                   >>  45 // mail:        gum@triumf.ca
 41 //                                                 46 //
 42 //////////////////////////////////////////////     47 ////////////////////////////////////////////////////////////////////////
 43                                                    48 
                                                   >>  49 #include "globals.hh"
 44 #include "G4MaterialPropertiesTable.hh"            50 #include "G4MaterialPropertiesTable.hh"
 45                                                << 
 46 #include "G4Log.hh"                            << 
 47 #include "G4OpticalMaterialProperties.hh"      << 
 48 #include "G4PhysicalConstants.hh"                  51 #include "G4PhysicalConstants.hh"
 49 #include "globals.hh"                          << 
 50                                                << 
 51 #include <algorithm>                           << 
 52 #include <cassert>                             << 
 53                                                    52 
 54 #ifdef G4MULTITHREADED                         <<  53 /////////////////
 55 #  include "G4AutoLock.hh"                     <<  54 // Constructors
 56 namespace                                      <<  55 /////////////////
 57 {                                              << 
 58 G4Mutex materialPropertyTableMutex = G4MUTEX_I << 
 59 }                                              << 
 60 #endif                                         << 
 61                                                    56 
 62 G4MaterialPropertiesTable::G4MaterialPropertie     57 G4MaterialPropertiesTable::G4MaterialPropertiesTable()
 63 {                                                  58 {
 64   // elements of these 2 vectors must be in sa << 
 65   // the corresponding enums in G4MaterialProp << 
 66   fMatPropNames.assign(kNumberOfPropertyIndex, << 
 67   fMatPropNames[kRINDEX] =                     << 
 68   fMatPropNames[kREFLECTIVITY] =               << 
 69   fMatPropNames[kREALRINDEX] =                 << 
 70   fMatPropNames[kIMAGINARYRINDEX] =            << 
 71   fMatPropNames[kEFFICIENCY] =                 << 
 72   fMatPropNames[kTRANSMITTANCE] =              << 
 73   fMatPropNames[kSPECULARLOBECONSTANT] =       << 
 74   fMatPropNames[kSPECULARSPIKECONSTANT] =      << 
 75   fMatPropNames[kBACKSCATTERCONSTANT] =        << 
 76   fMatPropNames[kGROUPVEL] =                   << 
 77   fMatPropNames[kMIEHG] =                      << 
 78   fMatPropNames[kRAYLEIGH] =                   << 
 79   fMatPropNames[kWLSCOMPONENT] =               << 
 80   fMatPropNames[kWLSABSLENGTH] =               << 
 81   fMatPropNames[kWLSCOMPONENT2] =              << 
 82   fMatPropNames[kWLSABSLENGTH2] =              << 
 83   fMatPropNames[kABSLENGTH] =                  << 
 84   fMatPropNames[kPROTONSCINTILLATIONYIELD] =   << 
 85   fMatPropNames[kDEUTERONSCINTILLATIONYIELD] = << 
 86   fMatPropNames[kTRITONSCINTILLATIONYIELD] =   << 
 87   fMatPropNames[kALPHASCINTILLATIONYIELD] =    << 
 88   fMatPropNames[kIONSCINTILLATIONYIELD] =      << 
 89   fMatPropNames[kELECTRONSCINTILLATIONYIELD] = << 
 90   fMatPropNames[kSCINTILLATIONCOMPONENT1] =    << 
 91   fMatPropNames[kSCINTILLATIONCOMPONENT2] =    << 
 92   fMatPropNames[kSCINTILLATIONCOMPONENT3] =    << 
 93   fMatPropNames[kCOATEDRINDEX] =               << 
 94                                                << 
 95   fMP.assign(kNumberOfPropertyIndex, nullptr); << 
 96                                                << 
 97   fMatConstPropNames.assign(kNumberOfConstProp << 
 98   fMatConstPropNames[kSURFACEROUGHNESS] =      << 
 99   fMatConstPropNames[kISOTHERMAL_COMPRESSIBILI << 
100   fMatConstPropNames[kRS_SCALE_FACTOR] =       << 
101   fMatConstPropNames[kWLSMEANNUMBERPHOTONS] =  << 
102   fMatConstPropNames[kWLSTIMECONSTANT] =       << 
103   fMatConstPropNames[kWLSMEANNUMBERPHOTONS2] = << 
104   fMatConstPropNames[kWLSTIMECONSTANT2] =      << 
105   fMatConstPropNames[kMIEHG_FORWARD] =         << 
106   fMatConstPropNames[kMIEHG_BACKWARD] =        << 
107   fMatConstPropNames[kMIEHG_FORWARD_RATIO] =   << 
108   fMatConstPropNames[kSCINTILLATIONYIELD] =    << 
109   fMatConstPropNames[kRESOLUTIONSCALE] =       << 
110   fMatConstPropNames[kFERMIPOT] =              << 
111   fMatConstPropNames[kDIFFUSION] =             << 
112   fMatConstPropNames[kSPINFLIP] =              << 
113   fMatConstPropNames[kLOSS] =                  << 
114   fMatConstPropNames[kLOSSCS] =                << 
115   fMatConstPropNames[kABSCS] =                 << 
116   fMatConstPropNames[kSCATCS] =                << 
117   fMatConstPropNames[kMR_NBTHETA] =            << 
118   fMatConstPropNames[kMR_NBE] =                << 
119   fMatConstPropNames[kMR_RRMS] =               << 
120   fMatConstPropNames[kMR_CORRLEN] =            << 
121   fMatConstPropNames[kMR_THETAMIN] =           << 
122   fMatConstPropNames[kMR_THETAMAX] =           << 
123   fMatConstPropNames[kMR_EMIN] =               << 
124   fMatConstPropNames[kMR_EMAX] =               << 
125   fMatConstPropNames[kMR_ANGNOTHETA] =         << 
126   fMatConstPropNames[kMR_ANGNOPHI] =           << 
127   fMatConstPropNames[kMR_ANGCUT] =             << 
128   fMatConstPropNames[kSCINTILLATIONTIMECONSTAN << 
129   fMatConstPropNames[kSCINTILLATIONTIMECONSTAN << 
130   fMatConstPropNames[kSCINTILLATIONTIMECONSTAN << 
131   fMatConstPropNames[kSCINTILLATIONRISETIME1]  << 
132   fMatConstPropNames[kSCINTILLATIONRISETIME2]  << 
133   fMatConstPropNames[kSCINTILLATIONRISETIME3]  << 
134   fMatConstPropNames[kSCINTILLATIONYIELD1] =   << 
135   fMatConstPropNames[kSCINTILLATIONYIELD2] =   << 
136   fMatConstPropNames[kSCINTILLATIONYIELD3] =   << 
137   fMatConstPropNames[kPROTONSCINTILLATIONYIELD << 
138   fMatConstPropNames[kPROTONSCINTILLATIONYIELD << 
139   fMatConstPropNames[kPROTONSCINTILLATIONYIELD << 
140   fMatConstPropNames[kDEUTERONSCINTILLATIONYIE << 
141   fMatConstPropNames[kDEUTERONSCINTILLATIONYIE << 
142   fMatConstPropNames[kDEUTERONSCINTILLATIONYIE << 
143   fMatConstPropNames[kTRITONSCINTILLATIONYIELD << 
144   fMatConstPropNames[kTRITONSCINTILLATIONYIELD << 
145   fMatConstPropNames[kTRITONSCINTILLATIONYIELD << 
146   fMatConstPropNames[kALPHASCINTILLATIONYIELD1 << 
147   fMatConstPropNames[kALPHASCINTILLATIONYIELD2 << 
148   fMatConstPropNames[kALPHASCINTILLATIONYIELD3 << 
149   fMatConstPropNames[kIONSCINTILLATIONYIELD1]  << 
150   fMatConstPropNames[kIONSCINTILLATIONYIELD2]  << 
151   fMatConstPropNames[kIONSCINTILLATIONYIELD3]  << 
152   fMatConstPropNames[kELECTRONSCINTILLATIONYIE << 
153   fMatConstPropNames[kELECTRONSCINTILLATIONYIE << 
154   fMatConstPropNames[kELECTRONSCINTILLATIONYIE << 
155   fMatConstPropNames[kCOATEDTHICKNESS] =       << 
156   fMatConstPropNames[kCOATEDFRUSTRATEDTRANSMIS << 
157   fMatConstPropNames[kPROTONSCINTILLATIONTIMEC << 
158   fMatConstPropNames[kPROTONSCINTILLATIONTIMEC << 
159   fMatConstPropNames[kPROTONSCINTILLATIONTIMEC << 
160   fMatConstPropNames[kDEUTERONSCINTILLATIONTIM << 
161   fMatConstPropNames[kDEUTERONSCINTILLATIONTIM << 
162   fMatConstPropNames[kDEUTERONSCINTILLATIONTIM << 
163   fMatConstPropNames[kTRITONSCINTILLATIONTIMEC << 
164   fMatConstPropNames[kTRITONSCINTILLATIONTIMEC << 
165   fMatConstPropNames[kTRITONSCINTILLATIONTIMEC << 
166   fMatConstPropNames[kALPHASCINTILLATIONTIMECO << 
167   fMatConstPropNames[kALPHASCINTILLATIONTIMECO << 
168   fMatConstPropNames[kALPHASCINTILLATIONTIMECO << 
169   fMatConstPropNames[kIONSCINTILLATIONTIMECONS << 
170   fMatConstPropNames[kIONSCINTILLATIONTIMECONS << 
171   fMatConstPropNames[kIONSCINTILLATIONTIMECONS << 
172   fMatConstPropNames[kELECTRONSCINTILLATIONTIM << 
173   fMatConstPropNames[kELECTRONSCINTILLATIONTIM << 
174   fMatConstPropNames[kELECTRONSCINTILLATIONTIM << 
175   fMCP.assign(kNumberOfConstPropertyIndex, {0. << 
176 }                                              << 
177                                                << 
178 G4MaterialPropertiesTable::~G4MaterialProperti << 
179 {                                              << 
180   for (auto prop : fMP) {                      << 
181     delete (prop);                             << 
182   }                                            << 
183 }                                              << 
184                                                << 
185 G4int G4MaterialPropertiesTable::GetConstPrope << 
186 {                                              << 
187   // Returns the constant material property in << 
188                                                << 
189   std::size_t index = std::distance(fMatConstP << 
190     std::find(fMatConstPropNames.cbegin(), fMa << 
191   if (index < fMatConstPropNames.size()) {     << 
192     return (G4int)index;                       << 
193   }                                            << 
194                                                << 
195   G4ExceptionDescription ed;                   << 
196   ed << "Constant Material Property Index for  << 
197   G4Exception("G4MaterialPropertiesTable::GetC << 
198   return 0;                                    << 
199 }                                              << 
200                                                << 
201 G4int G4MaterialPropertiesTable::GetPropertyIn << 
202 {                                              << 
203   // Returns the material property index corre << 
204   std::size_t index = std::distance(           << 
205     fMatPropNames.cbegin(), std::find(fMatProp << 
206   if (index < fMatPropNames.size()) {          << 
207     return (G4int)index;                       << 
208   }                                            << 
209   G4ExceptionDescription ed;                   << 
210   ed << "Material Property Index for key " <<  << 
211   G4Exception("G4MaterialPropertiesTable::GetP << 
212   return 0;                                    << 
213 }                                              << 
214                                                << 
215 G4double G4MaterialPropertiesTable::GetConstPr << 
216 {                                              << 
217   // Returns the constant material property co << 
218   // fatal exception if property not found     << 
219                                                << 
220   if (index < (G4int)fMCP.size() && fMCP[index << 
221     return fMCP[index].first;                  << 
222   }                                            << 
223   G4ExceptionDescription ed;                   << 
224   ed << "Constant Material Property " << fMatC << 
225   G4Exception("G4MaterialPropertiesTable::GetC << 
226   return 0.;                                   << 
227 }                                              << 
228                                                << 
229 G4double G4MaterialPropertiesTable::GetConstPr << 
230 {                                              << 
231   // Returns the constant material property co << 
232   // fatal exception if property not found     << 
233                                                << 
234   return GetConstProperty(GetConstPropertyInde << 
235 }                                              << 
236                                                << 
237 G4double G4MaterialPropertiesTable::GetConstPr << 
238 {                                              << 
239   return GetConstProperty(GetConstPropertyInde << 
240 }                                                  59 }
241                                                    60 
242 G4bool G4MaterialPropertiesTable::ConstPropert <<  61 ////////////////
243 {                                              <<  62 // Destructor
244   // Returns true if a const property correspo <<  63 ////////////////
245                                                << 
246   return index >= 0 && index < (G4int)fMCP.siz << 
247 }                                              << 
248                                                << 
249 G4bool G4MaterialPropertiesTable::ConstPropert << 
250 {                                              << 
251   // Returns true if a const property 'key' ex << 
252   std::size_t index = std::distance(fMatConstP << 
253     std::find(fMatConstPropNames.cbegin(), fMa << 
254   if (index < fMatConstPropNames.size()) {  // << 
255     return ConstPropertyExists((G4int)index);  << 
256   }                                            << 
257   return false;                                << 
258 }                                              << 
259                                                << 
260 G4bool G4MaterialPropertiesTable::ConstPropert << 
261 {                                              << 
262   std::size_t index = std::distance(fMatConstP << 
263     std::find(fMatConstPropNames.cbegin(), fMa << 
264   if (index < fMatConstPropNames.size()) {  // << 
265     return ConstPropertyExists((G4int)index);  << 
266   }                                            << 
267   return false;                                << 
268 }                                              << 
269                                                << 
270 G4MaterialPropertyVector* G4MaterialProperties << 
271 {                                              << 
272   // Returns a Material Property Vector corres << 
273   if (std::find(fMatPropNames.cbegin(), fMatPr << 
274     const G4int index = GetPropertyIndex(G4Str << 
275     return GetProperty(index);                 << 
276   }                                            << 
277   return nullptr;                              << 
278 }                                              << 
279                                                << 
280 G4MaterialPropertyVector* G4MaterialProperties << 
281 {                                              << 
282   if (std::find(fMatPropNames.cbegin(), fMatPr << 
283     const G4int index = GetPropertyIndex(G4Str << 
284     return GetProperty(index);                 << 
285   }                                            << 
286   return nullptr;                              << 
287 }                                              << 
288                                                << 
289 G4MaterialPropertyVector* G4MaterialProperties << 
290 {                                              << 
291   // Returns a Material Property Vector corres << 
292   // returns nullptr if the property has not b << 
293   if (index >= 0 && index < (G4int)fMP.size()) << 
294     return fMP[index];                         << 
295   }                                            << 
296   return nullptr;                              << 
297 }                                              << 
298                                                << 
299 G4MaterialPropertyVector* G4MaterialProperties << 
300   const std::vector<G4double>& photonEnergies, << 
301   G4bool createNewKey, G4bool spline)          << 
302 {                                              << 
303   if (photonEnergies.size() != propertyValues. << 
304     G4ExceptionDescription ed;                 << 
305     ed << "AddProperty error. Number of proper << 
306        << "energy values. Property name: " <<  << 
307     G4Exception("G4MaterialPropertiesTable::Ad << 
308   }                                            << 
309                                                << 
310   if (photonEnergies.size() == 1) {            << 
311     G4ExceptionDescription ed;                 << 
312     ed << "AddProperty warning. A material pro << 
313        << "Unless you will later add an entry, << 
314        << "Property name: " << key;            << 
315     G4Exception("G4MaterialPropertiesTable::Ad << 
316   }                                            << 
317                                                << 
318   // G4PhysicsVector assumes energies are in i << 
319   for (std::size_t i = 0; i < photonEnergies.s << 
320     if (photonEnergies.at(i + 1) < photonEnerg << 
321       G4ExceptionDescription ed;               << 
322       ed << "Energies in material property vec << 
323          << "order. Key: " << key << " Energy: << 
324       G4Exception("G4MaterialPropertiesTable:: << 
325     }                                          << 
326   }                                            << 
327                                                << 
328   // if the key doesn't exist, add it if reque << 
329   if (std::find(fMatPropNames.cbegin(), fMatPr << 
330     if (createNewKey) {                        << 
331       fMatPropNames.push_back(key);            << 
332       fMP.push_back(nullptr);                  << 
333     }                                          << 
334     else {                                     << 
335       G4ExceptionDescription ed;               << 
336       ed << "Attempting to create a new materi << 
337          << "createNewKey parameter of AddProp << 
338       G4Exception("G4MaterialPropertiesTable:: << 
339     }                                          << 
340   }                                            << 
341                                                << 
342   auto* mpv = new G4MaterialPropertyVector(pho << 
343   mpv->SetVerboseLevel(1);                     << 
344   if (spline) {                                << 
345     mpv->FillSecondDerivatives();              << 
346   }                                            << 
347   G4int index = GetPropertyIndex(key);         << 
348   fMP[index] = mpv;                            << 
349                                                    64 
350   // if key is RINDEX, we calculate GROUPVEL - <<  65 G4MaterialPropertiesTable::~G4MaterialPropertiesTable()
351   // contribution from Tao Lin (IHEP, the JUNO << 
352   if (key == "RINDEX") {                       << 
353     CalculateGROUPVEL();                       << 
354   }                                            << 
355                                                << 
356   return mpv;                                  << 
357 }                                              << 
358                                                << 
359 G4MaterialPropertyVector* G4MaterialProperties << 
360   G4double* photonEnergies, G4double* property << 
361   G4bool spline)                               << 
362 {                                              << 
363   // Provides a way of adding a property to th << 
364   // Table given a pair of arrays and a key    << 
365   G4String k(key);                             << 
366                                                << 
367   std::vector<G4double> energies(photonEnergie << 
368   std::vector<G4double> values(propertyValues, << 
369   return AddProperty(k, energies, values, crea << 
370 }                                              << 
371                                                << 
372 void G4MaterialPropertiesTable::AddProperty(   << 
373   const G4String& key, G4MaterialPropertyVecto << 
374 {                                              << 
375   //  Provides a way of adding a property to t << 
376   //  Table given an G4MaterialPropertyVector  << 
377                                                << 
378   // G4PhysicsVector assumes energies are in i << 
379   if (mpv->GetVectorLength() > 1) {            << 
380     for (std::size_t i = 0; i < mpv->GetVector << 
381       if (mpv->Energy(i + 1) < mpv->Energy(i)) << 
382         G4ExceptionDescription ed;             << 
383         ed << "Energies in material property v << 
384            << "order. Key: " << key << " Energ << 
385         G4Exception("G4MaterialPropertiesTable << 
386       }                                        << 
387     }                                          << 
388   }                                            << 
389                                                << 
390   if (mpv->GetVectorLength() <= 1) {           << 
391     G4ExceptionDescription ed;                 << 
392     ed << "AddProperty warning. A material pro << 
393        << "Unless you will later add an entry, << 
394        << "Property name: " << key;            << 
395     G4Exception("G4MaterialPropertiesTable::Ad << 
396   }                                            << 
397                                                << 
398   // if the key doesn't exist, add it          << 
399   if (std::find(fMatPropNames.cbegin(), fMatPr << 
400     if (createNewKey) {                        << 
401       fMatPropNames.push_back(key);            << 
402       fMP.push_back(nullptr);                  << 
403     }                                          << 
404     else {                                     << 
405       G4ExceptionDescription ed;               << 
406       ed << "Attempting to create a new materi << 
407          << "createNewKey parameter of AddProp << 
408       G4Exception("G4MaterialPropertiesTable:: << 
409     }                                          << 
410   }                                            << 
411   G4int index = GetPropertyIndex(key);         << 
412   fMP[index] = mpv;                            << 
413                                                << 
414   // if key is RINDEX, we calculate GROUPVEL - << 
415   // contribution from Tao Lin (IHEP, the JUNO << 
416   if (key == "RINDEX") {                       << 
417     CalculateGROUPVEL();                       << 
418   }                                            << 
419 }                                              << 
420                                                << 
421 void G4MaterialPropertiesTable::AddProperty(   << 
422   const char* key, G4MaterialPropertyVector* m << 
423 {                                              << 
424   AddProperty(G4String(key), mpv, createNewKey << 
425 }                                              << 
426                                                << 
427 void G4MaterialPropertiesTable::AddProperty(co << 
428 {                                              << 
429   // load a material property vector defined i << 
430   G4MaterialPropertyVector* v = G4OpticalMater << 
431   AddProperty(key, v);                         << 
432 }                                              << 
433                                                << 
434 void G4MaterialPropertiesTable::AddConstProper << 
435   const G4String& key, G4double propertyValue, << 
436 {                                                  66 {
437   // Provides a way of adding a constant prope <<  67   MPTiterator i;
438   // Table given a key                         <<  68   for (i = MPT.begin(); i != MPT.end(); ++i)
439   if (std::find(fMatConstPropNames.cbegin(), f << 
440       fMatConstPropNames.cend())               << 
441   {                                                69   {
442     if (createNewKey) {                        <<  70     delete (*i).second;
443       fMatConstPropNames.push_back(key);       << 
444       fMCP.emplace_back(0., true);             << 
445     }                                          << 
446     else {                                     << 
447       G4ExceptionDescription ed;               << 
448       ed << "Attempting to create a new materi << 
449          << " without setting\n"               << 
450          << "createNewKey parameter of AddProp << 
451       G4Exception("G4MaterialPropertiesTable:: << 
452     }                                          << 
453   }                                                71   }
454   G4int index = GetConstPropertyIndex(key);    <<  72   MPT.clear();
455                                                <<  73   MPTC.clear();
456   fMCP[index] = std::pair<G4double, G4bool>{pr << 
457 }                                                  74 }
458                                                    75 
459 void G4MaterialPropertiesTable::AddConstProper <<  76 ////////////
460   const char* key, G4double propertyValue, G4b <<  77 // Methods
461 {                                              <<  78 ////////////
462   // Provides a way of adding a constant prope << 
463   // Table given a key                         << 
464   AddConstProperty(G4String(key), propertyValu << 
465 }                                              << 
466                                                    79 
467 void G4MaterialPropertiesTable::RemoveConstPro <<  80 void G4MaterialPropertiesTable::DumpTable()
468 {                                                  81 {
469   G4int index = GetConstPropertyIndex(key);    <<  82   MPTiterator i;
470   if (index < (G4int)fMCP.size()) {            <<  83   for (i = MPT.begin(); i != MPT.end(); ++i)
471     fMCP[index] = std::pair<G4double, G4bool>{ <<  84   {
472   }                                            <<  85     G4cout << (*i).first << G4endl;
473 }                                              <<  86     if ( (*i).second != 0 )
474                                                <<  87     {
475 void G4MaterialPropertiesTable::RemoveConstPro <<  88       (*i).second->DumpValues();
476 {                                              <<  89     }
477   RemoveConstProperty(G4String(key));          <<  90     else
478 }                                              <<  91     {
479                                                <<  92       G4Exception("G4MaterialPropertiesTable::DumpTable()", "mat204",
480 void G4MaterialPropertiesTable::RemoveProperty <<  93                   JustWarning, "NULL Material Property Vector Pointer.");
481 {                                              << 
482   G4int index = GetPropertyIndex(key);         << 
483   delete fMP[index];                           << 
484   fMP[index] = nullptr;                        << 
485 }                                              << 
486                                                << 
487 void G4MaterialPropertiesTable::RemoveProperty << 
488                                                << 
489 void G4MaterialPropertiesTable::AddEntry(      << 
490   const G4String& key, G4double aPhotonEnergy, << 
491 {                                              << 
492   // Allows to add an entry pair directly to t << 
493   // given a key.                              << 
494   if (std::find(fMatPropNames.cbegin(), fMatPr << 
495     G4ExceptionDescription ed;                 << 
496     ed << "Material Property Vector " << key < << 
497     G4Exception("G4MaterialPropertiesTable::Ad << 
498   }                                            << 
499   G4int index = GetPropertyIndex(key);         << 
500                                                << 
501   G4MaterialPropertyVector* targetVector = fMP << 
502   if (targetVector != nullptr) {               << 
503     // do not allow duplicate energies         << 
504     for (std::size_t i = 0; i < targetVector-> << 
505       if (aPhotonEnergy == targetVector->Energ << 
506         G4ExceptionDescription ed;             << 
507         ed << "Energy values in material prope << 
508            << "Key: " << key;                  << 
509         G4Exception("G4MaterialPropertiesTable << 
510       }                                        << 
511     }                                              94     }
512                                                << 
513     targetVector->InsertValues(aPhotonEnergy,  << 
514   }                                            << 
515   else {                                       << 
516     G4ExceptionDescription ed;                 << 
517     ed << "Material Property Vector " << key < << 
518     G4Exception("G4MaterialPropertiesTable::Ad << 
519   }                                                95   }
520   if (key == "RINDEX") {                       <<  96   MPTCiterator j;
521     CalculateGROUPVEL();                       <<  97   for (j = MPTC.begin(); j != MPTC.end(); ++j)
522   }                                            <<  98   {
523 }                                              <<  99     G4cout << j->first << G4endl;
524                                                << 100     if ( j->second != 0 )
525 void G4MaterialPropertiesTable::AddEntry(      << 101     {
526   const char* key, G4double aPhotonEnergy, G4d << 102       G4cout << j->second << G4endl;
527 {                                              << 
528   AddEntry(G4String(key), aPhotonEnergy, aProp << 
529 }                                              << 
530                                                << 
531 void G4MaterialPropertiesTable::DumpTable() co << 
532 {                                              << 
533   // material properties                       << 
534   G4int j = 0;                                 << 
535   for (const auto& prop : fMP) {               << 
536     if (prop != nullptr) {                     << 
537       G4cout << j << ": " << fMatPropNames[j]  << 
538       prop->DumpValues();                      << 
539     }                                             103     }
540     ++j;                                       << 104     else
541   }                                            << 105     {
542   // material constant properties              << 106       G4Exception("G4MaterialPropertiesTable::DumpTable()", "mat202",
543   j = 0;                                       << 107                   JustWarning, "No Material Constant Property.");
544   for (const auto& cprop : fMCP) {             << 
545     if (cprop.second) {                        << 
546       G4cout << j << ": " << fMatConstPropName << 
547     }                                             108     }
548     ++j;                                       << 
549   }                                               109   }
550 }                                                 110 }
551                                                   111 
552 G4MaterialPropertyVector* G4MaterialProperties << 112 G4MaterialPropertyVector* G4MaterialPropertiesTable::SetGROUPVEL()
553 {                                                 113 {
554 #ifdef G4MULTITHREADED                         << 
555   G4AutoLock mptm(&materialPropertyTableMutex) << 
556 #endif                                         << 
557                                                << 
558   // check if "GROUPVEL" already exists. If so << 
559   if (fMP[kGROUPVEL] != nullptr) {             << 
560     this->RemoveProperty("GROUPVEL");          << 
561   }                                            << 
562                                                << 
563   // fetch RINDEX data, give up if unavailable    114   // fetch RINDEX data, give up if unavailable
564   G4MaterialPropertyVector* rindex = this->Get << 115   //
565   if (rindex == nullptr) {                     << 116   G4MaterialPropertyVector *rindex = this->GetProperty("RINDEX");
566     return nullptr;                            << 117   if (rindex==0)  { return 0; }
567   }                                            << 
568                                                   118 
569   // RINDEX exists but has no entries, give up    119   // RINDEX exists but has no entries, give up
570   if (rindex->GetVectorLength() == 0) {        << 120   //
571     return nullptr;                            << 121   if ( rindex->GetVectorLength() == 0 ) { return 0; }
572   }                                            << 
573                                                   122 
574   // add GROUPVEL vector                          123   // add GROUPVEL vector
575   auto* groupvel = new G4MaterialPropertyVecto << 124   //
576   groupvel->SetVerboseLevel(1);                << 125   G4MaterialPropertyVector* groupvel = new G4MaterialPropertyVector();
577                                                   126 
                                                   >> 127   this->AddProperty( "GROUPVEL", groupvel );
                                                   >> 128                                                                                 
578   // fill GROUPVEL vector using RINDEX values     129   // fill GROUPVEL vector using RINDEX values
579   // rindex built-in "iterator" was advanced t    130   // rindex built-in "iterator" was advanced to first entry above
                                                   >> 131   //
580   G4double E0 = rindex->Energy(0);                132   G4double E0 = rindex->Energy(0);
581   G4double n0 = (*rindex)[0];                     133   G4double n0 = (*rindex)[0];
582                                                   134 
583   if (E0 <= 0.) {                              << 135   if (E0 <= 0.)
584     G4Exception("G4MaterialPropertiesTable::Ca << 136   {
585       "Optical Photon Energy <= 0");           << 137     G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "mat205",
                                                   >> 138                 FatalException, "Optical Photon Energy <= 0");
586   }                                               139   }
587                                                << 140                                                                                 
588   if (rindex->GetVectorLength() >= 2) {        << 141   if ( rindex->GetVectorLength() >= 2 )
                                                   >> 142   {
589     // good, we have at least two entries in R    143     // good, we have at least two entries in RINDEX
590     // get next energy/value pair                 144     // get next energy/value pair
591                                                   145 
592     G4double E1 = rindex->Energy(1);              146     G4double E1 = rindex->Energy(1);
593     G4double n1 = (*rindex)[1];                   147     G4double n1 = (*rindex)[1];
594                                                   148 
595     if (E1 <= 0.) {                            << 149     if (E1 <= 0.)
596       G4Exception("G4MaterialPropertiesTable:: << 150     {
597         "Optical Photon Energy <= 0");         << 151       G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "mat205",
                                                   >> 152                   FatalException, "Optical Photon Energy <= 0");
598     }                                             153     }
599                                                   154 
600     G4double vg;                                  155     G4double vg;
601                                                   156 
602     // add entry at first photon energy           157     // add entry at first photon energy
603     vg = c_light / (n0 + (n1 - n0) / G4Log(E1  << 158     //
                                                   >> 159     vg = c_light/(n0+(n1-n0)/std::log(E1/E0));
604                                                   160 
605     // allow only for 'normal dispersion' -> d    161     // allow only for 'normal dispersion' -> dn/d(logE) > 0
606     if ((vg < 0) || (vg > c_light / n0)) {     << 162     //
607       vg = c_light / n0;                       << 163     if((vg<0) || (vg>c_light/n0))  { vg = c_light/n0; }
608     }                                          << 
609                                                   164 
610     groupvel->InsertValues(E0, vg);            << 165     groupvel->InsertValues( E0, vg );
611                                                   166 
612     // add entries at midpoints between remain    167     // add entries at midpoints between remaining photon energies
613     for (std::size_t i = 2; i < rindex->GetVec << 168     //
614       vg = c_light / (0.5 * (n0 + n1) + (n1 -  << 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));
615                                                   173 
616       // allow only for 'normal dispersion' ->    174       // allow only for 'normal dispersion' -> dn/d(logE) > 0
617       if ((vg < 0) || (vg > c_light / (0.5 * ( << 175       //
618         vg = c_light / (0.5 * (n0 + n1));      << 176       if((vg<0) || (vg>c_light/(0.5*(n0+n1))))  { vg = c_light/(0.5*(n0+n1)); }
619       }                                        << 177       groupvel->InsertValues( 0.5*(E0+E1), vg );
620       groupvel->InsertValues(0.5 * (E0 + E1),  << 
621                                                   178 
622       // get next energy/value pair, or exit l    179       // get next energy/value pair, or exit loop
                                                   >> 180       //
623       E0 = E1;                                    181       E0 = E1;
624       n0 = n1;                                    182       n0 = n1;
625       E1 = rindex->Energy(i);                     183       E1 = rindex->Energy(i);
626       n1 = (*rindex)[i];                          184       n1 = (*rindex)[i];
627                                                   185 
628       if (E1 <= 0.) {                          << 186       if (E1 <= 0.)
629         G4Exception("G4MaterialPropertiesTable << 187       {
630           "Optical Photon Energy <= 0");       << 188         G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "mat205",
                                                   >> 189                     FatalException, "Optical Photon Energy <= 0");
631       }                                           190       }
632     }                                             191     }
633                                                   192 
634     // add entry at last photon energy            193     // add entry at last photon energy
635     vg = c_light / (n1 + (n1 - n0) / G4Log(E1  << 194     //
                                                   >> 195     vg = c_light/(n1+(n1-n0)/std::log(E1/E0));
636                                                   196 
637     // allow only for 'normal dispersion' -> d    197     // allow only for 'normal dispersion' -> dn/d(logE) > 0
638     if ((vg < 0) || (vg > c_light / n1)) {     << 198     //
639       vg = c_light / n1;                       << 199     if((vg<0) || (vg>c_light/n1))  { vg = c_light/n1; }
640     }                                          << 200     groupvel->InsertValues( E1, vg );
641     groupvel->InsertValues(E1, vg);            << 
642   }                                               201   }
643   else  // only one entry in RINDEX -- weird!  << 202   else // only one entry in RINDEX -- weird!
644   {                                               203   {
645     groupvel->InsertValues(E0, c_light / n0);  << 204     groupvel->InsertValues( E0, c_light/n0 );
646   }                                               205   }
647                                                << 206                                                                                 
648   this->AddProperty("GROUPVEL", groupvel);     << 
649                                                << 
650   return groupvel;                                207   return groupvel;
651 }                                                 208 }
652                                                   209