7 #include "CAFAna/Core/Binning.h" 9 #include "CAFAna/Core/Var.h" 20 #include "TLegendEntry.h" 35 TString
inDir =
"/nova/ana/users/essmith/ND_DataMC2020/";
45 void Legend(TH1* h_to_clone);
51 std::vector<HistDef>
defs;
60 unsigned int nVars = defs.size();
61 std::vector<std::string> varNames;
62 for(
unsigned int var = 0;
var<nVars; ++
var){
63 varNames.emplace_back(defs[
var].
name);
66 std::vector<std::string>
selNames = {
"Presel",
"CVNeLow",
"CVNeHigh"};
67 unsigned int nSels = selNames.size();
68 std::vector<std::string> compNames = {
"nue",
"numu",
"nc",
"antinue",
"antinumu"};
69 unsigned int nComps = compNames.size();
71 std::unique_ptr<Spectrum> specData;
72 double datapot[
nHC][nVars][nSels];
73 TH1* hData[
nHC][nVars][nSels];
74 TH1* hMC[
nHC][nVars][nSels][nComps];
75 TH1* hDecomp[
nHC][nVars][nSels][nComps];
77 unique_ptr<Spectrum> tempspec;
79 for(
unsigned int HC = 0; HC<
nHC; ++HC){
81 TString nueDataName =
inDir+
hcNames[HC]+
"_nue_data.root";
82 TString nueMCName =
inDir+hcNames[HC]+
"_nue_mc.root";
83 TString nueMCDecompName =
inDir+hcNames[HC]+
"_nue_mc_decomp.root";
85 TFile* nueDataFile = TFile::Open(nueDataName);
86 TFile* nueMCFile = TFile::Open(nueMCName);
87 TFile* nueMCDecompFile = TFile::Open(nueMCDecompName);
89 for(
unsigned int var = 0;
var<nVars; ++
var){
90 for(
unsigned int sel = 0; sel<nSels; ++sel){
91 TString
name = varNames[
var]+
"_"+selNames[sel];
92 if(!name.Contains(
"CVN2d_CVNeLow"))
continue;
95 datapot[
nHC][nVars][nSels] = specData->POT();
96 hData[HC][
var][sel] = specData->ToTH1(datapot[nHC][nVars][nSels]);
97 for(
unsigned int comp = 0; comp<nComps; ++comp){
99 hMC[HC][
var][sel][comp] = tempspec->ToTH1(datapot[nHC][nVars][nSels]);
102 hDecomp[HC][
var][sel][comp] = tempspec->ToTH1(datapot[nHC][nVars][nSels]);
108 for(
unsigned int var = 0;
var<nVars; ++
var){
109 for(
unsigned int sel = 0; sel<nSels; ++sel){
110 TString
name = varNames[
var]+
"_"+selNames[sel];
111 if(!name.Contains(
"CVN2d_CVNeLow"))
continue;
112 TString forfile =
"_"+
sNumu_Nue+
"_"+hcNames[HC];
114 TH1* totalMC = (TH1*)hMC[HC][
var][sel][0]->
Clone(
"totalMC");
115 TH1* totalDecomp = (TH1*)hDecomp[HC][
var][sel][0]->
Clone(
"totalDecomp");
117 for(
unsigned int comp = 1; comp<nComps; ++comp){
118 totalMC->Add(hMC[HC][
var][sel][comp]);
119 totalDecomp->Add(hDecomp[HC][
var][sel][comp]);
130 TCanvas*
c =
new TCanvas(name+forfile, name+forfile);
132 TPad*
p1 =
new TPad(
"p1",
"", 0,0,1,1);
133 TPad*
p2 =
new TPad(
"p2",
"",0,0,1,1);
134 p1->SetBottomMargin(ysplit);
135 p2->SetTopMargin(1-ysplit);
142 std::vector <int>
colors = {kMagenta,
148 std::vector<std::string>
labels = {
"#nu_{e} CC",
152 "#bar{#nu}_{#mu} CC"};
154 totalDecomp->GetYaxis()->SetTitle(
POTstr(datapot[nHC][nVars][nSels]));
155 totalDecomp->GetYaxis()->CenterTitle();
157 SetAxis(totalDecomp,
true, colors[nComps]);
158 double maxY = totalDecomp->GetMaximum();
159 totalDecomp->GetYaxis()->SetRangeUser(0, 1.30*maxY);
160 totalDecomp->Draw(
"hist");
167 SetAxis(totalMC,
false, colors[nComps], 7);
168 totalMC->Draw(
"hist same");
169 for(
unsigned int comp = 0; comp<nComps; comp++){
170 SetAxis(hDecomp[HC][
var][sel][comp],
false, colors[comp]);
171 hDecomp[HC][
var][sel][comp]->Draw(
"hist same");
172 SetAxis(hMC[HC][
var][sel][comp],
false, colors[comp], 7);
173 hMC[HC][
var][sel][comp]->Draw(
"hist same");
175 hData[HC][
var][sel]->SetMarkerStyle(kFullCircle);
177 hData[HC][
var][sel]->Draw(
"ep same");
181 totalDecomp->GetXaxis()->SetLabelSize(0.);
182 totalDecomp->GetXaxis()->SetTitleSize(0.);
183 totalDecomp->GetYaxis()->SetTitleSize(0.75*totalDecomp->GetYaxis()->GetTitleSize());
184 totalDecomp->GetYaxis()->SetRangeUser(0.001,totalDecomp->GetMaximum());
193 SetAxis(rDecomp,
true, 1, 1,
false);
196 SetAxis(rMC,
false, 17, 1,
false);
197 rMC->Draw(
"ep same");
202 rDecomp->GetYaxis()->SetTitleSize(0.75*rDecomp->GetYaxis()->GetTitleSize());
203 rDecomp->GetXaxis()->SetLabelSize(0.75*rDecomp->GetYaxis()->GetTitleSize());
204 rMC->GetYaxis()->SetRangeUser(.5,1.5);
205 rDecomp->GetYaxis()->SetRangeUser(.5,1.5);
212 gPad->Print(
outDir+name+forfile+
".pdf");
215 nueDataFile->Close();
217 nueMCDecompFile->Close();
225 if(scale) h->Scale(.001);
226 h->SetLineStyle(style);
227 h->SetLineColor(color);
229 h->SetTickLength(0.);
236 return TString(
TString::Format(
"10^{3} Events / %.3g#times10^{20} POT", pot/1e20));
241 return 3*(
int(
log10(h->GetMaximum())))/3;
245 TH1*
ret = (TH1*)num->Clone();
248 ret->SetMarkerStyle(kFullCircle);
249 ret->SetMarkerColor(color);
250 ret->SetLineColor(color);
251 ret->GetYaxis()->SetRangeUser(.5, 1.5);
252 ret->GetYaxis()->SetTitle(
"Data / MC");
253 ret->GetXaxis()->SetNdivisions(1900, kFALSE);
259 TGraph*
g =
new TGraph();
260 g->SetPoint(0, -1e10,0.003);
261 g->SetPoint(1, 1e10, 0.003);
269 TGraph*
g =
new TGraph();
270 g->SetPoint(0, -1e10,1);
271 g->SetPoint(1, 1e10, 1);
278 std::vector <std::pair<int, TString>> entries = {{kBlack,
"ND data"},
281 {
kGreen+2,
"#nu_{#mu} CC"},
282 {kMagenta,
"#nu_{e} CC"},
283 {
kGreen-3,
"#bar{#nu}_{#mu} CC"},
284 {kMagenta-2,
"#bar{#nu}_{e} CC"},
285 {kBlack,
"Uncorr. MC"},
290 TLegend*
leg =
new TLegend(.82, .5, .99, .92);
292 leg->SetFillColor(kWhite);
293 leg->SetBorderSize(1);
296 TH1*
h = (TH1F*)h_to_clone->Clone();
297 leg->SetTextSize(0.5*h->GetXaxis()->GetTitleSize());
300 h->SetMarkerStyle(kFullCircle);
302 leg->AddEntry(h, entries[0].
second,
"lep");
303 for(
int i = 1;
i < (
int) entries.size()-2;
i++){
304 h->SetLineColor(entries[
i].first);
305 if(
i == 7) h->SetLineStyle(7);
306 else h->SetLineStyle(1);
308 h->SetMarkerColor(entries[
i].first);
309 h->SetMarkerStyle(kFullCircle);
310 leg->AddEntry(h->Clone(), entries[
i].second,
"lep");
314 h->SetMarkerColor(entries[
i].first);
315 h->SetMarkerStyle(kFullCircle);
316 leg->AddEntry(h->Clone(), entries[
i].second,
"lep");
319 leg->AddEntry(h->Clone(), entries[
i].second,
"l");
321 leg->SetTextSize(1.3*leg->GetTextSize());
327 TLegend*
leg =
new TLegend(.12, .13, .47, .18);
330 leg->SetBorderSize(1);
331 TH1*
h =
new TH1F(
"",
"", 1, 0, 1);
332 h->SetMarkerColor(17);
334 h->SetMarkerStyle(kFullCircle);
335 leg->AddEntry(h->Clone(),
"Uncorr. MC",
"lep");
336 h->SetMarkerColor(1);
338 leg->AddEntry(h->Clone(),
"Decomp MC",
"lep");
343 TString txt = mode ==
"fhc"?
"Neutrino Mode" :
"Antineutrino Mode";
344 TLatex* lb =
new TLatex(.1, .95, txt);
346 lb->SetTextAlign(13);
347 lb->SetTextColor(kGray+3);
348 lb->SetTextSize(2/45.);
void Nue2018ThreeBinAxis(THStack *axes, bool drawLabels, bool merged, bool coreOnly)
void Legend(TH1 *h_to_clone)
TH1 * MakeRatio(TH1 *num, TH1 *denom, int color=1)
Cuts and Vars for the 2020 FD DiF Study.
void AddHistDefNueShower(std::vector< HistDef > &hd)
void SetAxis(TH1 *h, bool visible, int color, int style=1, bool scale=true)
void plot_ND_DataMC_energybinning()
void AddHistDefSlice(std::vector< HistDef > &hd)
void AddHistDefNueSelectionExtras(std::vector< HistDef > &hd)
double DerivePowScale(TH1 *h)
void Nue2018ThreeBinDivisions(bool coreOnly, const int color, const int style)
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
void NeutrinoMode(TString mode)
void AddHistDefRecoND(std::vector< HistDef > &hd)
const HistDef defs[kNumVars]
void AddHistDefProngCVN(std::vector< HistDef > &hd)
void AddHistDefNuePID(std::vector< HistDef > &hd)
void AddHistDefNueND(std::vector< HistDef > &hd)
void Nue2018ThreeBinLabels(const double yNDC, const double textsize, const int color, const bool nd)
TString POTstr(double pot)
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
const std::string selNames[kNumSels]
void AddHistDefNueEnergy(std::vector< HistDef > &hd)
std::vector< TString > hcNames