Public Member Functions | Private Attributes | List of all members
gar::garg4::MaterialPropertyLoader Class Reference

#include <MaterialPropertyLoader.h>

Public Member Functions

 MaterialPropertyLoader ()
 
 ~MaterialPropertyLoader ()
 
std::map< double, double > GetMaterialProperty (std::string const &Material, std::string const &Property)
 
double GetMaterialConstProperty (std::string const &Material, std::string const &Property)
 
std::map< std::string, double > GetMaterialConstProperties (std::string const &Material)
 
std::map< std::string, std::map< double, double > > GetMaterialProperties (std::string const &Material)
 
void SetMaterialProperty (std::string const &Material, std::string const &Property, std::map< double, double > const &Values, double Unit)
 
void SetMaterialConstProperty (std::string const &Material, std::string const &Property, double Value, double Unit)
 
void SetBirksConstant (std::string const &, double, double)
 
void SetReflectances (std::string const &, std::map< std::string, std::map< double, double > > const &, std::map< std::string, std::map< double, double > > const &)
 
void GetPropertiesFromServices ()
 
void UpdateGeometry (G4LogicalVolumeStore *)
 

Private Attributes

std::map< std::string, std::map< std::string, double > > fConstPropertyList
 
std::map< std::string, std::map< std::string, std::map< double, double > > > fPropertyList
 
std::map< std::string, double > fBirksConstants
 

Detailed Description

Definition at line 20 of file MaterialPropertyLoader.h.

Constructor & Destructor Documentation

gar::garg4::MaterialPropertyLoader::MaterialPropertyLoader ( )
inline

Definition at line 24 of file MaterialPropertyLoader.h.

24 {}
gar::garg4::MaterialPropertyLoader::~MaterialPropertyLoader ( )
inline

Definition at line 25 of file MaterialPropertyLoader.h.

25 {}

Member Function Documentation

std::map<std::string,double> gar::garg4::MaterialPropertyLoader::GetMaterialConstProperties ( std::string const &  Material)
inline

Definition at line 40 of file MaterialPropertyLoader.h.

41  {return fConstPropertyList[Material];}
std::map< std::string, std::map< std::string, double > > fConstPropertyList
double gar::garg4::MaterialPropertyLoader::GetMaterialConstProperty ( std::string const &  Material,
std::string const &  Property 
)
inline

Definition at line 36 of file MaterialPropertyLoader.h.

38  {return fConstPropertyList[Material][Property];}
std::map< std::string, std::map< std::string, double > > fConstPropertyList
Definition: types.h:32
std::map<std::string,std::map<double,double> > gar::garg4::MaterialPropertyLoader::GetMaterialProperties ( std::string const &  Material)
inline

Definition at line 43 of file MaterialPropertyLoader.h.

44  {return fPropertyList[Material];}
std::map< std::string, std::map< std::string, std::map< double, double > > > fPropertyList
std::map<double,double> gar::garg4::MaterialPropertyLoader::GetMaterialProperty ( std::string const &  Material,
std::string const &  Property 
)
inline

Definition at line 32 of file MaterialPropertyLoader.h.

34  {return fPropertyList[Material][Property];}
std::map< std::string, std::map< std::string, std::map< double, double > > > fPropertyList
Definition: types.h:32
void gar::garg4::MaterialPropertyLoader::GetPropertiesFromServices ( )

Definition at line 193 of file MaterialPropertyLoader.cxx.

194  {
195 // const detinfo::GArProperties* GarProp = gar::providerFrom<detinfo::GArPropertiesService>();
196 // const detinfo::DetectorProperties* DetProp = gar::providerFrom<detinfo::DetectorPropertiesService>();
197 
198  const detinfo::ECALProperties* EcalProp = gar::providerFrom<detinfo::ECALPropertiesService>();
199 
200  SetMaterialConstProperty("Scintillator", "DENSITY", 1.06, CLHEP::g/CLHEP::cm3);
201  SetBirksConstant("Scintillator", EcalProp->ScintBirksConstant(), CLHEP::mm/CLHEP::MeV);
202  }
static constexpr double g
Definition: Units.h:144
void SetBirksConstant(std::string const &, double, double)
static constexpr double cm3
Definition: Units.h:70
static constexpr double MeV
Definition: Units.h:129
void SetMaterialConstProperty(std::string const &Material, std::string const &Property, double Value, double Unit)
static constexpr double mm
Definition: Units.h:65
void gar::garg4::MaterialPropertyLoader::SetBirksConstant ( std::string const &  Material,
double  PropertyValue,
double  Unit 
)

