inlib
1.2.0
|
Classes | |
class | base_leaf |
class | basket |
class | branch |
class | branch_element |
class | buffer |
class | directory |
class | dummy |
class | fac |
class | file |
class | graph |
class | ifac |
class | ifile |
class | iro |
class | key |
class | leaf |
class | leaf_string |
class | leaf_element |
class | ObjArray |
class | ntuple |
class | rbuf |
class | dummy_fac |
class | List |
class | TDirectory |
class | tree |
Typedefs | |
typedef unsigned int | date |
typedef inlib::int64 | seek |
typedef int | seek32 |
typedef inlib::histo::histo_data < double, unsigned int, double > | hd_data |
typedef inlib::histo::profile_data < double, unsigned int, double, double > | pd_data |
Functions | |
const std::string & | leaf_store_class (char) |
const std::string & | leaf_store_class (short) |
const std::string & | leaf_store_class (int) |
const std::string & | leaf_store_class (float) |
const std::string & | leaf_store_class (double) |
const std::string & | leaf_float_cls () |
const std::string & | leaf_double_cls () |
const std::string & | leaf_int_cls () |
bool | Object_stream (buffer &a_buffer, uint32 &a_id, uint32 &a_bits) |
bool | Named_stream (buffer &a_buffer, std::string &a_name, std::string &a_title) |
bool | AttLine_stream (buffer &a_buffer) |
bool | AttFill_stream (buffer &a_buffer) |
bool | AttMarker_stream (buffer &a_buffer) |
template<class T > | |
bool | Array_stream (buffer &a_buffer, std::vector< T > &a_v) |
bool | read_key (std::ostream &a_out, inlib::rroot::key &a_key, bool a_dump) |
void | read (std::ostream &a_out, inlib::rroot::ifile &a_file, const std::vector< inlib::rroot::key * > &a_keys, bool a_recursive, bool a_ls, bool a_dump, unsigned int a_spaces) |
bool | AttAxis_stream (buffer &a_buffer) |
bool | Axis_stream (buffer &a_buffer, inlib::histo::axis< double > &a_fAxis) |
bool | null_epsil (double a_1, double a_2, double a_prec=-5) |
bool | TH_read_1D (buffer &a_buffer, hd_data &a_data, double &a_fEntries, double &a_fSw) |
bool | TH_read_2D (buffer &a_buffer, hd_data &a_data, double &a_fEntries, double &a_fSw) |
const std::string & | TH1F_cls () |
inlib::histo::h1d * | TH1F_stream (buffer &a_buffer, bool a_profile=false) |
const std::string & | TH1D_cls () |
inlib::histo::h1d * | TH1D_stream (buffer &a_buffer, bool a_profile=false) |
const std::string & | TH2F_cls () |
inlib::histo::h2d * | TH2F_stream (buffer &a_buffer, bool a_profile=false) |
const std::string & | TH2D_cls () |
inlib::histo::h2d * | TH2D_stream (buffer &a_buffer, bool a_profile=false) |
const std::string & | TProfile_cls () |
inlib::histo::p1d * | TProfile_stream (buffer &a_buffer) |
void | dump (std::ostream &a_out, inlib::rroot::ifile &a_file, const std::vector< inlib::rroot::key * > &a_keys, bool a_recursive, unsigned int a_spaces=0) |
const std::string & | TTree_cls () |
typedef unsigned int inlib::rroot::date |
typedef inlib::histo::histo_data<double,unsigned int,double> inlib::rroot::hd_data |
typedef inlib::histo::profile_data<double,unsigned int,double,double> inlib::rroot::pd_data |
typedef inlib::int64 inlib::rroot::seek |
typedef int inlib::rroot::seek32 |
bool inlib::rroot::Array_stream | ( | buffer & | a_buffer, |
std::vector< T > & | a_v | ||
) | [inline] |
bool inlib::rroot::AttAxis_stream | ( | buffer & | a_buffer | ) | [inline] |
Definition at line 32 of file streamers.
{ int fNdivisions = 510; //Number of divisions(10000*n3 + 100*n2 + n1) short fAxisColor = 1; //color of the line axis short fLabelColor = 1; //color of labels short fLabelFont = 62; //font for labels float fLabelOffset = 0.005F; //offset of labels float fLabelSize = 0.04F; //size of labels float fTickLength = 0.03F; //length of tick marks float fTitleOffset = 1; //offset of axis title float fTitleSize = 0.04F; //size of axis title short fTitleColor = 1; //color of axis title short fTitleFont = 62; //font for axis title // Version 4 streaming (ROOT/v3-00-6). short v; unsigned int s, c; if(!a_buffer.read_version(v,s,c)) return false; if(!a_buffer.read(fNdivisions)) return false; if(!a_buffer.read(fAxisColor)) return false; if(!a_buffer.read(fLabelColor)) return false; if(!a_buffer.read(fLabelFont)) return false; if(!a_buffer.read(fLabelOffset)) return false; if(!a_buffer.read(fLabelSize)) return false; if(!a_buffer.read(fTickLength)) return false; if(!a_buffer.read(fTitleOffset)) return false; if(!a_buffer.read(fTitleSize)) return false; if(!a_buffer.read(fTitleColor)) return false; if(!a_buffer.read(fTitleFont)) return false; if(!a_buffer.check_byte_count(s, c,"TAttAxis")) return false; return true; }
bool inlib::rroot::AttFill_stream | ( | buffer & | a_buffer | ) | [inline] |
Definition at line 51 of file named.
{ short fFillColor; short fFillStyle; short v; unsigned int s, c; if(!a_buffer.read_version(v,s,c)) return false; if(!a_buffer.read(fFillColor)) return false; if(!a_buffer.read(fFillStyle)) return false; if(!a_buffer.check_byte_count(s,c,"TAttFill")) return false; return true; }
bool inlib::rroot::AttLine_stream | ( | buffer & | a_buffer | ) | [inline] |
Definition at line 37 of file named.
{ short fLineColor; short fLineStyle; short fLineWidth; short v; unsigned int s, c; if(!a_buffer.read_version(v,s,c)) return false; if(!a_buffer.read(fLineColor)) return false; if(!a_buffer.read(fLineStyle)) return false; if(!a_buffer.read(fLineWidth)) return false; if(!a_buffer.check_byte_count(s,c,"TAttLine")) return false; return true; }
bool inlib::rroot::AttMarker_stream | ( | buffer & | a_buffer | ) | [inline] |
Definition at line 63 of file named.
{ short fMarkerColor; short fMarkerStyle; float fMarkerWidth; short v; unsigned int s, c; if(!a_buffer.read_version(v,s,c)) return false; if(!a_buffer.read(fMarkerColor)) return false; if(!a_buffer.read(fMarkerStyle)) return false; if(!a_buffer.read(fMarkerWidth)) return false; if(!a_buffer.check_byte_count(s,c,"TAttMarker")) return false; return true; }
bool inlib::rroot::Axis_stream | ( | buffer & | a_buffer, |
inlib::histo::axis< double > & | a_fAxis | ||
) | [inline] |
Definition at line 88 of file streamers.
{ // Version 6 streaming (ROOT/v3-00-6). short v; unsigned int s, c; if(!a_buffer.read_version(v,s,c)) return false; std::string name; std::string title; if(!Named_stream(a_buffer,name,title)) return false; if(!AttAxis_stream(a_buffer)) return false; int number; if(!a_buffer.read(number)) return false; double min; if(!a_buffer.read(min)) return false; double max; if(!a_buffer.read(max)) return false; //printf("debug : BatchLab::RioTH::streamTAxis : %d %g %g\n", // number,min,max); std::vector<double> edges; if(!Array_stream<double>(a_buffer,edges)) return false; //fXbins TArrayD int edgen = edges.size(); if(edgen<=0) { a_fAxis.configure(number,min,max); } else { std::vector<double> vedges; for(int index=0;index<edgen;index++) { vedges.push_back(edges[index]); } a_fAxis.configure(vedges); } int First; if(!a_buffer.read(First)) return false; int Last; if(!a_buffer.read(Last)) return false; if(v>=8) { //fBits2. unsigned short dummy; if(!a_buffer.read(dummy)) return false; } //Bool_t unsigned char TimeDisplay; if(!a_buffer.read(TimeDisplay)) return false; //TString std::string TimeFormat; if(!a_buffer.read(TimeFormat)) return false; if(v>=7) { dummy_fac fac(a_buffer.out()); ifac::args args; iro* obj; if(!a_buffer.read_object(fac,args,obj)) return false; //THashList* } if(!a_buffer.check_byte_count(s,c,"TAxis")) return false; return true; }
void inlib::rroot::dump | ( | std::ostream & | a_out, |
inlib::rroot::ifile & | a_file, | ||
const std::vector< inlib::rroot::key * > & | a_keys, | ||
bool | a_recursive, | ||
unsigned int | a_spaces = 0 |
||
) | [inline] |
Definition at line 1013 of file streamers.
{ // dump non directory objects : {std::vector<inlib::rroot::key*>::const_iterator it; for(it=a_keys.begin();it!=a_keys.end();++it) { inlib::rroot::key& k = *(*it); if(k.object_class()==inlib::rroot::TDirectory::store_class()) continue; {for(unsigned index=0;index<a_spaces;index++) a_out << " ";} k.dump(a_out); }} // dump directories : {std::vector<inlib::rroot::key*>::const_iterator it; for(it=a_keys.begin();it!=a_keys.end();++it) { inlib::rroot::key& k = *(*it); if(k.object_class()!=inlib::rroot::TDirectory::store_class()) continue; std::string label = k.object_name(); {for(unsigned index=0;index<a_spaces;index++) a_out << " ";} a_out << "directory : " << label << std::endl; if(!a_recursive) continue; uint32 sz; char* buf = k.get_object_buffer(sz); //we don't have ownership of buf. if(!buf) { a_out << "inlib::rroot::dump :" << " can't get directory data buffer." << std::endl; } else { inlib::rroot::buffer b(a_out,a_file.byte_swap(), sz,buf,k.key_length(),false); inlib::rroot::TDirectory tdir(a_file); if(!tdir.stream(b)) { a_out << "inlib::rroot::dump :" << " can't stream TDirectory." << std::endl; } else { const std::vector<inlib::rroot::key*>& keys = tdir.keys(); dump(a_out,a_file,keys,a_recursive,a_spaces+1); } } }} }
const std::string& inlib::rroot::leaf_double_cls | ( | ) | [inline] |
const std::string& inlib::rroot::leaf_float_cls | ( | ) | [inline] |
const std::string& inlib::rroot::leaf_int_cls | ( | ) | [inline] |
const std::string& inlib::rroot::leaf_store_class | ( | char | ) | [inline] |
const std::string& inlib::rroot::leaf_store_class | ( | short | ) | [inline] |
const std::string& inlib::rroot::leaf_store_class | ( | int | ) | [inline] |
const std::string& inlib::rroot::leaf_store_class | ( | float | ) | [inline] |
const std::string& inlib::rroot::leaf_store_class | ( | double | ) | [inline] |
bool inlib::rroot::Named_stream | ( | buffer & | a_buffer, |
std::string & | a_name, | ||
std::string & | a_title | ||
) | [inline] |
Definition at line 23 of file named.
{ short v; unsigned int s, c; if(!a_buffer.read_version(v,s,c)) return false; {uint32 id,bits; if(!Object_stream(a_buffer,id,bits)) return false;} if(!a_buffer.read(a_name)) return false; if(!a_buffer.read(a_title)) return false; if(!a_buffer.check_byte_count(s,c,"TNamed")) return false; return true; }
bool inlib::rroot::null_epsil | ( | double | a_1, |
double | a_2, | ||
double | a_prec = -5 |
||
) | [inline] |
bool inlib::rroot::Object_stream | ( | buffer & | a_buffer, |
uint32 & | a_id, | ||
uint32 & | a_bits | ||
) | [inline] |
void inlib::rroot::read | ( | std::ostream & | a_out, |
inlib::rroot::ifile & | a_file, | ||
const std::vector< inlib::rroot::key * > & | a_keys, | ||
bool | a_recursive, | ||
bool | a_ls, | ||
bool | a_dump, | ||
unsigned int | a_spaces | ||
) | [inline] |
Definition at line 145 of file rall.
{ {std::vector<inlib::rroot::key*>::const_iterator it; for(it=a_keys.begin();it!=a_keys.end();++it) { inlib::rroot::key& k = *(*it); if(k.object_class()!=inlib::rroot::TDirectory::store_class()) { if(a_ls||a_dump) { {for(unsigned index=0;index<a_spaces;index++) a_out << " ";} std::string label = k.object_name(); a_out << "object : " << sout(label) << ", class : " << k.object_class() << std::endl; //k.dump(a_out); } if(!read_key(a_out,k,a_dump)) return; } }} {std::vector<inlib::rroot::key*>::const_iterator it; for(it=a_keys.begin();it!=a_keys.end();++it) { inlib::rroot::key& k = *(*it); if(k.object_class()==inlib::rroot::TDirectory::store_class()) { if(a_ls||a_dump) { {for(unsigned index=0;index<a_spaces;index++) a_out << " ";} std::string label = k.object_name(); a_out << "directory : " << label << std::endl; } if(!a_recursive) continue; inlib::uint32 sz; char* buf = k.get_object_buffer(sz); if(!buf) { a_out << "read :" << " can't get directory data buffer." << std::endl; } else { inlib::rroot::buffer b(a_out,a_file.byte_swap(), sz,buf,k.key_length(),false); inlib::rroot::TDirectory dir(a_file); if(!dir.stream(b)) { a_out << "read :" << " can't stream TDirectory." << std::endl; } else { const std::vector<inlib::rroot::key*>& keys = dir.keys(); read(a_out,a_file,keys,a_recursive,a_ls,a_dump,a_spaces+1); } } } }} }
bool inlib::rroot::read_key | ( | std::ostream & | a_out, |
inlib::rroot::key & | a_key, | ||
bool | a_dump | ||
) | [inline] |
Definition at line 14 of file rall.
{ unsigned int sz; char* buf = a_key.get_object_buffer(sz); //we don't have ownership of buf. if(!buf) { a_out << "inlib::rroot::read_key :" << " can't get data buffer of " << a_key.object_name() << "." << std::endl; return false; } //a_out << "inlib::rroot::read_key :" // << " get data buffer size " << sz << "." // << std::endl; inlib::rroot::buffer b(a_out,a_key.file().byte_swap(), sz,buf,a_key.key_length(),false); if(a_key.object_class()==inlib::rroot::TH1F_cls()) { inlib::histo::h1d* h = inlib::rroot::TH1F_stream(b); if(!h) { a_out << "inlib::rroot::read_key :" << " TH1F streaming failed" << std::endl; } else { if(a_dump) h->hprint(a_out); } delete h; } else if(a_key.object_class()==inlib::rroot::TH1D_cls()) { inlib::histo::h1d* h = inlib::rroot::TH1D_stream(b); if(!h) { a_out << "inlib::rroot::read_key :" << " TH1D streaming failed" << std::endl; } else { if(a_dump) h->hprint(a_out); } delete h; } else if(a_key.object_class()==inlib::rroot::TH2F_cls()) { inlib::histo::h2d* h = inlib::rroot::TH2F_stream(b); if(!h) { a_out << "inlib::rroot::read_key :" << " TH2F streaming failed" << std::endl; } else { if(a_dump) h->hprint(a_out); } delete h; } else if(a_key.object_class()==inlib::rroot::TH2D_cls()) { inlib::histo::h2d* h = inlib::rroot::TH2D_stream(b); //we get ownership of h. if(!h) { a_out << "inlib::rroot::read_key :" << " TH2D streaming failed" << std::endl; } else { if(a_dump) h->hprint(a_out); } delete h; } else if(a_key.object_class()==inlib::rroot::TProfile_cls()) { inlib::histo::p1d* p = inlib::rroot::TProfile_stream(b); if(!p) { a_out << "inlib::rroot::read_key :" << " TProfile streaming failed" << std::endl; } else { if(a_dump) p->hprint(a_out); } delete p; } else if(a_key.object_class()==TTree_cls()) { inlib::rroot::fac fac(a_key.file()); inlib::rroot::tree tree(a_key.file(),fac); if(!tree.stream(b)) { a_out << "inlib::rroot::read_key :" << " TTree streaming failed" << std::endl; } else { //tree->dump(a_out); if(a_dump) { tree.dump(a_out,""," "); uint32 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(uint32 i=mx<uint32>(5,entries-5);i<entries;i++){ if(!tree.show(a_out,i)) { a_out << " show failed for entry " << i << std::endl; } } } } } else if(a_key.object_class()==inlib::rroot::TDirectory::store_class()) { //we should not pass here. } else { a_out << "inlib::rroot::read_key :" << " dont't know how to read key with object class " << inlib::sout(a_key.object_class()) << std::endl; } return true; }
const std::string& inlib::rroot::TH1D_cls | ( | ) | [inline] |
inlib::histo::h1d* inlib::rroot::TH1D_stream | ( | buffer & | a_buffer, |
bool | a_profile = false |
||
) | [inline] |
Definition at line 509 of file streamers.
{ unsigned int s, c; short v; if(!a_buffer.read_version(v,s,c)) return 0; //printf("debug : BatchLab::Rio::TH1D::stream : version %d\n",v); // Version 1 streaming (ROOT/v3-00-6). // Now we have to reconstruct a valid Histogram from 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; double fSw; if(!TH_read_1D(a_buffer,data,fEntries,fSw)) return 0; std::vector<double> bins; //fArray TArrayD if(!Array_stream<double>(a_buffer,bins)) return 0; unsigned int binn = data.m_bin_number; //printf("debug : BatchLab::Rio::TH1D::stream : histo bins %d\n",binn); data.m_bin_Sw.resize(binn,0); double asw = 0; {for(unsigned int index=0;index<binn;index++){ double h = bins[index]; data.m_bin_Sw[index] = h; asw += h; }} if(!a_profile) { double sw = data.get_Sw(); if(!null_epsil(sw,fSw)) { a_buffer.out() << "inlib::rroot::TH1D::stream : " << " WARNING : inconsistent total weight" << " for histo with title " << sout(data.m_title) << " :" << std::endl << " read fSw is " << fSw << " whilst sum of in-range bins weight is " << sw << " (diff is " << (sw-fSw) << ")." << std::endl; } } // Fill Sxw and Sx2w by using in range bins : std::vector<double> empty; empty.resize(1,0); data.m_bin_Sxw.resize(binn,empty); data.m_bin_Sx2w.resize(binn,empty); std::vector<int> is(data.m_dimension); for(unsigned int index=0;index<binn;index++){ if(!data.is_out(index)) { double height = bins[index]; data.get_indices(index,is); for(unsigned int iaxis=0;iaxis<data.m_dimension;iaxis++) { double x = data.m_axes[iaxis].bin_center(is[iaxis]); data.m_bin_Sxw[index][iaxis] = x * height; data.m_bin_Sx2w[index][iaxis] = x * x * height; } } } //ROOT does not store the number of entries per bin. // We have the global number of entries and weight ; with that // we do our best.... data.m_bin_entries.resize(binn,0); if(!a_profile && asw) { for(unsigned int index=0;index<binn;index++){ double height = bins[index]; int number = (int)((fEntries * height) / asw); if(number<0) { } else { data.m_bin_entries[index] = number; } } int allEntries = data.get_all_entries(); if(allEntries<int(fEntries)) { //FIXME //Correct some bins randomly (beurk, do you have a better idea ?) : int diff = int(fEntries)-allEntries; unsigned int nx = data.m_axes[0].m_number_of_bins; for(int i=0;i<diff;i++) { int ri = ::rand(); int ibin = int((nx-1) * ((double)ri/(double)RAND_MAX)) + 1; int offset = ibin; data.m_bin_entries[offset]++; } } else if(allEntries>int(fEntries)) { //FIXME a_buffer.out() << "inlib::rroot::TH1D::stream : " << " WARNING : can't reemulate number of entries per bin " << " for histo with title " << sout(data.m_title) << " :" << std::endl << " read fEntries (a double) is " << fEntries << " whilst corrected bin entries is " << allEntries << " (diff is " << (allEntries-int(fEntries)) << ")." << std::endl; } else { } } if(!a_buffer.check_byte_count(s,c,"TH1D")) return 0; inlib::histo::h1d* h = new inlib::histo::h1d("",10,0,1); h->copy_from_data(data); h->update_fast_getters(); // We have now a valid HCL histogram. return h; }
const std::string& inlib::rroot::TH1F_cls | ( | ) | [inline] |
inlib::histo::h1d* inlib::rroot::TH1F_stream | ( | buffer & | a_buffer, |
bool | a_profile = false |
||
) | [inline] |
Definition at line 392 of file streamers.
{ unsigned int s, c; short v; if(!a_buffer.read_version(v,s,c)) return 0; //printf("debug : BatchLab::Rio::TH1F::stream : version %d\n",v); // Version 1 streaming (ROOT/v3-00-6). // Now we have to reconstruct a valid Histogram from 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; double fSw; if(!TH_read_1D(a_buffer,data,fEntries,fSw)) return 0; std::vector<float> bins; //fArray TArrayF if(!Array_stream<float>(a_buffer,bins)) return 0; unsigned int binn = data.m_bin_number; //printf("debug : BatchLab::Rio::TH1F::stream : histo bins %d\n",binn); data.m_bin_Sw.resize(binn,0); double asw = 0; {for(unsigned int index=0;index<binn;index++){ double h = double(bins[index]); data.m_bin_Sw[index] = h; asw += h; }} if(!a_profile) { double sw = data.get_Sw(); if(!null_epsil(sw,fSw)) { a_buffer.out() << "inlib::rroot::TH1F::stream : " << " WARNING : inconsistent total weight" << " for histo with title " << sout(data.m_title) << " :" << std::endl << " read fSw is " << fSw << " whilst sum of in-range bins weight is " << sw << " (diff is " << (sw-fSw) << ")." << std::endl; } } // Fill Sxw and Sx2w by using in range bins : std::vector<double> empty; empty.resize(1,0); data.m_bin_Sxw.resize(binn,empty); data.m_bin_Sx2w.resize(binn,empty); std::vector<int> is(data.m_dimension); {for(unsigned int index=0;index<binn;index++){ if(!data.is_out(index)) { float height = bins[index]; data.get_indices(index,is); for(unsigned int iaxis=0;iaxis<data.m_dimension;iaxis++) { double x = data.m_axes[iaxis].bin_center(is[iaxis]); data.m_bin_Sxw[index][iaxis] = x * height; data.m_bin_Sx2w[index][iaxis] = x * x * height; } } }} //ROOT does not store the number of entries per bin. // We have the global number of entries and weight ; with that // we do our best.... data.m_bin_entries.resize(binn,0); if(!a_profile && asw) { for(unsigned int index=0;index<binn;index++){ float height = bins[index]; int number = (int)((fEntries * height) / asw); if(number<0) { } else { data.m_bin_entries[index] = number; } } int allEntries = data.get_all_entries(); if(allEntries<int(fEntries)) { //FIXME //Correct some bins randomly (beurk, do you have a better idea ?) : int diff = int(fEntries)-allEntries; unsigned int nx = data.m_axes[0].m_number_of_bins; for(int i=0;i<diff;i++) { int ri = ::rand(); // ibin in [1,nx-1] int ibin = int((nx-1) * ((double)ri/(double)RAND_MAX)) + 1; int offset = ibin; data.m_bin_entries[offset]++; } } else if(allEntries>int(fEntries)) { //FIXME a_buffer.out() << "inlib::rroot::TH1F::stream : " << " WARNING : can't reemulate number of entries per bin " << " for histo with title " << sout(data.m_title) << " :" << std::endl << " read fEntries (a double) is " << fEntries << " whilst corrected bin entries is " << allEntries << " (diff is " << (allEntries-int(fEntries)) << ")." << std::endl; } else { } } if(!a_buffer.check_byte_count(s,c,"TH1F")) return 0; inlib::histo::h1d* h = new inlib::histo::h1d("",10,0,1); h->copy_from_data(data); h->update_fast_getters(); // We have now a valid HCL histogram. return h; //give ownership to caller. }
const std::string& inlib::rroot::TH2D_cls | ( | ) | [inline] |
inlib::histo::h2d* inlib::rroot::TH2D_stream | ( | buffer & | a_buffer, |
bool | a_profile = false |
||
) | [inline] |
Definition at line 746 of file streamers.
{ unsigned int s, c; short v; if(!a_buffer.read_version(v,s,c)) return 0; //printf("debug : BatchLab::Rio::TH2D::stream : version %d\n",v); // Version 3 streaming (ROOT/v3-00-6). // Now we have to reconstruct a valid Histogram from 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); double fEntries; double fSw; if(!TH_read_2D(a_buffer,data,fEntries,fSw)) return 0; std::vector<double> bins; //fArray TArrayD if(!Array_stream<double>(a_buffer,bins)) return 0; //printf("debug : BatchLab::Rio::TH2D::stream : histo bins %d\n",n); unsigned int binn = data.m_bin_number; data.m_bin_Sw.resize(binn,0); double asw = 0; {for(unsigned int index=0;index<binn;index++){ double h = bins[index]; data.m_bin_Sw[index] = h; asw += h; }} if(!a_profile) { double sw = data.get_Sw(); if(!null_epsil(sw,fSw)) { a_buffer.out() << "inlib::rroot::TH2D::stream : " << " WARNING : inconsistent total weight" << " for histo with title " << sout(data.m_title) << " :" << std::endl << " read fSw is " << fSw << " whilst sum of in-range bins weight is " << sw << " (diff is " << (sw-fSw) << ")." << std::endl; } } // Fill Sxw and Sx2w by using in range bins : std::vector<double> empty; empty.resize(2,0); data.m_bin_Sxw.resize(binn,empty); data.m_bin_Sx2w.resize(binn,empty); std::vector<int> is(data.m_dimension); for(unsigned int index=0;index<binn;index++){ if(!data.is_out(index)) { double height = bins[index]; data.get_indices(index,is); for(unsigned int iaxis=0;iaxis<data.m_dimension;iaxis++) { double x = data.m_axes[iaxis].bin_center(is[iaxis]); data.m_bin_Sxw[index][iaxis] = x * height; data.m_bin_Sx2w[index][iaxis] = x * x * height; } } } //ROOT does not store the number of entries per bin. // We have the global number of entries and weight ; with that // we do our best.... data.m_bin_entries.resize(binn,0); if(!a_profile && asw) { for(unsigned int index=0;index<binn;index++){ double height = bins[index]; int number = (int)((fEntries * height) / asw); if(number<0) { } else { data.m_bin_entries[index] = number; } } int allEntries = data.get_all_entries(); if(allEntries<(int)fEntries) { //FIXME //Correct some bins randomly (beurk, do you have a better idea ?) : int diff = int(fEntries-allEntries); unsigned int nx = data.m_axes[0].m_number_of_bins; unsigned int ny = data.m_axes[1].m_number_of_bins; for(int i=0;i<diff;i++) { int ri = ::rand(); int ibin = int((nx-1) * ((double)ri/(double)RAND_MAX)) + 1; int rj = ::rand(); int jbin = int((ny-1) * ((double)rj/(double)RAND_MAX)) + 1; int offset = ibin + jbin * data.m_axes[1].m_offset; data.m_bin_entries[offset]++; } } else if(allEntries>int(fEntries)) { //FIXME a_buffer.out() << "inlib::rroot::TH2D::stream : " << " WARNING : can't reemulate number of entries per bin " << " for histo with title " << sout(data.m_title) << " :" << std::endl << " read fEntries (a double) is " << fEntries << " whilst corrected bin entries is " << allEntries << " (diff is " << (allEntries-int(fEntries)) << ")." << std::endl; } else { } } if(!a_buffer.check_byte_count(s,c,"TH2D")) return 0; inlib::histo::h2d* h = new inlib::histo::h2d("",10,0,1,10,0,1); h->copy_from_data(data); h->update_fast_getters(); // We have now a valid HCL histogram. return h; }
const std::string& inlib::rroot::TH2F_cls | ( | ) | [inline] |
inlib::histo::h2d* inlib::rroot::TH2F_stream | ( | buffer & | a_buffer, |
bool | a_profile = false |
||
) | [inline] |
Definition at line 626 of file streamers.
{ unsigned int s, c; short v; if(!a_buffer.read_version(v,s,c)) return 0; //printf("debug : BatchLab::Rio::TH2F::stream : version %d\n",v); // Version 3 streaming (ROOT/v3-00-6). // Now we have to reconstruct a valid Histogram from 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); double fEntries; double fSw; if(!TH_read_2D(a_buffer,data,fEntries,fSw)) return 0; std::vector<float> bins; //fArray TArrayF if(!Array_stream<float>(a_buffer,bins)) return 0; //printf("debug : BatchLab::Rio::TH2F::stream : histo bins %d\n",n); unsigned int binn = data.m_bin_number; data.m_bin_Sw.resize(binn,0); double asw = 0; {for(unsigned int index=0;index<binn;index++){ double h = double(bins[index]); data.m_bin_Sw[index] = h; asw += h; }} if(!a_profile) { double sw = data.get_Sw(); if(!null_epsil(sw,fSw)) { a_buffer.out() << "exlib::rroot::TH2F::stream : " << " WARNING : inconsistent total weight" << " for histo with title " << sout(data.m_title) << " :" << std::endl << " read fSw is " << fSw << " whilst sum of in-range bins weight is " << sw << " (diff is " << (sw-fSw) << ")." << std::endl; } } // Fill Sxw and Sx2w by using in range bins : std::vector<double> empty; empty.resize(2,0); data.m_bin_Sxw.resize(binn,empty); data.m_bin_Sx2w.resize(binn,empty); std::vector<int> is(data.m_dimension); for(unsigned int index=0;index<binn;index++){ if(!data.is_out(index)) { float height = bins[index]; data.get_indices(index,is); for(unsigned int iaxis=0;iaxis<data.m_dimension;iaxis++) { double x = data.m_axes[iaxis].bin_center(is[iaxis]); data.m_bin_Sxw[index][iaxis] = x * height; data.m_bin_Sx2w[index][iaxis] = x * x * height; } } } //ROOT does not store the number of entries per bin. // We have the global number of entries and weight ; with that // we do our best.... data.m_bin_entries.resize(binn,0); if(!a_profile && asw) { for(unsigned int index=0;index<binn;index++){ float height = bins[index]; int number = (int)((fEntries * height) / asw); if(number<0) { } else { data.m_bin_entries[index] = number; } } int allEntries = data.get_all_entries(); if(allEntries<(int)fEntries) { //FIXME //Correct some bins randomly (beurk, do you have a better idea ?) : int diff = int(fEntries-allEntries); unsigned int nx = data.m_axes[0].m_number_of_bins; unsigned int ny = data.m_axes[1].m_number_of_bins; for(int i=0;i<diff;i++) { int ri = ::rand(); int ibin = int((nx-1) * ((double)ri/(double)RAND_MAX)) + 1; int rj = ::rand(); int jbin = int((ny-1) * ((double)rj/(double)RAND_MAX)) + 1; int offset = ibin + jbin * data.m_axes[1].m_offset; data.m_bin_entries[offset]++; } } else if(allEntries>int(fEntries)) { //FIXME a_buffer.out() << "inlib::rroot::TH2F::stream : " << " WARNING : can't reemulate number of entries per bin " << " for histo with title " << sout(data.m_title) << " :" << std::endl << " read fEntries (a double) is " << fEntries << " whilst corrected bin entries is " << allEntries << " (diff is " << (allEntries-int(fEntries)) << ")." << std::endl; } else { } } if(!a_buffer.check_byte_count(s,c,"TH2F")) return 0; inlib::histo::h2d* h = new inlib::histo::h2d("",10,0,1,10,0,1); h->copy_from_data(data); h->update_fast_getters(); // We have now a valid HCL histogram. return h; }
bool inlib::rroot::TH_read_1D | ( | buffer & | a_buffer, |
hd_data & | a_data, | ||
double & | a_fEntries, | ||
double & | a_fSw | ||
) | [inline] |
Definition at line 226 of file streamers.
{ a_fEntries = 0; a_fSw = 0; unsigned int s, c; short v; if(!a_buffer.read_version(v,s,c)) return false; //printf("debug : BatchLab::Rio::TH::streamTH1 : version %d\n",v); // Version 3 streaming (ROOT/v3-00-6). std::string name; std::string title; if(!Named_stream(a_buffer,name,title)) return false; a_data.m_title = title; if(!AttLine_stream(a_buffer)) return false; if(!AttFill_stream(a_buffer)) return false; if(!AttMarker_stream(a_buffer)) return false; int Ncells; if(!a_buffer.read(Ncells)) return false; //fXAxis if(!Axis_stream(a_buffer,a_data.m_axes[0])) return false; a_data.m_axes[0].m_offset = 1; if(a_data.m_dimension==2) { if(!Axis_stream(a_buffer,a_data.m_axes[1])) return false; //fYAxis a_data.m_axes[1].m_offset = a_data.m_axes[0].m_offset * (a_data.m_axes[0].bins()+2); inlib::histo::axis<double> dummy; if(!Axis_stream(a_buffer,dummy)) return false; //fZAxis } else { inlib::histo::axis<double> dummy; if(!Axis_stream(a_buffer,dummy)) return false; //fYAxis if(!Axis_stream(a_buffer,dummy)) return false; //fZAxis } short barOffset; if(!a_buffer.read(barOffset)) return false; short barWidth; if(!a_buffer.read(barWidth)) return false; if(!a_buffer.read(a_fEntries)) return false; if(!a_buffer.read(a_fSw)) return false; //fTsumw //printf("debug : BatchLab::Rio::TH::streamTH1 : \"%s\" %g %g\n", //a_data.m_title.c_str(),fEntries,fSw); double sw2; if(!a_buffer.read(sw2)) return false; double xSxw; if(!a_buffer.read(xSxw)) return false; double xSx2w; if(!a_buffer.read(xSx2w)) return false; double max; if(!a_buffer.read(max)) return false; double min; if(!a_buffer.read(min)) return false; double NormFactor; if(!a_buffer.read(NormFactor)) return false; {std::vector<double> v; if(!Array_stream<double>(a_buffer,v)) return false;} //fContour TArrayD std::vector<double> sumw2; //fSumw2 TArrayD if(!Array_stream<double>(a_buffer,sumw2)) return false; {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); //} } {List dummy; if(!dummy.stream(a_buffer)) { a_buffer.out() << "inlib::rroot::TH_read_1D :" << " List stream failed." << std::endl; return false; }} //Functions if(v>=4) { int BufferSize; if(!a_buffer.read(BufferSize)) return false; //Double_t[fBufferSize] {char isArray; if(!a_buffer.read(isArray)) return false; if(isArray!=0) { if(BufferSize) { double* Buffer = new double[BufferSize]; if(!a_buffer.read_fast_array<double>(Buffer,BufferSize)) return false; delete [] Buffer; } }} } // Add two for outflows. if(a_data.m_dimension==1) { a_data.m_bin_number = a_data.m_axes[0].m_number_of_bins + 2; } else if(a_data.m_dimension==2) { a_data.m_bin_number = (a_data.m_axes[0].m_number_of_bins + 2) * (a_data.m_axes[1].m_number_of_bins + 2); } unsigned int binn = a_data.m_bin_number; a_data.m_bin_Sw2.resize(binn,0); if(binn==sumw2.size()) { for(unsigned int index=0;index<binn;index++){ a_data.m_bin_Sw2[index] = sumw2[index]; } } if(!a_buffer.check_byte_count(s,c,"TH")) return false; return true; }
bool inlib::rroot::TH_read_2D | ( | buffer & | a_buffer, |
hd_data & | a_data, | ||
double & | a_fEntries, | ||
double & | a_fSw | ||
) | [inline] |
Definition at line 361 of file streamers.
{ unsigned int s, c; short v; if(!a_buffer.read_version(v,s,c)) return false; //printf("debug : BatchLab::Rio::TH::streamTH2 : version %d\n",v); // Version 3 streaming (ROOT/v3-00-6). if(!TH_read_1D(a_buffer,a_data,a_fEntries,a_fSw)) return false; double ScaleFactor; if(!a_buffer.read(ScaleFactor)) return false; double Tsumwy; if(!a_buffer.read(Tsumwy)) return false; double Tsumwy2; if(!a_buffer.read(Tsumwy2)) return false; double Tsumwxy; if(!a_buffer.read(Tsumwxy)) return false; if(!a_buffer.check_byte_count(s,c,"TH2")) return false; return true; }
const std::string& inlib::rroot::TProfile_cls | ( | ) | [inline] |
inlib::histo::p1d* inlib::rroot::TProfile_stream | ( | buffer & | a_buffer | ) | [inline] |
Definition at line 866 of file streamers.
{ unsigned int s, c; short v; if(!a_buffer.read_version(v,s,c)) return 0; // Version 3 streaming (ROOT/v3-00-6). //WARNING : the mapping inlib::histo::p1d / TProfile is not obvious. //HCL::m_bin_Svw <---> TProfile::fArray //HCL::m_bin_Sv2w <---> TProfile::fSumw2 //HCL::m_bin_Sw <---> TProfile::fBinEntries inlib::histo::h1d* h = TH1D_stream(a_buffer,true); if(!h) return 0; //NOTE : histo.m_bin_Sw <---> TH1D::TArrayD::fArray //WARNING : should have a valid Rio::TH1D::fHistogram // being a inlib::histo::h1d. // But the inlib::histo::p1d does not inherit inlib::histo::h1d. pd_data data(h->get_histo_data()); delete h; std::vector<double> bins; //fBinEntries TArrayD if(!Array_stream<double>(a_buffer,bins)) return 0; int errorMode; if(!a_buffer.read(errorMode)) return 0; double ymin; if(!a_buffer.read(ymin)) return 0; double ymax; if(!a_buffer.read(ymax)) return 0; if(v>=4) { double sumwy; if(!a_buffer.read(sumwy)) return 0; double sumwy2; if(!a_buffer.read(sumwy2)) return 0; std::vector<double> bins_sumw2; //fBinSumw2 TArrayD if(!Array_stream<double>(a_buffer,bins_sumw2)) return 0; } data.m_is_profile = true; data.m_cut_v = true; data.m_min_v = ymin; data.m_max_v = ymax; unsigned int binn = data.m_bin_number; data.m_bin_Svw.resize(binn,0); data.m_bin_Sv2w.resize(binn,0); for(unsigned int index=0;index<binn;index++){ double svw = data.m_bin_Sw[index]; double sw = bins[index]; data.m_bin_entries[index] = (int)sw; //FIXME : ok for w = 1 only ! data.m_bin_Sw[index] = (double)sw; //FIXME : data.m_bin_Sxw //FIXME : data.m_bin_Sx2w data.m_bin_Svw[index] = svw; data.m_bin_Sv2w[index] = 0; //FIXME } if(!a_buffer.check_byte_count(s,c,"TProfile")) return 0; inlib::histo::p1d* p = new inlib::histo::p1d("",10,0,1); p->copy_from_data(data); p->update_fast_getters(); // We have now a valid inlib::histo::p1d. return p; }