LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
artg4tk::ArtG4tkModelConfig Class Reference

#include "ArtG4tkModelConfig.hh"

Public Member Functions

 ArtG4tkModelConfig ()
 
 ArtG4tkModelConfig (const bool &flag)
 
 ArtG4tkModelConfig (const ArtG4tkModelConfig &rhs)
 
 ~ArtG4tkModelConfig ()
 
void Fill (const fhicl::ParameterSet &)
 
void Insert (const std::string &, const std::string &, const double &)
 
bool IsDefaultPhysics () const
 
std::vector< std::string > GetConfiguredModels () const
 
const std::vector< std::pair< std::string, double > > * GetConfig (const std::string &) const
 
bool operator< (const ArtG4tkModelConfig &) const
 

Private Member Functions

void DoFill (std::string &, std::string &, fhicl::ParameterSet &)
 

Private Attributes

bool fDefaultPhysics
 
std::map< std::string, std::vector< std::pair< std::string, double > > > fModelConfig
 

Detailed Description

Definition at line 14 of file ArtG4tkModelConfig.hh.

Constructor & Destructor Documentation

artg4tk::ArtG4tkModelConfig::ArtG4tkModelConfig ( )
inline

Definition at line 17 of file ArtG4tkModelConfig.hh.

artg4tk::ArtG4tkModelConfig::ArtG4tkModelConfig ( const bool &  flag)
inline

Definition at line 18 of file ArtG4tkModelConfig.hh.

artg4tk::ArtG4tkModelConfig::ArtG4tkModelConfig ( const ArtG4tkModelConfig rhs)
inline

Definition at line 19 of file ArtG4tkModelConfig.hh.

20  : fDefaultPhysics(rhs.fDefaultPhysics), fModelConfig(rhs.fModelConfig)
21  {}
std::map< std::string, std::vector< std::pair< std::string, double > > > fModelConfig
artg4tk::ArtG4tkModelConfig::~ArtG4tkModelConfig ( )
inline

Definition at line 22 of file ArtG4tkModelConfig.hh.

References Fill().

22 {}

Member Function Documentation

void artg4tk::ArtG4tkModelConfig::DoFill ( std::string &  key,
std::string &  modkey,
fhicl::ParameterSet mpset 
)
private

Definition at line 50 of file ArtG4tkModelConfig.cc.

References fhicl::ParameterSet::get(), Insert(), and value.

Referenced by Fill().

53 {
54 
55  std::string mkey = modkey;
56  for (unsigned int ik = 0; ik < modkey.size(); ++ik)
57  mkey[ik] = std::tolower(mkey[ik]);
58  if (mkey.find("use") != std::string::npos) {
59  int ivalue = mpset.get<int>(modkey, 0);
60  Insert(key, modkey, ivalue);
61  } else {
62  double value = mpset.get<double>(modkey);
63  Insert(key, modkey, value);
64  }
65 
66  return;
67 }
void Insert(const std::string &, const std::string &, const double &)
T get(std::string const &key) const
Definition: ParameterSet.h:314
double value
Definition: spectrum.C:18
void artg4tk::ArtG4tkModelConfig::Fill ( const fhicl::ParameterSet pset)

Definition at line 6 of file ArtG4tkModelConfig.cc.

References DoFill(), fDefaultPhysics, fhicl::ParameterSet::get(), and fhicl::ParameterSet::get_names().

