g4tools  5.4.0
hd2mpi
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_histo_hd2mpi
5 #define tools_histo_hd2mpi
6 
7 // code to MPI_Pack, MPI_Unpack histos without having to include mpi.h.
8 
9 #include "../impi"
10 
11 #include "histo_data"
12 
13 #include "../forit"
14 
15 namespace tools {
16 namespace histo {
17 
21 
22 inline bool axis_dui_pack(impi& a_mpi,const axis<double,unsigned int>& a_axis) {
23  //typedef double TC;
24  //typedef unsigned int TO;
25  //typedef unsigned int bn_t;
26  if(!a_mpi.pack(a_axis.m_offset)) return false; //TO
27  if(!a_mpi.pack(a_axis.m_number_of_bins)) return false; //bn_t
28  if(!a_mpi.pack(a_axis.m_minimum_value)) return false; //TC
29  if(!a_mpi.pack(a_axis.m_maximum_value)) return false; //TC
30  if(!a_mpi.bpack(a_axis.m_fixed)) return false;
31  if(!a_mpi.pack(a_axis.m_bin_width)) return false; //TC
32  if(!a_mpi.vpack(a_axis.m_edges)) return false; //TC
33  return true;
34 }
35 
37  //typedef double TC;
38  //typedef unsigned int TO;
39  //typedef unsigned int TN;
40  //typedef double TW;
41  //typedef unsigned int dim_t;
42  typedef unsigned int num_t;
43 
44  if(!a_mpi.spack(a_hd.m_title)) return false;
45  if(!a_mpi.pack(a_hd.m_dimension)) return false; //dim_t
46  if(!a_mpi.pack(a_hd.m_bin_number)) return false; //TO
47  if(!a_mpi.vpack(a_hd.m_bin_entries)) return false; //TN
48  if(!a_mpi.vpack(a_hd.m_bin_Sw)) return false; //TW
49  if(!a_mpi.vpack(a_hd.m_bin_Sw2)) return false; //TW
50 
51  {for(unsigned int ibin=0;ibin<a_hd.m_bin_number;ibin++) {
52  if(!a_mpi.vpack(a_hd.m_bin_Sxw[ibin])) return false;
53  }}
54  {for(unsigned int ibin=0;ibin<a_hd.m_bin_number;ibin++) {
55  if(!a_mpi.vpack(a_hd.m_bin_Sx2w[ibin])) return false;
56  }}
57 
58  // Axes :
59  {for(unsigned int iaxis=0;iaxis<a_hd.m_dimension;iaxis++) {
60  if(!axis_dui_pack(a_mpi,a_hd.m_axes[iaxis])) return false;
61  }}
62 
63  // etc :
64  if(!a_mpi.vpack(a_hd.m_in_range_plane_Sxyw)) return false; //TC
65 
66  // Annotations :
67  {if(!a_mpi.pack((num_t)a_hd.m_annotations.size())) return false; //num_t
68  tools_mforcit(std::string,std::string,a_hd.m_annotations,it) {
69  if(!a_mpi.spack((*it).first)) return false;
70  if(!a_mpi.spack((*it).second)) return false;
71  }}
72 
73  // fast getters :
74  if(!a_mpi.pack(a_hd.m_all_entries)) return false; //TN
75  if(!a_mpi.pack(a_hd.m_in_range_entries)) return false; //TN
76  if(!a_mpi.pack(a_hd.m_in_range_Sw)) return false; //TW
77  if(!a_mpi.pack(a_hd.m_in_range_Sw2)) return false; //TW
78  if(!a_mpi.vpack(a_hd.m_in_range_Sxw)) return false; //TC
79  if(!a_mpi.vpack(a_hd.m_in_range_Sx2w)) return false; //TC
80 
81  return true;
82 }
83 
87 
88 inline bool axis_dui_unpack(impi& a_mpi,axis<double,unsigned int>& a_axis) {
89  //typedef double TC;
90  //typedef unsigned int TO;
91  //typedef unsigned int bn_t;
92 
93  if(!a_mpi.unpack(a_axis.m_offset)) return false; //TO
94  if(!a_mpi.unpack(a_axis.m_number_of_bins)) return false; //bn_t
95  if(!a_mpi.unpack(a_axis.m_minimum_value)) return false; //TC
96  if(!a_mpi.unpack(a_axis.m_maximum_value)) return false; //TC
97  if(!a_mpi.bunpack(a_axis.m_fixed)) return false;
98  if(!a_mpi.unpack(a_axis.m_bin_width)) return false; //TC
99  if(!a_mpi.vunpack(a_axis.m_edges)) return false; //TC
100 
101  return true;
102 }
103 
105  //typedef double TC;
106  //typedef unsigned int TO;
107  //typedef unsigned int TN;
108  //typedef double TW;
109  //typedef unsigned int dim_t;
110  typedef unsigned int num_t;
111 
112  if(!a_mpi.sunpack(a_hd.m_title)) return false;
113  if(!a_mpi.unpack(a_hd.m_dimension)) return false; //dim_t
114  if(!a_mpi.unpack(a_hd.m_bin_number)) return false; //TO
115  if(!a_mpi.vunpack(a_hd.m_bin_entries)) return false; //TN
116  if(!a_mpi.vunpack(a_hd.m_bin_Sw)) return false; //TW
117  if(!a_mpi.vunpack(a_hd.m_bin_Sw2)) return false; //TW
118 
119  {a_hd.m_bin_Sxw.resize(a_hd.m_bin_number);
120  for(unsigned int ibin=0;ibin<a_hd.m_bin_number;ibin++) {
121  if(!a_mpi.vunpack(a_hd.m_bin_Sxw[ibin])) return false;
122  }}
123  {a_hd.m_bin_Sx2w.resize(a_hd.m_bin_number);
124  for(unsigned int ibin=0;ibin<a_hd.m_bin_number;ibin++) {
125  if(!a_mpi.vunpack(a_hd.m_bin_Sx2w[ibin])) return false;
126  }}
127 
128  // Axes :
129  {a_hd.m_axes.resize(a_hd.m_dimension);
130  for(unsigned int iaxis=0;iaxis<a_hd.m_dimension;iaxis++) {
131  if(!axis_dui_unpack(a_mpi,a_hd.m_axes[iaxis])) return false;
132  }}
133 
134  // etc :
135  if(!a_mpi.vunpack(a_hd.m_in_range_plane_Sxyw)) return false; //TC
136 
137  // Annotations :
138  {a_hd.m_annotations.clear();
139  num_t num;
140  if(!a_mpi.unpack(num)) return false;
141  for(unsigned int index=0;index<num;index++) {
142  std::string k,v;
143  if(!a_mpi.sunpack(k)) return false;
144  if(!a_mpi.sunpack(v)) return false;
145  a_hd.m_annotations[k] = v;
146  }}
147 
148  // fast getters :
149  if(!a_mpi.unpack(a_hd.m_all_entries)) return false; //TN
150  if(!a_mpi.unpack(a_hd.m_in_range_entries)) return false; //TN
151  if(!a_mpi.unpack(a_hd.m_in_range_Sw)) return false; //TW
152  if(!a_mpi.unpack(a_hd.m_in_range_Sw2)) return false; //TW
153  if(!a_mpi.vunpack(a_hd.m_in_range_Sxw)) return false; //TC
154  if(!a_mpi.vunpack(a_hd.m_in_range_Sx2w)) return false; //TC
155 
156  return true;
157 }
158 
159 }}
160 
161 #include "profile_data"
162 
163 namespace tools {
164 namespace histo {
165 
169 
171 
172  if(!histo_data_duiuid_pack(a_mpi,a_pd)) return false;
173 
174  //typedef double TV;
175 
176  if(!a_mpi.bpack(a_pd.m_is_profile)) return false;
177  if(!a_mpi.vpack(a_pd.m_bin_Svw)) return false; //TV
178  if(!a_mpi.vpack(a_pd.m_bin_Sv2w)) return false; //TV
179  if(!a_mpi.bpack(a_pd.m_cut_v)) return false;
180  if(!a_mpi.pack(a_pd.m_min_v)) return false; //TV
181  if(!a_mpi.pack(a_pd.m_max_v)) return false; //TV
182 
183  return true;
184 }
185 
189 
191 
192  if(!histo_data_duiuid_unpack(a_mpi,a_pd)) return false;
193 
194  //typedef double TV;
195 
196  if(!a_mpi.bunpack(a_pd.m_is_profile)) return false;
197  if(!a_mpi.vunpack(a_pd.m_bin_Svw)) return false; //TV
198  if(!a_mpi.vunpack(a_pd.m_bin_Sv2w)) return false; //TV
199  if(!a_mpi.bunpack(a_pd.m_cut_v)) return false;
200  if(!a_mpi.unpack(a_pd.m_min_v)) return false; //TV
201  if(!a_mpi.unpack(a_pd.m_max_v)) return false; //TV
202 
203  return true;
204 }
205 
206 }}
207 
208 #endif
tools::histo::axis::m_edges
std::vector< TC > m_edges
Definition: axis:272
tools::impi::bunpack
virtual bool bunpack(bool &)=0
tools::histo::histo_data::m_in_range_Sw2
TW m_in_range_Sw2
Definition: histo_data:189
tools::histo::profile_data_duiuidd_pack
bool profile_data_duiuidd_pack(impi &a_mpi, const profile_data< double, unsigned int, unsigned int, double, double > &a_pd)
profile_data to C struct ////////////////////////////////////////////////
Definition: hd2mpi:170
tools::histo::profile_data::m_is_profile
bool m_is_profile
Definition: profile_data:73
tools::histo::histo_data::m_annotations
std::map< std::string, std::string > m_annotations
Definition: histo_data:184
tools::histo::axis::m_maximum_value
TC m_maximum_value
Definition: axis:267
tools::histo::axis::m_offset
TO m_offset
Definition: axis:264
tools::histo::histo_data::m_bin_Sx2w
std::vector< std::vector< TC > > m_bin_Sx2w
Definition: histo_data:179
tools::histo::histo_data::m_in_range_Sxw
std::vector< TC > m_in_range_Sxw
Definition: histo_data:190
tools::histo::axis< double, unsigned int >
tools::histo::histo_data_duiuid_unpack
bool histo_data_duiuid_unpack(impi &a_mpi, histo_data< double, unsigned int, unsigned int, double > &a_hd)
Definition: hd2mpi:104
tools::histo::histo_data::m_bin_entries
std::vector< TN > m_bin_entries
Definition: histo_data:175
tools::impi::bpack
virtual bool bpack(bool)=0
tools::histo::histo_data::m_bin_Sw
std::vector< TW > m_bin_Sw
Definition: histo_data:176
tools::histo::profile_data::m_bin_Sv2w
std::vector< TV > m_bin_Sv2w
Definition: profile_data:75
tools::histo::histo_data_duiuid_pack
bool histo_data_duiuid_pack(impi &a_mpi, const histo_data< double, unsigned int, unsigned int, double > &a_hd)
Definition: hd2mpi:36
tools::histo::profile_data::m_min_v
TV m_min_v
Definition: profile_data:77
tools::histo::histo_data::m_in_range_entries
TN m_in_range_entries
Definition: histo_data:187
tools::histo::profile_data::m_cut_v
bool m_cut_v
Definition: profile_data:76
tools::impi::vpack
virtual bool vpack(const std::vector< unsigned int > &)=0
tools::histo::axis::m_bin_width
TC m_bin_width
Definition: axis:270
tools::histo::histo_data::m_in_range_Sx2w
std::vector< TC > m_in_range_Sx2w
Definition: histo_data:191
tools::histo::histo_data::m_title
std::string m_title
Definition: histo_data:171
tools::histo::axis_dui_unpack
bool axis_dui_unpack(impi &a_mpi, axis< double, unsigned int > &a_axis)
mpi to hist_data ////////////////////////////////////////////////////////
Definition: hd2mpi:88
tools::histo::profile_data
Definition: profile_data:13
tools::histo::profile_data::m_bin_Svw
std::vector< TV > m_bin_Svw
Definition: profile_data:74
tools::histo::profile_data_duiuidd_unpack
bool profile_data_duiuidd_unpack(impi &a_mpi, profile_data< double, unsigned int, unsigned int, double, double > &a_pd)
mpi to profile_data /////////////////////////////////////////////////////
Definition: hd2mpi:190
tools::impi
Definition: impi:14
tools::histo::histo_data::m_bin_Sxw
std::vector< std::vector< TC > > m_bin_Sxw
Definition: histo_data:178
profile_data
tools::histo::histo_data< double, unsigned int, unsigned int, double >
tools::histo::histo_data::m_axes
std::vector< axis_t > m_axes
Definition: histo_data:181
tools::histo::axis::m_minimum_value
TC m_minimum_value
Definition: axis:266
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools_mforcit
#define tools_mforcit(a__K, a__V, a__m, a__it)
Definition: forit:49
tools::histo::axis::m_number_of_bins
bn_t m_number_of_bins
Definition: axis:265
tools::histo::histo_data::m_bin_Sw2
std::vector< TW > m_bin_Sw2
Definition: histo_data:177
tools::histo::histo_data::m_all_entries
TN m_all_entries
Definition: histo_data:186
tools::impi::pack
virtual bool pack(char)=0
tools::histo::histo_data::m_in_range_Sw
TW m_in_range_Sw
Definition: histo_data:188
tools::impi::vunpack
virtual bool vunpack(std::vector< unsigned int > &)=0
tools::histo::histo_data::m_bin_number
TO m_bin_number
Definition: histo_data:174
tools::histo::axis_dui_pack
bool axis_dui_pack(impi &a_mpi, const axis< double, unsigned int > &a_axis)
hist_data to mpi ////////////////////////////////////////////////////////
Definition: hd2mpi:22
histo_data
tools::impi::unpack
virtual bool unpack(char &)=0
tools::histo::axis::m_fixed
bool m_fixed
Definition: axis:268
tools::histo::histo_data::m_in_range_plane_Sxyw
std::vector< TC > m_in_range_plane_Sxyw
Definition: histo_data:183
tools::histo::profile_data::m_max_v
TV m_max_v
Definition: profile_data:78
tools::histo::histo_data::m_dimension
dim_t m_dimension
Definition: histo_data:172
tools::impi::spack
virtual bool spack(const std::string &)=0
tools::impi::sunpack
virtual bool sunpack(std::string &)=0