tex_tables_util.h
Go to the documentation of this file.
1 #include "TStyle.h"
2 #include "TFile.h"
3 #include "TH1.h"
4 #include "TCanvas.h"
5 #include "TGraph.h"
6 #include "TGraphAsymmErrors.h"
7 #include "TGaxis.h"
8 #include "TLatex.h"
9 #include "TLegend.h"
10 #include "TLine.h"
11 #include "TSystem.h"
12 
13 #include <iostream>
14 #include <fstream>
15 #include <iomanip>
16 
17 namespace ana
18 {
19 
20  double CalcChi2(TH1* hmc, TH1* hdata)
21  {
22  double chi2 = 0;
23  for (int i = 1; i < hmc->GetNbinsX() + 1; ++i) {
24  double ei = hmc->GetBinContent(i);
25  double oi = hdata->GetBinContent(i);
26  double sigma = sqrt(ei);
27  if(ei>0) chi2 += util::sqr(ei - oi) / util::sqr(sigma);
28  }
29  return chi2;
30  }
31 
32 TString MakeLatexCommandName(TString mystring){
33  //There must be a better way
34  std::vector<TString> in = {"0","1","2","3","4","5",
35  "6","7","8","9","_","#"," ",".","-","(",")"};
36  std::vector<TString> out = {"zero","one","two","three","four","five",
37  "six","seven","eight","nine","","","","","XX","",""};
38  for(unsigned int i=0;i<in.size();i++)
39  mystring.ReplaceAll(in[i],out[i]);
40  return mystring;
41 
42 }
43 
44 TString FixPlotName(TString mystring){
45  //There must be a better way
46  std::vector<TString> in = {"#"," ",".","_"};
47  std::vector<TString> out = {"","","",""};
48  for(unsigned int i=0;i<in.size();i++)
49  mystring.ReplaceAll(in[i],out[i]);
50  return mystring;
51 
52 }
53 
54 
55 void PrintLatexFigure(TString name, TString plotdir="plots/"){
56  output << " \\includegraphics[width=0.49\\textwidth]{"<<plotdir<<name<<".png}\n";
57 }
58 
59 
60 
61 void PrintTableHeader(TString ltxcommand="",
62  TString labelcol_style= "l",
63  TString bincol_style = "| r r r",
64  int nbins = 1 )
65 {
66  if(ltxcommand == "") { std::cerr << "WARNING Problem with PrintTableHeader ltxcommand\n"; return;}
67 
68  output << "\n % " << std::string(60,'-');
69  output << "\n \\vspace{30 pt} \n";
70  output << "\\setlength{\\tabcolsep}{1pt} \\renewcommand{\\arraystretch}{1.2} \n";
71  output << "\\" << MakeLatexCommandName(ltxcommand) << "\n\n";
72 
73  tables << "\\newcommand{\\" << MakeLatexCommandName(ltxcommand) << "}\n";
74  tables << "{\\centerline{ \n \\begin{tabular}{ "
75  << labelcol_style << " ";
76  for (int n =0; n<nbins; ++n) tables << bincol_style << (n +1 < nbins ? " | " : "}\n");
77 }
78 
80  tables << "\\end{tabular} } \n } \n"; //end centerline end command
81 }
82 
83 struct SystResults{
84  TString syst;
85  //plus minus, sig bkg
86  double diff_sig[2][5];
87  double diff_bkg[2][5];
88  double diff_tot[2][5];
89  double chisq_sig[2];
90  double chisq_bkg[2];
91  double chisq_tot[2];
92 };
94  double aa = max (a.chisq_sig[0], a.chisq_sig[1]);
95  double bb = max (b.chisq_sig[0], b.chisq_sig[1]);
96  return aa > bb;
97 }
99  double aa = max (a.chisq_bkg[0], a.chisq_bkg[1]);
100  double bb = max (b.chisq_bkg[0], b.chisq_bkg[1]);
101  return aa > bb;
102 }
103 
104 // std::vector< std::pair<TString,TH1D*> > allQhist_xp_wtv;
105 std::vector <SystResults> systresults_xp_prop;
106 std::vector <SystResults> systresults_xp_combo;
107 std::vector <SystResults> systresults_nxp;
108 
109 TH1D* systsum_plu_xp_prop[6] = {0,0,0,0,0,0};
110 TH1D* systsum_plu_xp_combo[6] = {0,0,0,0,0,0};
111 TH1D* systsum_plu_nxp[6] = {0,0,0,0,0,0};
112 TH1D* systsum_min_xp_prop[6] = {0,0,0,0,0,0};
113 TH1D* systsum_min_xp_combo[6] = {0,0,0,0,0,0};
114 TH1D* systsum_min_nxp[6] = {0,0,0,0,0,0};
115 
116 /*
117 void AddToEnvelop(TString ltxcommand, TString systName,
118  const std::vector<TH1*> & mcnom, const std::vector<TH1*> & mcplu, const std::vector<TH1*> & mcmin){
119 
120  if ( ltxcommand.Contains("ND") ) return;
121  if ( !(ltxcommand.Contains("EnergyCVN2D")) ) return;
122  if ( ltxcommand.Contains("3bin") ) return;
123 
124  int Nbins = mcnom[0]->GetNbinsX();
125  double binW = mcnom[0]->GetBinWidth(1);
126 
127  std::vector<TString> labels = {"$\\nu_e$ signal","Tot beam bkg",
128  "Beam $\\nu_{e}$CC","NC", "$\\nu_{\\mu}$CC",
129  "$\\nu_{\\tau}$CC"};
130 
131  std::vector<TString> tags = {"nueSignal","TotBeamBkg",
132  "BeamnueCC","NC","numuCC","nutauCC"};
133 
134  // Initialize histos if first time
135  for ( int s = 0; s < 6; ++s ){
136  if ( systsum_plu_xp_prop[0] == 0 ){
137 
138  systsum_plu_xp_prop[s] = new TH1D( "Envelope_xpp_plu_"+tags[s], "Envelope_xpp_plu"+labels[s],
139  Nbins, 0, (Nbins*binW) );
140  systsum_plu_xp_combo[s] = new TH1D( "Envelope_xpc_plu_"+tags[s], "Envelope_xpc_plu"+labels[s],
141  Nbins, 0, (Nbins*binW) );
142  systsum_plu_nxp[s] = new TH1D( "Envelope_nxp_plu_"+tags[s], "Envelope_nxp_plu"+labels[s],
143  Nbins, 0, (Nbins*binW) );
144  systsum_min_xp_prop[s] = new TH1D( "Envelope_xpp_min_"+tags[s], "Envelope_xpp_min"+labels[s],
145  Nbins, 0, (Nbins*binW) );
146  systsum_min_xp_combo[s] = new TH1D( "Envelope_xpc_min_"+tags[s], "Envelope_xpc_min"+labels[s],
147  Nbins, 0, (Nbins*binW) );
148  systsum_min_nxp[s] = new TH1D( "Envelope_nxp_min_"+tags[s], "Envelope_nxp_min"+labels[s],
149  Nbins, 0, (Nbins*binW) );
150  }
151 
152  TH1D* absPlu = mcplu[s]->Clone();
153  TH1D* absMin = mcmin[s]->Clone();
154 
155  // Make each bin content in + larger than -
156  FormatErrorBand(absPlu, absMin, false, true);
157 
158  // Add % diff in quadrature for + and -
159  for ( int b = 1; b <= Nbins; ++b ){
160 
161  double binNom = mcnom[s]->GetBinContent(b);
162  double binPlu = absPlu ->GetBinContent(b);
163  double binMin = absMin ->GetBinContent(b);
164 
165  double shiftPlu = (binPlu - binNom) / binNom;
166  double shiftMin = (binMin - binNom) / binNom;
167 
168  // +_ shift bands on one side of the nominal are covered
169  // by the largest one. Truncate to +diff >= 0 -diff<= 0
170  shiftPlu = std::max( shiftPlu, 0 );
171  shiftMin = std::min( shiftMin, 0 );
172 
173  // sum bin in quadrature
174  if ( ltxcommand.Contains("nxp") ){
175 
176  shiftPlu = systsum_plu_nxp[s]->GetBinContent(b) + (shiftPlu*shiftPlu);
177  shiftMin = systsum_min_nxp[s]->GetBinContent(b) + (shiftMin*shiftMin);
178  systsum_plu_nxp[s]->SetBinContent(b, shiftPlu );
179  systsum_min_nxp[s]->SetBinContent(b, shiftMin );
180  }
181  if ( ltxcommand.Contains("xp_prop") ){
182 
183  shiftPlu = systsum_plu_nxp[s]->GetBinContent(b) + (shiftPlu*shiftPlu);
184  shiftMin = systsum_min_nxp[s]->GetBinContent(b) + (shiftMin*shiftMin);
185  systsum_plu_nxp[s]->SetBinContent(b, shiftPlu );
186  systsum_min_nxp[s]->SetBinContent(b, shiftMin );
187  }
188  if ( ltxcommand.Contains("xp_combo") ){
189 
190  shiftPlu = systsum_plu_nxp[s]->GetBinContent(b) + (shiftPlu*shiftPlu);
191  shiftMin = systsum_min_nxp[s]->GetBinContent(b) + (shiftMin*shiftMin);
192  systsum_plu_nxp[s]->SetBinContent(b, shiftPlu );
193  systsum_min_nxp[s]->SetBinContent(b, shiftMin );
194  }
195 
196  }// bins
197  }// components
198 
199 }
200 */
201 
202 //////////////////////////////////////////////////////////////////////
203  void SetVecValues_Diff( SystResults &MyVec, int Ind, double Sig0, double Sig1, double Bkg0, double Bkg1, double Tot0, double Tot1 ) {
204  MyVec.diff_sig[0][Ind] = Sig0;
205  MyVec.diff_sig[1][Ind] = Sig1;
206  MyVec.diff_bkg[0][Ind] = Bkg0;
207  MyVec.diff_bkg[1][Ind] = Bkg1;
208  MyVec.diff_tot[0][Ind] = Tot0;
209  MyVec.diff_tot[1][Ind] = Tot1;
210 
211  if (isNumuAna && Ind == 3) {
212  /*
213  std::cout << "\n\n\tLooking at a numu analysis in the 4th quantile...Now I can fill out the total bin!!\n\n" << std::endl;
214  std::cout << "\tFor sig0 I have; "
215  << MyVec.diff_sig[0][0] << " && " << MyVec.diff_sig[0][1] << " && "
216  << MyVec.diff_sig[0][2] << " && " << MyVec.diff_sig[0][3] << "\n"
217  << "\tFor Sig1 I have; "
218  << MyVec.diff_sig[1][0] << " && " << MyVec.diff_sig[1][1] << " && "
219  << MyVec.diff_sig[1][2] << " && " << MyVec.diff_sig[1][3] << "\n"
220  << std::endl;
221  */
222  MyVec.diff_sig[0][4] = (MyVec.diff_sig[0][0] + MyVec.diff_sig[0][1] + MyVec.diff_sig[0][2] + MyVec.diff_sig[0][3]) / 4;
223  MyVec.diff_sig[1][4] = (MyVec.diff_sig[1][0] + MyVec.diff_sig[1][1] + MyVec.diff_sig[1][2] + MyVec.diff_sig[1][3]) / 4;
224  MyVec.diff_bkg[0][4] = (MyVec.diff_bkg[0][0] + MyVec.diff_bkg[0][1] + MyVec.diff_bkg[0][2] + MyVec.diff_bkg[0][3]) / 4;
225  MyVec.diff_bkg[1][4] = (MyVec.diff_bkg[1][0] + MyVec.diff_bkg[1][1] + MyVec.diff_bkg[1][2] + MyVec.diff_bkg[1][3]) / 4;
226  MyVec.diff_tot[0][4] = (MyVec.diff_tot[0][0] + MyVec.diff_tot[0][1] + MyVec.diff_tot[0][2] + MyVec.diff_tot[0][3]) / 4;
227  MyVec.diff_tot[1][4] = (MyVec.diff_tot[1][0] + MyVec.diff_tot[1][1] + MyVec.diff_tot[1][2] + MyVec.diff_tot[1][3]) / 4;
228  //std::cout << "After that I have;\t sig0 " << MyVec.diff_sig[0][4] << " && sig1 " << MyVec.diff_sig[1][4] << std::endl;
229  }
230  }
231 
232  void SetVecValues_ChiSq( SystResults &MyVec, double Sig0, double Sig1, double Bkg0, double Bkg1, double Tot0, double Tot1 ) {
233  /*
234  std::cout << "\nFor ChiSq I had ;\n\t"
235  << MyVec.chisq_sig[0] << " && " << MyVec.chisq_sig[1] << " && "
236  << MyVec.chisq_bkg[0] << " && " << MyVec.chisq_bkg[1] << " && "
237  << MyVec.chisq_tot[0] << " && " << MyVec.chisq_tot[1] << std::endl;
238  */
239  MyVec.chisq_sig[0] += Sig0;
240  MyVec.chisq_sig[1] += Sig1;
241  MyVec.chisq_bkg[0] += Bkg0;
242  MyVec.chisq_bkg[1] += Bkg1;
243  MyVec.chisq_tot[0] += Tot0;
244  MyVec.chisq_tot[1] += Tot1;
245  /*
246  std::cout << "Now I have ;\n\t"
247  << MyVec.chisq_sig[0] << " && " << MyVec.chisq_sig[1] << " && "
248  << MyVec.chisq_bkg[0] << " && " << MyVec.chisq_bkg[1] << " && "
249  << MyVec.chisq_tot[0] << " && " << MyVec.chisq_tot[1] << std::endl;
250  */
251  }
252 //////////////////////////////////////////////////////////////////////
253 
254 void AddToSummaryV(TString ltxcommand, TString systName,
255  const std::vector<TH1*> & mcnom, const std::vector<TH1*> & mcplu, const std::vector<TH1*> & mcmin){
256  if( !(isNumuAna) && !(ltxcommand.Contains("EnergyCVN2D")) ) return;
257  if( !(isNumuAna) && ltxcommand.Contains("3bin") ) return;
258  if (systName.Contains("RelativeCalib") ) return;
259 
261  int VecIndex_xp = -1;
262  int VecIndex_nxp = -1;
263  int VecIndex_com = -1;
264  TString FillSyst = systName;
265  // If Numu I may want to use something one which is already in my vector...
266  if (isNumuAna) {
267  int QLoc = std::max( systName.Index("Q1"), std::max( systName.Index("Q2"), std::max( systName.Index("Q3"), systName.Index("Q4") ) ) );
268  if (QLoc > 0) FillSyst = systName(0,QLoc);
269  if (ltxcommand.Contains("nxp") ) {
270  for (size_t resLoop=0; resLoop<systresults_nxp.size(); ++resLoop){
271  if (systresults_nxp[resLoop].syst == FillSyst) {
272  VecIndex_nxp = resLoop;
273  break;
274  }
275  }
276  } else if (ltxcommand.Contains("_xp_prop") || ltxcommand.Contains("_xp_numu") ) {
277  for (size_t resLoop=0; resLoop<systresults_xp_prop.size(); ++resLoop){
278  if (systresults_xp_prop[resLoop].syst == FillSyst) {
279  VecIndex_xp = resLoop;
280  break;
281  }
282  }
283  } else if (ltxcommand.Contains("_xp_combo") ) {
284  for (size_t resLoop=0; resLoop<systresults_xp_combo.size(); ++resLoop){
285  if (systresults_xp_combo[resLoop].syst == FillSyst) {
286  VecIndex_com = resLoop;
287  break;
288  }
289  }
290  } // Which Vector Index do I fill?
291  }
292  ret.syst = FillSyst;
293 
294  int Nbins=mcnom[0]->GetNbinsX();
295  int TotBins = 5; // for nue
296  int binNbins=Nbins/(TotBins-1);
297  if (isNumuAna) { // If numu
298  TotBins = 1;
299  binNbins = Nbins;
300  }
301 
302  bool hasmin = mcmin.size()>0;
303 
304  // ### Fill the main bins.
305  for(int n=0; n < TotBins; ++n){
306 
307  int ArIndex = n; // for nue.
308  if (isNumuAna && systName.Contains("Q1") ) ArIndex = 0;
309  if (isNumuAna && systName.Contains("Q2") ) ArIndex = 1;
310  if (isNumuAna && systName.Contains("Q3") ) ArIndex = 2;
311  if (isNumuAna && systName.Contains("Q4") ) ArIndex = 3;
312 
313  int bin1 = 1 + (n*binNbins);
314  int bin2 = (n+1) * binNbins;
315  if(n==TotBins-1) {bin1 = 1; bin2 = Nbins;}
316 
317  double Sig0 = -111;
318  double Sig1 = -111;
319 
320  if(mcnom[0] -> Integral(bin1,bin2) >0 ){
321  if(mcplu[0]) Sig0 = mcplu[0]->Integral(bin1,bin2)/ mcnom[0] -> Integral(bin1,bin2) - 1;
322  if(hasmin) Sig1 = mcmin[0]->Integral(bin1,bin2)/ mcnom[0] -> Integral(bin1,bin2) - 1;
323  }
324 
325  double Bkg0 = -111;
326  double Bkg1 = -111;
327 
328  if(mcnom[1] -> Integral(bin1,bin2) >0 ){
329  if(mcplu[1]) Bkg0 = mcplu[1]->Integral(bin1,bin2)/ mcnom[1] -> Integral(bin1,bin2) - 1;
330  if(hasmin) Bkg1 = mcmin[1]->Integral(bin1,bin2)/ mcnom[1] -> Integral(bin1,bin2) - 1;
331  }
332 
333  double Tot0 = -111;
334  double Tot1 = -111;
335 
336  if( (mcnom[0] -> Integral(bin1,bin2) + mcnom[1] -> Integral(bin1,bin2)) > 0 ){
337  if(mcplu[0] && mcplu[1])
338  Tot0 =( (mcplu[0]->Integral(bin1,bin2) + mcplu[1]->Integral(bin1,bin2)) /
339  (mcnom[0]->Integral(bin1,bin2) + mcnom[1]->Integral(bin1,bin2)) -1 );
340  if(hasmin)
341  Tot0 =( (mcmin[0]->Integral(bin1,bin2) + mcmin[1]->Integral(bin1,bin2)) /
342  (mcnom[0]->Integral(bin1,bin2) + mcnom[1]->Integral(bin1,bin2)) -1 );
343 
344  }
345 
346  // ### If numu how do I want to fill the bins?
347  if (VecIndex_xp == -1 && VecIndex_nxp == -1) {
348  SetVecValues_Diff( ret , ArIndex, Sig0, Sig1, Bkg0, Bkg1, Tot0, Tot1 );
349  } else if (ltxcommand.Contains("nxp")) {
350  SetVecValues_Diff( systresults_nxp[VecIndex_nxp] , ArIndex, Sig0, Sig1, Bkg0, Bkg1, Tot0, Tot1 );
351  } else if (ltxcommand.Contains("_xp_prop") || ltxcommand.Contains("_xp_numu") ) {
352  SetVecValues_Diff( systresults_xp_prop[VecIndex_xp] , ArIndex, Sig0, Sig1, Bkg0, Bkg1, Tot0, Tot1 );
353  } else if (ltxcommand.Contains("_xp_combo")) {
354  SetVecValues_Diff( systresults_xp_combo[VecIndex_com], ArIndex, Sig0, Sig1, Bkg0, Bkg1, Tot0, Tot1 );
355  }
356  }//end bins
357 
358  // #### Chi-Square calculation section
359  double chisq_Sig0 = -111, chisq_Sig1 = -111;
360  double chisq_Bkg0 = -111, chisq_Bkg1 = -111;
361  double chisq_Tot0 = -111, chisq_Tot1 = -111;
362 
363  auto temp_nom = (TH1*)mcnom[0]->Clone(UniqueName().c_str());
364  temp_nom->Add (mcnom[1]);
365  auto temp_plu = (TH1*)mcplu[0]->Clone(UniqueName().c_str());
366  temp_plu->Add (mcplu[1]);
367 
368  TH1* temp_min;
369  if(hasmin) {temp_min = (TH1*)mcmin[0]->Clone(UniqueName().c_str());
370  temp_min->Add (mcmin[1]);
371  }
372 
373  chisq_Sig0 = CalcChi2(mcnom[0],mcplu[0]);
374  chisq_Bkg0 = CalcChi2(mcnom[1],mcplu[1]);
375  chisq_Tot0 = CalcChi2(temp_nom,temp_plu);
376  if(hasmin){
377  chisq_Sig1 = CalcChi2(mcnom[0],mcmin[0]);
378  chisq_Bkg1 = CalcChi2(mcnom[1],mcmin[1]);
379  chisq_Tot1 = CalcChi2(temp_nom,temp_min);
380  }
381 
382  if (VecIndex_xp == -1 && VecIndex_nxp == -1) {
383  SetVecValues_ChiSq( ret , chisq_Sig0, chisq_Sig1, chisq_Bkg0, chisq_Bkg1, chisq_Tot0, chisq_Tot1 );
384  } else if (ltxcommand.Contains("nxp")) {
385  SetVecValues_ChiSq( systresults_nxp[VecIndex_nxp] , chisq_Sig0, chisq_Sig1, chisq_Bkg0, chisq_Bkg1, chisq_Tot0, chisq_Tot1 );
386  } else if (ltxcommand.Contains("_xp_prop") || ltxcommand.Contains("_xp_numu") ) {
387  SetVecValues_ChiSq( systresults_xp_prop[VecIndex_xp] , chisq_Sig0, chisq_Sig1, chisq_Bkg0, chisq_Bkg1, chisq_Tot0, chisq_Tot1 );
388  } else if (ltxcommand.Contains("_xp_combo")) {
389  SetVecValues_ChiSq( systresults_xp_combo[VecIndex_com], chisq_Sig0, chisq_Sig1, chisq_Bkg0, chisq_Bkg1, chisq_Tot0, chisq_Tot1 );
390  }
391 
392  // ### Junk output
393  /*
394  SystResults OutRet = ret;
395  if (VecIndex_nxp!=-1) {
396  OutRet = systresults_nxp[VecIndex_nxp];
397  std::cout << "I am looking at a NO extrap result..." << std::endl;
398  } else if (VecIndex_xp!=-1) {
399  OutRet = systresults_xp_prop [VecIndex_xp ];
400  std::cout << "I am looking at an extrap result..." << std::endl;
401  } else {
402  std::cout << "This is the first time I've seen this one..." << std::endl;
403  }
404  for (uint zz=0; zz<4; ++zz) {
405  std::cout << "\nLooking at ret["<<zz<<"];"
406  << "\n\t It has sig values " << OutRet.diff_sig[0][zz] << " && " << OutRet.diff_sig[1][zz]
407  << "\n\t It has bkg values " << OutRet.diff_bkg[0][zz] << " && " << OutRet.diff_bkg[1][zz]
408  << "\n\t It has tot values " << OutRet.diff_tot[0][zz] << " && " << OutRet.diff_tot[1][zz]
409  << std::endl;
410  }
411  */
412  // ### Prepare to push back if neccessary.
413  delete temp_nom,temp_plu,temp_min;
414 
415  if(ltxcommand.Contains("ND")) return;
416  if(VecIndex_nxp==-1 && ltxcommand.Contains("nxp")) {
417  systresults_nxp.push_back(ret);
418  return;
419  }
420  if(VecIndex_xp ==-1 && (ltxcommand.Contains("_xp_prop") || ltxcommand.Contains("_xp_numu") ) ) {
421  systresults_xp_prop .push_back(ret);
422  return;
423  }
424  if(VecIndex_com == -1 && ltxcommand.Contains("xp_combo")) {
425  systresults_xp_combo.push_back(ret);
426  return;
427  }
428 }
429 
430 //////////////////////////////////////////////////////////////////////
431 void ComparisonTableOne(const std::vector<TH1*> & mcnom, const std::vector<TH1*> & mcshift,
432  const std::vector<TString> & labels, const TString ltxcommand =""){
433  unsigned int nentries = mcnom.size();
434  if(mcshift.size()!=nentries || labels.size()!=nentries){std::cerr << "%incompatible sizes\n"; return;}
435 
436  // Extract Sytematic name from title
437  TString title = mcnom[0]->GetTitle();
438  TString systName = FixPlotName(title(0, title.Index(" ")));
439 
440  PrintTableHeader(ltxcommand, "| l |"," | r | r | r || r r | ", 1);
441  tables << TString::Format("%20s & %10s & %10s & %10s & %10s & %10s \\\\ \n",
442  " ", "Nominal",
443  "Sh(+)",
444  "Sh(-)",
445  "\\%(+)",
446  "\\%(-)"
447  );
448  tables << "\\hline \n";
449  TString sum0, sum1;
450  for(unsigned int i=0;i<nentries;i++){
451 
452  TString base = (mcnom[i]->Integral()>100 ?
453  "%20s & %10.0f & %10.0f & %10s & %+10.0f & %10s \\\\ \n":
454  "%20s & %10.3f & %10.3f & %10s & %+10.1f & %10s \\\\ \n");
455  auto temp = TString::Format(base.Data(),
456  labels[i].Data(),
457  mcnom[i]->Integral(),
458  mcshift[i]->Integral(), "--",
459  ((mcnom[i]->Integral()>0) ? ((mcshift[i]->Integral()/mcnom[i]->Integral()) -1.) : 0) *100.,
460  "--");
461  tables << temp;
462  if(i == 0) sum0 = temp;
463  if(i == 1) sum1 = temp;
464  }
466  AddToSummaryV (ltxcommand, systName, mcnom, mcshift,{});
467 }
468 
469 
470 
471 //////////////////////////////////////////////////////////////////////
472 
473 void ComparisonTableOneNbins(const std::vector<TH1*> & mcnom, const std::vector<TH1*> & mcshift,
474  const std::vector<TString> & labels, TString ltxcommand, int N=3){
475  if(N<3) return;
476  tables << "\n \\vspace{30 pt} \n";
477 
478  int Nbins=mcnom[0]->GetNbinsX();
479  int binNbins=Nbins/N;
480 
481  if(ltxcommand=="") {std::cerr<< "WARNING ComparisonTableOneNbins ltxcommand\n"; return;}
482  output << "\\setlength{\\tabcolsep}{1pt} \\renewcommand{\\arraystretch}{1.2} \n";
483  output << "\n{\\small \\vspace{30pt} \n";
484  output << "\\" << MakeLatexCommandName(ltxcommand+"bins") << "\n\n";
485 
486  tables << "\\newcommand{\\" << MakeLatexCommandName(ltxcommand+"bins") << "}\n";
487  tables << "{\\centerline{\n";
488 
489 
490  for ( int n = 0; n<N; ++n){
491 
492  int bin1 = 1 + (n*binNbins);
493  int bin2 = (n+1) * binNbins;
494 
495  unsigned int nentries = mcnom.size();
496  if(mcshift.size()!=nentries || labels.size()!=nentries){std::cerr << "%incompatible sizes\n"; return;}
497  tables << "\\begin{tabular}{" << (n==0? "l":"") <<"| r r | r |} \n"
498  << std::setw(20) << (n==0?"&":"") << "\\multicolumn{3}{|c|}{Bin " << n+1 << "}\\\\ \\hline "
499  << (n==0?" & ":" ")
500  << std::setw(10) << "Nom." << " & "
501  << std::setw(10) << "Shift" << " & "
502  << std::setw(12) << "\\% Diff."
503  <<"\t \\\\ \\hline \n";
504  for(unsigned int i=0;i<nentries;i++){
505  tables.unsetf(std::ios_base::floatfield);
506 
507  if(mcnom[i] ->Integral(bin1,bin2) > 100) tables << std::fixed << std::setprecision(0);
508  else tables << std::setprecision(2);
509 
510  tables << std::setw(20); if( n==0 ) tables << labels[i] << " & ";
511  tables << std::setw(10) << mcnom[i] ->Integral(bin1,bin2) << " & "
512  << std::setw(10) << mcshift[i]->Integral(bin1,bin2) << " & "
513  << std::setw(10) << std::setprecision(1) << std::fixed << std::showpos
514  << ( mcnom[i]->Integral()>0 ? (((mcshift[i]->Integral(bin1,bin2)/mcnom[i]->Integral(bin1,bin2)) -1.)*100.):0.)
515  << std::noshowpos
516  <</* "\\%*/" \t \\\\ \n";
517  }
518  tables << "\\end{tabular} \n";
519 
520  }
521  tables << "} } \n";
522  output << "}\n";
523 
524 }
525 
526 void ComparisonTable(const std::vector<TH1*> & mcnom, const std::vector<TH1*> & mcplus, const std::vector<TH1*> & mcminus,
527  std::vector<TString> labels, TString ltxcommand = ""){
528  // Extract Sytematic name from title
529  output << " \n % " << std::string(60,'-') << std::endl;
530  TString title = mcnom[0]->GetTitle();
531  TString systName = FixPlotName(title(0, title.Index(" ")));
532 
533  unsigned int nentries = mcnom.size();
534  if(mcplus.size()!=nentries || mcminus.size()!=nentries || labels.size()!=nentries){std::cerr << "incompatible sizes\n"; return;}
535  if(ltxcommand == "") {std::cerr<< "WARNING Problem wiyh comparisonTable ltx\n"; return;}
536 
537  output << "\\setlength{\\tabcolsep}{1pt} \\renewcommand{\\arraystretch}{1.2} \n";
538  output << "\\"<< MakeLatexCommandName(ltxcommand) << "\n\n";
539 
540  tables << "\\newcommand{\\" << MakeLatexCommandName(ltxcommand) << "}\n";
541  tables << "{\\centerline { \n \\begin{tabular}{ l | r r r | r r } \n"
542  << std::setw(25) << "Integral shift " << " & "
543  << std::setw(10) << "Nominal" << " & "
544  << std::setw(10) << "Shift (+)" << " & "
545  << std::setw(10) << "Shift (-)" << " & "
546  << std::setw(12) << "\\% Diff. (+)" << " & "
547  << std::setw(12) << "\\% Diff. (-)"
548  <<"\t \\\\ \\hline \n";
549  for(unsigned int i=0;i<nentries;i++){
550  tables.unsetf(std::ios_base::floatfield);
551  if(mcnom[i] ->Integral() > 100) tables << std::fixed << std::setprecision(0);
552  else tables << std::setprecision(2);
553  tables << std::setw(25) << labels[i] << " & "
554  << std::setw(10) << mcnom[i] ->Integral() << " & "
555  << std::setw(10) << mcplus[i] ->Integral() << " & "
556  << std::setw(10) << mcminus[i]->Integral() << " & "
557  << std::setw(10) << std::setprecision(1) << std::fixed << std::showpos
558  << ( mcnom[i]->Integral()>0 ? (((mcplus [i]->Integral()/mcnom[i]->Integral()) -1.)*100.):0.)
559  << /*"\\%"*/" & "
560  << std::setw(10)
561  << ( mcnom[i]->Integral()>0 ? (((mcminus[i]->Integral()/mcnom[i]->Integral()) -1.)*100.):0.)
562  << std::noshowpos
563  << /*"\\%"*/" \t \\\\ \n";
564  }
565  tables << "\\end{tabular} } \n } \n";
566 
567  // Can I add a table about the mean here???
568  // NOOO
569  // TODO fix latex command
570  if(isNumuAna){
571 
572  output << "\\setlength{\\tabcolsep}{1pt} \\renewcommand{\\arraystretch}{1.2} \n";
573  output << "\\vspace{25pt} \\" << MakeLatexCommandName(ltxcommand+"mean") << "\n\n";
574 
575  tables << "\\newcommand{\\" << MakeLatexCommandName(ltxcommand + "mean") << "}\n";
576  tables << "{\\centerline { \n \\begin{tabular}{ l | r r r | r r } \n"
577  << std::setw(25) << "Mean Value shift " << " & "
578  << std::setw(10) << "Nominal" << " & "
579  << std::setw(10) << "Shift (+)" << " & "
580  << std::setw(10) << "Shift (-)" << " & "
581  << std::setw(12) << "\\% Diff. (+)" << " & "
582  << std::setw(12) << "\\% Diff. (-)"
583  <<"\t \\\\ \\hline \n";
584  for(unsigned int i=0;i<nentries;i++){
585  tables.unsetf(std::ios_base::floatfield);
586  tables << std::setprecision(3);
587  tables << std::setw(25) << labels[i] << " & "
588  << std::setw(10) << mcnom[i] ->GetMean() << " & "
589  << std::setw(10) << mcplus[i] ->GetMean() << " & "
590  << std::setw(10) << mcminus[i]->GetMean() << " & "
591  << std::setw(10) << std::setprecision(1) << std::fixed << std::showpos
592  << ( mcnom[i]->Integral()>0 ? (((mcplus [i]->GetMean()/mcnom[i]->GetMean()) -1.)*100.):0.)
593  << /*"\\%"*/" & "
594  << std::setw(10)
595  << ( mcnom[i]->Integral()>0 ? (((mcminus[i]->GetMean()/mcnom[i]->GetMean()) -1.)*100.):0.)
596  << std::noshowpos
597  << /*"\\%"*/" \t \\\\ \n";
598  }
599  tables << "\\end{tabular} } \n } \n";
600 
601  // Can I add a table about the RMS here???
602  output << "\\setlength{\\tabcolsep}{1pt} \\renewcommand{\\arraystretch}{1.2} \n";
603  output << "\\vspace{25pt} \\" << MakeLatexCommandName(ltxcommand+"rms") << "\n\n";
604 
605  tables << "\\newcommand{\\" << MakeLatexCommandName(ltxcommand + "rms") << "}\n";
606  tables << "{\\centerline { \n \\begin{tabular}{ l | r r r | r r } \n"
607  << std::setw(25) << "RMS Value shift " << " & "
608  << std::setw(10) << "Nominal" << " & "
609  << std::setw(10) << "Shift (+)" << " & "
610  << std::setw(10) << "Shift (-)" << " & "
611  << std::setw(12) << "\\% Diff. (+)" << " & "
612  << std::setw(12) << "\\% Diff. (-)"
613  <<"\t \\\\ \\hline \n";
614  for(unsigned int i=0;i<nentries;i++){
615  tables.unsetf(std::ios_base::floatfield);
616  tables << std::setprecision(3);
617  tables << std::setw(25) << labels[i] << " & "
618  << std::setw(10) << mcnom[i] ->GetRMS() << " & "
619  << std::setw(10) << mcplus[i] ->GetRMS() << " & "
620  << std::setw(10) << mcminus[i]->GetRMS() << " & "
621  << std::setw(10) << std::setprecision(1) << std::fixed << std::showpos
622  << ( mcnom[i]->Integral()>0 ? (((mcplus [i]->GetRMS()/mcnom[i]->GetRMS()) -1.)*100.):0.)
623  << /*"\\%"*/" & "
624  << std::setw(10)
625  << ( mcnom[i]->Integral()>0 ? (((mcminus[i]->GetRMS()/mcnom[i]->GetRMS()) -1.)*100.):0.)
626  << std::noshowpos
627  << /*"\\%"*/" \t \\\\ \n";
628  }
629  tables << "\\end{tabular} } \n } \n";
630  }
631 
632  AddToSummaryV (ltxcommand, systName, mcnom, mcplus, mcminus);
633  //AddToEnvelop (ltxcommand, systName, mcnom, mcplus, mcminus);
634 
635 }
636 
637 TString FixMeSummary (double number, bool isdiff = true){
638  if(number <-100) return "--";
639  if(!isdiff) return TString::Format("%.3f",number);
640  TString pre="";
641  if(fabs(number*100) >= 7) pre = "\\cellcolor{\\myhighlightC}" ;
642  else if(fabs(number*100) >= 3) pre = "\\cellcolor{\\myhighlightB}" ;
643  else if(fabs(number*100) >= 1) pre = "\\cellcolor{\\myhighlightA}" ;
644  return pre + TString::Format("%+.2f",number*100);
645 
646 }
647 
648 void MakeSummaryV(bool signal = true, TString xptype = "nxp", bool sorted = false){
649 
650  auto results = systresults_nxp;
651  if(xptype.Contains ("prop")) results = systresults_xp_prop;
652  if(xptype.Contains ("combo")) results = systresults_xp_combo;
653  bool extrap = (xptype != "nxp");
654 
655  if(sorted && signal)std::sort(results.begin(), results.end(), sort_chisq_sig);
656  if(sorted && !signal)std::sort(results.begin(), results.end(), sort_chisq_bkg);
657 
658  TString summarylatex = MakeLatexCommandName("summaryT"+ xptype + (signal?"Sig":"Bkg") + (sorted?"sorted":""));
659 
660  output << "\\"<< summarylatex <<"\n\n";
661 
662  summary << "\\newcommand{\\" << summarylatex << "}{\n";
663  summary << "\\hspace*{-1em} \n";
664  summary << "\\begin{longtable}{p{0.15\\textwidth}||cc|cc|cc|cc||cc||cc}\n";
665  summary << (extrap?"Extrap. ":"FDMC ") << (signal? "Sig":"Bkg") << "\n";
666  TString BinQuant = isNumuAna? "Quant" : "Bin";
667  if (isNumuAna) {
668  // --- Table for Numu
669  summary << " & \\multicolumn{2}{c|}{"<<BinQuant<<"1} & \\multicolumn{2}{c|}{"<<BinQuant<<"2} &"
670  << " \\multicolumn{2}{c|}{"<<BinQuant<<"3} & \\multicolumn{2}{c||}{"<<BinQuant<<"4} &"
671  << " \\multicolumn{2}{c}{Chi2Test} \\\\ \n";
672  summary << "Syst & +(\\%) & - (\\%) & +(\\%) & - (\\%) & +(\\%) & - (\\%) & +(\\%) & - (\\%) &"
673  << "+ & - \\\\ \n \\hline \n";
674  } else {
675  // --- Table for nue
676  summary << " & \\multicolumn{2}{c|}{"<<BinQuant<<"1} & \\multicolumn{2}{c|}{"<<BinQuant<<"2} &"
677  << " \\multicolumn{2}{c|}{"<<BinQuant<<"3} & \\multicolumn{2}{c||}{"<<BinQuant<<"4} &"
678  << " \\multicolumn{2}{c||}{Tot} & \\multicolumn{2}{c}{Chi2Test} \\\\ \n";
679  summary << "Syst & +(\\%) & - (\\%) & +(\\%) & - (\\%) & +(\\%) & - (\\%) & +(\\%) & - (\\%) &"
680  << "+(\\%) & - (\\%) & + & - \\\\ \n \\hline \n";
681  }
682  for (auto const & res:results){
683  summary.unsetf(std::ios_base::floatfield);
684  TString section = "\\hyperref[sec:"+MakeLatexCommandName(res.syst)+"]{"+res.syst+"} ";
685  if(signal){
686  summary << std::setprecision(3) << std::showpos
687  << section << " & "
688  << FixMeSummary(res.diff_sig[0][0]) << " & \t"
689  << FixMeSummary(res.diff_sig[1][0]) << " & \t"
690  << FixMeSummary(res.diff_sig[0][1]) << " & \t"
691  << FixMeSummary(res.diff_sig[1][1]) << " & \t"
692  << FixMeSummary(res.diff_sig[0][2]) << " & \t"
693  << FixMeSummary(res.diff_sig[1][2]) << " & \t"
694  << FixMeSummary(res.diff_sig[0][3]) << " & \t"
695  << FixMeSummary(res.diff_sig[1][3]) << " & \t";
696  if (!isNumuAna) {
697  summary << FixMeSummary(res.diff_sig[0][4]) << " & \t"
698  << FixMeSummary(res.diff_sig[1][4]) << " & \t";
699  }
700  summary << std::noshowpos
701  << FixMeSummary(res.chisq_sig[0],false) << "& \t"
702  << FixMeSummary(res.chisq_sig[1],false) << " \t \\\\ \n";
703  } else {
704  summary << std::setprecision(3) << std::showpos
705  << section << " & "
706  << FixMeSummary(res.diff_bkg[0][0]) << " & \t"
707  << FixMeSummary(res.diff_bkg[1][0]) << " & \t"
708  << FixMeSummary(res.diff_bkg[0][1]) << " & \t"
709  << FixMeSummary(res.diff_bkg[1][1]) << " & \t"
710  << FixMeSummary(res.diff_bkg[0][2]) << " & \t"
711  << FixMeSummary(res.diff_bkg[1][2]) << " & \t"
712  << FixMeSummary(res.diff_bkg[0][3]) << " & \t"
713  << FixMeSummary(res.diff_bkg[1][3]) << " & \t";
714  if (!isNumuAna) {
715  summary << FixMeSummary(res.diff_bkg[0][4]) << " & \t"
716  << FixMeSummary(res.diff_bkg[1][4]) << " & \t";
717  }
718  summary << std::noshowpos
719  << FixMeSummary(res.chisq_bkg[0],false) << "& \t"
720  << FixMeSummary(res.chisq_bkg[1],false) << " \t \\\\ \n";
721  }
722  }
723  summary << "\\end{longtable} \n } \n\n";
724 }
725 
726 void ComparisonTableNbins(const std::vector<TH1*> & mcnom, const std::vector<TH1*> & mcplus, const std::vector<TH1*> & mcminus,
727  std::vector<TString> labels,TString ltxcommand = "", int N=3){
728  if(N<3) return;
729  output << "\n % " << std::string(60,'-') << std::endl;
730 
731  int Nbins=mcnom[0]->GetNbinsX();
732  int binNbins=Nbins/N;
733 
734  unsigned int nentries = mcnom.size();
735  if(mcplus.size()!=nentries || mcminus.size()!=nentries || labels.size()!=nentries){std::cerr << "WARNING incompatible sizes\n"; return;}
736  if(ltxcommand == "") {std::cerr << "WARNING Problem with ComparisonTableNbins ltxcommand\n"; return;}
737 
738  output << "\n\n{\\footnotesize \\vspace{30pt} \n";
739  output << "\\setlength{\\tabcolsep}{1.5pt} \\renewcommand{\\arraystretch}{1.2} \n";
740  output << "\\" << MakeLatexCommandName(ltxcommand+"bins") << "\n\n";
741 
742  tables << "\\newcommand{\\" << MakeLatexCommandName(ltxcommand+"bins") << "}\n";
743  tables << "{\\centerline{\n";
744  tables << "\\begin{tabular}{ l ";
745  for (int n = 1; n <= N; ++n ) tables << "| r r r | r r ";
746  tables << "} \n & ";
747  for (int n = 1; n <= N; ++n ){tables << "\\multicolumn{5}{c|}{Bin " << n << "} " <<( n < N ? " & ":" \\\\ \\hline \n");}
748  tables << std::setw(20) << " & ";
749  for (int n = 1; n <= N; ++n ){
750  tables << std::setw(3) << "Nom."<< "&"
751  << std::setw(3) << "(+)" << "&"
752  << std::setw(3) << "(-)" << "&"
753  << std::setw(5) << "\\%(+)" << "&"
754  << std::setw(5) << "\\%(-)"
755  <<( n < N ? " & ":" \\\\ \\hline \n");
756  }
757  for(unsigned int i=0;i<nentries;i++){
758  tables << std::setw(20) << labels[i] << " & ";
759 
760  for ( int n = 0; n<N; ++n){
761 
762  int bin1 = 1 + (n*binNbins);
763  int bin2 = (n+1)*binNbins;
764 
765  tables.unsetf(std::ios_base::floatfield);
766  if(mcnom[i] ->Integral(bin1,bin2) > 100) tables << std::fixed << std::setprecision(0);
767  else tables << std::setprecision(2);
768  tables << std::setw(5) << mcnom[i] ->Integral(bin1,bin2) << "&"
769  << std::setw(5) << mcplus[i] ->Integral(bin1,bin2) << "&"
770  << std::setw(5) << mcminus[i]->Integral(bin1,bin2) << "&"
771  << std::setw(5) << std::setprecision(1) << std::fixed << std::showpos
772  << ( mcnom[i]->Integral()>0 ? (((mcplus [i]->Integral(bin1,bin2)/mcnom[i]->Integral(bin1,bin2)) -1.)*100.):0.)
773  << "&"
774  << std::setw(5)
775  << ( mcnom[i]->Integral()>0 ? (((mcminus[i]->Integral(bin1,bin2)/mcnom[i]->Integral(bin1,bin2)) -1.)*100.):0.)
776  << std::noshowpos
777  << ( n + 1 < N ? " & ":" \\\\ \n");
778  }
779  }
780  tables << "\\end{tabular} \n";
781  tables << "}}\n";
782  output << "}\n"; //end footnotesize
783 
784 }
785 //////////////////////////////////////////////////////////////////////
786 void PrintRawEventCounts(TDirectory * dpred, TString title){
787 
788  std::vector<int> ndcounts;
789  std::vector<int> fdcounts;
790  std::vector<TString> labels;
791  //Data
792  labels.push_back("Data - $\\nu_\\mu $");
793  ndcounts.push_back(((TH1*)dpred->Get("extrap/MEextrap/Decomp/data_comp/hist"))->GetEntries());
794  fdcounts.push_back(0);
795  labels.push_back("Data - $\\nu_e $");
796  ndcounts.push_back(((TH1*)dpred->Get("extrap/EEextrap/Decomp/data_comp/hist"))->GetEntries());
797  fdcounts.push_back(0);
798 
799  //Signal
800  labels.push_back("Signal - $\\nu_\\mu \\to \\nu_e $");
801  labels.push_back("Signal - $\\bar{\\nu}_\\mu \\to \\bar{\\nu}_e $");
802  for(TString xp:{"ME","MEAnti"}){
803  ndcounts.push_back(((TH1*)dpred->Get("extrap/"+xp+"extrap/RecoToTrueND/hist"))->GetEntries());
804  fdcounts.push_back(((TH1*)dpred->Get("extrap/"+xp+"extrap/TrueToRecoFD/hist"))->GetEntries());
805  }
806 
807  //Major bkg
808  labels.push_back("Bkg. - $\\nu_e \\to \\nu_e $");
809  labels.push_back("Bkg. - $\\nu_\\mu \\to \\nu_\\mu $");
810  labels.push_back("Bkg. - $NC \\to NC $");
811  for(TString xp:{"EE","MM","NC"}){
812  ndcounts.push_back(((TH1*)dpred->Get("extrap/"+xp+"extrap/RecoND/hist"))->GetEntries());
813  fdcounts.push_back(((TH1*)dpred->Get("extrap/"+xp+"extrap/TrueToRecoFD/hist"))->GetEntries());
814  }
815 
816  //Minor bkg
817  labels.push_back("Bkg. - $\\nu_e \\to \\nu_\\tau $");
818  labels.push_back("Bkg. - $\\nu_\\mu \\to \\nu_\\tau $");
819  for(TString xp: {"ET","MT"}){
820  ndcounts.push_back(0);
821  fdcounts.push_back(((TH1*)dpred->Get("extrap/"+xp+"extrap/RecoFD/hist"))->GetEntries());
822  }
823  labels.push_back("Bkg. - Other");
824  double fdcount_minor=0;
825  for(TString xp: {"EM","EEAnti","EMAnti","ETAnti","MMAnti","MTAnti"}){
826  fdcount_minor+=(((TH1*)dpred->Get("extrap/"+xp+"extrap/RecoFD/hist"))->GetEntries());
827  }
828  ndcounts.push_back(0);
829  fdcounts.push_back(fdcount_minor);
830 
831  //Print
832  output << "% " << std::string(60,'-') << std::endl;
833  output << "\n " << title << "\n";
834  output << "\\setlength{\\tabcolsep}{1.5pt} \\renewcommand{\\arraystretch}{1.2} \n";
835  output << "\\vspace{20pt} \n \\centering{\\begin{tabular}{ l | r | r } \n"
836  << std::setw(45) << " " << " & "
837  << std::setw(10) << "ND" << " & "
838  << std::setw(10) << "FD"
839  << " \\\\ \\hline \n";
840  for(unsigned int i=0;i<labels.size();i++){
841  output << std::setw(45) << labels[i] << " & "
842  << std::setw(10)<< ndcounts[i] << " & "
843  << std::setw(10)<< fdcounts[i] << " \\\\ ";
844  if(i==1 || i==3 || i==6) output << "\\hline \n";
845  else output << "\n";
846  }
847  output << "\\end{tabular} \n} \n";
848  output << "% " << std::string(60,'-') << std::endl;
849 }
850 
852 {
853  if(usingdumb){
854  output << "\n\\bigskip\n"
855  << "Using dumb oscillations - no solar term, mass hierarchy nor delta. \n"
856  << "$L= 810 km,$ "
857  << "$\\Delta m^{2} = 2.40e-3 eV^{-2},$ "
858  << "$\\sin^{2}2\\theta_{13} = 0.1,$ "
859  << "$\\sin^{2}\\theta_{23} = 0.5$ "
860  << ".\\\\\n\\medskip\n\n";
861  }
862  else{
863  auto calc2 = dynamic_cast<osc::IOscCalcAdjustable *> (calc);
864  output << "\n\\bigskip\n"
865  << "Oscillation parameters:\n"
866  << TString::Format("$L= %.0f km,$ ",calc2->GetL())
867  << TString::Format("$\\rho= %.2f g/cm^3,$ ",calc2->GetRho())
868  << TString::Format("$\\Delta m^{2} = %.2e eV^{-2},$ ",calc2->GetDmsq32())
869  << TString::Format("$\\Delta m^{2} = %.2e eV^{-2},$ ",calc2->GetDmsq21())
870  << TString::Format("$\\sin^{2}2\\theta_{12} = %.3f,$ ",util::sqr(sin(2*calc2->GetTh12())))
871  << TString::Format("$\\sin^{2}2\\theta_{13} = %.3f,$ ",util::sqr(sin(2*calc2->GetTh13())))
872  << TString::Format("$\\sin^{2}\\theta_{23} = %.3f,$ ",util::sqr(sin(calc2->GetTh23())))
873  << TString::Format("$\\delta_{CP} = %.2f\\pi.$ ",calc2->GetdCP()/M_PI)
874  << "\\\\\n\\medskip\n\n";
875  }
876 
877 }
878 
879 }
TH1D * systsum_plu_xp_combo[6]
T max(const caf::Proxy< T > &a, T b)
const XML_Char * name
Definition: expat.h:151
ofstream output
void PrintTableHeader(TString ltxcommand="", TString labelcol_style="l", TString bincol_style="| r r r", int nbins=1)
double diff_bkg[2][5]
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void ComparisonTableOneNbins(const std::vector< TH1 * > &mcnom, const std::vector< TH1 * > &mcshift, const std::vector< TString > &labels, TString ltxcommand, int N=3)
TString FixPlotName(TString mystring)
double CalcChi2(TH1 *hmc, TH1 *hdata)
TH1D * systsum_min_xp_combo[6]
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
double Integral(const Spectrum &s, const double pot, int cvnregion)
void SetVecValues_Diff(SystResults &MyVec, int Ind, double Sig0, double Sig1, double Bkg0, double Bkg1, double Tot0, double Tot1)
T sqrt(T number)
Definition: d0nt_math.hpp:156
General interface to oscillation calculators.
Definition: StanTypedefs.h:22
bool sort_chisq_sig(SystResults a, SystResults b)
TH1D * systsum_plu_nxp[6]
OStream cerr
Definition: OStream.cxx:7
bool sort_chisq_bkg(SystResults a, SystResults b)
void ComparisonTableOne(const std::vector< TH1 * > &mcnom, const std::vector< TH1 * > &mcshift, const std::vector< TString > &labels, const TString ltxcommand="")
osc::OscCalcDumb calc
double chi2()
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
cout<< t1-> GetEntries()
Definition: plottest35.C:29
double diff_tot[2][5]
std::vector< SystResults > systresults_nxp
#define M_PI
Definition: SbMath.h:34
TH1D * systsum_plu_xp_prop[6]
const int nbins
Definition: cellShifts.C:15
bool isNumuAna
std::vector< SystResults > systresults_xp_prop
TH1D * systsum_min_nxp[6]
void ComparisonTable(const std::vector< TH1 * > &mcnom, const std::vector< TH1 * > &mcplus, const std::vector< TH1 * > &mcminus, std::vector< TString > labels, TString ltxcommand="")
Long64_t nentries
const double a
void AddToSummaryV(TString ltxcommand, TString systName, const std::vector< TH1 * > &mcnom, const std::vector< TH1 * > &mcplu, const std::vector< TH1 * > &mcmin)
TH1D * systsum_min_xp_prop[6]
double sigma(TH1F *hist, double percentile)
TString FixMeSummary(double number, bool isdiff=true)
void SetVecValues_ChiSq(SystResults &MyVec, double Sig0, double Sig1, double Bkg0, double Bkg1, double Tot0, double Tot1)
void PrintLatexFigure(TString name, TString plotdir="plots/")
std::vector< SystResults > systresults_xp_combo
void MakeSummaryV(bool signal=true, TString xptype="nxp", bool sorted=false)
ofstream summary
TString MakeLatexCommandName(TString mystring)
ifstream in
Definition: comparison.C:7
T sin(T number)
Definition: d0nt_math.hpp:132
void PrintTableFooter()
void PrintOscilationParameters(osc::IOscCalc *calc, bool usingdumb)
void ComparisonTableNbins(const std::vector< TH1 * > &mcnom, const std::vector< TH1 * > &mcplus, const std::vector< TH1 * > &mcminus, std::vector< TString > labels, TString ltxcommand="", int N=3)
ofstream tables
const hit & b
Definition: hits.cxx:21
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
double diff_sig[2][5]
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
void PrintRawEventCounts(TDirectory *dpred, TString title)
enum BeamMode string