Import Geant4 10.3.0 source tree
This commit is contained in:
@@ -17,9 +17,9 @@
|
||||
namespace tools {
|
||||
namespace rroot {
|
||||
|
||||
inline tools::rroot::TDirectory* find_dir(tools::rroot::directory& a_dir,const std::string& a_name) {
|
||||
inline TDirectory* find_dir(directory& a_dir,const std::string& a_name) {
|
||||
std::ostream& out = a_dir.file().out();
|
||||
tools::rroot::key* k = a_dir.find_key(a_name);
|
||||
key* k = a_dir.find_key(a_name);
|
||||
if(!k) {
|
||||
//out << "tools::rroot::find_dir :"
|
||||
// << " " << a_name << " not a key."
|
||||
@@ -27,22 +27,22 @@ inline tools::rroot::TDirectory* find_dir(tools::rroot::directory& a_dir,const s
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(k->object_class()!=tools::rroot::TDirectory_cls()) {
|
||||
if(k->object_class()!=TDirectory_cls()) {
|
||||
out << "tools::rroot::find_dir :"
|
||||
<< " key " << a_name << " not a TDirectory."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
uint32 sz;
|
||||
char* buf = k->get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = k->get_object_buffer(a_dir.file(),sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::find_dir :"
|
||||
<< " can't get directory data buffer."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
tools::rroot::buffer b(out,a_dir.file().byte_swap(),sz,buf,k->key_length(),false);
|
||||
tools::rroot::TDirectory* tdir = new tools::rroot::TDirectory(a_dir.file());
|
||||
buffer b(out,a_dir.file().byte_swap(),sz,buf,k->key_length(),false);
|
||||
TDirectory* tdir = new TDirectory(a_dir.file());
|
||||
if(!tdir) return 0;
|
||||
if(!tdir->stream(b)) {
|
||||
out << "tools::rroot::find_dir :"
|
||||
@@ -53,9 +53,9 @@ inline tools::rroot::TDirectory* find_dir(tools::rroot::directory& a_dir,const s
|
||||
return tdir;
|
||||
}
|
||||
|
||||
inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
inline bool read_key(std::ostream& a_out,ifile& a_file,key& a_key,bool a_dump){
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
@@ -67,10 +67,10 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
// << " get data buffer size " << sz << "."
|
||||
// << std::endl;
|
||||
|
||||
tools::rroot::buffer b(a_out,a_key.file().byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
buffer b(a_out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
|
||||
if(a_key.object_class()==tools::rroot::TH1F_cls()) {
|
||||
tools::histo::h1d* h = tools::rroot::TH1F_stream(b);
|
||||
if(a_key.object_class()==TH1F_cls()) {
|
||||
tools::histo::h1d* h = TH1F_stream(b);
|
||||
if(!h) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TH1F streaming failed"
|
||||
@@ -80,8 +80,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
delete h;
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TH1D_cls()) {
|
||||
tools::histo::h1d* h = tools::rroot::TH1D_stream(b);
|
||||
} else if(a_key.object_class()==TH1D_cls()) {
|
||||
tools::histo::h1d* h = TH1D_stream(b);
|
||||
if(!h) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TH1D streaming failed"
|
||||
@@ -91,8 +91,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
delete h;
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TH2F_cls()) {
|
||||
tools::histo::h2d* h = tools::rroot::TH2F_stream(b);
|
||||
} else if(a_key.object_class()==TH2F_cls()) {
|
||||
tools::histo::h2d* h = TH2F_stream(b);
|
||||
if(!h) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TH2F streaming failed"
|
||||
@@ -102,8 +102,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
delete h;
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TH2D_cls()) {
|
||||
tools::histo::h2d* h = tools::rroot::TH2D_stream(b); //we get ownership of h.
|
||||
} else if(a_key.object_class()==TH2D_cls()) {
|
||||
tools::histo::h2d* h = TH2D_stream(b); //we get ownership of h.
|
||||
if(!h) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TH2D streaming failed"
|
||||
@@ -113,8 +113,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
delete h;
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TH3D_cls()) {
|
||||
tools::histo::h3d* h = tools::rroot::TH3D_stream(b); //we get ownership of h.
|
||||
} else if(a_key.object_class()==TH3D_cls()) {
|
||||
tools::histo::h3d* h = TH3D_stream(b); //we get ownership of h.
|
||||
if(!h) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TH3D streaming failed"
|
||||
@@ -124,8 +124,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
delete h;
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TProfile_cls()) {
|
||||
tools::histo::p1d* p = tools::rroot::TProfile_stream(b);
|
||||
} else if(a_key.object_class()==TProfile_cls()) {
|
||||
tools::histo::p1d* p = TProfile_stream(b);
|
||||
if(!p) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TProfile streaming failed"
|
||||
@@ -135,8 +135,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
delete p;
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TProfile2D_cls()) {
|
||||
tools::histo::p2d* p = tools::rroot::TProfile2D_stream(b);
|
||||
} else if(a_key.object_class()==TProfile2D_cls()) {
|
||||
tools::histo::p2d* p = TProfile2D_stream(b);
|
||||
if(!p) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TProfile2D streaming failed"
|
||||
@@ -148,8 +148,8 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
|
||||
} else if(a_key.object_class()==TTree_cls()) {
|
||||
|
||||
tools::rroot::fac fac(a_key.file());
|
||||
tools::rroot::tree tree(a_key.file(),fac);
|
||||
fac _fac(a_out);
|
||||
tree tree(a_file,_fac);
|
||||
if(!tree.stream(b)) {
|
||||
a_out << "tools::rroot::read_key :"
|
||||
<< " TTree streaming failed"
|
||||
@@ -246,7 +246,7 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
}
|
||||
#endif
|
||||
|
||||
} else if(a_key.object_class()==tools::rroot::TDirectory_cls()) {
|
||||
} else if(a_key.object_class()==TDirectory_cls()) {
|
||||
|
||||
//we should not pass here.
|
||||
|
||||
@@ -259,124 +259,152 @@ inline bool read_key(std::ostream& a_out,tools::rroot::key& a_key,bool a_dump){
|
||||
return true;
|
||||
}
|
||||
|
||||
inline tools::histo::h1d* key_to_h1d(tools::rroot::key& a_key){
|
||||
std::ostream& out = a_key.file().out();
|
||||
if((a_key.object_class()!=tools::rroot::TH1D_cls())&&
|
||||
(a_key.object_class()!=tools::rroot::TH1F_cls())
|
||||
inline tools::histo::h1d* key_to_h1d(ifile& a_file,key& a_key){
|
||||
std::ostream& out = a_key.out();
|
||||
if((a_key.object_class()!=TH1D_cls())&&
|
||||
(a_key.object_class()!=TH1F_cls())
|
||||
) {
|
||||
out << "tools::rroot::from(h1d) :"
|
||||
out << "tools::rroot::key_to_h1d :"
|
||||
<< " key not a TH1D and not a TH1F."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::from(h1d) :"
|
||||
out << "tools::rroot::key_to_h1d :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
tools::rroot::buffer b(out,a_key.file().byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
if(a_key.object_class()==tools::rroot::TH1D_cls()) {
|
||||
return tools::rroot::TH1D_stream(b);
|
||||
buffer b(out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
if(a_key.object_class()==TH1D_cls()) {
|
||||
return TH1D_stream(b);
|
||||
} else {
|
||||
return tools::rroot::TH1F_stream(b);
|
||||
return TH1F_stream(b);
|
||||
}
|
||||
}
|
||||
|
||||
inline tools::histo::h2d* key_to_h2d(tools::rroot::key& a_key){
|
||||
std::ostream& out = a_key.file().out();
|
||||
if(a_key.object_class()!=tools::rroot::TH2D_cls()) {
|
||||
out << "tools::rroot::from(h1d) :"
|
||||
inline tools::histo::h2d* key_to_h2d(ifile& a_file,key& a_key){
|
||||
std::ostream& out = a_key.out();
|
||||
if(a_key.object_class()!=TH2D_cls()) {
|
||||
out << "tools::rroot::key_to_h2d :"
|
||||
<< " key not a TH2D."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::from(h2d) :"
|
||||
out << "tools::rroot::key_to_h2d :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
tools::rroot::buffer b(out,a_key.file().byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return tools::rroot::TH2D_stream(b);
|
||||
buffer b(out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return TH2D_stream(b);
|
||||
}
|
||||
|
||||
inline tools::histo::h3d* key_to_h3d(tools::rroot::key& a_key){
|
||||
std::ostream& out = a_key.file().out();
|
||||
if(a_key.object_class()!=tools::rroot::TH3D_cls()) {
|
||||
out << "tools::rroot::from(h1d) :"
|
||||
inline tools::histo::h3d* key_to_h3d(ifile& a_file,key& a_key){
|
||||
std::ostream& out = a_key.out();
|
||||
if(a_key.object_class()!=TH3D_cls()) {
|
||||
out << "tools::rroot::key_to_h3d :"
|
||||
<< " key not a TH3D."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::from(h3d) :"
|
||||
out << "tools::rroot::key_to_h3d :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
tools::rroot::buffer b(out,a_key.file().byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return tools::rroot::TH3D_stream(b);
|
||||
buffer b(out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return TH3D_stream(b);
|
||||
}
|
||||
|
||||
inline tools::histo::p1d* key_to_p1d(tools::rroot::key& a_key){
|
||||
std::ostream& out = a_key.file().out();
|
||||
if(a_key.object_class()!=tools::rroot::TProfile_cls()) {
|
||||
out << "tools::rroot::from(p1d) :"
|
||||
inline tools::histo::p1d* key_to_p1d(ifile& a_file,key& a_key){
|
||||
std::ostream& out = a_key.out();
|
||||
if(a_key.object_class()!=TProfile_cls()) {
|
||||
out << "tools::rroot::key_to_p1d :"
|
||||
<< " key not a TProfile."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::from(p1d) :"
|
||||
out << "tools::rroot::key_to_p1d :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
tools::rroot::buffer b(out,a_key.file().byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return tools::rroot::TProfile_stream(b);
|
||||
buffer b(out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return TProfile_stream(b);
|
||||
}
|
||||
|
||||
inline tools::histo::p2d* key_to_p2d(tools::rroot::key& a_key){
|
||||
std::ostream& out = a_key.file().out();
|
||||
if(a_key.object_class()!=tools::rroot::TProfile2D_cls()) {
|
||||
out << "tools::rroot::from(p2d) :"
|
||||
inline tools::histo::p2d* key_to_p2d(ifile& a_file,key& a_key){
|
||||
std::ostream& out = a_key.out();
|
||||
if(a_key.object_class()!=TProfile2D_cls()) {
|
||||
out << "tools::rroot::key_to_p2d :"
|
||||
<< " key not a TProfile2D."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(sz); //we don't have ownership of buf.
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::from(p2d) :"
|
||||
out << "tools::rroot::key_to_p2d :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
tools::rroot::buffer b(out,a_key.file().byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return tools::rroot::TProfile2D_stream(b);
|
||||
buffer b(out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
return TProfile2D_stream(b);
|
||||
}
|
||||
|
||||
inline tree* key_to_tree(ifile& a_file,ifac& a_fac,key& a_key) {
|
||||
std::ostream& out = a_key.out();
|
||||
if(a_key.object_class()!=TTree_cls()) {
|
||||
out << "tools::rroot::key_to_tree :"
|
||||
<< " key not a TTree."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
unsigned int sz;
|
||||
char* buf = a_key.get_object_buffer(a_file,sz); //we don't have ownership of buf.
|
||||
if(!buf) {
|
||||
out << "tools::rroot::key_to_tree :"
|
||||
<< " can't get data buffer of " << a_key.object_name() << "."
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
buffer b(out,a_file.byte_swap(),sz,buf,a_key.key_length(),false);
|
||||
tree* _tree = new tree(a_file,a_fac);
|
||||
if(!_tree->stream(b)) {
|
||||
out << "tools::rroot::key_to_tree :"
|
||||
<< " TTree streaming failed"
|
||||
<< std::endl;
|
||||
delete _tree;
|
||||
return 0;
|
||||
}
|
||||
return _tree;
|
||||
}
|
||||
|
||||
inline void read(std::ostream& a_out,
|
||||
tools::rroot::ifile& a_file,
|
||||
const std::vector<tools::rroot::key*>& a_keys,
|
||||
ifile& a_file,
|
||||
const std::vector<key*>& a_keys,
|
||||
bool a_recursive,
|
||||
bool a_ls,
|
||||
bool a_dump,
|
||||
unsigned int a_spaces) {
|
||||
|
||||
{std::vector<tools::rroot::key*>::const_iterator it;
|
||||
{std::vector<key*>::const_iterator it;
|
||||
for(it=a_keys.begin();it!=a_keys.end();++it) {
|
||||
tools::rroot::key& k = *(*it);
|
||||
if(k.object_class()!=tools::rroot::TDirectory_cls()) {
|
||||
key& k = *(*it);
|
||||
if(k.object_class()!=TDirectory_cls()) {
|
||||
if(a_ls||a_dump) {
|
||||
{for(unsigned int index=0;index<a_spaces;index++) a_out << " ";}
|
||||
std::string label = k.object_name();
|
||||
@@ -385,14 +413,14 @@ inline void read(std::ostream& a_out,
|
||||
<< std::endl;
|
||||
//k.dump(a_out);
|
||||
}
|
||||
if(!read_key(a_out,k,a_dump)) return;
|
||||
if(!read_key(a_out,a_file,k,a_dump)) return;
|
||||
}
|
||||
}}
|
||||
|
||||
{std::vector<tools::rroot::key*>::const_iterator it;
|
||||
{std::vector<key*>::const_iterator it;
|
||||
for(it=a_keys.begin();it!=a_keys.end();++it) {
|
||||
tools::rroot::key& k = *(*it);
|
||||
if(k.object_class()==tools::rroot::TDirectory_cls()) {
|
||||
key& k = *(*it);
|
||||
if(k.object_class()==TDirectory_cls()) {
|
||||
|
||||
if(a_ls||a_dump) {
|
||||
{for(unsigned int index=0;index<a_spaces;index++) a_out << " ";}
|
||||
@@ -403,20 +431,20 @@ inline void read(std::ostream& a_out,
|
||||
if(!a_recursive) continue;
|
||||
|
||||
tools::uint32 sz;
|
||||
char* buf = k.get_object_buffer(sz);
|
||||
char* buf = k.get_object_buffer(a_file,sz);
|
||||
if(!buf) {
|
||||
a_out << "read :"
|
||||
<< " can't get directory data buffer."
|
||||
<< std::endl;
|
||||
} else {
|
||||
tools::rroot::buffer b(a_out,a_file.byte_swap(),sz,buf,k.key_length(),false);
|
||||
tools::rroot::TDirectory dir(a_file);
|
||||
buffer b(a_out,a_file.byte_swap(),sz,buf,k.key_length(),false);
|
||||
TDirectory dir(a_file);
|
||||
if(!dir.stream(b)) {
|
||||
a_out << "read :"
|
||||
<< " can't stream TDirectory."
|
||||
<< std::endl;
|
||||
} else {
|
||||
const std::vector<tools::rroot::key*>& keys = dir.keys();
|
||||
const std::vector<key*>& keys = dir.keys();
|
||||
read(a_out,a_file,keys,a_recursive,a_ls,a_dump,a_spaces+1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user