Fit.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "CAFAna/Core/Spectrum.h"
7 
8 class TGraph;
9 
10 namespace ana
11 {
12  class IExperiment;
13  class IFitVar;
14 
15  /// \brief Figure-of-merit with no systematics, for binned data
16  ///
17  /// \param obs The observed data
18  /// \param unosc A spectrum representing the null hypothesis
19  /// \param pot POT to scale to. Leave at default to adopt POT from \a obs
20  ///
21  /// \returns Sum in quadrature over the bins
22  /// \f[ \sqrt{\sum_i^{\rm bins}\left({s_i\over\sqrt{s_i+b_i}}\right)^2} \f]
23  double SimpleFOM(const Spectrum& obs, const Spectrum& unosc, double pot = 0);
24 
25  // Default values for Profile()
26  static std::map<const IFitVar*, TGraph*> empty_vars_map;
27  static std::map<const ISyst*, TGraph*> empty_syst_map;
28 
29  /// \brief \f$\chi^2\f$ scan in one variable, profiling over all others
30  ///
31  /// \param expt The experiment to retrieve chisq values from
32  /// \param calc Initial values of all oscillation parametes
33  /// \param v Scan over this variable
34  /// \param nbinsx Binning
35  /// \param minx Binning
36  /// \param maxx Binning
37  /// \param minchi Set non-default to force a chisq value to evaluate delta
38  /// chisqs against. Useful for comparing two profiles. If set
39  /// to zero it will not zero-adjust and the axis will be
40  /// labelled without "delta"
41  /// \param profVars Profile over these variables
42  /// \param profSysts Profile over these systematics
43  /// \param seedPts List of oscillation seeds
44  /// \param systSeedPts If non-empty, try fit starting at each of these
45  /// \param[out] profVarsMap Pass empty map. Returns best values of each var.
46  /// \param[out] systsMap Pass empty map. Returns best values of each syst.
47  ///
48  /// \return The best fit delta chisq as a function of \a a
49  TGraph* Profile(const IExperiment* expt,
51  const IFitVar* v,
52  int nbinsx, double minx, double maxx,
53  double minchi = -1,
54  const std::vector<const IFitVar*>& profVars = {},
55  const std::vector<const ISyst*>& profSysts = {},
56  const SeedList& seedPts = SeedList(),
57  const std::vector<SystShifts>& systsSeedPts = {},
58  std::map<const IFitVar*, TGraph*>& profVarsMap = empty_vars_map,
59  std::map<const ISyst*, TGraph*>& systsMap = empty_syst_map,
61 
62  /// Forward to \ref Profile but sqrt the result for a crude significance
63  TGraph* SqrtProfile(const IExperiment* expt,
65  const IFitVar* v,
66  int nbinsx, double minx, double maxx,
67  double minchi = -1,
68  std::vector<const IFitVar*> profVars = {},
69  std::vector<const ISyst*> profSysts = {},
70  const SeedList& seedPts = SeedList(),
71  const std::vector<SystShifts>& systsSeedPts = {},
72  std::map<const IFitVar*, TGraph*>& profVarsMap = empty_vars_map,
73  std::map<const ISyst*, TGraph*>& systsMap = empty_syst_map,
75 
76  /// \f$\chi^2\f$ scan in one variable, holding all others constant
77  TGraph* Slice(const IExperiment* expt,
78  osc::IOscCalcAdjustable* calc, const IFitVar* v,
79  int nbinsx, double minx, double maxx,
80  double minchi = -1,
82 
83  /// Forward to \ref Slice but sqrt the result for a crude significance
84  TGraph* SqrtSlice(const IExperiment* expt,
85  osc::IOscCalcAdjustable* calc, const IFitVar* v,
86  int nbinsx, double minx, double maxx, double minchi = -1,
88 
89  /// \brief Find the minimum in one variable as a function of another
90  ///
91  /// \param transpose plot \a scanVar on the y axis
92  TGraph* FindValley(const IExperiment* expt,
94  const IFitVar& scanVar,
95  const IFitVar& fitVar,
96  int nbinsx, double xmin, double xmax,
97  const std::vector<const IFitVar*>& profVars = {},
98  const std::vector<const ISyst*>& profSysts = {},
99  const SeedList& seedPts = SeedList(),
100  const std::vector<SystShifts>& systsSeedPts = {},
101  bool transpose = false,
103 
104  /// \brief Intended for use on the output of \ref Profile
105  ///
106  /// Returns a list of all the x-coordinates at which the curve described by
107  /// \a g crosses \a critVal. eg using critVal=1 will find the 1sigma lower
108  /// and upper bounds.
109  std::vector<double> FindCurveCrossings(TGraph* g, double critVal);
110 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
std::map< std::string, double > xmax
std::vector< double > FindCurveCrossings(TGraph *g, double critVal)
Intended for use on the output of Profile.
Definition: Fit.cxx:232
TGraph * Profile(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar *v, int nbinsx, double minx, double maxx, double input_minchi, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts, const SeedList &seedPts, const std::vector< SystShifts > &systSeedPts, std::map< const IFitVar *, TGraph * > &profVarsMap, std::map< const ISyst *, TGraph * > &profSystsMap, MinuitFitter::FitOpts opts)
scan in one variable, profiling over all others
Definition: Fit.cxx:48
osc::OscCalcDumb calc
static std::map< const ISyst *, TGraph * > empty_syst_map
Definition: Fit.h:27
default if un-specified
Definition: MinuitFitter.h:25
expt
Definition: demo5.py:34
#define pot
static std::map< const IFitVar *, TGraph * > empty_vars_map
Definition: Fit.h:26
TGraph * Slice(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar *v, int nbinsx, double minx, double maxx, double minchi, MinuitFitter::FitOpts opts)
scan in one variable, holding all others constant
Definition: Fit.cxx:169
std::vector< float > Spectrum
Definition: Constants.h:728
TGraph * SqrtSlice(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar *v, int nbinsx, double minx, double maxx, double minchi, MinuitFitter::FitOpts opts)
Forward to Slice but sqrt the result for a crude significance.
Definition: Fit.cxx:180
Int_t nbinsx
Definition: plot.C:23
double SimpleFOM(const Spectrum &obs, const Spectrum &unosc, double pot)
Figure-of-merit with no systematics, for binned data.
Definition: Fit.cxx:23
Base class defining interface for experiments.
Definition: IExperiment.h:14
Interface definition for fittable variables.
Definition: IFitVar.h:16
static float_mat transpose(const float_mat &a)
returns the transposed matrix.
TGraph * FindValley(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar &scanVar, const IFitVar &fitVar, int nbinsx, double xmin, double xmax, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts, const SeedList &seedPts, const std::vector< SystShifts > &systSeedPts, bool transpose, MinuitFitter::FitOpts opts)
Find the minimum in one variable as a function of another.
Definition: Fit.cxx:197
TGraph * SqrtProfile(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar *v, int nbinsx, double minx, double maxx, double minchi, std::vector< const IFitVar * > profVars, std::vector< const ISyst * > profSysts, const SeedList &seedPts, const std::vector< SystShifts > &systSeedPts, std::map< const IFitVar *, TGraph * > &profVarsMap, std::map< const ISyst *, TGraph * > &systsMap, MinuitFitter::FitOpts opts)
Forward to Profile but sqrt the result for a crude significance.
Definition: Fit.cxx:143