Jpp 21.0.1
the software that should make you happy
Loading...
Searching...
No Matches
JROOT::JBinsMap Class Reference

Class for I/O of variable-width binning of multiple histograms. More...

#include <JBinsMap.hh>

Inheritance diagram for JROOT::JBinsMap:
std::map< std::string, std::map< char, std::vector< double > > >

Public Types

typedef std::map< std::string, std::map< char, std::vector< double > > > map_type
 
typedef map_type::mapped_type mapped_type
 
typedef map_type::value_type value_type
 
typedef map_type::iterator iterator
 
typedef map_type::reverse_iterator reverse_iterator
 
typedef map_type::const_iterator const_iterator
 
typedef map_type::const_reverse_iterator const_reverse_iterator
 

Public Member Functions

template<class T >
std::unique_ptr< T > getHistogram (const std::string &name) const
 Get histogram with binning corresponding to a given histogram name.
 

Static Private Attributes

static const char SEPARATOR = ':'
 Separator for axis label.
 

Friends

std::istream & operator>> (std::istream &in, JBinsMap &binning)
 Read binning from stream.
 
std::ostream & operator<< (std::ostream &out, const JBinsMap &binning)
 Write binning to output.
 

Detailed Description

Class for I/O of variable-width binning of multiple histograms.

Definition at line 38 of file JBinsMap.hh.

Member Typedef Documentation

◆ map_type

std::map<std::string, std::map<char, std::vector<double> > > JROOT::JBinsMap::map_type

Definition at line 43 of file JBinsMap.hh.

◆ mapped_type

map_type::mapped_type JROOT::JBinsMap::mapped_type

Definition at line 45 of file JBinsMap.hh.

◆ value_type

map_type::value_type JROOT::JBinsMap::value_type

Definition at line 46 of file JBinsMap.hh.

◆ iterator

map_type::iterator JROOT::JBinsMap::iterator

Definition at line 48 of file JBinsMap.hh.

◆ reverse_iterator

map_type::reverse_iterator JROOT::JBinsMap::reverse_iterator

Definition at line 49 of file JBinsMap.hh.

◆ const_iterator

map_type::const_iterator JROOT::JBinsMap::const_iterator

Definition at line 51 of file JBinsMap.hh.

◆ const_reverse_iterator

map_type::const_reverse_iterator JROOT::JBinsMap::const_reverse_iterator

Definition at line 52 of file JBinsMap.hh.

Member Function Documentation

◆ getHistogram()

template<class T >
std::unique_ptr< T > JROOT::JBinsMap::getHistogram ( const std::string & name) const
inline

Get histogram with binning corresponding to a given histogram name.

Parameters
namehistogram name
Returns
pointer to 1D histogram

Definition at line 62 of file JBinsMap.hh.

63 {
64 static const JBinsMapHelper<T> getHistogram(*this);
65
66 return getHistogram(name);
67 }
std::unique_ptr< T > getHistogram(const std::string &name) const
Get histogram with binning corresponding to a given histogram name.
Definition JBinsMap.hh:62

Friends And Related Symbol Documentation

◆ operator>>

std::istream & operator>> ( std::istream & in,
JBinsMap & binning )
friend

Read binning from stream.

Parameters
ininput stream
Returns
input stream

Definition at line 76 of file JBinsMap.hh.

77 {
78 using namespace std;
79 using namespace JPP;
80
81 JStringStream is(in);
82
83 for (string name; is >> name; ) {
84
85 if (name.back() == SEPARATOR) { name.pop_back(); }
86
87 mapped_type binsMap;
88
89 for (char axis; is >> axis; ) {
90
91 if (axis != 'x' &&
92 axis != 'X' &&
93 axis != 'y' &&
94 axis != 'Y' &&
95 axis != 'z' &&
96 axis != 'Z') {
97 is.clear();
98 is.seekg(-1, ios::cur);
99 break;
100 }
101
102 axis = char(tolower(axis));
103
104 if (is.peek() == (int) SEPARATOR) { is.ignore(); }
105
106 vector<double> bins;
107
108 for (double value; is >> value; ) {
109
110 vector<double>::const_iterator i = std::lower_bound(bins.cbegin(), bins.cend(), value);
111
112 if (i == bins.cend() || *i != value) {
113 bins.insert(i, value);
114 }
115 }
116
117 binsMap.insert(make_pair(axis, bins));
118
119 is.clear();
120 }
121
122 binning.insert(make_pair(name, binsMap));
123 }
124
125 return in;
126 }
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
static const char SEPARATOR
Separator for axis label.
Definition JBinsMap.hh:162
map_type::mapped_type mapped_type
Definition JBinsMap.hh:45
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
name
Definition setup.py:24

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JBinsMap & binning )
friend

Write binning to output.

Parameters
outoutput stream
Returns
output stream

Definition at line 135 of file JBinsMap.hh.

136 {
137 using namespace std;
138
139 for (const_iterator i = binning.begin(); i != binning.end(); ++i) {
140
141 out << i->first << SEPARATOR << endl;
142
143 for (typename mapped_type::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
144
145 out << j->first << SEPARATOR;
146
147 for (vector<double>::const_iterator k = j->second.begin(); k != j->second.end(); ++k) {
148 out << ' ' << *k;
149 }
150
151 out << endl;
152 }
153
154 out << endl;
155 }
156
157 return out;
158 }
map_type::const_iterator const_iterator
Definition JBinsMap.hh:51
int j
Definition JPolint.hh:801

Member Data Documentation

◆ SEPARATOR

const char JROOT::JBinsMap::SEPARATOR = ':'
staticprivate

Separator for axis label.

Definition at line 162 of file JBinsMap.hh.


The documentation for this class was generated from the following file: