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