g4tools  5.4.0
Classes | Typedefs | Functions
tools::osc Namespace Reference

Classes

class  Annotation
 
class  Axis
 
class  BaseHistogram
 
class  Histogram
 
class  Histogram_cp
 
class  Item
 
class  Profile
 
class  Profile_cp
 
class  Vector
 

Typedefs

typedef histo::histo_data< double, unsigned int, unsigned int, double > hd_data
 
typedef histo::profile_data< double, unsigned int, unsigned int, double, double > pd_data
 

Functions

const std::string & s_axis ()
 
const std::string & s_annotation ()
 
const std::string & s_base_histogram ()
 
const std::string & s_item ()
 
const std::string & s_h1d ()
 
const std::string & s_h2d ()
 
const std::string & s_h3d ()
 
const std::string & s_p1d ()
 
const std::string & s_p2d ()
 
bool Axis_read (iobj_visitor &a_visitor, histo::axis< double, unsigned int > &a_axis)
 
template<class T >
bool std_vector_read (iobj_visitor &a_visitor, std::vector< T > &a_vec)
 
bool Annotation_read (iobj_visitor &a_visitor)
 
void map2vec (const std::map< std::string, std::string > &a_in, std::vector< Item > &a_out)
 
bool BaseHistogram_read (iobj_visitor &a_visitor)
 
template<class HIST >
bool visitHistogram (const HIST &a_hist, iobj_const_visitor &a_visitor)
 
bool readHistogram (hd_data &aData, iobj_visitor &a_visitor)
 
bool visit (iobj_const_visitor &a_v, const histo::h1d &a_histo)
 
bool read (iobj_visitor &a_visitor, histo::h1d &a_histo)
 
bool visit (iobj_const_visitor &a_v, const histo::h2d &a_histo)
 
bool read (iobj_visitor &a_visitor, histo::h2d &a_histo)
 
bool visit (iobj_const_visitor &a_v, const histo::h3d &a_histo)
 
bool read (iobj_visitor &a_visitor, histo::h3d &a_histo)
 
template<class PROF >
bool visitProfile (const PROF &a_prof, iobj_const_visitor &a_visitor)
 
bool readProfile (pd_data &aData, iobj_visitor &a_visitor)
 
bool visit (iobj_const_visitor &a_v, const histo::p1d &a_histo)
 
bool read (iobj_visitor &a_visitor, histo::p1d &a_histo)
 
bool visit (iobj_const_visitor &a_v, const histo::p2d &a_histo)
 
bool read (iobj_visitor &a_visitor, histo::p2d &a_histo)
 

Typedef Documentation

◆ hd_data

typedef histo::histo_data<double,unsigned int,unsigned int,double> tools::osc::hd_data

Definition at line 325 of file osc_streamers.

◆ pd_data

typedef histo::profile_data<double,unsigned int,unsigned int,double,double> tools::osc::pd_data

Definition at line 626 of file osc_streamers.

Function Documentation

◆ Annotation_read()

bool tools::osc::Annotation_read ( iobj_visitor a_visitor)
inline

Definition at line 307 of file osc_streamers.

307  {
308  //if(!a_visitor.begin(*this)) return false;
309  int version;
310  if(!a_visitor.visit(version)) return false;
311  std::vector<Item> fItems;
312  if(!std_vector_read<Item>(a_visitor,fItems)) return false;
313  //if(!a_visitor.end(*this)) return false;
314  return true;
315 }

◆ Axis_read()

bool tools::osc::Axis_read ( iobj_visitor a_visitor,
histo::axis< double, unsigned int > &  a_axis 
)
inline

Definition at line 108 of file osc_streamers.

108  {
109  //if(!a_visitor.begin(*this)) return false;
110 
111  int version;
112  if(!a_visitor.visit(version)) return false;
113 
114  if(!a_visitor.visit(a_axis.m_offset)) return false;
115 
116  {int nbin;
117  if(!a_visitor.visit(nbin)) return false;
118  a_axis.m_number_of_bins = nbin;}
119 
120  if(!a_visitor.visit(a_axis.m_minimum_value)) return false;
121  if(!a_visitor.visit(a_axis.m_maximum_value)) return false;
122  if(!a_visitor.visit(a_axis.m_fixed)) return false;
123  if(!a_visitor.visit(a_axis.m_bin_width)) return false;
124  if(!a_visitor.visit(a_axis.m_edges)) return false;
125 
126  //if(!a_visitor.end(*this)) return false;
127  return true;
128 }

