Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4MaterialPropertiesTable Class Reference

#include <G4MaterialPropertiesTable.hh>

Inheritance diagram for G4MaterialPropertiesTable:

Public Member Functions

 G4MaterialPropertiesTable ()
 
virtual ~G4MaterialPropertiesTable ()
 
void AddConstProperty (const char *key, G4double PropertyValue)
 
G4MaterialPropertyVectorAddProperty (const char *key, G4double *PhotonEnergies, G4double *PropertyValues, G4int NumEntries)
 
void AddProperty (const char *key, G4MaterialPropertyVector *opv)
 
void RemoveConstProperty (const char *key)
 
void RemoveProperty (const char *key)
 
G4double GetConstProperty (const char *key) const
 
G4bool ConstPropertyExists (const char *key) const
 
G4MaterialPropertyVectorGetProperty (const char *key)
 
void AddEntry (const char *key, G4double aPhotonEnergy, G4double aPropertyValue)
 
void DumpTable ()
 
const std::map< G4String,
G4MaterialPropertyVector
*, std::less< G4String > > * 
GetPropertiesMap () const
 
const std::map< G4String,
G4double, std::less< G4String > > * 
GetPropertiesCMap () const
 

Detailed Description

Definition at line 70 of file G4MaterialPropertiesTable.hh.

Constructor & Destructor Documentation

G4MaterialPropertiesTable::G4MaterialPropertiesTable ( )

Definition at line 58 of file G4MaterialPropertiesTable.cc.

59 {
60 }
G4MaterialPropertiesTable::~G4MaterialPropertiesTable ( )
virtual

Definition at line 66 of file G4MaterialPropertiesTable.cc.

67 {
68  MPTiterator i;
69  for (i = MPT.begin(); i != MPT.end(); ++i)
70  {
71  delete (*i).second;
72  }
73  MPT.clear();
74  MPTC.clear();
75 }

Member Function Documentation

void G4MaterialPropertiesTable::AddConstProperty ( const char *  key,
G4double  PropertyValue 
)
inline

Here is the caller graph for this function:

void G4MaterialPropertiesTable::AddEntry ( const char *  key,
G4double  aPhotonEnergy,
G4double  aPropertyValue 
)

Definition at line 139 of file G4MaterialPropertiesTable.cc.

142 {
143  // Allows to add an entry pair directly to the Material Property Vector
144  // given a key
145 
146  G4MaterialPropertyVector *targetVector=MPT [G4String(key)];
147  if (targetVector != nullptr)
148  {
149  targetVector->InsertValues(aPhotonEnergy, aPropertyValue);
150  }
151  else
152  {
153  G4Exception("G4MaterialPropertiesTable::AddEntry()", "mat203",
154  FatalException, "Material Property Vector not found.");
155  }
156 }
void InsertValues(G4double energy, G4double value)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

G4MaterialPropertyVector* G4MaterialPropertiesTable::AddProperty ( const char *  key,
G4double PhotonEnergies,
G4double PropertyValues,
G4int  NumEntries 
)
inline

Here is the caller graph for this function:

void G4MaterialPropertiesTable::AddProperty ( const char *  key,
G4MaterialPropertyVector opv 
)
inline
G4bool G4MaterialPropertiesTable::ConstPropertyExists ( const char *  key) const

Definition at line 94 of file G4MaterialPropertiesTable.cc.

95 {
96  // Returns true if a const property 'key' exists
97 
98  MPTCiterator j;
99  j = MPTC.find(G4String(key));
100  if ( j != MPTC.end() ) return true;
101  return false;
102 }

Here is the caller graph for this function:

void G4MaterialPropertiesTable::DumpTable ( )

Definition at line 158 of file G4MaterialPropertiesTable.cc.

