IFitVar.cxx
Go to the documentation of this file.
1 #include "CAFAna/Core/IFitVar.h"
2 #include "Utilities/func/Stan.h"
3 #include "Utilities/func/MathUtil.h"
4 
5 namespace ana
6 {
7  //----------------------------------------------------------------------
10  {
11  const auto lo = LowLimit();
12  const auto hi = HighLimit();
13 
14  if (val >= lo && val <= hi) return 0;
15 
16  // Try to direct fit back towards centre of the space. Engineer penalty to
17  // be zero at the limits.
18  const auto mean = (lo + hi) / 2;
19  const auto rad = (hi - lo) / 2;
20  return util::sqr((val - mean) / rad) - 1;
21 
22 
23  // if(val < lo) return util::sqr(lo-val);
24  // if(val > hi) return util::sqr(val-hi);
25  // return 0;
26  }
27 
28  //----------------------------------------------------------------------
31 
32 }
virtual double HighLimit() const =0
TSpline3 lo("lo", xlo, ylo, 12,"0")
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
virtual double LowLimit() const =0
double Penalty(double val, osc::IOscCalcAdjustable *) const override
Override the default implementation with one that pushes back towards the center of the constrained s...
Definition: IFitVar.cxx:8
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
stan::math::var StanExp(const stan::math::var &x)
Definition: IFitVar.cxx:29
TSpline3 hi("hi", xhi, yhi, 18,"0")
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
static constexpr Double_t rad
Definition: Munits.h:162
stan::math::var StanLog(const stan::math::var &x)
Definition: IFitVar.cxx:30