◆ BaseHistogram_read()

bool tools::osc::BaseHistogram_read ( iobj_visitor a_visitor)
inline

Definition at line 370 of file osc_streamers.

370  {
371  //if(!a_visitor.begin(*this)) return false;
372 
373  int version;
374  if(!a_visitor.visit(version)) return false;
375 
376  if(!Annotation_read(a_visitor)) return false;
377 
378  //if(!a_visitor.end(*this)) return false;
379  return true;
380 }

◆ map2vec()

void tools::osc::map2vec ( const std::map< std::string, std::string > &  a_in,
std::vector< Item > &  a_out 
)
inline

Definition at line 317 of file osc_streamers.

317  {
318  a_out.clear();
319  std::map<std::string,std::string>::const_iterator it;
320  for(it=a_in.begin();it!=a_in.end();++it) {
321  a_out.push_back(Item((*it).first,(*it).second,false));
322  }
323 }

◆ read() [1/5]

bool tools::osc::read ( iobj_visitor a_visitor,
histo::h1d a_histo 
)
inline

Definition at line 527 of file osc_streamers.

527  {
528  //if(!a_visitor.begin(*this)) return false;
529 
530  int version;
531  if(!a_visitor.visit(version)) return false;
532 
533  if(version!=1) {
534  //this may come from an unexpected byteswap.
535  a_visitor.out() << "tools::osc::read :"
536  << " unexpected version " << version
537  << std::endl;
538  return false;
539  }
540 
541  if(!BaseHistogram_read(a_visitor)) return false;
542 
543  hd_data hdata;
544  if(!readHistogram(hdata,a_visitor)) return false;
545 
546  hdata.update_fast_getters();
547  a_histo.copy_from_data(hdata);
548 
549  //fAxis.copy(fHistogram.get_axis(0));
550 
551  //if(!a_visitor.end(*this)) return false;
552 
553  return true;
554 }

◆ read() [2/5]

bool tools::osc::read ( iobj_visitor a_visitor,
histo::h2d a_histo 
)
inline

Definition at line 561 of file osc_streamers.

561  {
562  //if(!a_visitor.begin(*this)) return false;
563 
564  int version;
565  if(!a_visitor.visit(version)) return false;
566 
567  if(version!=1) {
568  //this may come from an unexpected byteswap.
569  a_visitor.out() << "tools::osc::read :"
570  << " unexpected version " << version
571  << std::endl;
572  return false;
573  }
574 
575  if(!BaseHistogram_read(a_visitor)) return false;
576 
577  hd_data hdata;
578  if(!readHistogram(hdata,a_visitor)) return false;
579 
580  hdata.update_fast_getters();
581  a_histo.copy_from_data(hdata);
582 
583  //fAxisX.copy(fHistogram.get_axis(0));
584  //fAxisY.copy(fHistogram.get_axis(1));
585 
586  //if(!a_visitor.end(*this)) return false;
587 
588  return true;
589 }

◆ read() [3/5]

bool tools::osc::read ( iobj_visitor a_visitor,
histo::h3d a_histo 
)
inline

Definition at line 596 of file osc_streamers.

596  {
597  //if(!a_visitor.begin(*this)) return false;
598 
599  int version;
600  if(!a_visitor.visit(version)) return false;
601 
602  if(version!=1) {
603  //this may come from an unexpected byteswap.
604  a_visitor.out() << "tools::osc::read :"
605  << " unexpected version " << version
606  << std::endl;
607  return false;
608  }
609 
610  if(!BaseHistogram_read(a_visitor)) return false;
611 
612  hd_data hdata;
613  if(!readHistogram(hdata,a_visitor)) return false;
614  hdata.update_fast_getters();
615  a_histo.copy_from_data(hdata);
616 
617  //fAxisX.copy(fHistogram.get_axis(0));
618  //fAxisY.copy(fHistogram.get_axis(1));
619  //fAxisZ.copy(fHistogram.get_axis(2));
620 
621  //if(!a_visitor.end(*this)) return false;
622 
623  return true;
624 }

