Import Geant4 10.3.0 source tree
This commit is contained in:
@@ -10,11 +10,6 @@
|
||||
|
||||
#include "named"
|
||||
|
||||
namespace tools {
|
||||
namespace rroot {
|
||||
class branch;
|
||||
}}
|
||||
|
||||
namespace tools {
|
||||
namespace rroot {
|
||||
|
||||
@@ -63,7 +58,6 @@ public:
|
||||
if(!a_buffer.read(fIsUnsigned)) return false;
|
||||
|
||||
{ifac::args args;
|
||||
args[ifac::arg_branch()] = &m_branch;
|
||||
iro* obj;
|
||||
if(!a_buffer.read_object(m_fac,args,obj)) {
|
||||
m_out << "tools::rroot::base_leaf::stream :"
|
||||
@@ -97,13 +91,12 @@ public:
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
virtual bool read_basket(buffer&) = 0;
|
||||
virtual bool read_buffer(buffer&) = 0;
|
||||
virtual bool print_value(std::ostream&,uint32) const = 0;
|
||||
virtual uint32 num_elem() const = 0;
|
||||
public:
|
||||
base_leaf(std::ostream& a_out,rroot::branch& a_branch,ifac& a_fac)
|
||||
base_leaf(std::ostream& a_out,ifac& a_fac)
|
||||
:m_out(a_out)
|
||||
,m_branch(a_branch)
|
||||
,m_fac(a_fac)
|
||||
,m_name("")
|
||||
,m_title("")
|
||||
@@ -134,7 +127,6 @@ protected:
|
||||
base_leaf(const base_leaf& a_from)
|
||||
:iro(a_from)
|
||||
,m_out(a_from.m_out)
|
||||
,m_branch(a_from.m_branch)
|
||||
,m_fac(a_from.m_fac)
|
||||
,m_ndata(0)
|
||||
,m_length(0)
|
||||
@@ -142,7 +134,6 @@ protected:
|
||||
{}
|
||||
base_leaf& operator=(const base_leaf&){return *this;}
|
||||
public:
|
||||
rroot::branch& branch() {return m_branch;}
|
||||
const std::string& name() const {return m_name;}
|
||||
const std::string& title() const {return m_title;}
|
||||
/*
|
||||
@@ -171,7 +162,6 @@ public:
|
||||
*/
|
||||
protected:
|
||||
std::ostream& m_out;
|
||||
rroot::branch& m_branch;
|
||||
ifac& m_fac;
|
||||
protected: //Named
|
||||
std::string m_name;
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace tools {
|
||||
namespace rroot {
|
||||
|
||||
class basket : public virtual iro, public key {
|
||||
typedef key parent;
|
||||
static uint32 kDisplacementMask() {return 0xFF000000;}
|
||||
public:
|
||||
static const std::string& s_class() {
|
||||
@@ -40,7 +41,7 @@ public:
|
||||
|
||||
uint32 startpos = a_buffer.length();
|
||||
|
||||
if(!key::from_buffer(a_buffer.eob(),a_buffer.pos())) return false;
|
||||
if(!parent::from_buffer(a_buffer.byte_swap(),a_buffer.eob(),a_buffer.pos(),a_buffer.verbose())) return false;
|
||||
|
||||
uint32 fBufferSize;
|
||||
|
||||
@@ -56,7 +57,7 @@ public:
|
||||
|
||||
uint16 basket_key_length = a_buffer.length()-startpos;
|
||||
if(basket_key_length!=m_key_length) {
|
||||
//m_file.out() << "tools::rroot::basket::stream :"
|
||||
//m_out << "tools::rroot::basket::stream :"
|
||||
// << " key length not consistent."
|
||||
// << " read " << m_key_length
|
||||
// << ", expected " << basket_key_length
|
||||
@@ -65,7 +66,7 @@ public:
|
||||
m_key_length = basket_key_length;
|
||||
}
|
||||
if(!m_object_size) {
|
||||
//m_file.out() << "tools::rroot::basket::stream :"
|
||||
//m_out << "tools::rroot::basket::stream :"
|
||||
// << " m_object_size is found to be zero."
|
||||
// << " Continue with (m_nbytes-m_key_length) "
|
||||
// << (m_nbytes-m_key_length)
|
||||
@@ -80,7 +81,7 @@ public:
|
||||
(flag!=11)&&(flag!=12) &&
|
||||
(flag!=41)&&(flag!=42) &&
|
||||
(flag!=51)&&(flag!=52) ) {
|
||||
m_file.out() << "tools::rroot::basket::stream :"
|
||||
m_out << "tools::rroot::basket::stream :"
|
||||
<< " bad flag " << (int)flag
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -90,12 +91,12 @@ public:
|
||||
//due to the upper "G.Barrand if", flag is here in {1,11,41,51}
|
||||
|
||||
if(!m_nev_buf_size) {
|
||||
m_file.out() << "tools::rroot::basket::stream :"
|
||||
m_out << "tools::rroot::basket::stream :"
|
||||
<< " m_nev_buf_size is zero." << std::endl;
|
||||
return false;
|
||||
}
|
||||
if(m_nev>m_nev_buf_size) {
|
||||
m_file.out() << "tools::rroot::basket::stream :"
|
||||
m_out << "tools::rroot::basket::stream :"
|
||||
<< " m_nev>m_nev_buf_size !"
|
||||
<< " m_nev " << m_nev
|
||||
<< " m_nev_buf_size " << m_nev_buf_size
|
||||
@@ -110,7 +111,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
if((n!=m_nev)&&(n!=(m_nev+1))) {
|
||||
m_file.out() << "tools::rroot::basket::stream :"
|
||||
m_out << "tools::rroot::basket::stream :"
|
||||
<< " m_entry_offset read len mismatch."
|
||||
<< " n " << n
|
||||
<< " m_nev " << m_nev
|
||||
@@ -134,7 +135,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
if((n!=m_nev)&&(n!=(m_nev+1))) {
|
||||
m_file.out() << "tools::rroot::basket::stream :"
|
||||
m_out << "tools::rroot::basket::stream :"
|
||||
<< " m_displacement read len mismatch."
|
||||
<< " n " << n
|
||||
<< " m_nev " << m_nev
|
||||
@@ -153,7 +154,7 @@ public:
|
||||
if(fBufferSize) {
|
||||
char* _buf = new char[fBufferSize];
|
||||
if(!_buf) {
|
||||
m_file.out() << "tools::rroot::basket::stream :"
|
||||
m_out << "tools::rroot::basket::stream :"
|
||||
<< " can't alloc " << fBufferSize << std::endl;
|
||||
_clear();
|
||||
return false;
|
||||
@@ -182,8 +183,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
basket(ifile& a_file)
|
||||
:key(a_file)
|
||||
basket(std::ostream& a_out)
|
||||
:parent(a_out)
|
||||
,m_nev_buf_size(0)
|
||||
,m_nev(0)
|
||||
,m_last(0)
|
||||
@@ -194,8 +195,8 @@ public:
|
||||
mem::increment(s_class().c_str());
|
||||
#endif
|
||||
}
|
||||
basket(ifile& a_file,seek a_pos,uint32 a_nbytes)
|
||||
:key(a_file,a_pos,a_nbytes)
|
||||
basket(std::ostream& a_out,seek a_pos,uint32 a_nbytes)
|
||||
:parent(a_out,a_pos,a_nbytes)
|
||||
,m_nev_buf_size(0)
|
||||
,m_nev(0)
|
||||
,m_last(0)
|
||||
@@ -215,7 +216,7 @@ public:
|
||||
public:
|
||||
basket(const basket& a_from)
|
||||
:iro(a_from)
|
||||
,key(a_from)
|
||||
,parent(a_from)
|
||||
,m_nev_buf_size(a_from.m_nev_buf_size)
|
||||
,m_nev(a_from.m_nev)
|
||||
,m_last(a_from.m_last)
|
||||
@@ -228,7 +229,7 @@ public:
|
||||
if(a_from.m_nev && a_from.m_entry_offset) {
|
||||
m_entry_offset = new int[a_from.m_nev];
|
||||
if(!m_entry_offset) {
|
||||
m_file.out() << "tools::rroot::basket::basket(cpcstor) :"
|
||||
m_out << "tools::rroot::basket::basket(cpcstor) :"
|
||||
<< " can't alloc " << a_from.m_nev << "."
|
||||
<< std::endl;
|
||||
} else {
|
||||
@@ -239,7 +240,7 @@ public:
|
||||
if(a_from.m_nev && a_from.m_displacement) {
|
||||
m_displacement = new int[a_from.m_nev];
|
||||
if(!m_displacement) {
|
||||
m_file.out() << "tools::rroot::basket::basket(cpcstor) :"
|
||||
m_out << "tools::rroot::basket::basket(cpcstor) :"
|
||||
<< " can't alloc " << a_from.m_nev << "."
|
||||
<< std::endl;
|
||||
} else {
|
||||
@@ -249,7 +250,7 @@ public:
|
||||
}
|
||||
}
|
||||
basket& operator=(const basket& a_from){
|
||||
key::operator=(a_from);
|
||||
parent::operator=(a_from);
|
||||
|
||||
if(&a_from==this) return *this;
|
||||
|
||||
@@ -265,7 +266,7 @@ public:
|
||||
if(a_from.m_nev && a_from.m_entry_offset) {
|
||||
m_entry_offset = new int[a_from.m_nev];
|
||||
if(!m_entry_offset) {
|
||||
m_file.out() << "tools::rroot::basket::operator=() :"
|
||||
m_out << "tools::rroot::basket::operator=() :"
|
||||
<< " can't alloc " << a_from.m_nev << "."
|
||||
<< std::endl;
|
||||
} else {
|
||||
@@ -276,7 +277,7 @@ public:
|
||||
if(a_from.m_nev && a_from.m_displacement) {
|
||||
m_displacement = new int[a_from.m_nev];
|
||||
if(!m_displacement) {
|
||||
m_file.out() << "tools::rroot::basket::operator=() :"
|
||||
m_out << "tools::rroot::basket::operator=() :"
|
||||
<< " can't alloc " << a_from.m_nev << "."
|
||||
<< std::endl;
|
||||
} else {
|
||||
@@ -292,27 +293,27 @@ public:
|
||||
int* displacement() {return m_displacement;}
|
||||
uint32 nev_buf_size() const {return m_nev_buf_size;}
|
||||
uint32 nev() const {return m_nev;}
|
||||
uint32 last() const {return m_last;}
|
||||
|
||||
bool read_offset_tables() {
|
||||
bool read_offset_tables(bool a_byte_swap) {
|
||||
if(!m_buffer) return false;
|
||||
if(!m_last) return false;
|
||||
|
||||
delete [] m_entry_offset;
|
||||
m_entry_offset = 0;
|
||||
|
||||
rroot::buffer buffer(m_file.out(),m_file.byte_swap(),
|
||||
m_buf_size,m_buffer,0,false);
|
||||
rroot::buffer buffer(m_out,a_byte_swap,m_buf_size,m_buffer,0,false);
|
||||
buffer.set_offset(m_last);
|
||||
|
||||
{uint32 n;
|
||||
if(!buffer.read_array<int>(0,m_entry_offset,n)) {
|
||||
m_file.out() << "tools::rroot::basket::read_offset_tables :"
|
||||
m_out << "tools::rroot::basket::read_offset_tables :"
|
||||
<< " read_array failed."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if((n!=m_nev)&&(n!=(m_nev+1))) {
|
||||
m_file.out() << "tools::rroot::basket::read_offset_tables :"
|
||||
m_out << "tools::rroot::basket::read_offset_tables :"
|
||||
<< " m_entry_offset read len mismatch."
|
||||
<< " n " << n
|
||||
<< " m_nev " << m_nev
|
||||
@@ -327,13 +328,13 @@ public:
|
||||
// array.
|
||||
uint32 n;
|
||||
if(!buffer.read_array<int>(0,m_displacement,n)) {
|
||||
m_file.out() << "tools::rroot::basket::read_offset_tables :"
|
||||
m_out << "tools::rroot::basket::read_offset_tables :"
|
||||
<< " readArray(2) failed."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if((n!=m_nev)&&(n!=(m_nev+1))) {
|
||||
m_file.out() << "tools::rroot::basket::read_offset_tables :"
|
||||
m_out << "tools::rroot::basket::read_offset_tables :"
|
||||
<< " m_displacement read len mismatch."
|
||||
<< " n " << n
|
||||
<< " m_nev " << m_nev
|
||||
|
||||
@@ -259,7 +259,7 @@ public:
|
||||
//TObjArray
|
||||
//::printf("debug : branch::stream : leaves : begin\n");
|
||||
{ifac::args args;
|
||||
args[ifac::arg_branch()] = this;
|
||||
//args[ifac::arg_branch()] = this;
|
||||
if(!m_leaves.stream(a_buffer,args)) {
|
||||
m_out << "tools::rroot::branch::stream :"
|
||||
<< " can't read leaves."
|
||||
@@ -516,9 +516,9 @@ public:
|
||||
|
||||
virtual bool read_leaves(buffer& a_buffer){
|
||||
tools_vforcit(base_leaf*,m_leaves,it) {
|
||||
if(!(*it)->read_basket(a_buffer)) {
|
||||
if(!(*it)->read_buffer(a_buffer)) {
|
||||
m_out << "tools::rroot::branch::read_leaves :"
|
||||
<< " read_basket failed."
|
||||
<< " read_buffer failed."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
@@ -526,7 +526,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool find_entry(uint32 a_entry,uint32& a_nbytes){
|
||||
virtual bool find_entry(ifile& a_file,uint32 a_entry,uint32& a_nbytes){
|
||||
// Read all leaves of entry and return total number of bytes :
|
||||
// The input argument entry is the entry serial number in the current tree.
|
||||
a_nbytes = 0;
|
||||
@@ -635,7 +635,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
bsk = get_basket(fBasketSeek[m_read_basket],fBasketBytes[m_read_basket]);
|
||||
bsk = get_basket(a_file,fBasketSeek[m_read_basket],fBasketBytes[m_read_basket]);
|
||||
if(!bsk) {
|
||||
m_out << "tools::rroot::branch::find_entry :"
|
||||
<< " can't read basket " << m_read_basket
|
||||
@@ -706,7 +706,7 @@ public:
|
||||
}
|
||||
*/
|
||||
|
||||
rroot::buffer buffer(m_out,m_file.byte_swap(),m__read_basket->buf_size(),m__read_basket->buf(),0,false);
|
||||
rroot::buffer buffer(m_out,a_file.byte_swap(),m__read_basket->buf_size(),m__read_basket->buf(),0,false);
|
||||
buffer.set_offset(bufbegin);
|
||||
|
||||
if(!read_leaves(buffer)) {
|
||||
@@ -727,10 +727,37 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool show(std::ostream& a_out,ifile& a_file,uint32 a_entry) {
|
||||
// Print values of all active leaves for entry :
|
||||
// if entry==-1, print current entry (default)
|
||||
uint32 n;
|
||||
if(!find_entry(a_file,a_entry,n)) return false;
|
||||
|
||||
tools_vforcit(base_leaf*,m_leaves,it) {
|
||||
base_leaf* bl = *it;
|
||||
|
||||
uint32 num = bl->num_elem();
|
||||
num = mn<uint32>(num,10);
|
||||
if(!num) continue;
|
||||
|
||||
{std::string s;
|
||||
uint32 len = uint32(bl->name().size())+128;
|
||||
sprintf(s,len," %-15s = ",bl->name().c_str());
|
||||
a_out << s;}
|
||||
|
||||
for(uint32 i=0;i<num;i++) {
|
||||
if(i) a_out << ", ";
|
||||
bl->print_value(a_out,i);
|
||||
}
|
||||
|
||||
a_out << std::endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
branch(ifile& a_file,ifac& a_fac)
|
||||
:m_file(a_file)
|
||||
,m_out(a_file.out())
|
||||
branch(std::ostream& a_out,ifac& a_fac)
|
||||
:m_out(a_out)
|
||||
,m_fac(a_fac)
|
||||
|
||||
,m_streamed_baskets(m_fac,true)
|
||||
@@ -765,7 +792,7 @@ public:
|
||||
protected:
|
||||
branch(const branch& a_from)
|
||||
:iro(a_from)
|
||||
,m_file(a_from.m_file),m_out(a_from.m_out),m_fac(a_from.m_fac)
|
||||
,m_out(a_from.m_out),m_fac(a_from.m_fac)
|
||||
,m_streamed_baskets(m_fac,false),m__read_basket(0)
|
||||
,fAutoDelete(false)
|
||||
,m_branches(m_fac,false),m_leaves(m_fac,false)
|
||||
@@ -779,57 +806,25 @@ protected:
|
||||
{}
|
||||
branch& operator=(const branch&){return *this;}
|
||||
public:
|
||||
ifile& file() {return m_file;}
|
||||
uint32 entry_number() const {return m_entry_number;}
|
||||
const std::string& name() const {return m_name;}
|
||||
const std::string& title() const {return m_title;}
|
||||
const std::vector<base_leaf*>& leaves() const {return m_leaves;}
|
||||
const std::vector<branch*>& branches() const {return m_branches;}
|
||||
|
||||
bool show(std::ostream& a_out,uint32 a_entry){
|
||||
// Print values of all active leaves for entry :
|
||||
// if entry==-1, print current entry (default)
|
||||
uint32 n;
|
||||
if(!find_entry(a_entry,n)) return false;
|
||||
|
||||
tools_vforcit(base_leaf*,m_leaves,it) {
|
||||
base_leaf* bl = *it;
|
||||
|
||||
uint32 num = bl->num_elem();
|
||||
num = mn<uint32>(num,10);
|
||||
if(!num) continue;
|
||||
|
||||
{std::string s;
|
||||
uint32 len = bl->name().size()+128;
|
||||
sprintf(s,len," %-15s = ",bl->name().c_str());
|
||||
a_out << s;}
|
||||
|
||||
for(uint32 i=0;i<num;i++) {
|
||||
if(i) a_out << ", ";
|
||||
bl->print_value(a_out,i);
|
||||
}
|
||||
|
||||
a_out << std::endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
protected:
|
||||
basket* get_basket(seek a_pos,uint32 a_len) {
|
||||
basket* get_basket(ifile& a_file,seek a_pos,uint32 a_len) {
|
||||
//if(fBranch.tree().memoryFull(fBufferSize)) fBranch.dropBaskets();
|
||||
if(!a_len) return 0;
|
||||
|
||||
rroot::basket* basket =
|
||||
new rroot::basket(m_file,a_pos,a_len); //basket is a key.
|
||||
if(!basket->read_file()) {
|
||||
rroot::basket* basket = new rroot::basket(m_out,a_pos,a_len); //basket is a key.
|
||||
if(!basket->read_file(a_file)) {
|
||||
m_out << "tools::rroot::branch::get_basket :"
|
||||
<< " read_file() failed."
|
||||
<< std::endl;
|
||||
delete basket;
|
||||
return 0;
|
||||
}
|
||||
{rroot::buffer buffer(m_out,m_file.byte_swap(),
|
||||
a_len,basket->buf(),0,false);
|
||||
{rroot::buffer buffer(m_out,a_file.byte_swap(),a_len,basket->buf(),0,false);
|
||||
if(!basket->stream(buffer)) {
|
||||
m_out << "tools::rroot::branch::get_basket :"
|
||||
<< " basket stream failed."
|
||||
@@ -838,7 +833,7 @@ protected:
|
||||
return 0;
|
||||
}}
|
||||
unsigned int sz;
|
||||
char* buf = basket->get_object_buffer(sz); //basket owns buf.
|
||||
char* buf = basket->get_object_buffer(a_file,sz); //basket owns buf.
|
||||
if(!buf) {
|
||||
m_out << "tools::rroot::branch::get_basket :"
|
||||
<< " get_object_buffer() failed."
|
||||
@@ -865,7 +860,7 @@ protected:
|
||||
//}
|
||||
|
||||
if(fEntryOffsetLen) {
|
||||
if(!basket->read_offset_tables()) {
|
||||
if(!basket->read_offset_tables(a_file.byte_swap())) {
|
||||
m_out << "tools::rroot::branch::get_basket :"
|
||||
<< " read_offset_tables failed."
|
||||
<< std::endl;
|
||||
@@ -916,8 +911,6 @@ protected:
|
||||
|
||||
|
||||
protected:
|
||||
//Tree& fTree;
|
||||
ifile& m_file;
|
||||
std::ostream& m_out;
|
||||
ifac& m_fac;
|
||||
std::vector< std::pair<uint32,uint32> > m_first_last;
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace tools {
|
||||
namespace rroot {
|
||||
|
||||
class branch_element : public branch {
|
||||
typedef branch parent;
|
||||
public:
|
||||
static const std::string& s_class() {
|
||||
static const std::string s_v("tools::rroot::branch_element");
|
||||
@@ -18,21 +19,21 @@ public:
|
||||
public: //iro
|
||||
virtual void* cast(const std::string& a_class) const {
|
||||
if(void* p = cmp_cast<branch_element>(this,a_class)) return p;
|
||||
return branch::cast(a_class);
|
||||
return parent::cast(a_class);
|
||||
}
|
||||
virtual const std::string& s_cls() const {return s_class();}
|
||||
public:
|
||||
static cid id_class() {return branch_element_cid();}
|
||||
virtual void* cast(cid a_class) const {
|
||||
if(void* p = cmp_cast<branch_element>(this,a_class)) {return p;}
|
||||
return branch::cast(a_class);
|
||||
return parent::cast(a_class);
|
||||
}
|
||||
public:
|
||||
virtual bool stream(buffer& a_buffer) {
|
||||
short v;
|
||||
unsigned int s, c;
|
||||
if(!a_buffer.read_version(v,s,c)) return false;
|
||||
if(!branch::stream(a_buffer)) return false;
|
||||
if(!parent::stream(a_buffer)) return false;
|
||||
|
||||
if(v<=7) {
|
||||
if(!a_buffer.read(fClassName)) return false;
|
||||
@@ -264,9 +265,9 @@ public: //branch
|
||||
*/
|
||||
}
|
||||
|
||||
virtual bool find_entry(uint32 a_entry,uint32& a_nbytes){
|
||||
virtual bool find_entry(ifile& a_file,uint32 a_entry,uint32& a_nbytes){
|
||||
//The below line will call the upper read_leaves.
|
||||
if(!branch::find_entry(a_entry,a_nbytes)) return false;
|
||||
if(!parent::find_entry(a_file,a_entry,a_nbytes)) return false;
|
||||
|
||||
if(m_branches.size()) {
|
||||
//if(!m_obj) {
|
||||
@@ -276,16 +277,31 @@ public: //branch
|
||||
|
||||
tools_vforcit(branch*,m_branches,it) {
|
||||
uint32 n;
|
||||
if(!(*it)->find_entry(a_entry,n)) return false;
|
||||
if(!(*it)->find_entry(a_file,a_entry,n)) return false;
|
||||
a_nbytes += n;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool show(std::ostream& a_out,ifile& a_file,uint32 a_entry){
|
||||
uint32 n;
|
||||
if(!find_entry(a_file,a_entry,n)) return false;
|
||||
|
||||
{std::string s;
|
||||
uint32 len = uint32(name().size())+128;
|
||||
sprintf(s,len," %-15s = ",name().c_str());
|
||||
a_out << s;}
|
||||
|
||||
a_out << m_obj << std::endl;
|
||||
|
||||
return true;
|
||||
//return parent::show(a_out,a_file,a_entry);
|
||||
}
|
||||
public:
|
||||
branch_element(ifile& a_file,ifac& a_fac)
|
||||
: branch(a_file,a_fac)
|
||||
branch_element(std::ostream& a_out,ifac& a_fac)
|
||||
:parent(a_out,a_fac)
|
||||
,m_obj(0)
|
||||
,fClassVersion(0)
|
||||
,fID(0)
|
||||
@@ -296,7 +312,7 @@ public:
|
||||
virtual ~branch_element(){delete m_obj;}
|
||||
protected:
|
||||
branch_element(const branch_element& a_from)
|
||||
:iro(a_from),branch(a_from){}
|
||||
:iro(a_from),parent(a_from){}
|
||||
branch_element& operator=(const branch_element&){return *this;}
|
||||
public:
|
||||
const std::string& class_name() const {return fClassName;}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
// in TOOLS_STL, we don't have (yet) a performant map.
|
||||
|
||||
#ifdef inlib_stl_vector
|
||||
#ifdef tools_stl_vector
|
||||
#define TOOLS_RROOT_OBJ_MAP_HASH_TABLE
|
||||
//#define TOOLS_RROOT_OBJ_MAP_OMAP
|
||||
#else
|
||||
@@ -40,6 +40,8 @@ namespace tools {
|
||||
namespace rroot {
|
||||
|
||||
class buffer : public rbuf {
|
||||
typedef rbuf parent;
|
||||
|
||||
static const std::string& s_class() {
|
||||
static const std::string s_v("tools::rroot::buffer");
|
||||
return s_v;
|
||||
@@ -76,7 +78,7 @@ class buffer : public rbuf {
|
||||
public:
|
||||
buffer(std::ostream& a_out,bool a_byte_swap,
|
||||
uint32 a_size,char* a_buffer,uint32 a_klen,bool a_verbose)
|
||||
: rbuf(a_out,a_byte_swap,a_buffer+a_size,m_pos)
|
||||
:parent(a_out,a_byte_swap,a_buffer+a_size,m_pos)
|
||||
,m_byte_swap(a_byte_swap)
|
||||
,m_verbose(a_verbose)
|
||||
,m_size(a_size) //expect a not zero size.
|
||||
@@ -97,7 +99,7 @@ public:
|
||||
}
|
||||
protected:
|
||||
buffer(const buffer& a_from)
|
||||
: rbuf(a_from.m_out,a_from.m_byte_swap,0,m_pos)
|
||||
:parent(a_from.m_out,a_from.m_byte_swap,0,m_pos)
|
||||
,m_byte_swap(a_from.m_byte_swap)
|
||||
,m_map_objs(a_from.m_map_objs)
|
||||
{
|
||||
@@ -107,6 +109,9 @@ protected:
|
||||
}
|
||||
buffer& operator=(const buffer&){return *this;}
|
||||
public:
|
||||
bool byte_swap() const {return m_byte_swap;}
|
||||
bool verbose() const {return m_verbose;}
|
||||
|
||||
void set_offset(unsigned int a_off) {m_pos = m_buffer+a_off;}
|
||||
|
||||
//char* buffer() const {return m_buffer;}
|
||||
@@ -128,7 +133,7 @@ protected:
|
||||
a_class.clear();
|
||||
|
||||
uint32 tag;
|
||||
if(!rbuf::read(tag)) return false;
|
||||
if(!parent::read(tag)) return false;
|
||||
|
||||
if(tag==kNewClassTag()) {
|
||||
char s[80];
|
||||
@@ -186,7 +191,7 @@ protected:
|
||||
|
||||
// read byte count and/or tag (older files don't have byte count)
|
||||
uint32 first_int = 0;
|
||||
if(!rbuf::read(first_int)) return false;
|
||||
if(!parent::read(first_int)) return false;
|
||||
|
||||
if(m_verbose) {
|
||||
std::ios::fmtflags old_flags = m_out.flags();
|
||||
@@ -317,7 +322,7 @@ public:
|
||||
m_pos = m_buffer + obj_offset;
|
||||
|
||||
uint32 first_int;
|
||||
if(!rbuf::read(first_int)) return false;
|
||||
if(!parent::read(first_int)) return false;
|
||||
if(first_int & kByteCountMask()) {
|
||||
std::string scls;
|
||||
if(!read_class_tag(scls)) return false;
|
||||
@@ -466,12 +471,12 @@ public:
|
||||
a_version = 0;
|
||||
short version = 0;
|
||||
// not interested in byte count
|
||||
if(!rbuf::read(version)) return false;
|
||||
if(!parent::read(version)) return false;
|
||||
|
||||
// if this is a byte count, then skip next short and read version
|
||||
if(version & kByteCountVMask()) {
|
||||
if(!rbuf::read(version)) return false;
|
||||
if(!rbuf::read(version)) return false;
|
||||
if(!parent::read(version)) return false;
|
||||
if(!parent::read(version)) return false;
|
||||
}
|
||||
|
||||
a_version = version;
|
||||
@@ -500,11 +505,11 @@ public:
|
||||
} v;
|
||||
|
||||
if(m_byte_swap) {
|
||||
if(!rbuf::read(v.vers[1])) return false;
|
||||
if(!rbuf::read(v.vers[0])) return false;
|
||||
if(!parent::read(v.vers[1])) return false;
|
||||
if(!parent::read(v.vers[0])) return false;
|
||||
} else {
|
||||
if(!rbuf::read(v.vers[0])) return false;
|
||||
if(!rbuf::read(v.vers[1])) return false;
|
||||
if(!parent::read(v.vers[0])) return false;
|
||||
if(!parent::read(v.vers[1])) return false;
|
||||
}
|
||||
|
||||
// no bytecount, backup and read version
|
||||
@@ -514,7 +519,7 @@ public:
|
||||
} else {
|
||||
m_pos -= sizeof(unsigned int);
|
||||
}
|
||||
if(!rbuf::read(version)) return false;
|
||||
if(!parent::read(version)) return false;
|
||||
//printf("Reading version=%d at pos=%d, bytecount=%d\n",
|
||||
//version,*startpos,*bcnt);
|
||||
|
||||
@@ -567,7 +572,7 @@ protected:
|
||||
int nr = 0;
|
||||
while (nr < int(a_max-1)) {
|
||||
char ch;
|
||||
if(!rbuf::read(ch)) return false;
|
||||
if(!parent::read(ch)) return false;
|
||||
// stop when 0 read
|
||||
if(ch == 0) break;
|
||||
a_string[nr++] = ch;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#ifndef tools_rroot_cids
|
||||
#define tools_rroot_cids
|
||||
|
||||
//NOTE : logic must be in sync with wroot/cids.
|
||||
|
||||
#include "../cid"
|
||||
|
||||
namespace tools {
|
||||
@@ -34,6 +36,8 @@ inline cid streamer_element_cid() {return base_cid()+14;}
|
||||
|
||||
inline cid stl_vector_string_cid() {return base_cid()+16;}
|
||||
|
||||
inline cid Named_cid() {return base_cid()+17;}
|
||||
|
||||
//base for templates :
|
||||
inline cid base_leaf_cid() {return base_cid()+20;} //+12=32
|
||||
//NOTE : leaf<T> = base_leaf_cid()+_cid(T)
|
||||
|
||||
@@ -59,6 +59,11 @@ inline const std::string& TList_cls(){
|
||||
return s_v;
|
||||
}
|
||||
|
||||
inline const std::string& TNamed_cls(){
|
||||
static const std::string s_v("TNamed");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
{int v;
|
||||
if(!rb.read(v)) return false;
|
||||
m_nbytes_name = v;}
|
||||
if(versiondir>1000) {
|
||||
if(versiondir>(short)big_file_version_tag()) {
|
||||
if(!rb.read(m_seek_directory)) return false;
|
||||
if(!rb.read(m_seek_parent)) return false;
|
||||
if(!rb.read(m_seek_keys)) return false;
|
||||
@@ -150,10 +150,10 @@ public:
|
||||
|
||||
clear_keys();
|
||||
|
||||
key headerkey(m_file,m_seek_keys,m_nbytes_keys);
|
||||
if(!headerkey.read_file()) return false;
|
||||
key headerkey(m_file.out(),m_seek_keys,m_nbytes_keys);
|
||||
if(!headerkey.read_file(m_file)) return false;
|
||||
char* buffer = headerkey.data_buffer();
|
||||
if(!headerkey.from_buffer(headerkey.eob(),buffer)) return false;
|
||||
if(!headerkey.from_buffer(m_file.byte_swap(),headerkey.eob(),buffer,m_file.verbose())) return false;
|
||||
int nkeys = 0;
|
||||
rbuf rb(m_file.out(),m_file.byte_swap(),headerkey.eob(),buffer);
|
||||
if(!rb.read(nkeys)) return false;
|
||||
@@ -164,8 +164,8 @@ public:
|
||||
<< std::endl;
|
||||
}
|
||||
for(int i=0;i<nkeys;i++) {
|
||||
key* k = new key(m_file);
|
||||
if(!k->from_buffer(headerkey.eob(),buffer)) {
|
||||
key* k = new key(m_file.out());
|
||||
if(!k->from_buffer(m_file.byte_swap(),headerkey.eob(),buffer,m_file.verbose())) {
|
||||
delete k;
|
||||
return false;
|
||||
}
|
||||
@@ -183,8 +183,8 @@ protected:
|
||||
// Record (stored in file):
|
||||
date m_date_C; //Date and time when directory is created
|
||||
date m_date_M; //Date and time of last modification
|
||||
uint32 m_nbytes_keys; //Number of bytes for the keys
|
||||
uint32 m_nbytes_name; //Number of bytes in TNamed at creation time
|
||||
uint32 m_nbytes_keys; //Number of bytes for the keys
|
||||
uint32 m_nbytes_name; //Number of bytes in TNamed at creation time
|
||||
seek m_seek_directory; //Location of directory on file
|
||||
seek m_seek_parent; //Location of parent directory on file
|
||||
seek m_seek_keys; //Location of Keys record on file
|
||||
|
||||
@@ -23,57 +23,41 @@ public:
|
||||
return s_v;
|
||||
}
|
||||
public: //ifac
|
||||
virtual iro* create(const std::string& a_class,const args& a_args) {
|
||||
//m_file.out() << "tools::rroot::fac::create :"
|
||||
virtual iro* create(const std::string& a_class,const args&) {
|
||||
//m_out << "tools::rroot::fac::create :"
|
||||
// << " create object of class " << a_class << "..."
|
||||
// << std::endl;
|
||||
if(a_class=="TBranch") {
|
||||
return new branch(m_file,*this);
|
||||
return new branch(m_out,*this);
|
||||
} else if(a_class=="TBranchElement") {
|
||||
return new branch_element(m_file,*this);
|
||||
return new branch_element(m_out,*this);
|
||||
|
||||
} else if(a_class=="TLeafB") {
|
||||
branch* b = arg_branch(a_args);
|
||||
if(!b) return 0;
|
||||
return new leaf<char>(m_file.out(),*b,*this);
|
||||
return new leaf<char>(m_out,*this);
|
||||
|
||||
} else if(a_class=="TLeafS") {
|
||||
branch* b = arg_branch(a_args);
|
||||
if(!b) return 0;
|
||||
return new leaf<short>(m_file.out(),*b,*this);
|
||||
return new leaf<short>(m_out,*this);
|
||||
|
||||
} else if(a_class=="TLeafI") {
|
||||
branch* b = arg_branch(a_args);
|
||||
if(!b) return 0;
|
||||
return new leaf<int>(m_file.out(),*b,*this);
|
||||
return new leaf<int>(m_out,*this);
|
||||
|
||||
} else if(a_class=="TLeafF") {
|
||||
branch* b = arg_branch(a_args);
|
||||
if(!b) return 0;
|
||||
return new leaf<float>(m_file.out(),*b,*this);
|
||||
return new leaf<float>(m_out,*this);
|
||||
|
||||
} else if(a_class=="TLeafD") {
|
||||
branch* b = arg_branch(a_args);
|
||||
if(!b) return 0;
|
||||
return new leaf<double>(m_file.out(),*b,*this);
|
||||
return new leaf<double>(m_out,*this);
|
||||
|
||||
} else if(a_class=="TLeafO") {
|
||||
branch* b = arg_branch(a_args);
|
||||
if(!b) return 0;
|
||||
return new leaf<bool>(m_file.out(),*b,*this);
|
||||
return new leaf<bool>(m_out,*this);
|
||||
|
||||
} else if(a_class=="TLeafC") {
|
||||
branch* b = arg_branch(a_args);
|
||||
if(!b) return 0;
|
||||
return new leaf_string(m_file.out(),*b,*this);
|
||||
return new leaf_string(m_out,*this);
|
||||
|
||||
} else if(a_class=="TLeafElement") {
|
||||
branch* b = arg_branch(a_args);
|
||||
if(!b) return 0;
|
||||
return new leaf_element(m_file.out(),*b,*this);
|
||||
return new leaf_element(m_out,*this);
|
||||
|
||||
} else if(a_class=="TBasket") {
|
||||
return new basket(m_file);
|
||||
return new basket(m_out);
|
||||
|
||||
// L.Duflot ATLAS file :
|
||||
} else if(a_class=="TTreeIndex") {
|
||||
@@ -118,7 +102,7 @@ public: //ifac
|
||||
return new dummy();
|
||||
|
||||
} else {
|
||||
m_file.out() << "tools::rroot::fac::create :"
|
||||
m_out << "tools::rroot::fac::create :"
|
||||
<< " unknown class " << sout(a_class) << "."
|
||||
<< " Create a tools::rroot::dummy object."
|
||||
<< std::endl;
|
||||
@@ -127,24 +111,26 @@ public: //ifac
|
||||
}
|
||||
virtual void destroy(iro*& a_obj) {delete a_obj;a_obj = 0;}
|
||||
public:
|
||||
fac(ifile& a_file):m_file(a_file){}
|
||||
fac(std::ostream& a_out):m_out(a_out){}
|
||||
virtual ~fac(){}
|
||||
public:
|
||||
fac(const fac& a_from): ifac(a_from),m_file(a_from.m_file){}
|
||||
fac(const fac& a_from):ifac(a_from),m_out(a_from.m_out){}
|
||||
fac& operator=(const fac&){return *this;}
|
||||
protected:
|
||||
/*
|
||||
branch* arg_branch(const args& a_args) {
|
||||
void* p = ifac::find_args(a_args,ifac::arg_branch());
|
||||
if(!p) {
|
||||
m_file.out() << "tools::rroot::fac::arg_branch :"
|
||||
m_out << "tools::rroot::fac::arg_branch :"
|
||||
<< " branch not found in args."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
return (branch*)p;
|
||||
}
|
||||
*/
|
||||
protected:
|
||||
ifile& m_file;
|
||||
std::ostream& m_out;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
static const std::string s_v("tools::rroot::file");
|
||||
return s_v;
|
||||
}
|
||||
virtual const std::string& s_cls() const {return s_class();}
|
||||
public: //ifile
|
||||
virtual const std::string& path() const {return m_path;}
|
||||
|
||||
@@ -115,7 +116,7 @@ public:
|
||||
,m_file(not_open())
|
||||
,m_bytes_read(0)
|
||||
,m_root_directory(*this)
|
||||
,m_streamer_info_key(*this)
|
||||
,m_streamer_info_key(a_out)
|
||||
// begin of record :
|
||||
,m_version(0)
|
||||
,m_BEGIN(0)
|
||||
@@ -156,7 +157,7 @@ protected:
|
||||
:ifile(a_from)
|
||||
,m_out(a_from.m_out)
|
||||
,m_root_directory(*this)
|
||||
,m_streamer_info_key(*this)
|
||||
,m_streamer_info_key(a_from.m_out)
|
||||
{
|
||||
#ifdef TOOLS_MEM
|
||||
mem::increment(s_class().c_str());
|
||||
@@ -422,7 +423,7 @@ protected:
|
||||
char* buffer = new char[m_nbytes_info+1];
|
||||
if(!read_buffer(buffer,m_nbytes_info)) {delete [] buffer;return false;}
|
||||
char* buf = buffer;
|
||||
if(!m_streamer_info_key.from_buffer(buffer+m_nbytes_info,buf)) {
|
||||
if(!m_streamer_info_key.from_buffer(byte_swap(),buffer+m_nbytes_info,buf,m_verbose)) {
|
||||
delete [] buffer;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
if(it==a_args.end()) return 0;
|
||||
return (*it).second;
|
||||
}
|
||||
static char arg_branch() {return 'B';}
|
||||
//static char arg_branch() {return 'B';}
|
||||
static char arg_class() {return 'C';}
|
||||
|
||||
static std::string* arg_class(const args& a_args) {
|
||||
|
||||
@@ -189,7 +189,7 @@ public: //iro
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
m_elements.operator=(*obj);
|
||||
if(obj) m_elements.operator=(*obj);
|
||||
delete obj;}
|
||||
|
||||
return a_buffer.check_byte_count(s,c,s_store_class());
|
||||
|
||||
@@ -40,14 +40,14 @@ public:
|
||||
static uint32 std_string_record_size(const std::string& x) {
|
||||
// Returns size string will occupy on I/O buffer.
|
||||
if (x.size() > 254)
|
||||
return x.size()+sizeof(unsigned char)+sizeof(int);
|
||||
return uint32(x.size()+sizeof(unsigned char)+sizeof(int));
|
||||
else
|
||||
return x.size()+sizeof(unsigned char);
|
||||
return uint32(x.size()+sizeof(unsigned char));
|
||||
}
|
||||
|
||||
public:
|
||||
key(ifile& a_file)
|
||||
:m_file(a_file)
|
||||
key(std::ostream& a_out)
|
||||
:m_out(a_out)
|
||||
,m_buf_size(0)
|
||||
,m_buffer(0)
|
||||
// Record :
|
||||
@@ -70,8 +70,8 @@ public:
|
||||
//fDate.setDate(0);
|
||||
}
|
||||
|
||||
key(ifile& a_file,seek a_pos,uint32 a_nbytes)
|
||||
:m_file(a_file)
|
||||
key(std::ostream& a_out,seek a_pos,uint32 a_nbytes)
|
||||
:m_out(a_out)
|
||||
,m_buf_size(0)
|
||||
,m_buffer(0)
|
||||
// Record :
|
||||
@@ -90,10 +90,10 @@ public:
|
||||
#ifdef TOOLS_MEM
|
||||
mem::increment(s_class().c_str());
|
||||
#endif
|
||||
if(a_pos>START_BIG_FILE) m_version += 1000;
|
||||
if(a_pos>START_BIG_FILE) m_version += big_file_version_tag();
|
||||
m_buffer = new char[a_nbytes];
|
||||
if(!m_buffer) {
|
||||
m_file.out() << "tools::rroot::key::key(cpcstor) :"
|
||||
m_out << "tools::rroot::key::key(cpcstor) :"
|
||||
<< " can't alloc " << a_nbytes << "."
|
||||
<< std::endl;
|
||||
} else {
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
}
|
||||
protected:
|
||||
key(const key& a_from)
|
||||
:m_file(a_from.m_file)
|
||||
:m_out(a_from.m_out)
|
||||
,m_buf_size(0)
|
||||
,m_buffer(0)
|
||||
,m_nbytes(a_from.m_nbytes)
|
||||
@@ -129,7 +129,7 @@ protected:
|
||||
if(a_from.m_buf_size && a_from.m_buffer) {
|
||||
m_buffer = new char[a_from.m_buf_size];
|
||||
if(!m_buffer) {
|
||||
m_file.out() << "tools::rroot::key::key(cpcstor) :"
|
||||
m_out << "tools::rroot::key::key(cpcstor) :"
|
||||
<< " can't alloc " << a_from.m_buf_size << "."
|
||||
<< std::endl;
|
||||
} else {
|
||||
@@ -160,7 +160,7 @@ public:
|
||||
if(a_from.m_buf_size && a_from.m_buffer) {
|
||||
m_buffer = new char[a_from.m_buf_size];
|
||||
if(!m_buffer) {
|
||||
m_file.out() << "tools::rroot::key::operator=() :"
|
||||
m_out << "tools::rroot::key::operator=() :"
|
||||
<< " can't alloc " << a_from.m_buf_size << "."
|
||||
<< std::endl;
|
||||
} else {
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
ifile& file() {return m_file;}
|
||||
std::ostream& out() const {return m_out;}
|
||||
|
||||
uint32 nbytes() const {return m_nbytes;}
|
||||
seek seek_key() const {return m_seek_key;}
|
||||
@@ -183,12 +183,12 @@ public:
|
||||
const std::string& object_title() const {return m_object_title;}
|
||||
const std::string& object_class() const {return m_object_class;}
|
||||
|
||||
bool read_file(){
|
||||
bool read_file(ifile& a_file){
|
||||
// Read the key structure from the file.
|
||||
if(!m_file.set_pos(m_seek_key)) return false;
|
||||
if(!m_file.read_buffer(m_buffer,m_nbytes)) return false;
|
||||
if(m_file.verbose()) {
|
||||
m_file.out() << "tools::rroot::key::read_file :"
|
||||
if(!a_file.set_pos(m_seek_key)) return false;
|
||||
if(!a_file.read_buffer(m_buffer,m_nbytes)) return false;
|
||||
if(a_file.verbose()) {
|
||||
m_out << "tools::rroot::key::read_file :"
|
||||
<< " reading " << m_nbytes << " bytes"
|
||||
<< " at position " << m_seek_key
|
||||
<< "."
|
||||
@@ -203,8 +203,8 @@ public:
|
||||
uint32 buf_size() const {return m_buf_size;}
|
||||
uint32 key_length() const {return m_key_length;}
|
||||
|
||||
bool from_buffer(const char* aEOB,char*& a_pos) {
|
||||
rbuf rb(m_file.out(),m_file.byte_swap(),aEOB,a_pos);
|
||||
bool from_buffer(bool a_byte_swap,const char* aEOB,char*& a_pos,bool a_verbose) {
|
||||
rbuf rb(m_out,a_byte_swap,aEOB,a_pos);
|
||||
int _nbytes;
|
||||
if(!rb.read(_nbytes)) return false;
|
||||
/*
|
||||
@@ -237,7 +237,7 @@ public:
|
||||
{short v;
|
||||
if(!rb.read(v)) return false;
|
||||
m_cycle = v;}
|
||||
if(version>1000) {
|
||||
if(version>(short)big_file_version_tag()) {
|
||||
if(!rb.read(m_seek_key)) return false;
|
||||
if(!rb.read(m_seek_parent_dir)) return false;
|
||||
} else {
|
||||
@@ -251,8 +251,8 @@ public:
|
||||
if(!rb.read(m_object_class)) return false;
|
||||
if(!rb.read(m_object_name)) return false;
|
||||
if(!rb.read(m_object_title)) return false;
|
||||
if(m_file.verbose()) {
|
||||
m_file.out() << "tools::rroot::key::from_buffer :"
|
||||
if(a_verbose) {
|
||||
m_out << "tools::rroot::key::from_buffer :"
|
||||
<< " nbytes : " << m_nbytes
|
||||
<< ", object class : " << sout(m_object_class)
|
||||
<< ", object name : " << sout(m_object_name)
|
||||
@@ -264,9 +264,9 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
char* get_object_buffer(uint32& a_size) {
|
||||
char* get_object_buffer(ifile& a_file,uint32& a_size) {
|
||||
if(!m_key_length) {
|
||||
m_file.out() << "tools::rroot::key::get_object_buffer :"
|
||||
m_out << "tools::rroot::key::get_object_buffer :"
|
||||
<< " WARNING : m_key_length is zero."
|
||||
<< std::endl;
|
||||
//delete [] m_buffer;
|
||||
@@ -276,7 +276,7 @@ public:
|
||||
//return 0;
|
||||
}
|
||||
if(!m_nbytes) {
|
||||
m_file.out() << "tools::rroot::key::get_object_buffer :"
|
||||
m_out << "tools::rroot::key::get_object_buffer :"
|
||||
<< " m_nbytes is zero."
|
||||
<< std::endl;
|
||||
delete [] m_buffer;
|
||||
@@ -286,13 +286,13 @@ public:
|
||||
return 0;
|
||||
}
|
||||
if(!m_object_size) {
|
||||
m_file.out() << "tools::rroot::key::get_object_buffer :"
|
||||
m_out << "tools::rroot::key::get_object_buffer :"
|
||||
<< " WARNING : m_object_size is zero."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
if(m_file.verbose()) {
|
||||
m_file.out() << "tools::rroot::key::get_object_buffer :"
|
||||
if(a_file.verbose()) {
|
||||
m_out << "tools::rroot::key::get_object_buffer :"
|
||||
<< " m_nbytes : " << m_nbytes
|
||||
<< " m_key_length : " << m_key_length
|
||||
<< " m_object_size : " << m_object_size << "."
|
||||
@@ -304,7 +304,7 @@ public:
|
||||
delete [] m_buffer;
|
||||
m_buf_size = m_key_length+m_object_size;
|
||||
if(m_buf_size<m_nbytes) {
|
||||
m_file.out() << "tools::rroot::key::get_object_buffer :"
|
||||
m_out << "tools::rroot::key::get_object_buffer :"
|
||||
<< " WARNING : m_buf_size<m_nbytes."
|
||||
<< " m_buf_size " << m_buf_size
|
||||
<< " m_nbytes " << m_nbytes
|
||||
@@ -314,7 +314,7 @@ public:
|
||||
}
|
||||
m_buffer = new char[m_buf_size];
|
||||
if(!m_buffer) {
|
||||
m_file.out() << "tools::rroot::key::get_object_buffer :"
|
||||
m_out << "tools::rroot::key::get_object_buffer :"
|
||||
<< " can't alloc " << m_buf_size
|
||||
<< std::endl;
|
||||
m_buffer = 0;
|
||||
@@ -323,7 +323,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!read_file()) {
|
||||
if(!read_file(a_file)) {
|
||||
delete [] m_buffer;
|
||||
m_buffer = 0;
|
||||
m_buf_size = 0;
|
||||
@@ -337,7 +337,7 @@ public:
|
||||
uint32 decsiz = m_key_length+m_object_size;
|
||||
char* decbuf = new char[decsiz];
|
||||
if(!decbuf) {
|
||||
m_file.out() << "tools::rroot::key::get_object_buffer :"
|
||||
m_out << "tools::rroot::key::get_object_buffer :"
|
||||
<< " can't alloc " << decsiz
|
||||
<< std::endl;
|
||||
a_size = 0;
|
||||
@@ -347,7 +347,7 @@ public:
|
||||
delete [] m_buffer;
|
||||
m_buffer = new char[m_nbytes];
|
||||
m_buf_size = m_nbytes;
|
||||
if(!read_file()) {
|
||||
if(!read_file(a_file)) {
|
||||
delete [] decbuf;
|
||||
decbuf = 0;
|
||||
delete [] m_buffer;
|
||||
@@ -367,7 +367,7 @@ public:
|
||||
while(true) {
|
||||
int nin = 9 + ((int)bufcur[3] | ((int)bufcur[4] << 8) | ((int)bufcur[5] << 16));
|
||||
int nbuf = (int)bufcur[6] | ((int)bufcur[7] << 8) | ((int)bufcur[8] << 16);
|
||||
if(!unzip(m_file.out(),nin,bufcur,nbuf,objbuf,nout)) break;
|
||||
if(!unzip(m_out,a_file,nin,bufcur,nbuf,objbuf,nout)) break;
|
||||
if(!nout) break;
|
||||
noutot += nout;
|
||||
if(noutot >= m_object_size) break;
|
||||
@@ -380,7 +380,7 @@ public:
|
||||
m_buf_size = 0;
|
||||
|
||||
if(!noutot) {
|
||||
m_file.out() << "tools::rroot::key::get_object_buffer :"
|
||||
m_out << "tools::rroot::key::get_object_buffer :"
|
||||
<< " nothing from decompression."
|
||||
<< std::endl;
|
||||
delete [] decbuf;
|
||||
@@ -389,7 +389,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
if(noutot!=m_object_size) {
|
||||
m_file.out() << "tools::rroot::key::get_object_buffer :"
|
||||
m_out << "tools::rroot::key::get_object_buffer :"
|
||||
<< " decompression mismatch."
|
||||
<< " noutot " << noutot
|
||||
<< " m_object_size " << m_object_size
|
||||
@@ -428,7 +428,7 @@ protected:
|
||||
_nbytes += sizeof(date);
|
||||
_nbytes += sizeof(m_key_length);
|
||||
_nbytes += sizeof(m_cycle); //2+4*4=18
|
||||
if(a_version>1000) {
|
||||
if(a_version>big_file_version_tag()) {
|
||||
_nbytes += sizeof(seek);
|
||||
_nbytes += sizeof(seek); //18+2*8=34
|
||||
} else {
|
||||
@@ -442,7 +442,8 @@ protected:
|
||||
return _nbytes;
|
||||
}
|
||||
|
||||
bool unzip(std::ostream& a_out,int a_srcsize,unsigned char* a_src,int a_tgtsize,unsigned char* a_tgt,int& a_irep) {
|
||||
bool unzip(std::ostream& a_out,ifile& a_file,
|
||||
int a_srcsize,unsigned char* a_src,int a_tgtsize,unsigned char* a_tgt,int& a_irep) {
|
||||
|
||||
// Author: E.Chernyaev (IHEP/Protvino)
|
||||
// Input: scrsize - size of input buffer
|
||||
@@ -490,7 +491,7 @@ protected:
|
||||
|
||||
if (a_src[0] == 'Z' && a_src[1] == 'L') { //compressed with zlib.
|
||||
tools::decompress_func func;
|
||||
if(!m_file.unziper('Z',func)) {
|
||||
if(!a_file.unziper('Z',func)) {
|
||||
a_out << "tools::rroot::key::unzip : "
|
||||
<< " zlib unziper not found." << std::endl;
|
||||
return false;
|
||||
@@ -553,7 +554,7 @@ protected:
|
||||
return s_v;
|
||||
}
|
||||
protected:
|
||||
ifile& m_file;
|
||||
std::ostream& m_out;
|
||||
uint32 m_buf_size;
|
||||
char* m_buffer;
|
||||
// Record (stored in file) :
|
||||
|
||||
@@ -91,41 +91,38 @@ public:
|
||||
return true;
|
||||
}
|
||||
public: //base_leaf
|
||||
virtual bool read_basket(buffer& a_buffer) {
|
||||
virtual bool read_buffer(buffer& a_buffer) {
|
||||
if(!m_leaf_count && (m_ndata == 1)) {
|
||||
/*
|
||||
if(!aBuffer.read(m_value[0])) {
|
||||
std::ostream& out = base_leaf::branch().out();
|
||||
out << "Rio::Leaf::readBasket : \"" << name() << "\" :"
|
||||
m_out << "Rio::Leaf::readBasket : \"" << name() << "\" :"
|
||||
<< " read value failed."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
*/
|
||||
m_out << "tools::rroot::leaf::read_basket :"
|
||||
m_out << "tools::rroot::leaf::read_buffer :"
|
||||
<< " case(1) not yet handled."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}else {
|
||||
if(m_leaf_count) {
|
||||
m_out << "tools::rroot::leaf::read_basket :"
|
||||
m_out << "tools::rroot::leaf::read_buffer :"
|
||||
<< " case(2) not yet handled."
|
||||
<< std::endl;
|
||||
return false;
|
||||
/*
|
||||
int len = m_leaf_count->number();
|
||||
if (len > m_leaf_count->maximum()) {
|
||||
std::ostream& out = base_leaf::branch().out();
|
||||
out << "Rio::Leaf::readBasket : \""
|
||||
m_out << "Rio::Leaf::readBasket : \""
|
||||
<< name() << "\", len = " << len << " and max = "
|
||||
<< m_leaf_count->maximum() << std::endl;
|
||||
len = m_leaf_count->maximum();
|
||||
}
|
||||
m_ndata = len * fLength;
|
||||
if(!aBuffer.readFastArray(m_value,len * fLength)) {
|
||||
std::ostream& out = base_leaf::branch().out();
|
||||
out << "Rio::Leaf::readBasket : \"" << name() << "\" :"
|
||||
m_out << "Rio::Leaf::readBasket : \"" << name() << "\" :"
|
||||
<< " readFastArray failed."
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -139,14 +136,14 @@ public: //base_leaf
|
||||
m_value = new T[m_length]; //we assume m_length is constant.
|
||||
}
|
||||
if(!a_buffer.read_fast_array<T>(m_value,m_length)) {
|
||||
m_out << "tools::rroot::leaf::read_basket :"
|
||||
m_out << "tools::rroot::leaf::read_buffer :"
|
||||
<< " read_fast_array failed. m_length " << m_length
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
m_out << "tools::rroot::leaf::read_basket :"
|
||||
m_out << "tools::rroot::leaf::read_buffer :"
|
||||
<< " read_fast_array failed. m_length is zero."
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -163,8 +160,8 @@ public: //base_leaf
|
||||
}
|
||||
virtual uint32 num_elem() const {return m_length;}
|
||||
public:
|
||||
leaf(std::ostream& a_out,rroot::branch& a_branch,ifac& a_fac)
|
||||
:base_leaf(a_out,a_branch,a_fac)
|
||||
leaf(std::ostream& a_out,ifac& a_fac)
|
||||
:base_leaf(a_out,a_fac)
|
||||
,m_min(T()),m_max(T())
|
||||
,m_value(0)
|
||||
{}
|
||||
@@ -221,13 +218,13 @@ public:
|
||||
return true;
|
||||
}
|
||||
public: //base_leaf
|
||||
virtual bool read_basket(buffer& a_buffer) {
|
||||
virtual bool read_buffer(buffer& a_buffer) {
|
||||
delete [] m_value;
|
||||
m_value = 0;
|
||||
|
||||
unsigned char lenchar;
|
||||
if(!a_buffer.read(lenchar)) {
|
||||
m_out << "tools::rroot::leaf_string::read_basket :"
|
||||
m_out << "tools::rroot::leaf_string::read_buffer :"
|
||||
<< " read(uchar) failed."
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -237,7 +234,7 @@ public: //base_leaf
|
||||
len = lenchar;
|
||||
} else {
|
||||
if(!a_buffer.read(len)) {
|
||||
m_out << "tools::rroot::leaf_string::read_basket :"
|
||||
m_out << "tools::rroot::leaf_string::read_buffer :"
|
||||
<< " read(int) failed."
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -246,7 +243,7 @@ public: //base_leaf
|
||||
if(len) {
|
||||
|
||||
if(!m_length) {
|
||||
m_out << "tools::rroot::leaf_string::read_basket :"
|
||||
m_out << "tools::rroot::leaf_string::read_buffer :"
|
||||
<< " m_length is zero."
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -257,7 +254,7 @@ public: //base_leaf
|
||||
m_value = new char[len+1];
|
||||
|
||||
if(!a_buffer.read_fast_array(m_value,len)) {
|
||||
m_out << "tools::rroot::leaf_string::read_basket :"
|
||||
m_out << "tools::rroot::leaf_string::read_buffer :"
|
||||
<< " read_fast_array failed."
|
||||
<< std::endl;
|
||||
delete [] m_value;
|
||||
@@ -276,8 +273,8 @@ public: //base_leaf
|
||||
}
|
||||
virtual uint32 num_elem() const {return 1;}
|
||||
public:
|
||||
leaf_string(std::ostream& a_out,rroot::branch& a_branch,ifac& a_fac)
|
||||
:base_leaf(a_out,a_branch,a_fac)
|
||||
leaf_string(std::ostream& a_out,ifac& a_fac)
|
||||
:base_leaf(a_out,a_fac)
|
||||
,m_min(0),m_max(0),m_value(0){}
|
||||
virtual ~leaf_string(){
|
||||
delete [] m_value;
|
||||
@@ -330,8 +327,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
public: //base_leaf
|
||||
virtual bool read_basket(buffer&) {
|
||||
m_out << "tools::rroot::leaf_element::read_basket :"
|
||||
virtual bool read_buffer(buffer&) {
|
||||
m_out << "tools::rroot::leaf_element::read_buffer :"
|
||||
<< " dummy."
|
||||
<< std::endl;
|
||||
return false;
|
||||
@@ -339,8 +336,8 @@ public: //base_leaf
|
||||
virtual bool print_value(std::ostream&,uint32) const {return true;}
|
||||
virtual uint32 num_elem() const {return 0;}
|
||||
public:
|
||||
leaf_element(std::ostream& a_out,rroot::branch& a_branch,ifac& a_fac)
|
||||
:base_leaf(a_out,a_branch,a_fac),fID(0),fType(0){}
|
||||
leaf_element(std::ostream& a_out,ifac& a_fac)
|
||||
:base_leaf(a_out,a_fac),fID(0),fType(0){}
|
||||
virtual ~leaf_element(){}
|
||||
protected:
|
||||
leaf_element(const leaf_element& a_from)
|
||||
@@ -354,6 +351,10 @@ protected:
|
||||
int fType; //leaf type
|
||||
};
|
||||
|
||||
// for SWIG :
|
||||
inline leaf<float>* cast_leaf_float(base_leaf& a_leaf) {return safe_cast<base_leaf, leaf<float> >(a_leaf);}
|
||||
inline leaf<int>* cast_leaf_int(base_leaf& a_leaf) {return safe_cast<base_leaf, leaf<int> >(a_leaf);}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -46,9 +46,9 @@ public:
|
||||
virtual bool visit(std::vector<bool>& a_v){
|
||||
std::vector<unsigned char> data;
|
||||
if(!m_buf.read_array(data)) {a_v.clear();return false;}
|
||||
unsigned int number = data.size();
|
||||
size_t number = data.size();
|
||||
a_v.resize(number);
|
||||
for(unsigned int index=0;index<number;index++) {
|
||||
for(size_t index=0;index<number;index++) {
|
||||
a_v[index] = (data[index]==1?true:false);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
public: //icolumn<T>
|
||||
virtual bool get_entry(T& a_v) const {
|
||||
unsigned int n;
|
||||
if(!m_leaf.branch().find_entry(uint32(m_index),n)) {
|
||||
if(!m_branch.find_entry(m_file,uint32(m_index),n)) {
|
||||
a_v = T();
|
||||
return false;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
virtual bool fetch_entry() const {
|
||||
//NOTE : it is ok to have a NULL m_user_var.
|
||||
unsigned int n;
|
||||
if(!m_leaf.branch().find_entry(uint32(m_index),n)) {
|
||||
if(!m_branch.find_entry(m_file,uint32(m_index),n)) {
|
||||
if(m_user_var) *m_user_var = T();
|
||||
return false;
|
||||
}
|
||||
@@ -77,8 +77,10 @@ public:
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
column(leaf<T>& a_leaf,int64& a_index,T* a_user_var = 0)
|
||||
:m_leaf(a_leaf)
|
||||
column(ifile& a_file,branch& a_branch,leaf<T>& a_leaf,int64& a_index,T* 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
|
||||
{}
|
||||
@@ -87,6 +89,8 @@ public:
|
||||
column(const column& 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)
|
||||
@@ -97,6 +101,8 @@ public:
|
||||
return *this;
|
||||
}
|
||||
protected:
|
||||
ifile& m_file;
|
||||
branch& m_branch;
|
||||
leaf<T>& m_leaf;
|
||||
int64& m_index; //WARNING : a ref.
|
||||
T* m_user_var;
|
||||
@@ -119,7 +125,7 @@ public:
|
||||
virtual bool fetch_entry() const {
|
||||
//NOTE : it is ok to have a NULL m_user_var.
|
||||
unsigned int n;
|
||||
if(!m_leaf.branch().find_entry(uint32(m_index),n)) {
|
||||
if(!m_branch.find_entry(m_file,uint32(m_index),n)) {
|
||||
if(m_user_var) *m_user_var = std::string();
|
||||
return false;
|
||||
}
|
||||
@@ -127,8 +133,10 @@ public:
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
column_string(leaf_string& a_leaf,int64& a_index,std::string* a_user_var = 0)
|
||||
:m_leaf(a_leaf)
|
||||
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
|
||||
{}
|
||||
@@ -136,6 +144,8 @@ public:
|
||||
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)
|
||||
@@ -146,6 +156,8 @@ public:
|
||||
return *this;
|
||||
}
|
||||
protected:
|
||||
ifile& m_file;
|
||||
branch& m_branch;
|
||||
leaf_string& m_leaf;
|
||||
int64& m_index; //WARNING : a ref.
|
||||
std::string* m_user_var;
|
||||
@@ -167,9 +179,8 @@ public:
|
||||
public: //icolumn<T>
|
||||
virtual bool get_entry(T& a_v) const {
|
||||
unsigned int n;
|
||||
if(!m_leaf.branch().find_entry(uint32(m_index),n)) {a_v = T();return false;}
|
||||
if(!m_be) {a_v = T();return false;}
|
||||
iro* obj = m_be->object(); //Not owner.
|
||||
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;}
|
||||
@@ -178,15 +189,11 @@ public:
|
||||
}
|
||||
virtual bool fetch_entry() const {
|
||||
unsigned int n;
|
||||
if(!m_leaf.branch().find_entry(uint32(m_index),n)) {
|
||||
if(!m_be.find_entry(m_file,uint32(m_index),n)) {
|
||||
if(m_user_var) *m_user_var = T();
|
||||
return false;
|
||||
}
|
||||
if(!m_be) {
|
||||
if(m_user_var) *m_user_var = T();
|
||||
return false;
|
||||
}
|
||||
iro* obj = m_be->object(); //Not owner.
|
||||
iro* obj = m_be.object(); //Not owner.
|
||||
if(!obj) {
|
||||
if(m_user_var) *m_user_var = T();
|
||||
return false;
|
||||
@@ -200,33 +207,33 @@ public:
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
column_element(leaf_element& a_leaf,int64& a_index,T* a_user_var = 0)
|
||||
:m_leaf(a_leaf)
|
||||
column_element(ifile& a_file,branch_element& a_branch,leaf_element& a_leaf,int64& a_index,T* a_user_var = 0)
|
||||
:m_file(a_file)
|
||||
,m_be(a_branch)
|
||||
,m_leaf(a_leaf)
|
||||
,m_index(a_index) //WARNING : we keep the ref !
|
||||
,m_be(0)
|
||||
,m_user_var(a_user_var) //not owner
|
||||
{
|
||||
m_be = safe_cast<branch,branch_element>(m_leaf.branch());
|
||||
}
|
||||
{}
|
||||
virtual ~column_element(){}
|
||||
protected:
|
||||
column_element(const column_element& 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_be(a_from.m_be)
|
||||
,m_user_var(a_from.m_user_var)
|
||||
{}
|
||||
column_element& operator=(const column_element& a_from){
|
||||
if(&a_from==this) return *this;
|
||||
m_be = a_from.m_be;
|
||||
m_user_var = a_from.m_user_var;
|
||||
return *this;
|
||||
}
|
||||
protected:
|
||||
ifile& m_file;
|
||||
branch_element& m_be;
|
||||
leaf_element& m_leaf;
|
||||
int64& m_index; //WARNING : a ref.
|
||||
branch_element* m_be;
|
||||
T* m_user_var;
|
||||
};
|
||||
|
||||
@@ -254,7 +261,8 @@ public:
|
||||
bool initialize(std::ostream& a_out,const ntuple_binding& a_bd = ntuple_binding()) {
|
||||
tools::clear<read::icol>(m_cols);
|
||||
|
||||
std::vector<base_leaf*> leaves = m_tree.find_leaves();
|
||||
std::vector<base_leaf*> leaves;
|
||||
m_tree.find_leaves(leaves);
|
||||
tools_vforcit(base_leaf*,leaves,it) {
|
||||
base_leaf* bl = (*it);
|
||||
if(find_named<read::icol>(m_cols,bl->name())) {
|
||||
@@ -265,6 +273,14 @@ public:
|
||||
tools::clear<read::icol>(m_cols);
|
||||
return false;
|
||||
}
|
||||
branch* _branch = m_tree.find_leaf_branch(*bl);
|
||||
if(!_branch) {
|
||||
a_out << "tools::rroot::ntuple::initialize :"
|
||||
<< " can't find branch of leaf " << sout(bl->name()) << "."
|
||||
<< std::endl;
|
||||
tools::clear<read::icol>(m_cols);
|
||||
return false;
|
||||
}
|
||||
|
||||
//a_out << "tools::rroot::ntuple::initialize :"
|
||||
// << " entries " << bl->branch().entry_number() << "."
|
||||
@@ -272,32 +288,41 @@ public:
|
||||
|
||||
if(leaf<float>* lf = safe_cast<base_leaf, leaf<float> >(*bl) ){
|
||||
|
||||
column<float>* col = new column<float>(*lf,m_index,a_bd.find_variable<float>(bl->name()));
|
||||
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);
|
||||
|
||||
} else if(leaf<double>* ld = safe_cast<base_leaf, leaf<double> >(*bl) ){
|
||||
|
||||
column<double>* col = new column<double>(*ld,m_index,a_bd.find_variable<double>(bl->name()));
|
||||
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>(*li,m_index,a_bd.find_variable<int>(bl->name()));
|
||||
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(*ls,m_index,a_bd.find_variable<std::string>(bl->name()));
|
||||
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_element* le = safe_cast<base_leaf,leaf_element>(*bl) ){
|
||||
|
||||
branch_element* be = safe_cast<branch,branch_element>(le->branch());
|
||||
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);
|
||||
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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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;
|
||||
@@ -306,25 +331,25 @@ public:
|
||||
} 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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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;
|
||||
@@ -333,49 +358,49 @@ public:
|
||||
} 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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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;
|
||||
@@ -384,7 +409,7 @@ public:
|
||||
} 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(*le,m_index,a_bd.find_variable< std::vector<el_t> >(bl->name()));
|
||||
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 {
|
||||
@@ -409,7 +434,7 @@ public:
|
||||
|
||||
}
|
||||
|
||||
unsigned int num = m_cols.size();
|
||||
size_t num = m_cols.size();
|
||||
if(!num) {
|
||||
a_out << "tools::rroot::ntuple::initialize :"
|
||||
<< " zero columns."
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
namespace tools {
|
||||
namespace rroot {
|
||||
|
||||
inline tools::rroot::TDirectory* find_dir(tools::rroot::directory& a_dir,const std::string& a_name) {
|
||||
inline TDirectory* find_dir(directory& a_dir,const std::string& a_name) {
|
||||
std::ostream& out = a_dir.file().out();
|
||||
tools::rroot::key* k = a_dir.find_key(a_name);
|
||||
key* k = a_dir.find_key(a_name);
|
||||
if(!k) {
|
||||
//out << "tools::rroot::find_dir :"
|
||||
// << " " << a_name << " not a key."
|
||||
@@ -27,22 +27,22 @@ inline tools::rroot::TDirectory* find_dir(tools::rroot::directory& a_dir,const s
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(k->object_class()!=tools::rroot::TDirectory_cls()) {
|
||||
if(k->object_class()!=TDirectory_cls()) {
|
||||
out << "tools::rroot::find_dir :"
|
||||
<< " key " << a_name << " not a TDirectory."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
uint32 sz;
|
||||
char* buf = k->get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = k->get_object_buffer(a_dir.file(),sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::find_dir :"
|
||||
<< " can't get directory data buffer."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
tools::rroot::buffer b(out,a_dir.file().byte_swap(),sz,buf,k->key_length(),false);
|
||||
tools::rroot::TDirectory* tdir = new tools::rroot::TDirectory(a_dir.file());
|
||||
buffer b(out,a_dir.file().byte_swap(),sz,buf,k->key_length(),false);
|
||||
TDirectory* tdir = new TDirectory(a_dir.file());
|
||||
if(!tdir) return 0;
|
||||
if(!tdir->stream(b)) {
|
||||
out << "tools::rroot::find_dir :"
|
||||
@@ -53,9 +53,9 @@ inline tools::rroot::TDirectory* find_dir(tools::rroot::directory& a_dir,const s
|
||||
return tdir;
|
||||
}
|
||||
|
||||
inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
inline bool read_key(std::ostream& a_out,ifile& a_file,key& a_key,bool a_dump){
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
@@ -67,10 +67,10 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
// << " get data buffer size " << sz << "."
|
||||
// << std::endl;
|
||||
|
||||
tools::rroot::buffer b(a_out,a_key.file().byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
buffer b(a_out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
|
||||
if(a_key.object_class()==tools::rroot::TH1F_cls()) {
|
||||
tools::histo::h1d* h = tools::rroot::TH1F_stream(b);
|
||||
if(a_key.object_class()==TH1F_cls()) {
|
||||
tools::histo::h1d* h = TH1F_stream(b);
|
||||
if(!h) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TH1F streaming failed"
|
||||
@@ -80,8 +80,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
delete h;
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TH1D_cls()) {
|
||||
tools::histo::h1d* h = tools::rroot::TH1D_stream(b);
|
||||
} else if(a_key.object_class()==TH1D_cls()) {
|
||||
tools::histo::h1d* h = TH1D_stream(b);
|
||||
if(!h) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TH1D streaming failed"
|
||||
@@ -91,8 +91,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
delete h;
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TH2F_cls()) {
|
||||
tools::histo::h2d* h = tools::rroot::TH2F_stream(b);
|
||||
} else if(a_key.object_class()==TH2F_cls()) {
|
||||
tools::histo::h2d* h = TH2F_stream(b);
|
||||
if(!h) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TH2F streaming failed"
|
||||
@@ -102,8 +102,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
delete h;
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TH2D_cls()) {
|
||||
tools::histo::h2d* h = tools::rroot::TH2D_stream(b); //we get ownership of h.
|
||||
} else if(a_key.object_class()==TH2D_cls()) {
|
||||
tools::histo::h2d* h = TH2D_stream(b); //we get ownership of h.
|
||||
if(!h) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TH2D streaming failed"
|
||||
@@ -113,8 +113,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
delete h;
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TH3D_cls()) {
|
||||
tools::histo::h3d* h = tools::rroot::TH3D_stream(b); //we get ownership of h.
|
||||
} else if(a_key.object_class()==TH3D_cls()) {
|
||||
tools::histo::h3d* h = TH3D_stream(b); //we get ownership of h.
|
||||
if(!h) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TH3D streaming failed"
|
||||
@@ -124,8 +124,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
delete h;
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TProfile_cls()) {
|
||||
tools::histo::p1d* p = tools::rroot::TProfile_stream(b);
|
||||
} else if(a_key.object_class()==TProfile_cls()) {
|
||||
tools::histo::p1d* p = TProfile_stream(b);
|
||||
if(!p) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TProfile streaming failed"
|
||||
@@ -135,8 +135,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
delete p;
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TProfile2D_cls()) {
|
||||
tools::histo::p2d* p = tools::rroot::TProfile2D_stream(b);
|
||||
} else if(a_key.object_class()==TProfile2D_cls()) {
|
||||
tools::histo::p2d* p = TProfile2D_stream(b);
|
||||
if(!p) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TProfile2D streaming failed"
|
||||
@@ -148,8 +148,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
|
||||
} else if(a_key.object_class()==TTree_cls()) {
|
||||
|
||||
tools::rroot::fac fac(a_key.file());
|
||||
tools::rroot::tree tree(a_key.file(),fac);
|
||||
fac _fac(a_out);
|
||||
tree tree(a_file,_fac);
|
||||
if(!tree.stream(b)) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TTree streaming failed"
|
||||
@@ -246,7 +246,7 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
#endif
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TDirectory_cls()) {
|
||||
} else if(a_key.object_class()==TDirectory_cls()) {
|
||||
|
||||
//we should not pass here.
|
||||
|
||||
@@ -259,124 +259,152 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
return true;
|
||||
}
|
||||
|
||||
inline tools::histo::h1d* key_to_h1d(tools::rroot::key& a_key){
|
||||
std::ostream& out = a_key.file().out();
|
||||
if((a_key.object_class()!=tools::rroot::TH1D_cls())&&
|
||||
(a_key.object_class()!=tools::rroot::TH1F_cls())
|
||||
inline tools::histo::h1d* key_to_h1d(ifile& a_file,key& a_key){
|
||||
std::ostream& out = a_key.out();
|
||||
if((a_key.object_class()!=TH1D_cls())&&
|
||||
(a_key.object_class()!=TH1F_cls())
|
||||
) {
|
||||
out << "tools::rroot::from(h1d) :"
|
||||
out << "tools::rroot::key_to_h1d :"
|
||||
<< " key not a TH1D and not a TH1F."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::from(h1d) :"
|
||||
out << "tools::rroot::key_to_h1d :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
tools::rroot::buffer b(out,a_key.file().byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
if(a_key.object_class()==tools::rroot::TH1D_cls()) {
|
||||
return tools::rroot::TH1D_stream(b);
|
||||
buffer b(out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
if(a_key.object_class()==TH1D_cls()) {
|
||||
return TH1D_stream(b);
|
||||
} else {
|
||||
return tools::rroot::TH1F_stream(b);
|
||||
return TH1F_stream(b);
|
||||
}
|
||||
}
|
||||
|
||||
inline tools::histo::h2d* key_to_h2d(tools::rroot::key& a_key){
|
||||
std::ostream& out = a_key.file().out();
|
||||
if(a_key.object_class()!=tools::rroot::TH2D_cls()) {
|
||||
out << "tools::rroot::from(h1d) :"
|
||||
inline tools::histo::h2d* key_to_h2d(ifile& a_file,key& a_key){
|
||||
std::ostream& out = a_key.out();
|
||||
if(a_key.object_class()!=TH2D_cls()) {
|
||||
out << "tools::rroot::key_to_h2d :"
|
||||
<< " key not a TH2D."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::from(h2d) :"
|
||||
out << "tools::rroot::key_to_h2d :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
tools::rroot::buffer b(out,a_key.file().byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return tools::rroot::TH2D_stream(b);
|
||||
buffer b(out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return TH2D_stream(b);
|
||||
}
|
||||
|
||||
inline tools::histo::h3d* key_to_h3d(tools::rroot::key& a_key){
|
||||
std::ostream& out = a_key.file().out();
|
||||
if(a_key.object_class()!=tools::rroot::TH3D_cls()) {
|
||||
out << "tools::rroot::from(h1d) :"
|
||||
inline tools::histo::h3d* key_to_h3d(ifile& a_file,key& a_key){
|
||||
std::ostream& out = a_key.out();
|
||||
if(a_key.object_class()!=TH3D_cls()) {
|
||||
out << "tools::rroot::key_to_h3d :"
|
||||
<< " key not a TH3D."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::from(h3d) :"
|
||||
out << "tools::rroot::key_to_h3d :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
tools::rroot::buffer b(out,a_key.file().byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return tools::rroot::TH3D_stream(b);
|
||||
buffer b(out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return TH3D_stream(b);
|
||||
}
|
||||
|
||||
inline tools::histo::p1d* key_to_p1d(tools::rroot::key& a_key){
|
||||
std::ostream& out = a_key.file().out();
|
||||
if(a_key.object_class()!=tools::rroot::TProfile_cls()) {
|
||||
out << "tools::rroot::from(p1d) :"
|
||||
inline tools::histo::p1d* key_to_p1d(ifile& a_file,key& a_key){
|
||||
std::ostream& out = a_key.out();
|
||||
if(a_key.object_class()!=TProfile_cls()) {
|
||||
out << "tools::rroot::key_to_p1d :"
|
||||
<< " key not a TProfile."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::from(p1d) :"
|
||||
out << "tools::rroot::key_to_p1d :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
tools::rroot::buffer b(out,a_key.file().byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return tools::rroot::TProfile_stream(b);
|
||||
buffer b(out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return TProfile_stream(b);
|
||||
}
|
||||
|
||||
inline tools::histo::p2d* key_to_p2d(tools::rroot::key& a_key){
|
||||
std::ostream& out = a_key.file().out();
|
||||
if(a_key.object_class()!=tools::rroot::TProfile2D_cls()) {
|
||||
out << "tools::rroot::from(p2d) :"
|
||||
inline tools::histo::p2d* key_to_p2d(ifile& a_file,key& a_key){
|
||||
std::ostream& out = a_key.out();
|
||||
if(a_key.object_class()!=TProfile2D_cls()) {
|
||||
out << "tools::rroot::key_to_p2d :"
|
||||
<< " key not a TProfile2D."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::from(p2d) :"
|
||||
out << "tools::rroot::key_to_p2d :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
tools::rroot::buffer b(out,a_key.file().byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return tools::rroot::TProfile2D_stream(b);
|
||||
buffer b(out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return TProfile2D_stream(b);
|
||||
}
|
||||
|
||||
inline tree* key_to_tree(ifile& a_file,ifac& a_fac,key& a_key) {
|
||||
std::ostream& out = a_key.out();
|
||||
if(a_key.object_class()!=TTree_cls()) {
|
||||
out << "tools::rroot::key_to_tree :"
|
||||
<< " key not a TTree."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::key_to_tree :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
buffer b(out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
tree* _tree = new tree(a_file,a_fac);
|
||||
if(!_tree->stream(b)) {
|
||||
out << "tools::rroot::key_to_tree :"
|
||||
<< " TTree streaming failed"
|
||||
<< std::endl;
|
||||
delete _tree;
|
||||
return 0;
|
||||
}
|
||||
return _tree;
|
||||
}
|
||||
|
||||
inline void read(std::ostream& a_out,
|
||||
tools::rroot::ifile& a_file,
|
||||
const std::vector<tools::rroot::key*>& a_keys,
|
||||
ifile& a_file,
|
||||
const std::vector<key*>& a_keys,
|
||||
bool a_recursive,
|
||||
bool a_ls,
|
||||
bool a_dump,
|
||||
unsigned int a_spaces) {
|
||||
|
||||
{std::vector<tools::rroot::key*>::const_iterator it;
|
||||
{std::vector<key*>::const_iterator it;
|
||||
for(it=a_keys.begin();it!=a_keys.end();++it) {
|
||||
tools::rroot::key& k = *(*it);
|
||||
if(k.object_class()!=tools::rroot::TDirectory_cls()) {
|
||||
key& k = *(*it);
|
||||
if(k.object_class()!=TDirectory_cls()) {
|
||||
if(a_ls||a_dump) {
|
||||
{for(unsigned int index=0;index<a_spaces;index++) a_out << " ";}
|
||||
std::string label = k.object_name();
|
||||
@@ -385,14 +413,14 @@ inline void read(std::ostream& a_out,
|
||||
<< std::endl;
|
||||
//k.dump(a_out);
|
||||
}
|
||||
if(!read_key(a_out,k,a_dump)) return;
|
||||
if(!read_key(a_out,a_file,k,a_dump)) return;
|
||||
}
|
||||
}}
|
||||
|
||||
{std::vector<tools::rroot::key*>::const_iterator it;
|
||||
{std::vector<key*>::const_iterator it;
|
||||
for(it=a_keys.begin();it!=a_keys.end();++it) {
|
||||
tools::rroot::key& k = *(*it);
|
||||
if(k.object_class()==tools::rroot::TDirectory_cls()) {
|
||||
key& k = *(*it);
|
||||
if(k.object_class()==TDirectory_cls()) {
|
||||
|
||||
if(a_ls||a_dump) {
|
||||
{for(unsigned int index=0;index<a_spaces;index++) a_out << " ";}
|
||||
@@ -403,20 +431,20 @@ inline void read(std::ostream& a_out,
|
||||
if(!a_recursive) continue;
|
||||
|
||||
tools::uint32 sz;
|
||||
char* buf = k.get_object_buffer(sz);
|
||||
char* buf = k.get_object_buffer(a_file,sz);
|
||||
if(!buf) {
|
||||
a_out << "read :"
|
||||
<< " can't get directory data buffer."
|
||||
<< std::endl;
|
||||
} else {
|
||||
tools::rroot::buffer b(a_out,a_file.byte_swap(),sz,buf,k.key_length(),false);
|
||||
tools::rroot::TDirectory dir(a_file);
|
||||
buffer b(a_out,a_file.byte_swap(),sz,buf,k.key_length(),false);
|
||||
TDirectory dir(a_file);
|
||||
if(!dir.stream(b)) {
|
||||
a_out << "read :"
|
||||
<< " can't stream TDirectory."
|
||||
<< std::endl;
|
||||
} else {
|
||||
const std::vector<tools::rroot::key*>& keys = dir.keys();
|
||||
const std::vector<key*>& keys = dir.keys();
|
||||
read(a_out,a_file,keys,a_recursive,a_ls,a_dump,a_spaces+1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
public:
|
||||
bool read(unsigned char& a_x) {
|
||||
if(!_check_eob<unsigned char>(a_x)) return false;
|
||||
a_x = *m_pos++;
|
||||
a_x = *m_pos;m_pos++;
|
||||
return true;
|
||||
}
|
||||
bool read(unsigned short& a_x) {
|
||||
@@ -185,7 +185,7 @@ public:
|
||||
|
||||
bool read(char& a_x) {
|
||||
if(!_check_eob<char>(a_x)) return false;
|
||||
a_x = *m_pos++;
|
||||
a_x = *m_pos;m_pos++;
|
||||
return true;
|
||||
}
|
||||
bool read(short& a_x) {
|
||||
|
||||
@@ -13,9 +13,11 @@
|
||||
namespace tools {
|
||||
namespace rroot {
|
||||
|
||||
typedef tools::int64 seek;
|
||||
typedef int64 seek;
|
||||
typedef int seek32;
|
||||
|
||||
inline uint32 big_file_version_tag() {return 1000;}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -147,12 +147,12 @@ inline bool Axis_stream(buffer& a_buffer,tools::histo::axis<double,unsigned int>
|
||||
std::vector<double> edges;
|
||||
if(!Array_stream<double>(a_buffer,edges)) return false; //fXbins TArrayD
|
||||
|
||||
int edgen = edges.size();
|
||||
if(edgen<=0) {
|
||||
size_t edgen = edges.size();
|
||||
if(!edgen) {
|
||||
a_fAxis.configure(number,min,max);
|
||||
} else {
|
||||
std::vector<double> vedges;
|
||||
for(int index=0;index<edgen;index++) {
|
||||
for(size_t index=0;index<edgen;index++) {
|
||||
vedges.push_back(edges[index]);
|
||||
}
|
||||
a_fAxis.configure(vedges);
|
||||
@@ -227,8 +227,7 @@ inline bool TH_read_1D(buffer& a_buffer,hd_data& a_data,
|
||||
|
||||
if(a_data.m_dimension==2) {
|
||||
if(!Axis_stream(a_buffer,a_data.m_axes[1])) return false; //fYAxis
|
||||
a_data.m_axes[1].m_offset =
|
||||
a_data.m_axes[0].m_offset * (a_data.m_axes[0].bins()+2);
|
||||
a_data.m_axes[1].m_offset = a_data.m_axes[0].m_offset * (a_data.m_axes[0].bins()+2);
|
||||
|
||||
tools::histo::axis<double,unsigned int> dummy;
|
||||
if(!Axis_stream(a_buffer,dummy)) return false; //fZAxis
|
||||
@@ -839,14 +838,10 @@ class TDirectory : public tools::rroot::directory {
|
||||
//public:
|
||||
// static const std::string& store_class() {return TDirectory_cls();}
|
||||
public:
|
||||
TDirectory(ifile& a_file)
|
||||
:tools::rroot::directory(a_file)
|
||||
{}
|
||||
TDirectory(ifile& a_file):tools::rroot::directory(a_file){}
|
||||
virtual ~TDirectory(){}
|
||||
protected:
|
||||
TDirectory(const TDirectory& a_from)
|
||||
:tools::rroot::directory(a_from)
|
||||
{}
|
||||
TDirectory(const TDirectory& a_from):tools::rroot::directory(a_from){}
|
||||
TDirectory& operator=(const TDirectory&){return *this;}
|
||||
public:
|
||||
bool stream(buffer& a_buffer){
|
||||
@@ -860,7 +855,7 @@ public:
|
||||
//m_date_M.setDate(_date);
|
||||
if(!a_buffer.read(m_nbytes_keys)) return false;
|
||||
if(!a_buffer.read(m_nbytes_name)) return false;
|
||||
if(version>1000) {
|
||||
if((uint32)version>big_file_version_tag()) {
|
||||
if(!a_buffer.read(m_seek_directory)) return false;
|
||||
if(!a_buffer.read(m_seek_parent)) return false;
|
||||
if(!a_buffer.read(m_seek_keys)) return false;
|
||||
@@ -877,7 +872,7 @@ public:
|
||||
if(!a_buffer.read(i)) return false;
|
||||
m_seek_keys = i;}
|
||||
}
|
||||
//short v = version%1000;
|
||||
//short v = version%big_file_version_tag();
|
||||
|
||||
if (m_seek_keys) {
|
||||
uint32 n;
|
||||
@@ -935,7 +930,7 @@ inline void dump(std::ostream& a_out,
|
||||
if(!a_recursive) continue;
|
||||
|
||||
uint32 sz;
|
||||
char* buf = k.get_object_buffer(sz);
|
||||
char* buf = k.get_object_buffer(a_file,sz);
|
||||
//we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
a_out << "tools::rroot::dump :"
|
||||
@@ -959,7 +954,7 @@ inline void dump(std::ostream& a_out,
|
||||
|
||||
inline bool read_sinfos(tools::rroot::ifile& a_file){
|
||||
key& k = a_file.sinfos_key();
|
||||
std::ostream& out = k.file().out();
|
||||
std::ostream& out = k.out();
|
||||
if(k.object_class()!=tools::rroot::TList_cls()) {
|
||||
out << "tools::rroot::read_sinfos :"
|
||||
<< " key not a TList."
|
||||
@@ -967,14 +962,14 @@ inline bool read_sinfos(tools::rroot::ifile& a_file){
|
||||
return false;
|
||||
}
|
||||
unsigned int sz;
|
||||
char* buf = k.get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = k.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::read_sinfos :"
|
||||
<< " can't get data buffer of " << k.object_name() << "."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
tools::rroot::buffer b(out,k.file().byte_swap(),sz,buf,k.key_length(),false);
|
||||
tools::rroot::buffer b(out,a_file.byte_swap(),sz,buf,k.key_length(),false);
|
||||
dummy_fac fac(out);
|
||||
List infos(fac,true);
|
||||
if(!infos.stream(b)) return false;
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
//fReadEntry = a_entry;
|
||||
tools_vforit(branch*,m_branches,it) {
|
||||
uint32 n;
|
||||
if(!(*it)->find_entry(a_entry,n)) return false;
|
||||
if(!(*it)->find_entry(m_file,a_entry,n)) return false;
|
||||
nbytes += n;
|
||||
}
|
||||
a_nbytes = nbytes;
|
||||
@@ -81,31 +81,30 @@ public:
|
||||
_dump_branches(a_out,m_branches,a_spaces+a_indent,a_indent);
|
||||
}
|
||||
|
||||
branch* find_branch(const std::string& a_name,
|
||||
bool a_recursive = false) const {
|
||||
branch* find_branch(const std::string& a_name,bool a_recursive = false) const {
|
||||
return _find_branch(m_branches,a_name,a_recursive);
|
||||
}
|
||||
|
||||
std::vector<base_leaf*> find_leaves(){
|
||||
std::vector<base_leaf*> leaves;
|
||||
_find_leaves(m_branches,leaves);
|
||||
return leaves;
|
||||
base_leaf* find_leaf(const std::string& a_name,bool a_recursive = false) const {
|
||||
return _find_leaf(m_branches,a_name,a_recursive);
|
||||
}
|
||||
|
||||
std::vector<branch*> find_branches(){
|
||||
std::vector<branch*> _branches;
|
||||
_find_branches(m_branches,_branches);
|
||||
return _branches;
|
||||
void find_leaves(std::vector<base_leaf*>& a_leaves) const {
|
||||
a_leaves.clear();
|
||||
_find_leaves(m_branches,a_leaves);
|
||||
}
|
||||
|
||||
//branch* find_leaf_branch(base_leaf* a_leaf){
|
||||
// return _find_leaf_branch(m_branches,a_leaf);
|
||||
//}
|
||||
void find_branches(std::vector<branch*>& a_branches) const {
|
||||
a_branches.clear();
|
||||
_find_branches(m_branches,a_branches);
|
||||
}
|
||||
|
||||
branch* find_leaf_branch(const base_leaf& a_leaf) const {return _find_leaf_branch(m_branches,a_leaf);}
|
||||
|
||||
bool show(std::ostream& a_out,uint32 a_entry){
|
||||
a_out << "======> EVENT:" << a_entry << std::endl;
|
||||
tools_vforit(branch*,m_branches,it) {
|
||||
if(!(*it)->show(a_out,a_entry)) return false;
|
||||
if(!(*it)->show(a_out,m_file,a_entry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -288,9 +287,9 @@ public:
|
||||
// the branches in the upper line of code.
|
||||
//::printf("debug : tree : read leaves : begin\n");
|
||||
{ObjArray<base_leaf> m_leaves(m_fac,true);
|
||||
branch b(m_file,m_fac);
|
||||
branch b(m_out,m_fac);
|
||||
ifac::args args;
|
||||
args[ifac::arg_branch()] = &b;
|
||||
//args[ifac::arg_branch()] = &b;
|
||||
if(!m_leaves.stream(a_buffer,args)) {
|
||||
m_out << "tools::rroot::tree::stream : "
|
||||
<< "can't read leaves."
|
||||
@@ -399,9 +398,7 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
branch* _find_branch(const std::vector<branch*>& a_bs,
|
||||
const std::string& a_name,
|
||||
bool a_recursive) const {
|
||||
static branch* _find_branch(const std::vector<branch*>& a_bs,const std::string& a_name,bool a_recursive) {
|
||||
tools_vforcit(branch*,a_bs,it) {
|
||||
if(tools::rcmp((*it)->name(),a_name)) return *it;
|
||||
if(a_recursive) {
|
||||
@@ -412,40 +409,41 @@ protected:
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _find_leaves(const std::vector<branch*>& a_bs,
|
||||
std::vector<base_leaf*>& a_leaves){
|
||||
static base_leaf* _find_leaf(const std::vector<branch*>& a_bs,const std::string& a_name,bool a_recursive) {
|
||||
tools_vforcit(branch*,a_bs,it) {
|
||||
{const std::vector<base_leaf*>& lvs = (*it)->leaves();
|
||||
tools_vforcit(base_leaf*,lvs,itl) {
|
||||
a_leaves.push_back(*itl);
|
||||
}}
|
||||
tools_vforcit(base_leaf*,(*it)->leaves(),itl) {
|
||||
if(tools::rcmp((*itl)->name(),a_name)) return *itl;
|
||||
}
|
||||
if(a_recursive) {
|
||||
base_leaf* lf = _find_leaf((*it)->branches(),a_name,a_recursive);
|
||||
if(lf) return lf;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _find_leaves(const std::vector<branch*>& a_bs,std::vector<base_leaf*>& a_leaves) {
|
||||
tools_vforcit(branch*,a_bs,it) {
|
||||
tools_vforcit(base_leaf*,(*it)->leaves(),itl) a_leaves.push_back(*itl);
|
||||
_find_leaves((*it)->branches(),a_leaves);
|
||||
}
|
||||
}
|
||||
|
||||
void _find_branches(const std::vector<branch*>& a_bs,
|
||||
std::vector<branch*>& a_branches){
|
||||
static void _find_branches(const std::vector<branch*>& a_bs,std::vector<branch*>& a_branches){
|
||||
tools_vforcit(branch*,a_bs,it) {
|
||||
a_branches.push_back(*it);
|
||||
_find_branches((*it)->branches(),a_branches);
|
||||
}
|
||||
}
|
||||
|
||||
//branch* _find_leaf_branch(const std::vector<branch*>& a_bs,
|
||||
// base_leaf* a_leaf){
|
||||
// std::vector<branch*>::const_iterator it;
|
||||
// for(it=a_bs.begin();it!=a_bs.end();++it) {
|
||||
// {const std::vector<base_leaf*>& lvs = (*it)->leaves();
|
||||
// std::vector<base_leaf*>::const_iterator itl;
|
||||
// for(itl=lvs.begin();itl!=lvs.end();++itl) {
|
||||
// if(*itl==a_leaf) return *it;
|
||||
// }}
|
||||
// {branch* br = _find_leaf_branch((*it)->branches(),a_leaf);
|
||||
// if(br) return br;}
|
||||
// }
|
||||
// return 0;
|
||||
//}
|
||||
static branch* _find_leaf_branch(const std::vector<branch*>& a_bs,const base_leaf& a_leaf) {
|
||||
tools_vforcit(branch*,a_bs,itb) {
|
||||
tools_vforcit(base_leaf*,(*itb)->leaves(),itl) {if(*itl==&a_leaf) return *itb;}
|
||||
{branch* br = _find_leaf_branch((*itb)->branches(),a_leaf);
|
||||
if(br) return br;}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
protected:
|
||||
ifile& m_file;
|
||||
ifac& m_fac;
|
||||
|
||||
@@ -24,7 +24,7 @@ inline tree* find_tree(file& a_file,ifac& a_fac,const std::string& a_name) {
|
||||
}
|
||||
|
||||
unsigned int sz;
|
||||
char* buf = key->get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = key->get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::find_tree :"
|
||||
<< " can't get data buffer of "
|
||||
@@ -37,7 +37,7 @@ inline tree* find_tree(file& a_file,ifac& a_fac,const std::string& a_name) {
|
||||
// << " get data buffer size " << sz << "."
|
||||
// << std::endl;
|
||||
|
||||
buffer b(out,key->file().byte_swap(),sz,buf,key->key_length(),false);
|
||||
buffer b(out,a_file.byte_swap(),sz,buf,key->key_length(),false);
|
||||
|
||||
if(key->object_class()!=TTree_cls()) {
|
||||
out << "tools::rroot::find_tree :"
|
||||
@@ -83,11 +83,11 @@ inline branch_element* find_be(tree& a_tree,const std::string& a_name){
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline stl_vector<T>* find_vec(branch_element& a_be,unsigned int a_event){
|
||||
std::ostream& out = a_be.file().out();
|
||||
inline stl_vector<T>* find_vec(ifile& a_file,branch_element& a_be,unsigned int a_event){
|
||||
std::ostream& out = a_file.out();
|
||||
|
||||
unsigned int n;
|
||||
if(!a_be.find_entry(a_event,n)) {
|
||||
if(!a_be.find_entry(a_file,a_event,n)) {
|
||||
out << "tools::rroot::find_vec :"
|
||||
<< " find event failed."
|
||||
<< std::endl;
|
||||
|
||||
Reference in New Issue
Block a user