FrequentistSurface.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "CAFAna/Core/ISyst.h"
6 
7 #include "CAFAna/Fit/ISurface.h"
8 #include "CAFAna/Fit/FitAxis.h"
10 
11 #include "Rtypes.h"
12 #include "TAttMarker.h"
13 
14 #include <iostream>
15 #include <map>
16 
17 class TGraph;
18 class TH2;
19 class TH2F;
20 
21 namespace ana
22 {
23  class IExperiment;
24  class IFitVar;
25 
26  /// Log-likelihood scan across two parameters
28  {
29  public:
30  /// \param expt The experiment object to draw \f$ \chi^2 \f$ values from
31  /// \param calc Values for oscillation parameters to be held fixed
32  /// \param xax Definition of the x-axis
33  /// \param yax Definition of the y-axis
34  /// \param profVars Oscillation parameters to profile over
35  /// \param profSysts Systematic parameters to profile over
36  /// \param seedPts Try all combinations of these params as seeds
37  /// \param systSeedPts Try all of these systematic combinations as seeds
38  /// \param parallel Use all the cores on this machine? Be careful...
41  const FitAxis& xax, const FitAxis& yax,
42  const std::vector<const IFitVar*>& profVars = {},
43  const std::vector<const ISyst*>& profSysts = {},
44  const SeedList& seedPts = SeedList(),
45  const std::vector<SystShifts>& systSeedPts = {},
46  bool parallel = false,
48 
49  /// \param expt The experiment object to draw \f$ \chi^2 \f$ values from
50  /// \param calc Values for oscillation parameters to be held fixed
51  /// \param xvar Oscillation parameter to place on the x axis
52  /// \param nbinsx Number of bins along x axis
53  /// \param xmin Minimum value of x axis
54  /// \param xmax Maximum value of x axis
55  /// \param nbinsy Number of bins along y axis
56  /// \param ymin Minimum value of y axis
57  /// \param ymax Maximum value of y axis
58  /// \param profVars Oscillation parameters to profile over
59  /// \param profSysts Systematic parameters to profile over
60  /// \param seedPts Try all combinations of these params as seeds
61  /// \param systSeedPts Try all of these systematic combinations as seeds
62  /// \param parallel Use all the cores on this machine? Be careful...
65  const IFitVar* xvar, int nbinsx, double xmin, double xmax,
66  const IFitVar* yvar, int nbinsy, double ymin, double ymax,
67  const std::vector<const IFitVar*>& profVars = {},
68  const std::vector<const ISyst*>& profSysts = {},
69  const SeedList& seedPts = SeedList(),
70  const std::vector<SystShifts>& systSeedPts = {},
71  bool parallel = false,
73  : FrequentistSurface(expt, calc,
74  FitAxis(xvar, nbinsx, xmin, xmax, false),
75  FitAxis(yvar, nbinsy, ymin, ymax, false),
76  profVars, profSysts, seedPts, systSeedPts, parallel, opts)
77  {
78  }
79 
80  virtual ~FrequentistSurface();
81 
82  /// Maps of the values taken on by the profiled parameters
83  std::vector<TH2*> GetProfiledHists() {return fProfHists;}
84 
85  void SaveTo(TDirectory* dir, const std::string& name) const;
86  static std::unique_ptr<FrequentistSurface> LoadFrom(TDirectory* dir, const std::string& name);
87 
88  protected:
90 
91  void CreateHistograms(const FitAxis& xax, const FitAxis& yax,
92  const std::vector<const IFitVar*>& profVars,
93  const std::vector<const ISyst*>& profSysts);
94 
95  std::string ProgressBarTitle(const IFitVar* xvar, const IFitVar* yvar,
96  const std::vector<const IFitVar*>& profVars,
97  const std::vector<const ISyst*>& profSysts) const;
98 
99  virtual void FillSurface(const IExperiment* expt,
101  const IFitVar* xvar, const IFitVar* yvar,
102  const std::vector<const IFitVar*>& profVars,
103  const std::vector<const ISyst*>& profSysts,
104  const SeedList& seedPts,
105  const std::vector<SystShifts>& systSeedPts);
106 
107  double FillSurfacePoint(const IExperiment* expt,
109  const IFitVar* xvar, double x,
110  const IFitVar* yvar, double y,
111  const std::vector<const IFitVar*>& profVars,
112  const std::vector<const ISyst*>& profSysts,
113  const SeedList& seedPts,
114  const std::vector<SystShifts>& systSeedPts);
115 
116  void FindMinimum(const IExperiment* expt,
118  const IFitVar* xvar, const IFitVar* yvar,
119  const std::vector<const IFitVar*>& profVars,
120  const std::vector<const ISyst*>& profSysts,
121  const SeedList& seedPts,
122  const std::vector<SystShifts>& systSeedPts);
123 
124  bool fParallel;
125 
127 
128  // Best fit point
129  std::vector<TH2*> fProfHists;
130  };
131 
132  /// Up-value surface for 68% confidence in 2D in gaussian approximation
134  /// Up-value surface for 90% confidence in 2D in gaussian approximation
136  /// Up-value surface for 95% confidence in 2D in gaussian approximation
138  /// Up-value surface for 2 sigma confidence in 2D in gaussian approximation
139  TH2* Gaussian2Sigma2D (const FrequentistSurface& s);
140  /// Up-value surface for 99% confidence in 2D in gaussian approximation
142  /// Up-value surface for 3 sigma confidence in 2D in gaussian approximation
143  TH2* Gaussian3Sigma2D (const FrequentistSurface& s);
144 
145  // First approximation of the correct up-values to use for ss2th13 vs delta
146 
147  /// Up-value surface for 68% confidence in 1D in gaussian approximation
149  /// Up-value surface for 90% confidence in 1D in gaussian approximation
151  /// Up-value surface for 95% confidence in 1D in gaussian approximation
153  /// Up-value surface for 2 sigma confidence in 1D in gaussian approximation
154  TH2* Gaussian2Sigma1D (const FrequentistSurface& s);
155  /// Up-value surface for 99% confidence in 1D in gaussian approximation
157  /// Up-value surface for 3 sigma confidence in 1D in gaussian approximation
158  TH2* Gaussian3Sigma1D (const FrequentistSurface& s);
159 }
const XML_Char * name
Definition: expat.h:151
TH2 * Gaussian90Percent1D(const FrequentistSurface &s)
Up-value surface for 90% confidence in 1D in gaussian approximation.
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
std::map< std::string, double > xmax
MinuitFitter::FitOpts fFitOpts
double FillSurfacePoint(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar *xvar, double x, const IFitVar *yvar, double y, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts, const SeedList &seedPts, const std::vector< SystShifts > &systSeedPts)
TH2 * Gaussian68Percent2D(const FrequentistSurface &s)
Up-value surface for 68% confidence in 2D in gaussian approximation.
TH2 * Gaussian2Sigma2D(const FrequentistSurface &s)
Up-value surface for 2 sigma confidence in 2D in gaussian approximation.
TH2 * Gaussian2Sigma1D(const FrequentistSurface &s)
Up-value surface for 2 sigma confidence in 1D in gaussian approximation.
osc::OscCalcDumb calc
std::string ProgressBarTitle(const IFitVar *xvar, const IFitVar *yvar, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts) const
std::vector< TH2 * > fProfHists
Double_t ymax
Definition: plot.C:25
Log-likelihood scan across two parameters.
const XML_Char * s
Definition: expat.h:262
TH2 * Gaussian95Percent2D(const FrequentistSurface &s)
Up-value surface for 95% confidence in 2D in gaussian approximation.
default if un-specified
Definition: MinuitFitter.h:25
expt
Definition: demo5.py:34
std::vector< TH2 * > GetProfiledHists()
Maps of the values taken on by the profiled parameters.
void FindMinimum(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar *xvar, const IFitVar *yvar, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts, const SeedList &seedPts, const std::vector< SystShifts > &systSeedPts)
TH2 * Gaussian3Sigma2D(const FrequentistSurface &s)
Up-value surface for 3 sigma confidence in 2D in gaussian approximation.
TH2 * Gaussian99Percent2D(const FrequentistSurface &s)
Up-value surface for 99% confidence in 2D in gaussian approximation.
TH2 * Gaussian3Sigma1D(const FrequentistSurface &s)
Up-value surface for 3 sigma confidence in 1D in gaussian approximation.
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
Int_t nbinsx
Definition: plot.C:23
TDirectory * dir
Definition: macro.C:5
TH2 * Gaussian90Percent2D(const FrequentistSurface &s)
Up-value surface for 90% confidence in 2D in gaussian approximation.
void SaveTo(TDirectory *dir, const std::string &name) const
FrequentistSurface(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar *xvar, int nbinsx, double xmin, double xmax, const IFitVar *yvar, int nbinsy, double ymin, double ymax, const std::vector< const IFitVar * > &profVars={}, const std::vector< const ISyst * > &profSysts={}, const SeedList &seedPts=SeedList(), const std::vector< SystShifts > &systSeedPts={}, bool parallel=false, MinuitFitter::FitOpts opts=MinuitFitter::kNormal)
Base class defining interface for experiments.
Definition: IExperiment.h:14
Interface definition for fittable variables.
Definition: IFitVar.h:16
Double_t ymin
Definition: plot.C:24
TH2 * Gaussian99Percent1D(const FrequentistSurface &s)
Up-value surface for 99% confidence in 1D in gaussian approximation.
void CreateHistograms(const FitAxis &xax, const FitAxis &yax, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts)
TH2 * Gaussian95Percent1D(const FrequentistSurface &s)
Up-value surface for 95% confidence in 1D in gaussian approximation.
static std::unique_ptr< FrequentistSurface > LoadFrom(TDirectory *dir, const std::string &name)
TH2 * Gaussian68Percent1D(const FrequentistSurface &s)
Up-value surface for 68% confidence in 1D in gaussian approximation.
Collect information describing the axis of a fit variable.
Definition: FitAxis.h:10
virtual void FillSurface(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar *xvar, const IFitVar *yvar, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts, const SeedList &seedPts, const std::vector< SystShifts > &systSeedPts)