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-04-15/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 33 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.

43  : fParallel(parallel), fFitOpts(opts)
44  {
45  fLogX = xax.islog;
46  fLogY = yax.islog;
47 
48  CreateHistograms(xax, yax, profVars, profSysts);
49 
50  for(const IFitVar* v: profVars) fSeedValues.push_back(v->GetValue( calc));
51 
52  FillSurface(expt, calc, xax.var, yax.var, profVars, profSysts, seedPts, systSeedPts);
53 
54  FindMinimum(expt, calc, xax.var, yax.var, profVars, profSysts, seedPts, systSeedPts);
55  }
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 58 of file FrequentistSurface.cxx.

References CreateHistograms().

Referenced by FrequentistSurface().

59  {
60  }
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 64 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().

67  {
68  fHist = ExpandedHistogram(";"+xax.var->LatexName()+";"+yax.var->LatexName(),
69  xax.nbins, xax.min, xax.max, xax.islog,
70  yax.nbins, yax.min, yax.max, yax.islog);
71 
72  for(unsigned int i = 0; i < profVars.size()+profSysts.size(); ++i){
74  if(i < profVars.size())
75  title = profVars[i]->LatexName();
76  else
77  title = profSysts[i-profVars.size()]->LatexName();
78 
79  fProfHists.push_back(ExpandedHistogram(title+";"+xax.var->LatexName()+";"+yax.var->LatexName(),
80  xax.nbins, xax.min, xax.max, xax.islog,
81  yax.nbins, yax.min, yax.max, yax.islog));
82  }
83 
84  }
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:148
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:28
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 109 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, add_attributes::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().

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

Referenced by FillSurface(), and FrequentistSurface().

236  {
237  if(fParallel){
238  // Need to take our own copy so that we don't get overwritten by someone
239  // else's changes.
240  calc = calc->Copy();
241  }
242 
243  xvar->SetValue(calc, x);
244  yvar->SetValue(calc, y);
245 
246  //Make sure that the profiled values of fitvars do not persist between steps.
247  for(int i = 0; i < (int)fSeedValues.size(); ++i) profVars[i]->SetValue( calc, fSeedValues[i] );
248 
249  expt->Reset();
250 
251  double chi;
252  if(profVars.empty() && profSysts.empty()){
253  chi = expt->ChiSq(calc);
254  }
255  else{
256  MinuitFitter fitter(expt, profVars, profSysts);
257  fitter.SetFitOpts(fFitOpts);
258  SystShifts bestSysts;
259  chi = fitter.Fit(calc, bestSysts, seedPts, systSeedPts, MinuitFitter::kQuiet)->EvalMetricVal();
260 
261  for(unsigned int i = 0; i < profVars.size(); ++i){
262  fProfHists[i]->Fill(x, y, profVars[i]->GetValue(calc));
263  }
264  for(unsigned int j = 0; j < profSysts.size(); ++j){
265  fProfHists[j+profVars.size()]->Fill(x, y, bestSysts.GetShift(profSysts[j]));
266  }
267  }
268 
269  fHist->Fill(x, y, chi);
270 
271  if(fParallel) delete calc;
272 
273  return chi;
274  }
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 278 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::IExperiment::Reset(), ana::RunningOnGrid(), ana::MinuitFitter::SetFitOpts(), ana::IFitVar::SetValue(), submit_syst::x, and submit_syst::y.

Referenced by FrequentistSurface().

