//____________________________________________________________________________
/*!

\program gvld_nuxs_comp

\brief   A GENIE utility that reads-in GENIE cross section files and generates 
         comparisons plots.

         Syntax:
           gvld_xsec_comp 
              -f file [-r ref_file] [-d] [-h host] [-u user] [-p passwd]

         Options:
           [] Denotes an optional argument.
           -f Specifies a ROOT file with GENIE cross section graphs.
	   -r Specifies a reference ROOT file with GENIE cross section graphs.
           -d Enable comparisons with data-sets stored in NuVld MySQL dbase.
           -h NuVld MySQL URL (eg mysql://localhost/NuScat).
           -u NuVld MySQL username.
           -p NuVld MySQL password.

         Notes:
           The input ROOT files are the ones generated by GENIE's gspl2root
           utility. See the GENIE User Manual for more details.
           	      
         Example:
           Compare cross sections in xsec-v2_4.root and xsec-v2_2.root and
           enable comparisons with data:
           shell$ gvld_nuxs_comp -f xsec-v2_4.root -r xsec-v2_2.root -d
		      
\author  Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
         STFC, Rutherford Appleton Laboratory

\created June 06, 2008 

\cpright Copyright (c) 2003-2009, GENIE Neutrino MC Generator Collaboration
         For the full text of the license visit http://copyright.genie-mc.org
         or see $GENIE/LICENSE
*/
//____________________________________________________________________________

#include <cassert>
#include <sstream>
#include <string>

#include <TSystem.h>
#include <TFile.h>
#include <TDirectory.h>
#include <TGraph.h>
#include <TPostScript.h>
#include <TH1D.h>
#include <TMath.h>
#include <TCanvas.h>
#include <TPavesText.h>
#include <TText.h>
#include <TStyle.h>
#include <TLegend.h>

#include "Conventions/GBuild.h"
#include "Messenger/Messenger.h"
#include "PDG/PDGUtils.h"
#include "PDG/PDGCodes.h"
#include "Utils/CmdLineArgParserUtils.h"
#include "Utils/CmdLineArgParserException.h"
#include "ValidationTools/NuVld/DBI.h"
#include "ValidationTools/NuVld/DBStatus.h"

using std::ostringstream;
using std::string;

using namespace genie;
using namespace genie::nuvld;

/* 
..............................................................................
NEUTRINO CROSS SECTION DATA
..............................................................................
ID   DESCRIPTION
0    neutrino      QEL [all]
1    neutrino      QEL [light targets]
2    neutrino      QEL [heavy targets]
3    anti-neutrino QEL [all]
4    anti-neutrino QEL [light targets]
5    anti-neutrino QEL [heavy targets]
6    neutrino      RES [all: v + p -> mu- + p + pi+]
7    neutrino      TOT [E>10]
8    anti-neutrino TOT [E>10]
9    neutrino      MPP [v + n -> l + p + pi+ + pi-]
10   neutrino      MPP [v + p -> l + p + pi+ + pi0]
11   neutrino      MPP [v + p -> l + n + pi+ + pi+]
..............................................................................
*/
const int    kNuXSecDataSets = 12;
const char * kNuXSecDataSetLabel[kNuXSecDataSets] = {
/* 0 */ "neutrino      QEL [all]              ",
/* 1 */ "neutrino      QEL [light targets]    ",
/* 2 */ "neutrino      QEL [heavy targets]    ",
/* 3 */ "anti-neutrino QEL [all]              ",
/* 4 */ "anti-neutrino QEL [light targets]    ",
/* 5 */ "anti-neutrino QEL [heavy targets]    ",
/* 6 */ "neutrino      RES [all: vp->mu-ppi+] ",
/* 7 */ "neutrino      TOT [E>10]             ",
/* 8 */ "anti-neutrino TOT [E>10]             ",
/* 9 */ "neutrino      MPP [v + n -> l + p + pi+ + pi-]",
/*10 */ "neutrino      MPP [v + p -> l + p + pi+ + pi0]",
/*11 */ "neutrino      MPP [v + p -> l + n + pi+ + pi+]"
};
const char * kNuXSecKeyList[kNuXSecDataSets] = {
/* 0 */ "ANL_12FT,1;ANL_12FT,3;BEBC,12;BNL_7FT,3;FNAL_15FT,3;Gargamelle,2;SERP_A1,0;SERP_A1,1;SKAT,8",
/* 1 */ "ANL_12FT,1;ANL_12FT,3;BEBC,12;BNL_7FT,3;FNAL_15FT,3",
/* 2 */ "Gargamelle,2;SERP_A1,0;SERP_A1,1;SKAT,8",
/* 3 */ "BNL_7FT,2;Gargamelle,3;Gargamelle,5;SERP_A1,2;SKAT,9",
/* 4 */ "BNL_7FT,2",
/* 5 */ "Gargamelle,3;Gargamelle,5;SERP_A1,2;SKAT,9",
/* 6 */ "ANL_12FT,0;ANL_12FT,5;ANL_12FT,8;BEBC,4;BEBC,9;BEBC,13;BNL_7FT,5;FNAL_15FT,0;Gargamelle,4;SKAT,4;SKAT,5",
/* 7 */ "ANL_12FT,2;ANL_12FT,4;BEBC,0;BEBC,2;BEBC,5;BEBC,8;BNL_7FT,0;BNL_7FT,4;CCFR,2;CCFRR,0;CHARM,0;CHARM,4;FNAL_15FT,1;FNAL_15FT,2;Gargamelle,0;Gargamelle,10;Gargamelle,12;IHEP_ITEP,0;IHEP_ITEP,2;IHEP_JINR,0;SKAT,0",
/* 8 */ "BEBC,1;BEBC,3;BEBC,6;BEBC,7;BNL_7FT,1;CCFR,3;CHARM,1;CHARM,5;FNAL_15FT,4;FNAL_15FT,5;Gargamelle,1;Gargamelle,11;Gargamelle,13;IHEP_ITEP,1;IHEP_ITEP,3;IHEP_JINR,1",
/* 9 */ "ANL_12FT,11;BNL_7FT,8",
/*10 */ "ANL_12FT,12",
/*11 */ "ANL_12FT,13"
};
float kNuXSecERange[kNuXSecDataSets][2] = {
/* 0 */ { 0.1,  30.0},
/* 1 */ { 0.1,  30.0},
/* 2 */ { 0.1,  30.0},
/* 3 */ { 0.1,  30.0},
/* 4 */ { 0.1,  30.0},
/* 5 */ { 0.1,  30.0},
/* 6 */ { 0.1,  30.0},
/* 7 */ {10.0, 120.0},
/* 8 */ {10.0, 120.0},
/* 9 */ { 1.0, 120.0},
/*10 */ { 1.0, 120.0},
/*11 */ { 1.0, 120.0}
};

// function prototypes
void                        GeneratePlots      (void);
void                        GeneratePlots_1dir (string dirname);
void                        CompareWithData    (void);
DBQueryString               FormQuery          (const char * key_list, float emin,  float emax);
DBTable<DBNuXSecTableRow> * GetNuVldData       (int iset);
TGraph *                    NuXSecPrediction   (int iset);
TH1F *                      DrawFrame          (TGraph * gr0, TGraph * gr1, TCanvas * c);
void                        Format             (TGraph* gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz);
void                        Draw               (TGraph* gr, const char * opt);
void                        GetCommandLineArgs (int argc, char ** argv);
void                        PrintSyntax        (void);
bool                        CheckRootFilename  (string filename);
string                      OutputFileName     (string input_file_name);

// command-line arguments
string gOptXSecFilename_curr = "";  // (-f) input ROOT cross section file
string gOptXSecFilename_ref0 = "";  // (-r) input ROOT cross section file (reference)
bool   gOptHaveRef;
bool   gOptCmpWithData;
string gOptDbURL;
string gOptDbUser;
string gOptDbPasswd;

// dbase information
const char * kDefDbURL = "mysql://localhost/NuScat";  

// globals
TFile *  gXSecFile_curr = 0;
TFile *  gXSecFile_ref0 = 0;
DBI *    dbi            = 0;

