4 #ifndef tools_wroot_base_pntuple_column_wise
5 #define tools_wroot_base_pntuple_column_wise
11 #include "../ntuple_booking"
25 file(std::ostream& a_out,
bool a_byte_swap,
uint32 a_compression,
bool a_verbose)
54 const std::string& a_name,
const std::string& a_title,
bool a_verbose)
55 :
parent(a_out,a_seek_directory,a_name,a_title)
56 ,
m_file(a_out,a_byte_swap,a_compression,a_verbose)
59 const std::vector<uint32>& a_basket_sizes,
61 :
parent(a_out,a_seek_directory,a_bkg.name(),a_bkg.title())
62 ,
m_file(a_out,a_byte_swap,a_compression,a_verbose)
64 const std::vector<column_booking>& cols = a_bkg.
columns();
66 if(a_basket_sizes.size()!=cols.size()) {
67 a_out <<
"tools::wroot::base_pntuple_column_wise :"
68 <<
" a_basket_sizes.size() (" << a_basket_sizes.size() <<
") != "
69 <<
"a_bkg.columns().size() (" << a_bkg.
columns().size() <<
")."
73 std::vector<uint32>::const_iterator itb = a_basket_sizes.begin();
77 #define TOOLS_WROOT_PNTUPLE_CREATE_COL(a__type) \
78 if((*it).cls_id()==_cid(a__type())) {\
79 a__type* user = (a__type*)(*it).user_obj();\
81 if(!create_column_ref<a__type>(*itb,(*it).name(),*user)) {\
82 a_out << "tools::wroot::base_pntuple_column_wise : create_column_ref(" << (*it).name() << ") failed." << std::endl;\
83 safe_clear<icol>(m_cols);\
84 safe_clear<branch>(m_branches);\
89 if(!create_column<a__type>(*itb,(*it).name())) {\
90 a_out << "tools::wroot::base_pntuple_column_wise : create_column(" << (*it).name() << ") failed." << std::endl;\
91 safe_clear<icol>(m_cols);\
92 safe_clear<branch>(m_branches);\
99 #define TOOLS_WROOT_PNTUPLE_CREATE_VEC_COL(a__type) \
100 if((*it).cls_id()==_cid_std_vector<a__type>()) {\
101 std::vector<a__type>* vec = (std::vector<a__type>*)(*it).user_obj();\
103 if(!create_column_vector_ref<a__type>(*itb,(*it).name(),*vec)) {\
104 a_out << "tools::wroot::base_pntuple_column_wise :"\
105 << " create_column failed for std::vector column_ref " << sout((*it).name()) << "."\
107 safe_clear<icol>(m_cols);\
108 safe_clear<branch>(m_branches);\
113 if(!create_column_vector<a__type>(*itb,(*it).name())) {\
114 a_out << "tools::wroot::base_pntuple_column_wise :"\
115 << " create_column failed for std::vector column " << sout((*it).name()) << "."\
117 safe_clear<icol>(m_cols);\
118 safe_clear<branch>(m_branches);\
131 else if((*it).cls_id()==
_cid(std::string())) {
132 std::string* user = (std::string*)(*it).user_obj();
135 a_out <<
"tools::wroot::base_pntuple_column_wise : create_column_string_ref(" << (*it).name() <<
") failed."
144 a_out <<
"tools::wroot::base_pntuple_column_wise : create_column_string(" << (*it).name() <<
") failed." << std::endl;
159 else if((*it).cls_id()==_cid_std_vector<std::string>()) {\
160 std::vector<std::string>* user = (std::vector<std::string>*)(*it).user_obj();
164 a_out <<
"tools::wroot::base_pntuple_column_wise :"
165 <<
" create_column_vector_string_ref(" << (*it).name() <<
") failed." << std::endl;
173 a_out <<
"tools::wroot::base_pntuple_column_wise :"
174 <<
" create_column_vector_string(" << (*it).name() <<
") failed." << std::endl;
186 a_out <<
"tools::wroot::base_pntuple_column_wise :"
187 <<
" for column " <<
sout((*it).name())
188 <<
", type with cid " << (*it).cls_id() <<
" not yet handled."
196 #undef TOOLS_WROOT_PNTUPLE_CREATE_COL
197 #undef TOOLS_WROOT_PNTUPLE_CREATE_VEC_COL
209 if(find_named<icol>(
m_cols,a_name))
return 0;
213 column_ref<T>* col =
new column_ref<T>(*_branch,a_name,a_ref);
214 if(!col) {
delete _branch;
return 0;}
222 if(find_named<icol>(
m_cols,a_name))
return 0;
226 column<T>* col =
new column<T>(*_branch,a_name,a_def);
227 if(!col) {
delete _branch;
return 0;}
234 if(find_named<icol>(
m_cols,a_name))
return 0;
238 column_string_ref* col =
new column_string_ref(*_branch,a_name,a_ref);
239 if(!col) {
delete _branch;
return 0;}
246 const std::string& a_name,
247 const std::string& a_def = std::string()) {
248 if(find_named<icol>(
m_cols,a_name))
return 0;
252 column_string* col =
new column_string(*_branch,a_name,a_def);
253 if(!col) {
delete _branch;
return 0;}
260 const std::vector<std::string>& a_ref,
char a_sep) {
261 if(find_named<icol>(
m_cols,a_name))
return 0;
265 column_vector_string_ref* col =
new column_vector_string_ref(*_branch,a_name,a_ref,a_sep);
266 if(!col) {
delete _branch;
return 0;}
273 const std::string& a_name,
274 const std::vector<std::string>& a_def,
char a_sep) {
275 if(find_named<icol>(
m_cols,a_name))
return 0;
279 column_vector_string* col =
new column_vector_string(*_branch,a_name,a_def,a_sep);
280 if(!col) {
delete _branch;
return 0;}
288 if(find_named<icol>(
m_cols,a_name))
return 0;
292 std_vector_column_ref<T>* col =
new std_vector_column_ref<T>(*_branch,a_name,a_ref);
293 if(!col) {
delete _branch;
return 0;}
301 if(find_named<icol>(
m_cols,a_name))
return 0;
305 std_vector_column<T>* col =
new std_vector_column<T>(*_branch,a_name,a_def);
306 if(!col) {
delete _branch;
return 0;}