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

Log-likelihood scan across two parameters. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-25/CAFAna/Fit/FrequentistSurface.h"

Inheritance diagram for ana::FrequentistSurface:
ana::ISurface ana::SurfaceKrige

Public Member Functions

 FrequentistSurface (const IExperiment *expt, osc::IOscCalcAdjustable *calc, const FitAxis &xax, const FitAxis &yax, 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)
 
 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)
 
virtual ~FrequentistSurface ()
 
std::vector< TH2 * > GetProfiledHists ()
 Maps of the values taken on by the profiled parameters. More...
 
void SaveTo (TDirectory *dir, const std::string &name) const
 
double BestLikelihood () const
 
double GetBestFitX () const
 
double GetBestFitY () const
 
void Draw () const
 Draw the surface itself. More...
 
void DrawBestFit (Color_t color, Int_t marker=kFullCircle) const
 Draw the best fit point. More...
 
void DrawContour (TH2 *fc, Style_t style, Color_t color, double minchi=-1)
 
std::vector< TGraph * > GetGraphs (TH2 *fc, double minchi=-1)
 For expert use, custom painting of contours. More...
 
TH2 * ToTH2 (double minchi=-1) const
 
void SetTitle (const char *str)
 

Static Public Member Functions

static std::unique_ptr< FrequentistSurfaceLoadFrom (TDirectory *dir, const std::string &name)
 
static std::unique_ptr< FrequentistSurfaceLoadFromMulti (std::vector< TFile * > files, std::string label)
 
static std::unique_ptr< FrequentistSurfaceLoadFromMulti (std::string wildcard, std::string label)
 

Protected Member Functions

 FrequentistSurface ()
 
void CreateHistograms (const FitAxis &xax, const FitAxis &yax, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts)
 
std::string ProgressBarTitle (const IFitVar *xvar, const IFitVar *yvar, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts) const
 
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)
 
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)
 
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)
 
double BinCenterX (int bin) const
 
double BinCenterY (int bin) const
 
void SaveToHelper (TDirectory *dir) const
 dir should already be the appropriate sub-directory More...
 
void EnsureAxes () const
 
void CheckMask (const std::string &func) const
 

Static Protected Member Functions

static void FillSurfObj (ISurface &surf, TDirectory *dir)
 

Protected Attributes

bool fParallel
 
MinuitFitter::FitOpts fFitOpts
 
std::vector< TH2 * > fProfHists
 
double fBestLikelihood
 
double fBestFitX
 
double fBestFitY
 
TH2F * fHist
 
bool fLogX
 
bool fLogY
 
std::vector< double > fSeedValues
 
std::vector< intfBinMask
 

Detailed Description

Log-likelihood scan across two parameters.

Definition at line 27 of file FrequentistSurface.h.

Constructor & Destructor Documentation

ana::FrequentistSurface::FrequentistSurface ( const IExperiment expt,
osc::IOscCalcAdjustable calc,
const FitAxis xax,
const FitAxis yax,
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 
)
Parameters
exptThe experiment object to draw $ \chi^2 $ values from
calcValues for oscillation parameters to be held fixed
xaxDefinition of the x-axis
yaxDefinition of the y-axis
profVarsOscillation parameters to profile over
profSystsSystematic parameters to profile over
seedPtsTry all combinations of these params as seeds
systSeedPtsTry all of these systematic combinations as seeds
parallelUse all the cores on this machine? Be careful...

Definition at line 32 of file FrequentistSurface.cxx.

References CreateHistograms(), FillSurface(), FindMinimum(), ana::ISurface::fLogX, ana::ISurface::fLogY, ana::ISurface::fSeedValues, ana::FitAxis::islog, registry_explorer::v, and ana::FitAxis::var.

42  : fParallel(parallel), fFitOpts(opts)
43  {
44  fLogX = xax.islog;
45  fLogY = yax.islog;
46 
47  CreateHistograms(xax, yax, profVars, profSysts);
48 
49  for(const IFitVar* v: profVars) fSeedValues.push_back(v->GetValue( calc));
50 
51  FillSurface(expt, calc, xax.var, yax.var, profVars, profSysts, seedPts, systSeedPts);
52 
53  FindMinimum(expt, calc, xax.var, yax.var, profVars, profSysts, seedPts, systSeedPts);
54  }
MinuitFitter::FitOpts fFitOpts
expt
Definition: demo5.py:34
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)
bool fLogX
Definition: ISurface.h:69
bool fLogY
Definition: ISurface.h:69
std::vector< double > fSeedValues
Definition: ISurface.h:70
void CreateHistograms(const FitAxis &xax, const FitAxis &yax, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts)
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)
ana::FrequentistSurface::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 
)
inline
Parameters
exptThe experiment object to draw $ \chi^2 $ values from
calcValues for oscillation parameters to be held fixed
xvarOscillation parameter to place on the x axis
nbinsxNumber of bins along x axis
xminMinimum value of x axis
xmaxMaximum value of x axis
nbinsyNumber of bins along y axis
yminMinimum value of y axis
ymaxMaximum value of y axis
profVarsOscillation parameters to profile over
profSystsSystematic parameters to profile over
seedPtsTry all combinations of these params as seeds
systSeedPtsTry all of these systematic combinations as seeds
parallelUse all the cores on this machine? Be careful...

Definition at line 63 of file FrequentistSurface.h.

References FrequentistSurface(), ana::MinuitFitter::kNormal, plot_validation_datamc::opts, and ~FrequentistSurface().

67  {},
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  }
std::map< std::string, double > xmax
Double_t ymax
Definition: plot.C:25
default if un-specified
Definition: MinuitFitter.h:25
expt
Definition: demo5.py:34
Int_t nbinsx
Definition: plot.C:23
Double_t ymin
Definition: plot.C:24
ana::FrequentistSurface::~FrequentistSurface ( )
virtual

Definition at line 57 of file FrequentistSurface.cxx.

References CreateHistograms().

Referenced by FrequentistSurface().

58  {
59  }
ana::FrequentistSurface::FrequentistSurface ( )
inlineprotected

Member Function Documentation

double ana::ISurface::BestLikelihood ( ) const
inlineinherited

Definition at line 29 of file ISurface.h.

References ana::ISurface::fBestLikelihood.

