4 #ifndef tools_waxml_histos
5 #define tools_waxml_histos
7 #include "../histo/h1d"
8 #include "../histo/h2d"
9 #include "../histo/h3d"
10 #include "../histo/p1d"
11 #include "../histo/p2d"
22 inline std::string
soutd(std::ostringstream& a_oss,
double a_value) {
31 inline std::string
bin_to_string(std::ostringstream& a_oss,
int a_index) {
47 ,std::ostream& a_writer
50 if(a_annotations.empty())
return;
53 for(
int i=0;i<aShift;i++) spaces +=
" ";
55 a_writer << spaces <<
" <annotation>" << std::endl;
57 annotations_t::const_iterator it;
58 for(it=a_annotations.begin();it!=a_annotations.end();++it){
59 a_writer << spaces <<
" <item"
64 a_writer << spaces <<
" </annotation>" << std::endl;
69 ,
const std::string& aDirection
70 ,std::ostream& a_writer
71 ,std::ostringstream& a_oss
77 for(
int i=0;i<aShift;i++) spaces +=
" ";
80 a_writer << spaces <<
" <axis"
81 <<
" direction=" <<
sout(aDirection)
87 a_writer << spaces <<
" <axis"
88 <<
" direction=" <<
sout(aDirection)
93 bn_t number = aAxis.
bins()-1;
94 for(bn_t index=0;index<number;index++) {
95 a_writer << spaces <<
" <binBorder"
99 a_writer << spaces <<
" </axis>" << std::endl;
104 std::ostream& a_writer
105 ,std::ostringstream& a_oss
107 ,
const std::string& aSpaces
110 unsigned int entries = aObject.
bin_entries(aIndex);
112 a_writer << aSpaces <<
" <bin1d"
118 double mean = aObject.
bin_mean(aIndex);
120 a_writer <<
" weightedMean=" <<
soutd(a_oss,mean);
123 double stddev = aObject.
bin_rms(aIndex);
125 a_writer <<
" weightedRms=" <<
soutd(a_oss,stddev);
128 a_writer <<
"/>" << std::endl;
133 std::ostream& a_writer
134 ,std::ostringstream& a_oss
136 ,
const std::string& aSpaces
140 unsigned int entries = aObject.
bin_entries(aIndexX,aIndexY);
142 a_writer << aSpaces <<
" <bin2d"
149 double mean_x = aObject.
bin_mean_x(aIndexX,aIndexY);
151 a_writer <<
" weightedMeanX=" <<
soutd(a_oss,mean_x);
153 double mean_y = aObject.
bin_mean_y(aIndexX,aIndexY);
155 a_writer <<
" weightedMeanY=" <<
soutd(a_oss,mean_y);
158 double stddevX = aObject.
bin_rms_x(aIndexX,aIndexY);
160 a_writer <<
" weightedRmsX=" <<
soutd(a_oss,stddevX);
162 double stddevY = aObject.
bin_rms_y(aIndexX,aIndexY);
164 a_writer <<
" weightedRmsY=" <<
soutd(a_oss,stddevY);
167 a_writer <<
"/>" << std::endl;
172 std::ostream& a_writer
173 ,std::ostringstream& a_oss
175 ,
const std::string& aSpaces
180 unsigned int entries = aObject.
bin_entries(aIndexX,aIndexY,aIndexZ);
182 a_writer << aSpaces <<
" <bin3d"
187 <<
" height=" <<
soutd(a_oss,aObject.
bin_height(aIndexX,aIndexY,aIndexZ))
188 <<
" error=" <<
soutd(a_oss,aObject.
bin_error(aIndexX,aIndexY,aIndexZ));
191 double mean_x = aObject.
bin_mean_x(aIndexX,aIndexY,aIndexZ);
193 a_writer <<
" weightedMeanX=" <<
soutd(a_oss,mean_x);
195 double mean_y = aObject.
bin_mean_y(aIndexX,aIndexY,aIndexZ);
197 a_writer <<
" weightedMeanY=" <<
soutd(a_oss,mean_y);
199 double mean_z = aObject.
bin_mean_z(aIndexX,aIndexY,aIndexZ);
201 a_writer <<
" weightedMeanZ=" <<
soutd(a_oss,mean_z);
204 double stddevX = aObject.
bin_rms_x(aIndexX,aIndexY,aIndexZ);
206 a_writer <<
" weightedRmsX=" <<
soutd(a_oss,stddevX);
208 double stddevY = aObject.
bin_rms_y(aIndexX,aIndexY,aIndexZ);
210 a_writer <<
" weightedRmsY=" <<
soutd(a_oss,stddevY);
212 double stddevZ = aObject.
bin_rms_z(aIndexX,aIndexY,aIndexZ);
214 a_writer <<
" weightedRmsZ=" <<
soutd(a_oss,stddevZ);
217 a_writer <<
"/>" << std::endl;
222 std::ostream& a_writer
223 ,std::ostringstream& a_oss
225 ,
const std::string& aSpaces
229 a_writer << aSpaces <<
" <bin1d"
234 <<
" weightedMean=" <<
soutd(a_oss,aObject.
bin_mean(aIndex));
236 double stddev = aObject.
bin_rms(aIndex);
238 a_writer <<
" weightedRms=" <<
soutd(a_oss,stddev);
242 a_writer <<
"/>" << std::endl;
247 std::ostream& a_writer
248 ,std::ostringstream& a_oss
250 ,
const std::string& aSpaces
255 a_writer << aSpaces <<
" <bin2d"
261 <<
" weightedMeanX=" <<
soutd(a_oss,aObject.
bin_mean_x(aIndexX,aIndexY))
262 <<
" weightedMeanY=" <<
soutd(a_oss,aObject.
bin_mean_y(aIndexX,aIndexY));
264 double stddevX = aObject.
bin_rms_x(aIndexX,aIndexY);
266 a_writer <<
" weightedRmsX=" <<
soutd(a_oss,stddevX);
268 double stddevY = aObject.
bin_rms_y(aIndexX,aIndexY);
270 a_writer <<
" weightedRmsY=" <<
soutd(a_oss,stddevY);
274 a_writer <<
"/>" << std::endl;
279 std::ostream& a_writer
281 ,
const std::string& aPath
282 ,
const std::string& aName
285 std::ostringstream ossd;
290 std::ostream&
writer = a_writer;
293 for(
int i=0;i<aShift;i++) spaces +=
" ";
296 writer << spaces <<
" <histogram1d"
309 writer << spaces <<
" <statistics"
312 writer << spaces <<
" <statistic"
313 <<
" direction=" <<
sout(
"x")
314 <<
" mean=" <<
soutd(ossd,aObject.
mean())
315 <<
" rms=" <<
soutd(ossd,aObject.
rms())
316 <<
"/>" << std::endl;
317 writer << spaces <<
" </statistics>" << std::endl;
320 writer << spaces <<
" <data1d>" << std::endl;
323 for(bn_t index=0;index<xbins;index++)
329 writer << spaces <<
" </data1d>" << std::endl;
330 writer << spaces <<
" </histogram1d>" << std::endl;
336 std::ostream& a_writer
338 ,
const std::string& aPath
339 ,
const std::string& aName
342 std::ostringstream ossd;
347 std::ostream&
writer = a_writer;
350 for(
int i=0;i<aShift;i++) spaces +=
" ";
353 writer << spaces <<
" <histogram2d"
367 writer << spaces <<
" <statistics"
370 writer << spaces <<
" <statistic"
371 <<
" direction=" <<
sout(
"x")
374 <<
"/>" << std::endl;
375 writer << spaces <<
" <statistic"
376 <<
" direction=" <<
sout(
"y")
379 <<
"/>" << std::endl;
380 writer << spaces <<
" </statistics>" << std::endl;
383 writer << spaces <<
" <data2d>" << std::endl;
388 for(indexX=0;indexX<xbins;indexX++) {
389 for(indexY=0;indexY<ybins;indexY++) {
399 for(indexX=0;indexX<xbins;indexX++){
404 for(indexY=0;indexY<ybins;indexY++){
409 writer << spaces <<
" </data2d>" << std::endl;
410 writer << spaces <<
" </histogram2d>" << std::endl;
416 std::ostream& a_writer
418 ,
const std::string& aPath
419 ,
const std::string& aName
422 std::ostringstream ossd;
426 std::ostream&
writer = a_writer;
429 for(
int i=0;i<aShift;i++) spaces +=
" ";
432 writer << spaces <<
" <histogram3d"
447 writer << spaces <<
" <statistics"
450 writer << spaces <<
" <statistic"
451 <<
" direction=" <<
sout(
"x")
454 <<
"/>" << std::endl;
455 writer << spaces <<
" <statistic"
456 <<
" direction=" <<
sout(
"y")
459 <<
"/>" << std::endl;
460 writer << spaces <<
" <statistic"
461 <<
" direction=" <<
sout(
"z")
464 <<
"/>" << std::endl;
465 writer << spaces <<
" </statistics>" << std::endl;
468 writer << spaces <<
" <data3d>" << std::endl;
472 bn_t indexX,indexY,indexZ;
473 for(indexX=0;indexX<xbins;indexX++) {
474 for(indexY=0;indexY<ybins;indexY++) {
475 for(indexZ=0;indexZ<zbins;indexZ++) {
518 for(indexX=0;indexX<xbins;indexX++){
537 for(indexY=0;indexY<ybins;indexY++){
556 for(indexZ=0;indexZ<zbins;indexZ++){
577 for(indexX=0;indexX<xbins;indexX++) {
578 for(indexY=0;indexY<ybins;indexY++) {
585 for(indexY=0;indexY<ybins;indexY++) {
586 for(indexZ=0;indexZ<zbins;indexZ++) {
593 for(indexX=0;indexX<xbins;indexX++) {
594 for(indexZ=0;indexZ<zbins;indexZ++) {
602 writer << spaces <<
" </data3d>" << std::endl;
603 writer << spaces <<
" </histogram3d>" << std::endl;
609 std::ostream& a_writer
611 ,
const std::string& aPath
612 ,
const std::string& aName
615 std::ostringstream ossd;
619 std::ostream&
writer = a_writer;
622 for(
int i=0;i<aShift;i++) spaces +=
" ";
625 writer << spaces <<
" <profile1d"
638 writer << spaces <<
" <statistics"
641 writer << spaces <<
" <statistic"
642 <<
" direction=" <<
sout(
"x")
643 <<
" mean=" <<
soutd(ossd,aObject.
mean())
644 <<
" rms=" <<
soutd(ossd,aObject.
rms())
645 <<
"/>" << std::endl;
646 writer << spaces <<
" </statistics>" << std::endl;
649 writer << spaces <<
" <data1d>" << std::endl;
651 for(bn_t index=0;index<xbins;index++) {
658 writer << spaces <<
" </data1d>" << std::endl;
659 writer << spaces <<
" </profile1d>" << std::endl;
665 std::ostream& a_writer
667 ,
const std::string& aPath
668 ,
const std::string& aName
671 std::ostringstream ossd;
675 std::ostream&
writer = a_writer;
678 for(
int i=0;i<aShift;i++) spaces +=
" ";
681 writer << spaces <<
" <profile2d"
695 writer << spaces <<
" <statistics"
698 writer << spaces <<
" <statistic"
699 <<
" direction=" <<
sout(
"x")
702 <<
"/>" << std::endl;
703 writer << spaces <<
" <statistic"
704 <<
" direction=" <<
sout(
"y")
707 <<
"/>" << std::endl;
708 writer << spaces <<
" </statistics>" << std::endl;
711 writer << spaces <<
" <data2d>" << std::endl;
714 for(bn_t indexX=0;indexX<xbins;indexX++) {
715 for(bn_t indexY=0;indexY<ybins;indexY++) {
729 for(bn_t indexX=0;indexX<aObject.
axis_x().bins();indexX++){
734 for(bn_t indexY=0;indexY<aObject.
axis_y().bins();indexY++){
739 writer << spaces <<
" </data2d>" << std::endl;
740 writer << spaces <<
" </profile2d>" << std::endl;