Parameter.h
Go to the documentation of this file.
1 // Object to keep track of parameter information
2 //
3 // Created by Brian Rebel on 8/17/20.
4 //
5 
6 #ifndef COVARIANCEMATRIXFIT_DATAPRODUCTS_PARAMETER_H
7 #define COVARIANCEMATRIXFIT_DATAPRODUCTS_PARAMETER_H
8 
9 #include "NovaDAQConventions/DAQConventions.h"
10 
13 
14 #include <iomanip>
15 
16 namespace cmf{
17  class Parameter;
18  class OscPar;
19  class SystPar;
20 
21  //typedef std::map<std::string, Parameter> ParameterSpaceLoc;
22 
24 
25  public:
27  : fDetector((uint8_t)cmf::kUnknownDet)
28  {}
29 
31  std::vector<cmf::Parameter> const& pars)
32  : fDetector((uint8_t)det)
33  , fPars(pars)
34  {}
35 
36  size_t count (std::string const& parName) const;
37  cmf::Parameter const& Parameter (std::string const& parName) const;
38  void SetParameterValue(std::string const& parName,
39  double const& val);
40  void InsertParameter (cmf::Parameter const& par);
41 
42  size_t size() const { return fPars.size(); }
43  std::vector<cmf::Parameter> const& Parameters() const { return fPars; }
44  cmf::DetType_t const Detector() const { return (cmf::DetType_t)fDetector; }
45 
46  private:
47 
48  uint8_t fDetector;
49  std::vector<cmf::Parameter> fPars;
50  };
51 
52 }
53 
54 
55 //----------------------------------------------------------------------------
57 
58 public:
59 
61  : fParm(cmf::kNumOscParams)
62  , fVal(cmf::kGarbageFloat)
63  {}
64 
66  float const& val)
67  : fParm(par)
68  , fVal(val)
69  {}
70 
71  cmf::OscParm_t const& Param() const { return fParm; }
72  float const& Value() const { return fVal; }
73 
74  bool operator==(cmf::OscPar const& other) const { return fParm == other.Param(); }
75  bool operator< (cmf::OscPar const& other) const { return fParm < other.Param(); }
76 
77  friend std::ostream& operator << (std::ostream & o, cmf::OscPar const& op);
78 
79 private:
80 
81  cmf::OscParm_t fParm; ///< the parameter
82  float fVal; ///< the value of the parameter
83 };
84 
85 //----------------------------------------------------------------------------
87 
88 public:
89 
91  : fParm(cmf::kNumSigmaSysts)
92  , fVal(cmf::kGarbageFloat)
93  {}
94 
95  SystPar(uint8_t const& par,
96  float const& val)
97  : fParm(par)
98  , fVal(val)
99  {}
100 
101  uint8_t const& Param() const { return fParm; }
102  float const& Value() const { return fVal; }
103 
104  bool operator==(cmf::SystPar const& other) const { return fParm == other.Param(); }
105  bool operator< (cmf::SystPar const& other) const { return fParm < other.Param(); }
106 
107 private:
108 
109  uint8_t fParm; ///< the parameter
110  float fVal; ///< the value of the parameter
111 };
112 
113 // cmf::Parameter is used in the definition of cmf::ParameterSpaceLoc
114 //.............................................................................
116 
117 public:
118  Parameter();
119 
120  Parameter(std::string const& name,
121  cmf::DetType_t const& det,
122  double const& val,
123  bool const& fixed,
124  float const& sigmaSize,
125  float const& cv,
126  float const& variance,
127  bool const& nuisance,
128  bool const& constrained,
129  float const& lowerBound,
130  float const& upperBound);
131 
132  std::string const Name() const { return (fParType == cmf::kOscPar) ? cmf::cOscParams_Strings[fKey] : cmf::KeyToVarName(fKey); }
133  cmf::ParType_t const ParType() const { return (cmf::ParType_t)fParType; }
134  double const& Value() const { return fVal; }
135  uint8_t const& Key() const { return fKey; }
136  cmf::DetType_t const Detector() const { return (cmf::DetType_t)fDetector; }
137  float const& CentralValue() const { return fCentralVal; }
138  float const& Sigma() const { return fSigmaSize; }
139  float const& Variance() const { return fVariance; }
140  bool const& IsFixed() const { return fIsFixed; }
141  bool IsOscPar() const { return (fParType == cmf::kOscPar); }
142  bool const& IsConstrained() const { return fIsConstrained; }
143  bool const& IsNuisance() const { return fIsNuisance; }
144  float const& LowerBound() const { return fLowerBound; }
145  float const& UpperBound() const { return fUpperBound; }
146 
147  void SetValue(double const& val) { fVal = val; }
148 
149  bool operator<(cmf::Parameter const& other) const;
150  bool operator==(cmf::Parameter const& other) const;
151 
152  friend std::ostream& operator << (std::ostream & o, cmf::Parameter const& par);
153 
154 private:
155  uint8_t fKey; ///< key for this parameter
156  uint8_t fDetector; ///< which detector is this parameter for?
157  double fVal; ///< current value for the parameter in the fit
158  float fCentralVal; ///< central value for the parameter
159  float fSigmaSize; ///< size of 1 sigma
160  float fVariance; ///< amount parameter can vary when making random universes
161  bool fIsFixed; ///< is this parameter fixed during fits?
162  bool fIsNuisance; ///< is this parameter treated as a nuisance parameter?
163  bool fIsConstrained; ///< is this parameter constrained in allowed values?
164  float fLowerBound; ///< lower bound for the constrained parameter
165  float fUpperBound; ///< upper bound for the constrained parameter
166  uint8_t fParType; ///< type of paramter this is
167 
168 };
169 
170 namespace cmf{
171 
172  class Location {
173 
174  public:
175 
177  {}
178 
179  Location(std::vector<ParameterSpaceLoc> const& locations)
180  : fDetLocs(locations)
181  {}
182 
183  Location(std::set<cmf::DetType_t> const& dets);
184 
185  Location(cmf::OscillationParameterMap const& oscPars,
186  std::set<cmf::DetType_t> const& dets);
187 
188  cmf::OscillationParameterMap AsOscillationParameterMap(cmf::DetType_t const& det=cmf::kFARDET) const;
189  std::vector<Parameter> OscillationParameters (cmf::DetType_t const& det=cmf::kFARDET) const;
190  std::vector<Parameter> SystematicParameters (cmf::DetType_t const& det=cmf::kFARDET) const;
191 
192  cmf::ParameterSpaceLoc const& DetectorLocation(cmf::DetType_t const& det) const;
193  std::vector<ParameterSpaceLoc> const& DetectorLocations() const { return fDetLocs; }
194 
195  void InsertParameter(cmf::Parameter const& par);
196  void SetParameterValue(std::string const& parName,
197  double const& value,
198  cmf::DetType_t const& det);
199 
200 
201  private:
202 
203  std::vector<ParameterSpaceLoc> fDetLocs;
204 
205  friend std::ostream& operator<<(std::ostream& o, cmf::Location const& loc);
206  };
207 }
208 
209 #endif //COVARIANCEMATRIXFIT_DATAPRODUCTS_PARAMETER_H
const XML_Char * name
Definition: expat.h:151
cmf::ParType_t const ParType() const
Definition: Parameter.h:133
float const & LowerBound() const
Definition: Parameter.h:144
enum cmf::osc_params OscParm_t
uint8_t fParm
the parameter
Definition: Parameter.h:109
float fVal
the value of the parameter
Definition: Parameter.h:110
std::vector< cmf::Parameter > const & Parameters() const
Definition: Parameter.h:43
SystPar(uint8_t const &par, float const &val)
Definition: Parameter.h:95
bool const & IsConstrained() const
Definition: Parameter.h:142
float fSigmaSize
size of 1 sigma
Definition: Parameter.h:159
float fCentralVal
central value for the parameter
Definition: Parameter.h:158
Int_t par
Definition: SimpleIterate.C:24
void SetValue(double const &val)
Definition: Parameter.h:147
cmf::DetType_t const Detector() const
Definition: Parameter.h:44
bool const & IsFixed() const
Definition: Parameter.h:140
bool fIsConstrained
is this parameter constrained in allowed values?
Definition: Parameter.h:163
enum cmf::det_type DetType_t
float fUpperBound
upper bound for the constrained parameter
Definition: Parameter.h:165
size_t size() const
Definition: Parameter.h:42
cmf::OscParm_t fParm
the parameter
Definition: Parameter.h:81
bool IsOscPar() const
Definition: Parameter.h:141
std::ostream & operator<<(std::ostream &o, cmf::Event const &event)
Definition: Event.cxx:27
cmf::Parameter const & Parameter(std::string const &parName) const
Definition: Parameter.cxx:30
enum cmf::par_type ParType_t
float const & Value() const
Definition: Parameter.h:102
size_t count(std::string const &parName) const
Definition: Parameter.cxx:14
float const & Sigma() const
Definition: Parameter.h:138
bool operator==(cmf::OscPar const &other) const
Definition: Parameter.h:74
std::map< cmf::OscParm_t, float > OscillationParameterMap
Definition: Constants.h:745
const XML_Char int const XML_Char * value
Definition: expat.h:331
void SetParameterValue(std::string const &parName, double const &val)
Definition: Parameter.cxx:50
float fLowerBound
lower bound for the constrained parameter
Definition: Parameter.h:164
float fVal
the value of the parameter
Definition: Parameter.h:82
static const float kGarbageFloat
Definition: Constants.h:19
const std::string cv[Ncv]
bool const & IsNuisance() const
Definition: Parameter.h:143
OscPar(cmf::OscParm_t const &par, float const &val)
Definition: Parameter.h:65
bool operator<(StanConfig::Verbosity a, StanConfig::Verbosity b)
Allow for comparing them, since kQuiet is definitely "less" verbose than kVerbose.
Definition: StanConfig.h:95
uint8_t fDetector
which detector is this parameter for?
Definition: Parameter.h:156
cmf::DetType_t const Detector() const
Definition: Parameter.h:136
float const & Value() const
Definition: Parameter.h:72
uint8_t const & Key() const
Definition: Parameter.h:135
bool operator==(FC &A, FC &B)
float const & CentralValue() const
Definition: Parameter.h:137
Location(std::vector< ParameterSpaceLoc > const &locations)
Definition: Parameter.h:179
bool fIsNuisance
is this parameter treated as a nuisance parameter?
Definition: Parameter.h:162
double fVal
current value for the parameter in the fit
Definition: Parameter.h:157
bool operator==(cmf::SystPar const &other) const
Definition: Parameter.h:104
float fVariance
amount parameter can vary when making random universes
Definition: Parameter.h:160
Module to combine a set of results into a single file currently only does one data product type at a ...
Definition: Event.cxx:24
cmf::OscParm_t const & Param() const
Definition: Parameter.h:71
static const uint8_t kNumSigmaSysts
Definition: Constants.h:558
std::vector< ParameterSpaceLoc > const & DetectorLocations() const
Definition: Parameter.h:193
std::string pars("Th23Dmsq32")
bool fIsFixed
is this parameter fixed during fits?
Definition: Parameter.h:161
float const & UpperBound() const
Definition: Parameter.h:145
std::vector< cmf::Parameter > fPars
Definition: Parameter.h:49
ParameterSpaceLoc(cmf::DetType_t const &det, std::vector< cmf::Parameter > const &pars)
Definition: Parameter.h:30
uint8_t fKey
key for this parameter
Definition: Parameter.h:155
uint8_t const & Param() const
Definition: Parameter.h:101
double const & Value() const
Definition: Parameter.h:134
float const & Variance() const
Definition: Parameter.h:139
std::string const Name() const
Definition: Parameter.h:132
double variance(Eigen::VectorXd x)
static std::string KeyToVarName(uint8_t const &key)
Definition: StaticFuncs.h:410
std::vector< ParameterSpaceLoc > fDetLocs
Definition: Parameter.h:203
uint8_t fParType
type of paramter this is
Definition: Parameter.h:166
void InsertParameter(cmf::Parameter const &par)
Definition: Parameter.cxx:74
const std::vector< std::string > cOscParams_Strings({"L","Rho","Dmsq21","Dmsq32","Th12","Th13","Th23","dCP","Th14","Th24","Th34","Dmsq41","d24","Eps_ee","Eps_emu","Eps_etau","Eps_mumu","Eps_mutau","Eps_tautau","Delta_emu","Delta_etau","Delta_mutau"})
enum BeamMode string