29 {return fBestLikelihood;}
double fBestLikelihood
Definition: ISurface.h:65
double ana::ISurface::BinCenterX ( int  bin) const
protectedinherited

Definition at line 265 of file ISurface.cxx.

References visualisationForPaperMasterPlot::ax, ana::ISurface::fHist, and ana::ISurface::fLogX.

Referenced by ana::BayesianSurface::BuildHist(), ana::ISurface::EnsureAxes(), FillSurface(), FindMinimum(), and ana::ISurface::GetBestFitY().

266  {
267  const TAxis* ax = fHist->GetXaxis();
268  return fLogX ? ax->GetBinCenterLog(bin) : ax->GetBinCenter(bin);
269  }
TH2F * fHist
Definition: ISurface.h:68
bool fLogX
Definition: ISurface.h:69
float bin[41]
Definition: plottest35.C:14
double ana::ISurface::BinCenterY ( int  bin) const
protectedinherited

Definition at line 272 of file ISurface.cxx.

References visualisationForPaperMasterPlot::ax, ana::ISurface::fHist, and ana::ISurface::fLogY.

Referenced by ana::BayesianSurface::BuildHist(), ana::ISurface::EnsureAxes(), FillSurface(), FindMinimum(), and ana::ISurface::GetBestFitY().

273  {
274  const TAxis* ax = fHist->GetYaxis();
275  return fLogY ? ax->GetBinCenterLog(bin) : ax->GetBinCenter(bin);
276  }
TH2F * fHist
Definition: ISurface.h:68
float bin[41]
Definition: plottest35.C:14
bool fLogY
Definition: ISurface.h:69
void ana::ISurface::CheckMask ( const std::string func) const
protectedinherited

Definition at line 279 of file ISurface.cxx.

References om::cout, allTimeWatchdog::endl, and ana::ISurface::fBinMask.

Referenced by ana::ISurface::DrawBestFit(), ana::ISurface::DrawContour(), and ana::ISurface::GetGraphs().

280  {
281  if(!fBinMask.empty()) {
282  std::cout << "Cannot call " << func << "() on a partial surface!" << std::endl;
283  abort();
284  }
285  }
double func(double x, double y)
OStream cout
Definition: OStream.cxx:6
std::vector< int > fBinMask
Definition: ISurface.h:71
void ana::FrequentistSurface::CreateHistograms ( const FitAxis xax,
const FitAxis yax,
const std::vector< const IFitVar * > &  profVars,
const std::vector< const ISyst * > &  profSysts 
)
protected

Definition at line 63 of file FrequentistSurface.cxx.

References ana::ExpandedHistogram(), ana::ISurface::fHist, fProfHists, MECModelEnuComparisons::i, ana::FitAxis::islog, ana::IFitVar::LatexName(), ana::FitAxis::max, ana::FitAxis::min, ana::FitAxis::nbins, ProgressBarTitle(), string, plotROC::title, and ana::FitAxis::var.

Referenced by FrequentistSurface(), and ~FrequentistSurface().

66  {
67  fHist = ExpandedHistogram(";"+xax.var->LatexName()+";"+yax.var->LatexName(),
68  xax.nbins, xax.min, xax.max, xax.islog,
69  yax.nbins, yax.min, yax.max, yax.islog);
70 
71  for(unsigned int i = 0; i < profVars.size()+profSysts.size(); ++i){
73  if(i < profVars.size())
74  title = profVars[i]->LatexName();
75  else
76  title = profSysts[i-profVars.size()]->LatexName();
77 
78  fProfHists.push_back(ExpandedHistogram(title+";"+xax.var->LatexName()+";"+yax.var->LatexName(),
79  xax.nbins, xax.min, xax.max, xax.islog,
80  yax.nbins, yax.min, yax.max, yax.islog));
81  }
82 
83  }
TH2F * ExpandedHistogram(const std::string &title, int nbinsx, double xmin, double xmax, bool xlog, int nbinsy, double ymin, double ymax, bool ylog)
Internal helper for Surface and FCSurface.
Definition: Utilities.cxx:149
std::vector< TH2 * > fProfHists
TH2F * fHist
Definition: ISurface.h:68
enum BeamMode string
void ana::ISurface::Draw ( ) const
inherited

Draw the surface itself.

Definition at line 21 of file ISurface.cxx.

References ana::ISurface::EnsureAxes(), and ana::ISurface::fHist.

Referenced by cc(), demo5(), ana::ISurface::GetBestFitY(), modularextrap_demo_nue(), modularextrap_demo_numu(), Plot2DSlices(), plot_3flavor_withsysts(), test_ana(), test_stanfit_statsonly(), test_stanfit_withsysts(), and test_surf_stride().

22  {
23  // Can be useful to draw a partial surface for debugging
24  // CheckMask();
25 
26  EnsureAxes();
27 
28  fHist->Draw("colz same");
29 
30  // colz obliterated them
31  gPad->RedrawAxis();
32 
33  gPad->Update();
34  }
TH2F * fHist
Definition: ISurface.h:68
void EnsureAxes() const
Definition: ISurface.cxx:70
void ana::ISurface::DrawBestFit ( Color_t  color,
Int_t  marker = kFullCircle 
) const
inherited

Draw the best fit point.

Definition at line 37 of file ISurface.cxx.

References ana::ISurface::CheckMask(), ana::ISurface::EnsureAxes(), ana::ISurface::fBestFitX, and ana::ISurface::fBestFitY.

Referenced by cc(), demo5(), demo_CPT(), drawSensitivity(), ana::ISurface::GetBestFitY(), getSensitivity(), make_contours(), modularextrap_demo_nue(), modularextrap_demo_numu(), Plot2DSlices(), plot_3flavor_withsysts(), starPlot(), syst_test(), template_basic(), template_GENIE_systs(), template_nonGENIE_systs(), test_ana(), test_stanfit_statsonly(), and test_stanfit_withsysts().

