Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
fnex::NuisanceParameters Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-02/FNEX/dataProducts/NuisanceParameters.h"

Public Member Functions

void InsertParameter (fhicl::ParameterSet const &p)
 
double const Sigma (std::string const &name) const
 
double const Variance (std::string const &name) const
 
double const CentralValue (std::string const &name) const
 
std::map< std::string, NPInfo > const & NuisanceParameterInfo () const
 
void Lock ()
 
void Unlock ()
 
void Clear ()
 
void Print (std::ostream &stream=std::cout)
 

Static Public Member Functions

static NuisanceParametersInstance ()
 

Private Member Functions

 NuisanceParameters ()
 
 ~NuisanceParameters ()
 

Private Attributes

std::map< std::string, NPInfofParameterMap
 map name to size of 1 sigma More...
 
bool fLock
 set if we are done allowing new parameters More...
 

Detailed Description

Definition at line 44 of file NuisanceParameters.h.

Constructor & Destructor Documentation

fnex::NuisanceParameters::NuisanceParameters ( )
private

Definition at line 22 of file NuisanceParameters.cxx.

References fParameterMap.

Referenced by Instance().

23  : fLock(true)
24  {
25  fParameterMap.clear();
26 
27  return;
28  }
bool fLock
set if we are done allowing new parameters
std::map< std::string, NPInfo > fParameterMap
map name to size of 1 sigma
fnex::NuisanceParameters::~NuisanceParameters ( )
private

Definition at line 31 of file NuisanceParameters.cxx.

32  {
33 
34  }

Member Function Documentation

double const fnex::NuisanceParameters::CentralValue ( std::string const &  name) const
inline

Definition at line 160 of file NuisanceParameters.h.

References LOG_WARNING.

161 {
162  if(fParameterMap.count(name) < 1){
163  LOG_WARNING("NuisanceParameters")
164  << "Nuisance Parameter central value for parameter "
165  << name
166  << " was requested, but does not exist, return 0";
167  return 0;
168  }
169 
170  return fParameterMap.at(name).fCentralValue;
171 }
const XML_Char * name
Definition: expat.h:151
#define LOG_WARNING(category)
std::map< std::string, NPInfo > fParameterMap
map name to size of 1 sigma
void fnex::NuisanceParameters::Clear ( )
inline

Definition at line 188 of file NuisanceParameters.h.

189 {
190  fParameterMap.clear();
191  return;
192 }
std::map< std::string, NPInfo > fParameterMap
map name to size of 1 sigma
void fnex::NuisanceParameters::InsertParameter ( fhicl::ParameterSet const &  p)
inline

Definition at line 87 of file NuisanceParameters.h.

References fhicl::ParameterSet::get(), fhicl::ParameterSet::has_key(), LOG_WARNING, fnex::NPInfo::NPInfo(), and string.

88 {
89  // Don't do anything if we are locked out
90  if(fLock) return;
91 
92  auto nuisance = p.get<bool >("Nuisance", false);
93  auto fixed = p.get<bool >("Fixed" );
94  auto parstr = p.get<std::string>("Parameter" );
95 
96  // check that the fixed and nuisance flags are consistent
97  if(fixed && nuisance){
98  LOG_WARNING("InputPoint")
99  << "Parameter: "
100  << parstr
101  << " requested to be fixed and treated as a nuisance parameter,"
102  << " which does not make sense. Assume treating it as fixed is correct";
103 
104  nuisance = false;
105  }
106  else if(!fixed && !nuisance && p.has_key("Sigma")){
107  LOG_WARNING("InputPoint")
108  << "Parameter: "
109  << parstr
110  << " requested to float and has a sigma value, but not requested to be"
111  << " treated as a nuisance parameter. Double check this is what was "
112  << " intended";
113  }
114 
115  // if we are treating this parameter as a nuisance parameter then
116  // nuisance is true, and we better have values for sigma, central value,
117  // and variance
118  if(nuisance){
119  if(!p.has_key("Sigma") ||
120  !p.has_key("CentralValue") ||
121  !p.has_key("Variance") ){
122  LOG_WARNING("InputPoint")
123  << "Input parameter "
124  << parstr
125  << " requested to be treated as nuisance parameter but is missing one of"
126  << " Sigma: "
127  << p.has_key("Sigma")
128  << " CentralValue: "
129  << p.has_key("CentralValue")
130  << " Variance: "
131  << p.has_key("Variance")
132  << " move on to the next parameter";
133  return;
134  }
135 
136  fParameterMap.emplace(parstr,
137  NPInfo(p.get<double>("Sigma"),
138  p.get<double>("Variance"),
139  p.get<double>("CentralValue")));
140  }
141 
142  return;
143 }
bool fLock
set if we are done allowing new parameters
const char * p
Definition: xmltok.h:285
#define LOG_WARNING(category)
std::map< std::string, NPInfo > fParameterMap
map name to size of 1 sigma
enum BeamMode string
NuisanceParameters * fnex::NuisanceParameters::Instance ( )
static
void fnex::NuisanceParameters::Lock ( )
inline

Definition at line 195 of file NuisanceParameters.h.

196 {
197  fLock = true;
198  return;
199 }
bool fLock
set if we are done allowing new parameters
std::map< std::string, fnex::NPInfo > const & fnex::NuisanceParameters::NuisanceParameterInfo ( ) const
inline

Definition at line 76 of file NuisanceParameters.h.

References LOG_DEBUG.

Referenced by fnex::CovarianceFitHelper::ChiSqr(), and fnex::MultiExperiment::CreateNuisanceParameterExperiments().

77 {
78  LOG_DEBUG("NuisanceParameters")
79  << "there are "
80  << fParameterMap.size()
81  << " nuisance parameters in the map";
82 
83  return fParameterMap;
84 }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
std::map< std::string, NPInfo > fParameterMap
map name to size of 1 sigma
void fnex::NuisanceParameters::Print ( std::ostream &  stream = std::cout)

Definition at line 37 of file NuisanceParameters.cxx.

References allTimeWatchdog::endl, HTMLTools::entry(), and fParameterMap.

38  {
39  stream << "NuisanceParameters::Print( ): \n";
40  stream << std::setw(30) << "Name" << std::setw(20) << "Sigma\n";
41  for(auto entry : fParameterMap){
42  stream << std::setw(30)
43  << entry.first
44  << std::setw(20)
45  << " Central Value: "
46  << entry.second.fCentralValue
47  << " sigma: "
48  << entry.second.fSigma
49  << " variance: "
50  << entry.second.fVariance
51  << std::endl;
52  }
53  }
def entry(str)
Definition: HTMLTools.py:26
std::map< std::string, NPInfo > fParameterMap
map name to size of 1 sigma
double const fnex::NuisanceParameters::Sigma ( std::string const &  name) const
inline

Definition at line 146 of file NuisanceParameters.h.

References LOG_WARNING.

147 {
148  if(fParameterMap.count(name) < 1){
149  LOG_WARNING("NuisanceParameters")
150  << "Nuisance Parameter sigma for parameter "
151  << name
152  << " was requested, but does not exist, return 0";
153  return 0;
154  }
155 
156  return fParameterMap.at(name).fSigma;
157 }
const XML_Char * name
Definition: expat.h:151
#define LOG_WARNING(category)
std::map< std::string, NPInfo > fParameterMap
map name to size of 1 sigma
void fnex::NuisanceParameters::Unlock ( )
inline

Definition at line 202 of file NuisanceParameters.h.

203 {
204  fLock = false;
205  return;
206 }
bool fLock
set if we are done allowing new parameters
double const fnex::NuisanceParameters::Variance ( std::string const &  name) const
inline

Definition at line 174 of file NuisanceParameters.h.

References LOG_WARNING.

175 {
176  if(fParameterMap.count(name) < 1){
177  LOG_WARNING("NuisanceParameters")
178  << "Nuisance Parameter variance for parameter "
179  << name
180  << " was requested, but does not exist, return 0";
181  return 0;
182  }
183 
184  return fParameterMap.at(name).fCentralValue;
185 }
const XML_Char * name
Definition: expat.h:151
#define LOG_WARNING(category)
std::map< std::string, NPInfo > fParameterMap
map name to size of 1 sigma

Member Data Documentation

bool fnex::NuisanceParameters::fLock
private

set if we are done allowing new parameters

Definition at line 69 of file NuisanceParameters.h.

std::map<std::string, NPInfo> fnex::NuisanceParameters::fParameterMap
private

map name to size of 1 sigma

Definition at line 68 of file NuisanceParameters.h.

Referenced by NuisanceParameters(), and Print().


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