1#ifndef __JROOT__JBINSMAP__ 
    2#define __JROOT__JBINSMAP__ 
   26namespace JPP { 
using namespace JROOT; }
 
   41    public std::map<std::string, std::map<char, std::vector<double> > >
 
   85      if (getFileStatus(is.str().c_str())) {
 
   89      for (
string name; is >> name; ) {
 
   91        if (name.back() == 
SEPARATOR) { name.pop_back(); }
 
   95        for (
char axis; is >> axis; ) {
 
  104            is.seekg(-1, ios::cur);         
 
  108          axis = char(tolower(axis));
 
  110          if (is.peek() == (
int) 
SEPARATOR) { is.ignore(); }
 
  114          for (
double value; is >> value; ) {
 
  116            vector<double>::const_iterator i = std::lower_bound(bins.cbegin(), bins.cend(), value);
 
  118            if (i == bins.cend() || *i != value) {
 
  119              bins.insert(i, value);
 
  123          binsMap.insert(make_pair(axis, bins));
 
  128        binning.insert(make_pair(name, binsMap));
 
 
  145      for (
const_iterator i = binning.begin(); i != binning.end(); ++i) {
 
  149        for (
typename mapped_type::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
 
  153          for (vector<double>::const_iterator k = j->second.begin(); k != j->second.end(); ++k) {
 
 
 
  194    std::unique_ptr<TH1D> 
operator()(
const std::string& name)
 const 
  201      if (i == binsMap.cend()) {
 
  202        THROW(
JNoValue, 
"JBinsMapHelper<TH1D>::operator(): No bin configuration found for " << name);
 
  207      typename JBinsMap::mapped_type::const_iterator p = bins.find(
'x');
 
  209      if (p != bins.cend()) {
 
  213        return std::make_unique<TH1D>(name.c_str(), 
"",
 
  214                                      Xbins.size()-1, Xbins.data());
 
  217      THROW(
JNoValue, 
"JBinsMapHelper<TH1D>::operator(): Missing x-axis binning for " << name);
 
 
 
  248    std::unique_ptr<TH2D> 
operator()(
const std::string& name)
 const 
  255      if (i == binsMap.cend()) {
 
  256        THROW(
JNoValue, 
"JBinsMapHelper<TH2D>::operator(): No bin configuration found for " << name);
 
  261      typename JBinsMap::mapped_type::const_iterator p = bins.find(
'x');
 
  263      if (p != bins.cend()) {
 
  267        typename JBinsMap::mapped_type::const_iterator q = bins.find(
'y');
 
  269        if (q != bins.cend()) {
 
  273          return std::make_unique<TH2D>(name.c_str(), 
"",
 
  274                                        Xbins.size()-1, Xbins.data(),
 
  275                                        Ybins.size()-1, Ybins.data());
 
  278        THROW(
JNoValue, 
"JBinsMapHelper<TH2D>::operator(): Missing y-axis binning for " << name);
 
  281      THROW(
JNoValue, 
"JBinsMapHelper<TH2D>::operator(): Missing x-axis binning for " << name);
 
 
 
  312    std::unique_ptr<TH3D> 
operator()(
const std::string& name)
 const 
  319      if (i == binsMap.cend()) {
 
  320        THROW(
JNoValue, 
"JBinsMapHelper<TH3D>::operator(): No bin configuration found for " << name);
 
  325      typename JBinsMap::mapped_type::const_iterator p = bins.find(
'x');
 
  327      if (p != bins.cend()) {
 
  331        typename JBinsMap::mapped_type::const_iterator q = bins.find(
'y');
 
  333        if (q != bins.cend()) {
 
  337          typename JBinsMap::mapped_type::const_iterator r = bins.find(
'z');
 
  339          if (r != bins.cend()) {
 
  343            return std::make_unique<TH3D>(name.c_str(), 
"",
 
  344                                          Xbins.size()-1, Xbins.data(),
 
  345                                          Ybins.size()-1, Ybins.data(),
 
  346                                          Zbins.size()-1, Zbins.data());
 
  349          THROW(
JNoValue, 
"JBinsMapHelper<TH3D>::operator(): Missing z-axis binning for " << name);
 
  352        THROW(
JNoValue, 
"JBinsMapHelper<TH3D>::operator(): Missing y-axis binning for " << name);
 
  355      THROW(
JNoValue, 
"JBinsMapHelper<TH3D>::operator(): Missing x-axis binning for " << name);
 
 
 
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
 
Exception for missing value.
 
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
 
void load()
Load data from file with name corresponding to current contents.
 
Template declaration of auxiliary class for retrieving histograms corresponding to a given histogram ...
 
Class for I/O of variable-width binning of multiple histograms.
 
friend std::ostream & operator<<(std::ostream &out, const JBinsMap &binning)
Write binning to output.
 
map_type::value_type value_type
 
map_type::const_iterator const_iterator
 
static const char SEPARATOR
Separator for axis label.
 
map_type::reverse_iterator reverse_iterator
 
std::map< std::string, std::map< char, std::vector< double > > > map_type
 
map_type::iterator iterator
 
map_type::mapped_type mapped_type
 
std::unique_ptr< T > getHistogram(const std::string &name) const
Get histogram with binning corresponding to a given histogram name.
 
friend std::istream & operator>>(std::istream &in, JBinsMap &binning)
Read binning from stream.
 
map_type::const_reverse_iterator const_reverse_iterator
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Auxiliary classes and methods for ROOT I/O.
 
std::unique_ptr< TH1D > operator()(const std::string &name) const
Get 1D histogram with binning corresponding to a given histogram name.
 
const JBinsMap & binsMap
Bins map.
 
JBinsMapHelper(const JBinsMap &binsMap)
Constructor.
 
const JBinsMap & binsMap
Bins map.
 
std::unique_ptr< TH2D > operator()(const std::string &name) const
Get 2D histogram with binning corresponding to a given histogram name.
 
JBinsMapHelper(const JBinsMap &binsMap)
Constructor.
 
JBinsMapHelper(const JBinsMap &binsMap)
Constructor.
 
std::unique_ptr< TH3D > operator()(const std::string &name) const
Get 3D histogram with binning corresponding to a given histogram name.
 
const JBinsMap & binsMap
Bins map.