38  {
39  CheckMask("DrawBestFit");
40  EnsureAxes();
41 
42  TMarker *mark = new TMarker(fBestFitX, fBestFitY, marker);
43  mark->SetMarkerSize(1.5);
44  mark->SetMarkerColor(color);
45  mark->Draw();
46  gPad->Update();
47  }
void CheckMask(const std::string &func) const
Definition: ISurface.cxx:279
double fBestFitY
Definition: ISurface.h:67
void EnsureAxes() const
Definition: ISurface.cxx:70
double fBestFitX
Definition: ISurface.h:66
void ana::ISurface::DrawContour ( TH2 *  fc,
Style_t  style,
Color_t  color,
double  minchi = -1 
)
inherited
Parameters
fcSurface to compare against for this significance level
styleLine style for TAttLine, solid, dotted, dashed etc
colorLine color for TAttLine
minchi$\chi^2$ of best fit to compare against. Default: best fit from this surface.

Definition at line 50 of file ISurface.cxx.

References ana::ISurface::CheckMask(), ana::ISurface::EnsureAxes(), MECModelEnuComparisons::g, ana::ISurface::GetGraphs(), and APDGainPoints::gs.

Referenced by cc(), demo5(), Draw2DSurface(), DrawContours(), drawSensitivity(), ana::ISurface::GetBestFitY(), getSensitivity(), make_contours(), make_nom_expt(), modularextrap_demo_nue(), modularextrap_demo_numu(), Plot2DSlice(), Plot2DSlices(), plot_3flavor_withsysts(), plotContProf(), plots(), starPlot(), syst_test(), template_basic(), template_GENIE_systs(), template_nonGENIE_systs(), test_ana(), test_stanfit_statsonly(), and test_stanfit_withsysts().

52  {
53  CheckMask("DrawContour");
54  EnsureAxes();
55 
56  std::vector<TGraph *> gs = GetGraphs(fc, minchi);
57 
58  for (TGraph *g: gs)
59  {
60  g->SetLineWidth(3);//2);
61  g->SetLineStyle(style);
62  g->SetLineColor(color);
63  g->Draw("l");
64  }
65 
66  gPad->Update();
67  }
void CheckMask(const std::string &func) const
Definition: ISurface.cxx:279
std::vector< TGraph * > GetGraphs(TH2 *fc, double minchi=-1)
For expert use, custom painting of contours.
Definition: ISurface.cxx:113
void EnsureAxes() const
Definition: ISurface.cxx:70
void ana::ISurface::EnsureAxes ( ) const
protectedinherited

Definition at line 70 of file ISurface.cxx.

References visualisationForPaperMasterPlot::ax, file_size_ana::axes, ana::ISurface::BinCenterX(), ana::ISurface::BinCenterY(), ana::ISurface::fHist, ana::ISurface::fLogX, ana::ISurface::fLogY, genie::utils::style::Format(), and ana::UniqueName().

Referenced by ana::ISurface::Draw(), ana::ISurface::DrawBestFit(), and ana::ISurface::DrawContour().

71  {
72  // Could have a file temporarily open
73  DontAddDirectory guard;
74 
75  // If this pad has already been drawn in, already has axes
76  if (gPad && !gPad->GetListOfPrimitives()->IsEmpty()) return;
77 
78  const TAxis *ax = fHist->GetXaxis();
79  const TAxis *ay = fHist->GetYaxis();
80  const double Nx = ax->GetNbins();
81  const double Ny = ay->GetNbins();
82 
83  // Axes with limits where the user originally requested them, which we
84  // adjusted to be the centres of the first and last bins.
85  TH2 *axes = new TH2C(UniqueName().c_str(),
86  TString::Format(";%s;%s",
87  ax->GetTitle(), ay->GetTitle()),
88  Nx - 1, BinCenterX(1), BinCenterX(Nx),
89  Ny - 1, BinCenterY(1), BinCenterY(Ny));
90  axes->Draw();
91 
92  if(fHist){
93  // "colz same" will reuse axis's min and max, so set them helpfully here
94  axes->SetMinimum(fHist->GetMinimum());
95  axes->SetMaximum(fHist->GetMaximum());
96  }
97 
98  axes->SetTitle(fHist->GetTitle());
99  axes->GetXaxis()->SetLabelSize(ax->GetLabelSize());
100  axes->GetYaxis()->SetLabelSize(ay->GetLabelSize());
101  axes->GetXaxis()->SetLabelOffset(ax->GetLabelOffset());
102  axes->GetYaxis()->SetLabelOffset(ay->GetLabelOffset());
103  axes->GetXaxis()->CenterTitle();
104  axes->GetYaxis()->CenterTitle();
105 
106  if(fLogX) gPad->SetLogx();
107  if(fLogY) gPad->SetLogy();
108 
109  gPad->Update();
110  }
double BinCenterX(int bin) const
Definition: ISurface.cxx:265
double BinCenterY(int bin) const
Definition: ISurface.cxx:272
TH2F * fHist
Definition: ISurface.h:68
bool fLogX
Definition: ISurface.h:69
bool fLogY
Definition: ISurface.h:69
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
void ana::FrequentistSurface::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 
)
protectedvirtual

Reimplemented in ana::SurfaceKrige.

Definition at line 108 of file FrequentistSurface.cxx.

References ana::ThreadPool::AddTask(), bin, ana::ISurface::BinCenterX(), ana::ISurface::BinCenterY(), om::cerr, ana::IExperiment::ChiSq(), ana::Progress::Done(), e, allTimeWatchdog::endl, ana::ISurface::fBinMask, ana::ISurface::fHist, FillSurfacePoint(), ana::ThreadPool::Finish(), genie::utils::style::Format(), fParallel, site_stats_from_log::job, ana::JobNumber(), ana::ThreadPool::NThreads(), ana::NumJobs(), ana::IFitVar::Penalty(), time_estimates::pool, cacheDefinitionData::prog, ProgressBarTitle(), ana::RunningOnGrid(), ana::Progress::SetProgress(), ana::IFitVar::ShortName(), ana::ThreadPool::ShowProgress(), fillBadChanDBTables::step, update_sam_good_runs_metadata::stride, string, submit_syst::x, and submit_syst::y.

Referenced by FrequentistSurface().

