Go to the documentation of this file.
4 #ifndef tools_waxml_ntuple
5 #define tools_waxml_ntuple
23 #include "../ntuple_booking"
38 virtual const std::string&
name()
const = 0;
47 if(
void* p = cmp_cast<leaf>(
this,a_class)) {
return p;}
52 virtual const std::string&
s_def()
const = 0;
53 virtual void s_value(std::string&)
const = 0;
62 static const std::string s_v(
"int");
66 static const std::string s_v(
"float");
70 static const std::string s_v(
"double");
74 static const std::string s_v(
"string");
79 static const std::string s_v(
"ITuple");
101 column(
const std::string& a_name,
const T& a_def)
119 bool fill(
const T& a_value) {
m_tmp = a_value;
return true;}
132 if(
void* p = cmp_cast<sub_ntuple>(
this,a_class)) {
return p;}
140 sub_ntuple(
const std::string& a_name,
const std::string& a_spaces)
150 if(find_named<iobj>(
m_cols,a_name))
return 0;
158 if(find_named<iobj>(
m_cols,a_name))
return 0;
160 for(
unsigned int i=0;i<4;i++) spaces +=
" ";
179 if(
m_cols.empty())
return false;
180 std::ostringstream
sout;
188 }
else if(
leaf* lf = id_cast<iobj,leaf>(*(*it))){
192 <<
" value=\"" << _sv
193 <<
"\"/>" << std::endl;
215 if(
void* p = cmp_cast<std_vector_column>(
this,a_class)) {
return p;}
224 virtual void s_value(std::string& a_s)
const {
225 std::ostringstream
sout;
227 typedef typename std::vector<T>::const_iterator it_t;
229 sout <<
m_spaces <<
" <row><entry" <<
" value=\"" <<
tos(*it) <<
"\"/></row>" << std::endl;
235 std_vector_column(
const std::string& a_name,std::vector<T>& a_user_vec,
const std::string& a_spaces)
262 int _id = (int)a_obj.
id_cls()-220;
263 if((_id<=0)||(_id>=20))
return 0;
264 return id_cast<iobj,leaf>(a_obj);
268 ntuple(std::ostream& a_writer,
unsigned int a_spaces = 0)
270 for(
unsigned int i=0;i<a_spaces;i++)
m_spaces +=
" ";
275 unsigned int a_spaces = 0)
277 for(
unsigned int i=0;i<a_spaces;i++)
m_spaces +=
" ";
279 const std::vector<column_booking>& cols = a_bkg.
columns();
282 if((*it).cls_id()==
_cid(
int(0))) {
283 create_column<int>((*it).name());
284 }
else if((*it).cls_id()==
_cid(
float(0))) {
285 create_column<float>((*it).name());
286 }
else if((*it).cls_id()==
_cid(
double(0))) {
287 create_column<double>((*it).name());
288 }
else if((*it).cls_id()==
_cid(std::string())) {
289 create_column<std::string>((*it).name());
291 }
else if((*it).cls_id()==_cid_std_vector<int>()) {
292 std::vector<int>* vec = (std::vector<int>*)(*it).user_obj();
294 create_column<int>((*it).name(),*vec);
296 a_out <<
"tools::waxml::ntuple :"
297 <<
" for std::vector column " <<
sout((*it).name())
298 <<
", the user vector pointer is null."
303 }
else if((*it).cls_id()==_cid_std_vector<float>()) {
304 std::vector<float>* vec = (std::vector<float>*)(*it).user_obj();
306 create_column<float>((*it).name(),*vec);
308 a_out <<
"tools::waxml::ntuple :"
309 <<
" for std::vector column " <<
sout((*it).name())
310 <<
", the user vector pointer is null."
315 }
else if((*it).cls_id()==_cid_std_vector<double>()) {
316 std::vector<double>* vec = (std::vector<double>*)(*it).user_obj();
318 create_column<double>((*it).name(),*vec);
320 a_out <<
"tools::waxml::ntuple :"
321 <<
" for std::vector column " <<
sout((*it).name())
322 <<
", the user vector pointer is null."
329 a_out <<
"tools::waxml::ntuple :"
330 <<
" for column " <<
sout((*it).name())
331 <<
", type with cid " << (*it).cls_id() <<
" not yet handled."
356 if(find_named<iobj>(
m_cols,a_name))
return 0;
365 if(find_named<iobj>(
m_cols,a_name))
return 0;
367 for(
unsigned int i=0;i<8;i++) spaces +=
" ";
378 return id_cast<iobj, column<T> >(*col);
382 if(find_named<iobj>(
m_cols,a_name))
return 0;
384 for(
unsigned int i=0;i<10;i++) spaces +=
" ";
391 void write_header(
const std::string& a_path,
const std::string& a_name,
const std::string& a_title){
407 <<
" type=" <<
sout(
"ITuple")
408 <<
" booking=\"{" << vlf->aida_type() <<
" " <<
to_xml((*it)->name())
410 <<
"/>" << std::endl;
411 }
else if(
sub_ntuple*
sub = id_cast<iobj,sub_ntuple>(*(*it))){
414 <<
" type=" <<
sout(
"ITuple")
415 <<
" booking=" <<
sout(
sub->booking(
true))
416 <<
"/>" << std::endl;
417 }
else if( id_cast<iobj,leaf>(*(*it))){
420 <<
" type=" <<
sout((*it)->aida_type())
422 <<
"/>" << std::endl;
433 if(
m_cols.empty())
return false;
440 }
else if(
sub_ntuple*
sub = id_cast<iobj,sub_ntuple>(*(*it))){
445 }
else if(
leaf* lf = id_cast<iobj,leaf>(*(*it))){
449 <<
" value=" <<
sout(_sv)
450 <<
"/>" << std::endl;
469 static void get_booking(
const std::vector<iobj*>& a_cols,
bool a_xml_esc,
470 std::string& a_string) {
474 if(it!=a_cols.begin()) a_string +=
",";
476 std::string sname = (*it)->name();
477 if(a_xml_esc) sname =
to_xml(sname);
480 a_string +=
"ITuple " + (*it)->name() +
" = {" + vlf->aida_type() +
" " + sname +
"}";
482 }
else if(
sub_ntuple*
sub = id_cast<iobj,sub_ntuple>(*(*it))){
483 a_string += (*it)->aida_type() +
" " + sname +
" = ";
486 }
else if(
leaf* lf = id_cast<iobj,leaf>(*(*it))){
487 a_string += (*it)->aida_type() +
" " + sname +
" = " + lf->s_def();
#define tools_vforcit(a__T, a__v, a__it)