Import Geant4 10.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2017-12-08 12:52:30 +01:00
parent 98e455a940
commit fc6af9e721
2166 changed files with 276760 additions and 100873 deletions
+461 -218
View File
@@ -16,6 +16,7 @@
#include "../vfind"
#include "../vmanip"
#include "../ntuple_binding"
#include "../get_lines"
#ifdef TOOLS_MEM
#include "../mem"
@@ -44,71 +45,159 @@ public: //intuple
public:
template <class T>
class column : public virtual read::icolumn<T> {
class column_ref : public virtual read::icolumn<T> {
typedef read::icolumn<T> parent;
public:
static cid id_class() {return 200+_cid(T());}
static cid id_class() {return 200+_cid(T())+10000;}
public: //icol
virtual void* cast(cid a_class) const {
if(void* p = cmp_cast<column>(this,a_class)) {return p;}
if(void* p = cmp_cast<column_ref>(this,a_class)) return p;
return parent::cast(a_class);
}
virtual cid id_cls() const {return id_class();}
public: //icol
virtual const std::string& name() const {return m_leaf.name();}
public: //icolumn<T>
virtual bool fetch_entry() const {return _fetch_entry();}
virtual bool get_entry(T& a_v) const {
unsigned int n;
if(!m_branch.find_entry(m_file,uint32(m_index),n)) {
a_v = T();
return false;
}
a_v = m_leaf.value();
return true;
}
virtual bool fetch_entry() const {
//NOTE : it is ok to have a NULL m_user_var.
unsigned int n;
if(!m_branch.find_entry(m_file,uint32(m_index),n)) {
if(m_user_var) *m_user_var = T();
return false;
}
if(m_user_var) *m_user_var = m_leaf.value();
if(!_fetch_entry()) {a_v = T();return false;}
a_v = m_ref;
return true;
}
public:
column(ifile& a_file,branch& a_branch,leaf<T>& a_leaf,int64& a_index,T* a_user_var = 0)
column_ref(ifile& a_file,branch& a_branch,leaf<T>& a_leaf,int64& a_index,T& a_ref)
:m_file(a_file)
,m_branch(a_branch)
,m_leaf(a_leaf)
,m_index(a_index) //WARNING : we keep the ref !
,m_user_var(a_user_var) //not owner
,m_ref(a_ref)
{}
virtual ~column(){}
virtual ~column_ref(){}
protected:
column(const column& a_from)
column_ref(const column_ref& a_from)
:read::intuple(a_from)
,parent(a_from)
,m_file(a_from.m_file)
,m_branch(a_from.m_branch)
,m_leaf(a_from.m_leaf)
,m_index(a_from.m_index)
,m_user_var(a_from.m_user_var)
,m_ref(a_from.m_ref)
{}
column& operator=(const column& a_from){
column_ref& operator=(const column_ref& a_from){
if(&a_from==this) return *this;
m_user_var = a_from.m_user_var;
return *this;
}
protected:
bool _fetch_entry() const {
unsigned int n;
if(!m_branch.find_entry(m_file,uint32(m_index),n)) {m_ref = T();return false;}
if(!m_leaf.num_elem()) {m_ref = T();return true;} //it is ok. It may be a vector from a row_wise ntuple column.
return m_leaf.value(0,m_ref);
}
protected:
ifile& m_file;
branch& m_branch;
leaf<T>& m_leaf;
int64& m_index; //WARNING : a ref.
T* m_user_var;
T& m_ref;
};
class column_string : public virtual read::icol {
template <class T>
class column : public column_ref<T> {
typedef column_ref<T> parent;
public:
static cid id_class() {return 200+_cid(T());}
public: //icol
virtual void* cast(cid a_class) const {
if(void* p = cmp_cast<column>(this,a_class)) return p;
return parent::cast(a_class);
}
virtual cid id_cls() const {return id_class();}
public:
column(ifile& a_file,branch& a_branch,leaf<T>& a_leaf,int64& a_index)
:parent(a_file,a_branch,a_leaf,a_index,m_value)
,m_value(T())
{}
virtual ~column(){}
protected:
column(const column& a_from)
:read::intuple(a_from)
,parent(a_from)
,m_value(a_from.m_value)
{}
column& operator=(const column& a_from){
if(&a_from==this) return *this;
m_value = a_from.m_value;
return *this;
}
public:
const T& get_value() const {return m_value;}
protected:
T m_value;
};
class column_string_ref : public virtual read::icol {
public:
static cid id_class() {
static const std::string s_v;
return _cid(s_v)+10000;
}
public: //icol
virtual void* cast(cid a_class) const {
if(void* p = cmp_cast<column_string_ref>(this,a_class)) return p;
return 0;
}
virtual cid id_cls() const {return id_class();}
virtual const std::string& name() const {return m_leaf.name();}
public:
virtual bool fetch_entry() const {return _fetch_entry();}
public:
column_string_ref(ifile& a_file,branch& a_branch,leaf_string& a_leaf,int64& a_index,std::string& a_ref)
:m_file(a_file)
,m_branch(a_branch)
,m_leaf(a_leaf)
,m_index(a_index) //WARNING : we keep the ref !
,m_ref(a_ref)
{}
virtual ~column_string_ref(){}
protected:
column_string_ref(const column_string_ref& a_from)
:read::icol(a_from)
,m_file(a_from.m_file)
,m_branch(a_from.m_branch)
,m_leaf(a_from.m_leaf)
,m_index(a_from.m_index)
,m_ref(a_from.m_ref)
{}
column_string_ref& operator=(const column_string_ref& a_from){
if(&a_from==this) return *this;
return *this;
}
public:
bool get_entry(std::string& a_v) const {
if(!_fetch_entry()) {a_v.clear();return false;}
a_v = m_ref;
return true;
}
protected:
bool _fetch_entry() const {
unsigned int n;
if(!m_branch.find_entry(m_file,uint32(m_index),n)) {m_ref.clear();return false;}
const char* _cs = m_leaf.value();
if(!_cs) {m_ref.clear();return false;}
m_ref = _cs;
return true;
}
protected:
ifile& m_file;
branch& m_branch;
leaf_string& m_leaf;
int64& m_index; //WARNING : a ref.
std::string& m_ref;
};
class column_string : public column_string_ref {
typedef column_string_ref parent;
public:
static cid id_class() {
static const std::string s_v;
@@ -122,119 +211,265 @@ public:
virtual cid id_cls() const {return id_class();}
virtual const std::string& name() const {return m_leaf.name();}
public:
virtual bool fetch_entry() const {
//NOTE : it is ok to have a NULL m_user_var.
unsigned int n;
if(!m_branch.find_entry(m_file,uint32(m_index),n)) {
if(m_user_var) *m_user_var = std::string();
return false;
}
if(m_user_var) *m_user_var = m_leaf.value();
return true;
}
public:
column_string(ifile& a_file,branch& a_branch,leaf_string& a_leaf,int64& a_index,std::string* a_user_var = 0)
:m_file(a_file)
,m_branch(a_branch)
,m_leaf(a_leaf)
,m_index(a_index) //WARNING : we keep the ref !
,m_user_var(a_user_var) //not owner
column_string(ifile& a_file,branch& a_branch,leaf_string& a_leaf,int64& a_index)
:parent(a_file,a_branch,a_leaf,a_index,m_value)
{}
virtual ~column_string(){}
protected:
column_string(const column_string& a_from)
:read::icol(a_from)
,m_file(a_from.m_file)
,m_branch(a_from.m_branch)
,m_leaf(a_from.m_leaf)
,m_index(a_from.m_index)
,m_user_var(a_from.m_user_var)
,parent(a_from)
,m_value(a_from.m_value)
{}
column_string& operator=(const column_string& a_from){
if(&a_from==this) return *this;
m_user_var = a_from.m_user_var;
m_value = a_from.m_value;
return *this;
}
public:
const std::string& get_value() const {return m_value;}
protected:
ifile& m_file;
branch& m_branch;
leaf_string& m_leaf;
int64& m_index; //WARNING : a ref.
std::string* m_user_var;
std::string m_value;
};
template <class RT,class T>
class column_element : public virtual read::icolumn<T> {
typedef read::icolumn<T> parent;
class column_vector_string_ref : public column_string_ref {
typedef column_string_ref parent;
public:
static cid id_class() {return 300+_cid(T());}
static cid id_class() {return _cid_std_vector<std::string>()+10000;}
public: //icol
virtual void* cast(cid a_class) const {
if(void* p = cmp_cast<column_element>(this,a_class)) {return p;}
if(void* p = cmp_cast<column_vector_string_ref>(this,a_class)) return p;
return 0;
}
virtual cid id_cls() const {return id_class();}
virtual const std::string& name() const {return m_leaf.name();}
public:
virtual bool fetch_entry() const {return _fetch_entry();}
public:
column_vector_string_ref(ifile& a_file,branch& a_branch,leaf_string& a_leaf,int64& a_index,
std::vector<std::string>& a_ref,char a_sep)
:parent(a_file,a_branch,a_leaf,a_index,m_value)
,m_ref(a_ref)
,m_sep(a_sep)
{}
virtual ~column_vector_string_ref(){}
protected:
column_vector_string_ref(const column_vector_string_ref& a_from)
:read::icol(a_from)
,parent(a_from)
,m_ref(a_from.m_ref)
,m_sep(a_from.m_sep)
{}
column_vector_string_ref& operator=(const column_vector_string_ref& a_from){
if(&a_from==this) return *this;
m_sep = a_from.m_sep;
return *this;
}
public:
bool get_entry(std::vector<std::string>& a_v) const {
if(!_fetch_entry()) {a_v.clear();return false;}
a_v = m_ref;
return true;
}
protected:
bool _fetch_entry() const {
if(!parent::_fetch_entry()) return false;
get_lines(m_value,m_ref);
return true;
}
protected:
std::vector<std::string>& m_ref;
char m_sep;
std::string m_value;
};
class column_vector_string : public column_vector_string_ref {
typedef column_vector_string_ref parent;
public:
static cid id_class() {return _cid_std_vector<std::string>();}
public: //icol
virtual void* cast(cid a_class) const {
if(void* p = cmp_cast<column_vector_string>(this,a_class)) return p;
return 0;
}
virtual cid id_cls() const {return id_class();}
virtual const std::string& name() const {return m_leaf.name();}
public:
column_vector_string(ifile& a_file,branch& a_branch,leaf_string& a_leaf,int64& a_index,char a_sep)
:parent(a_file,a_branch,a_leaf,a_index,m_value,a_sep)
{}
virtual ~column_vector_string(){}
protected:
column_vector_string(const column_vector_string& a_from)
:read::icol(a_from)
,parent(a_from)
,m_value(a_from.m_value)
{}
column_vector_string& operator=(const column_vector_string& a_from){
if(&a_from==this) return *this;
m_value = a_from.m_value;
return *this;
}
public:
const std::vector<std::string>& get_value() const {return m_value;}
protected:
std::vector<std::string> m_value;
};
// to read row_wise columns with vector of basic types :
template <class T>
class std_vector_column_ref : public virtual read::icolumn<T> {
typedef read::icolumn<T> parent;
public:
static cid id_class() {return 200+_cid(T())+10000;}
public: //icol
virtual void* cast(cid a_class) const {
if(void* p = cmp_cast<std_vector_column_ref>(this,a_class)) return p;
return parent::cast(a_class);
}
virtual cid id_cls() const {return id_class();}
public: //icol
virtual const std::string& name() const {return m_leaf.name();}
public: //icolumn<T>
virtual bool fetch_entry() const {return _fetch_entry();}
virtual bool get_entry(T& a_v) const {
unsigned int n;
if(!m_be.find_entry(m_file,uint32(m_index),n)) {a_v = T();return false;}
iro* obj = m_be.object(); //Not owner.
if(!obj) {a_v = T();return false;}
RT* v = id_cast<iro,RT>(*obj);
if(!v) {a_v = T();return false;}
a_v = *v; //it assumes a T::operator=(RT)
return true;
}
virtual bool fetch_entry() const {
unsigned int n;
if(!m_be.find_entry(m_file,uint32(m_index),n)) {
if(m_user_var) *m_user_var = T();
return false;
}
iro* obj = m_be.object(); //Not owner.
if(!obj) {
if(m_user_var) *m_user_var = T();
return false;
}
RT* v = id_cast<iro,RT>(*obj);
if(!v) {
if(m_user_var) *m_user_var = T();
return false;
}
if(m_user_var) *m_user_var = *v; //it assumes a T::operator=(RT)
if(!_fetch_entry()) {a_v = T();return false;}
if(m_ref.empty()) {a_v = T();return false;}
a_v = m_ref[0];
return true;
}
public:
column_element(ifile& a_file,branch_element& a_branch,leaf_element& a_leaf,int64& a_index,T* a_user_var = 0)
std_vector_column_ref(ifile& a_file,branch& a_branch,leaf<T>& a_leaf,int64& a_index,std::vector<T>& a_ref)
:m_file(a_file)
,m_branch(a_branch)
,m_leaf(a_leaf)
,m_index(a_index) //WARNING : we keep the ref !
,m_ref(a_ref)
{}
virtual ~std_vector_column_ref(){}
protected:
std_vector_column_ref(const std_vector_column_ref& a_from)
:read::intuple(a_from)
,parent(a_from)
,m_file(a_from.m_file)
,m_branch(a_from.m_branch)
,m_leaf(a_from.m_leaf)
,m_index(a_from.m_index)
,m_ref(a_from.m_ref)
{}
std_vector_column_ref& operator=(const std_vector_column_ref& a_from){
if(&a_from==this) return *this;
return *this;
}
protected:
bool _fetch_entry() const {
unsigned int n;
if(!m_branch.find_entry(m_file,uint32(m_index),n)) {m_ref.clear();return false;}
m_leaf.value(m_ref);
return true;
}
protected:
ifile& m_file;
branch& m_branch;
leaf<T>& m_leaf;
int64& m_index; //WARNING : a ref.
std::vector<T>& m_ref;
};
// to read column_wise columns with vector of basic types :
template <class RT,class T>
class column_element_ref : public virtual read::icolumn<T> {
typedef read::icolumn<T> parent;
public:
static cid id_class() {return 300+_cid(T())+10000;}
public: //icol
virtual void* cast(cid a_class) const {
if(void* p = cmp_cast<column_element_ref>(this,a_class)) return p;
return parent::cast(a_class);
}
virtual cid id_cls() const {return id_class();}
public: //icol
virtual const std::string& name() const {return m_leaf.name();}
public: //icolumn<T>
virtual bool fetch_entry() const {return _fetch_entry();}
virtual bool get_entry(T& a_v) const {
if(!_fetch_entry()) {a_v = T();return false;}
a_v = m_ref;
return true;
}
public:
column_element_ref(ifile& a_file,branch_element& a_branch,leaf_element& a_leaf,int64& a_index,T& a_ref)
:m_file(a_file)
,m_be(a_branch)
,m_leaf(a_leaf)
,m_index(a_index) //WARNING : we keep the ref !
,m_user_var(a_user_var) //not owner
,m_ref(a_ref)
{}
virtual ~column_element(){}
virtual ~column_element_ref(){}
protected:
column_element(const column_element& a_from)
column_element_ref(const column_element_ref& a_from)
:read::intuple(a_from),parent(a_from)
,m_file(a_from.m_file)
,m_be(a_from.m_be)
,m_leaf(a_from.m_leaf)
,m_index(a_from.m_index)
,m_user_var(a_from.m_user_var)
,m_ref(a_from.m_ref)
{}
column_element& operator=(const column_element& a_from){
column_element_ref& operator=(const column_element_ref& a_from){
if(&a_from==this) return *this;
m_user_var = a_from.m_user_var;
return *this;
}
protected:
bool _fetch_entry() const {
unsigned int n;
if(!m_be.find_entry(m_file,uint32(m_index),n)) {m_ref = T();return false;}
iro* obj = m_be.object(); //Not owner.
if(!obj) {m_ref = T();return false;}
RT* v = id_cast<iro,RT>(*obj);
if(!v) {m_ref = T();return false;}
m_ref = *v; //it assumes a T::operator=(RT)
return true;
}
protected:
ifile& m_file;
branch_element& m_be;
leaf_element& m_leaf;
int64& m_index; //WARNING : a ref.
T* m_user_var;
T& m_ref;
};
template <class RT,class T>
class column_element : public column_element_ref<RT,T> {
typedef column_element_ref<RT,T> parent;
public:
static cid id_class() {return 300+_cid(T());}
public: //icol
virtual void* cast(cid a_class) const {
if(void* p = cmp_cast<column_element>(this,a_class)) return p;
return parent::cast(a_class);
}
virtual cid id_cls() const {return id_class();}
public:
column_element(ifile& a_file,branch_element& a_branch,leaf_element& a_leaf,int64& a_index)
:parent(a_file,a_branch,a_leaf,a_index,m_value)
,m_value(T())
{}
virtual ~column_element(){}
protected:
column_element(const column_element& a_from)
:read::intuple(a_from)
,parent(a_from)
,m_value(a_from.m_value)
{}
column_element& operator=(const column_element& a_from){
if(&a_from==this) return *this;
m_value = a_from.m_value;
return *this;
}
public:
const T& get_value() const {return m_value;}
protected:
T m_value;
};
public:
@@ -244,7 +479,7 @@ public:
#endif
}
virtual ~ntuple() {
tools::clear<read::icol>(m_cols);
safe_clear<read::icol>(m_cols);
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
@@ -259,7 +494,7 @@ protected:
ntuple& operator=(const ntuple&){return *this;}
public:
bool initialize(std::ostream& a_out,const ntuple_binding& a_bd = ntuple_binding()) {
tools::clear<read::icol>(m_cols);
safe_clear<read::icol>(m_cols);
std::vector<base_leaf*> leaves;
m_tree.find_leaves(leaves);
@@ -270,7 +505,7 @@ public:
<< " column with name " << sout(bl->name())
<< " already exists."
<< std::endl;
tools::clear<read::icol>(m_cols);
safe_clear<read::icol>(m_cols);
return false;
}
branch* _branch = m_tree.find_leaf_branch(*bl);
@@ -278,7 +513,7 @@ public:
a_out << "tools::rroot::ntuple::initialize :"
<< " can't find branch of leaf " << sout(bl->name()) << "."
<< std::endl;
tools::clear<read::icol>(m_cols);
safe_clear<read::icol>(m_cols);
return false;
}
@@ -286,137 +521,139 @@ public:
// << " entries " << bl->branch().entry_number() << "."
// << std::endl;
if(leaf<float>* lf = safe_cast<base_leaf, leaf<float> >(*bl) ){
#define TOOLS_RROOT_NTUPLE_CREATE_COL(a__type) \
if(leaf<a__type>* lf_##a__type = safe_cast<base_leaf, leaf<a__type> >(*bl) ){\
cid user_cid;void* user_obj;\
a_bd.find_user_obj(bl->name(),user_cid,user_obj);\
if(!user_obj) {\
column<a__type>* col = new column<a__type>(m_tree.file(),*_branch,*lf_##a__type,m_index);\
m_cols.push_back(col);\
} else {\
const base_leaf* lfc = bl->leaf_count();\
if(lfc) {\
/*::printf("debug : ntuple : create col leaf count : %s\n",bl->name().c_str());*/\
if(user_cid!=_cid_std_vector<a__type>()) {\
a_out << "tools::rroot::ntuple::initialize :"\
<< " for leaf with name " << sout(bl->name())\
<< ", user variable type is not a std::vector of " << #a__type << "."\
<< std::endl;\
safe_clear<read::icol>(m_cols);\
return false;\
}\
std::vector<a__type>* user_var = (std::vector<a__type>*)user_obj;\
std_vector_column_ref<a__type>* col = new std_vector_column_ref<a__type>\
(m_tree.file(),*_branch,*lf_##a__type,m_index,*user_var);\
m_cols.push_back(col);\
} else {\
/*::printf("debug : ntuple : create col : %s\n",bl->name().c_str());*/\
if(user_cid!=_cid(a__type())) {\
a_out << "tools::rroot::ntuple::initialize :"\
<< " for leaf with name " << sout(bl->name())\
<< ", user variable type is not a " << #a__type << "."\
<< std::endl;\
safe_clear<read::icol>(m_cols);\
return false;\
}\
a__type* user_var = (a__type*)user_obj;\
column_ref<a__type>* col = new column_ref<a__type>(m_tree.file(),*_branch,*lf_##a__type,m_index,*user_var);\
m_cols.push_back(col);\
}\
}\
}
column<float>* col = new column<float>(m_tree.file(),*_branch,*lf,
m_index,a_bd.find_variable<float>(bl->name()));
m_cols.push_back(col);
//below types are in sync with wroot/ntuple.
} else if(leaf<double>* ld = safe_cast<base_leaf, leaf<double> >(*bl) ){
TOOLS_RROOT_NTUPLE_CREATE_COL(char)
else TOOLS_RROOT_NTUPLE_CREATE_COL(short)
else TOOLS_RROOT_NTUPLE_CREATE_COL(int)
else TOOLS_RROOT_NTUPLE_CREATE_COL(float)
else TOOLS_RROOT_NTUPLE_CREATE_COL(double)
column<double>* col = new column<double>(m_tree.file(),*_branch,*ld,
m_index,a_bd.find_variable<double>(bl->name()));
m_cols.push_back(col);
} else if(leaf<int>* li = safe_cast<base_leaf, leaf<int> >(*bl) ){
column<int>* col = new column<int>(m_tree.file(),*_branch,*li,
m_index,a_bd.find_variable<int>(bl->name()));
m_cols.push_back(col);
} else if(leaf_string* ls = safe_cast<base_leaf, leaf_string >(*bl) ){
column_string* col = new column_string(m_tree.file(),*_branch,*ls,
m_index,a_bd.find_variable<std::string>(bl->name()));
m_cols.push_back(col);
else if(leaf_string* ls = safe_cast<base_leaf, leaf_string >(*bl) ){
char sep = '\n';
cid user_cid;void* user_obj;
if(!a_bd.find_user_obj(bl->name(),user_cid,user_obj)) {
column_vector_string* col = new column_vector_string(m_tree.file(),*_branch,*ls,m_index,sep);
m_cols.push_back(col);
} else if(user_cid==_cid_std_vector<std::string>()) {
std::vector<std::string>* user_var = (std::vector<std::string>*)user_obj;
if(user_var) {
column_vector_string_ref* col = new column_vector_string_ref(m_tree.file(),*_branch,*ls,m_index,*user_var,sep);
m_cols.push_back(col);
} else {
column_vector_string* col = new column_vector_string(m_tree.file(),*_branch,*ls,m_index,sep);
m_cols.push_back(col);
}
} else if(user_cid==_cid(std::string())) {
std::string* user_var = (std::string*)user_obj;
if(user_var) {
column_string_ref* col = new column_string_ref(m_tree.file(),*_branch,*ls,m_index,*user_var);
m_cols.push_back(col);
} else {
column_string* col = new column_string(m_tree.file(),*_branch,*ls,m_index);
m_cols.push_back(col);
}
} else {
a_out << "tools::rroot::ntuple::initialize :"
<< " for leaf with name " << sout(ls->name())
<< ", user variable type is not a std::string or a std::vector<std::string>."
<< ". It's class id is " << user_cid << "."
<< std::endl;
safe_clear<read::icol>(m_cols);
return false;
}
} else if(leaf_element* le = safe_cast<base_leaf,leaf_element>(*bl) ){
branch_element* be = safe_cast<branch,branch_element>(*_branch);
if(!be) {
a_out << "tools::rroot::ntuple::initialize : branch is not a branch_element." << std::endl;
tools::clear<read::icol>(m_cols);
safe_clear<read::icol>(m_cols);
return false;
}
if(be->class_name()=="vector<string>") {
typedef std::string el_t;
typedef column_element< stl_vector<el_t> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
#define TOOLS_RROOT_NTUPLE_CREATE_VEC_COL(a__name,a__type) \
if(be->class_name()==a__name) {\
/*::printf("debug : ntuple : create vec col : %s\n",bl->name().c_str());*/\
typedef a__type el_t;\
std::vector<el_t>* user_var = a_bd.find_vector_variable<el_t>(bl->name());\
if(user_var) {\
typedef column_element_ref< stl_vector<el_t> , std::vector<el_t> > ce_t;\
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,*user_var);\
m_cols.push_back(col);\
} else {\
typedef column_element< stl_vector<el_t> , std::vector<el_t> > ce_t;\
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index);\
m_cols.push_back(col);\
}\
}
TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<char>",char)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<short>",short)
//else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<unsigned short>",unsigned short)
//else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<unsigned int>",unsigned int)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<int>",int)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<float>",float)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<double>",double)
//else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<string>",std::string)
//else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<unsigned long>",uint64) //beurk
//unsigned int n;
//if(!be->find_entry(0,n)) {}
// WARNING : take care of the space in "> >".
/* VisualC++ : the below does not compile.
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<vector<unsigned short> >",std::vector<unsigned short>)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<vector<short> >",std::vector<short>)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<vector<unsigned int> >",std::vector<unsigned int>)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<vector<int> >",std::vector<short>)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<vector<float> >",std::vector<float>)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<vector<double> >",std::vector<double>)
*/
} else if(be->class_name()=="vector<unsigned short>") {
typedef unsigned short el_t;
typedef column_element< stl_vector<el_t> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
} else if(be->class_name()=="vector<short>") {
typedef short el_t;
typedef column_element< stl_vector<el_t> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
} else if(be->class_name()=="vector<unsigned int>") {
typedef unsigned int el_t;
typedef column_element< stl_vector<el_t> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
} else if(be->class_name()=="vector<unsigned long>") { //beurk!
typedef uint64 el_t; //it is ok to map to an uint64 ?
typedef column_element< stl_vector<el_t> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
//unsigned int n;
//if(!be->find_entry(0,n)) {}
} else if(be->class_name()=="vector<int>") {
typedef int el_t;
typedef column_element< stl_vector<el_t> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
} else if(be->class_name()=="vector<float>") {
typedef float el_t;
typedef column_element< stl_vector<el_t> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
} else if(be->class_name()=="vector<double>") {
typedef double el_t;
typedef column_element< stl_vector<el_t> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
} else if(be->class_name()=="vector<vector<unsigned short> >") {
typedef std::vector<unsigned short> el_t;
typedef column_element< stl_vector_vector<unsigned short> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
} else if(be->class_name()=="vector<vector<short> >") {
typedef std::vector<short> el_t;
typedef column_element< stl_vector_vector<short> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
} else if(be->class_name()=="vector<vector<unsigned int> >") {
typedef std::vector<unsigned int> el_t;
typedef column_element< stl_vector_vector<unsigned int> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
} else if(be->class_name()=="vector<vector<int> >") {
typedef std::vector<int> el_t;
typedef column_element< stl_vector_vector<int> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
} else if(be->class_name()=="vector<vector<float> >") {
typedef std::vector<float> el_t;
typedef column_element< stl_vector_vector<float> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
//unsigned int n;
//if(!be->find_entry(0,n)) {}
} else if(be->class_name()=="vector<vector<double> >") {
typedef std::vector<double> el_t;
typedef column_element< stl_vector_vector<double> , std::vector<el_t> > ce_t;
ce_t* col = new ce_t(m_tree.file(),*be,*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
m_cols.push_back(col);
} else {
else {
a_out << "tools::rroot::ntuple::initialize :"
<< " WARNING : leaf element"
<< " with name " << tools::sout(bl->name())
<< ",title " << tools::sout(bl->title())
<< " with name " << sout(bl->name())
<< ",title " << sout(bl->title())
<< " br_elem class name " << be->class_name() << "."
<< " entries " << be->entry_number() << "."
<< std::endl;
@@ -425,15 +662,18 @@ public:
} else {
a_out << "tools::rroot::ntuple::initialize :"
<< " WARNING : column type not yet handled for leaf"
<< " with name " << tools::sout(bl->name())
<< " and title " << tools::sout(bl->title()) << "."
<< " s_cls() is " << tools::sout(bl->s_cls()) << "."
<< " with name " << sout(bl->name())
<< " and title " << sout(bl->title()) << "."
<< " s_cls() is " << sout(bl->s_cls()) << "."
<< " Not fatal."
<< std::endl;
}
}
#undef TOOLS_RROOT_NTUPLE_CREATE_VEC_COL
#undef TOOLS_RROOT_NTUPLE_CREATE_COL
size_t num = m_cols.size();
if(!num) {
a_out << "tools::rroot::ntuple::initialize :"
@@ -452,7 +692,10 @@ public:
bool get_row() const {
bool status = true;
tools_vforcit(read::icol*,m_cols,it) {
if(!(*it)->fetch_entry()) status = false;
if(!(*it)->fetch_entry()) {
m_tree.out() << "tools::rroot::ntuple::get_row : fetch_entry() failed for leaf " << (*it)->name() << std::endl;
status = false;
}
}
return status;
}