115  {
116  // Nothing created during surface filling belongs in a
117  // directory. Unfortunately the local guards in Spectrum etc are racey when
118  // run in parallel. But this should cover the whole lot safely.
119  DontAddDirectory guard;
120 
121  const std::string progTitle = ProgressBarTitle(xvar, yvar, profVars, profSysts);
122 
123  Progress *prog = 0;
124  // Difficult to keep a progress bar properly up to date when threaded
125  if (!fParallel) prog = new Progress(progTitle);
126  ThreadPool *pool = 0;
127 
128  if(fParallel){
129  // A hack/workaround needed for parallel running:
130  //
131  // Give all the constituents of the Prediction a chance to do lazy
132  // initialization, before they race themselves trying to do it in
133  // parallel.
134  expt->ChiSq(calc);
135 
136  pool = new ThreadPool;
137  pool->ShowProgress(progTitle + TString::Format(" using %d threads", pool->NThreads()).Data());
138  }
139 
140  const int Nx = fHist->GetNbinsX();
141  const int Ny = fHist->GetNbinsY();
142 
143  // Fill bins in "random" order so that the progress bar is accurate
144  // straight away instead of possibly being misled by whatever atypical
145  // points we start with. This step is a prime which guarantees we get every
146  // cell.
147  int step = 7919;
148  // Very unlikely (Nx or Ny is a multiple of step), but just to be safe.
149  if ((Nx * Ny) % step == 0) step = 1;
150 
151  int bin = 0;
152  int neval = 0;
153 
154  // Allow the surface to be parallelised across multiple jobs by splitting up
155  // the full surface into patches, and only running bins that fall inside a
156  // certain patch
157  int first = 0, last = Nx * Ny;
158  if (RunningOnGrid() && NumJobs()>1) {
159  double stride = double(Nx*Ny) / double(NumJobs());
160  int job = JobNumber();
161  first = job * stride;
162  last = (job+1) * stride;
163  }
164 
165  do{
166  if (neval < first) {
167  ++neval;
168  bin = (bin + step) % (Nx * Ny);
169  continue;
170  } else if (neval >= last) {
171  break;
172  }
173 
174  const int x = bin % Nx + 1;
175  const int y = bin / Nx + 1;
176 
177  const double xv = BinCenterX(x);
178  const double yv = BinCenterY(y);
179 
180  if (xvar->Penalty(xv, calc) > 1e-10)
181  {
182  std::cerr << "Warning! " << xvar->ShortName() << " = " << xv
183  << " has penalty of " << xvar->Penalty(xv, calc)
184  << " that could have been applied in surface. "
185  << "This should never happen." << std::endl;
186  }
187  if (yvar->Penalty(yv, calc) > 1e-10)
188  {
189  std::cerr << "Warning! " << yvar->ShortName() << " = " << yv
190  << " has penalty of " << yvar->Penalty(yv, calc)
191  << " that could have been applied in surface. "
192  << "This should never happen." << std::endl;
193  }
194 
195  ThreadPool::func_t task = [=](){
196  FillSurfacePoint(expt, calc,
197  xvar, xv, yvar, yv,
198  profVars, profSysts, seedPts, systSeedPts);
199  };
200 
201  ++neval;
202  if(fParallel){
203  pool->AddTask(task);
204  }
205  else{
206  task(); // Just do it straight away
207  prog->SetProgress(double(neval-first) / double(last-first));
208  }
209 
210  if (RunningOnGrid() && NumJobs()>1) fBinMask.push_back(bin);
211 
212  bin = (bin + step) % (Nx * Ny);
213  } while (bin != 0);
214 
215 
216  if(fParallel){
217  pool->Finish();
218  delete pool;
219  }
220  else{
221  prog->Done();
222  delete prog;
223  }
224  }
size_t JobNumber()
What&#39;s the process number for a grid job?
Definition: Utilities.cxx:438
double BinCenterX(int bin) const
Definition: ISurface.cxx:265
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)
bool RunningOnGrid()
Is this a grid (condor) job?
Definition: Utilities.cxx:359
std::function< void(void)> func_t
The type of the user&#39;s worker functions.
Definition: ThreadPool.h:33
double BinCenterY(int bin) const
Definition: ISurface.cxx:272
OStream cerr
Definition: OStream.cxx:7
std::string ProgressBarTitle(const IFitVar *xvar, const IFitVar *yvar, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts) const
expt
Definition: demo5.py:34
TH2F * fHist
Definition: ISurface.h:68
float bin[41]
Definition: plottest35.C:14
size_t NumJobs()
Definition: Utilities.cxx:449
std::vector< int > fBinMask
Definition: ISurface.h:71
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
Float_t e
Definition: plot.C:35
enum BeamMode string
double ana::FrequentistSurface::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 
)
protected

Definition at line 227 of file FrequentistSurface.cxx.

References calc, ana::IExperiment::ChiSq(), osc::_IOscCalcAdjustable< T >::Copy(), fFitOpts, ana::ISurface::fHist, ana::IFitter::Fit(), fParallel, fProfHists, ana::ISurface::fSeedValues, ana::SystShifts::GetShift(), MECModelEnuComparisons::i, makeTrainCVSamples::int, calib::j, ana::IFitter::kQuiet, ana::MinuitFitter::SetFitOpts(), and ana::IFitVar::SetValue().

Referenced by FillSurface(), and FrequentistSurface().

235  {
236  if(fParallel){
237  // Need to take our own copy so that we don't get overwritten by someone
238  // else's changes.
239  calc = calc->Copy();
240  }
241 
242  xvar->SetValue(calc, x);
243  yvar->SetValue(calc, y);
244 
245  //Make sure that the profiled values of fitvars do not persist between steps.
246  for(int i = 0; i < (int)fSeedValues.size(); ++i) profVars[i]->SetValue( calc, fSeedValues[i] );
247 
248  double chi;
249  if(profVars.empty() && profSysts.empty()){
250  chi = expt->ChiSq(calc);
251  }
252  else{
253  MinuitFitter fitter(expt, profVars, profSysts);
254  fitter.SetFitOpts(fFitOpts);
255  SystShifts bestSysts;
256  chi = fitter.Fit(calc, bestSysts, seedPts, systSeedPts, MinuitFitter::kQuiet)->EvalMetricVal();
257 
258  for(unsigned int i = 0; i < profVars.size(); ++i){
259  fProfHists[i]->Fill(x, y, profVars[i]->GetValue(calc));
260  }
261  for(unsigned int j = 0; j < profSysts.size(); ++j){
262  fProfHists[j+profVars.size()]->Fill(x, y, bestSysts.GetShift(profSysts[j]));
263  }
264  }
265 
266  fHist->Fill(x, y, chi);
267 
268  if(fParallel) delete calc;
269 
270  return chi;
271  }
virtual _IOscCalcAdjustable< T > * Copy() const =0
MinuitFitter::FitOpts fFitOpts
osc::OscCalcDumb calc
std::vector< TH2 * > fProfHists
expt
Definition: demo5.py:34
TH2F * fHist
Definition: ISurface.h:68
const double j
Definition: BetheBloch.cxx:29
std::vector< double > fSeedValues
Definition: ISurface.h:70
void ana::ISurface::FillSurfObj ( ISurface surf,
TDirectory *  dir 
)
staticprotectedinherited