285  {
286  // Location of the best minimum found from filled surface
287  double minchi = 1e10;
288  int minx = fHist->GetNbinsX()/2;
289  int miny = fHist->GetNbinsY()/2;
290  for(int x = 1; x <= fHist->GetNbinsX(); ++x){
291  for(int y = 1; y <= fHist->GetNbinsY(); ++y){
292  int bin = ((y-1)*fHist->GetNbinsX())+(x-1);
293  const double chi = fHist->GetBinContent(x, y);
294  if(RunningOnGrid() && NumJobs()>1
295  && !std::count(fBinMask.begin(), fBinMask.end(), bin)) continue;
296  if (chi < minchi){
297  minchi = chi;
298  minx = x;
299  miny = y;
300  }
301  }
302  }
303 
304  std::vector<const IFitVar*> allVars = {xvar, yvar};
305  allVars.insert(allVars.end(), profVars.begin(), profVars.end());
306  MinuitFitter fit(expt, allVars, profSysts);
307  fit.SetFitOpts(fFitOpts);
308  expt->Reset();
309  // Seed from best grid point
310  xvar->SetValue(calc, BinCenterX(minx));
311  yvar->SetValue(calc, BinCenterY(miny));
312  for(int i = 0; i < (int)fSeedValues.size(); ++i) profVars[i]->SetValue( calc, fSeedValues[i] );
313  SystShifts systSeed = SystShifts::Nominal();
314  fBestLikelihood = fit.Fit(calc, systSeed, seedPts)->EvalMetricVal();
315  fBestFitX = xvar->GetValue(calc);
316  fBestFitY = yvar->GetValue(calc);
317 
318  for(int x = 0; x < fHist->GetNbinsX()+2; ++x){
319  for(int y = 0; y < fHist->GetNbinsY()+2; ++y){
320  fHist->SetBinContent(x, y, fHist->GetBinContent(x, y)-fBestLikelihood);
321  }
322  }
323 
324  fHist->SetMinimum(0);
325  }
MinuitFitter::FitOpts fFitOpts
double BinCenterX(int bin) const
Definition: ISurface.cxx:265
bool RunningOnGrid()
Is this a grid (condor) job?
Definition: Utilities.cxx:358
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:448
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:28
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 354 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().

355  {
356  dir = dir->GetDirectory(name.c_str()); // switch to subdir
357  assert(dir);
358 
359  DontAddDirectory guard;
360 
361  TObjString *tag = (TObjString *) dir->Get("type");
362  assert(tag);
363  assert(tag->GetString() == "FrequentistSurface" || tag->GetString() == "Surface");
364  delete tag;
365 
366  std::unique_ptr<FrequentistSurface> surf(new FrequentistSurface);
368 
369  for (std::size_t idx = 0; idx < surf->fSeedValues.size(); ++idx)
370  {
371  // Search for old "marg" name here too for backwards compatibility
372  TH2 *h = (TH2 *) dir->Get(TString::Format("profHists/hist%lu", idx));
373  if (h)
374  surf->fProfHists.push_back(h);
375  else
376  surf->fProfHists.push_back((TH2 *) dir->Get(TString::Format("margHists/hist%lu", idx)));
377  }
378 
379  const TObjString* logx = (TObjString*)dir->Get("logx");
380  const TObjString* logy = (TObjString*)dir->Get("logy");
381  // Tolerate missing log tags for backwards compatibility
382  surf->fLogX = (logx && logx->GetString() == "yes");
383  surf->fLogY = (logy && logy->GetString() == "yes");
384 
385  delete dir;
386 
387  return surf;
388  }
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 391 of file FrequentistSurface.cxx.

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

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

