7 #ifndef H_POTTU_OBJECTTREE
8 #define H_POTTU_OBJECTTREE
17 #include <sys/types.h>
31 static inline bool operator<(
const std::unique_ptr<OTObject> &o1,
const std::unique_ptr<OTObject> &o2 ) {
32 return( o1->name() < o2->name() );
34 static inline bool operator<(
const std::string &name,
const std::unique_ptr<OTObject> &oto ) {
35 return( name < oto->name() );
37 static inline bool operator<(
const std::unique_ptr<OTObject> &oto,
const std::string &name ) {
38 return( oto->name() < name );
56 ObjectTree *createSubTree(
const std::string &name ) {
57 auto it = _objects.find<std::string>( name );
58 if( it != _objects.end() )
59 throw std::runtime_error( std::string()+
"Object with name " + name +
" already in the tree." );
63 _objects.emplace( p );
69 createHistogram1D(
const std::string &name,
70 double low,
double high,
unsigned int binc,
71 const std::string &title =
"",
72 const std::string &xlabel =
"",
73 const std::string &ylabel =
"" ) {
74 auto it = _objects.find<std::string>( name );
75 if( it != _objects.end() )
76 throw std::runtime_error( std::string()+
"Object with name " + name +
" already in the tree." );
78 auto p =
new OTOH1D_double_64( name, low, high, binc, title, xlabel, ylabel );
80 _objects.emplace( p );
85 createHistogram1D_doublecell(
const std::string &name,
86 double low,
double high,
unsigned int binc,
87 const std::string &title =
"",
88 const std::string &xlabel =
"",
89 const std::string &ylabel =
"" ) {
90 auto it = _objects.find<std::string>( name );
91 if( it != _objects.end() )
92 throw std::runtime_error( std::string()+
"Object with name " + name +
" already in the tree." );
96 _objects.emplace( p );
101 createHistogram1D_pow2(
const std::string &name,
102 uint32_t high_bits, uint32_t bins_bits,
103 const std::string &title =
"",
104 const std::string &xlabel =
"",
105 const std::string &ylabel =
"" ) {
106 auto it = _objects.find<std::string>( name );
107 if( it != _objects.end() )
108 throw std::runtime_error( std::string()+
"Object with name " + name +
" already in the tree." );
110 auto p =
new OTOH1D_pow2_64( name, high_bits, bins_bits, title, xlabel, ylabel );
112 _objects.emplace( p );
119 createHistogram2D(
const std::string &name,
120 double xlow,
double xhigh,
unsigned int xbinc,
121 double ylow,
double yhigh,
unsigned int ybinc,
122 const std::string &title =
"",
123 const std::string &xlabel =
"",
124 const std::string &ylabel =
"",
125 const std::string &zlabel =
"" ) {
126 auto it = _objects.find<std::string>( name );
127 if( it != _objects.end() )
128 throw std::runtime_error( std::string()+
"Object with name " + name +
" already in the tree." );
133 title, xlabel, ylabel, zlabel );
135 _objects.emplace( p );
141 createHistogram2D_doublecell(
const std::string &name,
142 double xlow,
double xhigh,
unsigned int xbinc,
143 double ylow,
double yhigh,
unsigned int ybinc,
144 const std::string &title =
"",
145 const std::string &xlabel =
"",
146 const std::string &ylabel =
"",
147 const std::string &zlabel =
"" ) {
148 auto it = _objects.find<std::string>( name );
149 if( it != _objects.end() )
150 throw std::runtime_error( std::string()+
"Object with name " + name +
" already in the tree." );
155 title, xlabel, ylabel, zlabel );
157 _objects.emplace( p );
163 virtual void exportToDisk(
const std::string &prefix,
export_context_t &ectx )
const {
167 std::string newprefix=prefix;
171 std::cout <<
"Trying to create \'" << newprefix <<
"\'\n";
173 int ret = mkdir( newprefix.c_str(), 0777 );
174 if( ret == -1 && errno != EEXIST ) {
175 throw std::runtime_error( strerror(errno) );
186 for(
auto &obj : _objects ) {
188 obj->exportToDisk( newprefix, ectx );
196 std::set< std::unique_ptr<OTObject>, std::less<> > _objects;
Binner with float values.
Definition: binners.hpp:19
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
Class holding tree of histograms and subtrees.
Definition: ObjectTree.hpp:44
Definition: mainpage.dox:6
Definition: OTObject.hpp:30