Definition at line 229 of file ISurface.cxx.

References ana::ISurface::fBestFitX, ana::ISurface::fBestFitY, ana::ISurface::fBestLikelihood, ana::ISurface::fBinMask, ana::ISurface::fHist, ana::ISurface::fSeedValues, compare_h5_caf::idx, m, and registry_explorer::v.

Referenced by ana::ISurface::GetBestFitY(), ana::BayesianSurface::LoadFrom(), and LoadFrom().

230  {
231 
232  const TVectorD v = *(TVectorD *) dir->Get("minValues");
233  const TVectorD s = *(TVectorD *) dir->Get("seeds");
234  TVectorD* m = (TVectorD *) dir->Get("mask");
235 
236  surf.fHist = (TH2F *) dir->Get("hist");
237  surf.fBestLikelihood = v[0];
238  surf.fBestFitX = v[1];
239  surf.fBestFitY = v[2];
240 
241  for (int idx = 0; idx < s.GetNrows(); ++idx)
242  surf.fSeedValues.push_back(s[idx]);
243 
244  if (m) {
245  for (int idx = 0; idx < m->GetNrows(); ++idx)
246  surf.fBinMask.push_back((*m)[idx]);
247  }
248 
249  }
const XML_Char * s
Definition: expat.h:262
TDirectory * dir
Definition: macro.C:5
surf
Definition: demo5.py:35
void ana::FrequentistSurface::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 
)
protected

Definition at line 275 of file FrequentistSurface.cxx.

References bin, ana::ISurface::BinCenterX(), ana::ISurface::BinCenterY(), confusionMatrixTree::count, ana::ISurface::fBestFitX, ana::ISurface::fBestFitY, ana::ISurface::fBestLikelihood, ana::ISurface::fBinMask, fFitOpts, ana::ISurface::fHist, ana::IFitter::Fit(), ana::ISurface::fSeedValues, ana::IFitVar::GetValue(), MECModelEnuComparisons::i, makeTrainCVSamples::int, ana::SystShifts::Nominal(), ana::NumJobs(), ana::RunningOnGrid(), ana::MinuitFitter::SetFitOpts(), ana::IFitVar::SetValue(), submit_syst::x, and submit_syst::y.

Referenced by FrequentistSurface().

282  {
283  // Location of the best minimum found from filled surface
284  double minchi = 1e10;
285  int minx = fHist->GetNbinsX()/2;
286  int miny = fHist->GetNbinsY()/2;
287  for(int x = 1; x <= fHist->GetNbinsX(); ++x){
288  for(int y = 1; y <= fHist->GetNbinsY(); ++y){
289  int bin = ((y-1)*fHist->GetNbinsX())+(x-1);
290  const double chi = fHist->GetBinContent(x, y);
291  if(RunningOnGrid() && NumJobs()>1
292  && !std::count(fBinMask.begin(), fBinMask.end(), bin)) continue;
293  if (chi < minchi){
294  minchi = chi;
295  minx = x;
296  miny = y;
297  }
298  }
299  }
300 
301  std::vector<const IFitVar*> allVars = {xvar, yvar};
302  allVars.insert(allVars.end(), profVars.begin(), profVars.end());
303  MinuitFitter fit(expt, allVars, profSysts);
304  fit.SetFitOpts(fFitOpts);
305  // Seed from best grid point
306  xvar->SetValue(calc, BinCenterX(minx));
307  yvar->SetValue(calc, BinCenterY(miny));
308  for(int i = 0; i < (int)fSeedValues.size(); ++i) profVars[i]->SetValue( calc, fSeedValues[i] );
309  SystShifts systSeed = SystShifts::Nominal();
310  fBestLikelihood = fit.Fit(calc, systSeed, seedPts)->EvalMetricVal();
311  fBestFitX = xvar->GetValue(calc);
312  fBestFitY = yvar->GetValue(calc);
313 
314  for(int x = 0; x < fHist->GetNbinsX()+2; ++x){
315  for(int y = 0; y < fHist->GetNbinsY()+2; ++y){
316  fHist->SetBinContent(x, y, fHist->GetBinContent(x, y)-fBestLikelihood);
317  }
318  }
319 
320  fHist->SetMinimum(0);
321  }
MinuitFitter::FitOpts fFitOpts
double BinCenterX(int bin) const
Definition: ISurface.cxx:265
bool RunningOnGrid()
Is this a grid (condor) job?
Definition: Utilities.cxx:359
double BinCenterY(int bin) const
Definition: ISurface.cxx:272
static SystShifts Nominal()
Definition: SystShifts.h:34
expt
Definition: demo5.py:34
TH2F * fHist
Definition: ISurface.h:68
double fBestFitY
Definition: ISurface.h:67
float bin[41]
Definition: plottest35.C:14
std::vector< double > fSeedValues
Definition: ISurface.h:70
double fBestFitX
Definition: ISurface.h:66
size_t NumJobs()
Definition: Utilities.cxx:449
std::vector< int > fBinMask
Definition: ISurface.h:71
double fBestLikelihood
Definition: ISurface.h:65
double ana::ISurface::GetBestFitX ( ) const
inlineinherited

Definition at line 30 of file ISurface.h.

References ana::ISurface::fBestFitX.

Referenced by test_stanfit_statsonly().

30 {return fBestFitX;}
double fBestFitX
Definition: ISurface.h:66
double ana::ISurface::GetBestFitY ( ) const
inlineinherited
std::vector< TGraph * > ana::ISurface::GetGraphs ( TH2 *  fc,
double  minchi = -1 
)
inherited

