Import Geant4 10.2.0 source tree
This commit is contained in:
@@ -31,9 +31,7 @@ class buffer {
|
||||
return s_v;
|
||||
}
|
||||
public:
|
||||
buffer(std::ostream& a_out,
|
||||
bool a_byte_swap,
|
||||
uint32 a_size) // we expect a not zero value.
|
||||
buffer(std::ostream& a_out,bool a_byte_swap,uint32 a_size) // we expect a not zero value for a_size.
|
||||
:m_out(a_out)
|
||||
,m_byte_swap(a_byte_swap)
|
||||
,m_size(0)
|
||||
@@ -87,7 +85,7 @@ public:
|
||||
|
||||
char* buf() {return m_buffer;}
|
||||
const char* buf() const {return m_buffer;}
|
||||
uint32 length() const {return m_pos-m_buffer;}
|
||||
uint32 length() const {return uint32(m_pos-m_buffer);}
|
||||
uint32 size() const {return m_size;}
|
||||
|
||||
char*& pos() {return m_pos;} //used in basket.
|
||||
@@ -278,7 +276,7 @@ public:
|
||||
bool expand2(uint32 a_new_size) {return expand(mx<uint32>(2*m_size,a_new_size));} //CERN-ROOT logic.
|
||||
|
||||
bool expand(uint32 a_new_size) {
|
||||
unsigned long len = m_pos-m_buffer;
|
||||
diff_pointer_t len = m_pos-m_buffer;
|
||||
if(!realloc<char>(m_buffer,a_new_size,m_size)) {
|
||||
m_out << "tools::wroot::buffer::expand :"
|
||||
<< " can't realloc " << a_new_size << " bytes."
|
||||
@@ -388,9 +386,6 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
static std::string sout(const std::string& a_string) {
|
||||
return std::string("\"")+a_string+"\"";
|
||||
}
|
||||
protected:
|
||||
std::ostream& m_out;
|
||||
bool m_byte_swap;
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
#ifndef tools_wroot_date
|
||||
#define tools_wroot_date
|
||||
|
||||
//WIN32 : localtime_r() does not exist on Windows and we can't use the
|
||||
// Windows ::GetLocalTime() since G4 do not want to include windows.h.
|
||||
// Then we stay with the not thread safe localtime().
|
||||
//_MSC_VER (= Microsoft VisualC++) :
|
||||
// localtime_r() does not exist on Windows and we can't use the
|
||||
// Windows ::GetLocalTime() since G4 do not want to include windows.h.
|
||||
// Then we stay with the not thread safe localtime().
|
||||
|
||||
#include <time.h>
|
||||
|
||||
@@ -21,7 +22,7 @@ inline date get_date(){
|
||||
// Date is stored with the origin being the 1st january 1995.
|
||||
// Time has 1 second precision.
|
||||
time_t tloc = ::time(0);
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER
|
||||
struct tm *tp = (tm*)::localtime(&tloc); //not thread safe (but exist on Windows).
|
||||
#else
|
||||
struct tm tpa;
|
||||
|
||||
@@ -289,8 +289,8 @@ public:
|
||||
if(m_file.verbose()) {
|
||||
m_file.out() << "tools::wroot::directory::write :"
|
||||
<< " " << sout(m_name)
|
||||
<< " : " << long2s(m_dirs.size())
|
||||
<< " : " << long2s(m_objs.size())
|
||||
<< " : " << long_out(m_dirs.size())
|
||||
<< " : " << long_out(m_objs.size())
|
||||
<< " objects."
|
||||
<< std::endl;
|
||||
}
|
||||
@@ -546,10 +546,6 @@ protected:
|
||||
return key->write_file(a_nbytes);
|
||||
}
|
||||
|
||||
protected:
|
||||
static std::string sout(const std::string& a_string) {
|
||||
return std::string("\"")+a_string+"\"";
|
||||
}
|
||||
protected:
|
||||
ifile& m_file;
|
||||
directory* m_parent;
|
||||
|
||||
@@ -38,6 +38,16 @@ namespace streamer_info {
|
||||
TOBJECT = 66, // 12
|
||||
TNAMED = 67 // 28
|
||||
};
|
||||
|
||||
const int size_FLOAT = 4;
|
||||
const int size_DOUBLE = 8;
|
||||
const int size_INT = 4;
|
||||
const int size_UINT = 4;
|
||||
const int size_SHORT = 2;
|
||||
const int size_BOOL = 4; //(Bool_t = 1 + 3 for alignement)
|
||||
//uuu ? const int size_BOOL = 1;
|
||||
|
||||
const int size_TString = 8;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,9 +78,10 @@ public:
|
||||
virtual streamer_element* copy() const = 0;
|
||||
public:
|
||||
virtual void out(std::ostream& aOut) const {
|
||||
char s[128];
|
||||
snpf(s,sizeof(s)," %-14s%-15s offset=%3d type=%2d %-20s",
|
||||
fTypeName.c_str(),fullName().c_str(),fOffset,fType,fTitle.c_str());
|
||||
std::string _fname;
|
||||
fullName(_fname);
|
||||
char s[256];
|
||||
snpf(s,sizeof(s)," %-14s%-15s offset=%3d type=%2d %-20s",fTypeName.c_str(),_fname.c_str(),fOffset,fType,fTitle.c_str());
|
||||
aOut << s << std::endl;
|
||||
}
|
||||
public:
|
||||
@@ -128,14 +139,13 @@ public:
|
||||
else fArrayLength *= aMaximum;
|
||||
}
|
||||
|
||||
virtual std::string fullName() const {
|
||||
std::string s = fName;
|
||||
virtual void fullName(std::string& a_s) const {
|
||||
a_s = fName;
|
||||
for (int i=0;i<fArrayDim;i++) {
|
||||
char cdim[32];
|
||||
snpf(cdim,sizeof(cdim),"[%d]",fMaxIndex[i]);
|
||||
s += cdim;
|
||||
a_s += cdim;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
protected: //Named
|
||||
std::string fName;
|
||||
@@ -205,12 +215,10 @@ public: //ibo
|
||||
return true;
|
||||
}
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {
|
||||
return new streamer_basic_type(*this);
|
||||
}
|
||||
virtual streamer_element* copy() const {return new streamer_basic_type(*this);}
|
||||
public:
|
||||
streamer_basic_type(const std::string& aName,const std::string& aTitle,
|
||||
int aOffset,int aType,const std::string& aTypeName)
|
||||
int aOffset,int aType,const std::string& aTypeName)
|
||||
:streamer_element(aName,aTitle,aOffset,aType,aTypeName)
|
||||
{}
|
||||
virtual ~streamer_basic_type(){}
|
||||
@@ -224,6 +232,132 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class streamer_short : public streamer_basic_type {
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {return new streamer_short(*this);}
|
||||
public:
|
||||
streamer_short(const std::string& aName,const std::string& aTitle,int aOffset)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::SHORT,"Short_t")
|
||||
{}
|
||||
streamer_short(int& aOffset,const std::string& aName,const std::string& aTitle)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::SHORT,"Short_t")
|
||||
{
|
||||
aOffset += streamer_info::size_SHORT;
|
||||
}
|
||||
virtual ~streamer_short(){}
|
||||
public:
|
||||
streamer_short(const streamer_short& a_from):ibo(a_from),streamer_basic_type(a_from){}
|
||||
streamer_short& operator=(const streamer_short& a_from){streamer_basic_type::operator=(a_from);return *this;}
|
||||
};
|
||||
|
||||
class streamer_int : public streamer_basic_type {
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {return new streamer_int(*this);}
|
||||
public:
|
||||
streamer_int(const std::string& aName,const std::string& aTitle,int aOffset)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::INT,"Int_t")
|
||||
{}
|
||||
streamer_int(int& aOffset,const std::string& aName,const std::string& aTitle)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::INT,"Int_t")
|
||||
{
|
||||
aOffset += streamer_info::size_INT;
|
||||
}
|
||||
virtual ~streamer_int(){}
|
||||
public:
|
||||
streamer_int(const streamer_int& a_from):ibo(a_from),streamer_basic_type(a_from){}
|
||||
streamer_int& operator=(const streamer_int& a_from){streamer_basic_type::operator=(a_from);return *this;}
|
||||
};
|
||||
|
||||
class streamer_uint : public streamer_basic_type {
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {return new streamer_uint(*this);}
|
||||
public:
|
||||
streamer_uint(const std::string& aName,const std::string& aTitle,int aOffset)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::UNSIGNED_INT,"UInt_t")
|
||||
{}
|
||||
streamer_uint(int& aOffset,const std::string& aName,const std::string& aTitle)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::UNSIGNED_INT,"UInt_t")
|
||||
{
|
||||
aOffset += streamer_info::size_UINT;
|
||||
}
|
||||
virtual ~streamer_uint(){}
|
||||
public:
|
||||
streamer_uint(const streamer_uint& a_from):ibo(a_from),streamer_basic_type(a_from){}
|
||||
streamer_uint& operator=(const streamer_uint& a_from){streamer_basic_type::operator=(a_from);return *this;}
|
||||
};
|
||||
|
||||
class streamer_float : public streamer_basic_type {
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {return new streamer_float(*this);}
|
||||
public:
|
||||
streamer_float(const std::string& aName,const std::string& aTitle,int aOffset)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::FLOAT,"Float_t")
|
||||
{}
|
||||
streamer_float(int& aOffset,const std::string& aName,const std::string& aTitle)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::FLOAT,"Float_t")
|
||||
{
|
||||
aOffset += streamer_info::size_FLOAT;
|
||||
}
|
||||
virtual ~streamer_float(){}
|
||||
public:
|
||||
streamer_float(const streamer_float& a_from):ibo(a_from),streamer_basic_type(a_from){}
|
||||
streamer_float& operator=(const streamer_float& a_from){streamer_basic_type::operator=(a_from);return *this;}
|
||||
};
|
||||
|
||||
class streamer_double : public streamer_basic_type {
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {return new streamer_double(*this);}
|
||||
public:
|
||||
streamer_double(const std::string& aName,const std::string& aTitle,int aOffset)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::DOUBLE,"Double_t")
|
||||
{}
|
||||
streamer_double(int& aOffset,const std::string& aName,const std::string& aTitle)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::DOUBLE,"Double_t")
|
||||
{
|
||||
aOffset += streamer_info::size_DOUBLE;
|
||||
}
|
||||
virtual ~streamer_double(){}
|
||||
public:
|
||||
streamer_double(const streamer_double& a_from):ibo(a_from),streamer_basic_type(a_from){}
|
||||
streamer_double& operator=(const streamer_double& a_from){streamer_basic_type::operator=(a_from);return *this;}
|
||||
};
|
||||
|
||||
class streamer_stat_t : public streamer_basic_type {
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {return new streamer_stat_t(*this);}
|
||||
public:
|
||||
streamer_stat_t(const std::string& aName,const std::string& aTitle,int aOffset)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::DOUBLE,"Stat_t")
|
||||
{}
|
||||
streamer_stat_t(int& aOffset,const std::string& aName,const std::string& aTitle)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::DOUBLE,"Stat_t")
|
||||
{
|
||||
aOffset += streamer_info::size_DOUBLE;
|
||||
}
|
||||
virtual ~streamer_stat_t(){}
|
||||
public:
|
||||
streamer_stat_t(const streamer_stat_t& a_from):ibo(a_from),streamer_basic_type(a_from){}
|
||||
streamer_stat_t& operator=(const streamer_stat_t& a_from){streamer_basic_type::operator=(a_from);return *this;}
|
||||
};
|
||||
|
||||
class streamer_bool : public streamer_basic_type {
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {return new streamer_bool(*this);}
|
||||
public:
|
||||
streamer_bool(const std::string& aName,const std::string& aTitle,int aOffset)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::UNSIGNED_CHAR,"Bool_t")
|
||||
{}
|
||||
streamer_bool(int& aOffset,const std::string& aName,const std::string& aTitle)
|
||||
:streamer_basic_type(aName,aTitle,aOffset,streamer_info::UNSIGNED_CHAR,"Bool_t")
|
||||
{
|
||||
aOffset += streamer_info::size_BOOL;
|
||||
}
|
||||
virtual ~streamer_bool(){}
|
||||
public:
|
||||
streamer_bool(const streamer_bool& a_from):ibo(a_from),streamer_basic_type(a_from){}
|
||||
streamer_bool& operator=(const streamer_bool& a_from){streamer_basic_type::operator=(a_from);return *this;}
|
||||
};
|
||||
|
||||
class streamer_basic_pointer : public streamer_element {
|
||||
public: //ibo
|
||||
virtual const std::string& store_cls() const {
|
||||
@@ -241,9 +375,7 @@ public: //ibo
|
||||
return true;
|
||||
}
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {
|
||||
return new streamer_basic_pointer(*this);
|
||||
}
|
||||
virtual streamer_element* copy() const {return new streamer_basic_pointer(*this);}
|
||||
public:
|
||||
streamer_basic_pointer(const std::string& aName,const std::string& aTitle,
|
||||
int aOffset,int aType,
|
||||
@@ -292,23 +424,20 @@ public: //ibo
|
||||
return true;
|
||||
}
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {
|
||||
return new streamer_string(*this);
|
||||
}
|
||||
virtual streamer_element* copy() const {return new streamer_string(*this);}
|
||||
public:
|
||||
streamer_string(const std::string& aName,const std::string& aTitle,
|
||||
int aOffset)
|
||||
streamer_string(const std::string& aName,const std::string& aTitle,int aOffset)
|
||||
:streamer_element(aName,aTitle,aOffset,streamer_info::TSTRING,"TString")
|
||||
{}
|
||||
streamer_string(int& aOffset,const std::string& aName,const std::string& aTitle)
|
||||
:streamer_element(aName,aTitle,aOffset,streamer_info::TSTRING,"TString")
|
||||
{
|
||||
aOffset += streamer_info::size_TString;
|
||||
}
|
||||
virtual ~streamer_string(){}
|
||||
public:
|
||||
streamer_string(const streamer_string& a_from)
|
||||
:ibo(a_from),streamer_element(a_from)
|
||||
{}
|
||||
streamer_string& operator=(const streamer_string& a_from){
|
||||
streamer_element::operator=(a_from);
|
||||
return *this;
|
||||
}
|
||||
streamer_string(const streamer_string& a_from):ibo(a_from),streamer_element(a_from){}
|
||||
streamer_string& operator=(const streamer_string& a_from){streamer_element::operator=(a_from);return *this;}
|
||||
};
|
||||
|
||||
|
||||
@@ -326,9 +455,7 @@ public: //ibo
|
||||
return true;
|
||||
}
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {
|
||||
return new streamer_object(*this);
|
||||
}
|
||||
virtual streamer_element* copy() const {return new streamer_object(*this);}
|
||||
public:
|
||||
streamer_object(const std::string& aName,const std::string& aTitle,
|
||||
int aOffset,const std::string& aTypeName)
|
||||
@@ -339,8 +466,7 @@ public:
|
||||
}
|
||||
virtual ~streamer_object(){}
|
||||
public:
|
||||
streamer_object(const streamer_object& a_from)
|
||||
:ibo(a_from),streamer_element(a_from){}
|
||||
streamer_object(const streamer_object& a_from):ibo(a_from),streamer_element(a_from){}
|
||||
streamer_object& operator=(const streamer_object& a_from){
|
||||
streamer_element::operator=(a_from);
|
||||
return *this;
|
||||
@@ -361,20 +487,16 @@ public: //ibo
|
||||
return true;
|
||||
}
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {
|
||||
return new streamer_object_pointer(*this);
|
||||
}
|
||||
virtual streamer_element* copy() const {return new streamer_object_pointer(*this);}
|
||||
public:
|
||||
streamer_object_pointer(const std::string& aName,const std::string& aTitle,
|
||||
int aOffset,const std::string& aTypeName)
|
||||
:streamer_element(aName,aTitle,aOffset,
|
||||
streamer_info::OBJECT_POINTER,aTypeName){
|
||||
int aOffset,const std::string& aTypeName)
|
||||
:streamer_element(aName,aTitle,aOffset,streamer_info::OBJECT_POINTER,aTypeName){
|
||||
if(aTitle.substr(0,2)=="->") fType = streamer_info::OBJECT_ARROW;
|
||||
}
|
||||
virtual ~streamer_object_pointer(){}
|
||||
public:
|
||||
streamer_object_pointer(const streamer_object_pointer& a_from)
|
||||
:ibo(a_from),streamer_element(a_from){}
|
||||
streamer_object_pointer(const streamer_object_pointer& a_from):ibo(a_from),streamer_element(a_from){}
|
||||
streamer_object_pointer& operator=(const streamer_object_pointer& a_from){
|
||||
streamer_element::operator=(a_from);
|
||||
return *this;
|
||||
@@ -395,18 +517,15 @@ public: //ibo
|
||||
return true;
|
||||
}
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {
|
||||
return new streamer_object_any(*this);
|
||||
}
|
||||
virtual streamer_element* copy() const {return new streamer_object_any(*this);}
|
||||
public:
|
||||
streamer_object_any(const std::string& aName,const std::string& aTitle,
|
||||
int aOffset,const std::string& aTypeName)
|
||||
int aOffset,const std::string& aTypeName)
|
||||
:streamer_element(aName,aTitle,aOffset,streamer_info::OBJECT_ANY,aTypeName)
|
||||
{}
|
||||
virtual ~streamer_object_any(){}
|
||||
public:
|
||||
streamer_object_any(const streamer_object_any& a_from)
|
||||
:ibo(a_from),streamer_element(a_from){}
|
||||
streamer_object_any(const streamer_object_any& a_from):ibo(a_from),streamer_element(a_from){}
|
||||
streamer_object_any& operator=(const streamer_object_any& a_from){
|
||||
streamer_element::operator=(a_from);
|
||||
return *this;
|
||||
@@ -430,9 +549,7 @@ public: //ibo
|
||||
return true;
|
||||
}
|
||||
public: //streamer_element
|
||||
virtual streamer_element* copy() const {
|
||||
return new streamer_STL(*this);
|
||||
}
|
||||
virtual streamer_element* copy() const {return new streamer_STL(*this);}
|
||||
protected:
|
||||
enum ESTLtype { kSTL = 300, kSTLstring =365, kSTLvector = 1,
|
||||
kSTLlist = 2, kSTLdeque = 3, kSTLmap = 4,
|
||||
@@ -446,9 +563,9 @@ protected:
|
||||
//};
|
||||
public:
|
||||
streamer_STL(const std::string& aName,const std::string& aTitle,
|
||||
int aOffset,
|
||||
streamer_info::Type aType, //Must match TDataType/EDataType
|
||||
const std::string& aTypeName)
|
||||
int aOffset,
|
||||
streamer_info::Type aType, //Must match TDataType/EDataType
|
||||
const std::string& aTypeName)
|
||||
:streamer_element(aName,aTitle,aOffset,kSTL,aTypeName){
|
||||
fSTLtype = kSTLvector;
|
||||
fCtype = aType;
|
||||
|
||||
@@ -21,13 +21,11 @@
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef __GNUC__
|
||||
#ifdef _MSC_VER
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
// disable the warning about the usage of "this" in the constructor.
|
||||
#pragma warning(disable:4355)
|
||||
#endif
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@@ -45,7 +43,7 @@ class file : public virtual ifile {
|
||||
static uint32 START_BIG_FILE() {return 2000000000;}
|
||||
public: //ifile
|
||||
virtual bool verbose() const {return m_verbose;}
|
||||
virtual std::ostream& out() {return m_out;}
|
||||
virtual std::ostream& out() const {return m_out;}
|
||||
|
||||
virtual bool byte_swap() const {return is_little_endian();}
|
||||
virtual bool set_pos(seek a_offset = 0,from a_from = begin){
|
||||
@@ -64,7 +62,7 @@ public: //ifile
|
||||
|
||||
#if defined(__linux__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 2)
|
||||
if (::lseek64(m_file, a_offset, whence) < 0) {
|
||||
#elif defined(WIN32)
|
||||
#elif defined(_MSC_VER)
|
||||
if (::_lseeki64(m_file, a_offset, whence) < 0) {
|
||||
#else
|
||||
if (::lseek(m_file, a_offset, whence) < 0) {
|
||||
@@ -101,7 +99,7 @@ public: //ifile
|
||||
|
||||
virtual bool write_buffer(const char* a_buffer,uint32 a_length) {
|
||||
// Write a buffer to the file. This is the basic low level write operation.
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER
|
||||
typedef int ssize_t;
|
||||
#endif
|
||||
ssize_t siz;
|
||||
@@ -117,7 +115,7 @@ public: //ifile
|
||||
if(siz!=(ssize_t)a_length) {
|
||||
m_out << "tools::wroot::file::write_buffer :"
|
||||
<< "error writing all requested bytes to file " << sout(m_path)
|
||||
<< ", wrote " << long2s(siz) << " of " << a_length
|
||||
<< ", wrote " << long_out(siz) << " of " << a_length
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
@@ -138,21 +136,28 @@ public: //ifile
|
||||
|
||||
virtual bool synchronize(){
|
||||
// Synchornize a file's in-core and on-disk states.
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER
|
||||
if(::_commit(m_file)) {
|
||||
m_out << "tools::wroot::file::synchronize :"
|
||||
<< " in _commit() for file " << sout(m_path) << "."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
#elif defined(__MINGW32__) || defined(__MINGW64__)
|
||||
return true;
|
||||
#else
|
||||
if (::fsync(m_file) < 0) {
|
||||
m_out << "tools::wroot::file::synchronize :"
|
||||
<< " error flushing file " << sout(m_path) << "."
|
||||
<< " error in fsync() for file " << sout(m_path) << "."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool ziper(char a_key,zip_func& a_func) const {
|
||||
std::map<char,zip_func>::const_iterator it = m_zipers.find(a_key);
|
||||
virtual bool ziper(char a_key,compress_func& a_func) const {
|
||||
std::map<char,compress_func>::const_iterator it = m_zipers.find(a_key);
|
||||
if(it==m_zipers.end()) {
|
||||
a_func = 0;
|
||||
return false;
|
||||
@@ -172,7 +177,7 @@ public: //ifile
|
||||
uint32 nbytes = a_buffer.length();
|
||||
uint32 cxlevel = m_compress;
|
||||
if(cxlevel && (nbytes>256)) {
|
||||
tools::zip_func func;
|
||||
tools::compress_func func;
|
||||
if(!ziper('Z',func)) {
|
||||
//m_out << "tools::wroot::directory::write_object :"
|
||||
// << " zlib ziper not found."
|
||||
@@ -249,7 +254,7 @@ public:
|
||||
}
|
||||
|
||||
m_file = _open(a_path.c_str(),
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER
|
||||
O_RDWR | O_CREAT | O_BINARY,S_IREAD | S_IWRITE
|
||||
#else
|
||||
O_RDWR | O_CREAT,0644
|
||||
@@ -440,8 +445,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool add_ziper(char a_key,zip_func a_func){
|
||||
std::map<char,zip_func>::const_iterator it = m_zipers.find(a_key);
|
||||
bool add_ziper(char a_key,compress_func a_func){
|
||||
std::map<char,compress_func>::const_iterator it = m_zipers.find(a_key);
|
||||
if(it!=m_zipers.end()) {
|
||||
//(*it).second = a_func; //override ?
|
||||
return false;
|
||||
@@ -460,7 +465,7 @@ protected:
|
||||
static bool access_path(const std::string& a_path,EAccessMode a_mode){
|
||||
// Returns true if one can access a file using the specified access mode.
|
||||
// Mode is the same as for the WinNT access(2) function.
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER
|
||||
return (::_access(a_path.c_str(),a_mode) == 0) ? true : false;
|
||||
#else
|
||||
return (::access(a_path.c_str(),a_mode) == 0) ? true : false;
|
||||
@@ -471,7 +476,7 @@ protected:
|
||||
// false in case of failure.
|
||||
struct stat finfo;
|
||||
if (::stat(a_path.c_str(),&finfo) < 0) return false;
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER
|
||||
if (finfo.st_mode & S_IFDIR)
|
||||
return (::_rmdir(a_path.c_str())==-1 ? false : true);
|
||||
else
|
||||
@@ -491,9 +496,6 @@ protected:
|
||||
return ::open(a_name,a_flags,a_mode);
|
||||
#endif
|
||||
}
|
||||
static std::string sout(const std::string& a_string) {
|
||||
return std::string("\"")+a_string+"\"";
|
||||
}
|
||||
bool write_header() {
|
||||
const char root[] = "root";
|
||||
//char psave[kBegin()];
|
||||
@@ -532,7 +534,7 @@ protected:
|
||||
}
|
||||
if(!wb.write(m_nbytes_info)) return false;
|
||||
if(!set_pos()) return false; //BOF
|
||||
uint32 nbytes = pos - psave;
|
||||
uint32 nbytes = uint32(pos - psave);
|
||||
//::printf("debug : write_header : %d\n",nbytes);
|
||||
if(!write_buffer(psave,nbytes)) return false;
|
||||
if(!synchronize()) return false;
|
||||
@@ -692,7 +694,7 @@ protected:
|
||||
}
|
||||
|
||||
static bool zip(std::ostream& a_out,
|
||||
tools::zip_func a_func,
|
||||
tools::compress_func a_func,
|
||||
int a_level,
|
||||
uint32 a_srcsize,char* a_src,
|
||||
uint32 a_tgtsize,char* a_tgt,
|
||||
@@ -770,7 +772,7 @@ protected:
|
||||
//uint64 m_bytes_write; //Number of bytes write in this file
|
||||
std::string m_title; //must be before the below.
|
||||
directory m_root_directory;
|
||||
std::map<char,zip_func> m_zipers;
|
||||
std::map<char,compress_func> m_zipers;
|
||||
std::list<free_seg*> m_free_segs; //Free segments linked list table
|
||||
// begin of record :
|
||||
// "root"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define tools_wroot_ifile
|
||||
|
||||
#include "seek"
|
||||
#include "../zfunc"
|
||||
#include "../press_func"
|
||||
|
||||
namespace tools {
|
||||
namespace wroot {
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
virtual ~ifile(){}
|
||||
public:
|
||||
virtual bool verbose() const = 0;
|
||||
virtual std::ostream& out() = 0;
|
||||
virtual std::ostream& out() const = 0;
|
||||
virtual bool byte_swap() const = 0;
|
||||
enum from {
|
||||
begin,
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
|
||||
virtual bool synchronize() = 0;
|
||||
|
||||
virtual bool ziper(char,zip_func&) const = 0;
|
||||
virtual bool ziper(char,compress_func&) const = 0;
|
||||
|
||||
virtual uint32 compression() const = 0;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,7 @@
|
||||
#include "date"
|
||||
#include "ifile"
|
||||
#include "wbuf"
|
||||
#include "../sout"
|
||||
|
||||
#ifdef TOOLS_MEM
|
||||
#include "../mem"
|
||||
@@ -92,10 +93,7 @@ public:
|
||||
void set_cycle(uint16 a_cycle) {m_cycle = a_cycle;}
|
||||
|
||||
const std::string& object_name() const {return m_object_name;}
|
||||
std::string object_name() {return m_object_name;}
|
||||
|
||||
const std::string& object_class() const {return m_object_class;}
|
||||
std::string object_class() {return m_object_class;}
|
||||
|
||||
bool write_self() {
|
||||
char* buffer = m_buffer;
|
||||
@@ -187,10 +185,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
static std::string sout(const std::string& a_string) {
|
||||
return std::string("\"")+a_string+"\"";
|
||||
}
|
||||
protected:
|
||||
uint32 record_size(uint32 a_version) const {
|
||||
// Return the size in bytes of the key header structure.
|
||||
@@ -222,7 +216,7 @@ protected:
|
||||
m_seek_key = m_file.END();
|
||||
m_file.set_END(m_seek_key+nsize);
|
||||
|
||||
//NOTE : the free segment logic found in ROOT/TKey
|
||||
//NOTE : the free segment logic found in CERN-ROOT/TKey
|
||||
// is not yet needed right now for us, since
|
||||
// we always write at end of file. The update
|
||||
// of the eof free_seg is done in set_END.
|
||||
|
||||
@@ -13,9 +13,7 @@ namespace wroot {
|
||||
|
||||
class member_writer : public virtual iobj_const_visitor {
|
||||
public:
|
||||
virtual bool begin(const istorable&,
|
||||
const std::string&,
|
||||
local_func) {return true;}
|
||||
virtual bool begin(const istorable&,const std::string&,local_func) {return true;}
|
||||
virtual bool end(const istorable&){return true;}
|
||||
|
||||
virtual bool visit(const std::string&,bool a_v){return m_buf.write(a_v);}
|
||||
|
||||
@@ -64,7 +64,7 @@ public: //ibo
|
||||
}
|
||||
public:
|
||||
ObjArray(){}
|
||||
virtual ~ObjArray(){tools::clear<T>(*this);} //WIN32 wants inlib::
|
||||
virtual ~ObjArray(){tools::clear<T>(*this);}
|
||||
public:
|
||||
ObjArray(const ObjArray& a_from): ibo(a_from),std::vector<T*>() {
|
||||
typedef typename std::vector<T*>::const_iterator it_t;
|
||||
@@ -115,7 +115,7 @@ public: //ibo
|
||||
}
|
||||
public:
|
||||
List(){}
|
||||
virtual ~List(){tools::clear<T>(*this);} //WIN32 wants inlib::
|
||||
virtual ~List(){tools::clear<T>(*this);}
|
||||
protected:
|
||||
List(const List& a_from): ibo(a_from),std::vector<T*>(){}
|
||||
List& operator=(const List&){return *this;}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#ifndef tools_wroot_ntuple
|
||||
#define tools_wroot_ntuple
|
||||
|
||||
// An ntuple class to write at the ROOT format.
|
||||
// An ntuple class to write at the CERN-ROOT format.
|
||||
// It inherits wroot::tree and each column is mapped
|
||||
// on a wroot::branch. Each add_row() does a tree::fill().
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace tools {
|
||||
namespace wroot {
|
||||
|
||||
class ntuple : public tree {
|
||||
protected:
|
||||
public:
|
||||
class icol {
|
||||
public:
|
||||
virtual ~icol(){}
|
||||
|
||||
@@ -112,67 +112,67 @@ inline bool List_empty_stream(buffer& a_buffer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class HDATA>
|
||||
inline std::string axis_title(const HDATA& a_data,
|
||||
template <class HIST>
|
||||
inline std::string axis_title(const HIST& a_h,
|
||||
const std::string& a_key) {
|
||||
typedef std::map<std::string,std::string> annotations_t;
|
||||
annotations_t::const_iterator it = a_data.m_annotations.find(a_key);
|
||||
if(it==a_data.m_annotations.end()) return std::string();
|
||||
annotations_t::const_iterator it = a_h.annotations().find(a_key);
|
||||
if(it==a_h.annotations().end()) return std::string();
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
template <class HDATA>
|
||||
template <class HIST>
|
||||
inline bool TH_write_1D(buffer& a_buffer,
|
||||
const HDATA& a_data,
|
||||
const HIST& a_h,
|
||||
const std::string& a_name,
|
||||
const std::vector<double>& a_bin_Sw2) {
|
||||
|
||||
if(!a_buffer.write_version(3)) return false;
|
||||
|
||||
if(!Named_stream(a_buffer,a_name,a_data.m_title)) return false;
|
||||
if(!Named_stream(a_buffer,a_name,a_h.title())) return false;
|
||||
|
||||
if(!AttLine_stream(a_buffer)) return false;
|
||||
if(!AttFill_stream(a_buffer)) return false;
|
||||
if(!AttMarker_stream(a_buffer)) return false;
|
||||
|
||||
if(!a_buffer.write((int)a_data.m_bin_number)) return false;
|
||||
if(!a_buffer.write((int)a_h.get_bins())) return false;
|
||||
|
||||
//fXAxis,fYAxis,fZAxis
|
||||
if(a_data.m_dimension==3) {
|
||||
if(a_h.dimension()==3) {
|
||||
|
||||
{histo::axis<double,unsigned int> haxis(a_data.m_axes[0]);
|
||||
if(!axis_stream(a_buffer,haxis,"xaxis",axis_title(a_data,histo::key_axis_x_title()))) return false;}
|
||||
{histo::axis<double,unsigned int> haxis(a_h.get_axis(0));
|
||||
if(!axis_stream(a_buffer,haxis,"xaxis",axis_title(a_h,histo::key_axis_x_title()))) return false;}
|
||||
|
||||
{histo::axis<double,unsigned int> haxis(a_data.m_axes[1]);
|
||||
if(!axis_stream(a_buffer,haxis,"yaxis",axis_title(a_data,histo::key_axis_y_title()))) return false;}
|
||||
{histo::axis<double,unsigned int> haxis(a_h.get_axis(1));
|
||||
if(!axis_stream(a_buffer,haxis,"yaxis",axis_title(a_h,histo::key_axis_y_title()))) return false;}
|
||||
|
||||
{histo::axis<double,unsigned int> haxis(a_data.m_axes[2]);
|
||||
if(!axis_stream(a_buffer,haxis,"zaxis",axis_title(a_data,histo::key_axis_z_title()))) return false;}
|
||||
{histo::axis<double,unsigned int> haxis(a_h.get_axis(2));
|
||||
if(!axis_stream(a_buffer,haxis,"zaxis",axis_title(a_h,histo::key_axis_z_title()))) return false;}
|
||||
|
||||
} else if(a_data.m_dimension==2) {
|
||||
} else if(a_h.dimension()==2) {
|
||||
|
||||
{histo::axis<double,unsigned int> haxis(a_data.m_axes[0]);
|
||||
if(!axis_stream(a_buffer,haxis,"xaxis",axis_title(a_data,histo::key_axis_x_title()))) return false;}
|
||||
{histo::axis<double,unsigned int> haxis(a_h.get_axis(0));
|
||||
if(!axis_stream(a_buffer,haxis,"xaxis",axis_title(a_h,histo::key_axis_x_title()))) return false;}
|
||||
|
||||
{histo::axis<double,unsigned int> haxis(a_data.m_axes[1]);
|
||||
if(!axis_stream(a_buffer,haxis,"yaxis",axis_title(a_data,histo::key_axis_y_title()))) return false;}
|
||||
{histo::axis<double,unsigned int> haxis(a_h.get_axis(1));
|
||||
if(!axis_stream(a_buffer,haxis,"yaxis",axis_title(a_h,histo::key_axis_y_title()))) return false;}
|
||||
|
||||
{histo::axis<double,unsigned int> dummy;
|
||||
dummy.configure(1,0,1);
|
||||
if(!axis_stream(a_buffer,dummy,"zaxis",axis_title(a_data,histo::key_axis_z_title()))) return false;}
|
||||
if(!axis_stream(a_buffer,dummy,"zaxis",axis_title(a_h,histo::key_axis_z_title()))) return false;}
|
||||
|
||||
} else if(a_data.m_dimension==1) {
|
||||
} else if(a_h.dimension()==1) {
|
||||
|
||||
{histo::axis<double,unsigned int> haxis(a_data.m_axes[0]);
|
||||
if(!axis_stream(a_buffer,haxis,"xaxis",axis_title(a_data,histo::key_axis_x_title()))) return false;}
|
||||
{histo::axis<double,unsigned int> haxis(a_h.get_axis(0));
|
||||
if(!axis_stream(a_buffer,haxis,"xaxis",axis_title(a_h,histo::key_axis_x_title()))) return false;}
|
||||
|
||||
{histo::axis<double,unsigned int> dummy;
|
||||
dummy.configure(1,0,1);
|
||||
if(!axis_stream(a_buffer,dummy,"yaxis",axis_title(a_data,histo::key_axis_y_title()))) return false;}
|
||||
if(!axis_stream(a_buffer,dummy,"yaxis",axis_title(a_h,histo::key_axis_y_title()))) return false;}
|
||||
|
||||
{histo::axis<double,unsigned int> dummy;
|
||||
dummy.configure(1,0,1);
|
||||
if(!axis_stream(a_buffer,dummy,"zaxis",axis_title(a_data,histo::key_axis_z_title()))) return false;}
|
||||
if(!axis_stream(a_buffer,dummy,"zaxis",axis_title(a_h,histo::key_axis_z_title()))) return false;}
|
||||
|
||||
} else {
|
||||
return false;
|
||||
@@ -181,16 +181,16 @@ inline bool TH_write_1D(buffer& a_buffer,
|
||||
if(!a_buffer.write((short)(1000 * 0.25))) return false; //fBarOffset
|
||||
if(!a_buffer.write((short)(1000 * 0.5))) return false; //fBarWidth
|
||||
|
||||
if(!a_buffer.write((double)a_data.m_all_entries)) return false;
|
||||
if(!a_buffer.write((double)a_data.m_in_range_Sw)) return false; //enforce double in case h1df
|
||||
if(!a_buffer.write((double)a_data.m_in_range_Sw2)) return false; //idem
|
||||
if(!a_buffer.write((double)a_h.all_entries())) return false;
|
||||
if(!a_buffer.write((double)a_h.get_in_range_Sw())) return false; //enforce double in case h1df
|
||||
if(!a_buffer.write((double)a_h.get_in_range_Sw2())) return false; //idem
|
||||
|
||||
{double value;
|
||||
a_data.get_ith_axis_Sxw(0,value);
|
||||
a_h.get_ith_axis_Sxw(0,value);
|
||||
if(!a_buffer.write(value)) return false;}
|
||||
|
||||
{double value;
|
||||
a_data.get_ith_axis_Sx2w(0,value);
|
||||
a_h.get_ith_axis_Sx2w(0,value);
|
||||
if(!a_buffer.write(value)) return false;}
|
||||
|
||||
if(!a_buffer.write((double)-1111)) return false; //fMaximum
|
||||
@@ -202,68 +202,66 @@ inline bool TH_write_1D(buffer& a_buffer,
|
||||
if(!a_buffer.write_array(a_bin_Sw2)) return false; //fSumw2 TArrayD
|
||||
|
||||
// store annotation on fOption
|
||||
// but try to fool ROOT in order that it does not
|
||||
// understand fOption as.. ROOT options !
|
||||
// but try to fool CERN-ROOT in order that it does not
|
||||
// understand fOption as.. CERN-ROOT options !
|
||||
//{std::string opt = " "+fAnnotation;
|
||||
// opt[0] = 0; //awfull trick
|
||||
// if(!a_buffer.write(opt)) return false;} //TString fOption
|
||||
{std::string opt;
|
||||
if(!a_buffer.write(opt)) return false;} //TString fOption
|
||||
|
||||
if(!List_empty_stream(a_buffer)) return false; //Functions
|
||||
if(!List_empty_stream(a_buffer)) return false; //*TList fFunctions
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class HDATA>
|
||||
template <class HIST>
|
||||
inline bool TH_write_2D(buffer& a_buffer,
|
||||
const HDATA& a_data,
|
||||
const HIST& a_h,
|
||||
const std::string& a_name,
|
||||
const std::vector<double>& a_bin_Sw2) {
|
||||
if(!a_buffer.write_version(3)) return false;
|
||||
if(!TH_write_1D(a_buffer,a_data,a_name,a_bin_Sw2)) return false;
|
||||
if(!TH_write_1D(a_buffer,a_h,a_name,a_bin_Sw2)) return false;
|
||||
if(!a_buffer.write((double)1)) return false; //ScaleFactor
|
||||
|
||||
{double value;
|
||||
a_data.get_ith_axis_Sxw(1,value);
|
||||
a_h.get_ith_axis_Sxw(1,value);
|
||||
if(!a_buffer.write(value)) return false;}
|
||||
|
||||
{double value;
|
||||
a_data.get_ith_axis_Sx2w(1,value);
|
||||
a_h.get_ith_axis_Sx2w(1,value);
|
||||
if(!a_buffer.write(value)) return false;}
|
||||
|
||||
if(!a_buffer.write((double)0)) return false; //Tsumwxy //FIXME.
|
||||
if(!a_buffer.write((double)a_h.Sxyw())) return false; //Tsumwxy
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class HDATA>
|
||||
template <class HIST>
|
||||
inline bool TH_write_3D(buffer& a_buffer,
|
||||
const HDATA& a_data,
|
||||
const HIST& a_h,
|
||||
const std::string& a_name,
|
||||
const std::vector<double>& a_bin_Sw2) {
|
||||
if(!a_buffer.write_version(4)) return false;
|
||||
if(!TH_write_1D(a_buffer,a_data,a_name,a_bin_Sw2)) return false;
|
||||
if(!TH_write_1D(a_buffer,a_h,a_name,a_bin_Sw2)) return false;
|
||||
if(!Att3D_stream(a_buffer)) return false;
|
||||
|
||||
{double value;
|
||||
a_data.get_ith_axis_Sxw(1,value);
|
||||
a_h.get_ith_axis_Sxw(1,value);
|
||||
if(!a_buffer.write(value)) return false;} //Tsumwy : Total Sum of weight*Y
|
||||
{double value;
|
||||
a_data.get_ith_axis_Sx2w(1,value);
|
||||
a_h.get_ith_axis_Sx2w(1,value);
|
||||
if(!a_buffer.write(value)) return false;} //Tsumwy2 : Total Sum of weight*Y*Y
|
||||
//FIXME
|
||||
if(!a_buffer.write((double)0)) return false; //Tsumwxy : Total Sum of weight*X*Y
|
||||
if(!a_buffer.write((double)a_h.Sxyw())) return false; //Tsumwxy : Total Sum of weight*X*Y
|
||||
|
||||
{double value;
|
||||
a_data.get_ith_axis_Sxw(2,value);
|
||||
a_h.get_ith_axis_Sxw(2,value);
|
||||
if(!a_buffer.write(value)) return false;} //Tsumwz : Total Sum of weight*Z
|
||||
{double value;
|
||||
a_data.get_ith_axis_Sx2w(2,value);
|
||||
a_h.get_ith_axis_Sx2w(2,value);
|
||||
if(!a_buffer.write(value)) return false;} //Tsumwz2 : Total Sum of weight*Z*Z
|
||||
//FIXME
|
||||
if(!a_buffer.write((double)0)) return false; //Tsumwxz : Total Sum of weight*X*Z
|
||||
if(!a_buffer.write((double)0)) return false; //Tsumwyz : Total Sum of weight*Y*Z
|
||||
if(!a_buffer.write((double)a_h.Szxw())) return false; //Tsumwxz : Total Sum of weight*X*Z
|
||||
if(!a_buffer.write((double)a_h.Syzw())) return false; //Tsumwyz : Total Sum of weight*Y*Z
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -272,8 +270,8 @@ inline bool TH1F_stream(buffer& a_buffer,
|
||||
const histo::h1df& a_h,
|
||||
const std::string& a_name) {
|
||||
if(!a_buffer.write_version(1)) return false;
|
||||
if(!TH_write_1D(a_buffer,a_h,a_name,convert<float,double>(a_h.m_bin_Sw2))) return false;
|
||||
if(!a_buffer.write_array(a_h.m_bin_Sw)) return false;
|
||||
if(!TH_write_1D(a_buffer,a_h,a_name,convert<float,double>(a_h.bins_sum_w2()))) return false;
|
||||
if(!a_buffer.write_array(a_h.bins_sum_w())) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -281,8 +279,8 @@ inline bool TH1F_stream(buffer& a_buffer,
|
||||
const histo::h1d& a_h,
|
||||
const std::string& a_name) {
|
||||
if(!a_buffer.write_version(1)) return false;
|
||||
if(!TH_write_1D(a_buffer,a_h,a_name,a_h.m_bin_Sw2)) return false;
|
||||
if(!a_buffer.write_array(convert<double,float>(a_h.m_bin_Sw))) return false;
|
||||
if(!TH_write_1D(a_buffer,a_h,a_name,a_h.bins_sum_w2())) return false;
|
||||
if(!a_buffer.write_array(convert<double,float>(a_h.bins_sum_w()))) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -290,8 +288,8 @@ inline bool TH1D_stream(buffer& a_buffer,
|
||||
const histo::h1d& a_h,
|
||||
const std::string& a_name) {
|
||||
if(!a_buffer.write_version(1)) return false;
|
||||
if(!TH_write_1D(a_buffer,a_h,a_name,a_h.m_bin_Sw2)) return false;
|
||||
if(!a_buffer.write_array(a_h.m_bin_Sw)) return false; //fArray TArrayD
|
||||
if(!TH_write_1D(a_buffer,a_h,a_name,a_h.bins_sum_w2())) return false;
|
||||
if(!a_buffer.write_array(a_h.bins_sum_w())) return false; //fArray TArrayD
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -299,8 +297,8 @@ inline bool TH2F_stream(buffer& a_buffer,
|
||||
const histo::h2d& a_h,
|
||||
const std::string& a_name){
|
||||
if(!a_buffer.write_version(3)) return false;
|
||||
if(!TH_write_2D(a_buffer,a_h,a_name,a_h.m_bin_Sw2)) return false;
|
||||
if(!a_buffer.write_array(convert<double,float>(a_h.m_bin_Sw))) return false; //fArray TArrayF
|
||||
if(!TH_write_2D(a_buffer,a_h,a_name,a_h.bins_sum_w2())) return false;
|
||||
if(!a_buffer.write_array(convert<double,float>(a_h.bins_sum_w()))) return false; //fArray TArrayF
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -308,8 +306,8 @@ inline bool TH2F_stream(buffer& a_buffer,
|
||||
const histo::h2df& a_h,
|
||||
const std::string& a_name){
|
||||
if(!a_buffer.write_version(3)) return false;
|
||||
if(!TH_write_2D(a_buffer,a_h,a_name,convert<float,double>(a_h.m_bin_Sw2))) return false;
|
||||
if(!a_buffer.write_array(a_h.m_bin_Sw)) return false;
|
||||
if(!TH_write_2D(a_buffer,a_h,a_name,convert<float,double>(a_h.bins_sum_w2()))) return false;
|
||||
if(!a_buffer.write_array(a_h.bins_sum_w())) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -317,70 +315,62 @@ inline bool TH2D_stream(buffer& a_buffer,
|
||||
const histo::h2d& a_h,
|
||||
const std::string& a_name){
|
||||
if(!a_buffer.write_version(3)) return false;
|
||||
if(!TH_write_2D(a_buffer,a_h,a_name,a_h.m_bin_Sw2)) return false;
|
||||
if(!a_buffer.write_array(a_h.m_bin_Sw)) return false; //fArray TArrayD
|
||||
if(!TH_write_2D(a_buffer,a_h,a_name,a_h.bins_sum_w2())) return false;
|
||||
if(!a_buffer.write_array(a_h.bins_sum_w())) return false; //fArray TArrayD
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool TH3F_stream(buffer& a_buffer,const histo::h3d& a_h,const std::string& a_name){
|
||||
if(!a_buffer.write_version(3)) return false;
|
||||
if(!TH_write_3D(a_buffer,a_h,a_name,a_h.m_bin_Sw2)) return false;
|
||||
if(!a_buffer.write_array(convert<double,float>(a_h.m_bin_Sw))) return false; //fArray TArrayF
|
||||
if(!TH_write_3D(a_buffer,a_h,a_name,a_h.bins_sum_w2())) return false;
|
||||
if(!a_buffer.write_array(convert<double,float>(a_h.bins_sum_w()))) return false; //fArray TArrayF
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool TH3F_stream(buffer& a_buffer,const histo::h3df& a_h,const std::string& a_name){
|
||||
if(!a_buffer.write_version(3)) return false;
|
||||
if(!TH_write_3D(a_buffer,a_h,a_name,convert<float,double>(a_h.m_bin_Sw2))) return false;
|
||||
if(!a_buffer.write_array(a_h.m_bin_Sw)) return false; //fArray TArrayF
|
||||
if(!TH_write_3D(a_buffer,a_h,a_name,convert<float,double>(a_h.bins_sum_w2()))) return false;
|
||||
if(!a_buffer.write_array(a_h.bins_sum_w())) return false; //fArray TArrayF
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool TH3D_stream(buffer& a_buffer,const histo::h3d& a_h,const std::string& a_name){
|
||||
if(!a_buffer.write_version(3)) return false;
|
||||
if(!TH_write_3D(a_buffer,a_h,a_name,a_h.m_bin_Sw2)) return false;
|
||||
if(!a_buffer.write_array(a_h.m_bin_Sw)) return false; //fArray TArrayD
|
||||
if(!TH_write_3D(a_buffer,a_h,a_name,a_h.bins_sum_w2())) return false;
|
||||
if(!a_buffer.write_array(a_h.bins_sum_w())) return false; //fArray TArrayD
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool TProfile_stream(buffer& a_buffer,
|
||||
const histo::p1d& a_p,
|
||||
const std::string& a_name){
|
||||
if(!a_buffer.write_version(4)) return false;
|
||||
inline bool TProfile_stream(buffer& a_buffer,const histo::p1d& a_p,const std::string& a_name){
|
||||
if(!a_buffer.write_version(4)) return false;
|
||||
|
||||
//WARNING : the mapping histo::p1d / TProfile is not obvious.
|
||||
//p1d::m_bin_Svw <---> TProfile::fArray
|
||||
//p1d::m_bin_Sv2w <---> TProfile::fSumw2
|
||||
//p1d::m_bin_Sw <---> TProfile::fBinEntries
|
||||
//WARNING : the mapping histo::p1d / TProfile is not obvious.
|
||||
//p1d::m_bin_Svw <---> TProfile::fArray
|
||||
//p1d::m_bin_Sv2w <---> TProfile::fSumw2
|
||||
//p1d::m_bin_Sw <---> TProfile::fBinEntries
|
||||
|
||||
double Svw = a_p.get_Svw();
|
||||
double Sv2w = a_p.get_Sv2w();
|
||||
// TH1D_stream(a_buffer,h,a_name) :
|
||||
//if(!a_buffer.write_version(1)) return false;
|
||||
//if(!TH_write_1D(a_buffer,a_h,a_name,a_h.bins_sum_w2())) return false; //fSumw2 TArrayD
|
||||
//if(!a_buffer.write_array(a_h.bins_sum_w())) return false; //fArray TArrayD
|
||||
// but for profile :
|
||||
if(!a_buffer.write_version(1)) return false;
|
||||
if(!TH_write_1D(a_buffer,a_p,a_name,a_p.bins_sum_v2w())) return false; //fSumw2 TArrayD
|
||||
if(!a_buffer.write_array(a_p.bins_sum_vw())) return false; //fArray TArrayD
|
||||
|
||||
pd_data data = a_p.get_histo_data();
|
||||
//NOTE : histo.m_bin_Sw <---> TH1D::TArrayD::fArray
|
||||
// then have to copy histo.m_bin_Svw on histo.m_bin_Sw
|
||||
// before streaming.
|
||||
//TProfile specific :
|
||||
if(!a_buffer.write_array(a_p.bins_sum_w())) return false; //fBinEntries TArrayD
|
||||
|
||||
std::vector<double> vbins = data.m_bin_Sw;
|
||||
data.m_bin_Sw = data.m_bin_Svw;
|
||||
int errorMode = 0;
|
||||
if(!a_buffer.write(errorMode)) return false;
|
||||
if(!a_buffer.write(a_p.min_v())) return false;
|
||||
if(!a_buffer.write(a_p.max_v())) return false;
|
||||
|
||||
histo::h1d h("",10,0,1);
|
||||
h.copy_from_data(data);
|
||||
if(!TH1D_stream(a_buffer,h,a_name)) return false;
|
||||
// version 4 :
|
||||
if(!a_buffer.write(a_p.get_Svw())) return false; //Double_t fTsumwy; //Total Sum of weight*Y
|
||||
if(!a_buffer.write(a_p.get_Sv2w())) return false; //Double_t fTsumwy2; //Total Sum of weight*Y*Y
|
||||
|
||||
//TProfile specific :
|
||||
if(!a_buffer.write_array(vbins)) return false; //fBinEntries TArrayD
|
||||
|
||||
int errorMode = 0;
|
||||
if(!a_buffer.write(errorMode)) return false;
|
||||
if(!a_buffer.write(data.m_min_v)) return false;
|
||||
if(!a_buffer.write(data.m_max_v)) return false;
|
||||
|
||||
// version 4 :
|
||||
if(!a_buffer.write(Svw)) return false; //Double_t fTsumwy; //Total Sum of weight*Y
|
||||
if(!a_buffer.write(Sv2w)) return false; //Double_t fTsumwy2; //Total Sum of weight*Y*Y
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool TProfile2D_stream(buffer& a_buffer,const histo::p2d& a_p,const std::string& a_name){
|
||||
@@ -391,32 +381,26 @@ inline bool TProfile2D_stream(buffer& a_buffer,const histo::p2d& a_p,const std::
|
||||
//p2d::m_bin_Sv2w <---> TProfile2D::fSumw2
|
||||
//p2d::m_bin_Sw <---> TProfile2D::fBinEntries
|
||||
|
||||
double Svw = a_p.get_Svw();
|
||||
double Sv2w = a_p.get_Sv2w();
|
||||
|
||||
pd_data data = a_p.get_histo_data();
|
||||
//NOTE : histo.m_bin_Sw <---> TH2D::TArrayD::fArray
|
||||
// then have to copy histo.m_bin_Svw on histo.m_bin_Sw
|
||||
// before streaming.
|
||||
|
||||
std::vector<double> vbins = data.m_bin_Sw;
|
||||
data.m_bin_Sw = data.m_bin_Svw;
|
||||
|
||||
histo::h2d h("",10,0,1,10,0,1);
|
||||
h.copy_from_data(data);
|
||||
if(!TH2D_stream(a_buffer,h,a_name)) return false;
|
||||
// TH2D_stream(a_buffer,h,a_name) :
|
||||
//if(!a_buffer.write_version(3)) return false;
|
||||
//if(!TH_write_2D(a_buffer,a_h,a_name,a_h.bins_sum_w2())) return false; //fSumw2 TArrayD
|
||||
//if(!a_buffer.write_array(a_h.bins_sum_w())) return false; //fArray TArrayD
|
||||
// for profile :
|
||||
if(!a_buffer.write_version(3)) return false;
|
||||
if(!TH_write_2D(a_buffer,a_p,a_name,a_p.bins_sum_v2w())) return false; //fSumw2 TArrayD
|
||||
if(!a_buffer.write_array(a_p.bins_sum_vw())) return false; //fArray TArrayD
|
||||
|
||||
//TProfile2D specific :
|
||||
if(!a_buffer.write_array(vbins)) return false; //fBinEntries TArrayD
|
||||
if(!a_buffer.write_array(a_p.bins_sum_w())) return false; //fBinEntries TArrayD
|
||||
|
||||
int errorMode = 0;
|
||||
if(!a_buffer.write(errorMode)) return false; //fErrorMode
|
||||
if(!a_buffer.write(data.m_min_v)) return false; //fZmin
|
||||
if(!a_buffer.write(data.m_max_v)) return false; //fZmax
|
||||
if(!a_buffer.write(a_p.min_v())) return false; //fZmin
|
||||
if(!a_buffer.write(a_p.max_v())) return false; //fZmax
|
||||
|
||||
// version 5 :
|
||||
if(!a_buffer.write(Svw)) return false; //Double_t fTsumwz; //Total Sum of weight*Z
|
||||
if(!a_buffer.write(Sv2w)) return false; //Double_t fTsumwz2; //Total Sum of weight*Z*Z
|
||||
if(!a_buffer.write(a_p.get_Svw())) return false; //Double_t fTsumwz; //Total Sum of weight*Z
|
||||
if(!a_buffer.write(a_p.get_Sv2w())) return false; //Double_t fTsumwz2; //Total Sum of weight*Z*Z
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -119,6 +119,42 @@ inline bool to(directory& a_dir,const histo::p2d& a_histo,const std::string& a_n
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool write_histos(directory& a_dir,const std::vector< std::pair<std::string,void*> >& a_hists) {
|
||||
typedef std::pair<std::string,void*> class_pointer;
|
||||
|
||||
tools_vforcit(class_pointer,a_hists,it) {
|
||||
const std::string& scls = (*it).first;
|
||||
void* p = (*it).second;
|
||||
if(scls==histo::h1d::s_class()) {
|
||||
histo::h1d& h = *((histo::h1d*)p);
|
||||
if(!to(a_dir,h,h.title())) return false;
|
||||
|
||||
} else if(scls==histo::h2d::s_class()) {
|
||||
histo::h2d& h = *((histo::h2d*)p);
|
||||
if(!to(a_dir,h,h.title())) return false;
|
||||
|
||||
} else if(scls==histo::h3d::s_class()) {
|
||||
histo::h3d& h = *((histo::h3d*)p);
|
||||
if(!to(a_dir,h,h.title())) return false;
|
||||
|
||||
} else if(scls==histo::p1d::s_class()) {
|
||||
histo::p1d& h = *((histo::p1d*)p);
|
||||
if(!to(a_dir,h,h.title())) return false;
|
||||
|
||||
} else if(scls==histo::p2d::s_class()) {
|
||||
histo::p2d& h = *((histo::p2d*)p);
|
||||
if(!to(a_dir,h,h.title())) return false;
|
||||
|
||||
} else {
|
||||
a_dir.file().out() << "tools::wroot::write_histos :"
|
||||
<< " WARNING : class " << scls << " not handled."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#include "member_writer"
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#define tools_wroot_wbuf
|
||||
|
||||
#include <ostream>
|
||||
#include "../pointer"
|
||||
#include "../long_out"
|
||||
#include "../charp_out"
|
||||
#include "../stype"
|
||||
|
||||
#ifdef TOOLS_MEM
|
||||
@@ -236,9 +237,9 @@ protected:
|
||||
bool check_eob(){
|
||||
if((m_pos+sizeof(T))>m_eob) {
|
||||
m_out << s_class() << " : " << stype(T()) << " : "
|
||||
<< " try to access out of buffer " << long2s(sizeof(T)) << " bytes"
|
||||
<< " (pos=" << char_p2s(m_pos)
|
||||
<< ", eob=" << char_p2s(m_eob) << ")." << std::endl;
|
||||
<< " try to access out of buffer " << long_out(sizeof(T)) << " bytes"
|
||||
<< " (pos=" << charp_out(m_pos)
|
||||
<< ", eob=" << charp_out(m_eob) << ")." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -246,13 +247,14 @@ protected:
|
||||
bool check_eob(size_t a_n,const char* a_cmt){
|
||||
if((m_pos+a_n)>m_eob) {
|
||||
m_out << s_class() << " : " << a_cmt << " : "
|
||||
<< " try to access out of buffer " << long2s(a_n) << " bytes"
|
||||
<< " (pos=" << char_p2s(m_pos)
|
||||
<< ", eob=" << char_p2s(m_eob) << ")." << std::endl;
|
||||
<< " try to access out of buffer " << long_out(a_n) << " bytes"
|
||||
<< " (pos=" << charp_out(m_pos)
|
||||
<< ", eob=" << charp_out(m_eob) << ")." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::ostream& m_out;
|
||||
bool m_byte_swap;
|
||||
|
||||
Reference in New Issue
Block a user