393  {
394  std::vector<std::unique_ptr<FrequentistSurface>> surfs;
395  for (TFile* f : files) {
396  surfs.push_back(FrequentistSurface::LoadFrom(f, label));
397  }
398 
399  int Nx = surfs[0]->fHist->GetNbinsX();
400  int Ny = surfs[0]->fHist->GetNbinsY();
401  size_t nbins = Nx * Ny;
402  std::vector<int> binMask;
403 
404  // Loop over the surfaces to check all bins are present
405  for (size_t i = 0; i < surfs.size(); ++i) {
406  for (int bin : surfs[i]->fBinMask) {
407  if (std::count(binMask.begin(), binMask.end(), bin))
408  assert(false && "Repeated bin found in surfaces being merged.");
409  binMask.push_back(bin);
410  }
411  }
412  if (binMask.size() != nbins) {
413  std::cout << "Missing bins found in surfaces being merged. "
414  << "Are you sure you included all files for this surface?"
415  << std::endl;
416  assert(false);
417  }
418 
419  DontAddDirectory guard;
420 
421  // Create return surface and initialise with first in list
422  std::unique_ptr<FrequentistSurface> ret(new FrequentistSurface);
423  ret->fHist = (TH2F*)surfs[0]->ToTH2(0)->Clone();
424  for (TH2* h : surfs[0]->fProfHists)
425  ret->fProfHists.push_back((TH2F*)h->Clone());
426 
427  ret->fLogX = surfs[0]->fLogX;
428  ret->fLogY = surfs[0]->fLogY;
429  ret->fSeedValues = surfs[0]->fSeedValues;
430 
431  // Find job that contains minimum bin (and therefore true best fit)
432  int best = -1;
433  double minChi = std::numeric_limits<double>::max();
434  for (size_t i = 0; i < surfs.size(); ++i) {
435  TH2F* hist = (TH2F*)surfs[i]->ToTH2(0);
436  for (size_t bin : surfs[i]->fBinMask) {
437  const int x = bin % Nx + 1;
438  const int y = bin / Nx + 1;
439  double val = hist->GetBinContent(x, y);
440  if (val < minChi) {
441  minChi = val;
442  best = i;
443  }
444  }
445  }
446 
447  ret->fBestLikelihood = surfs[best]->fBestLikelihood;
448  ret->fBestFitX = surfs[best]->fBestFitX;
449  ret->fBestFitY = surfs[best]->fBestFitY;
450 
451  // Loop over other surfaces and add them in
452  for (size_t i = 1; i < surfs.size(); ++i) {
453  ret->fHist->Add(surfs[i]->ToTH2(0));
454  for (size_t j = 0; j < ret->fProfHists.size(); ++j)
455  ret->fProfHists[j]->Add(surfs[i]->fProfHists[j]);
456  }
457 
458  // Scale hist by global minimum
459  for(int x = 0; x < ret->fHist->GetNbinsX()+2; ++x){
460  for(int y = 0; y < ret->fHist->GetNbinsY()+2; ++y){
461  ret->fHist->SetBinContent(x, y, ret->fHist->GetBinContent(x, y)-ret->fBestLikelihood);
462  }
463  }
464 
465  ret->fHist->SetMinimum(0);
466 
467  return ret;
468  }
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)
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:66
static std::unique_ptr< FrequentistSurface > LoadFrom(TDirectory *dir, const std::string &name)
std::unique_ptr< FrequentistSurface > ana::FrequentistSurface::LoadFromMulti ( std::string  wildcard,
std::string  label 
)
static

Definition at line 471 of file FrequentistSurface.cxx.

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

473  {
474  std::vector<std::string> fileNames = Wildcard(wildcard);
475  std::vector<TFile*> files;
476  for (std::string fileName : fileNames) {
477  files.push_back(TFile::Open(fileName.c_str(), "read"));
478  }
479  std::unique_ptr<FrequentistSurface> ret = LoadFromMulti(files, label);
480  for(TFile* f: files) delete f;
481  return ret;
482  }
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 88 of file FrequentistSurface.cxx.

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

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

91  {
92  std::string title = "Filling surface for "+yvar->ShortName()+" vs "+xvar->ShortName();
93 
94  if(!profVars.empty() || !profSysts.empty()){
95  title += " (profiling ";
96 
97  for(const IFitVar* v: profVars) title += v->ShortName() + ", ";
98  for(const ISyst* s: profSysts) title += s->ShortName() + ", ";
99 
100  // Always have one superfluous ", " at the end
101  title.resize(title.size()-2);
102  title += ")";
103  }
104 
105  return title;
106  }
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 328 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().

329  {
330  TDirectory *tmp = gDirectory;
331 
332  dir = dir->mkdir(name.c_str()); // switch to subdir
333  dir->cd();
334 
335  TObjString("FrequentistSurface").Write("type");
336 
338 
339  TDirectory *profDir = dir->mkdir("profHists");
340  int idx = 0;
342  {
343  profDir->cd();
344  it->Write(TString::Format("hist%d", idx++));
345  }
346 
347  dir->Write();
348  delete dir;
349 
350  tmp->cd();
351  }
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: