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