21 const double q2_error = 0.05;
23 void fill_delnu_plot_genie(
const gst& gtree,
const double q2, TH1D* delnu_histo) {
24 const double nucleon_mass = 0.939;
25 if (fabs(q2 - gtree.
Q2) < q2_error) {
26 const double nu = gtree.
Ev - gtree.
El;
27 const double delnu = nu - gtree.
Q2 / (2 * nucleon_mass);
28 delnu_histo->Fill(delnu);
32 const char* get_nucleus_name(
const int nucZ) {
54 TH1D* get_delnu_plot_genie(
const int nucZ,
const int nucA,
const double q2) {
55 char histo_title[500];
56 sprintf(histo_title,
"^{%d}%s, Q^{2} = (%0.1f #pm %0.2f) GeV",
57 nucA, get_nucleus_name(nucZ), q2, q2_error);
58 TH1D* delnu =
new TH1D(
"genie", histo_title, 100, -1.0, 2.0);
59 delnu->GetXaxis()->SetTitle(
"#nu - Q^{2} / (2 * M_{p}) (GeV)");
60 delnu->GetYaxis()->SetTitle(
"(1 / #sigma) d#sigma / d#nu (GeV^{-1})");
61 delnu->SetLineColor(kRed);
66 sprintf(data_file,
"./data/EFF/nu_14/%d_%d/gntp.%d.gst.root", nucZ, nucA,
run);
68 const int num_events_per_file = 50000;
69 for (
int event = 0;
event < num_events_per_file;
event++) {
71 fill_delnu_plot_genie(gtree, q2, delnu);
74 delnu->Scale(1.0 / delnu->Integral(
"width"));
78 bool fill_superscaling_vectors(
const int nucZ,
const int nucA,
const double q2,
79 vector<float>* delnu_vals, vector<float>* relative_xs) {
80 char superscaling_data_file[500];
81 sprintf(superscaling_data_file,
"superscaling/%d_%d_%0.1f.txt", nucZ, nucA, q2);
82 ifstream
infile(superscaling_data_file);
87 while (getline(
infile, line)) {
88 float delnu, xs, garbage;
89 if (!(istringstream(line) >> delnu >> garbage >> xs)) {
90 cerr <<
"Couldn't process line: " << line <<
endl;
93 delnu_vals->push_back(delnu);
94 relative_xs->push_back(xs);
99 TH1D* get_delnu_plot_superscaling(
const int nucZ,
const int nucA,
const double q2) {
100 vector<float> delnu_vals;
101 vector<float> relative_xs;
102 if(!fill_superscaling_vectors(nucZ, nucA, q2, &delnu_vals, &relative_xs)) {
103 return new TH1D(
"",
"", 100, -1, 1);
105 TH1D* delnu =
new TH1D(
"SuSc",
"SuSc", delnu_vals.size() - 1, &delnu_vals[0]);
106 for (
int i = 0; i < (
int)delnu_vals.size(); i++) {
107 delnu->Fill(delnu_vals[i], relative_xs[i]);
109 delnu->SetLineColor(kBlack);
110 delnu->Scale(1.0 / delnu->Integral(
"width"));
114 void validation_plot_delnu(
const int nucZ,
const int nucA,
const double q2) {
116 TH1D* genie_delnu = get_delnu_plot_genie(nucZ, nucA, q2);
117 TH1D* susc_delnu = get_delnu_plot_superscaling(nucZ, nucA, q2);
119 susc_delnu->Draw(
"SAME");
121 sprintf(outfile,
"./plots/delnu_%d_%d_%0.1f.pdf", nucZ, nucA, q2);
122 for (
int i = 1; i < (
int)strlen(outfile) - 4; i++) {
123 outfile[i] = outfile[i] ==
'.' ?
'p' : outfile[i];
125 canvas.Print(outfile);
130 void validation_plot_energy_xs_nu_nubar(
bool is_bar) {
132 TFile def_file(
"./splines/DEF_QE_splines.root",
"READ");
133 TFile eff_file(
"./splines/TE_QE_splines.root",
"READ");
135 sprintf(hist_name,
"nu_mu_%sC12/qel_cc_%s",
136 (is_bar ?
"bar_" :
""), (is_bar ?
"p" :
"n"));
137 TGraph* def_energy_xs = (TGraph*)def_file.Get(hist_name);
138 def_energy_xs->SetLineColor(kOrange);
139 TGraph* eff_energy_xs = (TGraph*)eff_file.Get(hist_name);
140 eff_energy_xs->SetLineColor(kRed);
141 def_energy_xs->Apply(&TF2(
"name,",
"y / 6.0"));
142 eff_energy_xs->Apply(&TF2(
"name",
"y / 6.0"));
144 sprintf(title,
"%sNeutrino Cross Section - %s + %s #rightarrow %s + #mu^%s",
145 (is_bar ?
"Anti-" :
""), (is_bar ?
"#bar{#nu}" :
"#nu"),
146 (is_bar ?
"p" :
"n"), (is_bar ?
"n" :
"p"), (is_bar ?
"{+}" :
"{-}"));
147 TH1F* frame = canvas.DrawFrame(1
e-1, 0, 1e2, (is_bar ? 1.2 : 1.6));
148 frame->SetTitle(title);
149 frame->GetYaxis()->SetTitle(
"#sigma (10^{-38} cm^{2})");
150 frame->GetXaxis()->SetTitle(
"E_{#nu} (GeV)");
152 eff_energy_xs->Draw(
"SAME");
153 def_energy_xs->Draw(
"SAME");
156 sprintf(file_name,
"./plots/nu_%sxs_energy.pdf", (is_bar ?
"bar_" :
""));
157 canvas.Print(file_name);
160 void validation_plot_energy_xs() {
161 validation_plot_energy_xs_nu_nubar(
true);
162 validation_plot_energy_xs_nu_nubar(
false);
165 void validation_plot_energy_ratio_nu_nubar(
bool is_bar) {
167 TFile def_file(
"./splines/DEF_QE_splines.root",
"READ");
168 TFile eff_file(
"./splines/TE_QE_splines.root",
"READ");
170 sprintf(hist_name,
"nu_mu_%sC12/qel_cc_%s",
171 (is_bar ?
"bar_" :
""), (is_bar ?
"p" :
"n"));
172 TGraph* def_energy_xs = (TGraph*)def_file.Get(hist_name);
173 TGraph* eff_energy_xs = (TGraph*)eff_file.Get(hist_name);
175 ratio.Set(def_energy_xs->GetN());
176 for (
int i = 0; i < def_energy_xs->GetN(); i++) {
177 double x_val, def_point, eff_point;
178 def_energy_xs->GetPoint(i, x_val, def_point);
179 eff_energy_xs->GetPoint(i, x_val, eff_point);
181 ratio.SetPoint(i, x_val, eff_point / def_point);
183 ratio.SetPoint(i, x_val, 0);
186 ratio.SetLineColor(kRed);
189 sprintf(title,
"%s + %s #rightarrow %s + #mu^%s, (Trans Enh in G^{#nu}_{M}, M_{A} = 1.014) / (M_{A} = 1.014)",
190 (is_bar ?
"#bar{#nu}" :
"#nu"), (is_bar ?
"p" :
"n"), (is_bar ?
"n" :
"p"), (is_bar ?
"{+}" :
"{-}"));
191 TH1F* frame = canvas.DrawFrame(0, (is_bar ? 0.85 : 0.9), 10, (is_bar ? 1.4 : 1.5));
192 frame->SetTitle(title);
193 frame->GetYaxis()->SetTitle(
"ratio #sigma");
194 frame->GetXaxis()->SetTitle(
"E^{#nu} (GeV)");
198 sprintf(file_name,
"./plots/nu_%sratio_energy.pdf", (is_bar ?
"bar_" :
""));
199 canvas.Print(file_name);
202 void validation_plot_energy_ratio() {
203 validation_plot_energy_ratio_nu_nubar(
true);
204 validation_plot_energy_ratio_nu_nubar(
false);
207 double get_qe_increase_factor(
double is_bar,
double energy = 3.0) {
208 TFile def_file(
"./splines/DEF_QE_splines.root",
"READ");
209 TFile eff_file(
"./splines/TE_QE_splines.root",
"READ");
211 sprintf(hist_name,
"nu_mu_%sC12/qel_cc_%s",
212 (is_bar ?
"bar_" :
""), (is_bar ?
"p" :
"n"));
213 TGraph* def_energy_xs = (TGraph*)def_file.Get(hist_name);
214 TGraph* eff_energy_xs = (TGraph*)eff_file.Get(hist_name);
215 for (
int i = 0; i < def_energy_xs->GetN(); i++) {
216 double point_energy, def_xs, eff_xs;
217 def_energy_xs->GetPoint(i, point_energy, def_xs);
218 if (point_energy >
energy) {
219 eff_energy_xs->GetPoint(i, point_energy, eff_xs);
220 return eff_xs / def_xs;
226 void populate_q2_plot(
bool is_bar,
const char*
tag, TH1D* q2) {
227 const int start_run = 500000;
228 const int end_run = 500010;
231 sprintf(data_file,
"./data/%s/nu_%d/6_12/gntp.%d.gst.root", tag,
232 (is_bar ? -14 : 14),
run);
233 gst gtree(data_file);
234 const int num_events_per_file = 50000;
235 for (
int event = 0;
event < num_events_per_file;
event++) {
243 void validation_plot_q2_ratio_nu_nubar(
bool is_bar) {
245 const double increase_factor = get_qe_increase_factor(is_bar);
247 sprintf(title,
"E_{#nu} = 3 GeV, %s + %s #rightarrow %s + #mu^%s, (Trans Enh in G^{#nu}_{M}, M_{A} = 1.014) / (M_{A} = 1.014)",
248 (is_bar ?
"#bar{#nu}" :
"#nu"), (is_bar ?
"p" :
"n"), (is_bar ?
"n" :
"p"), (is_bar ?
"{+}" :
"{-}"));
249 TH1D te_q2(
"", title, 50, 0, 2.5);
250 te_q2.GetYaxis()->SetTitle(
"ratio d#sigma / dQ^{2}");
251 te_q2.GetXaxis()->SetTitle(
"Q^{2} (GeV / c)^{2}");
252 TH1D def_q2(
"",
"",50, 0, 2.5);
253 populate_q2_plot(is_bar,
"TE", &te_q2);
254 populate_q2_plot(is_bar,
"DEF", &def_q2);
255 te_q2.Scale(increase_factor);
256 te_q2.Divide(&def_q2);
257 te_q2.SetLineColor(kRed);
260 sprintf(filename,
"./plots/nu%s_ratio_q2.pdf", (is_bar ?
"_bar" :
""));
261 canvas.Print(filename);
265 void validation_plot_q2_ratio() {
266 validation_plot_q2_ratio_nu_nubar(
true);
267 validation_plot_q2_ratio_nu_nubar(
false);
273 const int nucZs[] = {1, 2, 6, 10, 13, 18, 26, 82 };
274 const int nucAs[] = {2, 4, 12, 20, 27, 40, 56, 208};
275 const int num_nucs = 8;
277 const double q2s[] = {0.1, 0.3, 0.5, 0.7, 1.0, 1.2, 1.5, 2.0};
278 const int num_q2s = 8;
279 validation_plot_energy_xs();
280 validation_plot_energy_ratio();
281 validation_plot_q2_ratio();
283 for (
int i = 0; i < num_nucs; i++) {
284 for (
int j = 0; j < num_q2s; j++) {
285 validation_plot_delnu(nucZs[i], nucAs[i], q2s[j]);
void line(double t, double *p, double &x, double &y, double &z)
virtual Int_t GetEntry(Long64_t entry)
QTextStream & endl(QTextStream &s)
Event finding and building.