7 {
8 
9  // NOTE(JVY): To an extend, this kind of replicate the code in PhysModelConfig service.
10  // However, opted for this way because otherwise one would need to introduce
11  // MULTIPLE RunProducts (configs) in service which would be quite a complication !!!
12  //
13 
14  std::vector<std::string> keys = pset.get_names(); // no longer available: pset.get_keys();
15  std::vector<std::string> modkeys;
16  for (unsigned int i = 0; i < keys.size(); ++i) {
17  if (keys[i] == "DefaultPhysics") {
18  fDefaultPhysics = pset.get<bool>("DefaultPhysics", true);
19  continue;
20  }
21  if (fDefaultPhysics)
22  return;
23  fhicl::ParameterSet mpset = pset.get<fhicl::ParameterSet>(keys[i]);
24  modkeys.clear();
25  modkeys = mpset.get_names(); // no more: get_keys();
26  for (unsigned i1 = 0; i1 < modkeys.size(); ++i1) {
27  std::string modkey = modkeys[i1];
28  for (unsigned int ik = 0; ik < modkey.size(); ++ik)
29  modkey[ik] = std::tolower(modkey[ik]);
30  if (modkey == "underlyingmodels") {
31  fhicl::ParameterSet umpset = mpset.get<fhicl::ParameterSet>(modkeys[i1]);
32  std::vector<std::string> ukeys = umpset.get_names();
33  for (unsigned int iu = 0; iu < ukeys.size(); ++iu) {
34  fhicl::ParameterSet umodel = umpset.get<fhicl::ParameterSet>(ukeys[iu]);
35  std::vector<std::string> umconfig = umodel.get_names();
36  for (unsigned int iukm = 0; iukm < umconfig.size(); ++iukm) {
37  DoFill(ukeys[iu], umconfig[iukm], umodel);
38  }
39  }
40  } else {
41  DoFill(keys[i], modkeys[i1], mpset);
42  }
43  }
44  }
45 
46  return;
47 }
void DoFill(std::string &, std::string &, fhicl::ParameterSet &)
T get(std::string const &key) const
Definition: ParameterSet.h:314
std::vector< std::string > get_names() const
const std::vector< std::pair< std::string, double > > * artg4tk::ArtG4tkModelConfig::GetConfig ( const std::string &  model) const

Definition at line 111 of file ArtG4tkModelConfig.cc.

References fModelConfig.

112 {
113 
114  std::map<std::string, std::vector<std::pair<std::string, double>>>::const_iterator itr =
115  fModelConfig.find(model);
116 
117  if (itr == fModelConfig.end()) {
118  // FIXME !!
119  // Needs to give a WARNING !!!
120  //
121  return NULL;
122  }
123 
124  return &(itr->second);
125 }
std::map< std::string, std::vector< std::pair< std::string, double > > > fModelConfig
std::vector< std::string > artg4tk::ArtG4tkModelConfig::GetConfiguredModels ( ) const

Definition at line 96 of file ArtG4tkModelConfig.cc.

References fModelConfig.

97 {
98 
99  std::vector<std::string> models;
100 
101  std::map<std::string, std::vector<std::pair<std::string, double>>>::const_iterator itr =
102  fModelConfig.begin();
103  for (; itr != fModelConfig.end(); ++itr) {
104  models.push_back(itr->first);
105  }
106 
107  return models;
108 }
std::map< std::string, std::vector< std::pair< std::string, double > > > fModelConfig
void artg4tk::ArtG4tkModelConfig::Insert ( const std::string &  model,
const std::string &  param,
const double &  value 
)

Definition at line 70 of file ArtG4tkModelConfig.cc.

References fDefaultPhysics, fModelConfig, and lar::dump::vector().

Referenced by DoFill().

73 {
74 
75  // Check if "Default Physics" (no changes to G4's defaults whatsoever)
76  // and store config(s) only if NOT
77  //
78  //
79  if (fDefaultPhysics)
80  return;
81 
82  if (fModelConfig.find(model) == fModelConfig.end()) {
83  fModelConfig.insert(std::pair<std::string, std::vector<std::pair<std::string, double>>>(
84  model, std::vector<std::pair<std::string, double>>()));
85  }
86 
87  std::map<std::string, std::vector<std::pair<std::string, double>>>::iterator itr =
88  fModelConfig.find(model);
89 
90  (itr->second).push_back(std::pair<std::string, double>(param, value));
91 
92  return;
93 }
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
std::map< std::string, std::vector< std::pair< std::string, double > > > fModelConfig
double value
Definition: spectrum.C:18
bool artg4tk::ArtG4tkModelConfig::IsDefaultPhysics ( ) const
inline

Definition at line 28 of file ArtG4tkModelConfig.hh.

29  {
30  return fDefaultPhysics;
31  }
bool artg4tk::ArtG4tkModelConfig::operator< ( const ArtG4tkModelConfig ) const
inline

Definition at line 43 of file ArtG4tkModelConfig.hh.

44  {
45  return true;
46  }

Member Data Documentation

bool artg4tk::ArtG4tkModelConfig::fDefaultPhysics
private

Definition at line 55 of file ArtG4tkModelConfig.hh.

Referenced by Fill(), and Insert().

std::map<std::string, std::vector<std::pair<std::string, double> > > artg4tk::ArtG4tkModelConfig::fModelConfig
private

Definition at line 63 of file ArtG4tkModelConfig.hh.

Referenced by GetConfig(), GetConfiguredModels(), and Insert().


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