159 {
160  MPTiterator i;
161  for (i = MPT.begin(); i != MPT.end(); ++i)
162  {
163  G4cout << (*i).first << G4endl;
164  if ( (*i).second != 0 )
165  {
166  (*i).second->DumpValues();
167  }
168  else
169  {
170  G4Exception("G4MaterialPropertiesTable::DumpTable()", "mat204",
171  JustWarning, "NULL Material Property Vector Pointer.");
172  }
173  }
174  MPTCiterator j;
175  for (j = MPTC.begin(); j != MPTC.end(); ++j)
176  {
177  G4cout << j->first << G4endl;
178  if ( j->second != 0 )
179  {
180  G4cout << j->second << G4endl;
181  }
182  else
183  {
184  G4Exception("G4MaterialPropertiesTable::DumpTable()", "mat202",
185  JustWarning, "No Material Constant Property.");
186  }
187  }
188 }
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

G4double G4MaterialPropertiesTable::GetConstProperty ( const char *  key) const

Definition at line 81 of file G4MaterialPropertiesTable.cc.

82 {
83  // Returns the constant material property corresponding to a key
84 
85  MPTCiterator j;
86  j = MPTC.find(G4String(key));
87  if ( j != MPTC.end() ) return j->second;
88  G4cout << "key: " << G4String(key) << G4endl;
89  G4Exception("G4MaterialPropertiesTable::GetConstProperty()","mat202",
90  FatalException, "Constant Material Property not found.");
91  return 0.;
92 }
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

const std::map< G4String, G4double, std::less<G4String> >* G4MaterialPropertiesTable::GetPropertiesCMap ( ) const
inline

Definition at line 120 of file G4MaterialPropertiesTable.hh.

120 { return &MPTC; }

Here is the caller graph for this function:

const std::map< G4String, G4MaterialPropertyVector*, std::less<G4String> >* G4MaterialPropertiesTable::GetPropertiesMap ( ) const
inline

Definition at line 118 of file G4MaterialPropertiesTable.hh.

118 { return &MPT; }

Here is the caller graph for this function:

G4MaterialPropertyVector * G4MaterialPropertiesTable::GetProperty ( const char *  key)

Definition at line 105 of file G4MaterialPropertiesTable.cc.

106 {
107  // Returns a Material Property Vector corresponding to a key
108 
109  //Important Note for MT. adotti 17 Feb 2016
110  //In previous implementation the following line was at the bottom of the
111  //function causing a rare race-condition.
112  //Moving this line here from the bottom solves the problem because:
113  //1- Map is accessed only via operator[] (to insert) and find() (to search),
114  // and these are thread safe if done on separate elements.
115  // See notes on data-races at:
116  // http://www.cplusplus.com/reference/map/map/operator%5B%5D/
117  // http://www.cplusplus.com/reference/map/map/find/
118  //2- So we have a data race if two threads access the same element (GROUPVEL)
119  // one in read and one in write mode. This was happening with the line
120  // at the bottom of the code, one thread in SetGROUPVEL(),
121  // and the other here
122  //3- SetGROUPVEL() is protected by a mutex that ensures that only
123  // one thread at the time will execute its code
124  //4- The if() statement guarantees that only if two threads are searching
125  // the same problematic key (GROUPVEL) the mutex will be used.
126  // Different keys do not lock (good for performances)
127  //5- As soon as a thread acquires the mutex in SetGROUPVEL it checks again
128  // if the map has GROUPVEL key, if so returns immediately.
129  // This "double check" allows to execute the heavy code to calculate
130  // group velocity only once even if two threads enter SetGROUPVEL together
131  if (G4String(key) == "GROUPVEL") return SetGROUPVEL();
132 
133  MPTiterator i;
134  i = MPT.find(G4String(key));
135  if ( i != MPT.end() ) return i->second;
136  return nullptr;
137 }

Here is the caller graph for this function:

void G4MaterialPropertiesTable::RemoveConstProperty ( const char *  key)
inline

Here is the caller graph for this function:

void G4MaterialPropertiesTable::RemoveProperty ( const char *  key)
inline

The documentation for this class was generated from the following files: