All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IFitVar.cxx
Go to the documentation of this file.
2 
4 
5 #include <cmath>
6 
7 namespace ana
8 {
9  //----------------------------------------------------------------------
10  double IConstrainedFitVar::Penalty(double val,
12  {
13  const double lo = LowLimit();
14  const double hi = HighLimit();
15 
16  if(val >= lo && val <= hi) return 0;
17 
18  // Try to direct fit back towards centre of the space. Engineer penalty to
19  // be zero at the limits.
20  const double mean = (lo+hi)/2;
21  const double rad = (hi-lo)/2;
22  return util::sqr((val-mean)/rad)-1;
23 
24 
25  // if(val < lo) return util::sqr(lo-val);
26  // if(val > hi) return util::sqr(val-hi);
27  // return 0;
28  }
29 
30  //----------------------------------------------------------------------
31  double IConstrainedFitVar::Clamp(double val) const
32  {
33  return std::max(LowLimit(), std::min(val, HighLimit()));
34  }
35 } // namespace
virtual double Penalty(double val, osc::IOscCalcAdjustable *) const
Definition: IFitVar.cxx:10
virtual double LowLimit() const =0
process_name opflashCryoW ana
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
double Clamp(double val) const
Definition: IFitVar.cxx:31
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
virtual double HighLimit() const =0