g4tools  5.4.0
Classes | Functions
tools::wcsv Namespace Reference

Classes

class  ntuple
 

Functions

template<class AXIS >
void axis_to (std::ostream &a_writer, const AXIS &a_axis, char a_hc)
 
template<class ANNOTATION >
void annotations_to (std::ostream &a_writer, const ANNOTATION &a_ans, char a_hc)
 
template<class HIST >
void h_header (std::ostream &a_writer, const std::string &a_class, const HIST &a_h, char a_hc='#')
 
template<class HIST >
bool hto (std::ostream &a_writer, const std::string &a_class, const HIST &a_h, char a_sep=',', char a_hc='#', bool a_header=true)
 
template<class PROF >
void p_header (std::ostream &a_writer, const std::string &a_class, const PROF &a_prof, char a_hc='#')
 
template<class PROF >
bool pto (std::ostream &a_writer, const std::string &a_class, const PROF &a_prof, char a_sep=',', char a_hc='#', bool a_header=true)
 

Function Documentation

◆ annotations_to()

template<class ANNOTATION >
void tools::wcsv::annotations_to ( std::ostream &  a_writer,
const ANNOTATION &  a_ans,
char  a_hc 
)
inline

Definition at line 33 of file wcsv_histo.

33  {
34  typename ANNOTATION::const_iterator it;
35  for(it=a_ans.begin();it!=a_ans.end();++it) {
36  a_writer << a_hc << "annotation " << (*it).first << " " << (*it).second << std::endl;
37  }
38 }

◆ axis_to()

template<class AXIS >
void tools::wcsv::axis_to ( std::ostream &  a_writer,
const AXIS &  a_axis,
char  a_hc 
)
inline

Definition at line 15 of file wcsv_histo.

15  {
16  if(a_axis.m_fixed) {
17  a_writer << a_hc
18  << "axis fixed " << a_axis.m_number_of_bins
19  << " " << a_axis.m_minimum_value
20  << " " << a_axis.m_maximum_value
21 // << " " << a_axis.m_bin_width
22  << std::endl;
23  } else {
24  a_writer << a_hc << "axis edges";
25  for(unsigned int iedge=0;iedge<a_axis.m_edges.size();iedge++) {
26  a_writer << " " << a_axis.m_edges[iedge];
27  }
28  a_writer << std::endl;
29  }
30 }

◆ h_header()

template<class HIST >
void tools::wcsv::h_header ( std::ostream &  a_writer,
const std::string &  a_class,
const HIST &  a_h,
char  a_hc = '#' 
)
inline

Definition at line 41 of file wcsv_histo.

41  {
42  a_writer << a_hc << "class " << a_class << std::endl;
43  a_writer << a_hc << "title " << a_h.title() << std::endl;
44  a_writer << a_hc << "dimension " << a_h.dimension() << std::endl;
45  for(unsigned int iaxis=0;iaxis<a_h.dimension();iaxis++) axis_to(a_writer,a_h.get_axis(iaxis),a_hc);
46  {const std::vector<typename HIST::coordinate_t>& planes = a_h.in_range_planes_xyw();
47  if(planes.size()) {
48  a_writer << a_hc << "planes_Sxyw";
49  for(unsigned int iplane=0;iplane<planes.size();iplane++) a_writer << " " << planes[iplane];
50  a_writer << std::endl;
51  }}
52  annotations_to(a_writer,a_h.annotations(),a_hc);
53  a_writer << a_hc << "bin_number " << a_h.get_bins() << std::endl;
54 }

◆ hto()

template<class HIST >
bool tools::wcsv::hto ( std::ostream &  a_writer,
const std::string &  a_class,
const HIST &  a_h,
char  a_sep = ',',
char  a_hc = '#',
bool  a_header = true 
)
inline

Definition at line 57 of file wcsv_histo.

58  {
59  if(a_header) h_header(a_writer,a_class,a_h,a_hc);
60 
61  {a_writer << "entries" << a_sep << "Sw" << a_sep << "Sw2";
62  for(unsigned int iaxis=0;iaxis<a_h.dimension();iaxis++) {
63  a_writer << a_sep << "Sxw" << iaxis << a_sep << "Sx2w" << iaxis;
64  }
65  a_writer << std::endl;}
66 
67  typedef typename HIST::coordinate_t coordinate_t;
68  typedef typename HIST::dim_t dim_t;
69  typedef typename HIST::offset_t offset_t;
70  typedef typename HIST::num_entries_t num_entries_t;
71  typedef typename HIST::weight_t weight_t;
72 
73  dim_t _dim = a_h.dimension();
74  offset_t _bins = a_h.get_bins();
75 
76  const std::vector<num_entries_t>& _bin_entries = a_h.bins_entries();
77  const std::vector<weight_t>& _bin_Sw = a_h.bins_sum_w();
78  const std::vector<weight_t>& _bin_Sw2 = a_h.bins_sum_w2();
79  const std::vector< std::vector<coordinate_t> >& _bin_Sxw = a_h.bins_sum_xw();
80  const std::vector< std::vector<coordinate_t> >& _bin_Sx2w = a_h.bins_sum_x2w();
81 
82  for(unsigned int i=0;i<_bins;i++) {
83  a_writer << _bin_entries[i] << a_sep << _bin_Sw[i] << a_sep << _bin_Sw2[i];
84  for(unsigned int iaxis=0;iaxis<_dim;iaxis++) {
85  a_writer << a_sep << _bin_Sxw[i][iaxis] << a_sep << _bin_Sx2w[i][iaxis];
86  }
87  a_writer << std::endl;
88  }
89 
90  a_h.not_a_profile(); //trick to be sure to use this function on an histo and not a profile.
91 
92  return true;
93 }

