MaterialPropertyLoader.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file larsim/LArG4/MaterialPropertyLoader.h
3 //
4 /// \author bjpjones@mit.edu
5 ////////////////////////////////////////////////////////////////////////
6 // Class to set material properties for different materials in
7 // the detector. Currently used to supply optical properties to LAr
8 // and other optical elements of the detector.
9 //
10 
11 // TODO uniform the header guard format to LArSoft common
12 #ifndef LArG4_MaterialPropertyLoader_h
13 #define LArG4_MaterialPropertyLoader_h
14 
15 #include <map>
16 #include <string>
17 
18 class G4LogicalVolumeStore;
19 
20 namespace detinfo {
21  class DetectorPropertiesData;
22 }
23 
24 namespace larg4 {
25 
26  /**
27  * @brief Stores material properties and sends them to GEANT4 geometry.
28  *
29  * Class to set material properties for different materials in the detector.
30  * Currently mainly used to set optical properties for LAr and other optical
31  * components.
32  *
33  * Notes on the implementation of reflectivity
34  * --------------------------------------------
35  *
36  * The reflectivity properties of the material are stored in a different way
37  * depending on whether the standard GEANT4 process or the custom simple
38  * boundary process are used in the simulation (determined by
39  * `detinfo::DetectorProperties::SimpleBoundary()`).
40  * For the former, reflectivity is saved as a property of the material itself
41  * with the property name `"REFLECTIVITY"`.
42  * For the latter, the properties (both a reflectivity and a diffuse
43  * reflection fraction) are stored as properties of the `"LAr"` material,
44  * with a name `"REFLECTANCE_<Material>"` and
45  * `"DIFFUSE_REFLECTANCE_FRACTION_<Material>"`. This is the storage policy
46  * expected by `larg4::OpBoundaryProcessSimple`, which implements the simple
47  * boundary model.
48  *
49  */
51  public:
52  // TODO turn arguments into constant references
53  //Accessors
54  std::map<double, double>
56  {
57  return fPropertyList[Material][Property];
58  }
59 
60  // TODO turn arguments into constant references
61  double
63  {
64  return fConstPropertyList[Material][Property];
65  }
66 
67  // TODO turn argument into constant reference
68  std::map<std::string, double> const&
70  {
71  return fConstPropertyList[Material];
72  }
73 
74  // TODO turn argument into constant reference
75  std::map<std::string, std::map<double, double>> const&
77  {
78  return fPropertyList[Material];
79  }
80 
81  // --- BEGIN Methods to set material properties ----------------------------
82  /// @name Methods to set material properties
83  /// @{
84 
85  /**
86  * @brief Stores the specified emergy-dependent material property.
87  * @param Material name of the material to set the property of
88  * @param Property name of the property
89  * @param Values table of property values (see below)
90  * @param Unit unit of the property values (CLHEP)
91  * @see `SetMaterialConstProperty()`
92  *
93  * The property is stored internally and _not_ propagated to GEANT4
94  * (use `UpdateGeometry()` to that purpose).
95  * The previous value of the property is silently overwritten.
96  *
97  * The table of values is in form of (`energy`, `value`) pairs, where
98  * `value` is measured in `Units` and `energy` is measured in electronvolt.
99  */
100  // TODO turn arguments into constant references
101  void SetMaterialProperty(std::string Material,
103  std::map<double, double> Values,
104  double Unit);
105 
106  /**
107  * @brief Stores the specified material property.
108  * @param Material name of the material to set the property of
109  * @param Property name of the property
110  * @param Value the value of the property
111  * @param Unit unit of the property value (CLHEP)
112  * @see `SetMaterialProperty()`
113  *
114  * The property is stored internally and _not_ propagated to GEANT4
115  * (use `UpdateGeometry()` to that purpose).
116  * The previous value of the property is silently overwritten.
117  */
118  // TODO turn arguments into constant references
119  void SetMaterialConstProperty(std::string Material,
120  std::string Property,
121  double Value,
122  double Unit);
123 
124  /// @}
125  // --- END Methods to set material properties ------------------------------
126 
127  // --- BEGIN Setting of specific properties --------------------------------
128  /// @name Setting of specific properties
129  /// @{
130 
131  // Method to set LArG4 Birks constant
132  void SetBirksConstant(std::string, double, double);
133 
134  /**
135  * @brief
136  */
137  // TODO turn the arguments into constant references (using type aliases)
138  void SetReflectances(std::string,
139  std::map<std::string, std::map<double, double>>,
140  std::map<std::string, std::map<double, double>>);
141  // TODO turn the argument into constant reference (using type aliases)
142  void SetReflectances(std::map<std::string, std::map<double, double>>);
143 
144  /// @}
145  // --- END Setting of specific properties ----------------------------------
146 
147  /**
148  * @brief Imports properties from LArSoft services
149  *
150  * The properties imported include:
151  *
152  * * material `"LAr"`:
153  * * fast scintillation light spectrum (`"FASTCOMPONENT"`) from `detinfo::LArProperties::FastScintSpectrum()`
154  * * slow scintillation light spectrum (`"SLOWCOMPONENT"`) from `detinfo::LArProperties::SlowScintSpectrum()`
155  * * refraction index vs. photon energy (`"RINDEX"`) from `detinfo::LArProperties::RIndexSpectrum()`
156  * * absorption length vs. photon energy (`"ABSLENGTH"`) from `detinfo::LArProperties::AbsLengthSpectrum()` _[cm]_
157  * * Rayleigh scattering vs. photon energy (`"RAYLEIGH"`) from `detinfo::LArProperties::RayleighSpectrum()` _[cm]_
158  * * scintillation yield (`"SCINTILLATIONYIELD"`) from `detinfo::LArProperties::ScintYield(true)` _[1/MeV]_
159  * * "RESOLUTIONSCALE"
160  * * fast scintillation light delay (`"FASTTIMECONSTANT"`) from `detinfo::LArProperties::ScintFastTimeConst()` _[ns]_
161  * * slow scintillation light delay (`"SLOWTIMECONSTANT"`) from `detinfo::LArProperties::ScintSlowTimeConst()` _[ns]_
162  * * scintillation yield ratio (`"YIELDRATIO"`) `detinfo::LArProperties::ScintYieldRatio()`
163  * * electric field (`"ELECTRICFIELD"`) from `detinfo::DetectorProperties::Efield()` _[kV/cm]_
164  * * scintillation Birks constant vs. photon energy, from `detinfo::LArProperties::ScintBirksConstant()` _[cm/MeV]_
165  * * if using the simple reflectivity model (`detinfo::DetectorProperties::SimpleBoundary()`), for each supported material `XXX`:
166  * * reflectivity (`"REFLECTANCE_XXX"`) from `detinfo::LArProperties::SurfaceReflectances()`
167  * * diffused reflectivity fraction (`"DIFFUSE_REFLECTANCE_FRACTION_XXX"`) from `detinfo::LArProperties::SurfaceReflectances()`
168  * .
169  * The materials are the ones listed in the property from `detinfo::LArProperties`.
170  * * if using different scintillation yield for different particle types (according to `detinfo::LArProperties::ScintByParticleType()`):
171  * * scintillation yield `"<PARTICLE>SCINTILLATIONYIELD"` from `detinfo::LArProperties::<Particle>ScintYield()` (as above)
172  * * scintillation yield ratio `"<PARTICLE>YIELDRATIO"` from `detinfo::LArProperties::<Particle>ScintYieldRatio()` (as above)
173  * .
174  * with `<PARTICLE>` being proton, muon, kaon, pion, electron and &alpha; particles.
175  * * if _not_ using the simple reflectivity model (`!detinfo::DetectorProperties::SimpleBoundary()`):
176  * * material `XXX` reflectivity (`"REFLECTIVITY"`) from `detinfo::LArProperties::SurfaceReflectances()`
177  * .
178  * The materials are the ones listed in the property from `detinfo::LArProperties::SurfaceReflectances()`.
179  * * `TPB` material (if simulating it, according to `detinfo::LArProperties::ExtraMatProperties()`):
180  * * refraction index vs. photon energy (`"RINDEX"`) from `detinfo::LArProperties::RIndexSpectrum()`
181  * * wavelength shifter absorbtion length vs. photon energy (`"WLSABSLENGTH"`) from `detinfo::LArProperties::TpbAbs()` _[m]_
182  * * `"WLSCOMPONENT"` from `detinfo::LArProperties::TpbEm()`
183  *
184  */
185  void GetPropertiesFromServices(detinfo::DetectorPropertiesData const& detProp);
186 
187  // TODO make this method constant
188  /**
189  * @brief Updates the material properties with the collected values.
190  * @param lvs the store of logical volumes to be updated
191  *
192  * Before calling this function, properties for some materials (mostly
193  * liquid argon, but not only: see e.g. `GetPropertiesFromServices()`) are
194  * collected and updated.
195  * This method considers all volumes in the store `lvs`. For the ones made
196  * of a material we have properties for, their material properties are
197  * updated to reflect the values we have collected.
198  */
199  void UpdateGeometry(G4LogicalVolumeStore* lvs);
200 
201  private:
202  // materials properties values
203  std::map<std::string, std::map<std::string, double>> fConstPropertyList;
204 
205  // materials properties energies values
206  std::map<std::string, std::map<std::string, std::map<double, double>>> fPropertyList;
207 
208  std::map<std::string, double> fBirksConstants;
209  }; // clas MaterialPropertyLoader
210 
211 } // namespace larg4
212 
213 #endif // LArG4_MaterialPropertyLoader_h
Stores material properties and sends them to GEANT4 geometry.
std::string string
Definition: nybbler.cc:12
std::map< std::string, std::map< std::string, std::map< double, double > > > fPropertyList
Geant4 interface.
std::map< std::string, std::map< std::string, double > > fConstPropertyList
double GetMaterialConstProperty(std::string Material, std::string Property)
General LArSoft Utilities.
std::map< std::string, std::map< double, double > > const & GetMaterialProperties(std::string Material)
std::map< std::string, double > const & GetMaterialConstProperties(std::string Material)
std::map< std::string, double > fBirksConstants
std::map< double, double > GetMaterialProperty(std::string Material, std::string Property)
Definition: types.h:32