For expert use, custom painting of contours.

Definition at line 113 of file ISurface.cxx.

References ana::ISurface::CheckMask(), ana::ISurface::fBestLikelihood, ana::ISurface::fHist, runNovaSAM::ret, PandAna.Demos.tute_pid_validation::specs, demo5::surf, tmp, and ana::UniqueName().

Referenced by ana::ISurface::DrawContour(), and ana::ISurface::GetBestFitY().

114  {
115  CheckMask("GetGraphs");
116 
117  std::vector<TGraph*> ret;
118 
119  if(minchi < 0) minchi = fBestLikelihood;
120  std::unique_ptr<TH2> surf((TH2*)fHist->Clone(UniqueName().c_str()));
121  surf->Add(fc, -1);
122 
123  TVirtualPad* bak = gPad;
124 
125  const bool wasbatch = gROOT->IsBatch();
126  gROOT->SetBatch(); // User doesn't want to see our temporary canvas
127  TCanvas tmp;
128 
129  gStyle->SetOptStat(0);
130 
131  const double level = minchi-fBestLikelihood;
132  surf->SetContour(1, &level);
133  surf->Draw("cont list");
134 
135  tmp.Update();
136  tmp.Paint();
137 
138  gROOT->SetBatch(wasbatch);
139  gPad = bak;
140 
141  // The graphs we need (contained inside TLists, contained inside
142  // TObjArrays) are in the list of specials. But we need to be careful about
143  // types, because other stuff can get in here too (TDatabasePDG for
144  // example).
145  TCollection* specs = gROOT->GetListOfSpecials();
146 
147  TIter nextSpec(specs);
148  while(TObject* spec = nextSpec()){
149  if(!spec->InheritsFrom(TObjArray::Class())) continue;
150  TObjArray* conts = (TObjArray*)spec;
151 
152  if(conts->IsEmpty()) continue;
153 
154  if(!conts->At(0)->InheritsFrom(TList::Class())) continue;
155  TList* cont = (TList*)conts->At(0);
156 
157  TIter nextObj(cont);
158  // Contour could be split into multiple pieces
159  while(TObject* obj = nextObj()){
160  if(!obj->InheritsFrom(TGraph::Class())) continue;
161 
162  ret.push_back((TGraph*)obj->Clone(UniqueName().c_str()));
163  } // end for obj
164  } // end for spec
165 
166  return ret;
167  }
void CheckMask(const std::string &func) const
Definition: ISurface.cxx:279
Float_t tmp
Definition: plot.C:36
TH2F * fHist
Definition: ISurface.h:68
double fBestLikelihood
Definition: ISurface.h:65
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
surf
Definition: demo5.py:35
std::vector<TH2*> ana::FrequentistSurface::GetProfiledHists ( )
inline

Maps of the values taken on by the profiled parameters.

Definition at line 83 of file FrequentistSurface.h.

References dir, compareCafs::files, fProfHists, label, LoadFrom(), LoadFromMulti(), SaveTo(), string, and wildcard().

Referenced by run_joint_fit_2020_contours().

83 {return fProfHists;}
std::vector< TH2 * > fProfHists
std::unique_ptr< FrequentistSurface > ana::FrequentistSurface::LoadFrom ( TDirectory *  dir,
const std::string name 
)
static

Definition at line 350 of file FrequentistSurface.cxx.

References ana::assert(), dir, ana::ISurface::FillSurfObj(), genie::utils::style::Format(), make_syst_table_plots::h, compare_h5_caf::idx, logx, logy, demo5::surf, and getGoodRuns4SAM::tag.

Referenced by compare_fits(), demoFitContours(), DrawExtrapSurface(), GetProfiledHists(), joint_fit_2018_contours(), joint_fit_2019_contours(), LoadFromMulti(), median_contours(), plot_joint_fit_2020_contours(), Plotting_CompareMultipleContours(), sensitivity2018(), and sensitivity2020().

351  {
352  dir = dir->GetDirectory(name.c_str()); // switch to subdir
353  assert(dir);
354 
355  DontAddDirectory guard;
356 
357  TObjString *tag = (TObjString *) dir->Get("type");
358  assert(tag);
359  assert(tag->GetString() == "FrequentistSurface" || tag->GetString() == "Surface");
360  delete tag;
361 
362  std::unique_ptr<FrequentistSurface> surf(new FrequentistSurface);
364 
365  for (std::size_t idx = 0; idx < surf->fSeedValues.size(); ++idx)
366  {
367  // Search for old "marg" name here too for backwards compatibility
368  TH2 *h = (TH2 *) dir->Get(TString::Format("profHists/hist%lu", idx));
369  if (h)
370  surf->fProfHists.push_back(h);
371  else
372  surf->fProfHists.push_back((TH2 *) dir->Get(TString::Format("margHists/hist%lu", idx)));
373  }
374 
375  const TObjString* logx = (TObjString*)dir->Get("logx");
376  const TObjString* logy = (TObjString*)dir->Get("logy");
377  // Tolerate missing log tags for backwards compatibility
378  surf->fLogX = (logx && logx->GetString() == "yes");
379  surf->fLogY = (logy && logy->GetString() == "yes");
380 
381  delete dir;
382 
383  return surf;
384  }
const XML_Char * name
Definition: expat.h:151
bool logy
bool logx
TDirectory * dir
Definition: macro.C:5
assert(nhit_max >=nhit_nbins)
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
static void FillSurfObj(ISurface &surf, TDirectory *dir)
Definition: ISurface.cxx:229
surf
Definition: demo5.py:35
std::unique_ptr< FrequentistSurface > ana::FrequentistSurface::LoadFromMulti ( std::vector< TFile * >  files,
std::string  label 
)
static

Definition at line 387 of file FrequentistSurface.cxx.

References ana::assert(), bin, confusionMatrixTree::count, om::cout, allTimeWatchdog::endl, MakeMiniprodValidationCuts::f, ana::ISurface::fBestLikelihood, ana::ISurface::fBinMask, fProfHists, make_syst_table_plots::h, MECModelEnuComparisons::i, calib::j, LoadFrom(), nbins, runNovaSAM::ret, ana::ISurface::ToTH2(), submit_syst::x, and submit_syst::y.

