The XSec class generates plots or splines of cross sections, and is somewhat independent from the rest of FluxReader. It does not get its input from flux files, rather, it looks in the environment variable $GENIEXSECPATH for its input file.


The constructor does not take any input, so it simply needs to be declared.

  XSec xsec();

General Use

Cross sections can be pulled in a variety of formats, but the standard method should be to create a TSpline3. The user must specify three arguments, an integer sign sensitive PDG code to specify the neutrino flavor, a std::string nuclear target (that does not include the number of nucleons), and a std::string current type. There are a lot of currents the user can specify, but most of the time the currents tot_cc or tot_nc will be what the user needs. However, the function ListIntTypes will list all available options.


With the three arguments, the user can create a cross section spline. The following example shows the cross section of muon neutrinos scattering off CH2 via charged current.

  TSpline3* spl = xsec.GetXSec(+14, "CH2", "tot_cc");

To evaluate a spline, the Eval function can be called directly on the TSpline3. However, there is also an XSec::XSecEval function. The advantage of the XSecEval function is that it automatically protects against negative output, as cross sections must always be positive. The example below evaluates the previous cross section spline at 5 GeV.

  double option1 = spl->Eval(5.);
  double option2 = xsec.XSecEval(spl, 5.);

The user can also get a ratio of two cross sections directly. The function GetXSecRatio takes two sets of the three cross section arguments. The first set of arguments is the numerator cross section, and the second set is the denominator. The example below creates a spline of the ratio of charged current scattering off CH2 for muon neutrinos over electron neutrinos.

  TSpline3* rat = xsec.GetXSecRatio(+14,"CH2","tot_cc", +12,"CH2","tot_cc");

The user can also generate a TGraph using the functions GetGraph or GetGraphRatio, with the same arguments as GetXSec or GetXSecRatio. The same spline ratio is generated below as a TGraph.

  TGraph* grat = xsec.GetGraphRatio(+14,"CH2","tot_cc", +12,"CH2","tot_cc");

Finally, a user can create a TH1 using the function GetHist. GetHist takes a TSpline3* as input, an integer number of bins, and either a double minimum edge and double maximum edge, or a pointer to an array of double bin edges. Since GetHist takes a TSpline3* as an argument, there is no need for a secondary function for making a ratio. The histogram is created by a pseudo-integration of the spline. For each bin, the integral is performed by using a minimum of 10 equally spaced trapezoids. The maximum length (delta x) is 0.1 GeV, so if the histogram bin is larger than 1 GeV, more than 10 trapezoids will be evaluated. The area of all the trapezoids are summed, and then result is averaged over the length of the bin. This calculation is motivated from the fact that cross sections scale linearly with energy for a large portion of the energy range.

The example below takes the original spline, and turns it into a histogram with 120 equally spaced bins from 0 to 120 GeV. Two methods are shown, one calling GetXSec inside of GetHist (the preferred method), and the other using the actual object created above, spl.

  TH1* hist1 = xsec.GetHist(xsec.GetXSec(+14, "CH2", "tot_cc"), 120, 0., 120.);
  TH1* hist2 = xsec.GetHist(spl,                                120, 0., 120.); // White space for style

A few other publicly accessible functions exist, though their use is limited. If the user is interested in the path name generated to access a particular cross section from the input file, the function GetXSecGenStr can be used. This will output the path to the most recently accessed cross section.

  std::cout << xsec.GetXSecGenStr() << std::endl;

If the user is interested in knowing what file is actually being used for cross section input, GetXSecFileName will output this.

  std::cout << xsec.GetXSecFileName() << std::endl;

Finally, if the user wants to override the default file, the user can use the SetXSecFileName, with a std::string argument pointing to the location of the new file. Generally, this should never be necessary.

For users that are particularly savvy using splines, both GetXSec and GetXSecRatio have two optional arguments that can be specified after all of the cross section specific arguments. When constructing a general TSpline3, the user can optionally input a const char* set of options, a double beginning value, and a double ending value. Within the GetXSec(Ratio) function, the user can specify the optional const char* input and the optional double beginning value, but not the ending value. As energy decreases, all cross sections should approach zero. The intention of including those two optional arguments in the GetXSec(Ratio) functions is to allow the user to force the cross section to approach zero (the beginning value) with decreasing energy in a particular way (the const char* set of options). Please see the ROOT documentation to learn how to use these options. However, the user can omit these options for most uses.