10 #include "Utilities/func/MathUtil.h" 25 if(pot == 0) pot = obs.
POT();
27 std::unique_ptr<TH1> oh(obs.
ToTH1(pot));
28 std::unique_ptr<TH1> bh(unosc.
ToTH1(pot));
29 assert(oh->GetNbinsX() == bh->GetNbinsX());
34 for(
int i = 0;
i < oh->GetNbinsX(); ++
i){
35 const double o = oh->GetBinContent(
i);
36 const double b = bh->GetBinContent(
i);
50 int nbinsx,
double minx,
double maxx,
52 const std::vector<const IFitVar*>& profVars,
53 const std::vector<const ISyst*>& profSysts,
55 const std::vector<SystShifts>& systSeedPts,
56 std::map<const IFitVar*, TGraph*>& profVarsMap,
57 std::map<const ISyst*, TGraph*>& profSystsMap,
63 for(
auto it: profVarsMap)
delete it.second;
64 for(
auto it: profSystsMap)
delete it.second;
69 for(
const IFitVar* v: profVars) profVarsMap[
v] =
new TGraph;
70 for(
const ISyst*
s: profSysts) profSystsMap[
s] =
new TGraph;
72 TGraph*
ret =
new TGraph;
76 std::vector<double> seedValues;
77 for(
const IFitVar* v: profVars) seedValues.push_back(v->
GetValue(calc));
87 const double x = minx + (maxx-minx)*
double(
n)/
nbinsx;
91 for(
unsigned int i = 0;
i < seedValues.size(); ++
i)
92 profVars[
i]->SetValue( calc, seedValues[
i] );
97 ret->SetPoint(ret->GetN(),
x, chi);
104 profVarsMap[
var]->SetPoint(
n, x,
var->GetValue(calc));
106 for(
const ISyst*
s: profSysts){
107 profSystsMap[
s]->SetPoint(
n, x, systshift.
GetShift(
s));
112 if(input_minchi == -1){
113 std::vector<const IFitVar*> allVars = {v};
114 for(
unsigned int i = 0;
i < seedValues.size(); ++
i) {
116 allVars.push_back(profVars[i]);
121 minchi = fit.
Fit(calc)->EvalMetricVal();
124 ret->SetPoint(ret->GetN(), v->
GetValue(calc), minchi);
129 minchi = input_minchi;
133 for(
int i = 0;
i < ret->GetN(); ++
i){
135 ret->GetPoint(
i, x, y);
136 ret->SetPoint(
i, x, y-minchi);
145 int nbinsx,
double minx,
double maxx,
double minchi,
146 std::vector<const IFitVar*> profVars,
147 std::vector<const ISyst*> profSysts,
149 const std::vector<SystShifts>& systSeedPts,
150 std::map<const IFitVar*, TGraph*>& profVarsMap,
151 std::map<const ISyst*, TGraph*>& systsMap,
155 v, nbinsx, minx, maxx,
156 minchi, profVars, profSysts, seedPts, systSeedPts,
157 profVarsMap, systsMap, opts);
159 for(
int i = 0;
i < ret->GetN(); ++
i){
161 ret->GetPoint(
i, x, y);
162 ret->SetPoint(
i, x, y > 0 ?
sqrt(y) : 0);
171 int nbinsx,
double minx,
double maxx,
175 return Profile(expt, calc, v, nbinsx, minx, maxx, minchi,
182 int nbinsx,
double minx,
double maxx,
double minchi,
185 TGraph*
ret =
Slice(expt, calc, v, nbinsx, minx, maxx, minchi, opts);
187 for(
int i = 0;
i < ret->GetN(); ++
i){
189 ret->GetPoint(
i, x, y);
190 ret->SetPoint(
i, x, y > 0 ?
sqrt(y) : 0);
202 const std::vector<const IFitVar*>& profVars,
203 const std::vector<const ISyst*>& profSysts,
205 const std::vector<SystShifts>& systSeedPts,
209 TGraph*
g =
new TGraph;
212 std::vector<const IFitVar*>
vars = profVars;
213 vars.push_back(&fitVar);
216 const double x = xmin +
i*(xmax-
xmin)/nbinsx;
223 g->SetPoint(
i, y, x);
225 g->SetPoint(
i, x, y);
234 std::vector<double>
ret;
237 for(
int i = 0;
i+1 < g->GetN(); ++
i){
238 double x0,
x1, y0,
y1;
239 g->GetPoint(
i, x0, y0);
240 g->GetPoint(
i+1, x1, y1);
243 if((y0 < critVal) != (y1 < critVal)){
245 const double x = x0 + (x1-x0)*(critVal-y0)/(y1-y0);
Cuts and Vars for the 2020 FD DiF Study.
std::map< std::string, double > xmax
Float_t y1[n_points_granero]
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Simple record of shifts applied to systematic parameters.
Float_t x1[n_points_granero]
std::vector< double > FindCurveCrossings(TGraph *g, double critVal)
Intended for use on the output of Profile.
TGraph * Profile(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar *v, int nbinsx, double minx, double maxx, double input_minchi, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts, const SeedList &seedPts, const std::vector< SystShifts > &systSeedPts, std::map< const IFitVar *, TGraph * > &profVarsMap, std::map< const ISyst *, TGraph * > &profSystsMap, MinuitFitter::FitOpts opts)
scan in one variable, profiling over all others
static SystShifts Nominal()
T sqr(T x)
More efficient square function than pow(x,2)
Encapsulate code to systematically shift a caf::SRProxy.
static std::map< const ISyst *, TGraph * > empty_syst_map
Representation of a spectrum in any variable, with associated POT.
virtual std::unique_ptr< IFitSummary > Fit(osc::IOscCalcAdjustable *seed, SystShifts &bestSysts=junkShifts, const SeedList &seedPts=SeedList(), const std::vector< SystShifts > &systSeedPts={}, Verbosity verb=kVerbose) const
Master fitting method. Depends on FitHelper and FitHelperSeeded.
T GetShift(const ISyst *syst) const
static std::map< const IFitVar *, TGraph * > empty_vars_map
TGraph * Slice(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar *v, int nbinsx, double minx, double maxx, double minchi, MinuitFitter::FitOpts opts)
scan in one variable, holding all others constant
TGraph * SqrtSlice(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar *v, int nbinsx, double minx, double maxx, double minchi, MinuitFitter::FitOpts opts)
Forward to Slice but sqrt the result for a crude significance.
void SetProgress(double frac)
Update the progress fraction between zero and one.
virtual void SetValue(osc::IOscCalcAdjustable *osc, double val) const =0
double SimpleFOM(const Spectrum &obs, const Spectrum &unosc, double pot)
Figure-of-merit with no systematics, for binned data.
Base class defining interface for experiments.
assert(nhit_max >=nhit_nbins)
A simple ascii-art progress bar.
Interface definition for fittable variables.
static float_mat transpose(const float_mat &a)
returns the transposed matrix.
void Done()
Call this when action is completed.
TGraph * FindValley(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar &scanVar, const IFitVar &fitVar, int nbinsx, double xmin, double xmax, const std::vector< const IFitVar * > &profVars, const std::vector< const ISyst * > &profSysts, const SeedList &seedPts, const std::vector< SystShifts > &systSeedPts, bool transpose, MinuitFitter::FitOpts opts)
Find the minimum in one variable as a function of another.
TGraph * SqrtProfile(const IExperiment *expt, osc::IOscCalcAdjustable *calc, const IFitVar *v, int nbinsx, double minx, double maxx, double minchi, std::vector< const IFitVar * > profVars, std::vector< const ISyst * > profSysts, const SeedList &seedPts, const std::vector< SystShifts > &systSeedPts, std::map< const IFitVar *, TGraph * > &profVarsMap, std::map< const ISyst *, TGraph * > &systsMap, MinuitFitter::FitOpts opts)
Forward to Profile but sqrt the result for a crude significance.
virtual double GetValue(const osc::IOscCalcAdjustable *osc) const =0
Perform MINUIT fits in one or two dimensions.