Import Geant4 9.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 17:01:34 +02:00
parent b1eb5424d2
commit e2d2f9810a
10384 changed files with 698580 additions and 628834 deletions
+60 -8
View File
@@ -12,6 +12,9 @@
#include "../vfind"
#include "../vmanip"
#include "../ntuple_booking"
#include "../sout"
#include "../scast"
namespace tools {
namespace wroot {
@@ -21,6 +24,9 @@ protected:
class icol {
public:
virtual ~icol(){}
public:
virtual void* cast(cid) const = 0;
virtual cid id_cls() const = 0;
public:
virtual void add() = 0;
virtual const std::string& name() const = 0;
@@ -30,6 +36,16 @@ protected:
public:
template <class T>
class column : public virtual icol {
public:
static cid id_class() {
static const T s_v = T(); //do that for T = std::string.
return _cid(s_v);
}
virtual void* cast(cid a_class) const {
if(void* p = cmp_cast<column>(this,a_class)) {return p;}
else return 0;
}
virtual cid id_cls() const {return id_class();}
public: //icol
virtual void add() {m_leaf->fill(m_tmp);m_tmp = m_def;}
virtual const std::string& name() const {return m_leaf->name();}
@@ -37,9 +53,7 @@ public:
m_leaf->branch().set_basket_size(a_size);
}
public:
column(tree& a_tree,
const std::string& a_name,
const T& a_def)
column(tree& a_tree,const std::string& a_name,const T& a_def)
:m_tree(a_tree),m_leaf(0)
,m_def(a_def),m_tmp(a_def)
{
@@ -71,9 +85,41 @@ public:
};
public:
ntuple(idir& a_dir,
const std::string& a_name,const std::string& a_title)
: tree(a_dir,a_name,a_title){}
ntuple(idir& a_dir,const std::string& a_name,const std::string& a_title)
:tree(a_dir,a_name,a_title){}
ntuple(idir& a_dir,const ntuple_booking& a_bkg)
:tree(a_dir,a_bkg.m_name,a_bkg.m_title){
const std::vector<ntuple_booking::col_t>& cols = a_bkg.m_columns;
std::vector<ntuple_booking::col_t>::const_iterator it;
for(it=cols.begin();it!=cols.end();++it){
if((*it).second==_cid(char(0))) {
create_column<char>((*it).first);
} else if((*it).second==_cid(short(0))) {
create_column<short>((*it).first);
} else if((*it).second==_cid(int(0))) {
create_column<int>((*it).first);
} else if((*it).second==_cid(float(0))) {
create_column<float>((*it).first);
} else if((*it).second==_cid(double(0))) {
create_column<double>((*it).first);
// no leaf_store_class() defined for the other types.
} else {
m_out << "tools::wroot::ntuple :"
<< " for column " << sout((*it).first)
<< ", type with cid " << (*it).second << " not yet handled."
<< std::endl;
//throw
tools::clear<icol>(m_cols);
tools::clear<branch>(m_branches);
return;
}
}
}
virtual ~ntuple() {}
protected:
ntuple(const ntuple& a_from)
@@ -84,8 +130,7 @@ public:
const std::vector<icol*>& columns() const {return m_cols;}
template <class T>
column<T>* create_column(const std::string& a_name,
const T& a_def = T()) {
column<T>* create_column(const std::string& a_name,const T& a_def = T()) {
if(find_named<icol>(m_cols,a_name)) return 0;
column<T>* col = new column<T>(*this,a_name,a_def);
if(!col) return 0;
@@ -93,6 +138,13 @@ public:
return col;
}
template <class T>
column<T>* find_column(const std::string& a_name) {
icol* col = find_named<icol>(m_cols,a_name);
if(!col) return 0;
return id_cast<icol, column<T> >(*col);
}
bool add_row() {
if(m_cols.empty()) return false;
{std::vector<icol*>::iterator it;