31 std::string h1dtype{
"gzip_json"};
32 std::string h2dtype{
"gzip_json"};
33 std::string tmp1, tmp2;
41 OTObject(
const std::string &name_ ) : _name( name_ ) {}
47 const std::string &name()
const {
return(_name);}
51 virtual void exportToDisk(
const std::string &prefix,
71 double low,
double high,
double binc,
72 const std::string &title =
"",
73 const std::string &xlabel =
"",
74 const std::string &ylabel =
"" )
75 :
OTObject(name), _h( low, high, binc )
77 _h.setTitle(title); _h.setXlabel(xlabel); _h.setYlabel(ylabel);
82 virtual void exportToDisk(
const std::string &prefix,
export_context_t &ectx )
const {
84 if( ectx.h1dtype ==
"gzip_json" ) {
85 nlohmann::json j = _h.getAsJSON();
86 ectx.tmp1 = std::move(j.dump());
87 gzFile f = gzopen( (prefix+name()+
".h1d").c_str(),
"wb" );
88 gzwrite( f, ectx.tmp1.data(), ectx.tmp1.size() );
90 }
else if( ectx.h1dtype ==
"ascii" ) {
91 std::ofstream f( prefix+name() );
93 throw std::runtime_error( std::string()+
"Couldn\'t open file "+prefix+name()+
"!" );
96 throw std::runtime_error( std::string()+
"Unsupported h1dtype: "+ectx.h1dtype );
112 double low,
double high,
double binc,
113 const std::string &title =
"",
114 const std::string &xlabel =
"",
115 const std::string &ylabel =
"" )
116 :
OTObject(name), _h( low, high, binc )
118 _h.setTitle(title); _h.setXlabel(xlabel); _h.setYlabel(ylabel);
123 virtual void exportToDisk(
const std::string &prefix,
export_context_t &ectx )
const {
125 if( ectx.h1dtype ==
"gzip_json" ) {
126 nlohmann::json j = _h.getAsJSON();
127 ectx.tmp1 = std::move(j.dump());
128 gzFile f = gzopen( (prefix+name()+
".h1d").c_str(),
"wb" );
129 gzwrite( f, ectx.tmp1.data(), ectx.tmp1.size() );
131 }
else if( ectx.h1dtype ==
"ascii" ) {
132 std::ofstream f( prefix+name() );
134 throw std::runtime_error( std::string()+
"Couldn\'t open file "+prefix+name()+
"!" );
137 throw std::runtime_error( std::string()+
"Unsupported h1dtype: "+ectx.h1dtype );
152 uint32_t high_bits, uint32_t bins_bits,
153 const std::string &title =
"",
154 const std::string &xlabel =
"",
155 const std::string &ylabel =
"" )
158 _h.setTitle(title); _h.setXlabel(xlabel); _h.setYlabel(ylabel);
163 virtual void exportToDisk(
const std::string &prefix,
export_context_t &ectx )
const {
164 if( ectx.h1dtype ==
"gzip_json" ) {
165 nlohmann::json j = _h.getAsJSON();
166 ectx.tmp1 = std::move(j.dump());
167 gzFile f = gzopen( (prefix+name()+
".h1d").c_str(),
"wb" );
168 gzwrite( f, ectx.tmp1.data(), ectx.tmp1.size() );
170 }
else if( ectx.h1dtype ==
"ascii" ) {
171 std::ofstream f( prefix+name() );
173 throw std::runtime_error( std::string()+
"Couldn\'t open file "+prefix+name()+
"!" );
176 throw std::runtime_error( std::string()+
"Unsupported h1dtype: "+ectx.h1dtype );
190 double xlow,
double xhigh,
double xbinc,
191 double ylow,
double yhigh,
double ybinc,
192 const std::string &title =
"",
193 const std::string &xlabel =
"",
194 const std::string &ylabel =
"",
195 const std::string &zlabel =
"" )
196 :
OTObject(name), _h( xlow, xhigh, xbinc, ylow, yhigh, ybinc )
198 _h.setTitle(title); _h.setXlabel(xlabel); _h.setYlabel(ylabel); _h.setZlabel(zlabel);
203 virtual void exportToDisk(
const std::string &prefix,
export_context_t &ectx )
const {
204 if( ectx.h1dtype ==
"gzip_json" ) {
205 nlohmann::json j = _h.getAsJSON();
206 ectx.tmp1 = std::move(j.dump());
207 gzFile f = gzopen( (prefix+name()+
".h2d").c_str(),
"wb" );
208 gzwrite( f, ectx.tmp1.data(), ectx.tmp1.size() );
210 }
else if( ectx.h1dtype ==
"gnuplot_binary" ) {
211 std::ofstream f( prefix+name() );
213 throw std::runtime_error( std::string()+
"Couldn\'t open file "+prefix+name()+
"!" );
214 _h.exportGnuplotBinary( f );
216 throw std::runtime_error( std::string()+
"Unsupported h1dtype: "+ectx.h1dtype );
230 double xlow,
double xhigh,
double xbinc,
231 double ylow,
double yhigh,
double ybinc,
232 const std::string &title =
"",
233 const std::string &xlabel =
"",
234 const std::string &ylabel =
"",
235 const std::string &zlabel =
"" )
236 :
OTObject(name), _h( xlow, xhigh, xbinc, ylow, yhigh, ybinc )
238 _h.setTitle(title); _h.setXlabel(xlabel); _h.setYlabel(ylabel); _h.setZlabel(zlabel);
243 virtual void exportToDisk(
const std::string &prefix,
export_context_t &ectx )
const {
244 if( ectx.h1dtype ==
"gzip_json" ) {
245 nlohmann::json j = _h.getAsJSON();
246 ectx.tmp1 = std::move(j.dump());
247 gzFile f = gzopen( (prefix+name()+
".h2d").c_str(),
"wb" );
248 gzwrite( f, ectx.tmp1.data(), ectx.tmp1.size() );
250 }
else if( ectx.h1dtype ==
"gnuplot_binary" ) {
251 std::ofstream f( prefix+name() );
253 throw std::runtime_error( std::string()+
"Couldn\'t open file "+prefix+name()+
"!" );
254 _h.exportGnuplotBinary( f );
256 throw std::runtime_error( std::string()+
"Unsupported h1dtype: "+ectx.h1dtype );
Binner with float values.
Definition: binners.hpp:19
Binner for histograms with integer values and bin counts of powers of two.
Definition: binners.hpp:104
Simple 1D histogram.
Definition: Histogram1D.hpp:26
Simple 2D histogram.
Definition: Histogram2D.hpp:22
OTObject wrapper for Histogram1D.
Definition: OTObject.hpp:68
OTObject wrapper for Histogram1D.
Definition: OTObject.hpp:109
OTObject wrapper for power of two histogram 1D.
Definition: OTObject.hpp:149
OTObject wrapper for Histogram2D.
Definition: OTObject.hpp:187
OTObject wrapper for Histogram2D.
Definition: OTObject.hpp:227
Pure virtual base class for ObjectTree objects.
Definition: OTObject.hpp:39
Definition: mainpage.dox:6
Definition: OTObject.hpp:30