Definition at line 64 of file MaterialPropertyLoader.cxx.

67  {
68  fBirksConstants[Material] = PropertyValue * Unit;
69  MF_LOG_INFO("MaterialPropertyLoader")
70  << "Set Birks constant "
71  << Material;
72  }
std::map< std::string, double > fBirksConstants
#define MF_LOG_INFO(category)
void gar::garg4::MaterialPropertyLoader::SetMaterialConstProperty ( std::string const &  Material,
std::string const &  Property,
double  Value,
double  Unit 
)

Definition at line 47 of file MaterialPropertyLoader.cxx.

51  {
52  fConstPropertyList[Material][Property]=PropertyValue*Unit;
53 
54  MF_LOG_INFO("MaterialPropertyLoader")
55  << "Added const property "
56  << Material
57  << " "
58  << Property
59  << " = "
60  << PropertyValue;
61  }
std::map< std::string, std::map< std::string, double > > fConstPropertyList
#define MF_LOG_INFO(category)
Definition: types.h:32
void gar::garg4::MaterialPropertyLoader::SetMaterialProperty ( std::string const &  Material,
std::string const &  Property,
std::map< double, double > const &  Values,
double  Unit 
)

Definition at line 28 of file MaterialPropertyLoader.cxx.

32  {
33  std::map<double,double> PropVectorWithUnit;
34  for(auto const& itr : PropertyVector){
35  PropVectorWithUnit[itr.first * CLHEP::eV] = itr.second * Unit;
36  }
37 
38  fPropertyList[Material][Property] = PropVectorWithUnit;
39 
40  MF_LOG_INFO("MaterialPropertyLoader")
41  <<"Added property "
42  << Material<< " "
43  << Property;
44  }
static constexpr double eV
Definition: Units.h:127
#define MF_LOG_INFO(category)
std::map< std::string, std::map< std::string, std::map< double, double > > > fPropertyList
Definition: types.h:32
void gar::garg4::MaterialPropertyLoader::SetReflectances ( std::string const &  ,
std::map< std::string, std::map< double, double > > const &  Reflectances,
std::map< std::string, std::map< double, double > > const &  DiffuseFractions 
)

Definition at line 162 of file MaterialPropertyLoader.cxx.

165  {
166  std::map<double, double> ReflectanceToStore;
167  std::map<double, double> DiffuseToStore;
168 
169  for(auto const& itMat : Reflectances){
170  std::string ReflectancePropName = std::string("REFLECTANCE_") + itMat.first;
171  ReflectanceToStore.clear();
172  for(auto const& itEn : itMat.second){
173  ReflectanceToStore[itEn.first] = itEn.second;
174  }
175  SetMaterialProperty("GAr", ReflectancePropName, ReflectanceToStore,1);
176  }
177 
178  for(auto const& itMat : DiffuseFractions){
179  std::string DiffusePropName = std::string("DIFFUSE_REFLECTANCE_FRACTION_") + itMat.first;
180  DiffuseToStore.clear();
181  for(auto const& itEn : itMat.second){
182  DiffuseToStore[itEn.first] = itEn.second;
183  }
184  SetMaterialProperty("GAr",
185  DiffusePropName,
186  DiffuseToStore,
187  1);
188  }
189 
190  }
std::string string
Definition: nybbler.cc:12
void SetMaterialProperty(std::string const &Material, std::string const &Property, std::map< double, double > const &Values, double Unit)
void gar::garg4::MaterialPropertyLoader::UpdateGeometry ( G4LogicalVolumeStore *  lvs)

Definition at line 75 of file MaterialPropertyLoader.cxx.

76  {
77  std::map<std::string,G4MaterialPropertiesTable*> MaterialTables;
78  std::map<std::string,bool> MaterialsSet;
79 
80  MF_LOG_INFO("MaterialPropertyLoader")
81  << "UPDATING GEOMETRY";
82 
83  // Loop over each material with a property vector and create a new material table for it
84  for(auto const& itr : fPropertyList) {
85  std::string Material = itr.first;
86  MaterialsSet[Material] = true;
87  MaterialTables[Material] = new G4MaterialPropertiesTable;
88  }
89 
90  // Loop over each material with a const property,
91  // if material table does not exist, create one
92  for(auto const& itr : fConstPropertyList){
93  std::string Material = itr.first;
94  if(!MaterialsSet[Material]){
95  MaterialsSet[Material] = true;
96  MaterialTables[Material] = new G4MaterialPropertiesTable;
97  }
98  }
99 
100  // For each property vector, convert to an array of g4doubles and
101  // feed to materials table Lots of firsts and seconds! See annotation
102  // in MaterialPropertyLoader.h to follow what each element is
103 
104  for(auto const& itr : fPropertyList){
105  std::string Material = itr.first;
106  for(auto const& jitr : itr.second){
107  std::string Property = jitr.first;
108  std::vector<G4double> g4MomentumVector;
109  std::vector<G4double> g4PropertyVector;
110 
111  for(auto const& kitr : jitr.second){
112  g4MomentumVector.push_back(kitr.first);
113  g4PropertyVector.push_back(kitr.second);
114  }
115  int NoOfElements = g4MomentumVector.size();
116  MaterialTables[Material]->AddProperty(Property.c_str(),
117  &g4MomentumVector[0],
118  &g4PropertyVector[0],
119  NoOfElements);
120  MF_LOG_INFO("MaterialPropertyLoader")
121  << "Added property "
122  << Property
123  << " to material table "
124  << Material;
125  }
126  }
127 
128  //Add each const property element
129  for(auto const& itr : fConstPropertyList){
130  std::string Material = itr.first;
131  for(auto const& jitr : itr.second){
132  std::string Property = jitr.first;
133  G4double PropertyValue = jitr.second;
134  MaterialTables[Material]->AddConstProperty(Property.c_str(), PropertyValue);
135 
136  MF_LOG_INFO("MaterialPropertyLoader")
137  << "Added const property "
138  << Property
139  << " to material table "
140  << Material;
141  }
142  }
143 
144  //Loop through geometry elements and apply relevant material table where materials match
145  for ( G4LogicalVolumeStore::iterator i = lvs->begin(); i != lvs->end(); ++i ){
146  G4LogicalVolume* volume = (*i);
147  G4Material* TheMaterial = volume->GetMaterial();
148  std::string Material = TheMaterial->GetName();
149  for(auto const& jitr : MaterialTables){
150  if(Material == jitr.first){
151  TheMaterial->SetMaterialPropertiesTable(jitr.second);
152  //Birks Constant, for some reason, must be set separately
153  if(fBirksConstants[Material]!=0)
154  TheMaterial->GetIonisation()->SetBirksConstant(fBirksConstants[Material]);
155  volume->SetMaterial(TheMaterial);
156  }
157  }
158  }
159  }
intermediate_table::iterator iterator
std::map< std::string, double > fBirksConstants
std::string string
Definition: nybbler.cc:12
static const std::string volume[nvol]
std::map< std::string, std::map< std::string, double > > fConstPropertyList
#define MF_LOG_INFO(category)
std::map< std::string, std::map< std::string, std::map< double, double > > > fPropertyList
Definition: types.h:32

Member Data Documentation

std::map<std::string, double> gar::garg4::MaterialPropertyLoader::fBirksConstants
private

Definition at line 82 of file MaterialPropertyLoader.h.

std::map< std::string , std::map < std::string,double> > gar::garg4::MaterialPropertyLoader::fConstPropertyList
private

Definition at line 77 of file MaterialPropertyLoader.h.

std::map< std::string , std::map < std::string , std::map < double , double > > > gar::garg4::MaterialPropertyLoader::fPropertyList
private

Definition at line 80 of file MaterialPropertyLoader.h.


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