Project

General

Profile

Utilities

Utilities is not a class, but a set of functions useful to many of the other class. The functions useful to the user are discussed here. (Utilities includes others that are not useful to the user, but are used internally by some of the other FluxReader classes.)

Bins

This function takes three arguments, an integer number of bins, a double minimum edge, and a double maximum edge. It will return a std::vector<double> of bin edges, equally spaced. If n_bin is specified as the total number of bins, the returned vector will have n_bin + 1 entries. If the first n_bin entries are thought of the low edge of each bin, then the last entry is the high edge of the last bin and is identical to the input provided as the maximum edge. Within the framework, this function willl usually be called directly in the FluxReader::AddSpectra function, but the user can certainly use the function in general as well. For instance, it may be useful to create a local vector to check that bin edges are what the user expects. An example is shown below that creates 10 bins from 0 to 5 and outputs the edge values.

  std::vector<double> myvec = Bins(10, 0., 5.);
  for(unsigned int i = 0, n = myvec.size(); i < n; ++i) {
    std::cout << myvec[i] << std::endl;
  }

Wildcard

This function takes a std::string as input, and returns a std::vector<std::string>. The idea is that the input string is a path to some files that includes wildcard characters, and the output vector is the path to every file that matches the wildcard pattern. Like with Bins above, the user does not have to call this function directly, but the option is available. For example, if the user is inputting a wildcard string to the constructor of FluxReader but not getting the expected results, the user can try to debug the list of files to use by playing with this function in a test script. The example below demonstrates how to create a vector of file names and output each file name.

  std::vector<std::string> files = Wildcard("/nova/ana/users/rhatcher/dk2nu-data/fullsplit/generic*.root");
  for(unsigned int i = 0, n = files.size(); i < n; ++i) {
    std::cout << files[i] << std::endl;
  }