//_________________________________________________________________________________
int main(int argc, char ** argv)
{
  GetCommandLineArgs (argc,argv);

  // Generate cross section plots
  // Compare with reference cross section plots (if any)
  GeneratePlots();
  
  // Compare against NuVld data sets
  if(gOptCmpWithData) 
	CompareWithData();

  LOG("gvldtest", pINFO)  << "Done!";
  return 0;
}
//_________________________________________________________________________________
// Actual plotting
//.................................................................................
void GeneratePlots(void)
{
  // Open files
  gXSecFile_curr = new TFile(gOptXSecFilename_curr.c_str(), "read");
  gXSecFile_ref0 = (gOptHaveRef) ?
                   new TFile(gOptXSecFilename_ref0.c_str(), "read") : 0;

  // Get list of directories in the input file
  TList * dirnames = gXSecFile_curr->GetListOfKeys();

  // Loop over directories & generate plots for each one
  int ndir = dirnames->GetEntries();
  for(int idir=0; idir<ndir; idir++) {
    TObjString * dirname = (TObjString*) dirnames->At(idir);
    GeneratePlots_1dir(dirname->GetString().Data());
  }
}
//_________________________________________________________________________________
void GeneratePlots_1dir(string dirname)
{
  LOG("gvldtest", pINFO)  << "Plotting graphs from directory: " << dirname;

  TDirectory * dir_curr  = (TDirectory *) gXSecFile_curr->Get(dirname.c_str());
  TDirectory * dir_ref0  = (gXSecFile_ref0) ?
                           (TDirectory *) gXSecFile_ref0->Get(dirname.c_str()) : 0;
  if(!dir_ref0) {
    LOG("gvldtest", pINFO)  << "No reference plots will be shown.";
  }

  //
  //

  bool is_nu    = false;
  bool is_nubar = false;

  string snu;
  if      ( dirname.find ("nu_e_bar")   != string::npos ) { snu="#bar{#nu_{e}}";    is_nubar = true; }
  else if ( dirname.find ("nu_e")       != string::npos ) { snu="#nu_{e}";          is_nu    = true; }
  else if ( dirname.find ("nu_mu_bar")  != string::npos ) { snu="#bar{#nu_{#mu}}";  is_nubar = true; }
  else if ( dirname.find ("nu_mu")      != string::npos ) { snu="#nu_{#mu}";        is_nu    = true; }
  else if ( dirname.find ("nu_tau_bar") != string::npos ) { snu="#bar{#nu_{#tau}}"; is_nubar = true; }
  else if ( dirname.find ("nu_tau")     != string::npos ) { snu="#nu_{#tau}";       is_nu    = true; }

  const char * neutrino = snu.c_str();

  const char * target = "(Z,A)";

  LOG("gvldtest", pINFO)  << "Neutrino : " << neutrino;
  LOG("gvldtest", pINFO)  << "Target   : " << target;

  // Start plotting...
  //

  TCanvas * c = new TCanvas("c","",20,20,500,650);
  c->SetBorderMode(0);
  c->SetFillColor(0);
  c->SetGridx();
  c->SetGridy();

  //TH1F * hf = 0;
  TLegend * l  = new TLegend(0.80,0.20,0.99,0.99);
  TLegend * ls = new TLegend(0.15,0.85,0.55,0.95);
  l ->SetFillColor(0);
  ls->SetFillColor(0);
  ls->SetBorderSize(1);
  TPostScript * ps = new TPostScript("gnuxs.ps", 111);

  //
  // header
  //
  ps->NewPage();
  c->Range(0,0,100,100);
  TPavesText hdr(10,40,90,70,3,"tr");
  hdr.AddText("GENIE cross sections comparison plots");
  hdr.AddText(" ");
  hdr.AddText(" ");
  hdr.AddText(dirname.c_str());
  hdr.AddText(" ");
  hdr.AddText(" ");
  hdr.AddText(" ");
  hdr.Draw();
  c->Update();
  TPavesText title(10,40,90,70,1,"ndc");

  c->SetLogx();
  c->SetLogy();

  //
  // start plotting cross section graphs
  //

  if(is_nu) {

    // QEL CC v+n(A)
    {
          TGraph * gr_cc_n_curr = (TGraph*) dir_curr->Get("qel_cc_n");
          TGraph * gr_cc_n_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("qel_cc_n") : 0;
          DrawFrame (gr_cc_n_curr, gr_cc_n_ref0, c);
          Draw (gr_cc_n_curr, "L");
          Draw (gr_cc_n_ref0, "P");
          ls->Clear();
          ls->SetHeader(Form("QEL-CC / %s+n%s",neutrino, target));
          ls->Draw();
          c->Update();
    }
    // QEL NC v+n(A)
    {
	  TGraph * gr_nc_n_curr = (TGraph*) dir_curr->Get("qel_nc_n");
	  TGraph * gr_nc_n_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("qel_nc_n") : 0;
          DrawFrame (gr_nc_n_curr, gr_nc_n_ref0, c);
          Draw (gr_nc_n_curr, "L");
          Draw (gr_nc_n_ref0, "P");
          ls->Clear();
          ls->SetHeader(Form("QEL-NC / %s+p%s",neutrino,target));
          ls->Draw();
	  c->Update();
    }
    // QEL NC v+p(A)
    {
	  TGraph * gr_nc_p_curr = (TGraph*) dir_curr->Get("qel_nc_p");
	  TGraph * gr_nc_p_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("qel_nc_p") : 0;
          DrawFrame (gr_nc_p_curr, gr_nc_p_ref0, c);
          Draw (gr_nc_p_curr, "L");
          Draw (gr_nc_p_ref0, "P");
          ls->Clear();
          ls->SetHeader(Form("QEL-NC / %s+p%s",neutrino,target));
          ls->Draw();
	  c->Update();
    }
    // RES CC v+p(A)
    {
          TGraph * gr_cc_p_tot_curr = (TGraph*) dir_curr->Get("res_cc_p");
          TGraph * gr_cc_p_1_curr   = (TGraph*) dir_curr->Get("res_cc_p_1232P33");
          TGraph * gr_cc_p_2_curr   = (TGraph*) dir_curr->Get("res_cc_p_1620S31");
          TGraph * gr_cc_p_3_curr   = (TGraph*) dir_curr->Get("res_cc_p_1700D33");
          TGraph * gr_cc_p_4_curr   = (TGraph*) dir_curr->Get("res_cc_p_1910P31");
          TGraph * gr_cc_p_5_curr   = (TGraph*) dir_curr->Get("res_cc_p_1920P33");
          TGraph * gr_cc_p_6_curr   = (TGraph*) dir_curr->Get("res_cc_p_1905F35");
          TGraph * gr_cc_p_7_curr   = (TGraph*) dir_curr->Get("res_cc_p_1950F37");
          TGraph * gr_cc_p_tot_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p")         : 0;
          TGraph * gr_cc_p_1_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1232P33") : 0;
          TGraph * gr_cc_p_2_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1620S31") : 0;
          TGraph * gr_cc_p_3_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1700D33") : 0;
          TGraph * gr_cc_p_4_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1910P31") : 0;
          TGraph * gr_cc_p_5_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1920P33") : 0;
          TGraph * gr_cc_p_6_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1905F35") : 0;
          TGraph * gr_cc_p_7_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1950F37") : 0;
          Format (gr_cc_p_1_curr,  2, -1, -1, -1,  -1,  -1.0);
          Format (gr_cc_p_2_curr,  3, -1, -1, -1,  -1,  -1.0);
          Format (gr_cc_p_3_curr,  4, -1, -1, -1,  -1,  -1.0);
          Format (gr_cc_p_4_curr,  5, -1, -1, -1,  -1,  -1.0);
          Format (gr_cc_p_5_curr,  6, -1, -1, -1,  -1,  -1.0);
          Format (gr_cc_p_6_curr,  7, -1, -1, -1,  -1,  -1.0);
          Format (gr_cc_p_7_curr,  8, -1, -1, -1,  -1,  -1.0);
          Format (gr_cc_p_1_ref0, -1, -1, -1,  2,  23,   1.3);
          Format (gr_cc_p_2_ref0, -1, -1, -1,  3,  23,   1.3);
          Format (gr_cc_p_3_ref0, -1, -1, -1,  4,  23,   1.3);
          Format (gr_cc_p_4_ref0, -1, -1, -1,  5,  23,   1.3);
          Format (gr_cc_p_5_ref0, -1, -1, -1,  6,  23,   1.3);
          Format (gr_cc_p_6_ref0, -1, -1, -1,  7,  23,   1.3);
          Format (gr_cc_p_7_ref0, -1, -1, -1,  8,  23,   1.3);
          DrawFrame (gr_cc_p_tot_curr, gr_cc_p_tot_ref0, c);
          Draw (gr_cc_p_tot_curr, "L");
          Draw (gr_cc_p_1_curr,   "L");
          Draw (gr_cc_p_2_curr,   "L");
          Draw (gr_cc_p_3_curr,   "L");
          Draw (gr_cc_p_4_curr,   "L");
          Draw (gr_cc_p_5_curr,   "L");
          Draw (gr_cc_p_6_curr,   "L");
          Draw (gr_cc_p_7_curr,   "L");
          Draw (gr_cc_p_tot_ref0, "P");
          Draw (gr_cc_p_1_ref0,   "P");
          Draw (gr_cc_p_2_ref0,   "P");
          Draw (gr_cc_p_3_ref0,   "P");
          Draw (gr_cc_p_4_ref0,   "P");
          Draw (gr_cc_p_5_ref0,   "P");
          Draw (gr_cc_p_6_ref0,   "P");
          Draw (gr_cc_p_7_ref0,   "P");
          l->AddEntry(gr_cc_p_tot_curr, "total",     "L");
          l->AddEntry(gr_cc_p_1_curr,   "P33(1232)", "L");
          l->AddEntry(gr_cc_p_2_curr,   "S31(1620)", "L");
          l->AddEntry(gr_cc_p_3_curr,   "D33(1700)", "L");
          l->AddEntry(gr_cc_p_4_curr,   "P31(1910)", "L");
          l->AddEntry(gr_cc_p_5_curr,   "P33(1920)", "L");
          l->AddEntry(gr_cc_p_6_curr,   "F35(1905)", "L");
          l->AddEntry(gr_cc_p_7_curr,   "P37(1950)", "L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("RES-CC / %s+p%s",neutrino,target));
          ls->Draw();
          c->Update();
    }
    // RES CC v+n(A)
    {
          TGraph * gr_cc_n_tot_curr = (TGraph*) dir_curr->Get("res_cc_n");
          TGraph * gr_cc_n_1_curr   = (TGraph*) dir_curr->Get("res_cc_n_1232P33");
          TGraph * gr_cc_n_2_curr   = (TGraph*) dir_curr->Get("res_cc_n_1535S11");
          TGraph * gr_cc_n_3_curr   = (TGraph*) dir_curr->Get("res_cc_n_1520D13");
          TGraph * gr_cc_n_4_curr   = (TGraph*) dir_curr->Get("res_cc_n_1650S11");
          TGraph * gr_cc_n_5_curr   = (TGraph*) dir_curr->Get("res_cc_n_1700D13");
          TGraph * gr_cc_n_6_curr   = (TGraph*) dir_curr->Get("res_cc_n_1675D15");
          TGraph * gr_cc_n_7_curr   = (TGraph*) dir_curr->Get("res_cc_n_1620S31");
          TGraph * gr_cc_n_8_curr   = (TGraph*) dir_curr->Get("res_cc_n_1700D33");
          TGraph * gr_cc_n_9_curr   = (TGraph*) dir_curr->Get("res_cc_n_1440P11");
          TGraph * gr_cc_n_10_curr  = (TGraph*) dir_curr->Get("res_cc_n_1720P13");
          TGraph * gr_cc_n_11_curr  = (TGraph*) dir_curr->Get("res_cc_n_1680F15");
          TGraph * gr_cc_n_12_curr  = (TGraph*) dir_curr->Get("res_cc_n_1910P31");
          TGraph * gr_cc_n_13_curr  = (TGraph*) dir_curr->Get("res_cc_n_1920P33");
          TGraph * gr_cc_n_14_curr  = (TGraph*) dir_curr->Get("res_cc_n_1905F35");
          TGraph * gr_cc_n_15_curr  = (TGraph*) dir_curr->Get("res_cc_n_1950F37");
          TGraph * gr_cc_n_16_curr  = (TGraph*) dir_curr->Get("res_cc_n_1710P11");
          TGraph * gr_cc_n_tot_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n")         : 0;
          TGraph * gr_cc_n_1_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1232P33") : 0;
          TGraph * gr_cc_n_2_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1535S11") : 0;
          TGraph * gr_cc_n_3_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1520D13") : 0;
          TGraph * gr_cc_n_4_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1650S11") : 0;
          TGraph * gr_cc_n_5_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1700D13") : 0;
          TGraph * gr_cc_n_6_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1675D15") : 0;
          TGraph * gr_cc_n_7_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1620S31") : 0;
          TGraph * gr_cc_n_8_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1700D33") : 0;
          TGraph * gr_cc_n_9_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1440P11") : 0;
          TGraph * gr_cc_n_10_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1720P13") : 0;
          TGraph * gr_cc_n_11_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1680F15") : 0;
          TGraph * gr_cc_n_12_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1910P31") : 0;
          TGraph * gr_cc_n_13_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1920P33") : 0;
          TGraph * gr_cc_n_14_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1905F35") : 0;
          TGraph * gr_cc_n_15_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1950F37") : 0;
          TGraph * gr_cc_n_16_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1710P11") : 0;
          Format (gr_cc_n_1_curr,   2,  1,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_2_curr,   3,  1,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_3_curr,   4,  1,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_4_curr,   5,  1,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_5_curr,   6,  1,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_6_curr,   7,  1,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_7_curr,   8,  1,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_8_curr,   9,  1,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_9_curr,   2,  2,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_10_curr,  3,  2,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_11_curr,  4,  2,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_12_curr,  5,  2,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_13_curr,  6,  2,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_14_curr,  7,  2,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_15_curr,  8,  2,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_16_curr,  9,  2,  -1,  -1, -1, -1.0); 
          Format (gr_cc_n_1_ref0,  -1,  1,  -1,  2,  23,  1.3); 
          Format (gr_cc_n_2_ref0,  -1,  1,  -1,  3,  23,  1.3); 
          Format (gr_cc_n_3_ref0,  -1,  1,  -1,  4,  23,  1.3); 
          Format (gr_cc_n_4_ref0,  -1,  1,  -1,  5,  23,  1.3); 
          Format (gr_cc_n_5_ref0,  -1,  1,  -1,  6,  23,  1.3); 
          Format (gr_cc_n_6_ref0,  -1,  1,  -1,  7,  23,  1.3); 
          Format (gr_cc_n_7_ref0,  -1,  1,  -1,  8,  23,  1.3); 
          Format (gr_cc_n_8_ref0,  -1,  1,  -1,  9,  23,  1.3); 
          Format (gr_cc_n_9_ref0,  -1,  2,  -1,  2,  22,  1.3); 
          Format (gr_cc_n_10_ref0, -1,  2,  -1,  3,  22,  1.3); 
          Format (gr_cc_n_11_ref0, -1,  2,  -1,  4,  22,  1.3); 
          Format (gr_cc_n_12_ref0, -1,  2,  -1,  5,  22,  1.3); 
          Format (gr_cc_n_13_ref0, -1,  2,  -1,  6,  22,  1.3); 
          Format (gr_cc_n_14_ref0, -1,  2,  -1,  7,  22,  1.3); 
          Format (gr_cc_n_15_ref0, -1,  2,  -1,  8,  22,  1.3); 
          Format (gr_cc_n_16_ref0, -1,  2,  -1,  9,  22,  1.3); 
          DrawFrame (gr_cc_n_tot_curr, gr_cc_n_tot_ref0, c);
          Draw (gr_cc_n_tot_curr,  "L");
          Draw (gr_cc_n_1_curr,    "L");
          Draw (gr_cc_n_2_curr,    "L");
          Draw (gr_cc_n_3_curr,    "L");
          Draw (gr_cc_n_4_curr,    "L");
          Draw (gr_cc_n_5_curr,    "L");
          Draw (gr_cc_n_6_curr,    "L");
          Draw (gr_cc_n_7_curr,    "L");
          Draw (gr_cc_n_8_curr,    "L");
          Draw (gr_cc_n_9_curr,    "L");
          Draw (gr_cc_n_10_curr,   "L");
          Draw (gr_cc_n_11_curr,   "L");
          Draw (gr_cc_n_12_curr,   "L");
          Draw (gr_cc_n_13_curr,   "L");
          Draw (gr_cc_n_14_curr,   "L");
          Draw (gr_cc_n_15_curr,   "L");
          Draw (gr_cc_n_16_curr,   "L");
          Draw (gr_cc_n_tot_ref0,  "P");
          Draw (gr_cc_n_1_ref0,    "P");
          Draw (gr_cc_n_2_ref0,    "P");
          Draw (gr_cc_n_3_ref0,    "P");
          Draw (gr_cc_n_4_ref0,    "P");
          Draw (gr_cc_n_5_ref0,    "P");
          Draw (gr_cc_n_6_ref0,    "P");
          Draw (gr_cc_n_7_ref0,    "P");
          Draw (gr_cc_n_8_ref0,    "P");
          Draw (gr_cc_n_9_ref0,    "P");
          Draw (gr_cc_n_10_ref0,   "P");
          Draw (gr_cc_n_11_ref0,   "P");
          Draw (gr_cc_n_12_ref0,   "P");
          Draw (gr_cc_n_13_ref0,   "P");
          Draw (gr_cc_n_14_ref0,   "P");
          Draw (gr_cc_n_15_ref0,   "P");
          Draw (gr_cc_n_16_ref0,   "P");
          l->Clear();
          l->AddEntry(gr_cc_n_tot_curr,  "total",     "L");
          l->AddEntry(gr_cc_n_1_curr,    "(1232)P33", "L");
          l->AddEntry(gr_cc_n_2_curr,    "(1535)S11", "L");
          l->AddEntry(gr_cc_n_3_curr,    "(1520)D13", "L");
          l->AddEntry(gr_cc_n_4_curr,    "(1650)S11", "L");
          l->AddEntry(gr_cc_n_5_curr,    "(1700)D13", "L");
          l->AddEntry(gr_cc_n_6_curr,    "(1675)D15", "L");
          l->AddEntry(gr_cc_n_7_curr,    "(1620)S31", "L");
          l->AddEntry(gr_cc_n_8_curr,    "(1700)D33", "L");
          l->AddEntry(gr_cc_n_9_curr,    "(1440)P11", "L");
          l->AddEntry(gr_cc_n_10_curr,   "(1720)P13", "L");
          l->AddEntry(gr_cc_n_11_curr,   "(1680)F15", "L");
          l->AddEntry(gr_cc_n_12_curr,   "(1910)P31", "L");
          l->AddEntry(gr_cc_n_13_curr,   "(1920)P33", "L");
          l->AddEntry(gr_cc_n_14_curr,   "(1905)F35", "L");
          l->AddEntry(gr_cc_n_15_curr,   "(1950)F37", "L");
          l->AddEntry(gr_cc_n_16_curr,   "(1710)P11", "L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("RES-CC / %s+n%s",neutrino,target));
          ls->Draw();
	  c->Update();
     } 
     // RES NC v+p(A)
     {
          TGraph * gr_nc_p_tot_curr = (TGraph*) dir_curr->Get("res_nc_p");
          TGraph * gr_nc_p_1_curr   = (TGraph*) dir_curr->Get("res_nc_p_1232P33");
          TGraph * gr_nc_p_2_curr   = (TGraph*) dir_curr->Get("res_nc_p_1535S11");
          TGraph * gr_nc_p_3_curr   = (TGraph*) dir_curr->Get("res_nc_p_1520D13");
          TGraph * gr_nc_p_4_curr   = (TGraph*) dir_curr->Get("res_nc_p_1650S11");
          TGraph * gr_nc_p_5_curr   = (TGraph*) dir_curr->Get("res_nc_p_1700D13");
          TGraph * gr_nc_p_6_curr   = (TGraph*) dir_curr->Get("res_nc_p_1675D15");
          TGraph * gr_nc_p_7_curr   = (TGraph*) dir_curr->Get("res_nc_p_1620S31");
          TGraph * gr_nc_p_8_curr   = (TGraph*) dir_curr->Get("res_nc_p_1700D33");
          TGraph * gr_nc_p_9_curr   = (TGraph*) dir_curr->Get("res_nc_p_1440P11");
          TGraph * gr_nc_p_10_curr  = (TGraph*) dir_curr->Get("res_nc_p_1720P13");
          TGraph * gr_nc_p_11_curr  = (TGraph*) dir_curr->Get("res_nc_p_1680F15");
          TGraph * gr_nc_p_12_curr  = (TGraph*) dir_curr->Get("res_nc_p_1910P31");
          TGraph * gr_nc_p_13_curr  = (TGraph*) dir_curr->Get("res_nc_p_1920P33");
          TGraph * gr_nc_p_14_curr  = (TGraph*) dir_curr->Get("res_nc_p_1905F35");
          TGraph * gr_nc_p_15_curr  = (TGraph*) dir_curr->Get("res_nc_p_1950F37");
          TGraph * gr_nc_p_16_curr  = (TGraph*) dir_curr->Get("res_nc_p_1710P11");
          TGraph * gr_nc_p_tot_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p")         : 0;
          TGraph * gr_nc_p_1_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1232P33") : 0;
          TGraph * gr_nc_p_2_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1535S11") : 0;
          TGraph * gr_nc_p_3_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1520D13") : 0;
          TGraph * gr_nc_p_4_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1650S11") : 0;
          TGraph * gr_nc_p_5_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1700D13") : 0;
          TGraph * gr_nc_p_6_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1675D15") : 0;
          TGraph * gr_nc_p_7_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1620S31") : 0; 
          TGraph * gr_nc_p_8_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1700D33") : 0; 
          TGraph * gr_nc_p_9_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1440P11") : 0;
          TGraph * gr_nc_p_10_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1720P13") : 0;
          TGraph * gr_nc_p_11_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1680F15") : 0;
          TGraph * gr_nc_p_12_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1910P31") : 0;
          TGraph * gr_nc_p_13_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1920P33") : 0;
          TGraph * gr_nc_p_14_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1905F35") : 0; 
          TGraph * gr_nc_p_15_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1950F37") : 0;
          TGraph * gr_nc_p_16_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_p_1710P11") : 0;
          Format (gr_nc_p_1_curr,  2, 1, -1, -1, -1, -1);  
          Format (gr_nc_p_2_curr,  3, 1, -1, -1, -1, -1); 
          Format (gr_nc_p_3_curr,  4, 1, -1, -1, -1, -1); 
          Format (gr_nc_p_4_curr,  5, 1, -1, -1, -1, -1); 
          Format (gr_nc_p_5_curr,  6, 1, -1, -1, -1, -1); 
          Format (gr_nc_p_6_curr,  7, 1, -1, -1, -1, -1); 
          Format (gr_nc_p_7_curr,  8, 1, -1, -1, -1, -1); 
          Format (gr_nc_p_8_curr,  9, 1, -1, -1, -1, -1); 
          Format (gr_nc_p_9_curr,  2, 2, -1, -1, -1, -1); 
          Format (gr_nc_p_10_curr, 3, 2, -1, -1, -1, -1); 
          Format (gr_nc_p_11_curr, 4, 2, -1, -1, -1, -1); 
          Format (gr_nc_p_12_curr, 5, 2, -1, -1, -1, -1); 
          Format (gr_nc_p_13_curr, 6, 2, -1, -1, -1, -1); 
          Format (gr_nc_p_14_curr, 7, 2, -1, -1, -1, -1); 
          Format (gr_nc_p_15_curr, 8, 2, -1, -1, -1, -1); 
          Format (gr_nc_p_16_curr, 9, 2, -1, -1, -1, -1); 
          Format (gr_nc_p_1_ref0,  -1, 1, -1, 2, 23, 1.3); 
          Format (gr_nc_p_2_ref0,  -1, 1, -1, 3, 23, 1.3); 
          Format (gr_nc_p_3_ref0,  -1, 1, -1, 4, 23, 1.3); 
          Format (gr_nc_p_4_ref0,  -1, 1, -1, 5, 23, 1.3); 
          Format (gr_nc_p_5_ref0,  -1, 1, -1, 6, 23, 1.3); 
          Format (gr_nc_p_6_ref0,  -1, 1, -1, 7, 23, 1.3); 
          Format (gr_nc_p_7_ref0,  -1, 1, -1, 8, 23, 1.3); 
          Format (gr_nc_p_8_ref0,  -1, 1, -1, 9, 23, 1.3); 
          Format (gr_nc_p_9_ref0,  -1, 2, -1, 2, 22, 1.3); 
          Format (gr_nc_p_10_ref0, -1, 2, -1, 3, 22, 1.3); 
          Format (gr_nc_p_11_ref0, -1, 2, -1, 4, 22, 1.3); 
          Format (gr_nc_p_12_ref0, -1, 2, -1, 5, 22, 1.3); 
          Format (gr_nc_p_13_ref0, -1, 2, -1, 6, 22, 1.3); 
          Format (gr_nc_p_14_ref0, -1, 2, -1, 7, 22, 1.3); 
          Format (gr_nc_p_15_ref0, -1, 2, -1, 8, 22, 1.3); 
          Format (gr_nc_p_16_ref0, -1, 2, -1, 9, 22, 1.3); 
          DrawFrame (gr_nc_p_tot_curr, gr_nc_p_tot_ref0, c);
          Draw (gr_nc_p_tot_curr, "L");
          Draw (gr_nc_p_1_curr,   "L"); 
          Draw (gr_nc_p_2_curr,   "L"); 
          Draw (gr_nc_p_3_curr,   "L"); 
          Draw (gr_nc_p_4_curr,   "L"); 
          Draw (gr_nc_p_5_curr,   "L"); 
          Draw (gr_nc_p_6_curr,   "L"); 
          Draw (gr_nc_p_7_curr,   "L"); 
          Draw (gr_nc_p_8_curr,   "L"); 
          Draw (gr_nc_p_9_curr,   "L"); 
          Draw (gr_nc_p_10_curr,  "L"); 
          Draw (gr_nc_p_11_curr,  "L"); 
          Draw (gr_nc_p_12_curr,  "L"); 
          Draw (gr_nc_p_13_curr,  "L"); 
          Draw (gr_nc_p_14_curr,  "L"); 
          Draw (gr_nc_p_15_curr,  "L"); 
          Draw (gr_nc_p_16_curr,  "L"); 
          Draw (gr_nc_p_tot_ref0, "P");
          Draw (gr_nc_p_1_ref0,   "P"); 
          Draw (gr_nc_p_2_ref0,   "P"); 
          Draw (gr_nc_p_3_ref0,   "P"); 
          Draw (gr_nc_p_4_ref0,   "P"); 
          Draw (gr_nc_p_5_ref0,   "P"); 
          Draw (gr_nc_p_6_ref0,   "P"); 
          Draw (gr_nc_p_7_ref0,   "P"); 
          Draw (gr_nc_p_8_ref0,   "P"); 
          Draw (gr_nc_p_9_ref0,   "P"); 
          Draw (gr_nc_p_10_ref0,  "P"); 
          Draw (gr_nc_p_11_ref0,  "P"); 
          Draw (gr_nc_p_12_ref0,  "P"); 
          Draw (gr_nc_p_13_ref0,  "P"); 
          Draw (gr_nc_p_14_ref0,  "P"); 
          Draw (gr_nc_p_15_ref0,  "P"); 
          Draw (gr_nc_p_16_ref0,  "P"); 
          l->Clear();
          l->AddEntry(gr_nc_p_tot_curr, "total",     "L");
          l->AddEntry(gr_nc_p_1_curr,   "(1232)P33", "L");
          l->AddEntry(gr_nc_p_2_curr,   "(1535)S11", "L");
          l->AddEntry(gr_nc_p_3_curr,   "(1520)D13", "L");
          l->AddEntry(gr_nc_p_4_curr,   "(1650)S11", "L");
          l->AddEntry(gr_nc_p_5_curr,   "(1700)D13", "L");
          l->AddEntry(gr_nc_p_6_curr,   "(1675)D15", "L");
          l->AddEntry(gr_nc_p_7_curr,   "(1620)S31", "L");
          l->AddEntry(gr_nc_p_8_curr,   "(1700)D33", "L");
          l->AddEntry(gr_nc_p_9_curr,   "(1440)P11", "L");
          l->AddEntry(gr_nc_p_10_curr,  "(1720)P13", "L");
          l->AddEntry(gr_nc_p_11_curr,  "(1680)F15", "L");
          l->AddEntry(gr_nc_p_12_curr,  "(1910)P31", "L");
          l->AddEntry(gr_nc_p_13_curr,  "(1920)P33", "L");
          l->AddEntry(gr_nc_p_14_curr,  "(1905)F35", "L");
          l->AddEntry(gr_nc_p_15_curr,  "(1950)F37", "L");
          l->AddEntry(gr_nc_p_16_curr,  "(1710)P11", "L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("RES-NC / %s+p%s",neutrino,target));
          ls->Draw();
	  c->Update();
     } 
     // RES NC v+n(A)
     {
	  TGraph * gr_nc_n_tot_curr = (TGraph*) dir_curr->Get("res_nc_n");
          TGraph * gr_nc_n_1_curr   = (TGraph*) dir_curr->Get("res_nc_n_1232P33");
          TGraph * gr_nc_n_2_curr   = (TGraph*) dir_curr->Get("res_nc_n_1535S11");
          TGraph * gr_nc_n_3_curr   = (TGraph*) dir_curr->Get("res_nc_n_1520D13");
          TGraph * gr_nc_n_4_curr   = (TGraph*) dir_curr->Get("res_nc_n_1650S11");
          TGraph * gr_nc_n_5_curr   = (TGraph*) dir_curr->Get("res_nc_n_1700D13");
          TGraph * gr_nc_n_6_curr   = (TGraph*) dir_curr->Get("res_nc_n_1675D15");
          TGraph * gr_nc_n_7_curr   = (TGraph*) dir_curr->Get("res_nc_n_1620S31");
          TGraph * gr_nc_n_8_curr   = (TGraph*) dir_curr->Get("res_nc_n_1700D33");
          TGraph * gr_nc_n_9_curr   = (TGraph*) dir_curr->Get("res_nc_n_1440P11");
          TGraph * gr_nc_n_10_curr  = (TGraph*) dir_curr->Get("res_nc_n_1720P13");
          TGraph * gr_nc_n_11_curr  = (TGraph*) dir_curr->Get("res_nc_n_1680F15");
          TGraph * gr_nc_n_12_curr  = (TGraph*) dir_curr->Get("res_nc_n_1910P31");
          TGraph * gr_nc_n_13_curr  = (TGraph*) dir_curr->Get("res_nc_n_1920P33");
          TGraph * gr_nc_n_14_curr  = (TGraph*) dir_curr->Get("res_nc_n_1905F35");
          TGraph * gr_nc_n_15_curr  = (TGraph*) dir_curr->Get("res_nc_n_1950F37");
          TGraph * gr_nc_n_16_curr  = (TGraph*) dir_curr->Get("res_nc_n_1710P11");
	  TGraph * gr_nc_n_tot_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n")         : 0;
          TGraph * gr_nc_n_1_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1232P33") : 0;
          TGraph * gr_nc_n_2_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1535S11") : 0;
          TGraph * gr_nc_n_3_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1520D13") : 0;
          TGraph * gr_nc_n_4_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1650S11") : 0;
          TGraph * gr_nc_n_5_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1700D13") : 0;
          TGraph * gr_nc_n_6_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1675D15") : 0;
          TGraph * gr_nc_n_7_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1620S31") : 0;
          TGraph * gr_nc_n_8_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1700D33") : 0;
          TGraph * gr_nc_n_9_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1440P11") : 0;
          TGraph * gr_nc_n_10_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1720P13") : 0;
          TGraph * gr_nc_n_11_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1680F15") : 0;
          TGraph * gr_nc_n_12_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1910P31") : 0;
          TGraph * gr_nc_n_13_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1920P33") : 0;
          TGraph * gr_nc_n_14_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1905F35") : 0;
          TGraph * gr_nc_n_15_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1950F37") : 0;
          TGraph * gr_nc_n_16_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_nc_n_1710P11") : 0;
          Format (gr_nc_n_1_curr,  2, 1, -1, -1, -1, -1); 
          Format (gr_nc_n_2_curr,  3, 1, -1, -1, -1, -1); 
          Format (gr_nc_n_3_curr,  4, 1, -1, -1, -1, -1); 
          Format (gr_nc_n_4_curr,  5, 1, -1, -1, -1, -1); 
          Format (gr_nc_n_5_curr,  6, 1, -1, -1, -1, -1); 
          Format (gr_nc_n_6_curr,  7, 1, -1, -1, -1, -1); 
          Format (gr_nc_n_7_curr,  8, 1, -1, -1, -1, -1); 
          Format (gr_nc_n_8_curr,  9, 1, -1, -1, -1, -1); 
          Format (gr_nc_n_9_curr,  2, 2, -1, -1, -1, -1); 
          Format (gr_nc_n_10_curr, 3, 2, -1, -1, -1, -1); 
          Format (gr_nc_n_11_curr, 4, 2, -1, -1, -1, -1); 
          Format (gr_nc_n_12_curr, 5, 2, -1, -1, -1, -1); 
          Format (gr_nc_n_13_curr, 6, 2, -1, -1, -1, -1); 
          Format (gr_nc_n_14_curr, 7, 2, -1, -1, -1, -1); 
          Format (gr_nc_n_15_curr, 8, 2, -1, -1, -1, -1); 
          Format (gr_nc_n_16_curr, 9, 2, -1, -1, -1, -1); 
          Format (gr_nc_n_1_ref0,  -1, 1, -1, 2, 23, 1.3); 
          Format (gr_nc_n_2_ref0,  -1, 1, -1, 3, 23, 1.3); 
          Format (gr_nc_n_3_ref0,  -1, 1, -1, 4, 23, 1.3); 
          Format (gr_nc_n_4_ref0,  -1, 1, -1, 5, 23, 1.3); 
          Format (gr_nc_n_5_ref0,  -1, 1, -1, 6, 23, 1.3); 
          Format (gr_nc_n_6_ref0,  -1, 1, -1, 7, 23, 1.3); 
          Format (gr_nc_n_7_ref0,  -1, 1, -1, 8, 23, 1.3); 
          Format (gr_nc_n_8_ref0,  -1, 1, -1, 9, 23, 1.3); 
          Format (gr_nc_n_9_ref0,  -1, 2, -1, 2, 22, 1.3); 
          Format (gr_nc_n_10_ref0, -1, 2, -1, 3, 22, 1.3); 
          Format (gr_nc_n_11_ref0, -1, 2, -1, 4, 22, 1.3); 
          Format (gr_nc_n_12_ref0, -1, 2, -1, 5, 22, 1.3); 
          Format (gr_nc_n_13_ref0, -1, 2, -1, 6, 22, 1.3); 
          Format (gr_nc_n_14_ref0, -1, 2, -1, 7, 22, 1.3); 
          Format (gr_nc_n_15_ref0, -1, 2, -1, 8, 22, 1.3); 
          Format (gr_nc_n_16_ref0, -1, 2, -1, 9, 22, 1.3); 
          DrawFrame (gr_nc_n_tot_curr, gr_nc_n_tot_ref0, c);
          Draw (gr_nc_n_tot_curr, "L");
          Draw (gr_nc_n_1_curr,   "L"); 
          Draw (gr_nc_n_2_curr,   "L"); 
          Draw (gr_nc_n_3_curr,   "L"); 
          Draw (gr_nc_n_4_curr,   "L"); 
          Draw (gr_nc_n_5_curr,   "L"); 
          Draw (gr_nc_n_6_curr,   "L"); 
          Draw (gr_nc_n_7_curr,   "L"); 
          Draw (gr_nc_n_8_curr,   "L"); 
          Draw (gr_nc_n_9_curr,   "L"); 
          Draw (gr_nc_n_10_curr,  "L"); 
          Draw (gr_nc_n_11_curr,  "L"); 
          Draw (gr_nc_n_12_curr,  "L"); 
          Draw (gr_nc_n_13_curr,  "L"); 
          Draw (gr_nc_n_14_curr,  "L"); 
          Draw (gr_nc_n_15_curr,  "L"); 
          Draw (gr_nc_n_16_curr,  "L"); 
          Draw (gr_nc_n_tot_ref0, "P");
          Draw (gr_nc_n_1_ref0,   "P"); 
          Draw (gr_nc_n_2_ref0,   "P"); 
          Draw (gr_nc_n_3_ref0,   "P"); 
          Draw (gr_nc_n_4_ref0,   "P"); 
          Draw (gr_nc_n_5_ref0,   "P"); 
          Draw (gr_nc_n_6_ref0,   "P"); 
          Draw (gr_nc_n_7_ref0,   "P"); 
          Draw (gr_nc_n_8_ref0,   "P"); 
          Draw (gr_nc_n_9_ref0,   "P"); 
          Draw (gr_nc_n_10_ref0,  "P"); 
          Draw (gr_nc_n_11_ref0,  "P"); 
          Draw (gr_nc_n_12_ref0,  "P"); 
          Draw (gr_nc_n_13_ref0,  "P"); 
          Draw (gr_nc_n_14_ref0,  "P"); 
          Draw (gr_nc_n_15_ref0,  "P"); 
          Draw (gr_nc_n_16_ref0,  "P"); 
          l->Clear();
          l->AddEntry(gr_nc_n_tot_curr, "total",     "L");
          l->AddEntry(gr_nc_n_1_curr,   "(1232)P33", "L");
          l->AddEntry(gr_nc_n_2_curr,   "(1535)S11", "L");
          l->AddEntry(gr_nc_n_3_curr,   "(1520)D13", "L");
          l->AddEntry(gr_nc_n_4_curr,   "(1650)S11", "L");
          l->AddEntry(gr_nc_n_5_curr,   "(1700)D13", "L");
          l->AddEntry(gr_nc_n_6_curr,   "(1675)D15", "L");
          l->AddEntry(gr_nc_n_7_curr,   "(1620)S31", "L");
          l->AddEntry(gr_nc_n_8_curr,   "(1700)D33", "L");
          l->AddEntry(gr_nc_n_9_curr,   "(1440)P11", "L");
          l->AddEntry(gr_nc_n_10_curr,  "(1720)P13", "L");
          l->AddEntry(gr_nc_n_11_curr,  "(1680)F15", "L");
          l->AddEntry(gr_nc_n_12_curr,  "(1910)P31", "L");
          l->AddEntry(gr_nc_n_13_curr,  "(1920)P33", "L");
          l->AddEntry(gr_nc_n_14_curr,  "(1905)F35", "L");
          l->AddEntry(gr_nc_n_15_curr,  "(1950)F37", "L");
          l->AddEntry(gr_nc_n_16_curr,  "(1710)P11", "L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("RES-NC / %s+n%s",neutrino,target));
          ls->Draw();
	  c->Update();
     }
     // DIS CC v+p(A)
     {
	  TGraph * grdis_cc_p_curr        = (TGraph*) dir_curr->Get("dis_cc_p");
	  TGraph * grdis_cc_p_charm_curr  = (TGraph*) dir_curr->Get("dis_cc_p_charm");
          TGraph * grdis_cc_p_1_curr      = (TGraph*) dir_curr->Get("dis_cc_p_ubarsea");
          TGraph * grdis_cc_p_2_curr      = (TGraph*) dir_curr->Get("dis_cc_p_dval");
          TGraph * grdis_cc_p_3_curr      = (TGraph*) dir_curr->Get("dis_cc_p_dsea");
          TGraph * grdis_cc_p_4_curr      = (TGraph*) dir_curr->Get("dis_cc_p_ssea");
	  TGraph * grdis_cc_p_ref0        = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_cc_p")         : 0;
	  TGraph * grdis_cc_p_charm_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_cc_p_charm")   : 0;
          TGraph * grdis_cc_p_1_ref0      = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_cc_p_ubarsea") : 0;
          TGraph * grdis_cc_p_2_ref0      = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_cc_p_dval")    : 0;
          TGraph * grdis_cc_p_3_ref0      = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_cc_p_dsea")    : 0;
          TGraph * grdis_cc_p_4_ref0      = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_cc_p_ssea")    : 0;
          Format (grdis_cc_p_charm_curr, 1, -1, -1, -1, -1, -1); 
          Format (grdis_cc_p_1_curr,     2, -1, -1, -1, -1, -1); 
          Format (grdis_cc_p_2_curr,     3, -1, -1, -1, -1, -1); 
          Format (grdis_cc_p_3_curr,     4, -1, -1, -1, -1, -1); 
          Format (grdis_cc_p_4_curr,     5, -1, -1, -1, -1, -1); 
          Format (grdis_cc_p_charm_ref0, 1, -1, -1,  1, 23, 1.3);
          Format (grdis_cc_p_1_ref0,     2, -1, -1,  2, 23, 1.3);
          Format (grdis_cc_p_2_ref0,     3, -1, -1,  3, 23, 1.3);
          Format (grdis_cc_p_3_ref0,     4, -1, -1,  4, 23, 1.3);
          Format (grdis_cc_p_4_ref0,     5, -1, -1,  5, 23, 1.3);
          DrawFrame (grdis_cc_p_curr, grdis_cc_p_ref0, c);
          Draw (grdis_cc_p_curr,       "L");
          Draw (grdis_cc_p_charm_curr, "L");
          Draw (grdis_cc_p_1_curr,     "L");
          Draw (grdis_cc_p_2_curr,     "L");
          Draw (grdis_cc_p_3_curr,     "L");
          Draw (grdis_cc_p_4_curr,     "L");
          Draw (grdis_cc_p_ref0,       "P");
          Draw (grdis_cc_p_charm_ref0, "P");
          Draw (grdis_cc_p_1_ref0,     "P");
          Draw (grdis_cc_p_2_ref0,     "P");
          Draw (grdis_cc_p_3_ref0,     "P");
          Draw (grdis_cc_p_4_ref0,     "P");
          l->Clear();
          l->AddEntry(grdis_cc_p_curr,       "tot (-charm)", "L");
          l->AddEntry(grdis_cc_p_1_curr,     "ubar(sea)", "L");
          l->AddEntry(grdis_cc_p_2_curr,     "d(val)",    "L");
          l->AddEntry(grdis_cc_p_3_curr,     "d(sea)",    "L");
          l->AddEntry(grdis_cc_p_4_curr,     "s(sea)",    "L");
          l->AddEntry(grdis_cc_p_charm_curr, "tot charm", "L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("DIS-CC / %s+p%s",neutrino,target));
          ls->Draw();
	  c->Update();
     }
     // DIS CC v+n(A)
     {
	  TGraph * grdis_cc_n_curr       = (TGraph*) dir_curr->Get("dis_cc_n");
	  TGraph * grdis_cc_n_charm_curr = (TGraph*) dir_curr->Get("dis_cc_n_charm");
          TGraph * grdis_cc_n_1_curr     = (TGraph*) dir_curr->Get("dis_cc_n_ubarsea");
          TGraph * grdis_cc_n_2_curr     = (TGraph*) dir_curr->Get("dis_cc_n_dval");
          TGraph * grdis_cc_n_3_curr     = (TGraph*) dir_curr->Get("dis_cc_n_dsea");
          TGraph * grdis_cc_n_4_curr     = (TGraph*) dir_curr->Get("dis_cc_n_ssea");
	  TGraph * grdis_cc_n_ref0       = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_cc_n")         : 0;
	  TGraph * grdis_cc_n_charm_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_cc_n_charm")   : 0;
          TGraph * grdis_cc_n_1_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_cc_n_ubarsea") : 0;
          TGraph * grdis_cc_n_2_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_cc_n_dval")    : 0;
          TGraph * grdis_cc_n_3_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_cc_n_dsea")    : 0;
          TGraph * grdis_cc_n_4_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_cc_n_ssea")    : 0;
          Format (grdis_cc_n_charm_curr, 1, -1, -1, -1, -1, -1); 
          Format (grdis_cc_n_1_curr,     2, -1, -1, -1, -1, -1); 
          Format (grdis_cc_n_2_curr,     3, -1, -1, -1, -1, -1); 
          Format (grdis_cc_n_3_curr,     4, -1, -1, -1, -1, -1); 
          Format (grdis_cc_n_4_curr,     5, -1, -1, -1, -1, -1); 
          Format (grdis_cc_n_charm_ref0, 1, -1, -1,  1, 23, 1.3);
          Format (grdis_cc_n_1_ref0,     2, -1, -1,  2, 23, 1.3);
          Format (grdis_cc_n_2_ref0,     3, -1, -1,  3, 23, 1.3);
          Format (grdis_cc_n_3_ref0,     4, -1, -1,  4, 23, 1.3);
          Format (grdis_cc_n_4_ref0,     5, -1, -1,  5, 23, 1.3);
          DrawFrame (grdis_cc_n_curr, grdis_cc_n_ref0, c);
          Draw (grdis_cc_n_curr,       "L");
          Draw (grdis_cc_n_charm_curr, "L");
          Draw (grdis_cc_n_1_curr,     "L");
          Draw (grdis_cc_n_2_curr,     "L");
          Draw (grdis_cc_n_3_curr,     "L");
          Draw (grdis_cc_n_4_curr,     "L");
          Draw (grdis_cc_n_ref0,       "P");
          Draw (grdis_cc_n_charm_ref0, "P");
          Draw (grdis_cc_n_1_ref0,     "P");
          Draw (grdis_cc_n_2_ref0,     "P");
          Draw (grdis_cc_n_3_ref0,     "P");
          Draw (grdis_cc_n_4_ref0,     "P");
          l->Clear();
          l->AddEntry(grdis_cc_n_curr,       "tot (-charm)", "L");
          l->AddEntry(grdis_cc_n_1_curr,     "ubar(sea)",    "L");
          l->AddEntry(grdis_cc_n_2_curr,     "d(val)",       "L");
          l->AddEntry(grdis_cc_n_3_curr,     "d(sea)",       "L");
          l->AddEntry(grdis_cc_n_4_curr,     "s(sea)",       "L");
          l->AddEntry(grdis_cc_n_charm_curr, "tot charm",    "L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("DIS-CC / %s+n%s",neutrino,target));
          ls->Draw();
	  c->Update();
     }
     // DIS NC v+p(A)
     {
	  TGraph * grdis_nc_p_curr       = (TGraph*) dir_curr->Get("dis_nc_p");
	  TGraph * grdis_nc_p_charm_curr = (TGraph*) dir_curr->Get("dis_nc_p_charm");
          TGraph * grdis_nc_p_1_curr     = (TGraph*) dir_curr->Get("dis_nc_p_sbarsea");
          TGraph * grdis_nc_p_2_curr     = (TGraph*) dir_curr->Get("dis_nc_p_ubarsea");
          TGraph * grdis_nc_p_3_curr     = (TGraph*) dir_curr->Get("dis_nc_p_dbarsea");
          TGraph * grdis_nc_p_4_curr     = (TGraph*) dir_curr->Get("dis_nc_p_dval");
          TGraph * grdis_nc_p_5_curr     = (TGraph*) dir_curr->Get("dis_nc_p_dsea");
          TGraph * grdis_nc_p_6_curr     = (TGraph*) dir_curr->Get("dis_nc_p_uval");
          TGraph * grdis_nc_p_7_curr     = (TGraph*) dir_curr->Get("dis_nc_p_usea");
          TGraph * grdis_nc_p_8_curr     = (TGraph*) dir_curr->Get("dis_nc_p_ssea");
	  TGraph * grdis_nc_p_ref0       = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_p")         : 0;
	  TGraph * grdis_nc_p_charm_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_p_charm")   : 0;
          TGraph * grdis_nc_p_1_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_p_sbarsea") : 0;
          TGraph * grdis_nc_p_2_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_p_ubarsea") : 0;
          TGraph * grdis_nc_p_3_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_p_dbarsea") : 0;
          TGraph * grdis_nc_p_4_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_p_dval")    : 0;
          TGraph * grdis_nc_p_5_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_p_dsea")    : 0;
          TGraph * grdis_nc_p_6_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_p_uval")    : 0;
          TGraph * grdis_nc_p_7_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_p_usea")    : 0;
          TGraph * grdis_nc_p_8_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_p_ssea")    : 0;
          Format (grdis_nc_p_charm_curr, 1, -1, -1, -1, -1, -1); 
          Format (grdis_nc_p_1_curr,     2, -1, -1, -1, -1, -1); 
          Format (grdis_nc_p_2_curr,     3, -1, -1, -1, -1, -1); 
          Format (grdis_nc_p_3_curr,     4, -1, -1, -1, -1, -1); 
          Format (grdis_nc_p_4_curr,     5, -1, -1, -1, -1, -1); 
          Format (grdis_nc_p_5_curr,     6, -1, -1, -1, -1, -1); 
          Format (grdis_nc_p_6_curr,     8, -1, -1, -1, -1, -1); 
          Format (grdis_nc_p_7_curr,     8, -1, -1, -1, -1, -1); 
          Format (grdis_nc_p_8_curr,     9, -1, -1, -1, -1, -1); 
          Format (grdis_nc_p_charm_ref0, 1, -1, -1,  1, 23, 1.3);
          Format (grdis_nc_p_1_ref0,     2, -1, -1,  2, 23, 1.3);
          Format (grdis_nc_p_2_ref0,     3, -1, -1,  3, 23, 1.3);
          Format (grdis_nc_p_3_ref0,     4, -1, -1,  4, 23, 1.3);
          Format (grdis_nc_p_4_ref0,     5, -1, -1,  5, 23, 1.3);
          Format (grdis_nc_p_5_ref0,     6, -1, -1,  6, 23, 1.3);
          Format (grdis_nc_p_6_ref0,     7, -1, -1,  7, 23, 1.3);
          Format (grdis_nc_p_7_ref0,     8, -1, -1,  8, 23, 1.3);
          Format (grdis_nc_p_8_ref0,     9, -1, -1,  9, 23, 1.3);
          DrawFrame (grdis_nc_p_curr, grdis_nc_p_ref0, c);
          Draw (grdis_nc_p_curr,       "L");
          Draw (grdis_nc_p_charm_curr, "L");
          Draw (grdis_nc_p_1_curr,     "L");
          Draw (grdis_nc_p_2_curr,     "L");
          Draw (grdis_nc_p_3_curr,     "L");
          Draw (grdis_nc_p_4_curr,     "L");
          Draw (grdis_nc_p_5_curr,     "L");
          Draw (grdis_nc_p_6_curr,     "L");
          Draw (grdis_nc_p_7_curr,     "L");
          Draw (grdis_nc_p_8_curr,     "L");
          Draw (grdis_nc_p_ref0,       "P");
          Draw (grdis_nc_p_charm_ref0, "P");
          Draw (grdis_nc_p_1_ref0,     "P");
          Draw (grdis_nc_p_2_ref0,     "P");
          Draw (grdis_nc_p_3_ref0,     "P");
          Draw (grdis_nc_p_4_ref0,     "P");
          Draw (grdis_nc_p_5_ref0,     "P");
          Draw (grdis_nc_p_6_ref0,     "P");
          Draw (grdis_nc_p_7_ref0,     "P");
          Draw (grdis_nc_p_8_ref0,     "P");
          l->Clear();
          l->AddEntry(grdis_nc_p_curr,   "total",     "L");
          l->AddEntry(grdis_nc_p_1_curr, "sbar(sea)", "L");
          l->AddEntry(grdis_nc_p_2_curr, "ubar(sea)", "L");
          l->AddEntry(grdis_nc_p_3_curr, "dbar(sea)", "L");
          l->AddEntry(grdis_nc_p_4_curr, "d(val)",    "L");
          l->AddEntry(grdis_nc_p_5_curr, "d(sea)",    "L");
          l->AddEntry(grdis_nc_p_6_curr, "u(val)",    "L");
          l->AddEntry(grdis_nc_p_7_curr, "u(sea)",    "L");
          l->AddEntry(grdis_nc_p_8_curr, "s(sea)",    "L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("DIS-NC / %s+p%s",neutrino,target));
          ls->Draw();
	  c->Update();
     }
     // DIS NC v+n(A)
     {
	  TGraph * grdis_nc_n_curr       = (TGraph*) dir_curr->Get("dis_nc_n");
	  TGraph * grdis_nc_n_charm_curr = (TGraph*) dir_curr->Get("dis_nc_n_charm");
          TGraph * grdis_nc_n_1_curr     = (TGraph*) dir_curr->Get("dis_nc_n_sbarsea");
          TGraph * grdis_nc_n_2_curr     = (TGraph*) dir_curr->Get("dis_nc_n_ubarsea");
          TGraph * grdis_nc_n_3_curr     = (TGraph*) dir_curr->Get("dis_nc_n_dbarsea");
          TGraph * grdis_nc_n_4_curr     = (TGraph*) dir_curr->Get("dis_nc_n_dval");
          TGraph * grdis_nc_n_5_curr     = (TGraph*) dir_curr->Get("dis_nc_n_dsea");
          TGraph * grdis_nc_n_6_curr     = (TGraph*) dir_curr->Get("dis_nc_n_uval");
          TGraph * grdis_nc_n_7_curr     = (TGraph*) dir_curr->Get("dis_nc_n_usea");
          TGraph * grdis_nc_n_8_curr     = (TGraph*) dir_curr->Get("dis_nc_n_ssea");
	  TGraph * grdis_nc_n_ref0       = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_n")         : 0;
	  TGraph * grdis_nc_n_charm_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_n_charm")   : 0;
          TGraph * grdis_nc_n_1_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_n_sbarsea") : 0;
          TGraph * grdis_nc_n_2_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_n_ubarsea") : 0;
          TGraph * grdis_nc_n_3_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_n_dbarsea") : 0;
          TGraph * grdis_nc_n_4_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_n_dval")    : 0;
          TGraph * grdis_nc_n_5_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_n_dsea")    : 0;
          TGraph * grdis_nc_n_6_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_n_uval")    : 0;
          TGraph * grdis_nc_n_7_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_n_usea")    : 0;
          TGraph * grdis_nc_n_8_ref0     = (dir_ref0) ? (TGraph*) dir_ref0->Get("dis_nc_n_ssea")    : 0;
          Format (grdis_nc_n_charm_curr, 1, -1, -1, -1, -1, -1); 
          Format (grdis_nc_n_1_curr,     2, -1, -1, -1, -1, -1); 
          Format (grdis_nc_n_2_curr,     3, -1, -1, -1, -1, -1); 
          Format (grdis_nc_n_3_curr,     4, -1, -1, -1, -1, -1); 
          Format (grdis_nc_n_4_curr,     5, -1, -1, -1, -1, -1); 
          Format (grdis_nc_n_5_curr,     6, -1, -1, -1, -1, -1); 
          Format (grdis_nc_n_6_curr,     8, -1, -1, -1, -1, -1); 
          Format (grdis_nc_n_7_curr,     8, -1, -1, -1, -1, -1); 
          Format (grdis_nc_n_8_curr,     9, -1, -1, -1, -1, -1); 
          Format (grdis_nc_n_charm_ref0, 1, -1, -1,  1, 23, 1.3);
          Format (grdis_nc_n_1_ref0,     2, -1, -1,  2, 23, 1.3);
          Format (grdis_nc_n_2_ref0,     3, -1, -1,  3, 23, 1.3);
          Format (grdis_nc_n_3_ref0,     4, -1, -1,  4, 23, 1.3);
          Format (grdis_nc_n_4_ref0,     5, -1, -1,  5, 23, 1.3);
          Format (grdis_nc_n_5_ref0,     6, -1, -1,  6, 23, 1.3);
          Format (grdis_nc_n_6_ref0,     7, -1, -1,  7, 23, 1.3);
          Format (grdis_nc_n_7_ref0,     8, -1, -1,  8, 23, 1.3);
          Format (grdis_nc_n_8_ref0,     9, -1, -1,  9, 23, 1.3);
          DrawFrame (grdis_nc_n_curr, grdis_nc_n_ref0, c);
          Draw (grdis_nc_n_curr,       "L");
          Draw (grdis_nc_n_charm_curr, "L");
          Draw (grdis_nc_n_1_curr,     "L");
          Draw (grdis_nc_n_2_curr,     "L");
          Draw (grdis_nc_n_3_curr,     "L");
          Draw (grdis_nc_n_4_curr,     "L");
          Draw (grdis_nc_n_5_curr,     "L");
          Draw (grdis_nc_n_6_curr,     "L");
          Draw (grdis_nc_n_7_curr,     "L");
          Draw (grdis_nc_n_8_curr,     "L");
          Draw (grdis_nc_n_ref0,       "P");
          Draw (grdis_nc_n_charm_ref0, "P");
          Draw (grdis_nc_n_1_ref0,     "P");
          Draw (grdis_nc_n_2_ref0,     "P");
          Draw (grdis_nc_n_3_ref0,     "P");
          Draw (grdis_nc_n_4_ref0,     "P");
          Draw (grdis_nc_n_5_ref0,     "P");
          Draw (grdis_nc_n_6_ref0,     "P");
          Draw (grdis_nc_n_7_ref0,     "P");
          Draw (grdis_nc_n_8_ref0,     "P");
          l->Clear();
          l->AddEntry(grdis_nc_n_curr,   "total",     "L");
          l->AddEntry(grdis_nc_n_1_curr, "sbar(sea)", "L");
          l->AddEntry(grdis_nc_n_2_curr, "ubar(sea)", "L");
          l->AddEntry(grdis_nc_n_3_curr, "dbar(sea)", "L");
          l->AddEntry(grdis_nc_n_4_curr, "d(val)",    "L");
          l->AddEntry(grdis_nc_n_5_curr, "d(sea)",    "L");
          l->AddEntry(grdis_nc_n_6_curr, "u(val)",    "L");
          l->AddEntry(grdis_nc_n_7_curr, "u(sea)",    "L");
          l->AddEntry(grdis_nc_n_8_curr, "s(sea)",    "L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("DIS-NC / %s+n%s",neutrino,target));
          ls->Draw();
	  c->Update();
     }
     // COHPi CC v+A
     {
	  TGraph * gr_cohpi_curr = (TGraph *) dir_curr->Get("cohpi_cc");
	  TGraph * gr_cohpi_ref0 = (dir_ref0) ? (TGraph *) dir_ref0->Get("cohpi_cc") : 0;
          Draw(gr_cohpi_curr,"L");
          Draw(gr_cohpi_ref0,"L");
          DrawFrame (gr_cohpi_curr, gr_cohpi_ref0, c);
          ls->Clear();
          ls->SetHeader(Form("COHPI-CC / %s+%s",neutrino,target));
          ls->Draw();
	  c->Update();
     }
     // COHPi NC v+A
     {
	  TGraph * gr_cohpi_curr = (TGraph *) dir_curr->Get("cohpi_nc");
	  TGraph * gr_cohpi_ref0 = (dir_ref0) ? (TGraph *) dir_ref0->Get("cohpi_nc") : 0;
          Draw(gr_cohpi_curr,"L");
          Draw(gr_cohpi_ref0,"L");
          DrawFrame (gr_cohpi_curr, gr_cohpi_ref0, c);
          ls->Clear();
          ls->SetHeader(Form("COHPI-NC / %s+%s",neutrino,target));
          ls->Draw();
	  c->Update();
     }
     // IMD numu+e(A)
     {
/*
	  dir_curr->Get("imd_cc")->Draw("lp");
          ls->Clear();
          ls->SetHeader(Form("IMD / %s+e%s",neutrino,target));
          ls->Draw();
	  c->Update();
*/
     }
  }


  if(is_nubar) {

     // QEL CC vbar+p(A)
     {
          TGraph * gr_cc_p_curr = (TGraph*) dir_curr->Get("qel_cc_p");
          TGraph * gr_cc_p_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("qel_cc_p") : 0;
          DrawFrame (gr_cc_p_curr, gr_cc_p_ref0, c);
          Draw (gr_cc_p_curr, "L");
          Draw (gr_cc_p_ref0, "P");
          ls->Clear();
          ls->SetHeader(Form("QEL-CC / %s+n%s",neutrino,target));
          ls->Draw();
          c->Update();
     }
     // QEL NC vbar+n(A)
     {
	  TGraph * gr_nc_n_curr = (TGraph*) dir_curr->Get("qel_nc_n");
	  TGraph * gr_nc_n_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("qel_nc_n") : 0;
          DrawFrame (gr_nc_n_curr, gr_nc_n_ref0, c);
          Draw (gr_nc_n_curr, "L");
          Draw (gr_nc_n_ref0, "P");
          ls->Clear();
          ls->SetHeader(Form("QEL-NC / %s+p%s",neutrino,target));
          ls->Draw();
	  c->Update();
     }
     // QEL NC numubar+p(Fe56)
     {
	  TGraph * gr_nc_p_curr = (TGraph*) dir_curr->Get("qel_nc_p");
	  TGraph * gr_nc_p_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("qel_nc_p") : 0;
          DrawFrame (gr_nc_p_curr, gr_nc_p_ref0, c);
          Draw (gr_nc_p_curr, "L");
          Draw (gr_nc_p_ref0, "P");
          ls->Clear();
          ls->SetHeader(Form("QEL-NC / %s+p%s",neutrino,target));
          ls->Draw();
	  c->Update();
     }
     // RES CC numubar+p(Fe56)
     {
	  TGraph * gr_cc_p_curr    = (TGraph*) dir_curr->Get("res_cc_p");
          TGraph * gr_cc_p_1_curr  = (TGraph*) dir_curr->Get("res_cc_p_1232P33");
          TGraph * gr_cc_p_2_curr  = (TGraph*) dir_curr->Get("res_cc_p_1535S11");
          TGraph * gr_cc_p_3_curr  = (TGraph*) dir_curr->Get("res_cc_p_1520D13");
          TGraph * gr_cc_p_4_curr  = (TGraph*) dir_curr->Get("res_cc_p_1650S11");
          TGraph * gr_cc_p_5_curr  = (TGraph*) dir_curr->Get("res_cc_p_1700D13");
          TGraph * gr_cc_p_6_curr  = (TGraph*) dir_curr->Get("res_cc_p_1675D15");
          TGraph * gr_cc_p_7_curr  = (TGraph*) dir_curr->Get("res_cc_p_1620S31");
          TGraph * gr_cc_p_8_curr  = (TGraph*) dir_curr->Get("res_cc_p_1700D33");
          TGraph * gr_cc_p_9_curr  = (TGraph*) dir_curr->Get("res_cc_p_1440P11");
          TGraph * gr_cc_p_10_curr = (TGraph*) dir_curr->Get("res_cc_p_1720P13");
          TGraph * gr_cc_p_11_curr = (TGraph*) dir_curr->Get("res_cc_p_1680F15");
          TGraph * gr_cc_p_12_curr = (TGraph*) dir_curr->Get("res_cc_p_1910P31");
          TGraph * gr_cc_p_13_curr = (TGraph*) dir_curr->Get("res_cc_p_1920P33");
          TGraph * gr_cc_p_14_curr = (TGraph*) dir_curr->Get("res_cc_p_1905F35");
          TGraph * gr_cc_p_15_curr = (TGraph*) dir_curr->Get("res_cc_p_1950F37");
          TGraph * gr_cc_p_16_curr = (TGraph*) dir_curr->Get("res_cc_p_1710P11");
	  TGraph * gr_cc_p_ref0    = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p")         : 0;
          TGraph * gr_cc_p_1_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1232P33") : 0;
          TGraph * gr_cc_p_2_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1535S11") : 0;
          TGraph * gr_cc_p_3_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1520D13") : 0;
          TGraph * gr_cc_p_4_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1650S11") : 0;
          TGraph * gr_cc_p_5_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1700D13") : 0;
          TGraph * gr_cc_p_6_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1675D15") : 0;
          TGraph * gr_cc_p_7_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1620S31") : 0;
          TGraph * gr_cc_p_8_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1700D33") : 0;
          TGraph * gr_cc_p_9_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1440P11") : 0;
          TGraph * gr_cc_p_10_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1720P13") : 0;
          TGraph * gr_cc_p_11_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1680F15") : 0;
          TGraph * gr_cc_p_12_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1910P31") : 0;
          TGraph * gr_cc_p_13_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1920P33") : 0;
          TGraph * gr_cc_p_14_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1905F35") : 0;
          TGraph * gr_cc_p_15_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1950F37") : 0;
          TGraph * gr_cc_p_16_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_p_1710P11") : 0;
          Format (gr_cc_p_curr,     1, -1, -1, -1, -1, -1);
          Format (gr_cc_p_1_curr,   2, -1, -1, -1, -1, -1);
          Format (gr_cc_p_2_curr,   3, -1, -1, -1, -1, -1);
          Format (gr_cc_p_3_curr,   4, -1, -1, -1, -1, -1);
          Format (gr_cc_p_4_curr,   5, -1, -1, -1, -1, -1);
          Format (gr_cc_p_5_curr,   6, -1, -1, -1, -1, -1);
          Format (gr_cc_p_6_curr,   7, -1, -1, -1, -1, -1);
          Format (gr_cc_p_7_curr,   8, -1, -1, -1, -1, -1);
          Format (gr_cc_p_8_curr,   9, -1, -1, -1, -1, -1);
          Format (gr_cc_p_9_curr,  31, -1, -1, -1, -1, -1);
          Format (gr_cc_p_10_curr, 32, -1, -1, -1, -1, -1);
          Format (gr_cc_p_11_curr, 33, -1, -1, -1, -1, -1);
          Format (gr_cc_p_12_curr, 34, -1, -1, -1, -1, -1);
          Format (gr_cc_p_13_curr, 35, -1, -1, -1, -1, -1);
          Format (gr_cc_p_14_curr, 36, -1, -1, -1, -1, -1);
          Format (gr_cc_p_15_curr, 37, -1, -1, -1, -1, -1);
          Format (gr_cc_p_16_curr, 38, -1, -1, -1, -1, -1);
          Format (gr_cc_p_ref0,     1, -1, -1,  1, 23, 1.3);
          Format (gr_cc_p_1_ref0,   2, -1, -1,  2, 23, 1.3);
          Format (gr_cc_p_2_ref0,   3, -1, -1,  3, 23, 1.3);
          Format (gr_cc_p_3_ref0,   4, -1, -1,  4, 23, 1.3);
          Format (gr_cc_p_4_ref0,   5, -1, -1,  5, 23, 1.3);
          Format (gr_cc_p_5_ref0,   6, -1, -1,  6, 23, 1.3);
          Format (gr_cc_p_6_ref0,   7, -1, -1,  7, 23, 1.3);
          Format (gr_cc_p_7_ref0,   8, -1, -1,  8, 23, 1.3);
          Format (gr_cc_p_8_ref0,   9, -1, -1,  9, 23, 1.3);
          Format (gr_cc_p_9_ref0,  31, -1, -1, 31, 23, 1.3);
          Format (gr_cc_p_10_ref0, 32, -1, -1, 32, 23, 1.3);
          Format (gr_cc_p_11_ref0, 33, -1, -1, 33, 23, 1.3);
          Format (gr_cc_p_12_ref0, 34, -1, -1, 34, 23, 1.3);
          Format (gr_cc_p_13_ref0, 35, -1, -1, 35, 23, 1.3);
          Format (gr_cc_p_14_ref0, 36, -1, -1, 36, 23, 1.3);
          Format (gr_cc_p_15_ref0, 37, -1, -1, 37, 23, 1.3);
          Format (gr_cc_p_16_ref0, 38, -1, -1, 38, 23, 1.3);
          Draw (gr_cc_p_curr,    "L");
          Draw (gr_cc_p_1_curr,  "L");
          Draw (gr_cc_p_2_curr,  "L");
          Draw (gr_cc_p_3_curr,  "L");
          Draw (gr_cc_p_4_curr,  "L");
          Draw (gr_cc_p_5_curr,  "L");
          Draw (gr_cc_p_6_curr,  "L");
          Draw (gr_cc_p_7_curr,  "L");
          Draw (gr_cc_p_8_curr,  "L");
          Draw (gr_cc_p_9_curr,  "L");
          Draw (gr_cc_p_10_curr, "L");
          Draw (gr_cc_p_11_curr, "L");
          Draw (gr_cc_p_12_curr, "L");
          Draw (gr_cc_p_13_curr, "L");
          Draw (gr_cc_p_14_curr, "L");
          Draw (gr_cc_p_15_curr, "L");
          Draw (gr_cc_p_16_curr, "L");
          Draw (gr_cc_p_ref0,    "P");
          Draw (gr_cc_p_1_ref0,  "P");
          Draw (gr_cc_p_2_ref0,  "P");
          Draw (gr_cc_p_3_ref0,  "P");
          Draw (gr_cc_p_4_ref0,  "P");
          Draw (gr_cc_p_5_ref0,  "P");
          Draw (gr_cc_p_6_ref0,  "P");
          Draw (gr_cc_p_7_ref0,  "P");
          Draw (gr_cc_p_8_ref0,  "P");
          Draw (gr_cc_p_9_ref0,  "P");
          Draw (gr_cc_p_10_ref0, "P");
          Draw (gr_cc_p_11_ref0, "P");
          Draw (gr_cc_p_12_ref0, "P");
          Draw (gr_cc_p_13_ref0, "P");
          Draw (gr_cc_p_14_ref0, "P");
          Draw (gr_cc_p_15_ref0, "P");
          Draw (gr_cc_p_16_ref0, "P");
          l->Clear();
          l->AddEntry(gr_cc_p_curr,    "total",     "L");
          l->AddEntry(gr_cc_p_1_curr,  "(1232)P33", "L");
          l->AddEntry(gr_cc_p_2_curr,  "(1535)S11", "L");
          l->AddEntry(gr_cc_p_3_curr,  "(1520)D13", "L");
          l->AddEntry(gr_cc_p_4_curr,  "(1650)S11", "L");
          l->AddEntry(gr_cc_p_5_curr,  "(1700)D13", "L");
          l->AddEntry(gr_cc_p_6_curr,  "(1675)D15", "L");
          l->AddEntry(gr_cc_p_7_curr,  "(1620)S31", "L");
          l->AddEntry(gr_cc_p_8_curr,  "(1700)D33", "L");
          l->AddEntry(gr_cc_p_9_curr,  "(1440)P11", "L");
          l->AddEntry(gr_cc_p_10_curr, "(1720)P13", "L");
          l->AddEntry(gr_cc_p_11_curr, "(1680)F15", "L");
          l->AddEntry(gr_cc_p_12_curr, "(1910)P31", "L");
          l->AddEntry(gr_cc_p_13_curr, "(1920)P33", "L");
          l->AddEntry(gr_cc_p_14_curr, "(1905)F35", "L");
          l->AddEntry(gr_cc_p_15_curr, "(1950)F37", "L");
          l->AddEntry(gr_cc_p_16_curr, "(1710)P11", "L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("RES-CC / %s+p%s",neutrino,target));
          ls->Draw();
	  c->Update();
     }
     // RES CC numubar+n(Fe56)
     {
	  TGraph * gr_cc_n_tot_curr = (TGraph*) dir_curr->Get("res_cc_n");
          TGraph * gr_cc_n_1_curr   = (TGraph*) dir_curr->Get("res_cc_n_1232P33");
          TGraph * gr_cc_n_2_curr   = (TGraph*) dir_curr->Get("res_cc_n_1535S11");
          TGraph * gr_cc_n_3_curr   = (TGraph*) dir_curr->Get("res_cc_n_1520D13");
          TGraph * gr_cc_n_4_curr   = (TGraph*) dir_curr->Get("res_cc_n_1650S11");
          TGraph * gr_cc_n_5_curr   = (TGraph*) dir_curr->Get("res_cc_n_1700D13");
          TGraph * gr_cc_n_6_curr   = (TGraph*) dir_curr->Get("res_cc_n_1675D15");
          TGraph * gr_cc_n_7_curr   = (TGraph*) dir_curr->Get("res_cc_n_1620S31");
          TGraph * gr_cc_n_8_curr   = (TGraph*) dir_curr->Get("res_cc_n_1700D33");
          TGraph * gr_cc_n_9_curr   = (TGraph*) dir_curr->Get("res_cc_n_1440P11");
          TGraph * gr_cc_n_10_curr  = (TGraph*) dir_curr->Get("res_cc_n_1720P13");
          TGraph * gr_cc_n_11_curr  = (TGraph*) dir_curr->Get("res_cc_n_1680F15");
          TGraph * gr_cc_n_12_curr  = (TGraph*) dir_curr->Get("res_cc_n_1910P31");
          TGraph * gr_cc_n_13_curr  = (TGraph*) dir_curr->Get("res_cc_n_1920P33");
          TGraph * gr_cc_n_14_curr  = (TGraph*) dir_curr->Get("res_cc_n_1905F35");
          TGraph * gr_cc_n_15_curr  = (TGraph*) dir_curr->Get("res_cc_n_1950F37");
          TGraph * gr_cc_n_16_curr  = (TGraph*) dir_curr->Get("res_cc_n_1710P11");
	  TGraph * gr_cc_n_tot_ref0 = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n")         : 0;
          TGraph * gr_cc_n_1_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1232P33") : 0;
          TGraph * gr_cc_n_2_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1535S11") : 0;
          TGraph * gr_cc_n_3_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1520D13") : 0;
          TGraph * gr_cc_n_4_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1650S11") : 0;
          TGraph * gr_cc_n_5_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1700D13") : 0;
          TGraph * gr_cc_n_6_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1675D15") : 0;
          TGraph * gr_cc_n_7_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1620S31") : 0;
          TGraph * gr_cc_n_8_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1700D33") : 0;
          TGraph * gr_cc_n_9_ref0   = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1440P11") : 0;
          TGraph * gr_cc_n_10_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1720P13") : 0;
          TGraph * gr_cc_n_11_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1680F15") : 0; 
          TGraph * gr_cc_n_12_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1910P31") : 0;
          TGraph * gr_cc_n_13_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1920P33") : 0;
          TGraph * gr_cc_n_14_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1905F35") : 0;
          TGraph * gr_cc_n_15_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1950F37") : 0;
          TGraph * gr_cc_n_16_ref0  = (dir_ref0) ? (TGraph*) dir_ref0->Get("res_cc_n_1710P11") : 0;
          Format (gr_cc_n_tot_curr, 1, -1, -1, -1, -1, -1);
          Format (gr_cc_n_1_curr,   2, -1, -1, -1, -1, -1);
          Format (gr_cc_n_2_curr,   3, -1, -1, -1, -1, -1);
          Format (gr_cc_n_3_curr,   4, -1, -1, -1, -1, -1);
          Format (gr_cc_n_4_curr,   5, -1, -1, -1, -1, -1);
          Format (gr_cc_n_5_curr,   6, -1, -1, -1, -1, -1);
          Format (gr_cc_n_6_curr,   7, -1, -1, -1, -1, -1);
          Format (gr_cc_n_7_curr,   8, -1, -1, -1, -1, -1);
          Format (gr_cc_n_8_curr,   9, -1, -1, -1, -1, -1);
          Format (gr_cc_n_9_curr,  31, -1, -1, -1, -1, -1);
          Format (gr_cc_n_10_curr, 32, -1, -1, -1, -1, -1);
          Format (gr_cc_n_11_curr, 33, -1, -1, -1, -1, -1);
          Format (gr_cc_n_12_curr, 34, -1, -1, -1, -1, -1);
          Format (gr_cc_n_13_curr, 35, -1, -1, -1, -1, -1);
          Format (gr_cc_n_14_curr, 36, -1, -1, -1, -1, -1);
          Format (gr_cc_n_15_curr, 37, -1, -1, -1, -1, -1);
          Format (gr_cc_n_16_curr, 38, -1, -1, -1, -1, -1);
          Format (gr_cc_n_tot_ref0, 1, -1, -1,  1, 23, 1.3);
          Format (gr_cc_n_1_ref0,   2, -1, -1,  2, 23, 1.3);
          Format (gr_cc_n_2_ref0,   3, -1, -1,  3, 23, 1.3);
          Format (gr_cc_n_3_ref0,   4, -1, -1,  4, 23, 1.3);
          Format (gr_cc_n_4_ref0,   5, -1, -1,  5, 23, 1.3);
          Format (gr_cc_n_5_ref0,   6, -1, -1,  6, 23, 1.3);
          Format (gr_cc_n_6_ref0,   7, -1, -1,  7, 23, 1.3);
          Format (gr_cc_n_7_ref0,   8, -1, -1,  8, 23, 1.3);
          Format (gr_cc_n_8_ref0,   9, -1, -1,  9, 23, 1.3);
          Format (gr_cc_n_9_ref0,  31, -1, -1, 31, 23, 1.3);
          Format (gr_cc_n_10_ref0, 32, -1, -1, 32, 23, 1.3);
          Format (gr_cc_n_11_ref0, 33, -1, -1, 33, 23, 1.3);
          Format (gr_cc_n_12_ref0, 34, -1, -1, 34, 23, 1.3);
          Format (gr_cc_n_13_ref0, 35, -1, -1, 35, 23, 1.3);
          Format (gr_cc_n_14_ref0, 36, -1, -1, 36, 23, 1.3);
          Format (gr_cc_n_15_ref0, 37, -1, -1, 37, 23, 1.3);
          Format (gr_cc_n_16_ref0, 38, -1, -1, 38, 23, 1.3);
          Draw (gr_cc_n_tot_curr,"L");
          Draw (gr_cc_n_1_curr,  "L");
          Draw (gr_cc_n_2_curr,  "L");
          Draw (gr_cc_n_3_curr,  "L");
          Draw (gr_cc_n_4_curr,  "L");
          Draw (gr_cc_n_5_curr,  "L");
          Draw (gr_cc_n_6_curr,  "L");
          Draw (gr_cc_n_7_curr,  "L");
          Draw (gr_cc_n_8_curr,  "L");
          Draw (gr_cc_n_9_curr,  "L");
          Draw (gr_cc_n_10_curr, "L");
          Draw (gr_cc_n_11_curr, "L");
          Draw (gr_cc_n_12_curr, "L");
          Draw (gr_cc_n_13_curr, "L");
          Draw (gr_cc_n_14_curr, "L");
          Draw (gr_cc_n_15_curr, "L");
          Draw (gr_cc_n_16_curr, "L");
          Draw (gr_cc_n_tot_ref0,"P");
          Draw (gr_cc_n_1_ref0,  "P");
          Draw (gr_cc_n_2_ref0,  "P");
          Draw (gr_cc_n_3_ref0,  "P");
          Draw (gr_cc_n_4_ref0,  "P");
          Draw (gr_cc_n_5_ref0,  "P");
          Draw (gr_cc_n_6_ref0,  "P");
          Draw (gr_cc_n_7_ref0,  "P");
          Draw (gr_cc_n_8_ref0,  "P");
          Draw (gr_cc_n_9_ref0,  "P");
          Draw (gr_cc_n_10_ref0, "P");
          Draw (gr_cc_n_11_ref0, "P");
          Draw (gr_cc_n_12_ref0, "P");
          Draw (gr_cc_n_13_ref0, "P");
          Draw (gr_cc_n_14_ref0, "P");
          Draw (gr_cc_n_15_ref0, "P");
          Draw (gr_cc_n_16_ref0, "P");
          l->Clear();
          l->AddEntry(gr_cc_n_tot_curr,"total",     "L");
          l->AddEntry(gr_cc_n_1_curr,  "(1232)P33", "L");
          l->AddEntry(gr_cc_n_2_curr,  "(1535)S11", "L");
          l->AddEntry(gr_cc_n_3_curr,  "(1520)D13", "L");
          l->AddEntry(gr_cc_n_4_curr,  "(1650)S11", "L");
          l->AddEntry(gr_cc_n_5_curr,  "(1700)D13", "L");
          l->AddEntry(gr_cc_n_6_curr,  "(1675)D15", "L");
          l->AddEntry(gr_cc_n_7_curr,  "(1620)S31", "L");
          l->AddEntry(gr_cc_n_8_curr,  "(1700)D33", "L");
          l->AddEntry(gr_cc_n_9_curr,  "(1440)P11", "L");
          l->AddEntry(gr_cc_n_10_curr, "(1720)P13", "L");
          l->AddEntry(gr_cc_n_11_curr, "(1680)F15", "L");
          l->AddEntry(gr_cc_n_12_curr, "(1910)P31", "L");
          l->AddEntry(gr_cc_n_13_curr, "(1920)P33", "L");
          l->AddEntry(gr_cc_n_14_curr, "(1905)F35", "L");
          l->AddEntry(gr_cc_n_15_curr, "(1950)F37", "L");
          l->AddEntry(gr_cc_n_16_curr, "(1710)P11", "L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("QEL-CC / %s+n%s",neutrino,target));
          ls->Draw();
	  c->Update();
     }
     // RES NC numubar+p(Fe56)
     {
/*
	  TGraph * gr_nc_p_tot = (TGraph*) dir_curr->Get("res_nc_p");
          TGraph * gr_nc_p_1   = (TGraph*) dir_curr->Get("res_nc_p_1232P33");
          TGraph * gr_nc_p_2   = (TGraph*) dir_curr->Get("res_nc_p_1535S11");
          TGraph * gr_nc_p_3   = (TGraph*) dir_curr->Get("res_nc_p_1520D13");
          TGraph * gr_nc_p_4   = (TGraph*) dir_curr->Get("res_nc_p_1650S11");
          TGraph * gr_nc_p_5   = (TGraph*) dir_curr->Get("res_nc_p_1700D13");
          TGraph * gr_nc_p_6   = (TGraph*) dir_curr->Get("res_nc_p_1675D15");
          TGraph * gr_nc_p_7   = (TGraph*) dir_curr->Get("res_nc_p_1620S31");
          TGraph * gr_nc_p_8   = (TGraph*) dir_curr->Get("res_nc_p_1700D33");
          TGraph * gr_nc_p_9   = (TGraph*) dir_curr->Get("res_nc_p_1440P11");
          TGraph * gr_nc_p_10  = (TGraph*) dir_curr->Get("res_nc_p_1720P13");
          TGraph * gr_nc_p_11  = (TGraph*) dir_curr->Get("res_nc_p_1680F15");
          TGraph * gr_nc_p_12  = (TGraph*) dir_curr->Get("res_nc_p_1910P31");
          TGraph * gr_nc_p_13  = (TGraph*) dir_curr->Get("res_nc_p_1920P33");
          TGraph * gr_nc_p_14  = (TGraph*) dir_curr->Get("res_nc_p_1905F35");
          TGraph * gr_nc_p_15  = (TGraph*) dir_curr->Get("res_nc_p_1950F37");
          TGraph * gr_nc_p_16  = (TGraph*) dir_curr->Get("res_nc_p_1710P11");
          gr_nc_p_1 ->SetLineColor(2);
          gr_nc_p_2 ->SetLineColor(3);
          gr_nc_p_3 ->SetLineColor(4);
          gr_nc_p_4 ->SetLineColor(5);
          gr_nc_p_5 ->SetLineColor(6);
          gr_nc_p_6 ->SetLineColor(7);
          gr_nc_p_7 ->SetLineColor(8);
          gr_nc_p_8 ->SetLineColor(9);
          gr_nc_p_9 ->SetLineColor(31);
          gr_nc_p_10->SetLineColor(32);
          gr_nc_p_11->SetLineColor(33);
          gr_nc_p_12->SetLineColor(34);
          gr_nc_p_13->SetLineColor(35);
          gr_nc_p_14->SetLineColor(36);
          gr_nc_p_15->SetLineColor(37);
          gr_nc_p_16->SetLineColor(38);
          l->Clear();
          l->AddEntry(gr_nc_p_tot,"total",     "L");
          l->AddEntry(gr_nc_p_1,  "(1232)P33", "L");
          l->AddEntry(gr_nc_p_2,  "(1535)S11", "L");
          l->AddEntry(gr_nc_p_3,  "(1520)D13", "L");
          l->AddEntry(gr_nc_p_4,  "(1650)S11", "L");
          l->AddEntry(gr_nc_p_5,  "(1700)D13", "L");
          l->AddEntry(gr_nc_p_6,  "(1675)D15", "L");
          l->AddEntry(gr_nc_p_7,  "(1620)S31", "L");
          l->AddEntry(gr_nc_p_8,  "(1700)D33", "L");
          l->AddEntry(gr_nc_p_9,  "(1440)P11", "L");
          l->AddEntry(gr_nc_p_10, "(1720)P13", "L");
          l->AddEntry(gr_nc_p_11, "(1680)F15", "L");
          l->AddEntry(gr_nc_p_12, "(1910)P31", "L");
          l->AddEntry(gr_nc_p_13, "(1920)P33", "L");
          l->AddEntry(gr_nc_p_14, "(1905)F35", "L");
          l->AddEntry(gr_nc_p_15, "(1950)F37", "L");
          l->AddEntry(gr_nc_p_16, "(1710)P11", "L");
          gr_nc_p_tot ->Draw("L");
          gr_nc_p_1   ->Draw("L");
          gr_nc_p_2   ->Draw("L");
          gr_nc_p_3   ->Draw("L");
          gr_nc_p_4   ->Draw("L");
          gr_nc_p_5   ->Draw("L");
          gr_nc_p_6   ->Draw("L");
          gr_nc_p_7   ->Draw("L");
          gr_nc_p_8   ->Draw("L");
          gr_nc_p_9   ->Draw("L");
          gr_nc_p_10  ->Draw("L");
          gr_nc_p_11  ->Draw("L");
          gr_nc_p_12  ->Draw("L");
          gr_nc_p_13  ->Draw("L");
          gr_nc_p_14  ->Draw("L");
          gr_nc_p_15  ->Draw("L");
          gr_nc_p_16  ->Draw("L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("RES-NC / %s+p%s",neutrino,target));
          ls->Draw();
	  c->Update();
*/
     }
     // RES NC numubar+n(Fe56)
     {
/*
	  TGraph * gr_nc_n_tot = (TGraph*) dir_curr->Get("res_nc_n");
          TGraph * gr_nc_n_1   = (TGraph*) dir_curr->Get("res_nc_n_1232P33");
          TGraph * gr_nc_n_2   = (TGraph*) dir_curr->Get("res_nc_n_1535S11");
          TGraph * gr_nc_n_3   = (TGraph*) dir_curr->Get("res_nc_n_1520D13");
          TGraph * gr_nc_n_4   = (TGraph*) dir_curr->Get("res_nc_n_1650S11");
          TGraph * gr_nc_n_5   = (TGraph*) dir_curr->Get("res_nc_n_1700D13");
          TGraph * gr_nc_n_6   = (TGraph*) dir_curr->Get("res_nc_n_1675D15");
          TGraph * gr_nc_n_7   = (TGraph*) dir_curr->Get("res_nc_n_1620S31");
          TGraph * gr_nc_n_8   = (TGraph*) dir_curr->Get("res_nc_n_1700D33");
          TGraph * gr_nc_n_9   = (TGraph*) dir_curr->Get("res_nc_n_1440P11");
          TGraph * gr_nc_n_10  = (TGraph*) dir_curr->Get("res_nc_n_1720P13");
          TGraph * gr_nc_n_11  = (TGraph*) dir_curr->Get("res_nc_n_1680F15");
          TGraph * gr_nc_n_12  = (TGraph*) dir_curr->Get("res_nc_n_1910P31");
          TGraph * gr_nc_n_13  = (TGraph*) dir_curr->Get("res_nc_n_1920P33");
          TGraph * gr_nc_n_14  = (TGraph*) dir_curr->Get("res_nc_n_1905F35");
          TGraph * gr_nc_n_15  = (TGraph*) dir_curr->Get("res_nc_n_1950F37");
          TGraph * gr_nc_n_16  = (TGraph*) dir_curr->Get("res_nc_n_1710P11");
          gr_nc_n_1 ->SetLineColor(2);
          gr_nc_n_2 ->SetLineColor(3);
          gr_nc_n_3 ->SetLineColor(4);
          gr_nc_n_4 ->SetLineColor(5);
          gr_nc_n_5 ->SetLineColor(6);
          gr_nc_n_6 ->SetLineColor(7);
          gr_nc_n_7 ->SetLineColor(8);
          gr_nc_n_8 ->SetLineColor(9);
          gr_nc_n_9 ->SetLineColor(31);
          gr_nc_n_10->SetLineColor(32);
          gr_nc_n_11->SetLineColor(33);
          gr_nc_n_12->SetLineColor(34);
          gr_nc_n_13->SetLineColor(35);
          gr_nc_n_14->SetLineColor(36);
          gr_nc_n_15->SetLineColor(37);
          gr_nc_n_16->SetLineColor(38);
          l->Clear();
          l->AddEntry(gr_nc_n_tot,"total",     "L");
          l->AddEntry(gr_nc_n_1,  "(1232)P33", "L");
          l->AddEntry(gr_nc_n_2,  "(1535)S11", "L");
          l->AddEntry(gr_nc_n_3,  "(1520)D13", "L");
          l->AddEntry(gr_nc_n_4,  "(1650)S11", "L");
          l->AddEntry(gr_nc_n_5,  "(1700)D13", "L");
          l->AddEntry(gr_nc_n_6,  "(1675)D15", "L");
          l->AddEntry(gr_nc_n_7,  "(1620)S31", "L");
          l->AddEntry(gr_nc_n_8,  "(1700)D33", "L");
          l->AddEntry(gr_nc_n_9,  "(1440)P11", "L");
          l->AddEntry(gr_nc_n_10, "(1720)P13", "L");
          l->AddEntry(gr_nc_n_11, "(1680)F15", "L");
          l->AddEntry(gr_nc_n_12, "(1910)P31", "L");
          l->AddEntry(gr_nc_n_13, "(1920)P33", "L");
          l->AddEntry(gr_nc_n_14, "(1905)F35", "L");
          l->AddEntry(gr_nc_n_15, "(1950)F37", "L");
          l->AddEntry(gr_nc_n_16, "(1710)P11", "L");
          gr_nc_n_tot ->Draw("L");
          gr_nc_n_1   ->Draw("L");
          gr_nc_n_2   ->Draw("L");
          gr_nc_n_3   ->Draw("L");
          gr_nc_n_4   ->Draw("L");
          gr_nc_n_5   ->Draw("L");
          gr_nc_n_6   ->Draw("L");
          gr_nc_n_7   ->Draw("L");
          gr_nc_n_8   ->Draw("L");
          gr_nc_n_9   ->Draw("L");
          gr_nc_n_10  ->Draw("L");
          gr_nc_n_11  ->Draw("L");
          gr_nc_n_12  ->Draw("L");
          gr_nc_n_13  ->Draw("L");
          gr_nc_n_14  ->Draw("L");
          gr_nc_n_15  ->Draw("L");
          gr_nc_n_16 ->Draw("L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("RES-NC / %s+n%s",neutrino,target));
          ls->Draw();
	  c->Update();
*/
     }
     // DIS CC numubar+p(Fe56)
     {
/*
	  TGraph * dis_cc_p = (TGraph*) dir_curr->Get("dis_cc_p");
          dis_cc_p->Draw("l");
	  TGraph * dis_cc_p_charm = (TGraph*) dir_curr->Get("dis_cc_p_charm");
          dis_cc_p_charm->SetLineWidth(2);
          dis_cc_p_charm->Draw("l");
          TGraph * dis_cc_p_1  = (TGraph*) dir_curr->Get("dis_cc_p_sbarsea");
          TGraph * dis_cc_p_2  = (TGraph*) dir_curr->Get("dis_cc_p_dbarsea");
          TGraph * dis_cc_p_3  = (TGraph*) dir_curr->Get("dis_cc_p_uval");
          TGraph * dis_cc_p_4  = (TGraph*) dir_curr->Get("dis_cc_p_usea");
          dis_cc_p_1->SetLineColor(2);
          dis_cc_p_2->SetLineColor(3);
          dis_cc_p_3->SetLineColor(4);
          dis_cc_p_4->SetLineColor(5);
          l->Clear();
          l->AddEntry(dis_cc_p,        "tot (-charm)",   "L");
          l->AddEntry(dis_cc_p_1,      "sbar(sea)",      "L");
          l->AddEntry(dis_cc_p_2,      "dbar(sea)",      "L");
          l->AddEntry(dis_cc_p_3,      "u(val)",         "L");
          l->AddEntry(dis_cc_p_4,      "u(sea)",         "L");
          l->AddEntry(dis_cc_p_charm,  "tot charm",      "L");
          dis_cc_p_1->Draw("L");
          dis_cc_p_2->Draw("L");
          dis_cc_p_3->Draw("L");
          dis_cc_p_4->Draw("L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("DIS-CC / %s+p%s",neutrino,target));
          ls->Draw();
	  c->Update();
*/
     }
     // DIS CC numubar+n(Fe56)
     {
/*
	  TGraph * dis_cc_n = (TGraph *) dir_curr->Get("dis_cc_n");
          dis_cc_n->Draw("l");
	  TGraph * dis_cc_n_charm = (TGraph*) dir_curr->Get("dis_cc_n_charm");
          dis_cc_n_charm->SetLineWidth(2);
          dis_cc_n_charm->Draw("l");
          TGraph * dis_cc_n_1  = (TGraph*) dir_curr->Get("dis_cc_n_sbarsea");
          TGraph * dis_cc_n_2  = (TGraph*) dir_curr->Get("dis_cc_n_dbarsea");
          TGraph * dis_cc_n_3  = (TGraph*) dir_curr->Get("dis_cc_n_uval");
          TGraph * dis_cc_n_4  = (TGraph*) dir_curr->Get("dis_cc_n_usea");
          dis_cc_n_1->SetLineColor(2);
          dis_cc_n_2->SetLineColor(3);
          dis_cc_n_3->SetLineColor(4);
          dis_cc_n_4->SetLineColor(5);
          l->Clear();
          l->AddEntry(dis_cc_n,        "tot (-charm)", "L");
          l->AddEntry(dis_cc_n_1,      "sbar(sea)",    "L");
          l->AddEntry(dis_cc_n_2,      "dbar(sea)",    "L");
          l->AddEntry(dis_cc_n_3,      "u(val)",       "L");
          l->AddEntry(dis_cc_n_4,      "u(sea)",       "L");
          l->AddEntry(dis_cc_n_charm,  "tot charm",    "L");
          dis_cc_n_1->Draw("L");
          dis_cc_n_2->Draw("L");
          dis_cc_n_3->Draw("L");
          dis_cc_n_4->Draw("L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("DIS-CC / %s+n%s",neutrino,target));
          ls->Draw();
	  c->Update();
*/
     }
     // DIS NC numubar+p(Fe56)
     {
/*
	  TGraph * dis_nc_p = (TGraph*) dir_curr->Get("dis_nc_p");
          dis_nc_p->Draw("l");
          TGraph * dis_nc_p_1  = (TGraph*) dir_curr->Get("dis_nc_p_sbarsea");
          TGraph * dis_nc_p_2  = (TGraph*) dir_curr->Get("dis_nc_p_ubarsea");
          TGraph * dis_nc_p_3  = (TGraph*) dir_curr->Get("dis_nc_p_dbarsea");
          TGraph * dis_nc_p_4  = (TGraph*) dir_curr->Get("dis_nc_p_dval");
          TGraph * dis_nc_p_5  = (TGraph*) dir_curr->Get("dis_nc_p_dsea");
          TGraph * dis_nc_p_6  = (TGraph*) dir_curr->Get("dis_nc_p_uval");
          TGraph * dis_nc_p_7  = (TGraph*) dir_curr->Get("dis_nc_p_usea");
          TGraph * dis_nc_p_8  = (TGraph*) dir_curr->Get("dis_nc_p_ssea");
          dis_nc_p_1->SetLineColor(2);
          dis_nc_p_2->SetLineColor(3);
          dis_nc_p_3->SetLineColor(4);
          dis_nc_p_4->SetLineColor(5);
          dis_nc_p_5->SetLineColor(6);
          dis_nc_p_6->SetLineColor(7);
          dis_nc_p_7->SetLineColor(8);
          dis_nc_p_8->SetLineColor(9);
          l->Clear();
          l->AddEntry(dis_nc_p,   "total",     "L");
          l->AddEntry(dis_nc_p_1, "sbar(sea)", "L");
          l->AddEntry(dis_nc_p_2, "ubar(sea)", "L");
          l->AddEntry(dis_nc_p_3, "dbar(sea)", "L");
          l->AddEntry(dis_nc_p_4, "d(val)",    "L");
          l->AddEntry(dis_nc_p_5, "d(sea)",    "L");
          l->AddEntry(dis_nc_p_6, "u(val)",    "L");
          l->AddEntry(dis_nc_p_7, "u(sea)",    "L");
          l->AddEntry(dis_nc_p_8, "s(sea)",    "L");
          dis_nc_p_1->Draw("L");
          dis_nc_p_2->Draw("L");
          dis_nc_p_3->Draw("L");
          dis_nc_p_4->Draw("L");
          dis_nc_p_5->Draw("L");
          dis_nc_p_6->Draw("L");
          dis_nc_p_7->Draw("L");
          dis_nc_p_8->Draw("L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("DIS-NC / %s+p%s",neutrino,target));
          ls->Draw();
	  c->Update();
*/
     }
     // DIS NC numu+n(Fe56)
     {
/*
	  TGraph * dis_nc_n = (TGraph*) dir_curr->Get("dis_nc_n");
          dis_nc_n->Draw("l");
          TGraph * dis_nc_n_1  = (TGraph*) dir_curr->Get("dis_nc_n_sbarsea");
          TGraph * dis_nc_n_2  = (TGraph*) dir_curr->Get("dis_nc_n_ubarsea");
          TGraph * dis_nc_n_3  = (TGraph*) dir_curr->Get("dis_nc_n_dbarsea");
          TGraph * dis_nc_n_4  = (TGraph*) dir_curr->Get("dis_nc_n_dval");
          TGraph * dis_nc_n_5  = (TGraph*) dir_curr->Get("dis_nc_n_dsea");
          TGraph * dis_nc_n_6  = (TGraph*) dir_curr->Get("dis_nc_n_uval");
          TGraph * dis_nc_n_7  = (TGraph*) dir_curr->Get("dis_nc_n_usea");
          TGraph * dis_nc_n_8  = (TGraph*) dir_curr->Get("dis_nc_n_ssea");
          dis_nc_n_1->SetLineColor(2);
          dis_nc_n_2->SetLineColor(3);
          dis_nc_n_3->SetLineColor(4);
          dis_nc_n_4->SetLineColor(5);
          dis_nc_n_5->SetLineColor(6);
          dis_nc_n_6->SetLineColor(7);
          dis_nc_n_7->SetLineColor(8);
          dis_nc_n_8->SetLineColor(9);
          l->Clear();
          l->AddEntry(dis_nc_n,   "total",     "L");
          l->AddEntry(dis_nc_n_1, "sbar(sea)", "L");
          l->AddEntry(dis_nc_n_2, "ubar(sea)", "L");
          l->AddEntry(dis_nc_n_3, "dbar(sea)", "L");
          l->AddEntry(dis_nc_n_4, "d(val)",    "L");
          l->AddEntry(dis_nc_n_5, "d(sea)",    "L");
          l->AddEntry(dis_nc_n_6, "u(val)",    "L");
          l->AddEntry(dis_nc_n_7, "u(sea)",    "L");
          l->AddEntry(dis_nc_n_8, "s(sea)",    "L");
          dis_nc_n_1->Draw("L");
          dis_nc_n_2->Draw("L");
          dis_nc_n_3->Draw("L");
          dis_nc_n_4->Draw("L");
          dis_nc_n_5->Draw("L");
          dis_nc_n_6->Draw("L");
          dis_nc_n_7->Draw("L");
          dis_nc_n_8->Draw("L");
          l->Draw();
          ls->Clear();
          ls->SetHeader(Form("DIS-NC / %s+n%s",neutrino,target));
          ls->Draw();
	  c->Update();
*/
     }
  }//nubar
  ps->Close();  
}
//_________________________________________________________________________________
// Download cross section data from NuVld MySQL dbase and compare with GENIE
//.................................................................................
void CompareWithData(void)
{
#ifdef __GENIE_MYSQL_ENABLED__

  // Get a data-base interface
  TSQLServer * sql_server = TSQLServer::Connect(
      gOptDbURL.c_str(),gOptDbUser.c_str(),gOptDbPasswd.c_str());
  assert(sql_server && sql_server->IsConnected());
  dbi = new DBI(sql_server);
  assert(dbi);
 
  TCanvas * c = new TCanvas("c","",20,20,500,650);
  c->SetBorderMode(0);
  c->SetFillColor(0);
  c->SetGridx();
  c->SetGridy();

  //TH1F * hf = 0;
  TLegend * l  = new TLegend(0.80,0.20,0.99,0.99);
  TLegend * ls = new TLegend(0.15,0.85,0.55,0.95);
  l ->SetFillColor(0);
  ls->SetFillColor(0);
  ls->SetBorderSize(1);
  TPostScript * ps = new TPostScript("data_vs_mc-xsections.ps", 111);

  //
  // header
  //
  ps->NewPage();
  c->Range(0,0,100,100);
  TPavesText hdr(10,40,90,70,3,"tr");
  hdr.AddText("GENIE cross sections comparison plots");
  hdr.AddText(" ");
  hdr.AddText(" ");
  hdr.AddText("Notes:");
  hdr.AddText("");
  hdr.AddText("");
  hdr.Draw();
  c->Update();
  TPavesText title(10,40,90,70,1,"ndc");
  
  for(int iset = 0; iset < kNuXSecDataSets; iset++) {
    DBTable<DBNuXSecTableRow> * dbtable = GetNuVldData(iset);

    TGraphAsymmErrors * graph = dbtable->GetGraph("all-noE");
    double xmin  = ( graph->GetX() )[TMath::LocMin(graph->GetN(),graph->GetX())];
    double xmax  = ( graph->GetX() )[TMath::LocMax(graph->GetN(),graph->GetX())];
    double ymin  = ( graph->GetY() )[TMath::LocMin(graph->GetN(),graph->GetY())];
    double ymax  = ( graph->GetY() )[TMath::LocMax(graph->GetN(),graph->GetY())];

    c->Clear();
    c->Divide(2,1);
    c->GetPad(1)->SetPad("mplots_pad","",0.01,0.25,0.99,0.99);
    c->GetPad(2)->SetPad("legend_pad","",0.01,0.01,0.99,0.24);
    c->GetPad(1)->SetFillColor(0);
    c->GetPad(1)->SetBorderMode(0);
    c->GetPad(2)->SetFillColor(0);
    c->GetPad(2)->SetBorderMode(0);
    c->GetPad(1)->cd();
    c->GetPad(1)->SetBorderMode(0);

    c->GetPad(1)->SetLogx();
    c->GetPad(1)->SetLogy();

    TH1F * hframe = (TH1F*) c->GetPad(1)->DrawFrame(.5*xmin, .4*ymin, 1.2*xmax, 1.42*ymax);
    hframe->Draw();

    // draw current data set
    //
    MultiGraph * mgraph = dbtable->GetMultiGraph("all-noE");
    for(unsigned int igraph = 0; igraph < mgraph->NGraphs(); igraph++) {
       mgraph->GetGraph(igraph)->Draw("P");
    }

    // compare with corresponding GENIE prodiction
    //
    TGraph * model = NuXSecPrediction(iset);
    if(model) {
       model->Draw("L");
    }

    c->GetPad(2)->cd();
    TLegend * legend = new TLegend(0.01, 0.01, 0.99, 0.99);
    legend->SetFillColor(0);
    mgraph->FillLegend("LP", legend);
    legend->SetTextSize(0.08);
    legend->Draw();

    c->GetPad(2)->Update();
    c->Update();

/*
    // save current table to ROOT file
    ostringstream name;
    name << "nuxsec_data_" << iset;
    TGraphAsymmErrors * gr = dbtable->GetGraph("all-noE");
    gr->SetMarkerStyle(8);
    gr->SetMarkerSize(1.2);
    gr->Write(name.str().c_str());
 */
    delete dbtable;
  }

  ps->Close();

#endif
}
//_________________________________________________________________________________
DBQueryString FormQuery(const char * key_list, float emin, float emax)
{
// forms a DBQueryString for extracting neutrino cross section data from the input 
// key-list and for the input energy range
  
  ostringstream query_string;
  
  query_string 
    << "KEY-LIST:" << key_list
    << "$CUTS:Emin=" << emin << ";Emax=" << emax << "$DRAW_OPT:none$DB-TYPE:vN-XSec";
  
  DBQueryString query(query_string.str());
  
  return query;
}
//_________________________________________________________________________________
DBTable<DBNuXSecTableRow> * GetNuVldData(int iset)
{
  DBTable<DBNuXSecTableRow> * dbtable = new DBTable<DBNuXSecTableRow>;

  const char * keylist = kNuXSecKeyList[iset];
  float        e_min   = kNuXSecERange[iset][0];
  float        e_max   = kNuXSecERange[iset][1];

  DBQueryString query = FormQuery(keylist, e_min, e_max);
  assert( dbi->FillTable(dbtable, query) == eDbu_OK );

  return dbtable;
}
//_________________________________________________________________________________
TGraph * NuXSecPrediction(int iset)
{
    switch(iset) {
    case (0) :
    case (1) :
    case (2) :
    {
       TDirectory * dir  = (TDirectory *) gXSecFile_curr->Get("nu_mu_n");
       TGraph * model = (TGraph*) dir->Get("qel_cc_n");
       return model;
       break;
    }
    case (3) :
    case (4) :
    case (5) :
    {
       TDirectory * dir  = (TDirectory *) gXSecFile_curr->Get("nu_mu_bar_H1");
       TGraph * model = (TGraph*) dir->Get("qel_cc_p");
       return model;
       break;
    }
    case (6) :
    {
       TDirectory * dir  = (TDirectory *) gXSecFile_curr->Get("nu_mu_H1");
       TGraph * model = (TGraph*) dir->Get("res_cc_p");
       return model;
       break;
    }
    case (7) :
    {
       TDirectory * dir_n  = (TDirectory *) gXSecFile_curr->Get("nu_mu_n");
       TGraph * model_n = (TGraph*) dir_n->Get("tot_cc_n");
       TDirectory * dir_p  = (TDirectory *) gXSecFile_curr->Get("nu_mu_H1");
       TGraph * model_p = (TGraph*) dir_p->Get("tot_cc_p");
       const int n = 1000;
       double e[n], sig[n];
       for(int i=0; i<n; i++) {
         e  [i] = 5 + i*0.1;
         sig[i] = 0.5*(model_n->Eval(e[i]) + model_p->Eval(e[i]));
       }
       TGraph * model = new TGraph(n,e,sig);
       return model;
       break;
    }
    case (8) :
    {
       TDirectory * dir_n  = (TDirectory *) gXSecFile_curr->Get("nu_mu_bar_n");
       TGraph * model_n = (TGraph*) dir_n->Get("tot_cc_n");
       TDirectory * dir_p  = (TDirectory *) gXSecFile_curr->Get("nu_mu_bar_H1");
       TGraph * model_p = (TGraph*) dir_p->Get("tot_cc_p");
       const int n = 1000;
       double e[n], sig[n];
       for(int i=0; i<n; i++) {
         e  [i] = 5 + i*0.1;
         sig[i] = 0.5*(model_n->Eval(e[i]) + model_p->Eval(e[i]));
       }
       TGraph * model = new TGraph(n,e,sig);
       return model;
       break;
    }
    case (9) :
    {
       break;
    }
    case (10) :
    {
       break;
    }
    case (11) :
    {
       break;
    }

/*
6    neutrino      RES [all: v + p -> mu- + p + pi+]
9    neutrino      MPP [v + n -> l + p + pi+ + pi-]
10   neutrino      MPP [v + p -> l + p + pi+ + pi0]
11   neutrino      MPP [v + p -> l + n + pi+ + pi+]
*/
    default:
       return 0;
    }

    return 0;
}
//_________________________________________________________________________________
// Formatting
//.................................................................................
TH1F* DrawFrame(TGraph * gr0, TGraph * gr1, TCanvas * c)
{
  double xmin = 1E-5;
  double xmax = 1;
  double ymin = 1E-5;
  double ymax = 1;

  if(gr0) {  
    TAxis * x0 = gr0 -> GetXaxis();
    TAxis * y0 = gr0 -> GetYaxis();
    xmin = x0 -> GetXmin();
    xmax = x0 -> GetXmax();
    ymin = y0 -> GetXmin();
    ymax = y0 -> GetXmax();
  }
  if(gr1) {
     TAxis * x1 = gr1 -> GetXaxis();
     TAxis * y1 = gr1 -> GetYaxis();
     xmin = TMath::Min(xmin, x1 -> GetXmin());
     xmax = TMath::Max(xmax, x1 -> GetXmax());
     ymin = TMath::Min(ymin, y1 -> GetXmin());
     ymax = TMath::Max(ymax, y1 -> GetXmax());
  }
  xmin *= 0.5;
  xmax *= 1.5;
  ymin *= 0.5;
  ymax *= 1.5;
  xmin = TMath::Max(0.1, xmin);
  
  TH1F * hf = (TH1F*) c->DrawFrame(xmin, ymin, xmax, ymax);
  hf->GetXaxis()->SetTitle("E (GeV)");
  hf->GetYaxis()->SetTitle("#sigma (10^{-38} cm^{2})");
  hf->GetYaxis()->SetTitleSize(0.03);
  hf->GetYaxis()->SetTitleOffset(1.3);
  hf->GetXaxis()->SetLabelSize(0.03);
  hf->GetYaxis()->SetLabelSize(0.03);
  return hf;
}
//_________________________________________________________________________________
void Format(
    TGraph* gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
{
  if(!gr) return;

  if (lcol >= 0) gr -> SetLineColor   (lcol);
  if (lsty >= 0) gr -> SetLineStyle   (lsty);
  if (lwid >= 0) gr -> SetLineWidth   (lwid);

  if (mcol >= 0) gr -> SetMarkerColor (mcol);
  if (msty >= 0) gr -> SetMarkerStyle (msty);
  if (msiz >= 0) gr -> SetMarkerSize  (msiz);
}
//_________________________________________________________________________________
void Draw(TGraph* gr, const char * opt)
{
  if(!gr) return;
  gr->Draw(opt);
}
//_________________________________________________________________________________
// Parsing command-line arguments, check/form filenames, etc
//.................................................................................
void GetCommandLineArgs(int argc, char ** argv)
{
  LOG("gvldtest", pNOTICE) << "*** Parsing commad line arguments";

  // get input GENIE cross section file
  try {
    gOptXSecFilename_curr = utils::clap::CmdLineArgAsString(argc,argv,'f');
    bool ok = CheckRootFilename(gOptXSecFilename_curr.c_str());
    if(!ok) {
      PrintSyntax();
      exit(1);
    }
  } catch(exceptions::CmdLineArgParserException e) {
    if(!e.ArgumentFound()) {
      PrintSyntax();
      exit(1);
    }
  }

  // get [reference] input GENIE cross section file
  try {
    gOptXSecFilename_ref0 = utils::clap::CmdLineArgAsString(argc,argv,'r');
    bool ok = CheckRootFilename(gOptXSecFilename_ref0.c_str());
    if(!ok) {
      PrintSyntax();
      exit(1);
    }
    gOptHaveRef = true;
  } catch(exceptions::CmdLineArgParserException e) {
    if(!e.ArgumentFound()) {
      LOG("gvldtest", pNOTICE) << "No reference cross section file";
      gOptHaveRef = false;
    }
  }

  // check whether to compare with data
  gOptCmpWithData = genie::utils::clap::CmdLineArgAsBool(argc,argv,'d');

  if(gOptCmpWithData) {

   // get DB URL
   try {
     gOptDbURL = utils::clap::CmdLineArgAsString(argc,argv,'h');
   } catch(exceptions::CmdLineArgParserException e) {
     if(!e.ArgumentFound()) {
       gOptDbURL = kDefDbURL;
     }
   }

   // get DB username
   try {
     gOptDbUser = utils::clap::CmdLineArgAsString(argc,argv,'u');
   } catch(exceptions::CmdLineArgParserException e) {
     if(!e.ArgumentFound()) {
       PrintSyntax();
       exit(1);
     }
   }

   // get DB passwd
   try {
     gOptDbPasswd = utils::clap::CmdLineArgAsString(argc,argv,'p');
   } catch(exceptions::CmdLineArgParserException e) {
     if(!e.ArgumentFound()) {
       PrintSyntax();
       exit(1);
     }
   }

  } // -d enabled?

}
//_________________________________________________________________________________
void PrintSyntax(void)
{
  LOG("gvldtest", pNOTICE)
    << "\n\n" << "Syntax:" << "\n"
    << "   gNuSampleTest  -f sample.root [-n nev] [-r reference_sample.root]\n";
}
//_________________________________________________________________________________
bool CheckRootFilename(string filename)
{
  if(filename.size() == 0) return false;

  bool is_accessible = ! (gSystem->AccessPathName(filename.c_str()));
  if (!is_accessible) {
   LOG("gvldtest", pERROR)
       << "The input ROOT file [" << filename << "] is not accessible";
   return false;
  }
  return true;
}
//_________________________________________________________________________________
string OutputFileName(string inpname)
{
// Builds the output filename based on the name of the input filename
// Perfors the following conversion: name.root -> name.nuxsec_test.ps

  unsigned int L = inpname.length();

  // if the last 4 characters are "root" (ROOT file extension) then
  // remove them
  if(inpname.substr(L-4, L).find("root") != string::npos) {
    inpname.erase(L-4, L);
  }

  ostringstream name;
  name << inpname << "nuxsec_test.ps";

  return gSystem->BaseName(name.str().c_str());
}
//_________________________________________________________________________________