Referenced by GetProfiledHists(), LoadFromMulti(), MergeSurface(), MergeSurfaces(), and test_surf_stride().

389  {
390  std::vector<std::unique_ptr<FrequentistSurface>> surfs;
391  for (TFile* f : files) {
392  surfs.push_back(FrequentistSurface::LoadFrom(f, label));
393  }
394 
395  int Nx = surfs[0]->fHist->GetNbinsX();
396  int Ny = surfs[0]->fHist->GetNbinsY();
397  size_t nbins = Nx * Ny;
398  std::vector<int> binMask;
399 
400  // Loop over the surfaces to check all bins are present
401  for (size_t i = 0; i < surfs.size(); ++i) {
402  for (int bin : surfs[i]->fBinMask) {
403  if (std::count(binMask.begin(), binMask.end(), bin))
404  assert(false && "Repeated bin found in surfaces being merged.");
405  binMask.push_back(bin);
406  }
407  }
408  if (binMask.size() != nbins) {
409  std::cout << "Missing bins found in surfaces being merged. "
410  << "Are you sure you included all files for this surface?"
411  << std::endl;
412  assert(false);
413  }
414 
415  DontAddDirectory guard;
416 
417  // Create return surface and initialise with first in list
418  std::unique_ptr<FrequentistSurface> ret(new FrequentistSurface);
419  ret->fHist = new TH2F(*(TH2F*)surfs[0]->ToTH2(0));
420  ret->fBestLikelihood = surfs[0]->fBestLikelihood;
421  ret->fBestFitX = surfs[0]->fBestFitX;
422  ret->fBestFitY = surfs[0]->fBestFitY;
423  ret->fLogX = surfs[0]->fLogX;
424  ret->fLogY = surfs[0]->fLogY;
425  ret->fSeedValues = surfs[0]->fSeedValues;
426  for (TH2* h : surfs[0]->fProfHists)
427  ret->fProfHists.push_back((TH2F*)h->Clone());
428 
429  // Loop over other surfaces and add them in
430  for (size_t i = 1; i < surfs.size(); ++i) {
431  ret->fHist->Add(surfs[i]->ToTH2(0));
432  if (surfs[i]->fBestLikelihood < ret->fBestLikelihood) {
433  ret->fBestLikelihood = surfs[i]->fBestLikelihood;
434  ret->fBestFitX = surfs[i]->fBestFitX;
435  ret->fBestFitY = surfs[i]->fBestFitY;
436  }
437  for (size_t j = 0; j < ret->fProfHists.size(); ++j)
438  ret->fProfHists[j]->Add(surfs[i]->fProfHists[j]);
439  }
440 
441  // Scale hist by global minimum
442  for(int x = 0; x < ret->fHist->GetNbinsX()+2; ++x){
443  for(int y = 0; y < ret->fHist->GetNbinsY()+2; ++y){
444  ret->fHist->SetBinContent(x, y, ret->fHist->GetBinContent(x, y)-ret->fBestLikelihood);
445  }
446  }
447 
448  ret->fHist->SetMinimum(0);
449 
450  return ret;
451  }
const char * label
std::vector< TH2 * > fProfHists
const int nbins
Definition: cellShifts.C:15
const double j
Definition: BetheBloch.cxx:29
float bin[41]
Definition: plottest35.C:14
OStream cout
Definition: OStream.cxx:6
TH2 * ToTH2(double minchi=-1) const
Definition: ISurface.cxx:170
std::vector< int > fBinMask
Definition: ISurface.h:71
assert(nhit_max >=nhit_nbins)
static std::unique_ptr< FrequentistSurface > LoadFrom(TDirectory *dir, const std::string &name)
double fBestLikelihood
Definition: ISurface.h:65
std::unique_ptr< FrequentistSurface > ana::FrequentistSurface::LoadFromMulti ( std::string  wildcard,
std::string  label 
)
static

Definition at line 454 of file FrequentistSurface.cxx.

References MakeMiniprodValidationCuts::f, plotROC::fileName, compareCafs::files, LoadFromMulti(), runNovaSAM::ret, string, and ana::Wildcard().

456  {
457  std::vector<std::string> fileNames = Wildcard(wildcard);
458  std::vector<TFile*> files;
459  for (std::string fileName : fileNames) {
460  files.push_back(TFile::Open(fileName.c_str(), "read"));
461  }
462  std::unique_ptr<FrequentistSurface> ret = LoadFromMulti(files, label);
463  for(TFile* f: files) delete f;
464  return ret;
465  }
fileName
Definition: plotROC.py:78
const char * label
std::vector< std::string > Wildcard(const std::string &wildcardString)
Find files matching a UNIX glob, plus expand environment variables.
Definition: UtilsExt.cxx:268
std::vector< std::string > wildcard(const std::string &wildcardString)
Definition: convert.C:9
static std::unique_ptr< FrequentistSurface > LoadFromMulti(std::vector< TFile * > files, std::string label)
enum BeamMode string
std::string ana::FrequentistSurface::ProgressBarTitle ( const IFitVar xvar,
const IFitVar yvar,
const std::vector< const IFitVar * > &  profVars,
const std::vector< const ISyst * > &  profSysts 
) const
protected

Definition at line 87 of file FrequentistSurface.cxx.

References ana::IFitVar::ShortName(), string, plotROC::title, and registry_explorer::v.

Referenced by CreateHistograms(), FillSurface(), and FrequentistSurface().

90  {
91  std::string title = "Filling surface for "+yvar->ShortName()+" vs "+xvar->ShortName();
92 
93  if(!profVars.empty() || !profSysts.empty()){
94  title += " (profiling ";
95 
96  for(const IFitVar* v: profVars) title += v->ShortName() + ", ";
97  for(const ISyst* s: profSysts) title += s->ShortName() + ", ";
98 
99  // Always have one superfluous ", " at the end
100  title.resize(title.size()-2);
101  title += ")";
102  }
103 
104  return title;
105  }
const XML_Char * s
Definition: expat.h:262
enum BeamMode string
void ana::FrequentistSurface::SaveTo ( TDirectory *  dir,
const std::string name 
) const

Definition at line 324 of file FrequentistSurface.cxx.