◆ read() [4/5]

bool tools::osc::read ( iobj_visitor a_visitor,
histo::p1d a_histo 
)
inline

Definition at line 761 of file osc_streamers.

761  {
762  //if(!a_visitor.begin(*this)) return false;
763 
764  int version;
765  if(!a_visitor.visit(version)) return false;
766 
767  if(version!=1) {
768  //this may come from an unexpected byteswap.
769  a_visitor.out() << "tools::osc::read :"
770  << " unexpected version " << version
771  << std::endl;
772  return false;
773  }
774 
775 
776  if(!BaseHistogram_read(a_visitor)) return false;
777 
778  pd_data hdata;
779  if(!readProfile(hdata,a_visitor)) return false;
780  hdata.update_fast_getters();
781  a_histo.copy_from_data(hdata);
782 
783  //fAxis.copy(fHistogram.get_axis(0));
784 
785  //if(!a_visitor.end(*this)) return false;
786 
787  return true;
788 }

◆ read() [5/5]

bool tools::osc::read ( iobj_visitor a_visitor,
histo::p2d a_histo 
)
inline

Definition at line 795 of file osc_streamers.

795  {
796  //if(!a_visitor.begin(*this)) return false;
797 
798  int version;
799  if(!a_visitor.visit(version)) return false;
800 
801  if(version!=1) {
802  //this may come from an unexpected byteswap.
803  a_visitor.out() << "tools::osc::read :"
804  << " unexpected version " << version
805  << std::endl;
806  return false;
807  }
808 
809 
810  if(!BaseHistogram_read(a_visitor)) return false;
811 
812  pd_data hdata;
813  if(!readProfile(hdata,a_visitor)) return false;
814  hdata.update_fast_getters();
815  a_histo.copy_from_data(hdata);
816 
817  //fAxisX.copy(a_histo.get_axis(0));
818  //fAxisY.copy(a_histo.get_axis(1));
819 
820  //if(!a_visitor.end(*this)) return false;
821 
822  return true;
823 }

◆ readHistogram()

bool tools::osc::readHistogram ( hd_data aData,
iobj_visitor a_visitor 
)
inline

Definition at line 419 of file osc_streamers.

419  {
420  if(!a_visitor.visit(aData.m_title)) return false;
421  {int dim;
422  if(!a_visitor.visit(dim)) return false;
423  aData.m_dimension = dim;}
424 
425  {int nbin;
426  if(!a_visitor.visit(nbin)) return false;
427  aData.m_bin_number = nbin;}
428 
429  {std::vector<int> vec;
430  if(!a_visitor.visit(vec)) return false;
431  convert<int,unsigned int>(vec,aData.m_bin_entries);}
432 
433  if(!a_visitor.visit(aData.m_bin_Sw)) return false;
434  if(!a_visitor.visit(aData.m_bin_Sw2)) return false;
435  if(!a_visitor.visit(aData.m_bin_Sxw)) return false;
436  if(!a_visitor.visit(aData.m_bin_Sx2w)) return false;
437  aData.m_axes.clear();
438  for(unsigned int iaxis=0;iaxis<aData.m_dimension;iaxis++) {
439  histo::axis<double,unsigned int> baxis;
440  if(!Axis_read(a_visitor,baxis)) return false;
441  aData.m_axes.push_back(baxis);
442  }
443  {int dummy;
444  if(!a_visitor.visit(dummy)) return false;} //m_mode
445 
446  {bool dummy;
447  if(!a_visitor.visit(dummy)) return false;} //m_is_profile
448 
449  {std::vector<double> dummy;
450  if(!a_visitor.visit(dummy)) return false;} //m_bin_Svw
451 
452  {std::vector<double> dummy;
453  if(!a_visitor.visit(dummy)) return false;} //m_bin_Sv2w
454 
455  {bool dummy;
456  if(!a_visitor.visit(dummy)) return false;} //m_cut_v
457 
458  {double dummy;
459  if(!a_visitor.visit(dummy)) return false;} //aData.m_min_v
460 
461  {double dummy;
462  if(!a_visitor.visit(dummy)) return false;} //aData.m_max_v
463 
464  //aData.fDoubles
465  //aData.fInts
466  //aData.m_coords.resize(aData.m_dimension,0);
467  //aData.m_ints.resize(aData.m_dimension,0);
468 
469  return true;
470 }