◆ p_header()

template<class PROF >
void tools::wcsv::p_header ( std::ostream &  a_writer,
const std::string &  a_class,
const PROF &  a_prof,
char  a_hc = '#' 
)
inline

Definition at line 96 of file wcsv_histo.

96  {
97  a_writer << a_hc << "class " << a_class << std::endl;
98  a_writer << a_hc << "title " << a_prof.title() << std::endl;
99  a_writer << a_hc << "dimension " << a_prof.dimension() << std::endl;
100  for(unsigned int iaxis=0;iaxis<a_prof.dimension();iaxis++) axis_to(a_writer,a_prof.get_axis(iaxis),a_hc);
101  {const std::vector<typename PROF::coordinate_t>& planes = a_prof.in_range_planes_xyw();
102  if(planes.size()) {
103  a_writer << a_hc << "planes_Sxyw";
104  for(unsigned int iplane=0;iplane<planes.size();iplane++) a_writer << " " << planes[iplane];
105  a_writer << std::endl;
106  }}
107  annotations_to(a_writer,a_prof.annotations(),a_hc);
108  a_writer << a_hc << "cut_v " << (a_prof.cut_v()?"true":"false") << std::endl;
109  a_writer << a_hc << "min_v " << a_prof.min_v() << std::endl;
110  a_writer << a_hc << "max_v " << a_prof.max_v() << std::endl;
111  a_writer << a_hc << "bin_number " << a_prof.get_bins() << std::endl;
112 }

◆ pto()

template<class PROF >
bool tools::wcsv::pto ( std::ostream &  a_writer,
const std::string &  a_class,
const PROF &  a_prof,
char  a_sep = ',',
char  a_hc = '#',
bool  a_header = true 
)
inline

Definition at line 115 of file wcsv_histo.

116  {
117  if(a_header) p_header(a_writer,a_class,a_prof,a_hc);
118 
119  {a_writer << "entries" << a_sep << "Sw" << a_sep << "Sw2" << a_sep << "Svw" << a_sep << "Sv2w";
120  for(unsigned int iaxis=0;iaxis<a_prof.dimension();iaxis++) {
121  a_writer << a_sep << "Sxw" << iaxis << a_sep << "Sx2w" << iaxis;
122  }
123  a_writer << std::endl;}
124 
125  typedef typename PROF::coordinate_t coordinate_t;
126  typedef typename PROF::dim_t dim_t;
127  typedef typename PROF::offset_t offset_t;
128  typedef typename PROF::num_entries_t num_entries_t;
129  typedef typename PROF::weight_t weight_t;
130 
131  dim_t _dim = a_prof.dimension();
132  offset_t _bins = a_prof.get_bins();
133 
134  const std::vector<num_entries_t>& _bin_entries = a_prof.bins_entries();
135  const std::vector<weight_t>& _bin_Sw = a_prof.bins_sum_w();
136  const std::vector<weight_t>& _bin_Sw2 = a_prof.bins_sum_w2();
137  const std::vector< std::vector<coordinate_t> >& _bin_Sxw = a_prof.bins_sum_xw();
138  const std::vector< std::vector<coordinate_t> >& _bin_Sx2w = a_prof.bins_sum_x2w();
139 
140  typedef typename PROF::vs_t vs_t;
141  const vs_t& _bin_Svw = a_prof.bins_sum_vw();
142  const vs_t& _bin_Sv2w = a_prof.bins_sum_v2w();
143 
144  for(unsigned int i=0;i<_bins;i++) {
145  a_writer << _bin_entries[i] << a_sep << _bin_Sw[i] << a_sep << _bin_Sw2[i]
146  << a_sep << _bin_Svw[i] << a_sep << _bin_Sv2w[i];
147  for(unsigned int iaxis=0;iaxis<_dim;iaxis++) {
148  a_writer << a_sep << _bin_Sxw[i][iaxis] << a_sep << _bin_Sx2w[i][iaxis];
149  }
150  a_writer << std::endl;
151  }
152 
153  return true;
154 }
tools::wcsv::annotations_to
void annotations_to(std::ostream &a_writer, const ANNOTATION &a_ans, char a_hc)
Definition: wcsv_histo:33
tools::wcsv::h_header
void h_header(std::ostream &a_writer, const std::string &a_class, const HIST &a_h, char a_hc='#')
Definition: wcsv_histo:41
tools::wcsv::p_header
void p_header(std::ostream &a_writer, const std::string &a_class, const PROF &a_prof, char a_hc='#')
Definition: wcsv_histo:96
tools::wcsv::axis_to
void axis_to(std::ostream &a_writer, const AXIS &a_axis, char a_hc)
Definition: wcsv_histo:15