LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
LArPropertiesStandard.cxx
Go to the documentation of this file.
1 //
3 // LArProperties
4 //
6 
7 // LArSoft includes
9 #include "larcorealg/CoreUtils/ProviderUtil.h" // lar::IgnorableProviderConfigKeys()
10 
11 // ROOT includes
12 #include "TH1.h"
13 #include <RtypesCore.h>
14 
15 // Framework includes
16 #include "cetlib_except/exception.h"
17 #include "fhiclcpp/ParameterSet.h"
18 #include "fhiclcpp/types/Table.h"
19 
20 //-----------------------------------------------
22 
23 //-----------------------------------------------
25  std::set<std::string> ignore_params /* = {} */
26  )
28 {
29  this->Configure(pset, ignore_params);
30 }
31 
32 #if 0
33 //------------------------------------------------
35 {
36  this->SetRadiationLength (pset.get< double >("RadiationLength" ));
37  this->SetAtomicNumber (pset.get< double >("AtomicNumber"));
38  this->SetAtomicMass (pset.get< double >("AtomicMass"));
39  this->SetMeanExcitationEnergy (pset.get< double >("ExcitationEnergy"));
40 
41  this->SetArgon39DecayRate (pset.get< double >("Argon39DecayRate"));
42 
43  this->SetFastScintEnergies (pset.get< std::vector<double> >("FastScintEnergies"));
44  this->SetFastScintSpectrum (pset.get< std::vector<double> >("FastScintSpectrum"));
45  this->SetSlowScintEnergies (pset.get< std::vector<double> >("SlowScintEnergies"));
46  this->SetSlowScintSpectrum (pset.get< std::vector<double> >("SlowScintSpectrum"));
47  this->SetAbsLengthEnergies (pset.get< std::vector<double> >("AbsLengthEnergies"));
48  this->SetAbsLengthSpectrum (pset.get< std::vector<double> >("AbsLengthSpectrum"));
49  this->SetRIndexEnergies (pset.get< std::vector<double> >("RIndexEnergies" ));
50  this->SetRIndexSpectrum (pset.get< std::vector<double> >("RIndexSpectrum" ));
51  this->SetRayleighEnergies (pset.get< std::vector<double> >("RayleighEnergies" ));
52  this->SetRayleighSpectrum (pset.get< std::vector<double> >("RayleighSpectrum" ));
53 
54  this->SetScintResolutionScale (pset.get<double>("ScintResolutionScale"));
55  this->SetScintFastTimeConst (pset.get<double>("ScintFastTimeConst"));
56  this->SetScintSlowTimeConst (pset.get<double>("ScintSlowTimeConst"));
57  this->SetScintBirksConstant (pset.get<double>("ScintBirksConstant"));
58  this->SetScintByParticleType (pset.get<bool>("ScintByParticleType"));
59  this->SetScintYield (pset.get<double>("ScintYield"));
60  this->SetScintPreScale(pset.get<double>("ScintPreScale"));
61  this->SetScintYieldRatio (pset.get<double>("ScintYieldRatio"));
62 
63  if(ScintByParticleType()){
64  this->SetProtonScintYield(pset.get<double>("ProtonScintYield"));
65  this->SetProtonScintYieldRatio (pset.get<double>("ProtonScintYieldRatio"));
66  this->SetMuonScintYield (pset.get<double>("MuonScintYield"));
67  this->SetMuonScintYieldRatio (pset.get<double>("MuonScintYieldRatio"));
68  this->SetPionScintYield (pset.get<double>("PionScintYield"));
69  this->SetPionScintYieldRatio (pset.get<double>("PionScintYieldRatio"));
70  this->SetKaonScintYield (pset.get<double>("KaonScintYield"));
71  this->SetKaonScintYieldRatio (pset.get<double>("KaonScintYieldRatio"));
72  this->SetElectronScintYield (pset.get<double>("ElectronScintYield"));
73  this->SetElectronScintYieldRatio (pset.get<double>("ElectronScintYieldRatio"));
74  this->SetAlphaScintYield (pset.get<double>("AlphaScintYield"));
75  this->SetAlphaScintYieldRatio (pset.get<double>("AlphaScintYieldRatio"));
76  }
77 
78  this->SetEnableCerenkovLight (pset.get<bool>("EnableCerenkovLight"));
79 
80  this->SetReflectiveSurfaceNames(pset.get<std::vector<std::string> >("ReflectiveSurfaceNames"));
81  this->SetReflectiveSurfaceEnergies(pset.get<std::vector<double> >("ReflectiveSurfaceEnergies"));
82  this->SetReflectiveSurfaceReflectances(pset.get<std::vector<std::vector<double> > >("ReflectiveSurfaceReflectances"));
83  this->SetReflectiveSurfaceDiffuseFractions(pset.get<std::vector<std::vector<double> > >("ReflectiveSurfaceDiffuseFractions"));
84 
85  fIsConfigured = true;
86 
87 
88  return true;
89 }
90 #endif // 0
91 
92 //------------------------------------------------
94  std::set<std::string> ignore_params /* = {} */
95 )
96 {
97  // we need to know whether we require the additional ScintByParticleType parameters:
98  const bool bScintByParticleType = pset.get<bool>("ScintByParticleType", false);
99 
100  std::set<std::string> ignorable_keys = lar::IgnorableProviderConfigKeys();
101  ignorable_keys.insert(ignore_params.begin(), ignore_params.end());
102 
103 #if DETECTORINFO_LARPROPERTIESSTANDARD_HASOPTIONALATOM
104  // validation happens here:
106  Configuration_t const& config = config_table();
107 
108  if (bScintByParticleType) {
109  double value;
110  std::string errmsg;
111  if (config.ProtonScintYield(value))
112  SetProtonScintYield(value);
113  else
114  errmsg += fhicl::detail::fillMissingKeysMsg(&config_table, {config.ProtonScintYield.key()});
115  if (config.ProtonScintYieldRatio(value))
117  else
118  errmsg +=
119  fhicl::detail::fillMissingKeysMsg(&config_table, {config.ProtonScintYieldRatio.key()});
120  if (config.MuonScintYield(value))
121  SetMuonScintYield(value);
122  else
123  errmsg += fhicl::detail::fillMissingKeysMsg(&config_table, {config.MuonScintYield.key()});
124  if (config.MuonScintYieldRatio(value))
125  SetMuonScintYieldRatio(value);
126  else
127  errmsg +=
128  fhicl::detail::fillMissingKeysMsg(&config_table, {config.MuonScintYieldRatio.key()});
129  if (config.PionScintYield(value))
130  SetPionScintYield(value);
131  else
132  errmsg += fhicl::detail::fillMissingKeysMsg(&config_table, {config.PionScintYield.key()});
133  if (config.PionScintYieldRatio(value))
134  SetPionScintYieldRatio(value);
135  else
136  errmsg +=
137  fhicl::detail::fillMissingKeysMsg(&config_table, {config.PionScintYieldRatio.key()});
138  if (config.KaonScintYield(value))
139  SetKaonScintYield(value);
140  else
141  errmsg += fhicl::detail::fillMissingKeysMsg(&config_table, {config.KaonScintYield.key()});
142  if (config.KaonScintYieldRatio(value))
143  SetKaonScintYieldRatio(value);
144  else
145  errmsg +=
146  fhicl::detail::fillMissingKeysMsg(&config_table, {config.KaonScintYieldRatio.key()});
147  if (config.ElectronScintYield(value))
148  SetElectronScintYield(value);
149  else
150  errmsg += fhicl::detail::fillMissingKeysMsg(&config_table, {config.ElectronScintYield.key()});
151  if (config.ElectronScintYieldRatio(value))
153  else
154  errmsg +=
155  fhicl::detail::fillMissingKeysMsg(&config_table, {config.ElectronScintYieldRatio.key()});
156  if (config.AlphaScintYield(value))
157  SetAlphaScintYield(value);
158  else
159  errmsg += fhicl::detail::fillMissingKeysMsg(&config_table, {config.AlphaScintYield.key()});
160  if (config.AlphaScintYieldRatio(value))
162  else
163  errmsg +=
164  fhicl::detail::fillMissingKeysMsg(&config_table, {config.AlphaScintYieldRatio.key()});
165  if (!errmsg.empty()) {
167  ("[these parameters are REQUIRED when ScintByParticleType is true; the list may be "
168  "incomplete]\n" +
169  errmsg)
170  .c_str());
171  } // if missing parameters
172  } // if bScintByParticleType
173 
174  // read parameters
175 #else // !DETECTORINFO_LARPROPERTIESSTANDARD_HASOPTIONALATOM
176 
177  if (!bScintByParticleType) { // ignore the following keys
178  ConfigWithScintByType_t config; // to get the keys
179  ignorable_keys.insert(config.ProtonScintYield.key());
180  ignorable_keys.insert(config.ProtonScintYieldRatio.key());
181  ignorable_keys.insert(config.MuonScintYield.key());
182  ignorable_keys.insert(config.MuonScintYieldRatio.key());
183  ignorable_keys.insert(config.PionScintYield.key());
184  ignorable_keys.insert(config.PionScintYieldRatio.key());
185  ignorable_keys.insert(config.KaonScintYield.key());
186  ignorable_keys.insert(config.KaonScintYieldRatio.key());
187  ignorable_keys.insert(config.ElectronScintYield.key());
188  ignorable_keys.insert(config.ElectronScintYieldRatio.key());
189  ignorable_keys.insert(config.AlphaScintYield.key());
190  ignorable_keys.insert(config.AlphaScintYieldRatio.key());
191  } // if !bScintByParticleType
192 
193  // validation happens here:
194  fhicl::Table<ConfigWithScintByType_t> config_table{pset, ignorable_keys};
195 
196  // read parameters
197  ConfigWithScintByType_t const& config = config_table();
198  if (bScintByParticleType) {
211  } // if ScintByParticleType
212 #endif // DETECTORINFO_LARPROPERTIESSTANDARD_HASOPTIONALATOM??
213 
215 
216  SetAtomicNumber(config.AtomicNumber());
217  SetAtomicMass(config.AtomicMass());
219 
221 
232 
237  SetScintYield(config.ScintYield());
241 
243 
248 
253 
256 
257  fIsConfigured = true;
258 
259  return true;
260 }
261 
262 //------------------------------------------------
264 {
265  if (ts == 0) return false;
266 
267  return true;
268 }
269 
270 //---------------------------------------------------------------------------------
272 {
273  if (fFastScintSpectrum.size() != fFastScintEnergies.size()) {
274  throw cet::exception("Incorrect vector sizes in LArPropertiesStandard")
275  << "The vectors specifying the fast scintillation spectrum are "
276  << " different sizes - " << fFastScintSpectrum.size() << " " << fFastScintEnergies.size();
277  }
278 
279  std::map<double, double> ToReturn;
280  for (size_t i = 0; i != fFastScintSpectrum.size(); ++i)
281  ToReturn[fFastScintEnergies.at(i)] = fFastScintSpectrum.at(i);
282 
283  return ToReturn;
284 }
285 
286 //---------------------------------------------------------------------------------
288 {
289  if (fSlowScintSpectrum.size() != fSlowScintEnergies.size()) {
290  throw cet::exception("Incorrect vector sizes in LArPropertiesStandard")
291  << "The vectors specifying the slow scintillation spectrum are "
292  << " different sizes - " << fSlowScintSpectrum.size() << " " << fSlowScintEnergies.size();
293  }
294 
295  std::map<double, double> ToReturn;
296  for (size_t i = 0; i != fSlowScintSpectrum.size(); ++i)
297  ToReturn[fSlowScintEnergies.at(i)] = fSlowScintSpectrum.at(i);
298 
299  return ToReturn;
300 }
301 
302 //---------------------------------------------------------------------------------
303 std::map<double, double> detinfo::LArPropertiesStandard::RIndexSpectrum() const
304 {
305  if (fRIndexSpectrum.size() != fRIndexEnergies.size()) {
306  throw cet::exception("Incorrect vector sizes in LArPropertiesStandard")
307  << "The vectors specifying the RIndex spectrum are "
308  << " different sizes - " << fRIndexSpectrum.size() << " " << fRIndexEnergies.size();
309  }
310 
311  std::map<double, double> ToReturn;
312  for (size_t i = 0; i != fRIndexSpectrum.size(); ++i)
313  ToReturn[fRIndexEnergies.at(i)] = fRIndexSpectrum.at(i);
314 
315  return ToReturn;
316 }
317 
318 //---------------------------------------------------------------------------------
320 {
321  if (fAbsLengthSpectrum.size() != fAbsLengthEnergies.size()) {
322  throw cet::exception("Incorrect vector sizes in LArPropertiesStandard")
323  << "The vectors specifying the Abs Length spectrum are "
324  << " different sizes - " << fAbsLengthSpectrum.size() << " " << fAbsLengthEnergies.size();
325  }
326 
327  std::map<double, double> ToReturn;
328  for (size_t i = 0; i != fAbsLengthSpectrum.size(); ++i)
329  ToReturn[fAbsLengthEnergies.at(i)] = fAbsLengthSpectrum.at(i);
330 
331  return ToReturn;
332 }
333 
334 //---------------------------------------------------------------------------------
335 std::map<double, double> detinfo::LArPropertiesStandard::RayleighSpectrum() const
336 {
337  if (fRayleighSpectrum.size() != fRayleighEnergies.size()) {
338  throw cet::exception("Incorrect vector sizes in LArPropertiesStandard")
339  << "The vectors specifying the rayleigh spectrum are "
340  << " different sizes - " << fRayleighSpectrum.size() << " " << fRayleighEnergies.size();
341  }
342 
343  std::map<double, double> ToReturn;
344  for (size_t i = 0; i != fRayleighSpectrum.size(); ++i)
345  ToReturn[fRayleighEnergies.at(i)] = fRayleighSpectrum.at(i);
346 
347  return ToReturn;
348 }
349 
350 //---------------------------------------------------------------------------------
351 std::map<std::string, std::map<double, double>>
353 {
354  std::map<std::string, std::map<double, double>> ToReturn;
355 
357  throw cet::exception("Incorrect vector sizes in LArPropertiesStandard")
358  << "The vectors specifying the surface reflectivities "
359  << "do not have consistent sizes";
360  }
361  for (size_t i = 0; i != fReflectiveSurfaceNames.size(); ++i) {
362  if (fReflectiveSurfaceEnergies.size() != fReflectiveSurfaceReflectances.at(i).size()) {
363  throw cet::exception("Incorrect vector sizes in LArPropertiesStandard")
364  << "The vectors specifying the surface reflectivities do not have consistent sizes";
365  }
366  }
367  for (size_t iName = 0; iName != fReflectiveSurfaceNames.size(); ++iName)
368  for (size_t iEnergy = 0; iEnergy != fReflectiveSurfaceEnergies.size(); ++iEnergy)
369  ToReturn[fReflectiveSurfaceNames.at(iName)][fReflectiveSurfaceEnergies.at(iEnergy)] =
370  fReflectiveSurfaceReflectances[iName][iEnergy];
371 
372  return ToReturn;
373 }
374 
375 //---------------------------------------------------------------------------------
376 std::map<std::string, std::map<double, double>>
378 {
379  std::map<std::string, std::map<double, double>> ToReturn;
380 
382  throw cet::exception("Incorrect vector sizes in LArPropertiesStandard")
383  << "The vectors specifying the surface reflectivities do not have consistent sizes";
384  }
385  for (size_t i = 0; i != fReflectiveSurfaceNames.size(); ++i) {
387  throw cet::exception("Incorrect vector sizes in LArPropertiesStandard")
388  << "The vectors specifying the surface reflectivities do not have consistent sizes";
389  }
390  }
391  for (size_t iName = 0; iName != fReflectiveSurfaceNames.size(); ++iName)
392  for (size_t iEnergy = 0; iEnergy != fReflectiveSurfaceEnergies.size(); ++iEnergy)
393  ToReturn[fReflectiveSurfaceNames.at(iName)][fReflectiveSurfaceEnergies.at(iEnergy)] =
394  fReflectiveSurfaceDiffuseFractions[iName][iEnergy];
395 
396  return ToReturn;
397 }
398 //---------------------------------------------------------------------------------
399 std::map<double, double> detinfo::LArPropertiesStandard::TpbAbs() const
400 {
401  if (fTpbAbsorptionEnergies.size() != fTpbAbsorptionSpectrum.size()) {
402  throw cet::exception("Incorrect vector sizes in LArProperties")
403  << "The vectors specifying the TpbAbsorption spectrum are "
404  << " different sizes - " << fTpbAbsorptionEnergies.size() << " "
405  << fTpbAbsorptionSpectrum.size();
406  }
407 
408  std::map<double, double> ToReturn;
409  for (size_t i = 0; i != fTpbAbsorptionSpectrum.size(); ++i)
410  ToReturn[fTpbAbsorptionEnergies.at(i)] = fTpbAbsorptionSpectrum.at(i);
411 
412  return ToReturn;
413 }
414 //---------------------------------------------------------------------------------
415 std::map<double, double> detinfo::LArPropertiesStandard::TpbEm() const
416 {
417  if (fTpbEmmisionEnergies.size() != fTpbEmmisionSpectrum.size()) {
418  throw cet::exception("Incorrect vector sizes in LArProperties")
419  << "The vectors specifying the TpbEmmision spectrum are "
420  << " different sizes - " << fTpbEmmisionEnergies.size() << " " << fTpbEmmisionSpectrum.size();
421  }
422  //using interpolation for more smooth spectrum of TPB emmision - won't affect anything but the effective size of table passed to G4
423  Int_t tablesize = 100;
424  std::vector<double> new_x;
425  double xrange = 0.0;
426  Double_t* en = new Double_t[int(fTpbEmmisionSpectrum.size()) + 1];
427  Double_t* spectr = new Double_t[int(fTpbEmmisionSpectrum.size()) + 1];
428  for (int j = 0; j < int(fTpbEmmisionSpectrum.size()) + 1; j++) {
429  if (j == 0) {
430  en[j] = 0.;
431  en[j] = 0.;
432  }
433  else {
434  en[j] = fTpbEmmisionEnergies[j - 1];
435  spectr[j] = fTpbEmmisionSpectrum[j - 1];
436  //if(j==int(fTpbEmmisionSpectrum.size())) spectr[j]=+0.5;
437  }
438  //std::cout<<j<<" "<<int(fTpbEmmisionSpectrum.size())<<" energiestpb "<<en[j]<<std::endl;
439  }
440  TH1D* energyhist = new TH1D();
441  energyhist->SetBins(int(fTpbEmmisionSpectrum.size()), en);
442  for (int ii = 0; ii < int(fTpbEmmisionSpectrum.size()); ii++)
443  energyhist->SetBinContent(ii, spectr[ii]);
444  xrange =
445  double((en[int(fTpbEmmisionSpectrum.size())] - en[0]) / double(fTpbEmmisionSpectrum.size()));
446  new_x.clear();
447  for (int jj = 0; jj < int(tablesize); jj++) {
448 
449  new_x.push_back(jj * (xrange / double(tablesize)));
450  //std::cout<<"position "<<jj<<" "<<new_x[jj]<<" size of table "<<tablesize<<" range x "<<xrange<<std::endl;
451  }
452  std::map<double, double> ToReturn;
453  //for(size_t i=0; i!=fTpbEmmisionSpectrum.size(); ++i)
454  // ToReturn[fTpbEmmisionEnergies.at(i)]=fTpbEmmisionSpectrum.at(i);
455  for (int i = 0; i < tablesize; i++) {
456  ToReturn[new_x.at(i)] = energyhist->Interpolate(new_x[i]);
457  //std::cout<<ToReturn[new_x[i]]<< " is set in material propertiestpb at energy "<<new_x[i]<<" size of x "<<new_x.size()<<" "<<energyhist->Interpolate(new_x[i])<<std::end;
458  }
459  delete energyhist;
460 
461  delete[] en;
462  delete[] spectr;
463  return ToReturn;
464 }
465 //---------------------------------------------------------------------------------
std::vector< double > fTpbEmmisionSpectrum
virtual bool ScintByParticleType() const override
Service provider with utility LAr functions.
virtual std::map< double, double > SlowScintSpectrum() const override
virtual std::map< double, double > TpbAbs() const override
std::vector< double > fTpbAbsorptionSpectrum
std::vector< double > fFastScintEnergies
std::vector< double > fRayleighSpectrum
void SetAbsLengthSpectrum(std::vector< double > s)
virtual std::map< double, double > TpbEm() const override
void SetTpbEmmisionSpectrum(std::vector< double > s)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
virtual std::map< std::string, std::map< double, double > > SurfaceReflectanceDiffuseFractions() const override
std::vector< std::string > fReflectiveSurfaceNames
bool Configure(fhicl::ParameterSet const &pset, std::set< std::string > ignore_params={})
Configures the provider.
virtual std::map< double, double > AbsLengthSpectrum() const override
structure with all configuration parameters
void SetReflectiveSurfaceEnergies(std::vector< double > e)
T get(std::string const &key) const
Definition: ParameterSet.h:314
std::vector< double > fFastScintSpectrum
std::vector< double > fAbsLengthEnergies
std::set< std::string > const & IgnorableProviderConfigKeys()
Returns a list of configuration keys that providers should ignore.
Definition: ProviderUtil.h:34
std::string const & key() const
Definition: ParameterBase.cc:6
void SetSlowScintEnergies(std::vector< double > s)
std::vector< double > fSlowScintEnergies
structure with all configuration parameters
std::vector< double > fTpbEmmisionEnergies
void SetFastScintSpectrum(std::vector< double > s)
void SetRayleighSpectrum(std::vector< double > s)
void SetReflectiveSurfaceDiffuseFractions(std::vector< std::vector< double >> f)
void SetTpbEmmisionEnergies(std::vector< double > s)
double value
Definition: spectrum.C:18
void SetAbsLengthEnergies(std::vector< double > s)
void SetFastScintEnergies(std::vector< double > s)
void SetRIndexEnergies(std::vector< double > s)
void SetTpbAbsorptionSpectrum(std::vector< double > s)
std::vector< std::vector< double > > fReflectiveSurfaceReflectances
void SetReflectiveSurfaceReflectances(std::vector< std::vector< double >> r)
Properties related to liquid argon environment in the detector.
std::vector< double > fAbsLengthSpectrum
void SetTpbAbsorptionEnergies(std::vector< double > s)
std::vector< double > fReflectiveSurfaceEnergies
std::vector< double > fSlowScintSpectrum
void SetSlowScintSpectrum(std::vector< double > s)
Simple utilities for service providers.
virtual std::map< double, double > RIndexSpectrum() const override
std::vector< double > fTpbAbsorptionEnergies
virtual std::map< double, double > FastScintSpectrum() const override
virtual std::map< double, double > RayleighSpectrum() const override
fhicl::Sequence< fhicl::Sequence< double > > ReflectiveSurfaceReflectances
std::vector< double > fRayleighEnergies
virtual std::map< std::string, std::map< double, double > > SurfaceReflectances() const override
void SetReflectiveSurfaceNames(std::vector< std::string > n)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void SetRIndexSpectrum(std::vector< double > s)
std::vector< std::vector< double > > fReflectiveSurfaceDiffuseFractions
fhicl::Sequence< fhicl::Sequence< double > > ReflectiveSurfaceDiffuseFractions
void SetRayleighEnergies(std::vector< double > s)