Jpp 20.0.0-rc.2
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 40 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 45 of file JBinsMap.hh.

◆ mapped_type

map_type::mapped_type JROOT::JBinsMap::mapped_type

Definition at line 47 of file JBinsMap.hh.

◆ value_type

map_type::value_type JROOT::JBinsMap::value_type

Definition at line 48 of file JBinsMap.hh.

◆ iterator

map_type::iterator JROOT::JBinsMap::iterator

Definition at line 50 of file JBinsMap.hh.

◆ reverse_iterator

map_type::reverse_iterator JROOT::JBinsMap::reverse_iterator

Definition at line 51 of file JBinsMap.hh.

◆ const_iterator

map_type::const_iterator JROOT::JBinsMap::const_iterator

Definition at line 53 of file JBinsMap.hh.

◆ const_reverse_iterator

map_type::const_reverse_iterator JROOT::JBinsMap::const_reverse_iterator

Definition at line 54 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 64 of file JBinsMap.hh.

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

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 78 of file JBinsMap.hh.

79 {
80 using namespace std;
81 using namespace JPP;
82
83 JStringStream is(in);
84
85 if (getFileStatus(is.str().c_str())) {
86 is.load();
87 }
88
89 for (string name; is >> name; ) {
90
91 if (name.back() == SEPARATOR) { name.pop_back(); }
92
93 mapped_type binsMap;
94
95 for (char axis; is >> axis; ) {
96
97 if (axis != 'x' &&
98 axis != 'X' &&
99 axis != 'y' &&
100 axis != 'Y' &&
101 axis != 'z' &&
102 axis != 'Z') {
103 is.clear();
104 is.seekg(-1, ios::cur);
105 break;
106 }
107
108 axis = char(tolower(axis));
109
110 if (is.peek() == (int) SEPARATOR) { is.ignore(); }
111
112 vector<double> bins;
113
114 for (double value; is >> value; ) {
115
116 vector<double>::const_iterator i = std::lower_bound(bins.cbegin(), bins.cend(), value);
117
118 if (i == bins.cend() || *i != value) {
119 bins.insert(i, value);
120 }
121 }
122
123 binsMap.insert(make_pair(axis, bins));
124
125 is.clear();
126 }
127
128 binning.insert(make_pair(name, binsMap));
129 }
130
131 return in;
132 }
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:168
map_type::mapped_type mapped_type
Definition JBinsMap.hh:47
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).

◆ operator<<

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

Write binning to output.

Parameters
outoutput stream
Returns
output stream

Definition at line 141 of file JBinsMap.hh.

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

Member Data Documentation

◆ SEPARATOR

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

Separator for axis label.

Definition at line 168 of file JBinsMap.hh.


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