◆ readProfile()

bool tools::osc::readProfile ( pd_data aData,
iobj_visitor a_visitor 
)
inline

Definition at line 713 of file osc_streamers.

713  {
714  if(!a_visitor.visit(aData.m_title)) return false;
715 
716  {int dim;
717  if(!a_visitor.visit(dim)) return false;
718  aData.m_dimension = dim;}
719 
720  {int nbin;
721  if(!a_visitor.visit(nbin)) return false;
722  aData.m_bin_number = nbin;}
723 
724  {std::vector<int> vec;
725  if(!a_visitor.visit(vec)) return false;
726  convert<int,unsigned int>(vec,aData.m_bin_entries);}
727 
728  if(!a_visitor.visit(aData.m_bin_Sw)) return false;
729  if(!a_visitor.visit(aData.m_bin_Sw2)) return false;
730  if(!a_visitor.visit(aData.m_bin_Sxw)) return false;
731  if(!a_visitor.visit(aData.m_bin_Sx2w)) return false;
732  aData.m_axes.clear();
733  for(unsigned int iaxis=0;iaxis<aData.m_dimension;iaxis++) {
734  histo::axis<double,unsigned int> baxis;
735  if(!Axis_read(a_visitor,baxis)) return false;
736  aData.m_axes.push_back(baxis);
737  }
738  {int dummy;
739  if(!a_visitor.visit(dummy)) return false;} //m_mode
740  if(!a_visitor.visit(aData.m_is_profile)) return false;
741  if(!a_visitor.visit(aData.m_bin_Svw)) return false;
742  if(!a_visitor.visit(aData.m_bin_Sv2w)) return false;
743  if(!a_visitor.visit(aData.m_cut_v)) return false;
744  if(!a_visitor.visit(aData.m_min_v)) return false;
745  if(!a_visitor.visit(aData.m_max_v)) return false;
746 
747  // Not written :
748  //aData.fDoubles
749  //aData.fInts
750  //aData.m_coords.resize(aData.m_dimension,0);
751  //aData.m_ints.resize(aData.m_dimension,0);
752 
753  return true;
754 }

◆ s_annotation()

const std::string& tools::osc::s_annotation ( )
inline

Definition at line 28 of file osc_streamers.

28  {
29  static const std::string s_v("BatchLab::Annotation");
30  return s_v;
31 }

◆ s_axis()

const std::string& tools::osc::s_axis ( )
inline

Definition at line 24 of file osc_streamers.

24  {
25  static const std::string s_v("BatchLab::Axis");
26  return s_v;
27 }

◆ s_base_histogram()

const std::string& tools::osc::s_base_histogram ( )
inline

Definition at line 32 of file osc_streamers.

32  {
33  static const std::string s_v("BatchLab::BaseHistogram");
34  return s_v;
35 }

◆ s_h1d()

const std::string& tools::osc::s_h1d ( )
inline

Definition at line 41 of file osc_streamers.

41  {
42  static const std::string s_v("BatchLab::Histogram1D");
43  return s_v;
44 }

◆ s_h2d()

const std::string& tools::osc::s_h2d ( )
inline

Definition at line 46 of file osc_streamers.

46  {
47  static const std::string s_v("BatchLab::Histogram2D");
48  return s_v;
49 }

◆ s_h3d()

const std::string& tools::osc::s_h3d ( )
inline

Definition at line 51 of file osc_streamers.

51  {
52  static const std::string s_v("BatchLab::Histogram3D");
53  return s_v;
54 }

◆ s_item()

const std::string& tools::osc::s_item ( )
inline

Definition at line 36 of file osc_streamers.

36  {
37  static const std::string s_v("BatchLab::Item");
38  return s_v;
39 }

◆ s_p1d()

const std::string& tools::osc::s_p1d ( )
inline

Definition at line 56 of file osc_streamers.

56  {
57  static const std::string s_v("BatchLab::Profile1D");
58  return s_v;
59 }

◆ s_p2d()

const std::string& tools::osc::s_p2d ( )
inline

Definition at line 61 of file osc_streamers.

