9 #include "TGraphErrors.h" 26 #include "CAFAna/Core/Var.h" 62 return Form(
"/nova/ana/users/%s/mec_tuning_2020",
getenv(
"USER" ) );
79 std::vector<std::unique_ptr<const ana::CompNormSyst>>
systs=
ana::systsQ3Q0(24, 0.0, 1.2, 24, 0.0, 1.2,
83 std::vector<const ana::ISyst*> systs_ptrs;
85 for (
const auto &
s : systs ){
86 systs_ptrs.push_back(
s.get() );
101 TFile *
inFile =
new TFile( file_name.c_str(),
"READ" );
122 std::vector<const ana::ISyst*> systs_ptrs2 = systs_ptrs;
124 std::vector<int> bins_vec = {30,10,10,10,10,10,10,10,10,10,10,10,10};
129 TCanvas *
c1 =
new TCanvas(
"c1",
"c1",w,h);
130 c1->SetWindowSize( w+(w-c1->GetWw()), h+(h-c1->GetWh()) );
132 double pot = spec_fit_data.POT();
133 auto h_data = spec_fit_data.ToTH2( pot );
134 auto h_mc_raw = spec_fit_mc_raw.
ToTH2( pot );
135 auto h_non_mec_raw = spec_fit_non_mec_raw.
ToTH2( pot );
137 TVirtualPad *c1_1 = c1->cd(1);
138 c1_1->SetRightMargin(0.15);
139 c1_1->SetLeftMargin(0.15);
140 c1_1->SetBottomMargin(0.15);
146 TVirtualPad *c1_2 = c1->cd(2);
147 c1_2->SetRightMargin(0.15);
148 c1_2->SetLeftMargin(0.15);
149 c1_2->SetBottomMargin(0.15);
150 h_mc_raw->SetTitle(
"Nominal MC");
151 h_mc_raw->Draw(
"colz");
154 c1->Print(
"graphs_onefloat.pdf(");
156 TH2 * ratio_nom = (TH2*)h_mc_raw->Clone(
"ratio_nom");
157 ratio_nom->Divide(
h_data);
161 int param_limit = 13;
162 std::vector<double> shift_x, chisq_y;
166 TCanvas *
c2 =
new TCanvas(
"c2",
"c2",w,h);
167 c2->SetRightMargin(0.15);
168 c2->SetLeftMargin(0.15);
169 c2->SetBottomMargin(0.15);
171 c2->SetWindowSize( (w+(w-c1->GetWw()))-100, (h+(h-c1->GetWh()))-100 );
173 std::vector<const ana::ISyst*> systs_ptrs_temp = systs_ptrs;
174 systs_ptrs_temp.erase(systs_ptrs_temp.begin()+
param+1, systs_ptrs_temp.end());
175 systs_ptrs_temp.erase(systs_ptrs_temp.begin(), systs_ptrs_temp.begin()+
param);
179 for (
int j=0;
j<systs_ptrs_temp.size();
j++)
189 auto h_mc_zerotuned = spec_fit_mc_zerotuned.
ToTH2( pot );
192 for (
int i = -bins_vec[0];
i<bins_vec[0];
i++){
194 shifts_temp.
SetShift(systs_ptrs[param],
i);
197 chisq_y.push_back(chitemp);
198 shift_x.push_back(
i);
202 for (
auto & syst : systs_ptrs_temp )
209 auto h_mc_tuned = spec_fit_mc_tuned.
ToTH2( pot );
211 TVirtualPad *c2_1 = c2->cd(1);
212 c2_1->SetRightMargin(0.15);
213 c2_1->SetLeftMargin(0.15);
214 c2_1->SetBottomMargin(0.15);
217 h_mc_tuned->SetTitle(Form(
"Tuned Distribution Shift %s %i",systs_ptrs_temp[param]->ShortName().c_str(),
i));
218 gStyle->SetTitleFontSize(0.05);
219 h_mc_tuned->Draw(
"colz");
223 TH2 *
ratio = (TH2*)h_mc_tuned->Clone(
"ratio");
224 ratio->Divide(h_mc_zerotuned);
228 TVirtualPad *c2_2 = c2->cd(2);
229 c2_2->SetRightMargin(0.15);
230 c2_2->SetLeftMargin(0.15);
231 c2_2->SetBottomMargin(0.15);
232 ratio->SetTitle(Form(
"Ratio Tuned to Nominal Shift %i",
i));
236 c2->Print(
"graphs_onefloat.pdf(");
246 shifts_temp.
SetShift(systs_ptrs_temp[param], 0);
252 TCanvas *
c3 =
new TCanvas(
"c3",
"c3",w/2,h);
253 c3->SetRightMargin(0.15);
254 c3->SetLeftMargin(0.15);
255 c3->SetBottomMargin(0.15);
256 double *
x = &shift_x[0];
257 double *
y = &chisq_y[0];
258 TGraph* chi2temp =
new TGraph(shift_x.size(),
x,
y);
259 gStyle->SetTitleFontSize(0.08);
260 chi2temp->SetTitle(systs_ptrs_temp[param]->ShortName().c_str());
261 chi2temp->Draw(
"AC*");
262 c3->Print(
"graphs_onefloat.pdf(");
270 c1->Print(
"graphs_onefloat.pdf)");
Implements systematic errors by interpolation between shifted templates.
TH2 * ToTH2(double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Spectrum must be 2D to obtain TH2.
Simple record of shifts applied to systematic parameters.
Spectrum PredictSyst(osc::IOscCalc *calc, const SystShifts &shift) const override
double CalcMECDoubleGaussEnhShiftedParam(std::string shift_param, double shift_sigma, const GaussParams initialParams)
def ratio(spec1, spec2, nbins, pot, binrange=(0, 1))
Representation of a spectrum in any variable, with associated POT.
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
void mec_nux_tester_2020(const std::string beam="fhc", const std::string fit="bins", double chisq=1)
std::string getenv(std::string const &name)
Optimized version of OscCalcPMNS.
T GetShift(const ISyst *syst) const
std::vector< const ISyst * > systs_params_double_gauss_extra(const GaussParams init, std::string suffix)
std::string GetMECTuningDirectory()
std::vector< std::unique_ptr< const CompNormSyst > > systsQ3Q0(int nbinsQ3=20, float fitMinQ3=0.0, float fitMaxQ3=1.0, int nbinsQ0=16, float fitMinQ0=0.0, float fitMaxQ0=0.8, Cut cut=GetCutIsFitMEC(false))
Represent the ratio between two spectra.
const Cut GetCutIsFitMEC(const bool isRHC)
void SetShift(const ISyst *syst, double shift, bool force=false)
float h_data[xbins][ybins]
Perform MINUIT fits in one or two dimensions.