All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions
util::ROOT Namespace Reference

Classes

class  TDirectoryChanger
 A class restoring the previous TDirectory on destruction. More...
 
class  TStyleChanger
 A class restoring the previous TStyle on destruction. More...
 

Functions

void applyAxisLabels (TAxis *pAxis, std::vector< std::string > const &labels, int first=1)
 Sets all the labels starting with the bin first (1 by default). More...
 
template<typename Coll >
std::pair< std::vector< double >
, std::vector< std::string > > 
makeVariableBinningAndLabels (Coll const &centralPoints)
 Returns a variable size binning for the points. More...
 

Function Documentation

void util::ROOT::applyAxisLabels ( TAxis *  pAxis,
std::vector< std::string > const &  labels,
int  first = 1 
)
inline

Sets all the labels starting with the bin first (1 by default).

Parameters
pAxisthe axis to label
labelsthe labels of each bin
first(default: 1) start from this bin with the first label

Definition at line 175 of file ROOTutils.h.

176  {
177  for (auto&& [iLabel, label]: util::enumerate(labels))
178  pAxis->SetBinLabel(first + iLabel, label.c_str());
179  } // applyAxisLabels()
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
template<typename Coll >
std::pair<std::vector<double>, std::vector<std::string> > util::ROOT::makeVariableBinningAndLabels ( Coll const &  centralPoints)

Returns a variable size binning for the points.

Template Parameters
Colltype of collection of the points
Parameters
centralPointsset of points to build the bins around
Returns
a pair of bin edge and label collections

This algorithm attempts to create a variable width binning so that all specified points fall in the middle of their respective bin.

Note
This algorithm is known to be prone to failure for some point distributions.

The return value is a pair of collections. The first one is a sequence of bin boundaries, starting with the lower edge of the bin for the first point and ending with the upper edge of the last point. Therefore this first collection has a number of element larger than the number of points by one unit. The second collection is a string representing the name of the bin. The first element of this collection is the label of the first bin, that is the label of the bin whose lower edge is the first element of the other collection. The second collection has the same number of elements as the number of points, and smaller by one unit than the edge collection.

Requirements

  • the collection Coll must be
  • the type (T) of values in Coll needs to support the following operations:
    • convertible to double: operator double (T)
    • conversion to string (to_string(T))
  • centralPoint must contain at least two points