Warning, /include/Geant4/tools/waxml/histos is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_waxml_histos
0005 #define tools_waxml_histos
0006
0007 #include "../histo/h1d"
0008 #include "../histo/h2d"
0009 #include "../histo/h3d"
0010 #include "../histo/p1d"
0011 #include "../histo/p2d"
0012
0013 #include "../sout"
0014 #include "../num2s"
0015 #include "../srep"
0016
0017 #include <sstream>
0018
0019 namespace tools {
0020 namespace waxml {
0021
0022 inline std::string soutd(std::ostringstream& a_oss,double a_value) {
0023 a_oss.str("");
0024 a_oss << a_value;
0025 std::string _s("\"");
0026 _s += a_oss.str();
0027 _s += "\"";
0028 return _s;
0029 }
0030
0031 inline std::string bin_to_string(std::ostringstream& a_oss,int a_index) {
0032 if(a_index==histo::axis_UNDERFLOW_BIN) {
0033 return "UNDERFLOW";
0034 } else if(a_index==histo::axis_OVERFLOW_BIN) {
0035 return "OVERFLOW";
0036 } else {
0037 a_oss.str("");
0038 a_oss << a_index;
0039 return a_oss.str();
0040 }
0041 }
0042
0043 typedef std::map<std::string,std::string> annotations_t;
0044
0045 inline void write_annotations(
0046 const annotations_t& a_annotations
0047 ,std::ostream& a_writer
0048 ,int aShift
0049 ){
0050 if(a_annotations.empty()) return;
0051
0052 std::string spaces;
0053 for(int i=0;i<aShift;i++) spaces += " ";
0054
0055 a_writer << spaces << " <annotation>" << std::endl;
0056
0057 annotations_t::const_iterator it;
0058 for(it=a_annotations.begin();it!=a_annotations.end();++it){
0059 a_writer << spaces << " <item"
0060 << " key=" << sout(to_xml((*it).first))
0061 << " value=" << sout(to_xml((*it).second))
0062 << "/>" << std::endl;
0063 }
0064 a_writer << spaces << " </annotation>" << std::endl;
0065 }
0066
0067 inline void write_axis(
0068 const histo::axis<double,unsigned int>& aAxis
0069 ,const std::string& aDirection
0070 ,std::ostream& a_writer
0071 ,std::ostringstream& a_oss
0072 ,int aShift
0073 ){
0074 typedef histo::axis<double,unsigned int>::bn_t bn_t;
0075
0076 std::string spaces;
0077 for(int i=0;i<aShift;i++) spaces += " ";
0078
0079 if(aAxis.is_fixed_binning()) {
0080 a_writer << spaces << " <axis"
0081 << " direction=" << sout(aDirection)
0082 << " numberOfBins=" << num_out<bn_t>(aAxis.bins())
0083 << " min=" << soutd(a_oss,aAxis.lower_edge())
0084 << " max=" << soutd(a_oss,aAxis.upper_edge())
0085 << "/>" << std::endl;
0086 } else {
0087 a_writer << spaces << " <axis"
0088 << " direction=" << sout(aDirection)
0089 << " numberOfBins=" << num_out<bn_t>(aAxis.bins())
0090 << " min=" << soutd(a_oss,aAxis.lower_edge())
0091 << " max=" << soutd(a_oss,aAxis.upper_edge())
0092 << ">" << std::endl;
0093 bn_t number = aAxis.bins()-1;
0094 for(bn_t index=0;index<number;index++) {
0095 a_writer << spaces << " <binBorder"
0096 << " value=" << soutd(a_oss,aAxis.bin_upper_edge(index))
0097 << "/>" << std::endl;
0098 }
0099 a_writer << spaces << " </axis>" << std::endl;
0100 }
0101 }
0102
0103 inline void write_bin(
0104 std::ostream& a_writer
0105 ,std::ostringstream& a_oss
0106 ,const histo::h1d& aObject
0107 ,const std::string& aSpaces
0108 ,int aIndex
0109 ){
0110 unsigned int entries = aObject.bin_entries(aIndex);
0111 if(entries) {
0112 a_writer << aSpaces << " <bin1d"
0113 << " binNum=" << sout(bin_to_string(a_oss,aIndex))
0114 << " entries=" << num_out<unsigned int>(entries)
0115 << " height=" << soutd(a_oss,aObject.bin_height(aIndex))
0116 << " error=" << soutd(a_oss,aObject.bin_error(aIndex));
0117
0118 double mean = aObject.bin_mean(aIndex);
0119 if(mean!=0) {
0120 a_writer << " weightedMean=" << soutd(a_oss,mean);
0121 }
0122
0123 double stddev = aObject.bin_rms(aIndex);
0124 if(stddev!=0) {
0125 a_writer << " weightedRms=" << soutd(a_oss,stddev);
0126 }
0127
0128 a_writer << "/>" << std::endl;
0129 }
0130 }
0131
0132 inline void write_bin(
0133 std::ostream& a_writer
0134 ,std::ostringstream& a_oss
0135 ,const histo::h2d& aObject
0136 ,const std::string& aSpaces
0137 ,int aIndexX
0138 ,int aIndexY
0139 ){
0140 unsigned int entries = aObject.bin_entries(aIndexX,aIndexY);
0141 if(entries) {
0142 a_writer << aSpaces << " <bin2d"
0143 << " binNumX=" << sout(bin_to_string(a_oss,aIndexX))
0144 << " binNumY=" << sout(bin_to_string(a_oss,aIndexY))
0145 << " entries=" << num_out<unsigned int>(entries)
0146 << " height=" << soutd(a_oss,aObject.bin_height(aIndexX,aIndexY))
0147 << " error=" << soutd(a_oss,aObject.bin_error(aIndexX,aIndexY));
0148
0149 double mean_x = aObject.bin_mean_x(aIndexX,aIndexY);
0150 if(mean_x!=0) {
0151 a_writer << " weightedMeanX=" << soutd(a_oss,mean_x);
0152 }
0153 double mean_y = aObject.bin_mean_y(aIndexX,aIndexY);
0154 if(mean_y!=0) {
0155 a_writer << " weightedMeanY=" << soutd(a_oss,mean_y);
0156 }
0157
0158 double stddevX = aObject.bin_rms_x(aIndexX,aIndexY);
0159 if(stddevX!=0) {
0160 a_writer << " weightedRmsX=" << soutd(a_oss,stddevX);
0161 }
0162 double stddevY = aObject.bin_rms_y(aIndexX,aIndexY);
0163 if(stddevY!=0) {
0164 a_writer << " weightedRmsY=" << soutd(a_oss,stddevY);
0165 }
0166
0167 a_writer << "/>" << std::endl;
0168 }
0169 }
0170
0171 inline void write_bin(
0172 std::ostream& a_writer
0173 ,std::ostringstream& a_oss
0174 ,const histo::h3d& aObject
0175 ,const std::string& aSpaces
0176 ,int aIndexX
0177 ,int aIndexY
0178 ,int aIndexZ
0179 ){
0180 unsigned int entries = aObject.bin_entries(aIndexX,aIndexY,aIndexZ);
0181 if(entries) {
0182 a_writer << aSpaces << " <bin3d"
0183 << " binNumX=" << sout(bin_to_string(a_oss,aIndexX))
0184 << " binNumY=" << sout(bin_to_string(a_oss,aIndexY))
0185 << " binNumZ=" << sout(bin_to_string(a_oss,aIndexZ))
0186 << " entries=" << num_out<unsigned int>(entries)
0187 << " height=" << soutd(a_oss,aObject.bin_height(aIndexX,aIndexY,aIndexZ))
0188 << " error=" << soutd(a_oss,aObject.bin_error(aIndexX,aIndexY,aIndexZ));
0189
0190
0191 double mean_x = aObject.bin_mean_x(aIndexX,aIndexY,aIndexZ);
0192 if(mean_x!=0) {
0193 a_writer << " weightedMeanX=" << soutd(a_oss,mean_x);
0194 }
0195 double mean_y = aObject.bin_mean_y(aIndexX,aIndexY,aIndexZ);
0196 if(mean_y!=0) {
0197 a_writer << " weightedMeanY=" << soutd(a_oss,mean_y);
0198 }
0199 double mean_z = aObject.bin_mean_z(aIndexX,aIndexY,aIndexZ);
0200 if(mean_y!=0) {
0201 a_writer << " weightedMeanZ=" << soutd(a_oss,mean_z);
0202 }
0203
0204 double stddevX = aObject.bin_rms_x(aIndexX,aIndexY,aIndexZ);
0205 if(stddevX!=0) {
0206 a_writer << " weightedRmsX=" << soutd(a_oss,stddevX);
0207 }
0208 double stddevY = aObject.bin_rms_y(aIndexX,aIndexY,aIndexZ);
0209 if(stddevY!=0) {
0210 a_writer << " weightedRmsY=" << soutd(a_oss,stddevY);
0211 }
0212 double stddevZ = aObject.bin_rms_z(aIndexX,aIndexY,aIndexZ);
0213 if(stddevZ!=0) {
0214 a_writer << " weightedRmsZ=" << soutd(a_oss,stddevZ);
0215 }
0216
0217 a_writer << "/>" << std::endl;
0218 }
0219 }
0220
0221 inline void write_bin(
0222 std::ostream& a_writer
0223 ,std::ostringstream& a_oss
0224 ,const histo::p1d& aObject
0225 ,const std::string& aSpaces
0226 ,int aIndex
0227 ){
0228 if(aObject.bin_entries(aIndex)) {
0229 a_writer << aSpaces << " <bin1d"
0230 << " binNum=" << sout(bin_to_string(a_oss,aIndex))
0231 << " entries=" << num_out<unsigned int>(aObject.bin_entries(aIndex))
0232 << " height=" << soutd(a_oss,aObject.bin_height(aIndex))
0233 << " error=" << soutd(a_oss,aObject.bin_error(aIndex))
0234 << " weightedMean=" << soutd(a_oss,aObject.bin_mean(aIndex));
0235
0236 double stddev = aObject.bin_rms(aIndex);
0237 if(stddev!=0) {
0238 a_writer << " weightedRms=" << soutd(a_oss,stddev);
0239 }
0240
0241 a_writer << " rms=" << soutd(a_oss,aObject.bin_rms_value(aIndex));
0242 a_writer << "/>" << std::endl;
0243 }
0244 }
0245
0246 inline void write_bin(
0247 std::ostream& a_writer
0248 ,std::ostringstream& a_oss
0249 ,const histo::p2d& aObject
0250 ,const std::string& aSpaces
0251 ,int aIndexX
0252 ,int aIndexY
0253 ){
0254 if(aObject.bin_entries(aIndexX,aIndexY)) {
0255 a_writer << aSpaces << " <bin2d"
0256 << " binNumX=" << sout(bin_to_string(a_oss,aIndexX))
0257 << " binNumY=" << sout(bin_to_string(a_oss,aIndexY))
0258 << " entries=" << num_out<unsigned int>(aObject.bin_entries(aIndexX,aIndexY))
0259 << " height=" << soutd(a_oss,aObject.bin_height(aIndexX,aIndexY))
0260 << " error=" << soutd(a_oss,aObject.bin_error(aIndexX,aIndexY))
0261 << " weightedMeanX=" << soutd(a_oss,aObject.bin_mean_x(aIndexX,aIndexY))
0262 << " weightedMeanY=" << soutd(a_oss,aObject.bin_mean_y(aIndexX,aIndexY));
0263
0264 double stddevX = aObject.bin_rms_x(aIndexX,aIndexY);
0265 if(stddevX!=0) {
0266 a_writer << " weightedRmsX=" << soutd(a_oss,stddevX);
0267 }
0268 double stddevY = aObject.bin_rms_y(aIndexX,aIndexY);
0269 if(stddevY!=0) {
0270 a_writer << " weightedRmsY=" << soutd(a_oss,stddevY);
0271 }
0272
0273 a_writer << " rms=" << soutd(a_oss,aObject.bin_rms_value(aIndexX,aIndexY));
0274 a_writer << "/>" << std::endl;
0275 }
0276 }
0277
0278 inline bool write(
0279 std::ostream& a_writer
0280 ,const histo::h1d& aObject
0281 ,const std::string& aPath
0282 ,const std::string& aName
0283 ,int aShift = 0
0284 ){
0285 std::ostringstream ossd;
0286 ossd.precision(25);
0287
0288 typedef histo::axis<double,unsigned int>::bn_t bn_t;
0289
0290 std::ostream& writer = a_writer;
0291
0292 std::string spaces;
0293 for(int i=0;i<aShift;i++) spaces += " ";
0294
0295 // <histogram1d> :
0296 writer << spaces << " <histogram1d"
0297 << " path=" << sout(to_xml(aPath))
0298 << " name=" << sout(to_xml(aName))
0299 << " title=" << sout(to_xml(aObject.title()))
0300 << ">" << std::endl;
0301
0302 // <annotations> :
0303 write_annotations(aObject.annotations(),writer,aShift);
0304
0305 // <axis> :
0306 write_axis(aObject.axis(),"x",writer,ossd,aShift);
0307
0308 // <statistics> :
0309 writer << spaces << " <statistics"
0310 << " entries=" << num_out<unsigned int>(aObject.entries())
0311 << ">" << std::endl;
0312 writer << spaces << " <statistic"
0313 << " direction=" << sout("x")
0314 << " mean=" << soutd(ossd,aObject.mean())
0315 << " rms=" << soutd(ossd,aObject.rms())
0316 << "/>" << std::endl;
0317 writer << spaces << " </statistics>" << std::endl;
0318
0319 // bins :
0320 writer << spaces << " <data1d>" << std::endl;
0321
0322 bn_t xbins = aObject.axis().bins();
0323 for(bn_t index=0;index<xbins;index++)
0324 write_bin(writer,ossd,aObject,spaces,index);
0325
0326 write_bin(writer,ossd,aObject,spaces,histo::axis_UNDERFLOW_BIN);
0327 write_bin(writer,ossd,aObject,spaces,histo::axis_OVERFLOW_BIN);
0328
0329 writer << spaces << " </data1d>" << std::endl;
0330 writer << spaces << " </histogram1d>" << std::endl;
0331
0332 return true;
0333 }
0334
0335 inline bool write(
0336 std::ostream& a_writer
0337 ,const histo::h2d& aObject
0338 ,const std::string& aPath
0339 ,const std::string& aName
0340 ,int aShift = 0
0341 ){
0342 std::ostringstream ossd;
0343 ossd.precision(25);
0344
0345 typedef histo::axis<double,unsigned int>::bn_t bn_t;
0346
0347 std::ostream& writer = a_writer;
0348
0349 std::string spaces;
0350 for(int i=0;i<aShift;i++) spaces += " ";
0351
0352 // <histogram2d> :
0353 writer << spaces << " <histogram2d"
0354 << " path=" << sout(to_xml(aPath))
0355 << " name=" << sout(to_xml(aName))
0356 << " title=" << sout(to_xml(aObject.title()))
0357 << ">" << std::endl;
0358
0359 // <annotations> :
0360 write_annotations(aObject.annotations(),writer,aShift);
0361
0362 // <axis> :
0363 write_axis(aObject.axis_x(),"x",writer,ossd,aShift);
0364 write_axis(aObject.axis_y(),"y",writer,ossd,aShift);
0365
0366 // <statistics> :
0367 writer << spaces << " <statistics"
0368 << " entries=" << num_out<unsigned int>(aObject.entries())
0369 << ">" << std::endl;
0370 writer << spaces << " <statistic"
0371 << " direction=" << sout("x")
0372 << " mean=" << soutd(ossd,aObject.mean_x())
0373 << " rms=" << soutd(ossd,aObject.rms_x())
0374 << "/>" << std::endl;
0375 writer << spaces << " <statistic"
0376 << " direction=" << sout("y")
0377 << " mean=" << soutd(ossd,aObject.mean_y())
0378 << " rms=" << soutd(ossd,aObject.rms_y())
0379 << "/>" << std::endl;
0380 writer << spaces << " </statistics>" << std::endl;
0381
0382 // bins :
0383 writer << spaces << " <data2d>" << std::endl;
0384
0385 bn_t xbins = aObject.axis_x().bins();
0386 bn_t ybins = aObject.axis_y().bins();
0387 bn_t indexX,indexY;
0388 for(indexX=0;indexX<xbins;indexX++) {
0389 for(indexY=0;indexY<ybins;indexY++) {
0390 write_bin(writer,ossd,aObject,spaces,indexX,indexY);
0391 }
0392 }
0393
0394 write_bin(writer,ossd,aObject,spaces,histo::axis_UNDERFLOW_BIN,histo::axis_UNDERFLOW_BIN);
0395 write_bin(writer,ossd,aObject,spaces,histo::axis_OVERFLOW_BIN,histo::axis_UNDERFLOW_BIN);
0396 write_bin(writer,ossd,aObject,spaces,histo::axis_UNDERFLOW_BIN,histo::axis_OVERFLOW_BIN);
0397 write_bin(writer,ossd,aObject,spaces,histo::axis_OVERFLOW_BIN,histo::axis_OVERFLOW_BIN);
0398
0399 for(indexX=0;indexX<xbins;indexX++){
0400 write_bin(writer,ossd,aObject,spaces,indexX,histo::axis_UNDERFLOW_BIN);
0401 write_bin(writer,ossd,aObject,spaces,indexX,histo::axis_OVERFLOW_BIN);
0402 }
0403
0404 for(indexY=0;indexY<ybins;indexY++){
0405 write_bin(writer,ossd,aObject,spaces,histo::axis_UNDERFLOW_BIN,indexY);
0406 write_bin(writer,ossd,aObject,spaces,histo::axis_OVERFLOW_BIN,indexY);
0407 }
0408
0409 writer << spaces << " </data2d>" << std::endl;
0410 writer << spaces << " </histogram2d>" << std::endl;
0411
0412 return true;
0413 }
0414
0415 inline bool write(
0416 std::ostream& a_writer
0417 ,const histo::h3d& aObject
0418 ,const std::string& aPath
0419 ,const std::string& aName
0420 ,int aShift = 0
0421 ){
0422 std::ostringstream ossd;
0423 ossd.precision(25);
0424
0425 typedef histo::axis<double,unsigned int>::bn_t bn_t;
0426 std::ostream& writer = a_writer;
0427
0428 std::string spaces;
0429 for(int i=0;i<aShift;i++) spaces += " ";
0430
0431 // <histogram3d> :
0432 writer << spaces << " <histogram3d"
0433 << " path=" << sout(to_xml(aPath))
0434 << " name=" << sout(to_xml(aName))
0435 << " title=" << sout(to_xml(aObject.title()))
0436 << ">" << std::endl;
0437
0438 // <annotations> :
0439 write_annotations(aObject.annotations(),writer,aShift);
0440
0441 // <axis> :
0442 write_axis(aObject.axis_x(),"x",writer,ossd,aShift);
0443 write_axis(aObject.axis_y(),"y",writer,ossd,aShift);
0444 write_axis(aObject.axis_z(),"z",writer,ossd,aShift);
0445
0446 // <statistics> :
0447 writer << spaces << " <statistics"
0448 << " entries=" << num_out<unsigned int>(aObject.entries())
0449 << ">" << std::endl;
0450 writer << spaces << " <statistic"
0451 << " direction=" << sout("x")
0452 << " mean=" << soutd(ossd,aObject.mean_x())
0453 << " rms=" << soutd(ossd,aObject.rms_x())
0454 << "/>" << std::endl;
0455 writer << spaces << " <statistic"
0456 << " direction=" << sout("y")
0457 << " mean=" << soutd(ossd,aObject.mean_y())
0458 << " rms=" << soutd(ossd,aObject.rms_y())
0459 << "/>" << std::endl;
0460 writer << spaces << " <statistic"
0461 << " direction=" << sout("z")
0462 << " mean=" << soutd(ossd,aObject.mean_z())
0463 << " rms=" << soutd(ossd,aObject.rms_z())
0464 << "/>" << std::endl;
0465 writer << spaces << " </statistics>" << std::endl;
0466
0467 // bins :
0468 writer << spaces << " <data3d>" << std::endl;
0469 bn_t xbins = aObject.axis_x().bins();
0470 bn_t ybins = aObject.axis_y().bins();
0471 bn_t zbins = aObject.axis_z().bins();
0472 bn_t indexX,indexY,indexZ;
0473 for(indexX=0;indexX<xbins;indexX++) {
0474 for(indexY=0;indexY<ybins;indexY++) {
0475 for(indexZ=0;indexZ<zbins;indexZ++) {
0476 write_bin(writer,ossd,aObject,spaces,indexX,indexY,indexZ);
0477 }
0478 }
0479 }
0480
0481 // Corners :
0482 write_bin(writer,ossd,aObject,spaces,
0483 histo::axis_UNDERFLOW_BIN,
0484 histo::axis_UNDERFLOW_BIN,
0485 histo::axis_UNDERFLOW_BIN);
0486 write_bin(writer,ossd,aObject,spaces,
0487 histo::axis_OVERFLOW_BIN,
0488 histo::axis_UNDERFLOW_BIN,
0489 histo::axis_UNDERFLOW_BIN);
0490 write_bin(writer,ossd,aObject,spaces,
0491 histo::axis_UNDERFLOW_BIN,
0492 histo::axis_OVERFLOW_BIN,
0493 histo::axis_UNDERFLOW_BIN);
0494 write_bin(writer,ossd,aObject,spaces,
0495 histo::axis_OVERFLOW_BIN,
0496 histo::axis_OVERFLOW_BIN,
0497 histo::axis_UNDERFLOW_BIN);
0498
0499 write_bin(writer,ossd,aObject,spaces,
0500 histo::axis_UNDERFLOW_BIN,
0501 histo::axis_UNDERFLOW_BIN,
0502 histo::axis_OVERFLOW_BIN);
0503 write_bin(writer,ossd,aObject,spaces,
0504 histo::axis_OVERFLOW_BIN,
0505 histo::axis_UNDERFLOW_BIN,
0506 histo::axis_OVERFLOW_BIN);
0507 write_bin(writer,ossd,aObject,spaces,
0508 histo::axis_UNDERFLOW_BIN,
0509 histo::axis_OVERFLOW_BIN,
0510 histo::axis_OVERFLOW_BIN);
0511 write_bin(writer,ossd,aObject,spaces,
0512 histo::axis_OVERFLOW_BIN,
0513 histo::axis_OVERFLOW_BIN,
0514 histo::axis_OVERFLOW_BIN);
0515
0516
0517 // Edges :
0518 for(indexX=0;indexX<xbins;indexX++){
0519 write_bin(writer,ossd,aObject,spaces,
0520 indexX,
0521 histo::axis_UNDERFLOW_BIN,
0522 histo::axis_UNDERFLOW_BIN);
0523 write_bin(writer,ossd,aObject,spaces,
0524 indexX,
0525 histo::axis_OVERFLOW_BIN,
0526 histo::axis_UNDERFLOW_BIN);
0527 write_bin(writer,ossd,aObject,spaces,
0528 indexX,
0529 histo::axis_UNDERFLOW_BIN,
0530 histo::axis_OVERFLOW_BIN);
0531 write_bin(writer,ossd,aObject,spaces,
0532 indexX,
0533 histo::axis_OVERFLOW_BIN,
0534 histo::axis_OVERFLOW_BIN);
0535 }
0536
0537 for(indexY=0;indexY<ybins;indexY++){
0538 write_bin(writer,ossd,aObject,spaces,
0539 histo::axis_UNDERFLOW_BIN,
0540 indexY,
0541 histo::axis_UNDERFLOW_BIN);
0542 write_bin(writer,ossd,aObject,spaces,
0543 histo::axis_OVERFLOW_BIN,
0544 indexY,
0545 histo::axis_UNDERFLOW_BIN);
0546 write_bin(writer,ossd,aObject,spaces,
0547 histo::axis_UNDERFLOW_BIN,
0548 indexY,
0549 histo::axis_OVERFLOW_BIN);
0550 write_bin(writer,ossd,aObject,spaces,
0551 histo::axis_OVERFLOW_BIN,
0552 indexY,
0553 histo::axis_OVERFLOW_BIN);
0554 }
0555
0556 for(indexZ=0;indexZ<zbins;indexZ++){
0557 write_bin(writer,ossd,aObject,spaces,
0558 histo::axis_UNDERFLOW_BIN,
0559 histo::axis_UNDERFLOW_BIN,
0560 indexZ);
0561 write_bin(writer,ossd,aObject,spaces,
0562 histo::axis_OVERFLOW_BIN,
0563 histo::axis_UNDERFLOW_BIN,
0564 indexZ);
0565 write_bin(writer,ossd,aObject,spaces,
0566 histo::axis_UNDERFLOW_BIN,
0567 histo::axis_OVERFLOW_BIN,
0568 indexZ);
0569 write_bin(writer,ossd,aObject,spaces,
0570 histo::axis_OVERFLOW_BIN,
0571 histo::axis_OVERFLOW_BIN,
0572 indexZ);
0573 }
0574
0575
0576 // Faces :
0577 for(indexX=0;indexX<xbins;indexX++) {
0578 for(indexY=0;indexY<ybins;indexY++) {
0579 write_bin(writer,ossd,aObject,spaces,
0580 indexX,indexY,histo::axis_UNDERFLOW_BIN);
0581 write_bin(writer,ossd,aObject,spaces,
0582 indexX,indexY,histo::axis_OVERFLOW_BIN);
0583 }
0584 }
0585 for(indexY=0;indexY<ybins;indexY++) {
0586 for(indexZ=0;indexZ<zbins;indexZ++) {
0587 write_bin(writer,ossd,aObject,spaces,
0588 histo::axis_UNDERFLOW_BIN,indexY,indexZ);
0589 write_bin(writer,ossd,aObject,spaces,
0590 histo::axis_OVERFLOW_BIN,indexY,indexZ);
0591 }
0592 }
0593 for(indexX=0;indexX<xbins;indexX++) {
0594 for(indexZ=0;indexZ<zbins;indexZ++) {
0595 write_bin(writer,ossd,aObject,spaces,
0596 indexX,histo::axis_UNDERFLOW_BIN,indexZ);
0597 write_bin(writer,ossd,aObject,spaces,
0598 indexX,histo::axis_OVERFLOW_BIN,indexZ);
0599 }
0600 }
0601
0602 writer << spaces << " </data3d>" << std::endl;
0603 writer << spaces << " </histogram3d>" << std::endl;
0604
0605 return true;
0606 }
0607
0608 inline bool write(
0609 std::ostream& a_writer
0610 ,const histo::p1d& aObject
0611 ,const std::string& aPath
0612 ,const std::string& aName
0613 ,int aShift = 0
0614 ){
0615 std::ostringstream ossd;
0616 ossd.precision(25);
0617
0618 typedef histo::axis<double,unsigned int>::bn_t bn_t;
0619 std::ostream& writer = a_writer;
0620
0621 std::string spaces;
0622 for(int i=0;i<aShift;i++) spaces += " ";
0623
0624 // <profile1d> :
0625 writer << spaces << " <profile1d"
0626 << " path=" << sout(to_xml(aPath))
0627 << " name=" << sout(to_xml(aName))
0628 << " title=" << sout(to_xml(aObject.title()))
0629 << ">" << std::endl;
0630
0631 // <annotations> :
0632 write_annotations(aObject.annotations(),writer,aShift);
0633
0634 // <axis> :
0635 write_axis(aObject.axis(),"x",writer,ossd,aShift);
0636
0637 // <statistics> :
0638 writer << spaces << " <statistics"
0639 << " entries=" << num_out<unsigned int>(aObject.entries())
0640 << ">" << std::endl;
0641 writer << spaces << " <statistic"
0642 << " direction=" << sout("x")
0643 << " mean=" << soutd(ossd,aObject.mean())
0644 << " rms=" << soutd(ossd,aObject.rms())
0645 << "/>" << std::endl;
0646 writer << spaces << " </statistics>" << std::endl;
0647
0648 // bins :
0649 writer << spaces << " <data1d>" << std::endl;
0650 bn_t xbins = aObject.axis().bins();
0651 for(bn_t index=0;index<xbins;index++) {
0652 write_bin(writer,ossd,aObject,spaces,index);
0653 }
0654
0655 write_bin(writer,ossd,aObject,spaces,histo::axis_UNDERFLOW_BIN);
0656 write_bin(writer,ossd,aObject,spaces,histo::axis_OVERFLOW_BIN);
0657
0658 writer << spaces << " </data1d>" << std::endl;
0659 writer << spaces << " </profile1d>" << std::endl;
0660
0661 return true;
0662 }
0663
0664 inline bool write(
0665 std::ostream& a_writer
0666 ,const histo::p2d& aObject
0667 ,const std::string& aPath
0668 ,const std::string& aName
0669 ,int aShift = 0
0670 ){
0671 std::ostringstream ossd;
0672 ossd.precision(25);
0673
0674 typedef histo::axis<double,unsigned int>::bn_t bn_t;
0675 std::ostream& writer = a_writer;
0676
0677 std::string spaces;
0678 for(int i=0;i<aShift;i++) spaces += " ";
0679
0680 // <profile2d> :
0681 writer << spaces << " <profile2d"
0682 << " path=" << sout(to_xml(aPath))
0683 << " name=" << sout(to_xml(aName))
0684 << " title=" << sout(to_xml(aObject.title()))
0685 << ">" << std::endl;
0686
0687 // <annotations> :
0688 write_annotations(aObject.annotations(),writer,aShift);
0689
0690 // <axis> :
0691 write_axis(aObject.axis_x(),"x",writer,ossd,aShift);
0692 write_axis(aObject.axis_y(),"y",writer,ossd,aShift);
0693
0694 // <statistics> :
0695 writer << spaces << " <statistics"
0696 << " entries=" << num_out<unsigned int>(aObject.entries())
0697 << ">" << std::endl;
0698 writer << spaces << " <statistic"
0699 << " direction=" << sout("x")
0700 << " mean=" << soutd(ossd,aObject.mean_x())
0701 << " rms=" << soutd(ossd,aObject.rms_x())
0702 << "/>" << std::endl;
0703 writer << spaces << " <statistic"
0704 << " direction=" << sout("y")
0705 << " mean=" << soutd(ossd,aObject.mean_y())
0706 << " rms=" << soutd(ossd,aObject.rms_y())
0707 << "/>" << std::endl;
0708 writer << spaces << " </statistics>" << std::endl;
0709
0710 // bins :
0711 writer << spaces << " <data2d>" << std::endl;
0712 {bn_t xbins = aObject.axis_x().bins();
0713 bn_t ybins = aObject.axis_y().bins();
0714 for(bn_t indexX=0;indexX<xbins;indexX++) {
0715 for(bn_t indexY=0;indexY<ybins;indexY++) {
0716 write_bin(writer,ossd,aObject,spaces,indexX,indexY);
0717 }
0718 }}
0719
0720 write_bin(writer,ossd,aObject,spaces,
0721 histo::axis_UNDERFLOW_BIN,histo::axis_UNDERFLOW_BIN);
0722 write_bin(writer,ossd,aObject,spaces,
0723 histo::axis_OVERFLOW_BIN,histo::axis_UNDERFLOW_BIN);
0724 write_bin(writer,ossd,aObject,spaces,
0725 histo::axis_UNDERFLOW_BIN,histo::axis_OVERFLOW_BIN);
0726 write_bin(writer,ossd,aObject,spaces,
0727 histo::axis_OVERFLOW_BIN,histo::axis_OVERFLOW_BIN);
0728
0729 for(bn_t indexX=0;indexX<aObject.axis_x().bins();indexX++){
0730 write_bin(writer,ossd,aObject,spaces,indexX,histo::axis_UNDERFLOW_BIN);
0731 write_bin(writer,ossd,aObject,spaces,indexX,histo::axis_OVERFLOW_BIN);
0732 }
0733
0734 for(bn_t indexY=0;indexY<aObject.axis_y().bins();indexY++){
0735 write_bin(writer,ossd,aObject,spaces,histo::axis_UNDERFLOW_BIN,indexY);
0736 write_bin(writer,ossd,aObject,spaces,histo::axis_OVERFLOW_BIN,indexY);
0737 }
0738
0739 writer << spaces << " </data2d>" << std::endl;
0740 writer << spaces << " </profile2d>" << std::endl;
0741
0742 return true;
0743 }
0744
0745 }}
0746
0747 #endif