61  {
62  static const std::string s_v("BatchLab::Profile2D");
63  return s_v;
64 }

◆ std_vector_read()

template<class T >
bool tools::osc::std_vector_read ( iobj_visitor a_visitor,
std::vector< T > &  a_vec 
)
inline

Definition at line 250 of file osc_streamers.

250  {
251  a_vec.clear();
252 
253  //if(!a_visitor.begin(*this)) return false;
254 
255  int version;
256  if(!a_visitor.visit(version)) return false;
257 
258  unsigned int number;
259  if(!a_visitor.visit(number)) return false;
260 
261  a_vec.resize(number);
262  for(unsigned int index=0;index<number;index++) {
263  T& elem = a_vec[index];
264  if(!elem.read(a_visitor)) return false;
265  }
266 
267  //if(!a_visitor.end(*this)) return false;
268  return true;
269 }

◆ visit() [1/5]

bool tools::osc::visit ( iobj_const_visitor a_v,
const histo::h1d a_histo 
)
inline

Definition at line 522 of file osc_streamers.

522  {
523  Histogram<histo::h1d> h(a_histo,s_h1d());
524  return h.visit(a_v);
525 }

◆ visit() [2/5]

bool tools::osc::visit ( iobj_const_visitor a_v,
const histo::h2d a_histo 
)
inline

Definition at line 556 of file osc_streamers.

556  {
557  Histogram<histo::h2d> h(a_histo,s_h2d());
558  return h.visit(a_v);
559 }

◆ visit() [3/5]

bool tools::osc::visit ( iobj_const_visitor a_v,
const histo::h3d a_histo 
)
inline

Definition at line 591 of file osc_streamers.

591  {
592  Histogram<histo::h3d> h(a_histo,s_h3d());
593  return h.visit(a_v);
594 }

◆ visit() [4/5]

bool tools::osc::visit ( iobj_const_visitor a_v,
const histo::p1d a_histo 
)
inline

Definition at line 756 of file osc_streamers.

756  {
757  Profile<histo::p1d> h(a_histo,s_p1d());
758  return h.visit(a_v);
759 }

◆ visit() [5/5]

bool tools::osc::visit ( iobj_const_visitor a_v,
const histo::p2d a_histo 
)
inline

Definition at line 790 of file osc_streamers.

790  {
791  Profile<histo::p2d> h(a_histo,s_p2d());
792  return h.visit(a_v);
793 }

◆ visitHistogram()

template<class HIST >
bool tools::osc::visitHistogram ( const HIST &  a_hist,
iobj_const_visitor a_visitor 
)
inline

Definition at line 383 of file osc_streamers.

383  {
384  if(!a_visitor.visit("fTitle",a_hist.title())) return false;
385  if(!a_visitor.visit("fDimension",(int)a_hist.dimension())) return false;
386  if(!a_visitor.visit("fBinNumber",(int)a_hist.get_bins())) return false;
387 
388  std::vector<int> bins_entries;
389  convert<unsigned int,int>(a_hist.bins_entries(),bins_entries);
390  if(!a_visitor.visit("fBinEntries",bins_entries)) return false;
391 
392  if(!a_visitor.visit("fBinSw",a_hist.bins_sum_w())) return false;
393  if(!a_visitor.visit("fBinSw2",a_hist.bins_sum_w2())) return false;
394  if(!a_visitor.visit("fBinSxw",a_hist.bins_sum_xw())) return false;
395  if(!a_visitor.visit("fBinSx2w",a_hist.bins_sum_x2w())) return false;
396  {std::string name;
397  for(unsigned int iaxis=0;iaxis<a_hist.dimension();iaxis++) {
398  if(!num2s(iaxis,name)) return false;
399  name = "fAxes_"+name;
400  Axis axis(a_hist.get_axis(iaxis));
401  if(!a_visitor.visit(name,axis)) return false;
402  }}
403  {int dummy = 0;
404  if(!a_visitor.visit("fMode",dummy)) return false;} //m_mode
405  if(!a_visitor.visit("fProfile",false)) return false;
406  {std::vector<double> dummy;
407  if(!a_visitor.visit("fBinSvw",dummy)) return false;
408  if(!a_visitor.visit("fBinSv2w",dummy)) return false;}
409  if(!a_visitor.visit("fCutV",false)) return false;
410  {double dummy = 0;
411  if(!a_visitor.visit("fMinV",dummy)) return false;
412  if(!a_visitor.visit("fMaxV",dummy)) return false;}
413  // Not written :
414  //a_hist.fDoubles
415  //a_hist.fInts
416  return true;
417 }

