21 #include "TLegendEntry.h" 24 #include "TPaveLabel.h" 39 void Legend(TH1* h_to_clone);
46 std::string fdir =
"/nova/ana/nu_e_ana/Ana2018/DataMC/";
48 TFile*
fdata =
new TFile((fdir+
"20180331_Ana2018_"+
mode+
"_datamc_decomp_data_validation.root").c_str(),
"READ");
49 TFile *
fmc =
new TFile((fdir+
"20180331_Ana2018_"+
mode+
"_datamc_decomp_mc_validation.root").c_str(),
"READ");
50 TFile*
fdecomp =
new TFile((fdir +
"20180331_Ana2018_"+
mode+
"_datamc_decomp_mc_decomp_validation.root").c_str(),
"READ");
52 if(fmc->IsZombie()) {
std::cout <<
"MC File not found ";
return; }
53 if(fdata->IsZombie()) {
std::cout <<
"Data File not found ";
return; }
54 if(fdecomp->IsZombie()) {
std::cout <<
"MC Decomp File not found";
return; }
57 auto spec =
Spectrum::LoadFrom(fdata, (TString)
"Energy_Ana2018_Bin{group=Cut,cat=1_CVNeLow}");
58 double datapot = spec->POT();
59 TH1* hdata = spec->ToTH1(datapot);
61 std::vector <TH1*>
mc;
63 std::vector <std::string>
comps = {
"0_nue",
"1_numu",
"2_nc",
"3_antinue",
"4_antinumu"};
66 unique_ptr<Spectrum> tempspec;
70 tempmc = tempspec->ToTH1(datapot);
72 std::cout <<
"Loaded MC Spectrum Energy_Ana2018_Bin{group=Cut,cat=1_CVNeLow}{group=Component,cat="+comp+
"}" <<
endl;;
75 tempdecomp = tempspec->ToTH1(datapot);
77 std::cout <<
"Loaded Decomp Spectrum Energy_Ana2018_Bin{group=Cut,cat=1_CVNeLow}{group=Component,cat="+comp+
"}" <<
endl;
80 decomp.push_back(tempdecomp);
84 TH1* totalmc = (TH1*)mc[0]->
Clone(
"totalmc");
85 TH1* totaldecomp = (TH1*)decomp[0]->
Clone(
"totaldecomp");
86 for(
int i = 1;
i < (
int)mc.size();
i++) {
87 totalmc->Add( mc[
i] );
88 totaldecomp->Add( decomp[i] );
91 mc.push_back(totalmc);
92 decomp.push_back(totaldecomp);
95 int tot = mc.size()-1;
105 TCanvas*
c =
new TCanvas(
"c");
107 TPad*
p1 =
new TPad(
"p1",
"", 0,0,1,1);
108 TPad*
p2 =
new TPad(
"p2",
"",0,0,1,1);
109 p1->SetBottomMargin(ysplit);
110 p2->SetTopMargin(1-ysplit);
117 std::vector <int>
colors = {kMagenta,
123 std::vector<std::string>
labels = {
"#nu_{e} CC",
127 "#bar{#nu}_{#mu} CC"};
131 decomp[
tot]->GetYaxis()->SetTitle(
POTstr(datapot));
132 decomp[
tot]->GetYaxis()->CenterTitle();
134 SetAxis(decomp[tot],
true, colors[tot]);
135 double maxY = decomp[
tot]->GetMaximum();
136 decomp[
tot]->GetYaxis()->SetRangeUser(0, 1.30*maxY);
137 decomp[
tot]->Draw(
"hist");
144 SetAxis(mc[tot],
false, colors[tot], 7);
145 mc[
tot]->Draw(
"hist same");
146 for(
int j = 0;
j < (
int)mc.size()-1 ;
j++) {
147 SetAxis(decomp[
j],
false, colors[j]);
148 decomp[
j]->Draw(
"hist same");
149 SetAxis(mc[j],
false, colors[j], 7);
150 mc[
j]->Draw(
"hist same");
153 hdata->SetMarkerStyle(kFullCircle);
155 hdata->Draw(
"ep same");
159 decomp[
tot]->GetXaxis()->SetLabelSize(0.);
160 decomp[
tot]->GetXaxis()->SetTitleSize(0.);
161 decomp[
tot]->GetYaxis()->SetTitleSize(0.75*decomp[tot]->
GetYaxis()->GetTitleSize());
162 decomp[
tot]->GetYaxis()->SetRangeUser(0.001,
172 SetAxis(rdecomp,
true, 1, 1,
false);
175 SetAxis(rmc,
false, 17, 1,
false);
176 rmc->Draw(
"ep same");
181 rdecomp->GetYaxis()->SetTitleSize(0.75*rdecomp->GetYaxis()->GetTitleSize());
182 rmc->GetYaxis()->SetRangeUser(.5,1.5);
183 rdecomp->GetYaxis()->SetRangeUser(.5,1.5);
191 gPad->Print(
"Energy_Ana2018_Bin_CVNeLow_split.pdf");
195 if(scale) h->Scale(.001);
196 h->SetLineStyle(style);
197 h->SetLineColor(color);
199 h->SetTickLength(0.);
206 return TString(
TString::Format(
"10^{3} Events / %.3g#times10^{20} POT", pot/1e20));
211 return 3*(
int(
log10(h->GetMaximum())))/3;
215 TH1*
ret = (TH1*)num->Clone();
218 ret->SetMarkerStyle(kFullCircle);
219 ret->SetMarkerColor(color);
220 ret->SetLineColor(color);
221 ret->GetYaxis()->SetRangeUser(.5, 1.5);
222 ret->GetYaxis()->SetTitle(
"Data / MC");
223 ret->GetXaxis()->SetNdivisions(1900, kFALSE);
229 TGraph*
g =
new TGraph();
230 g->SetPoint(0, -1e10,0.003);
231 g->SetPoint(1, 1e10, 0.003);
239 TGraph*
g =
new TGraph();
240 g->SetPoint(0, -1e10,1);
241 g->SetPoint(1, 1e10, 1);
248 std::vector <std::pair<int, TString>> entries = {{kBlack,
"ND data"},
251 {
kGreen+2,
"#nu_{#mu} CC"},
252 {kMagenta,
"#nu_{e} CC"},
253 {
kGreen-3,
"#bar{#nu}_{#mu} CC"},
254 {kMagenta-2,
"#bar{#nu}_{e} CC"},
255 {kBlack,
"Uncorr. MC"},
260 TLegend*
leg =
new TLegend(.78, .4, .95, .89);
262 leg->SetFillColor(kWhite);
263 leg->SetBorderSize(1);
266 TH1*
h = (TH1F*)h_to_clone->Clone();
267 leg->SetTextSize(0.55*h->GetXaxis()->GetTitleSize());
270 h->SetMarkerStyle(kFullCircle);
272 leg->AddEntry(h, entries[0].
second,
"lep");
273 for(
int i = 1;
i < (
int) entries.size()-2;
i++){
274 h->SetLineColor(entries[
i].first);
275 if(
i == 7) h->SetLineStyle(7);
276 else h->SetLineStyle(1);
278 h->SetMarkerColor(entries[
i].first);
279 h->SetMarkerStyle(kFullCircle);
280 leg->AddEntry(h->Clone(), entries[
i].second,
"lep");
284 h->SetMarkerColor(entries[
i].first);
285 h->SetMarkerStyle(kFullCircle);
286 leg->AddEntry(h->Clone(), entries[
i].second,
"lep");
289 leg->AddEntry(h->Clone(), entries[
i].second,
"l");
291 leg->SetTextSize(1.3*leg->GetTextSize());
297 TLegend*
leg =
new TLegend(.12, .13, .47, .18);
300 leg->SetBorderSize(1);
301 TH1*
h =
new TH1F(
"",
"", 1, 0, 1);
302 h->SetMarkerColor(17);
304 h->SetMarkerStyle(kFullCircle);
305 leg->AddEntry(h->Clone(),
"Uncorr. MC",
"lep");
306 h->SetMarkerColor(1);
308 leg->AddEntry(h->Clone(),
"Decomp MC",
"lep");
313 std::string txt = mode ==
"fhc"?
"Neutrino Mode" :
"Antineutrino Mode";
314 TLatex* lb =
new TLatex(.1, .95, txt.c_str());
316 lb->SetTextAlign(13);
317 lb->SetTextColor(kGray+3);
318 lb->SetTextSize(2/45.);
void Nue2018ThreeBinAxis(THStack *axes, bool drawLabels, bool merged, bool coreOnly)
Cuts and Vars for the 2020 FD DiF Study.
void Legend(TH1 *h_to_clone)
correl_xv GetYaxis() -> SetDecimals()
void Nue2018ThreeBinDivisions(bool coreOnly, const int color, const int style)
void NeutrinoMode(std::string mode)
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
void plot_nd_spectra_2018(std::string mode="fhc")
void SetAxis(TH1 *h, bool visible, int color, int style=1, bool scale=true)
std::vector< std::string > comps
TString POTstr(double pot)
TH1 * MakeRatio(TH1 *num, TH1 *denom, int color=1)
void Nue2018ThreeBinLabels(const double yNDC, const double textsize, const int color, const bool nd)
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
double DerivePowScale(TH1 *h)
std::string to_string(ModuleType const mt)