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
+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;