◆ visitProfile()

template<class PROF >
bool tools::osc::visitProfile ( const PROF &  a_prof,
iobj_const_visitor a_visitor 
)
inline

Definition at line 629 of file osc_streamers.

629  {
630  if(!a_visitor.visit("fTitle",a_prof.title())) return false;
631  if(!a_visitor.visit("fDimension",(int)a_prof.dimension())) return false;
632  if(!a_visitor.visit("fBinNumber",(int)a_prof.get_bins())) return false;
633 
634  std::vector<int> bins_entries;
635  convert<unsigned int,int>(a_prof.bins_entries(),bins_entries);
636  if(!a_visitor.visit("fBinEntries",bins_entries)) return false;
637 
638  if(!a_visitor.visit("fBinSw",a_prof.bins_sum_w())) return false;
639  if(!a_visitor.visit("fBinSw2",a_prof.bins_sum_w2())) return false;
640  if(!a_visitor.visit("fBinSxw",a_prof.bins_sum_xw())) return false;
641  if(!a_visitor.visit("fBinSx2w",a_prof.bins_sum_x2w())) return false;
642  std::string name;
643  for(unsigned int iaxis=0;iaxis<a_prof.dimension();iaxis++) {
644  if(!num2s(iaxis,name)) return false;
645  name = "fAxes_"+name;
646  Axis axis(a_prof.get_axis(iaxis));
647  if(!a_visitor.visit(name,axis)) return false;
648  }
649  {int dummy = 0;
650  if(!a_visitor.visit("fMode",dummy)) return false;} //m_mode
651  if(!a_visitor.visit("fProfile",true)) return false;
652  if(!a_visitor.visit("fBinSvw",a_prof.bins_sum_vw())) return false;
653  if(!a_visitor.visit("fBinSv2w",a_prof.bins_sum_v2w())) return false;
654  if(!a_visitor.visit("fCutV",a_prof.cut_v())) return false;
655  if(!a_visitor.visit("fMinV",a_prof.min_v())) return false;
656  if(!a_visitor.visit("fMaxV",a_prof.max_v())) return false;
657  // Not written :
658  //a_prof.fDoubles
659  //a_prof.fInts
660  return true;
661 }
tools::osc::s_p2d
const std::string & s_p2d()
Definition: osc_streamers:61
tools::histo::histo_data::update_fast_getters
void update_fast_getters()
Definition: histo_data:103
tools::osc::s_h2d
const std::string & s_h2d()
Definition: osc_streamers:46
tools::osc::s_h3d
const std::string & s_h3d()
Definition: osc_streamers:51
tools::osc::Annotation_read
bool Annotation_read(iobj_visitor &a_visitor)
Definition: osc_streamers:307
tools::osc::pd_data
histo::profile_data< double, unsigned int, unsigned int, double, double > pd_data
Definition: osc_streamers:626
tools::osc::Axis_read
bool Axis_read(iobj_visitor &a_visitor, histo::axis< double, unsigned int > &a_axis)
Definition: osc_streamers:108
tools::osc::BaseHistogram_read
bool BaseHistogram_read(iobj_visitor &a_visitor)
Definition: osc_streamers:370
tools::version
unsigned int version()
Definition: version:14
tools::osc::s_h1d
const std::string & s_h1d()
Definition: osc_streamers:41
tools::osc::readProfile
bool readProfile(pd_data &aData, iobj_visitor &a_visitor)
Definition: osc_streamers:713
tools::osc::hd_data
histo::histo_data< double, unsigned int, unsigned int, double > hd_data
Definition: osc_streamers:325
tools::osc::s_p1d
const std::string & s_p1d()
Definition: osc_streamers:56
tools::osc::readHistogram
bool readHistogram(hd_data &aData, iobj_visitor &a_visitor)
Definition: osc_streamers:419
tools::num2s
bool num2s(unsigned short a_value, std::string &a_s)
Definition: num2s:26