References dir, genie::utils::style::Format(), fProfHists, compare_h5_caf::idx, it, ana::ISurface::SaveToHelper(), and tmp.

Referenced by getContProf(), getContProf_Sensitivity(), GetProfiledHists(), joint_fit_future_contour_univ(), make_surfprof(), make_surfprof_sensitivity(), MakeExtrapSurface(), MakeSurface(), run_joint_fit_2020_contours(), sensitivity2018(), and sensitivity2020().

325  {
326  TDirectory *tmp = gDirectory;
327 
328  dir = dir->mkdir(name.c_str()); // switch to subdir
329  dir->cd();
330 
331  TObjString("FrequentistSurface").Write("type");
332 
334 
335  TDirectory *profDir = dir->mkdir("profHists");
336  int idx = 0;
338  {
339  profDir->cd();
340  it->Write(TString::Format("hist%d", idx++));
341  }
342 
343  dir->Write();
344  delete dir;
345 
346  tmp->cd();
347  }
const XML_Char * name
Definition: expat.h:151
set< int >::iterator it
Float_t tmp
Definition: plot.C:36
std::vector< TH2 * > fProfHists
void SaveToHelper(TDirectory *dir) const
dir should already be the appropriate sub-directory
Definition: ISurface.cxx:198
TDirectory * dir
Definition: macro.C:5
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
void ana::ISurface::SaveToHelper ( TDirectory *  dir) const
protectedinherited

dir should already be the appropriate sub-directory

Definition at line 198 of file ISurface.cxx.

References ana::ISurface::fBestFitX, ana::ISurface::fBestFitY, ana::ISurface::fBestLikelihood, ana::ISurface::fBinMask, ana::ISurface::fHist, ana::ISurface::fLogX, ana::ISurface::fLogY, ana::ISurface::fSeedValues, m, tmp, and registry_explorer::v.

Referenced by ana::ISurface::GetBestFitY(), ana::BayesianSurface::SaveTo(), and SaveTo().

199  {
200  TDirectory *oldDir = gDirectory;
201 
202  dir->cd();
203 
204  TVectorD v(3);
205  v[0] = fBestLikelihood;
206  v[1] = fBestFitX;
207  v[2] = fBestFitY;
208  v.Write("minValues");
209 
210  fHist->Write("hist");
211 
212  TVectorD s(fSeedValues.size(), &fSeedValues[0]);
213  s.Write("seeds");
214 
215  if (!fBinMask.empty()) {
216  std::vector<double> tmp(fBinMask.begin(), fBinMask.end());
217  TVectorD m(tmp.size(), &tmp[0]);
218  m.Write("mask");
219  }
220 
221  TObjString(fLogX ? "yes" : "no").Write("logx");
222  TObjString(fLogY ? "yes" : "no").Write("logy");
223 
224  if (oldDir)
225  oldDir->cd();
226  }
Float_t tmp
Definition: plot.C:36
const XML_Char * s
Definition: expat.h:262
TH2F * fHist
Definition: ISurface.h:68
bool fLogX
Definition: ISurface.h:69
double fBestFitY
Definition: ISurface.h:67
bool fLogY
Definition: ISurface.h:69
std::vector< double > fSeedValues
Definition: ISurface.h:70
TDirectory * dir
Definition: macro.C:5
double fBestFitX
Definition: ISurface.h:66
std::vector< int > fBinMask
Definition: ISurface.h:71
double fBestLikelihood
Definition: ISurface.h:65
void ana::ISurface::SetTitle ( const char *  str)
inherited

Definition at line 192 of file ISurface.cxx.

References ana::ISurface::fHist.

Referenced by ana::ISurface::GetBestFitY(), and plots().

193  {
194  fHist->SetTitle(str);
195  }
TH2F * fHist
Definition: ISurface.h:68
TH2 * ana::ISurface::ToTH2 ( double  minchi = -1) const
inherited

Definition at line 170 of file ISurface.cxx.

References ana::ISurface::fBestLikelihood, ana::ISurface::fHist, runNovaSAM::ret, submit_syst::x, and submit_syst::y.

Referenced by CAF_makeCAFSensitivities_for_FNEX(), demoFitContours(), ana::ISurface::GetBestFitY(), joint_fit_2017_contours(), joint_fit_2018_contours(), joint_fit_2019_contours(), joint_fit_future_contour_univ(), LoadFromMulti(), MakeCAFSensitivities_for_FNEX(), Plot2DSlice(), Plot2DSlices(), plot_3flavor_withsysts(), run_joint_fit_2020_contours(), sensitivity2018(), sensitivity2020(), and test_stanfit_withsysts().

171  {
172  // Could have a file temporarily open
173  DontAddDirectory guard;
174 
175  TH2 *ret = new TH2F(*fHist);
176 
177  if (minchi >= 0)
178  {
179  for (int x = 0; x < ret->GetNbinsX() + 2; ++x)
180  {
181  for (int y = 0; y < ret->GetNbinsY() + 2; ++y)
182  {
183  ret->SetBinContent(x, y, ret->GetBinContent(x, y) + fBestLikelihood - minchi);
184  }
185  }
186  }
187 
188  return ret;
189  }
TH2F * fHist
Definition: ISurface.h:68
double fBestLikelihood
Definition: ISurface.h:65

Member Data Documentation

double ana::ISurface::fBestFitX
protectedinherited
double ana::ISurface::fBestFitY
protectedinherited
double ana::ISurface::fBestLikelihood
protectedinherited
std::vector<int> ana::ISurface::fBinMask
protectedinherited
MinuitFitter::FitOpts ana::FrequentistSurface::fFitOpts
protected

Definition at line 128 of file FrequentistSurface.h.

Referenced by FillSurfacePoint(), and FindMinimum().

TH2F* ana::ISurface::fHist
protectedinherited
bool ana::ISurface::fLogX
protectedinherited
bool ana::ISurface::fLogY
protectedinherited
bool ana::FrequentistSurface::fParallel
protected

Definition at line 126 of file FrequentistSurface.h.

Referenced by FillSurface(), and FillSurfacePoint().

std::vector<TH2*> ana::FrequentistSurface::fProfHists
protected
std::vector<double> ana::ISurface::fSeedValues
protectedinherited

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