Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ana::FitVarsProduct Class Reference

Fit the product of two variables (made from angles so their ranges are 0-1). See also FitVarsProductMarg. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-16/CAFAna/Vars/FitVarsProduct.h"

Inheritance diagram for ana::FitVarsProduct:
ana::IConstrainedFitVar ana::IFitVar

Public Member Functions

 FitVarsProduct (const IConstrainedFitVar &x, const IConstrainedFitVar &y)
 
virtual double GetValue (const osc::IOscCalcAdjustable *osc) const
 
virtual void SetValue (osc::IOscCalcAdjustable *osc, double val) const
 
virtual double LowLimit () const
 
virtual double HighLimit () const
 
double Penalty (double val, osc::IOscCalcAdjustable *) const override
 Override the default implementation with one that pushes back towards the center of the constrained space. More...
 
const std::stringShortName () const
 
const std::stringLatexName () const
 

Protected Member Functions

template<typename T >
T Clamp (T val) const
 

Protected Attributes

const IConstrainedFitVarfVarX
 
const IConstrainedFitVarfVarY
 

Detailed Description

Fit the product of two variables (made from angles so their ranges are 0-1). See also FitVarsProductMarg.

When we set the product, how do we decide to split it between the two variables? How do we marginalize over that freedom of choice? We introduce two new variables defined as:

$ \alpha=xy $ and $ \beta={2\over\pi}\arctan\left({1-x\over1-y}\right) $

This class is $ \alpha $, FitVarsProductMarg is $ \beta $. They have the property of being orthogonal, and ranging over 0 to 1 as $ x $ and $ y $ do.

One should fit over this parameter and introduce the corresponding FitVarsProductMarg as a marginalization variable.

Definition at line 25 of file FitVarsProduct.h.

Constructor & Destructor Documentation

ana::FitVarsProduct::FitVarsProduct ( const IConstrainedFitVar x,
const IConstrainedFitVar y 
)

Definition at line 100 of file FitVarsProduct.cxx.

References ana::assert(), ana::IConstrainedFitVar::HighLimit(), and ana::IConstrainedFitVar::LowLimit().

102  : IConstrainedFitVar(x.ShortName()+"*"+y.ShortName(),
103  x.LatexName()+y.LatexName()),
104  fVarX(x), fVarY(y)
105  {
106  assert(x.LowLimit() == 0 && x.HighLimit() == 1);
107  assert(y.LowLimit() == 0 && y.HighLimit() == 1);
108  }
const IConstrainedFitVar & fVarY
assert(nhit_max >=nhit_nbins)
const IConstrainedFitVar & fVarX

Member Function Documentation

template<typename T >
T ana::IConstrainedFitVar::Clamp ( T  val) const
inlineprotectedinherited
double ana::FitVarsProduct::GetValue ( const osc::IOscCalcAdjustable osc) const
virtual

Implements ana::IFitVar.

Definition at line 111 of file FitVarsProduct.cxx.

References beta, fVarX, fVarY, and ana::IFitVar::GetValue().

112  {
113  // Easy, just the product of the two
114  double alpha, beta;
115  XYToAlphaBeta(fVarX.GetValue(osc), fVarY.GetValue(osc), alpha, beta);
116  return alpha;
117  }
const IConstrainedFitVar & fVarY
Double_t beta
const IConstrainedFitVar & fVarX
virtual double GetValue(const osc::IOscCalcAdjustable *osc) const =0
virtual double ana::FitVarsProduct::HighLimit ( ) const
inlinevirtual

Implements ana::IConstrainedFitVar.

Definition at line 35 of file FitVarsProduct.h.

35 {return 1;}
const std::string& ana::IFitVar::LatexName ( ) const
inlineinherited
virtual double ana::FitVarsProduct::LowLimit ( ) const
inlinevirtual

Implements ana::IConstrainedFitVar.

Definition at line 34 of file FitVarsProduct.h.

34 {return 0;}
double ana::IConstrainedFitVar::Penalty ( double  val,
osc::IOscCalcAdjustable  
) const
overridevirtualinherited

Override the default implementation with one that pushes back towards the center of the constrained space.

Reimplemented from ana::IFitVar.

Definition at line 8 of file IFitVar.cxx.

References hi(), ana::IConstrainedFitVar::HighLimit(), lo(), ana::IConstrainedFitVar::LowLimit(), extractScale::mean, Munits::rad, and util::sqr().

Referenced by ana::SigmaDelta::SigmaPenalty().

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  }
virtual double HighLimit() const =0
TSpline3 lo("lo", xlo, ylo, 12,"0")
virtual double LowLimit() const =0
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
TSpline3 hi("hi", xhi, yhi, 18,"0")
static constexpr Double_t rad
Definition: Munits.h:162
void ana::FitVarsProduct::SetValue ( osc::IOscCalcAdjustable osc,
double  val 
) const
virtual

Implements ana::IFitVar.

Definition at line 120 of file FitVarsProduct.cxx.

References beta, ana::IConstrainedFitVar::Clamp(), fVarX, fVarY, ana::IFitVar::GetValue(), ana::IFitVar::SetValue(), submit_syst::x, and submit_syst::y.

121  {
122  // Conver to the other space, hold beta (the marg variable) fixed and
123  // adjust alpha, see where that leaves us.
124  double alpha, beta;
125  XYToAlphaBeta(fVarX.GetValue(osc), fVarY.GetValue(osc), alpha, beta);
126  alpha = Clamp(val);
127 
128  double x, y;
129  AlphaBetaToXY(alpha, beta, x, y);
130  fVarX.SetValue(osc, x);
131  fVarY.SetValue(osc, y);
132  }
const IConstrainedFitVar & fVarY
Double_t beta
T Clamp(T val) const
Definition: IFitVar.h:60
virtual void SetValue(osc::IOscCalcAdjustable *osc, double val) const =0
const IConstrainedFitVar & fVarX
virtual double GetValue(const osc::IOscCalcAdjustable *osc) const =0
const std::string& ana::IFitVar::ShortName ( ) const
inlineinherited

Member Data Documentation

const IConstrainedFitVar& ana::FitVarsProduct::fVarX
protected

Definition at line 37 of file FitVarsProduct.h.

Referenced by GetValue(), and SetValue().

const IConstrainedFitVar& ana::FitVarsProduct::fVarY
protected

Definition at line 38 of file FitVarsProduct.h.

Referenced by GetValue(), and SetValue().


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