Import Geant4 11.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2025-12-05 08:54:02 +01:00
parent a499fb82e9
commit b4a16de652
6484 changed files with 232674 additions and 221097 deletions
@@ -14,7 +14,6 @@
namespace tools {
namespace rroot {
//typedef histo::histo_data<double,unsigned int,double> hd_data;
typedef histo::profile_data<double,unsigned int,unsigned int,double,double> pd_data_t;
typedef histo::axis<double,unsigned int> axis_t;
typedef std::map<std::string,std::string> annotations_t;
@@ -602,7 +601,6 @@ inline bool read_annotations(buffer& a_buffer,annotations_t& a_annotations) {
if(!a_buffer.read(value)) return false;
bool sticky;
if(!a_buffer.read(sticky)) return false;
//if(!a_annotations.addItem(key,value,sticky)) return false; //FIXME : handle sticky ?
a_annotations[key] = value;
}
return true;
@@ -639,9 +637,6 @@ inline bool read_THistogram(buffer& a_buffer,pd_data_t& a_data,annotations_t& a_
return false;
}
//data.m_coords.resize(data.m_dimension,0);
//data.m_ints.resize(data.m_dimension,0);
a_data.update_fast_getters();
return true;
-52
View File
@@ -4,10 +4,6 @@
#ifndef tools_rroot_base_leaf
#define tools_rroot_base_leaf
#ifdef TOOLS_MEM
#include "../mem"
#endif
#include "named"
namespace tools {
@@ -69,9 +65,6 @@ public:
return false;
}
if(!obj) {
//m_out << "tools::rroot::base_leaf::stream :"
// << " null leaf count object."
// << std::endl;
} else {
m_leaf_count = safe_cast<iro,base_leaf>(*obj);
if(!m_leaf_count) {
@@ -91,10 +84,6 @@ public:
if(!a_buffer.check_byte_count(_s,_c,"TLeaf")) return false;
if(!m_length) m_length = 1;
/*
fNewValue = false;
if(!setAddress(0)) return false;
*/
return true;
}
public:
@@ -107,34 +96,21 @@ public:
,m_fac(a_fac)
,m_name("")
,m_title("")
//,fIndirectAddress(false)
//,fNewValue(false)
//,m_ndata(0)
,m_length(0)
,m_length_type(0)
//,fOffset(0)
,m_is_range(false)
//,fIsUnsigned(false)
,m_leaf_count(0)
,m_own_leaf_count(false)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~base_leaf(){
if(m_own_leaf_count) delete m_leaf_count;
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
base_leaf(const base_leaf& a_from)
:iro(a_from)
,m_out(a_from.m_out)
,m_fac(a_from.m_fac)
//,m_ndata(0)
,m_length(0)
,m_length_type(0)
,m_is_range(false)
@@ -146,44 +122,16 @@ public:
const std::string& name() const {return m_name;}
const std::string& title() const {return m_title;}
const base_leaf* leaf_count() const {return m_leaf_count;}
/*
uint32 length() const {
// Return the number of effective elements of this leaf.
if(m_leaf_count) {
m_out << "tools::rroot::base_leaf::length :"
<< " m_leaf_count not null. Case not yet handled."
<< std::endl;
return m_length;
//uint32 len = m_leaf_count->number();
//if (len > fLeafCount->maximum()) {
// m_out << "tools::rroot::base_leaf::length :"
// << fName << ", len=" << len << " and max="
// << fLeafCount->maximum()
// << std::endl;
// len = fLeafCount->maximum();
//}
//return len * fLength;
} else {
return m_length;
}
}
*/
protected:
std::ostream& m_out;
ifac& m_fac;
protected: //Named
std::string m_name;
std::string m_title;
//bool fIndirectAddress;
//bool fNewValue;
//uint32 m_ndata; //! Number of elements in fAddress data buffer
uint32 m_length; // Number of fixed length elements
uint32 m_length_type; // Number of bytes for this data type
//int fOffset; // Offset in ClonesArray object (if one)
bool m_is_range; // (=true if leaf has a range, false otherwise)
//bool fIsUnsigned; // (=kTRUE if unsigned, kFALSE otherwise)
base_leaf* m_leaf_count; // Pointer to Leaf count if variable length
bool m_own_leaf_count;
};
-32
View File
@@ -57,20 +57,9 @@ public:
uint16 basket_key_length = a_buffer.length()-startpos;
if(basket_key_length!=m_key_length) {
//m_out << "tools::rroot::basket::stream :"
// << " key length not consistent."
// << " read " << m_key_length
// << ", expected " << basket_key_length
// << ". Continue with " << basket_key_length
// << std::endl;
m_key_length = basket_key_length;
}
if(!m_object_size) {
//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)
// << std::endl;
m_object_size = m_nbytes-m_key_length;
}
@@ -120,13 +109,6 @@ public:
return false;
}
}
/* Due to the upper "G.Barrand if", flag can't be in ]20,40[, then to quiet Coverity we comment the below test.
if((20<flag)&&(flag<40)) {
for(uint32 i=0;i<m_nev;i++){
m_entry_offset[i] &= ~kDisplacementMask();
}
}
*/
if(flag>40) {
m_displacement = new int[m_nev_buf_size];
uint32 n;
@@ -175,8 +157,6 @@ public:
}
m_buffer = _buf;
m_buf_size = fBufferSize;
//fBufferRef->inline_setBufferOffset(m_last);
//fBranch.tree().incrementTotalBuffers(fBufferSize);
}
}
@@ -191,9 +171,6 @@ public:
,m_entry_offset(0)
,m_displacement(0)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
basket(std::ostream& a_out,seek a_pos,uint32 a_nbytes)
:parent(a_out,a_pos,a_nbytes)
@@ -203,15 +180,9 @@ public:
,m_entry_offset(0)
,m_displacement(0)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~basket(){
_clear();
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
public:
basket(const basket& a_from)
@@ -223,9 +194,6 @@ public:
,m_entry_offset(0)
,m_displacement(0)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
if(a_from.m_nev && a_from.m_entry_offset) {
m_entry_offset = new int[a_from.m_nev];
if(!m_entry_offset) {
+6 -145
View File
@@ -21,7 +21,6 @@ namespace tools {
namespace rroot {
class branch : public virtual iro {
//static uint32 kDoNotProcess() {return (1<<10);} // Active bit for branches
public:
static const std::string& s_class() {
static const std::string s_v("tools::rroot::branch");
@@ -43,34 +42,18 @@ public:
virtual iro* copy() const {return new branch(*this);}
virtual bool stream(buffer& a_buffer) {
_clear();
//::printf("debug : branch::stream : begin\n");
int fCompress;
int fBasketSize;
//int fNleaves;
//uint64 m_entries;
//uint64 m_tot_bytes;
//uint64 m_zip_bytes;
int fSplitLevel;
uint32 fMaxBaskets;
int fOffset;
unsigned int _s,_c;
//FIXME gROOT->SetReadingObject(kTRUE);
short vers;
if(!a_buffer.read_version(vers,_s,_c)) return false;
//::printf("debug : branch::stream : version %d count %d\n",vers,c);
if (vers > 5) {
//TBranch::Class()->ReadBuffer(b, this, v, s, c);
//gBranch = branchSave;
//fDirectory = gDirectory;
//fNleaves = m_leaves.GetEntriesFast();
//if (fFileName.Length() != 0) fDirectory = 0;
//gROOT->SetReadingObject(kFALSE);
//return;
}
//====process old versions before automatic schema evolution
@@ -82,7 +65,6 @@ public:
if(!Named_stream(a_buffer,m_name,m_title)) return false;
//::printf("debug : branch::stream %s %s\n",m_name.c_str(),m_title.c_str());
if(vers<=5) {
if(!a_buffer.read(fCompress)) return false;
@@ -93,15 +75,12 @@ public:
if(!a_buffer.read(m_entry_number)) return false;
{double v;
if(!a_buffer.read(v)) return false;
//m_entries = uint64(v);
}
{double v;
if(!a_buffer.read(v)) return false;
//m_tot_bytes = uint64(v);
}
{double v;
if(!a_buffer.read(v)) return false;
//m_zip_bytes = uint64(v);
}
if(!a_buffer.read(fOffset)) return false;
@@ -115,15 +94,12 @@ public:
if(!a_buffer.read(fMaxBaskets)) return false;
{double v;
if(!a_buffer.read(v)) return false;
//m_entries = uint64(v);
}
{double v;
if(!a_buffer.read(v)) return false;
//m_tot_bytes = uint64(v);
}
{double v;
if(!a_buffer.read(v)) return false;
//m_zip_bytes = uint64(v);
}
} else if(vers<=7) {
@@ -137,15 +113,12 @@ public:
if(!a_buffer.read(fSplitLevel)) return false;
{double v;
if(!a_buffer.read(v)) return false;
//m_entries = uint64(v);
}
{double v;
if(!a_buffer.read(v)) return false;
//m_tot_bytes = uint64(v);
}
{double v;
if(!a_buffer.read(v)) return false;
//m_zip_bytes = uint64(v);
}
} else if(vers<=9) {
@@ -161,15 +134,12 @@ public:
if(!a_buffer.read(fSplitLevel)) return false;
{double v;
if(!a_buffer.read(v)) return false;
//m_entries = uint64(v);
}
{double v;
if(!a_buffer.read(v)) return false;
//m_tot_bytes = uint64(v);
}
{double v;
if(!a_buffer.read(v)) return false;
//m_zip_bytes = uint64(v);
}
} else if(vers<=10) {
@@ -189,15 +159,12 @@ public:
{uint64 v;
if(!a_buffer.read(v)) return false;
//m_entries = v;
}
{uint64 v;
if(!a_buffer.read(v)) return false;
//m_tot_bytes = v;
}
{uint64 v;
if(!a_buffer.read(v)) return false;
//m_zip_bytes = v;
}
} else { //vers>=11
@@ -224,24 +191,18 @@ public:
if(!a_buffer.read(fSplitLevel)) return false;
{uint64 v;
if(!a_buffer.read(v)) return false;
//m_entries = v;
}
{uint64 v;
if(!a_buffer.read(v)) return false;} //fFirstEntry
{uint64 v;
if(!a_buffer.read(v)) return false;
//m_tot_bytes = v;
}
{uint64 v;
if(!a_buffer.read(v)) return false;
//m_zip_bytes = v;
}
}
//::printf("debug : branch::stream : %s : fSplitLevel %d\n",m_name.c_str(),fSplitLevel);
//TObjArray
//::printf("debug : branch::stream : branches : begin\n");
{ifac::args args;
if(!m_branches.stream(a_buffer,args)) {
m_out << "tools::rroot::branch::stream :"
@@ -249,36 +210,18 @@ public:
<< std::endl;
return false;
}}
//::printf("debug : branch::stream : branches : end %d\n",
// m_branches.size());
/* We see that with LHCb files.
if(m_entry_number!=m_entries) {
m_out << "tools::rroot::branch::stream :"
<< " for branch " << sout(m_name) << " :"
<< " WARNING : m_entry_number!=m_entries."
<< " m_entry_number " << m_entry_number
<< " m_entries " << m_entries
<< std::endl;
//return false;
}
*/
//TObjArray
//::printf("debug : branch::stream : leaves : begin\n");
{ifac::args args;
//args[ifac::arg_branch()] = this;
if(!m_leaves.stream(a_buffer,args)) {
m_out << "tools::rroot::branch::stream :"
<< " can't read leaves."
<< std::endl;
return false;
}}
//::printf("debug : branch::stream : leaves : end\n");
//TObjArray
//IMPORTANT : accept_null=true
//::printf("debug : branch::stream : streamed_baskets : begin\n");
{ifac::args args;
if(!m_streamed_baskets.stream(a_buffer,args,true)) {
m_out << "tools::rroot::branch::stream :"
@@ -286,9 +229,6 @@ public:
<< std::endl;
return false;
}}
//::printf("debug : branch::stream : streamed_baskets : end\n");
//fNleaves = m_leaves.size();
if(fMaxBaskets<=0) {
m_out << "tools::rroot::branch::stream :"
@@ -322,10 +262,6 @@ public:
}
}
if(vers<2) {
//GB : comment.
//for(int i=0;i<m_write_basket;i++) {
// fBasketSeek[i] = getBasket(i)->seekKey();
//}
m_out << "tools::rroot::branch::stream :"
<< " v < 2. Not (yet) handled."
<< std::endl;
@@ -349,8 +285,6 @@ public:
} else if(vers<=9) {
// See TStreamerInfo::ReadBuffer::ReadBasicPointer
//Int_t[fMaxBaskets]
{char isArray;
if(!a_buffer.read(isArray)) {
_clear();
@@ -363,7 +297,6 @@ public:
}
}}
//Int_t[fMaxBaskets]
{char isArray;
if(!a_buffer.read(isArray)) {
_clear();
@@ -376,7 +309,6 @@ public:
}
}}
//Seek_t[fMaxBaskets]
{char isBigFile;
if(!a_buffer.read(isBigFile)) {
_clear();
@@ -400,8 +332,6 @@ public:
} else { //vers>=10
// See TStreamerInfo::ReadBuffer::ReadBasicPointer
//Int_t[fMaxBaskets]
{char isArray;
if(!a_buffer.read(isArray)) {
_clear();
@@ -414,7 +344,6 @@ public:
}
}}
//Long64_t[fMaxBaskets]
{char isArray;
if(!a_buffer.read(isArray)) {
_clear();
@@ -430,7 +359,6 @@ public:
delete [] v;
}}
//Long64_t[fMaxBaskets]
{char isArray;
if(!a_buffer.read(isArray)) {
_clear();
@@ -485,7 +413,7 @@ public:
for(uint32 i=0;i<fMaxBaskets;i++) {
if(!fBasketSeek[i]) continue;
num++;
mxi = mx<uint32>(i,mxi);
mxi = max_of<uint32>(i,mxi);
}
if(m_write_basket) {
if((num!=m_write_basket)||(mxi!=(m_write_basket-1))) {
@@ -538,15 +466,7 @@ public:
// 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;
//if(_test_bit(kDoNotProcess())) return true;
//if(fReadEntry == (int)a_entry) return true;
if(a_entry>=m_entry_number) {
//m_out << "tools::rroot::branch::find_entry :"
// << " for branch " << sout(m_name) << " :"
// << " a_entry not within [0," << m_entry_number << "[."
// << std::endl;
//return false;
return true; //CERN-ROOT does not consider it is an error.
}
if(!m_entry_number || m_first_last.empty() ) { //GB
@@ -583,8 +503,7 @@ public:
}
if(!found) {
uint32 count = 0;
typedef std::pair<uint64,uint64> first_last;
tools_vforcit(first_last,m_first_last,it) {
for(auto it = m_first_last.cbegin(); it != m_first_last.cend(); ++it) {
first = (*it).first;
last = (*it).second;
if((a_entry>=first)&&(a_entry<=last)) {
@@ -609,7 +528,6 @@ public:
basket* bsk = (*it).second.first;
m_baskets.erase(it);
delete bsk;
//::printf("debug : erase basket %d\n",old_read_basket);
}
}
}
@@ -652,21 +570,12 @@ public:
<< std::endl;
return false;
}
//m_out << "tools::rroot::branch::find_entry :"
// << " got basket " << m_read_basket
// << " of size " << fBasketBytes[m_read_basket]
// << std::endl;
m_baskets[m_read_basket] = std::pair<basket*,bool>(bsk,true);
}
m__read_basket = bsk;
}
// Set entry offset in buffer and read data from all leaves
//buf->resetMap();
uint32 bufbegin;
{int* entry_offset = m__read_basket->entry_offset();
if(entry_offset) {
@@ -679,7 +588,6 @@ public:
return false;
}
bufbegin = entry_offset[index];
//::printf("debug : xxx++ %u : %u\n",index,bufbegin);
} else {
bufbegin = (uint32)(m__read_basket->key_length() + (a_entry-first)*m__read_basket->nev_buf_size());
}}
@@ -689,30 +597,9 @@ public:
m_out << "tools::rroot::branch::find_entry :"
<< " not null displacement. Not yet handled."
<< std::endl;
//buf->setDisplacement(displacement[a_entry-first]);
} else {
//buf->setDisplacement();
}}
/*
if(bufbegin>=m__read_basket->buf_size()) {
m_out << "tools::rroot::branch::find_entry :"
<< " bad buffer access for entry " << a_entry
<< ". bufbegin " << bufbegin
<< ", buf_size " << basket->buf_size()
<< ", (entry-first) " << (a_entry-first)
<< std::endl;
{int* entry_offset = m__read_basket->entry_offset();
if(entry_offset) {
uint32 nev = m__read_basket->nev();
::printf("debug : eoff : num %d\n",nev);
for(uint32 i=0;i<nev;i++){
::printf("debug : eoff %d : %d\n",i,entry_offset[i]);
}
}}
return false;
}
*/
buffer _buffer(m_out,a_file.byte_swap(),m__read_basket->buf_size(),m__read_basket->buf(),0,false);
_buffer.set_offset(bufbegin);
@@ -729,8 +616,6 @@ public:
return false;
}
//fReadEntry = a_entry;
a_nbytes = _buffer.length() - bufbegin;
return true;
@@ -746,7 +631,7 @@ public:
base_leaf* bl = *it;
uint32 num = bl->num_elem();
num = mn<uint32>(num,10);
num = min_of<uint32>(num,10);
if(!num) continue;
{std::string _s;
@@ -788,15 +673,9 @@ public:
,fBasketEntry(0)
,fBasketSeek(0)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~branch(){
_clear();
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
branch(const branch& a_from)
@@ -824,7 +703,6 @@ public:
const std::vector<branch*>& branches() const {return m_branches;}
protected:
basket* get_basket(ifile& a_file,seek a_pos,uint32 a_len) {
//if(fBranch.tree().memoryFull(fBufferSize)) fBranch.dropBaskets();
if(!a_len) return 0;
basket* _basket = new basket(m_out,a_pos,a_len); //basket is a key.
@@ -861,14 +739,7 @@ protected:
<< std::endl;
delete _basket;
return 0;
}
//if(_basket->nbytes()!=a_len) { //consistency check.
// m_out << "tools::rroot::branch::get_basket :"
// << " WARNING : length anomaly."
// << " a_len " << a_len
// << " nbytes() " << _basket->nbytes()
// << std::endl;
//}
}
if(fEntryOffsetLen) {
if(!_basket->read_offset_tables(a_file.byte_swap())) {
@@ -890,8 +761,7 @@ protected:
fBasketBytes = 0;
fBasketSeek = 0;
{typedef std::pair<basket*,bool> basket_todel;
tools_mforit(uint32,basket_todel,m_baskets,it) {
{for(auto it = m_baskets.begin(); it != m_baskets.end(); ++it) {
if((*it).second.second) delete (*it).second.first;
}
m_baskets.clear();}
@@ -905,8 +775,7 @@ protected:
m_out << "tools::rroot::branch::_dump_first_last :"
<< " first_last " << m_first_last.size()
<< std::endl;
typedef std::pair<uint64,uint64> first_last;
tools_vforcit(first_last,m_first_last,it) {
for(auto it = m_first_last.cbegin(); it != m_first_last.cend(); ++it) {
uint64 first = (*it).first;
uint64 last = (*it).second;
m_out << "tools::rroot::branch::stream :"
@@ -916,11 +785,6 @@ protected:
}
}
//bool _test_bit(uint32 a_f) const {
// return (bool)(m_bits & a_f);
//}
protected:
std::ostream& m_out;
ifac& m_fac;
@@ -929,9 +793,6 @@ protected:
obj_array<basket> m_streamed_baskets;
basket* m__read_basket; //optimization
protected:
//Object
//uint32 m_bits;
//Named
std::string m_name;
std::string m_title;
+6 -325
View File
@@ -10,7 +10,6 @@
#include "info"
#include "obj_list"
//#define TOOLS_RROOT_BRANCH_ELEMENT_DUMP
namespace tools {
namespace rroot {
@@ -42,8 +41,6 @@ public:
unsigned int _s,_c;
if(!a_buffer.read_version(v,_s,_c)) return false;
//::printf("debug : tools::branch_element::stream : version %d, count %d\n",v,c);
if(!parent::stream(a_buffer)) {
m_out << "tools::rroot::branch_element::stream : parent::stream() failed." << std::endl;
return false;
@@ -57,36 +54,26 @@ public:
if(!a_buffer.read(fStreamerType)) return false;
} else { //v>=8
if(!a_buffer.read(fClassName)) return false;
//::printf("debug : tools::branch_element::stream : fClassName \"%s\"\n",fClassName.c_str());
std::string fParentName;
if(!a_buffer.read(fParentName)) return false;
//::printf("debug : tools::branch_element::stream : fParentName \"%s\"\n",fParentName.c_str());
std::string fCloneName;
if(!a_buffer.read(fCloneName)) return false;
//::printf("debug : tools::branch_element::stream : fCloneName \"%s\"\n",fCloneName.c_str());
int dummy_int;
if(!a_buffer.read(dummy_int)) return false; //fCheckSum
//::printf("debug : tools::branch_element::stream : fCheckSum %d\n",dummy_int);
if(v>=10) {
short dummy_short;
if(!a_buffer.read(dummy_short)) return false; //fClassVersion
//::printf("debug : tools::branch_element::stream : fClassVersion %d\n",dummy_short);
} else {
if(!a_buffer.read(dummy_int)) return false; //fClassVersion
}
if(!a_buffer.read(fID)) return false;
//::printf("debug : tools::branch_element::stream : fID %d\n",fID);
if(!a_buffer.read(fType)) return false;
//::printf("debug : tools::branch_element::stream : fType %d\n",fType);
if(!a_buffer.read(fStreamerType)) return false;
//::printf("debug : tools::branch_element::stream : fStreamerType %d\n",fStreamerType);
if(!a_buffer.read(dummy_int)) return false; //fMaximum
//::printf("debug : tools::branch_element::stream : fMaximum %d\n",dummy_int);
//TBranchElement* fBranchCount;
ifac::args args;
if(!pointer_stream(a_buffer,m_fac,args,fBranchCount,fBranchCount_created)) {
m_out << "tools::rroot::branch_element::stream : "
@@ -95,7 +82,6 @@ public:
return false;
}
//TBranchElement* fBranchCount2;
if(!pointer_stream(a_buffer,m_fac,args,fBranchCount2,fBranchCount2_created)) {
m_out << "tools::rroot::branch_element::stream : "
<< "can't read fBranchCount2."
@@ -126,37 +112,14 @@ public: //branch
//from v4-00-01
int n;
if(!a_buffer.read(n)) return false;
/* ROOT-6.12.06 code :
if ((n < 0) || (n > fMaximum)) {
if (IsMissingCollection()) {
n = 0;
b.SetBufferOffset(b.Length() - sizeof(n));
} else {
Error("ReadLeaves", "Incorrect size read for the container in %s\nThe size read is %d when the maximum is %d\nThe size is reset to 0 for this entry (%lld)", GetName(), n, fMaximum, GetReadEntry());
n = 0;
}
}*/
//::printf("debug : uuuu : ndata %d\n",n);
fNdata = n;
//TClonesArray *clones = (TClonesArray*)fObject;
//if (!clones) return;
//if (clones->IsZombie()) return;
//clones->Clear();
//clones->ExpandCreateFast(fNdata);
//m_out << "debug : tools::rroot::branch_element::read_leaves :"
// << " name " << m_name << " ref_cls " << fClassName
// << " : type " << fType << ", fNdata " << n
// << std::endl;
return true;
} else if(fType==31) { // TClonesArray sub-branch (contains the elements).
if(fStreamerType==kObject) { //to read EsbRoot fgd_dig.root.
int ndata = fBranchCount->get_ndata();
#ifdef TOOLS_RROOT_BRANCH_ELEMENT_DUMP
::printf("debug : %s : fClassName %s : fID %d : kObject : ndata %d\n",m_name.c_str(),fClassName.c_str(),fID,ndata);
#endif
streamer_info* _info = a_file.find_streamer_info(fClassName);
if(!_info) {
m_out << "tools::rroot::branch_element::read_leaves : " << sout(m_name) << " :"
@@ -171,7 +134,6 @@ public: //branch
<< std::endl;
return false;
}
//::printf("debug : element type name %s\n",_element->type_name().c_str());
obj_list* _list = 0;
if(!m_obj) {
@@ -209,9 +171,6 @@ public: //branch
//from v4-00-01
if(fStreamerType==kDouble32) {
int ndata = fBranchCount->get_ndata();
#ifdef TOOLS_RROOT_BRANCH_ELEMENT_DUMP
::printf("debug : %s : fID %d : double32 : ndata %d\n",m_name.c_str(),fID,ndata);
#endif
stl_vector<double>* vec = 0;
if(!m_obj) {
vec = new stl_vector<double>;
@@ -236,7 +195,6 @@ public: //branch
vec->clear();
return false;
}
//::printf("debug : zzzz %g\n",afloat);
(*vec)[ii] = afloat;
}
@@ -244,9 +202,6 @@ public: //branch
} else if(fStreamerType==kDouble) {
int ndata = fBranchCount->get_ndata();
#ifdef TOOLS_RROOT_BRANCH_ELEMENT_DUMP
::printf("debug : %s : fID %d : double : ndata %d\n",m_name.c_str(),fID,ndata);
#endif
stl_vector<double>* vec = 0;
if(!m_obj) {
vec = new stl_vector<double>;
@@ -262,7 +217,7 @@ public: //branch
}
vec->resize(ndata);
double* _value = vec_data(*vec);
double* _value = vec->data();
if(!a_buffer.read_fast_array(_value,ndata)) {
m_out << "tools::rroot::branch_element::read_leaves : " << sout(m_name) << " :"
<< " read_fast_array(double) failed."
@@ -275,9 +230,6 @@ public: //branch
} else if(fStreamerType==kInt) {
int ndata = fBranchCount->get_ndata();
#ifdef TOOLS_RROOT_BRANCH_ELEMENT_DUMP
::printf("debug : %s : fID %d : int : ndata %d\n",m_name.c_str(),fID,ndata);
#endif
stl_vector<int>* vec = 0;
if(!m_obj) {
vec = new stl_vector<int>;
@@ -293,7 +245,7 @@ public: //branch
}
vec->resize(ndata);
int* _value = vec_data(*vec);
int* _value = vec->data();
if(!a_buffer.read_fast_array(_value,ndata)) {
m_out << "tools::rroot::branch_element::read_leaves : " << sout(m_name) << " :"
<< " read_fast_array(int) failed."
@@ -306,10 +258,6 @@ public: //branch
} else if((fStreamerType==kUInt)||(fStreamerType==kBits)) {
int ndata = fBranchCount->get_ndata();
#ifdef TOOLS_RROOT_BRANCH_ELEMENT_DUMP
if(fStreamerType==kUInt) ::printf("debug : %s : fID %d : uint : ndata %d\n",m_name.c_str(),fID,ndata);
else ::printf("debug : %s : fID %d : bits : ndata %d\n",m_name.c_str(),fID,ndata);
#endif
stl_vector<uint32>* vec = 0;
if(!m_obj) {
vec = new stl_vector<uint32>;
@@ -325,7 +273,7 @@ public: //branch
}
vec->resize(ndata);
uint32* _value = vec_data(*vec);
uint32* _value = vec->data();
if(!a_buffer.read_fast_array(_value,ndata)) {
m_out << "tools::rroot::branch_element::read_leaves : " << sout(m_name) << " :"
<< " read_fast_array(uint) failed."
@@ -343,37 +291,15 @@ public: //branch
<< std::endl;
return false;
}
/*
//m_obj = clones_array<float>(m_fac,true,false); //true = owner of objects.
uint32 ndata = 1;
float* _value = new float[ndata];
if(!a_buffer.read_fast_array(_value,ndata)) {
m_out << "tools::rroot::branch_element::read_leaves : \"" << name() << "\" :"
<< " read_fast_array failed."
<< std::endl;
return false;
}
*/
//} else if(fType<=2) { //in v5-18-00d
} else if(fType==0) { // to read wroot.root of examples/cpp/wroot.cpp.
// if(fID>=0) {
// // branch in split mode
// m_out << "tools::rroot::branch_element::read_leaves :"
// << " name " << m_name << " ref_cls " << fClassName << " :"
// << " type 0 with ID " << fID << "."
// << std::endl;
// return true;
//
if((fID==-1)||
(fID==1) // for pmx to read LHCb files :
){
//from v4-00-01
//if (fBranchCount) fNdata = (Int_t)fBranchCount->GetValue(0,0);
//else fNdata = 1;
if(fBranchCount) {
fNdata = fBranchCount->get_ndata();
//::printf("debug : branch_element::read_leaves : (fType==0,fID==-1) : fNdata %d\n",fNdata);
} else {
fNdata = 1;
}
@@ -413,174 +339,6 @@ public: //branch
<< " : type " << fType << " not treated, stream_type is " << fStreamerType << "."
<< std::endl;
return false;
/*
///////////////////////////////////////////////////////
/// STL container /////////////////////////////////////
///////////////////////////////////////////////////////
if(fType==4) {
// STL container master branch (has only the number of elements).
//from v4-00-01
int n;
if(!a_buffer.read(n)) return false;
//fNdata = n;
m_out << "tools::rroot::branch_element::read_leaves :"
<< " name " << m_name << " ref_cls " << fClassName
<< " : type " << fType << " not treated."
<< std::endl;
return false;
} else if(fType==41) {
// STL container sub-branch (contains the elements).
m_out << "tools::rroot::branch_element::read_leaves :"
<< " name " << m_name << " ref_cls " << fClassName
<< " : type " << fType << " not treated."
<< std::endl;
return false;
///////////////////////////////////////////////////////
/// TClonesArray container ////////////////////////////
///////////////////////////////////////////////////////
} else if(fType==3) {
// TClonesArray master branch (has only the number of elements).
//from v4-00-01
int n;
if(!a_buffer.read(n)) return false;
//fNdata = n;
//TClonesArray *clones = (TClonesArray*)fObject;
//if (!clones) return;
//if (clones->IsZombie()) return;
//clones->Clear();
//clones->ExpandCreateFast(fNdata);
m_out << "tools::rroot::branch_element::read_leaves :"
<< " name " << m_name << " ref_cls " << fClassName
<< " : type " << fType << " not treated."
<< std::endl;
return false;
} else if(fType==31) {
// TClonesArray sub-branch (contains the elements).
m_out << "tools::rroot::branch_element::read_leaves :"
<< " name " << m_name << " ref_cls " << fClassName
<< " : type " << fType << " not treated."
<< std::endl;
return false;
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
} else if(fType<=2) {
// branch in split mode
//from v4-00-01
//if (fBranchCount) fNdata = (Int_t)fBranchCount->GetValue(0,0);
//else fNdata = 1;
//if (!fInfo) return;
//fInfo->ReadBuffer(b,fObject,fID);
//if (fStreamerType == 6) fNdata = (Int_t)GetValue(0,0);
//from 3.0.06
//if (fID >= 0) {
// fInfo->ReadBuffer(b,fAddress,fID);
//} else if (fID == -1) { // top level branch in non split mode
// char **ppointer = (char**)fAddress;
// fInfo->ReadBuffer(b,*ppointer,fID);
//}
//m_out << "tools::rroot::branch_element::read_leaves :"
// << " name " << m_name << " ref_cls " << fClassName << " :"
// << " type " << fType << " with ID " << fID << "."
// << " and then ?"
// << std::endl;
// read object ?
bool created = false;
if(!m_obj) {
ifac::args args;
m_obj = m_fac.create(fClassName,args);
if(!m_obj) return false;
created = true;
}
if(!m_obj->stream(a_buffer)){
m_out << "tools::rroot::branch_element::read_leaves :"
<< " name " << m_name << " ref_cls " << fClassName << " :"
<< " obj stream failed."
<< std::endl;
if(created) {delete m_obj;m_obj = 0;}
return false;
}
//m_out << "tools::rroot::branch_element::read_leaves :"
// << " name " << m_name << " ref_cls " << fClassName << " :"
// << " obj streamed."
// << std::endl;
return true;
// } else if(fType==0) {
// if(fID>=0) {
// // branch in split mode
// m_out << "tools::rroot::branch_element::read_leaves :"
// << " name " << m_name << " ref_cls " << fClassName << " :"
// << " type 0 with ID " << fID << "."
// << std::endl;
// return true;
//
// } else if(fID==-1) {
// // top level branch in non split mode
// m_out << "tools::rroot::branch_element::read_leaves :"
// << " name " << m_name << " ref_cls " << fClassName << " :"
// << " type 0 with ID " << fID
// << " : fill object."
// << std::endl;
// if(!m_obj) {
// m_out << "tools::rroot::branch_element::read_leaves :"
// << " name " << m_name << " ref_cls " << fClassName << " :"
// << " m_obj is null."
// << std::endl;
// return false;
// }
// if(!m_obj->stream(a_buffer)){
// m_out << "tools::rroot::branch_element::read_leaves :"
// << " name " << m_name << " ref_cls " << fClassName << " :"
// << " obj stream failed."
// << std::endl;
// return false;
// }
// return true;
// } else {
// m_out << "tools::rroot::branch_element::read_leaves :"
// << " name " << m_name << " ref_cls " << fClassName << " :"
// << " type 0 with ID " << fID << " not treated."
// << std::endl;
// return false;
// }
// //LHCb files :
// } else if(fType==1) {
// // parent branch is a base class branch.
// // Ok, and then ?
// m_out << "tools::rroot::branch_element::read_leaves :"
// << " name " << m_name << " ref_cls " << fClassName << " :"
// << " type " << fType << " with ID " << fID << "."
// << std::endl;
// return true;
} else {
m_out << "tools::rroot::branch_element::read_leaves :"
<< " name " << m_name << " ref_cls " << fClassName << " :"
<< " type " << fType << " with ID " << fID << "."
<< " unknown case."
<< std::endl;
return false;
}
*/
}
virtual bool find_entry(ifile& a_file,uint64 a_entry,uint32& a_nbytes){
@@ -588,11 +346,6 @@ public: //branch
if(!parent::find_entry(a_file,a_entry,a_nbytes)) return false;
if(m_branches.size()) {
//if(!m_obj) {
// m_obj = m_fac.create(fClassName);
// if(!m_obj) return false;
//}
tools_vforcit(branch*,m_branches,it) {
uint32 n;
if(!(*it)->find_entry(a_file,a_entry,n)) return false;
@@ -615,7 +368,6 @@ public: //branch
a_out << m_obj << std::endl;
return true;
//return parent::show(a_out,a_file,a_entry);
}
public:
branch_element(std::ostream& a_out,ifac& a_fac)
@@ -721,76 +473,5 @@ protected:
}}
#ifdef TOOLS_RROOT_BRANCH_ELEMENT_DUMP
#undef TOOLS_RROOT_BRANCH_ELEMENT_DUMP
#endif
#endif
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
/* In v4-00-01 version 8 :
case 1: {b.ReadFastArray((Char_t*) fAddress, n); break;}
case 2: {b.ReadFastArray((Short_t*) fAddress, n); break;}
case 3: {b.ReadFastArray((Int_t*) fAddress, n); break;}
case 4: {b.ReadFastArray((Long_t*) fAddress, n); break;}
case 5: {b.ReadFastArray((Float_t*) fAddress, n); break;}
case 6: {b.ReadFastArray((Int_t*) fAddress, n); break;}
case 8: {b.ReadFastArray((Double_t*)fAddress, n); break;}
case 11: {b.ReadFastArray((UChar_t*) fAddress, n); break;}
case 12: {b.ReadFastArray((UShort_t*)fAddress, n); break;}
case 13: {b.ReadFastArray((UInt_t*) fAddress, n); break;}
case 14: {b.ReadFastArray((ULong_t*) fAddress, n); break;}
case 15: {b.ReadFastArray((Long64_t*)fAddress, n); break;}
case 16: {b.ReadFastArray((ULong64_t*)fAddress, n); break;}
case 9: {Double_t *xx = (Double_t*)fAddress;
Float_t afloat;
for (Int_t ii=0;ii<n;ii++) {
b>> afloat; xx[ii] = Double_t(afloat);
} break;}
*/
/* 6.12.06 version 10 : fStreamerType : from meta/inc/TVirtualStreamerInfo.h :
enum EReadWrite {
kBase = 0, kOffsetL = 20, kOffsetP = 40, kCounter = 6, kCharStar = 7,
kChar = 1, kShort = 2, kInt = 3, kLong = 4, kFloat = 5,
kDouble = 8, kDouble32= 9,
kUChar = 11, kUShort = 12, kUInt = 13, kULong = 14, kBits = 15,
kLong64 = 16, kULong64 = 17, kBool = 18, kFloat16 = 19,
kObject = 61, kAny = 62, kObjectp = 63, kObjectP = 64, kTString = 65,
kTObject = 66, kTNamed = 67, kAnyp = 68, kAnyP = 69, kAnyPnoVT = 70,
kSTLp = 71,
kSkip = 100, kSkipL = 120, kSkipP = 140,
kConv = 200, kConvL = 220, kConvP = 240,
kSTL = ROOT::kSTLany, // 300
kSTLstring = ROOT::kSTLstring, // 365
kStreamer = 500, kStreamLoop = 501,
kCache = 600, // Cache the value in memory than is not part of the object but is accessible via a SchemaRule
kArtificial = 1000,
kCacheNew = 1001,
kCacheDelete = 1002,
kNeedObjectForVirtualBaseClass = 99997,
kMissing = 99999
};
// Some comments about EReadWrite
// kBase : base class element
// kOffsetL : fixed size array
// kOffsetP : pointer to object
// kCounter : counter for array size
// kCharStar: pointer to array of char
// kBits : TObject::fBits in case of a referenced object
// kObject : Class derived from TObject
// kObjectp : Class* derived from TObject and with comment field //->Class
// kObjectP : Class* derived from TObject and with NO comment field //->Class
// kAny : Class not derived from TObject
// kAnyp : Class* not derived from TObject with comment field //->Class
// kAnyP : Class* not derived from TObject with NO comment field //->Class
// kAnyPnoVT: Class* not derived from TObject with NO comment field //->Class and Class has NO virtual table
// kSTLp : Pointer to STL container.
// kTString : TString, special case
// kTObject : TObject, special case
// kTNamed : TNamed , special case
*/
@@ -42,12 +42,10 @@ public: //branch
public:
branch_object(std::ostream& a_out,ifac& a_fac)
:parent(a_out,a_fac)
//,m_obj(0)
,fClassName()
{}
virtual ~branch_object(){
//delete m_obj;
}
protected:
branch_object(const branch_object& a_from)
@@ -55,9 +53,6 @@ protected:
branch_object& operator=(const branch_object&){return *this;}
public:
const std::string& class_name() const {return fClassName;}
// iro* object() {return m_obj;}
protected:
// iro* m_obj;
protected:
std::string fClassName; //Class name of referenced object
};
-150
View File
@@ -9,34 +9,12 @@
#include "iro"
#include "../sout"
#include "../mapmanip"
#ifdef TOOLS_MEM
#include "../mem"
#endif
#include <string>
#include <vector>
#include <ostream>
#include <utility>
// in TOOLS_STL, we don't have (yet) a performant map.
#ifdef tools_stl_vector
#define TOOLS_RROOT_OBJ_MAP_HASH_TABLE
//#define TOOLS_RROOT_OBJ_MAP_OMAP
#else
#define TOOLS_RROOT_OBJ_MAP_STD_MAP
#endif
#ifdef TOOLS_RROOT_OBJ_MAP_STD_MAP
#include <map>
#endif
#ifdef TOOLS_RROOT_OBJ_MAP_OMAP
#include "../omap"
#endif
#ifdef TOOLS_RROOT_OBJ_MAP_HASH_TABLE
#include "../hash_table"
#include "../hash"
#endif
namespace tools {
namespace rroot {
@@ -49,56 +27,22 @@ class buffer : public rbuf {
return s_v;
}
#ifdef TOOLS_RROOT_OBJ_MAP_STD_MAP
typedef std::map<uint32,iro*> obj_map;
#endif
#ifdef TOOLS_RROOT_OBJ_MAP_OMAP
typedef omap<uint32,iro*> obj_map;
#endif
#ifdef TOOLS_RROOT_OBJ_MAP_HASH_TABLE
class obj_map : public hash_table<uint32,iro*> {
typedef hash_table<uint32,iro*> parent;
protected:
virtual unsigned int hash(const uint32& a_key) {
return hash(&a_key,sizeof(uint32));
}
virtual bool cmp(const uint32& a_key1,const uint32& a_key2) {
return a_key1==a_key2?true:false;
}
public:
obj_map():parent(){}
virtual ~obj_map(){}
private:
obj_map(const obj_map& a_from):parent(a_from){}
obj_map& operator=(const obj_map& a_from){
parent::operator=(a_from);
return *this;
}
};
#endif
public:
buffer(std::ostream& a_out,bool a_byte_swap,uint32 a_size,char* a_buffer,uint32 a_klen,bool a_verbose)
:parent(a_out,a_byte_swap,a_buffer+a_size,m_pos)
,m_byte_swap(a_byte_swap)
,m_verbose(a_verbose)
//,m_verbose(true)
,m_size(a_size) //expect a not zero size.
,m_buffer(a_buffer) //don't get ownership.
,m_pos(a_buffer)
,m_klen(a_klen) //to compute refs (used in read_class, read_object)
//,m_map_objs(false)
,m_map_objs(true)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~buffer(){
m_objs.clear();
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
buffer(const buffer& a_from)
@@ -106,9 +50,6 @@ protected:
,m_byte_swap(a_from.m_byte_swap)
,m_map_objs(a_from.m_map_objs)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
buffer& operator=(const buffer&){return *this;}
public:
@@ -117,7 +58,6 @@ public:
void set_offset(unsigned int a_off) {m_pos = m_buffer+a_off;}
//char* buffer() const {return m_buffer;}
uint32 length() const {return uint32(m_pos-m_buffer);}
uint32 size() const {return m_size;}
@@ -146,27 +86,15 @@ protected:
<< " read string." << std::endl;
return false;
}
//m_out << "tools::rroot::read_class_tag :"
// << " tag kNewClassTag"
// << " class " << _s
// << std::endl;
a_class = _s;
return true;
} else if(tag & kClassMask()) {
//m_out << "tools::rroot::read_class_tag :"
// << " tag & kClassMask"
// << " ref " << (uint32)(tag & ~kClassMask)
// << " recurse..."
// << std::endl;
unsigned int cl_offset = (tag & ~kClassMask());
cl_offset -= kMapOffset();
cl_offset -= m_klen;
char* old_pos = m_pos;
m_pos = m_buffer + cl_offset;
//std::string scls;
//uint32 ref;
if(!read_class_tag(a_class)) return false;
m_pos = old_pos;
@@ -186,13 +114,10 @@ protected:
}
bool read_class(std::string& a_class,uint32& a_bcnt,bool& a_is_ref){
//m_verbose = true;
a_class.clear();
a_bcnt = 0;
a_is_ref = false;
//uint32 fVersion = 0; //Buffer format version
// read byte count and/or tag (older files don't have byte count)
uint32 first_int = 0;
if(!parent::read(first_int)) return false;
@@ -214,7 +139,6 @@ protected:
a_bcnt = 0;
return true;
//} else if(first_int==kNewClassTag()) { // class desc follows.
} else if(first_int & kByteCountMask()) {
// at write :
// skip int to store bcnt.
@@ -275,18 +199,12 @@ protected:
}
public:
void remove_in_map(iro* a_obj) {
#ifdef TOOLS_RROOT_OBJ_MAP_HASH_TABLE
m_out << "tools::rroot::remove_in_map : dummy." << std::endl;
#else
find_and_remove_value(m_objs,a_obj);
#endif
}
bool read_object(ifac& a_fac,const ifac::args& a_args,iro*& a_obj,bool& a_created){
a_obj = 0;
a_created = false;
//m_out << "debug : tools::rroot::buffer::read_object : begin :" << std::endl;
// before reading object save start position
uint32 startpos = (uint32)(m_pos-m_buffer);
@@ -298,7 +216,6 @@ public:
<< " can't read class." << std::endl;
return false;
}
//::printf("debug : %d\n",length()-startpos);
if(m_verbose) {
m_out << "tools::rroot::buffer::read_object :"
@@ -308,8 +225,6 @@ public:
}
if(is_ref) { //bcnt is the position toward an object or an object ref.
//m_out << "debug : tools::rroot::buffer::read_object : is_ref : bcnt " << bcnt << std::endl;
unsigned int obj_offset = bcnt;
obj_offset -= kMapOffset();
obj_offset -= m_klen;
@@ -321,20 +236,11 @@ public:
}
if(m_map_objs) {
#ifdef TOOLS_RROOT_OBJ_MAP_HASH_TABLE
if(m_objs.find(obj_offset,a_obj)) {
//m_out << "debug : tools::rroot::buffer::read_object : found object in map." << bcnt << std::endl;
return true;
}
#else
obj_map::const_iterator it = m_objs.find(obj_offset);
if(it!=m_objs.end()) {
a_obj = (*it).second;
//::printf("debug : find : %d %lu\n",obj_offset,a_obj);
//stay at current m_pos ?
return true;
}
#endif
}
{char* old_pos = m_pos;
@@ -359,10 +265,6 @@ public:
return false;
}
//m_out << "tools::rroot::buffer::read_object :"
// << " is_ref : class " << sout(scls)
// << std::endl;
iro* obj = a_fac.create(scls,a_args);
if(!obj) {
m_out << "tools::rroot::buffer::read_object : is_ref : creation of object"
@@ -372,15 +274,7 @@ public:
if(m_map_objs) {
//must be done before stream()
#ifdef TOOLS_RROOT_OBJ_MAP_HASH_TABLE
if(!m_objs.insert(obj_offset,obj)) {
m_out << "tools::rroot::buffer::read_object :"
<< " map insert failed."
<< std::endl;
}
#else
m_objs[obj_offset] = obj;
#endif
}
if(!obj->stream(*this)) {
@@ -393,10 +287,6 @@ public:
return false;
}
//m_out << "tools::rroot::buffer::read_object :"
// << " is_ref : streamed ok for class " << sout(scls)
// << std::endl;
a_obj = obj;
a_created = true;
@@ -414,58 +304,24 @@ public:
m_pos = m_buffer+startpos+sizeof(unsigned int);
//check_byte_count(startpos,0,sclass) would always be ok.
//a_obj = ???
} else {
if(sclass.empty()) {
//m_out << "debug : tools::rroot::buffer::read_object : found empty class name." << std::endl;
m_pos = m_buffer+startpos+bcnt+sizeof(unsigned int);
} else {
//m_out << "debug : tools::rroot::buffer::read_object : not a ref, create object." << std::endl;
// Being not a ref, it must NOT be in the map.
// We gain a lot by not doing the below find.
/*
if(m_map_objs) {
#ifdef TOOLS_RROOT_OBJ_MAP_HASH_TABLE
if(m_objs.find(startpos,a_obj)) return true;
#else
obj_map::const_iterator it = m_objs.find(startpos);
if(it!=m_objs.end()) {
a_obj = (*it).second;
::printf("debug : find xxx : %d %lu\n",startpos,a_obj);
//stay at current m_pos ?
return true;
}
#endif
}
*/
iro* obj = a_fac.create(sclass,a_args);
if(!obj) {
m_out << "tools::rroot::buffer::read_object : creation of object"
<< " of class " << sout(sclass) << " failed." << std::endl;
return false;
}
//m_out << "debug : tools::rroot::buffer::read_object : object created." << std::endl;
if(m_map_objs) {
//must be done before stream()
#ifdef TOOLS_RROOT_OBJ_MAP_HASH_TABLE
if(!m_objs.insert(startpos,obj)) {
m_out << "tools::rroot::buffer::read_object :"
<< " map insert failed."
<< std::endl;
}
#else
m_objs[startpos] = obj;
#endif
}
//::printf("debug : map : %d %lu\n",startpos,obj);
//NOTE : if class ref, "up there"-startpos = 8.
if(!obj->stream(*this)) {
m_out << "tools::rroot::buffer::read_object : object.stream() failed"
@@ -556,8 +412,6 @@ public:
m_pos -= sizeof(unsigned int);
}
if(!parent::read(version)) return false;
//printf("Reading version=%d at pos=%d, bytecount=%d\n",
//version,*startpos,*bcnt);
a_version = version;
a_start_pos = startpos;
@@ -614,10 +468,6 @@ protected:
a_string[nr] = 0;
return true;
}
protected:
// buffer objects cannot be copied or assigned
//void checkCount(unsigned int);
//unsigned int checkObject(unsigned int,const IClass*,bool = false);
protected:
bool m_byte_swap;
bool m_verbose;
-11
View File
@@ -24,9 +24,6 @@ public:
directory(ifile& a_file)
:m_file(a_file)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
m_date_C = 0; //.set();
m_date_M = 0; //.set();
m_nbytes_keys = 0;
@@ -37,15 +34,9 @@ public:
}
virtual ~directory(){
clear_keys();
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
directory(const directory& a_from):m_file(a_from.m_file){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
directory& operator=(const directory &){return *this;}
public:
@@ -107,9 +98,7 @@ public:
if(!rb.read(versiondir)) return false;
unsigned int _date;
if(!rb.read(_date)) return false;
//fDateC.setDate(_date);
if(!rb.read(_date)) return false;
//fDateM.setDate(_date);
{int v;
if(!rb.read(v)) return false;
m_nbytes_keys = v;}
-9
View File
@@ -51,20 +51,11 @@ public:
}
public:
dummy(){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~dummy(){
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
public:
dummy(const dummy& a_from): iro(a_from){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
dummy& operator=(const dummy&){return *this;}
};
-33
View File
@@ -18,39 +18,6 @@ public: //ifac
virtual iro* create(const std::string& a_class,const args& /*a_args*/) {
if(rcmp(a_class,"TGraph")) { //for TH_read_1D/List.
return new graph();
/*
} else if(rcmp(a_class,"TObjArray")) {
std::string* sc = ifac::arg_class(a_args);
if(sc) {
if((*sc)==streamer_element::s_class()){
return new obj_array<streamer_element>(*this);
} else {
m_out << "tools::rroot::dummy_fac::create :"
<< " Can't create TObjArray of " << *sc << "."
<< std::endl;
return 0;
}
} else {
return new iros(*this);
}
*/
/*
// for read_sinfos() :
} else if(rcmp(a_class,"TStreamerInfo")) {
return new streamer_info(*this);
} else if(rcmp(a_class,"TStreamerBase")
||rcmp(a_class,"TStreamerBasicType")
||rcmp(a_class,"TStreamerBasicPointer")
||rcmp(a_class,"TStreamerObjectAny")
||rcmp(a_class,"TStreamerObject")
||rcmp(a_class,"TStreamerObjectPointer")
||rcmp(a_class,"TStreamerString")
||rcmp(a_class,"TStreamerSTL")
||rcmp(a_class,"TStreamerLoop")
||rcmp(a_class,"TList")
) {
return new dummy_streamer_element();
*/
} else {
m_out << "tools::rroot::dummy_fac::create :"
<< " dummy. Can't create object of class " << sout(a_class) << "."
-29
View File
@@ -18,10 +18,6 @@
#include "vector3"
#include "matrix"
#ifdef TOOLS_MEM
#include "../mem"
#endif
namespace tools {
namespace rroot {
@@ -31,9 +27,6 @@ public:
public: //ifac
virtual std::ostream& out() const {return m_out;}
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_out,*this);
} else if(a_class=="TBranchElement") {
@@ -130,35 +123,13 @@ public: //ifac
}
public:
fac(std::ostream& a_out):m_out(a_out){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~fac(){
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
public:
fac(const fac& a_from):ifac(a_from),m_out(a_from.m_out){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
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_out << "tools::rroot::fac::arg_branch :"
<< " branch not found in args."
<< std::endl;
return 0;
}
return (branch*)p;
}
*/
protected:
std::ostream& m_out;
};
+36 -64
View File
@@ -27,7 +27,40 @@
namespace tools {
namespace rroot {
//doc
//
// A ROOT file is a suite of consecutive data records with the following
// format (see also the TKey class);
// TKey ---------------------
// byte 1->4 Nbytes = Length of compressed object (in bytes)
// 5->6 Version = TKey version identifier
// 7->10 ObjLen = Length of uncompressed object
// 11->14 Datime = Date and time when object was written to file
// 15->16 KeyLen = Length of the key structure (in bytes)
// 17->18 Cycle = Cycle of key
// 19->22 SeekKey = Pointer to record itself (consistency check)
// 23->26 SeekPdir = Pointer to directory header
// 27->27 lname = Number of bytes in the class name
// 28->.. ClassName = Object Class Name
// ..->.. lname = Number of bytes in the object name
// ..->.. Name = lName bytes with the name of the object
// ..->.. lTitle = Number of bytes in the object title
// ..->.. Title = Title of the object
// -----> DATA = Data bytes associated to the object
//
// The first data record starts at byte fBEGIN (currently set to kBegin)
// Bytes 1->kBegin contain the file description:
// byte 1->4 "root" = Root file identifier
// 5->8 fVersion = File format version
// 9->12 fBEGIN = Pointer to first data record
// 13->16 fEND = Pointer to first free word at the EOF
// 17->20 fSeekFree = Pointer to FREE data record
// 21->24 fNbytesFree = Number of bytes in FREE data record
// 25->28 nfree = Number of free data records
// 29->32 fNbytesName = Number of bytes in TNamed at creation time
// 33->33 fUnits = Number of bytes for file pointers
// 34->37 fCompress = Zip compression level
//
class file : public virtual ifile {
file& get_me() {return *this;} //_MSC_VER : to avoid warning about the usage of "this" in the constructor.
static int not_open() {return -1;}
@@ -132,10 +165,6 @@ public:
,m_nbytes_info(0)
,m_nbytes_name(0)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
m_file = _open(a_path.c_str(),
#if defined(_MSC_VER) || defined(__MINGW32__)
O_RDONLY | O_BINARY,S_IREAD | S_IWRITE
@@ -153,9 +182,6 @@ public:
}
virtual ~file() {
close();
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
file(const file& a_from)
@@ -166,9 +192,6 @@ protected:
,m_streamer_fac(a_from.m_out)
,m_streamer_infos(m_streamer_fac)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
file& operator=(const file&){return *this;}
public:
@@ -236,22 +259,7 @@ protected:
<< std::endl;
return false;
}
/*
fRootDirectory->setSeekDirectory(fBEGIN);
// Read Free segments structure if file is writable :
if (fWritable) {
if (fSeekFree > fBEGIN) {
if(!readFreeSegments()) {
m_out << "tools::rroot::file::initialize : Cannot read free segments."
<< std::endl;
return false;
}
} else {
m_out << "tools::rroot::file::initialize : file \"" << fName
<< "\" probably not closed, cannot read free segments" << std::endl;
}
}
*/
// Read Directory info :
uint32 nbytes = m_nbytes_name + m_root_directory.record_size(m_version);
char* header = new char[nbytes];
@@ -425,7 +433,6 @@ protected:
{int v;
if(!rb.read(v)) return false;
m_nbytes_name = v;}
//m_out << "debug : 1002 " << m_nbytes_name << std::endl;
{char fUnits;
if(!rb.read(fUnits)) return false;}
{int fCompress;
@@ -438,7 +445,6 @@ protected:
m_seek_info = i;}
}
if(!rb.read(m_nbytes_info)) return false;
//m_out << "debug : seek_info " << m_seek_info << " nbytes_info " << m_nbytes_info << std::endl;
return true;
}
@@ -506,7 +512,6 @@ protected:
seek m_seek_info; //Location on disk of StreamerInfo record
uint32 m_nbytes_free; //Number of bytes for free segments structure
uint32 m_nbytes_info; //Number of bytes for StreamerInfo record
//int nfree
uint32 m_nbytes_name; //Number of bytes in TNamed at creation time
};
@@ -515,37 +520,4 @@ protected:
#endif
//doc
//
// A ROOT file is a suite of consecutive data records with the following
// format (see also the TKey class);
// TKey ---------------------
// byte 1->4 Nbytes = Length of compressed object (in bytes)
// 5->6 Version = TKey version identifier
// 7->10 ObjLen = Length of uncompressed object
// 11->14 Datime = Date and time when object was written to file
// 15->16 KeyLen = Length of the key structure (in bytes)
// 17->18 Cycle = Cycle of key
// 19->22 SeekKey = Pointer to record itself (consistency check)
// 23->26 SeekPdir = Pointer to directory header
// 27->27 lname = Number of bytes in the class name
// 28->.. ClassName = Object Class Name
// ..->.. lname = Number of bytes in the object name
// ..->.. Name = lName bytes with the name of the object
// ..->.. lTitle = Number of bytes in the object title
// ..->.. Title = Title of the object
// -----> DATA = Data bytes associated to the object
//
// The first data record starts at byte fBEGIN (currently set to kBegin)
// Bytes 1->kBegin contain the file description:
// byte 1->4 "root" = Root file identifier
// 5->8 fVersion = File format version
// 9->12 fBEGIN = Pointer to first data record
// 13->16 fEND = Pointer to first free word at the EOF
// 17->20 fSeekFree = Pointer to FREE data record
// 21->24 fNbytesFree = Number of bytes in FREE data record
// 25->28 nfree = Number of free data records
// 29->32 fNbytesName = Number of bytes in TNamed at creation time
// 33->33 fUnits = Number of bytes for file pointers
// 34->37 fCompress = Zip compression level
//
-6
View File
@@ -47,14 +47,8 @@ public:
}
public:
graph(){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~graph(){
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
graph(const graph& a_from): iro(a_from){}
-1
View File
@@ -30,7 +30,6 @@ public:
if(it==a_args.end()) return 0;
return (*it).second;
}
//static char arg_branch() {return 'B';}
static char arg_class() {return 'C';}
static std::string* arg_class(const args& a_args) {
-22
View File
@@ -4,8 +4,6 @@
#ifndef tools_rroot_info
#define tools_rroot_info
//#include "buffer"
//#include "element"
#include "named"
#include "obj_array"
#include "../forit"
@@ -63,15 +61,9 @@ public:
:fName(),fTitle(),fType(-1)
,fSize(0),fArrayLength(0),fArrayDim(0),fOffset(0)
,fTypeName(){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
for(int i=0;i<5;i++) fMaxIndex[i] = 0;
}
virtual ~streamer_element(){
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
streamer_element(const streamer_element& a_from)
@@ -81,9 +73,6 @@ protected:
,fArrayLength(a_from.fArrayLength)
,fArrayDim(a_from.fArrayDim),fOffset(a_from.fOffset)
,fTypeName(a_from.fTypeName){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
for(int i=0;i<5;i++) fMaxIndex[i] = a_from.fMaxIndex[i];
}
streamer_element& operator=(const streamer_element& a_from){
@@ -118,7 +107,6 @@ protected:
int fArrayDim; //number of array dimensions
int fMaxIndex[5]; //Maximum array index for array dimension "dim"
int fOffset; //!element offset in class
//FIXME Int_t fNewType; //!new element type when reading
std::string fTypeName; //Data type name of data member
};
@@ -214,14 +202,8 @@ public:
,m_streamed_class_version(0)
,m_elements(a_fac)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~streamer_info(){
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
streamer_info(const streamer_info& a_from)
@@ -233,9 +215,6 @@ protected:
,m_streamed_class_version(a_from.m_streamed_class_version)
,m_elements(a_from.m_elements)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
streamer_info& operator=(const streamer_info& a_from){
m_name = a_from.m_name;
@@ -259,7 +238,6 @@ protected: //Named
protected:
unsigned int m_check_sum; //checksum of original class
int m_streamed_class_version; //Class version identifier
//int fNumber; //!Unique identifier
obj_array<streamer_element> m_elements; //Array of TStreamerElements
};
-26
View File
@@ -49,15 +49,9 @@ public:
iros(ifac& a_fac)
:m_fac(a_fac)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~iros(){
_clear();
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
public:
iros(const iros& a_from)
@@ -65,9 +59,6 @@ public:
,parent()
,m_fac(a_from.m_fac)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
tools_vforcit(iro*,a_from,it) {
parent::push_back((*it)->copy());
m_owns.push_back(true);
@@ -107,8 +98,6 @@ public:
unsigned int s, c;
if(!a_buffer.read_version(v,s,c)) return false;
//::printf("debug : iros::stream : version %d, byte count %d\n",v,c);
{uint32 id,bits;
if(!Object_stream(a_buffer,id,bits)) return false;}
std::string name;
@@ -118,19 +107,13 @@ public:
int lowerBound;
if(!a_buffer.read(lowerBound)) return false;
//::printf("debug : iros : name \"%s\", nobject %d, lowerBound %d\n",
// name.c_str(),nobjects,lowerBound);
for (int i=0;i<nobjects;i++) {
//::printf("debug : iros : n=%d i=%d ...\n",nobjects,i);
iro* obj;
bool created;
if(!a_buffer.read_object(m_fac,a_args,obj,created)){
a_buffer.out() << "tools::rroot::iros::stream : can't read object." << std::endl;
return false;
}
//::printf("debug : iros : n=%d i=%d : ok\n",nobjects,i);
if(obj) {
if(created) {
parent::push_back(obj);
@@ -169,15 +152,6 @@ protected:
std::vector<bool> m_owns;
};
/*
inline bool dummy_TObjArray_pointer_stream(buffer& a_buffer,ifac& a_fac,bool a_owner,bool a_warn) {
iros oa(a_fac,a_owner,a_warn);
iros oa(a_fac,true,true);
ifac::args args;
return oa.stream(a_buffer,args);
}
*/
}}
#endif
+30 -116
View File
@@ -10,29 +10,41 @@
#include "ifile"
#include "../sout"
#ifdef TOOLS_MEM
#include "../mem"
#endif
#include <map>
#include <ostream>
#include <cstring> //memcpy
//#include <zlib.h>
#ifdef TOOLS_USE_CSZ
// CSZ code where used as default compressor in old CERN-ROOT, then it may be needed
// to read old file (as the pawdemo.root one).
//FIXME : arrange to have csz coming from the "outside" (as zip).
extern "C" {
void csz__Init_Inflate(long,unsigned char*,long,unsigned char*);
int csz__Inflate();
unsigned char* csz__obufptr();
}
#endif
namespace tools {
namespace rroot {
//doc :
//////////////////////////////////////////////////////////////////////////
// //
// The Key class includes functions to book space on a file, //
// to create I/O buffers, to fill these buffers //
// to compress/uncompress data buffers. //
// //
// Before saving (making persistent) an object on a file, a key must //
// be created. The key structure contains all the information to //
// uniquely identify a persistent object on a file. //
// fNbytes = number of bytes for the compressed object+key //
// version of the Key class //
// fObjlen = Length of uncompressed object //
// fDatime = Date/Time when the object was written //
// fKeylen = number of bytes for the key structure //
// fCycle = cycle number of the object //
// fSeekKey = Address of the object on file (points to fNbytes) //
// This is a redundant information used to cross-check //
// the data base integrity. //
// fSeekPdir = Pointer to the directory supporting this object //
// fClassName = Object class name //
// fName = name of the object //
// fTitle = title of the object //
// //
// The Key class is used by ROOT to: //
// - to write an object in the Current Directory //
// - to write a new ntuple buffer //
// //
//////////////////////////////////////////////////////////////////////////
class key {
static uint32 class_version() {return 2;}
@@ -59,15 +71,8 @@ public:
,m_cycle(0)
,m_seek_key(0)
,m_seek_parent_dir(0)
//,m_object_class
//,m_object_name
//,m_object_title
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
m_key_length = record_size(m_version);
//fDate.setDate(0);
}
key(std::ostream& a_out,seek a_pos,uint32 a_nbytes)
@@ -83,13 +88,7 @@ public:
,m_cycle(0)
,m_seek_key(a_pos)
,m_seek_parent_dir(0)
//,m_object_class
//,m_object_name
//,m_object_title
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
if(a_pos>START_BIG_FILE) m_version += big_file_version_tag();
m_buffer = new char[a_nbytes];
if(!m_buffer) {
@@ -102,9 +101,6 @@ public:
}
virtual ~key(){
delete [] m_buffer;
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
key(const key& a_from)
@@ -123,9 +119,6 @@ protected:
,m_object_name(a_from.m_object_name)
,m_object_title(a_from.m_object_title)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
if(a_from.m_buf_size && a_from.m_buffer) {
m_buffer = new char[a_from.m_buf_size];
if(!m_buffer) {
@@ -207,21 +200,8 @@ public:
rbuf rb(m_out,a_byte_swap,aEOB,a_pos);
int _nbytes;
if(!rb.read(_nbytes)) return false;
/*
if(m_nbytes) {
if(_nbytes!=int(m_nbytes)) {
out << "tools::rroot::key::from_buffer :"
<< " nbytes not consistent."
<< " read " << _nbytes
<< ", expected " << m_nbytes
<< ". Continue with " << _nbytes
<< std::endl;
m_nbytes = _nbytes;
}
} else {
*/
m_nbytes = _nbytes;
//}
short version;
if(!rb.read(version)) return false;
m_version = version;
@@ -230,7 +210,6 @@ public:
m_object_size = v;}
unsigned int _date;
if(!rb.read(_date)) return false;
//fDate.setDate(_date);
{short v;
if(!rb.read(v)) return false;
m_key_length = v;}
@@ -269,11 +248,6 @@ public:
m_out << "tools::rroot::key::get_object_buffer :"
<< " WARNING : m_key_length is zero."
<< std::endl;
//delete [] m_buffer;
//m_buffer = 0;
//m_buf_size = 0;
//a_size = 0;
//return 0;
}
if(!m_nbytes) {
m_out << "tools::rroot::key::get_object_buffer :"
@@ -508,37 +482,6 @@ protected:
return false;
}
a_irep = irep;
#ifdef TOOLS_USE_CSZ
} else if (a_src[0] == 'C' && a_src[1] == 'S') {
//compressed with Chernyaev & Smirnov
csz__Init_Inflate(_ibufcnt,a_src + HDRSIZE,a_tgtsize,a_tgt);
if (csz__Inflate()) {
a_out << "tools::rroot::key::unzip :"
<< " error during decompression." << std::endl;
return false;
}
unsigned char* obufptr = csz__obufptr();
// if (obufptr - a_tgt != isize) {
// There are some rare cases when a few more bytes are required
if (obufptr - a_tgt > a_tgtsize) {
a_out << "tools::rroot::key::_unzip :"
<< " discrepancy " << (int)(obufptr - a_tgt)
<< " with initial size: " << (int)isize
<< ", tgtsize= " << a_tgtsize
<< std::endl;
a_irep = int(obufptr - a_tgt);
//return false;
}
a_irep = isize;
//a_out << "tools::rroot::key::unzip : CS : ok "
// << a_irep << std::endl;
#endif
} else {
a_out << "tools::rroot::key::_unzip : unknown a_src[0,1]."
<< " [0] = " << a_src[0] << ", [1] = " << a_src[1]
@@ -575,32 +518,3 @@ protected:
#endif
//doc :
//////////////////////////////////////////////////////////////////////////
// //
// The Key class includes functions to book space on a file, //
// to create I/O buffers, to fill these buffers //
// to compress/uncompress data buffers. //
// //
// Before saving (making persistent) an object on a file, a key must //
// be created. The key structure contains all the information to //
// uniquely identify a persistent object on a file. //
// fNbytes = number of bytes for the compressed object+key //
// version of the Key class //
// fObjlen = Length of uncompressed object //
// fDatime = Date/Time when the object was written //
// fKeylen = number of bytes for the key structure //
// fCycle = cycle number of the object //
// fSeekKey = Address of the object on file (points to fNbytes) //
// This is a redundant information used to cross-check //
// the data base integrity. //
// fSeekPdir = Pointer to the directory supporting this object //
// fClassName = Object class name //
// fName = name of the object //
// fTitle = title of the object //
// //
// The Key class is used by ROOT to: //
// - to write an object in the Current Directory //
// - to write a new ntuple buffer //
// //
//////////////////////////////////////////////////////////////////////////
+1 -25
View File
@@ -113,13 +113,6 @@ public: //base_leaf
uint32 ndata = len * m_length;
//if(!ndata) {
// delete [] m_value;
// m_value = new T[1];
// m_size = 0;
// return true;
//}
if(ndata>m_size) {
delete [] m_value;
m_value = new T[ndata];
@@ -163,7 +156,6 @@ public: //base_leaf
a_out << m_value[a_index];
return true;
}
//virtual uint32 num_elem() const {return m_length;}
virtual uint32 num_elem() const {return m_size;}
public:
leaf(std::ostream& a_out,ifac& a_fac)
@@ -196,7 +188,6 @@ public:
return true;
}
T get_max() const {return m_max;}
//uint32 size() const {return m_size;}
protected:
T m_min; //Minimum value if leaf range is specified
T m_max; //Maximum value if leaf range is specified
@@ -262,12 +253,6 @@ public: //base_leaf
}
}
if(len) {
//if(!m_length) {
// m_out << "tools::rroot::leaf_string::read_buffer : m_length is zero." << std::endl;
// return false;
//}
//if(len >= m_length) len = m_length-1;
m_value = new char[len+1];
if(!a_buffer.read_fast_array(m_value,len)) {
@@ -437,7 +422,6 @@ public: //base_leaf
<< " fClassName " << sout(fClassName)
<< ". m_obj.store_class_name() " << sout(m_obj->store_class_name())
<< std::endl;
//return false;
}
if(!m_obj->stream(a_buffer)) {
m_out << "tools::rroot::leaf_object::read_buffer :"
@@ -446,15 +430,7 @@ public: //base_leaf
<< std::endl;
return false;
}
// in case we had written a null pointer a Zombie object was created
// we must delete it
//FIXME
//if (object->TestBit(kInvalidObject)) {
// if (object->GetUniqueID() == 123456789) {
// delete object;
// object = 0;
// }
//}
return true;
}
virtual bool print_value(std::ostream&,uint32) const {
-9
View File
@@ -42,8 +42,6 @@ public:
short v;
if(!a_buffer.read_version(v,_s,_c)) return false;
//printf("debug : tools::rroot::matrix::stream : version %d\n",v);
// Version 2 streaming (ROOT/v3-00-6).
{uint32 id,bits;
@@ -60,7 +58,6 @@ public:
int ColLwb;
if(!a_buffer.read(ColLwb)) return false;
//Real_t* Elements; //[fNelems]
if(!dummy_array_stream<float>(a_buffer,Nelems)) return false;
if(!a_buffer.check_byte_count(_s,_c,s_store_class())) return false;
@@ -69,14 +66,8 @@ public:
public:
matrix(){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~matrix(){
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
matrix(const matrix& a_from): iro(a_from){}
+1 -12
View File
@@ -6,7 +6,6 @@
#include "object"
#include "../scast"
#include "../vdata"
#include "cids"
namespace tools {
@@ -85,7 +84,7 @@ inline bool Array_stream(buffer& a_buffer,std::vector<T>& a_v) {
//check sz is not crazy :
if(!a_buffer.check_eob(sz)) return false;
a_v.resize(sz);
if(!a_buffer.read_fast_array<T>(vec_data(a_v),sz)) return false;
if(!a_buffer.read_fast_array<T>(a_v.data(),sz)) return false;
return true;
}
@@ -123,7 +122,6 @@ public:
if(void* p = cmp_cast<named>(this,a_class)) {return p;}
else return 0;
}
//virtual void* cast(cid) const {return named_cid();}
public:
virtual iro* copy() const {return new named(*this);}
virtual bool stream(buffer& a_buffer) {
@@ -131,20 +129,11 @@ public:
}
public:
named() {
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~named() {
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
named(const named& a_from):iro(a_from),m_name(a_from.m_name),m_title(a_from.m_title) {
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
named& operator=(const named& a_from){
m_name = a_from.m_name;
-43
View File
@@ -13,15 +13,10 @@
#include "stl_vector"
#include "../cids"
#include "../vfind"
#include "../vmanip"
#include "../ntuple_binding"
#include "../get_lines"
#ifdef TOOLS_MEM
#include "../mem"
#endif
namespace tools {
namespace rroot {
@@ -92,7 +87,6 @@ public:
return *this;
}
protected:
//typedef typename LEAF::value_t value_t;
bool _fetch_entry() const {
unsigned int n;
if(!m_branch.find_entry(m_file,uint32(m_index),n)) {m_ref = T();return false;}
@@ -108,7 +102,6 @@ public:
LEAF& m_leaf;
int64& m_index; //WARNING : a ref.
T& m_ref;
//value_t m_tmp;
};
template <class T,class LEAF>
@@ -486,22 +479,13 @@ public:
public:
ntuple(tree& a_tree):m_tree(a_tree),m_index(-1){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~ntuple() {
safe_clear<read::icol>(m_cols);
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
ntuple(const ntuple& a_from)
:parent(a_from),m_tree(a_from.m_tree){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
ntuple& operator=(const ntuple&){return *this;}
public:
@@ -529,10 +513,6 @@ public:
return false;
}
//a_out << "tools::rroot::ntuple::initialize :"
// << " branch " << _branch->name()
// << ", entries " << _branch->entry_number() << "."
// << std::endl;
#define TOOLS_RROOT_NTUPLE_CREATE_COL(a__type) \
if(leaf<a__type>* lf_##a__type = safe_cast<base_leaf, leaf<a__type> >(*bl) ){\
@@ -550,7 +530,6 @@ public:
} else {\
const base_leaf* lfc = bl->leaf_count();\
if(lfc) {\
/*::printf("debug : ntuple : create col leaf count : %s\n",bl->name().c_str());*/\
if(user_cid!=_cid_std_vector<a__type>()) {\
a_out << "tools::rroot::ntuple::initialize :"\
<< " for leaf with name " << sout(bl->name())\
@@ -564,7 +543,6 @@ public:
(m_tree.file(),*_branch,*lf_##a__type,m_index,*user_var);\
m_cols.push_back(col);\
} else {\
/*::printf("debug : ntuple : create col : %s\n",bl->name().c_str());*/\
if(user_cid!=_cid(a__type())) {\
a_out << "tools::rroot::ntuple::initialize :"\
<< " for leaf with name " << sout(bl->name())\
@@ -634,7 +612,6 @@ public:
#define TOOLS_RROOT_NTUPLE_CREATE_VEC_COL(a__name,a__type) \
if(be->class_name()==a__name) {\
/*::printf("debug : ntuple : create vec col : %s\n",bl->name().c_str());*/\
typedef a__type el_t;\
std::vector<el_t>* user_var = a_bd.find_vector_variable<el_t>(bl->name());\
if(user_var) {\
@@ -650,25 +627,10 @@ public:
TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<char>",char)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<short>",short)
//else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<unsigned short>",unsigned short)
//else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<unsigned int>",unsigned int)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<int>",int)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<float>",float)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<double>",double)
//else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<string>",std::string)
//else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<unsigned long>",uint64) //beurk
// WARNING : take care of the space in "> >".
/* VisualC++ : the below does not compile.
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<vector<unsigned short> >",std::vector<unsigned short>)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<vector<short> >",std::vector<short>)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<vector<unsigned int> >",std::vector<unsigned int>)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<vector<int> >",std::vector<short>)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<vector<float> >",std::vector<float>)
else TOOLS_RROOT_NTUPLE_CREATE_VEC_COL("vector<vector<double> >",std::vector<double>)
*/
else {
a_out << "tools::rroot::ntuple::initialize :"
<< " WARNING : leaf element"
@@ -711,11 +673,6 @@ public:
return false;
}
}}
//a_out << "tools::rroot::ntuple::initialize :"
// << " number of columns " << num << "."
// << std::endl;
return true;
}
-19
View File
@@ -48,15 +48,9 @@ public:
obj_array(ifac& a_fac)
:m_fac(a_fac)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~obj_array(){
_clear();
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
public:
obj_array(const obj_array& a_from)
@@ -64,9 +58,6 @@ public:
,parent()
,m_fac(a_from.m_fac)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
typedef typename parent::const_iterator it_t;
for(it_t it=a_from.begin();it!=a_from.end();++it) {
if(!(*it)) {
@@ -124,14 +115,10 @@ public:
bool stream(buffer& a_buffer,const ifac::args& a_args,bool a_accept_null = false) {
_clear();
//::printf("debug : obj_array::stream : %lu : begin\n",(unsigned long)this);
short v;
unsigned int sp, bc;
if(!a_buffer.read_version(v,sp,bc)) return false;
//::printf("debug : obj_array::stream : version %d, byte count %d\n",v,bc);
{uint32 id,bits;
if(!Object_stream(a_buffer,id,bits)) return false;}
std::string name;
@@ -141,11 +128,7 @@ public:
int lowerBound;
if(!a_buffer.read(lowerBound)) return false;
//::printf("debug : obj_array : name \"%s\", nobject %d, lowerBound %d\n",name.c_str(),nobjects,lowerBound);
for (int i=0;i<nobjects;i++) {
//::printf("debug : obj_array::stream : %lu : n=%d i=%d ...\n",(unsigned long)this,nobjects,i);
iro* obj;
bool created;
if(!a_buffer.read_object(m_fac,a_args,obj,created)){
@@ -154,8 +137,6 @@ public:
<< ", nobjects " << nobjects << ", iobject " << i << std::endl;
return false;
}
//::printf("debug : obj_array::stream : %lu : n=%d i=%d : ok, obj %lu\n",(unsigned long)this,
// nobjects,i,(unsigned long)obj);
if(obj) {
T* to = safe_cast<iro,T>(*obj);
if(!to) {
+2 -19
View File
@@ -4,8 +4,6 @@
#ifndef tools_rroot_obj_list
#define tools_rroot_obj_list
//#include "../vmanip"
#include "iro"
#include "object"
@@ -41,7 +39,6 @@ public:
if(void* p = cmp_cast<obj_list>(this,a_class)) {return p;}
else return 0;
}
//virtual void* cast(cid) const {return obj_list_cid();}
public:
virtual iro* copy() const {return new obj_list(*this);}
virtual bool stream(buffer& a_buffer) {
@@ -51,8 +48,6 @@ public:
unsigned int _s,_c;
if(!a_buffer.read_version(v,_s,_c)) return false;
//::printf("debug : obj_list::stream : version %d, byte count %d\n",v,c);
{uint32 id,bits;
if(!Object_stream(a_buffer,id,bits)) return false;}
@@ -61,13 +56,8 @@ public:
int nobjects;
if(!a_buffer.read(nobjects)) return false;
//::printf("debug : obj_list : name \"%s\", nobject %d\n",
// name.c_str(),nobjects);
ifac::args args;
for (int i=0;i<nobjects;i++) {
//::printf("debug : obj_list : n=%d i=%d ...\n",nobjects,i);
iro* obj;
bool created;
if(!a_buffer.read_object(m_fac,args,obj,created)){
@@ -99,15 +89,9 @@ public:
obj_list(ifac& a_fac)
:m_fac(a_fac)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~obj_list(){
safe_clear();
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
public:
obj_list(const obj_list& a_from)
@@ -115,9 +99,6 @@ public:
,parent()
,m_fac(a_from.m_fac)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
tools_vforcit(iro*,a_from,it) {
parent::push_back((*it)->copy());
m_owns.push_back(true);
@@ -137,8 +118,10 @@ public:
}
public:
parent::const_iterator begin() const {return parent::begin();}
parent::const_iterator cbegin() const {return parent::cbegin();}
parent::iterator begin() {return parent::begin();}
parent::const_iterator end() const {return parent::end();}
parent::const_iterator cend() const {return parent::cend();}
parent::iterator end() {return parent::end();}
parent::size_type size() const {return parent::size();}
bool empty() const {return parent::empty();}
+2 -85
View File
@@ -7,13 +7,7 @@
#include "streamers"
#include "fac"
#include "tree"
#include "../words" //for annotations.
#define TOOLS_RROOT_NOT_OSC
#ifndef TOOLS_RROOT_NOT_OSC
#include "osc"
#endif
#include "../tokenize" //for annotations.
#include "THistogram"
@@ -24,9 +18,6 @@ inline TDirectory* find_dir(directory& a_dir,const std::string& a_name) {
std::ostream& out = a_dir.file().out();
key* k = a_dir.find_key(a_name);
if(!k) {
//out << "tools::rroot::find_dir :"
// << " " << a_name << " not a key."
// << std::endl;
return 0;
}
@@ -80,10 +71,6 @@ inline bool read_key(std::ostream& a_out,ifile& a_file,key& a_key,bool a_dump){
return false;
}
//a_out << "tools::rroot::read_key :"
// << " get data buffer size " << sz << "."
// << std::endl;
buffer b(a_out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
if(a_key.object_class()==TNamed_cls()) {
@@ -186,25 +173,13 @@ inline bool read_key(std::ostream& a_out,ifile& a_file,key& a_key,bool a_dump){
uint64 entries = tree.entries();
/*
{for(uint32 j=0;j<10;j++){ //to test memory.
for(uint32 i=0;i<entries;i++){
uint32 n;
if(!tree.find_entry(i,n)) {
a_out << " can't find entry " << i
<< std::endl;
}
}
}}
*/
{for(uint32 i=0;i<5;i++){
if(!tree.show(a_out,i)) {
a_out << " show failed for entry " << i
<< std::endl;
}
}}
{for(uint64 i=mx<int64>(5,entries-5);i<entries;i++){
{for(uint64 i=max_of<int64>(5,entries-5);i<entries;i++){
if(!tree.show(a_out,(uint32)i)) {
a_out << " show failed for entry " << i
<< std::endl;
@@ -214,63 +189,6 @@ inline bool read_key(std::ostream& a_out,ifile& a_file,key& a_key,bool a_dump){
}
}
#ifndef TOOLS_RROOT_NOT_OSC
} else if(a_key.object_class()==osc::s_h1d()) {
histo::h1d h("",10,0,1);
if(!from_osc(b,osc::s_h1d(),h)) {
a_out << "tools::rroot::read_key :"
<< " " << osc::s_h1d() << " streaming failed"
<< std::endl;
} else {
if(a_dump) h.hprint(a_out);
}
} else if(a_key.object_class()==osc::s_h2d()) {
histo::h2d h("",10,0,1,10,0,1);
if(!from_osc(b,osc::s_h2d(),h)) {
a_out << "tools::rroot::read_key :"
<< " " << osc::s_h2d() << " streaming failed"
<< std::endl;
} else {
if(a_dump) h.hprint(a_out);
}
} else if(a_key.object_class()==osc::s_h3d()) {
histo::h3d h("",10,0,1,10,0,1,10,0,1);
if(!from_osc(b,osc::s_h3d(),h)) {
a_out << "tools::rroot::read_key :"
<< " " << osc::s_h3d() << " streaming failed"
<< std::endl;
} else {
if(a_dump) h.hprint(a_out);
}
} else if(a_key.object_class()==osc::s_p1d()) {
histo::p1d h("",10,0,1);
if(!from_osc(b,osc::s_p1d(),h)) {
a_out << "tools::rroot::read_key :"
<< " " << osc::s_p1d() << " streaming failed"
<< std::endl;
} else {
if(a_dump) h.hprint(a_out);
}
} else if(a_key.object_class()==osc::s_p2d()) {
histo::p2d h("",10,0,1,10,0,1);
if(!from_osc(b,osc::s_p2d(),h)) {
a_out << "tools::rroot::read_key :"
<< " " << osc::s_p2d() << " streaming failed"
<< std::endl;
} else {
if(a_dump) h.hprint(a_out);
}
#endif
} else if(a_key.object_class()==THistogram_cls()) { //produced with osc/AIDA through BatchLab/Rio/THistogram.
pd_data_t data;
@@ -308,7 +226,6 @@ inline bool read_key(std::ostream& a_out,ifile& a_file,key& a_key,bool a_dump){
return true;
}
//typedef std::map<std::string,std::string> annotations_t;
inline bool key_to_annotations(ifile& a_file,key& a_key,std::map<std::string,std::string>& a_annotations,bool a_warn = true) {
a_annotations.clear();
std::ostream& out = a_key.out();
-13
View File
@@ -8,10 +8,6 @@
#include "../long_out"
#include "../charp_out"
#ifdef TOOLS_MEM
#include "../mem"
#endif
#include <ostream>
#include <vector>
#include <cstring> //memcpy
@@ -87,15 +83,9 @@ public:
,m_r_4_func(0)
,m_r_8_func(0)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
set_byte_swap(a_byte_swap);
}
virtual ~rbuf(){
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
public:
rbuf(const rbuf& a_from)
@@ -107,9 +97,6 @@ public:
,m_r_4_func(a_from.m_r_4_func)
,m_r_8_func(a_from.m_r_8_func)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
set_byte_swap(a_from.m_byte_swap);
}
rbuf& operator=(const rbuf& a_from){
-46
View File
@@ -45,14 +45,9 @@ public:
unsigned int _s,_c;
if(!a_buffer.read_version(v,_s,_c)) return false;
//::printf("debug : stl_vector::stream<%s> : version %d, byte count %d\n",
// stype(T()).c_str(),v,c);
unsigned int num;
if(!a_buffer.read(num)) return false;
//::printf("debug : stl_vector : %d\n",num);
if(num) {
T* vec = new T[num];
if(!a_buffer.read_fast_array<T>(vec,num)) {
@@ -71,23 +66,14 @@ public:
}
public:
stl_vector(){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~stl_vector(){
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
public:
stl_vector(const stl_vector& a_from)
:iro(a_from)
,std::vector<T>(a_from)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
stl_vector& operator=(const stl_vector& a_from){
std::vector<T>::operator=(a_from);
@@ -131,13 +117,10 @@ public:
unsigned int _s,_c;
if(!a_buffer.read_version(v,_s,_c)) return false;
//::printf("debug : stl_vector_vector::stream<%s> : version %d, byte count %d\n",stype(T()).c_str(),v,c);
unsigned int vecn;
if(!a_buffer.read(vecn)) return false;
std::vector<vec_t>::resize(vecn);
//::printf("debug : stl_vector_vector : %d\n",vecn);
for(unsigned int veci=0;veci<vecn;veci++) {
vec_t& elem = std::vector<vec_t>::operator[](veci);
@@ -146,7 +129,6 @@ public:
std::vector<vec_t>::clear();
return false;
}
//::printf("debug : stl_vector_vector : index %d num %d\n",veci,num);
if(num) {
T* vec = new T[num];
if(!a_buffer.read_fast_array<T>(vec,num)) {
@@ -165,23 +147,14 @@ public:
}
public:
stl_vector_vector(){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~stl_vector_vector(){
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
public:
stl_vector_vector(const stl_vector_vector& a_from)
:iro(a_from)
,std::vector< std::vector<T> >(a_from)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
stl_vector_vector& operator=(const stl_vector_vector& a_from){
std::vector< std::vector<T> >::operator=(a_from);
@@ -215,21 +188,13 @@ public:
virtual bool stream(buffer& a_buffer) {
std::vector<std::string>::clear();
//uint32 startpos = a_buffer.length();
//WARNING : not tested yet.
short v;
unsigned int _s,_c;
if(!a_buffer.read_version(v,_s,_c)) return false;
//::printf("debug : stl_vector_string::stream : version %d, byte count %d\n",v,c);
unsigned int num;
if(!a_buffer.read(num)) return false;
//::printf("debug : stl_vector_string : %d\n",num);
std::vector<std::string>::resize(num);
for(unsigned int index=0;index<num;index++) {
std::string& vs = std::vector<std::string>::operator[](index);
@@ -239,29 +204,18 @@ public:
}
}
//a_buffer.set_offset(startpos+_c+sizeof(unsigned int));
return a_buffer.check_byte_count(_s,_c,s_store_class());
}
public:
stl_vector_string(){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~stl_vector_string(){
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
public:
stl_vector_string(const stl_vector_string& a_from)
:iro(a_from)
,std::vector<std::string>(a_from)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
stl_vector_string& operator=(const stl_vector_string& a_from){
std::vector<std::string>::operator=(a_from);
-48
View File
@@ -9,7 +9,6 @@
#include "named"
#include "date"
#include "directory"
//#include "graph"
#include "clss"
#include "dummy"
#include "obj_list"
@@ -17,7 +16,6 @@
#include "../sout"
#include "../vmanip"
//#include "../histo/histo_data"
#include "../histo/profile_data"
#include "../histo/h1d"
@@ -147,8 +145,6 @@ inline bool TH_read_1D(buffer& a_buffer,hd_data& a_data,
short vers;
if(!a_buffer.read_version(vers,_s,_c)) return false;
//::printf("debug : tools::rroot::TH_read_1D : version %d\n",vers);
// Version 3 streaming (ROOT/v3-00-6).
std::string name;
@@ -222,10 +218,6 @@ inline bool TH_read_1D(buffer& a_buffer,hd_data& a_data,
{std::string opt;
if(!a_buffer.read(opt)) return false; //TString fOption
//look if it is an "annotation trick" :
//if(opt.size()&&(opt[0]==0)) {
// fAnnotation = opt.substr(1,opt.size()-1);
//}
}
{dummy_fac fac(a_buffer.out());
@@ -361,8 +353,6 @@ inline histo::h1d* TH1F_stream(buffer& a_buffer){
hd_data data;
data.m_dimension = 1;
//data.m_coords.resize(data.m_dimension,0);
//data.m_ints.resize(data.m_dimension,0);
data.m_axes.resize(1);
double fEntries; //in range + outflow.
@@ -531,8 +521,6 @@ inline histo::h2d* TH2D_stream(buffer& a_buffer){
hd_data data;
data.m_dimension = 2;
//data.m_coords.resize(data.m_dimension,0);
//data.m_ints.resize(data.m_dimension,0);
data.m_axes.resize(2);
data.m_in_range_plane_Sxyw.resize(1,0);
@@ -588,8 +576,6 @@ inline histo::h3d* TH3D_stream(buffer& a_buffer){
hd_data data;
data.m_dimension = 3;
//data.m_coords.resize(data.m_dimension,0);
//data.m_ints.resize(data.m_dimension,0);
data.m_axes.resize(3);
data.m_in_range_plane_Sxyw.resize(3,0);
@@ -776,8 +762,6 @@ inline histo::p2d* TProfile2D_stream(buffer& a_buffer){
}
class TDirectory : public directory {
//public:
// static const std::string& store_class() {return TDirectory_cls();}
public:
TDirectory(ifile& a_file):directory(a_file){}
virtual ~TDirectory(){}
@@ -813,7 +797,6 @@ public:
if(!a_buffer.read(i)) return false;
m_seek_keys = i;}
}
//short v = version%big_file_version_tag();
if (m_seek_keys) {
uint32 n;
@@ -892,37 +875,6 @@ inline void dump(std::ostream& a_out,
}}
}
/*
inline bool read_sinfos(ifile& a_file){
key& k = a_file.sinfos_key();
std::ostream& out = k.out();
if(k.object_class()!=TList_cls()) {
out << "tools::rroot::read_sinfos :"
<< " key not a TList."
<< std::endl;
return false;
}
unsigned int sz;
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;
}
buffer b(out,a_file.byte_swap(),sz,buf,k.key_length(),false);
dummy_fac fac(out);
obj_list infos(fac);
if(!infos.stream(b)) return false;
tools_vforcit(iro*,infos,it) {
streamer_info* info = safe_cast<iro,streamer_info>(*(*it));
if(!info) return false;
info->out(out);
}
return true;
}
*/
}}
#endif
-39
View File
@@ -41,14 +41,8 @@ public:
,m_branches(a_fac)
,m_entries(0)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~tree(){
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
tree(const tree& a_from)
@@ -128,25 +122,10 @@ public:
uint64 entries() const {return m_entries;}
virtual bool stream(buffer& a_buffer) { //virtual for iobject.
//uint64 m_tot_bytes;
//uint64 m_zip_bytes;
//uint64 m_saved_bytes;
short vers;
unsigned int _s,_c;
if(!a_buffer.read_version(vers,_s,_c)) return false;
//::printf("debug : tree::stream : version %d count %d\n",vers,c);
//if (vers > 4) {
//TTree::Class()->ReadBuffer(b, this, vers, s, c);
//if (fEstimate <= 10000) fEstimate = 1000000;
//m_saved_bytes = m_tot_bytes;
//fDirectory = gDirectory;
//gDirectory->Append(this);
//return;
//}
if(!Named_stream(a_buffer,m_name,m_title)) return false;
{short color,style,width;
@@ -167,11 +146,9 @@ public:
m_entries = uint64(v);}
{double v;
if(!a_buffer.read(v)) return false;
//m_tot_bytes = uint64(v);
}
{double v;
if(!a_buffer.read(v)) return false;
//m_zip_bytes = uint64(v);
}
{int fAutoSave;
if(!a_buffer.read(fAutoSave)) return false;}
@@ -183,15 +160,12 @@ public:
m_entries = uint64(v);}
{double v;
if(!a_buffer.read(v)) return false;
//m_tot_bytes = uint64(v);
}
{double v;
if(!a_buffer.read(v)) return false;
//m_zip_bytes = uint64(v);
}
{double v;
if(!a_buffer.read(v)) return false;
//m_saved_bytes = uint64(v);
}
int dummy_int;
@@ -215,15 +189,12 @@ public:
m_entries = uint64(v);}
{double v;
if(!a_buffer.read(v)) return false;
//m_tot_bytes = uint64(v);
}
{double v;
if(!a_buffer.read(v)) return false;
//m_zip_bytes = uint64(v);
}
{double v;
if(!a_buffer.read(v)) return false;
//m_saved_bytes = uint64(v);
}
if(!a_buffer.read(dummy_double)) return false; //fWeight
if(!a_buffer.read(dummy_int)) return false; //fTimerInterval
@@ -247,15 +218,12 @@ public:
m_entries = v;}
{uint64 v;
if(!a_buffer.read(v)) return false;
//m_tot_bytes = v;
}
{uint64 v;
if(!a_buffer.read(v)) return false;
//m_zip_bytes = v;
}
{uint64 v;
if(!a_buffer.read(v)) return false;
//m_saved_bytes = v;
}
if(vers>=18) {
if(!a_buffer.read(dummy_int64)) return false; //fFlushedBytes
@@ -304,7 +272,6 @@ public:
//TObjArray
//The below m_branches.read will create leaves.
//::printf("debug : tree : read branches : begin\n");
{ifac::args args;
if(!m_branches.stream(a_buffer,args)) {
m_out << "tools::rroot::tree::stream : "
@@ -312,24 +279,19 @@ public:
<< std::endl;
return false;
}}
//::printf("debug : tree : read branches : end\n");
//TObjArray
// We read leaves in order to keep streaming synchronisation.
// In fact m_leaves are references to existing leaves read by
// the branches in the upper line of code.
//::printf("debug : tree : read leaves : begin\n");
{obj_array<base_leaf> m_leaves(m_fac);
//branch b(m_out,m_fac);
ifac::args args;
//args[ifac::arg_branch()] = &b;
if(!m_leaves.stream(a_buffer,args)) {
m_out << "tools::rroot::tree::stream : "
<< "can't read leaves."
<< std::endl;
return false;
}}
//::printf("debug : tree : read leaves : end\n");
if(vers>=10) {
//TList* fAliases
@@ -341,7 +303,6 @@ public:
}
}
//m_saved_bytes = m_tot_bytes;
{std::vector<double> v;
if(!Array_stream<double>(a_buffer,v)) return false;} //fIndexValues TArrayD
-12
View File
@@ -39,19 +39,15 @@ public:
unsigned int _s,_c;
short v;
if(!a_buffer.read_version(v,_s,_c)) return false;
//::printf("debug : tree_index::stream : version %d count %d\n",v,c);
if(!virtual_index_stream(a_buffer)) return false;
std::string ds;
if(!a_buffer.read(ds)) return false; //fMajorName
//::printf("debug : tree_index::stream : fMajorName \"%s\"\n",ds.c_str());
if(!a_buffer.read(ds)) return false; //fMinorName
//::printf("debug : tree_index::stream : fMinorName \"%s\"\n",ds.c_str());
int64 m_n;
if(!a_buffer.read(m_n)) return false; //fN
//::printf("debug : tree_index::stream : fN %ld\n",m_n);
if(!dummy_array_stream<int64>(a_buffer,int(m_n))) return false;
if(!dummy_array_stream<int64>(a_buffer,int(m_n))) return false;
@@ -62,21 +58,14 @@ public:
if(!a_buffer.check_byte_count(_s,_c,s_store_class())) return false;
//::printf("debug : tree_index::stream : ok\n");
return true;
}
public:
tree_index()
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~tree_index(){
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
protected:
tree_index(const tree_index& a_from):iro(a_from){}
@@ -90,7 +79,6 @@ protected:
short v;
unsigned int _s,_c;
if(!a_buffer.read_version(v,_s,_c)) return false;
//::printf("debug : virtual_index::stream : version %d count %d\n",v,c);
std::string ds;
if(!Named_stream(a_buffer,ds,ds)) return false;
if(!a_buffer.check_byte_count(_s,_c,virtual_index_s_store_class()))
-8
View File
@@ -42,8 +42,6 @@ public:
short v;
if(!a_buffer.read_version(v,_s,_c)) return false;
//printf("debug : tools::rroot::vector3::stream : version %d\n",v);
{uint32 id,bits;
if(!Object_stream(a_buffer,id,bits)) return false;}
@@ -57,14 +55,8 @@ public:
public:
vector3():m_x(0),m_y(0),m_z(0){
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
}
virtual ~vector3(){
#ifdef TOOLS_MEM
mem::decrement(s_class().c_str());
#endif
}
public:
vector3(const vector3& a_from)