inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/waxml/histos
Go to the documentation of this file.
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
00002 // See the file inlib.license for terms.
00003 
00004 #ifndef inlib_waxml_histos
00005 #define inlib_waxml_histos
00006 
00007 #include "../histo/h1d"
00008 #include "../histo/h2d"
00009 #include "../histo/h3d"
00010 #include "../histo/p1d"
00011 #include "../histo/p2d"
00012 
00013 #include "../sout"
00014 #include "../sto"
00015 
00016 namespace inlib {
00017 namespace waxml {
00018 
00019   inline std::string bin_to_string(int a_index) {
00020     if(a_index==histo::axis<double>::UNDERFLOW_BIN) {
00021       return "UNDERFLOW";
00022     } else if(a_index==histo::axis<double>::OVERFLOW_BIN) {
00023       return "OVERFLOW";
00024     } else {
00025       std::ostringstream strm;
00026       strm << a_index;
00027       return strm.str();
00028     }
00029   }
00030   
00031   inline void write_axis(
00032    const histo::axis<double>& aAxis
00033   ,const std::string& aDirection
00034   ,std::ostream& a_writer
00035   ,int aShift
00036   ){
00037     typedef histo::axis<double>::bn_t bn_t;
00038 
00039     std::string spaces;
00040     for(int i=0;i<aShift;i++) spaces += " ";
00041   
00042     if(aAxis.is_fixed_binning()) {
00043       a_writer << spaces << "    <axis"
00044            << " direction=" << sout(aDirection) 
00045            << " numberOfBins=" << sout<bn_t>(aAxis.bins())
00046            << " min=" << soutd(aAxis.lower_edge())
00047            << " max=" << soutd(aAxis.upper_edge())
00048            << "/>" << std::endl;
00049     } else {
00050       a_writer << spaces << "    <axis"
00051            << " direction=" << sout(aDirection) 
00052            << " numberOfBins=" << sout<bn_t>(aAxis.bins())
00053            << " min=" << soutd(aAxis.lower_edge())
00054            << " max=" << soutd(aAxis.upper_edge())
00055            << ">" << std::endl;
00056       bn_t number = aAxis.bins()-1;
00057       for(bn_t index=0;index<number;index++) {
00058         a_writer << spaces << "      <binBorder"
00059              << " value=" << soutd(aAxis.bin_upper_edge(index))
00060              << "/>" << std::endl;
00061       }
00062       a_writer << spaces << "    </axis>" << std::endl;
00063     }
00064   }
00065   
00066   inline void write_bin(
00067    std::ostream& a_writer
00068   ,const histo::h1d& aObject
00069   ,const std::string& aSpaces
00070   ,int aIndex
00071   ){
00072     unsigned int entries = aObject.bin_entries(aIndex);
00073     if(entries) {
00074       a_writer << aSpaces << "      <bin1d"
00075            << " binNum=" << sout(bin_to_string(aIndex))
00076            << " entries=" << sout<unsigned int>(entries)
00077            << " height=" << soutd(aObject.bin_height(aIndex))
00078            << " error=" << soutd(aObject.bin_error(aIndex));
00079   
00080       double mean = aObject.bin_mean(aIndex);
00081       if(mean!=0) {
00082         a_writer << " weightedMean=" << soutd(mean);
00083       }
00084   
00085       double stddev = aObject.bin_rms(aIndex);
00086       if(stddev!=0) {
00087         a_writer << " weightedRms=" << soutd(stddev);
00088       }
00089   
00090       a_writer << "/>" << std::endl;
00091     }
00092   }
00093   
00094   inline void write_bin(
00095    std::ostream& a_writer
00096   ,const histo::h2d& aObject
00097   ,const std::string& aSpaces
00098   ,int aIndexX
00099   ,int aIndexY
00100   ){
00101     unsigned int entries = aObject.bin_entries(aIndexX,aIndexY);
00102     if(entries) {
00103       a_writer << aSpaces << "      <bin2d"
00104            << " binNumX=" << sout(bin_to_string(aIndexX))
00105            << " binNumY=" << sout(bin_to_string(aIndexY))
00106            << " entries=" << sout<unsigned int>(entries)
00107            << " height=" << soutd(aObject.bin_height(aIndexX,aIndexY))
00108            << " error=" << soutd(aObject.bin_error(aIndexX,aIndexY));
00109   
00110       double mean_x = aObject.bin_mean_x(aIndexX,aIndexY);
00111       if(mean_x!=0) {
00112         a_writer << " weightedMeanX=" << soutd(mean_x);
00113       }
00114       double mean_y = aObject.bin_mean_y(aIndexX,aIndexY);
00115       if(mean_y!=0) {
00116         a_writer << " weightedMeanY=" << soutd(mean_y);
00117       }
00118   
00119       double stddevX = aObject.bin_rms_x(aIndexX,aIndexY);
00120       if(stddevX!=0) {
00121         a_writer << " weightedRmsX=" << soutd(stddevX);
00122       }
00123       double stddevY = aObject.bin_rms_y(aIndexX,aIndexY);
00124       if(stddevY!=0) {
00125         a_writer << " weightedRmsY=" << soutd(stddevY);
00126       }
00127   
00128       a_writer << "/>" << std::endl;
00129     }
00130   }
00131   
00132   inline void write_bin(
00133    std::ostream& a_writer
00134   ,const histo::h3d& aObject
00135   ,const std::string& aSpaces
00136   ,int aIndexX
00137   ,int aIndexY
00138   ,int aIndexZ
00139   ){
00140     unsigned int entries = aObject.bin_entries(aIndexX,aIndexY,aIndexZ);
00141     if(entries) {
00142       a_writer << aSpaces << "      <bin3d"
00143            << " binNumX=" << sout(bin_to_string(aIndexX))
00144            << " binNumY=" << sout(bin_to_string(aIndexY))
00145            << " binNumZ=" << sout(bin_to_string(aIndexZ))
00146            << " entries=" << sout<unsigned int>(entries)
00147            << " height=" << soutd(aObject.bin_height(aIndexX,aIndexY,aIndexZ))
00148            << " error=" << soutd(aObject.bin_error(aIndexX,aIndexY,aIndexZ));
00149   
00150   
00151       double mean_x = aObject.bin_mean_x(aIndexX,aIndexY,aIndexZ);
00152       if(mean_x!=0) {
00153         a_writer << " weightedMeanX=" << soutd(mean_x);
00154       }
00155       double mean_y = aObject.bin_mean_y(aIndexX,aIndexY,aIndexZ);
00156       if(mean_y!=0) {
00157         a_writer << " weightedMeanY=" << soutd(mean_y);
00158       }
00159       double mean_z = aObject.bin_mean_z(aIndexX,aIndexY,aIndexZ);
00160       if(mean_y!=0) {
00161         a_writer << " weightedMeanZ=" << soutd(mean_z);
00162       }
00163   
00164       double stddevX = aObject.bin_rms_x(aIndexX,aIndexY,aIndexZ);
00165       if(stddevX!=0) {
00166         a_writer << " weightedRmsX=" << soutd(stddevX);
00167       }
00168       double stddevY = aObject.bin_rms_y(aIndexX,aIndexY,aIndexZ);
00169       if(stddevY!=0) {
00170         a_writer << " weightedRmsY=" << soutd(stddevY);
00171       }
00172       double stddevZ = aObject.bin_rms_z(aIndexX,aIndexY,aIndexZ);
00173       if(stddevZ!=0) {
00174         a_writer << " weightedRmsZ=" << soutd(stddevZ);
00175       }
00176   
00177       a_writer << "/>" << std::endl;
00178     }
00179   }
00180   
00181   inline void write_bin(
00182    std::ostream& a_writer
00183   ,const histo::p1d& aObject
00184   ,const std::string& aSpaces
00185   ,int aIndex
00186   ){
00187     if(aObject.bin_entries(aIndex)) {
00188       a_writer << aSpaces << "      <bin1d"
00189            << " binNum=" << sout(bin_to_string(aIndex))
00190            << " entries=" << sout<unsigned int>(aObject.bin_entries(aIndex))
00191            << " height=" << soutd(aObject.bin_height(aIndex))
00192            << " error=" << soutd(aObject.bin_error(aIndex))
00193            << " weightedMean=" << soutd(aObject.bin_mean(aIndex));
00194   
00195       double stddev = aObject.bin_rms(aIndex);
00196       if(stddev!=0) {
00197         a_writer << " weightedRms=" << soutd(stddev);
00198       }
00199   
00200       a_writer << " rms=" << soutd(aObject.bin_rms_value(aIndex));
00201       a_writer << "/>" << std::endl;
00202     }
00203   }
00204   
00205   inline void write_bin(
00206    std::ostream& a_writer
00207   ,const histo::p2d& aObject
00208   ,const std::string& aSpaces
00209   ,int aIndexX
00210   ,int aIndexY
00211   ){
00212     if(aObject.bin_entries(aIndexX,aIndexY)) {
00213       a_writer << aSpaces << "      <bin2d"
00214            << " binNumX=" << sout(bin_to_string(aIndexX))
00215            << " binNumY=" << sout(bin_to_string(aIndexY))
00216            << " entries=" << sout<unsigned int>(aObject.bin_entries(aIndexX,aIndexY))
00217            << " height=" << soutd(aObject.bin_height(aIndexX,aIndexY))
00218            << " error=" << soutd(aObject.bin_error(aIndexX,aIndexY))
00219            << " weightedMeanX=" << soutd(aObject.bin_mean_x(aIndexX,aIndexY))
00220            << " weightedMeanY=" << soutd(aObject.bin_mean_y(aIndexX,aIndexY));
00221   
00222       double stddevX = aObject.bin_rms_x(aIndexX,aIndexY);
00223       if(stddevX!=0) {
00224         a_writer << " weightedRmsX=" << soutd(stddevX);
00225       }
00226       double stddevY = aObject.bin_rms_y(aIndexX,aIndexY);
00227       if(stddevY!=0) {
00228         a_writer << " weightedRmsY=" << soutd(stddevY);
00229       }
00230   
00231       a_writer << " rms=" << soutd(aObject.bin_rms_value(aIndexX,aIndexY));
00232       a_writer << "/>" << std::endl;
00233     }
00234   }
00235 
00236   inline bool write(
00237    std::ostream& a_writer
00238   ,const histo::h1d& aObject
00239   ,const std::string& aPath
00240   ,const std::string& aName
00241   ,int aShift = 0
00242   ){
00243     typedef histo::axis<double>::bn_t bn_t;
00244 
00245     std::ostream& writer = a_writer;
00246   
00247     std::string spaces;
00248     for(int i=0;i<aShift;i++) spaces += " ";
00249   
00250     // <histogram1d> :
00251     writer << spaces << "  <histogram1d"
00252          << " path=" << sout(aPath)
00253          << " name=" << sout(aName)
00254          << " title=" << sout(aObject.title())
00255          << ">" << std::endl;
00256   
00257     // <axis> :
00258     write_axis(aObject.axis(),"x",writer,aShift);
00259   
00260     // <statistics> : 
00261     writer << spaces << "    <statistics"
00262            << " entries=" << sout<unsigned int>(aObject.entries())
00263            << ">" << std::endl;
00264     writer << spaces << "      <statistic"
00265          << " direction=" << sout("x") 
00266          << " mean=" << soutd(aObject.mean()) 
00267          << " rms=" << soutd(aObject.rms())
00268          << "/>" << std::endl;
00269     writer << spaces << "    </statistics>" << std::endl;
00270     
00271     // bins :
00272     writer << spaces << "    <data1d>" << std::endl;
00273   
00274     bn_t xbins = aObject.axis().bins();
00275     for(bn_t index=0;index<xbins;index++)
00276       write_bin(writer,aObject,spaces,index);
00277   
00278     write_bin(writer,aObject,spaces,histo::axis<double>::UNDERFLOW_BIN);
00279     write_bin(writer,aObject,spaces,histo::axis<double>::OVERFLOW_BIN);
00280   
00281     writer << spaces << "    </data1d>" << std::endl;
00282     writer << spaces << "  </histogram1d>" << std::endl;
00283   
00284     return true;  
00285   }
00286   
00287   inline bool write(
00288    std::ostream& a_writer
00289   ,const histo::h2d& aObject
00290   ,const std::string& aPath
00291   ,const std::string& aName
00292   ,int aShift = 0
00293   ){
00294     typedef histo::axis<double>::bn_t bn_t;
00295 
00296     std::ostream& writer = a_writer;
00297   
00298     std::string spaces;
00299     for(int i=0;i<aShift;i++) spaces += " ";
00300 
00301     // <histogram2d> :
00302     writer << spaces << "  <histogram2d"
00303          << " path=" << sout(aPath)
00304          << " name=" << sout(aName)
00305          << " title=" << sout(aObject.title())
00306          << ">" << std::endl;
00307   
00308   
00309     // <axis> :
00310     write_axis(aObject.axis_x(),"x",writer,aShift);
00311     write_axis(aObject.axis_y(),"y",writer,aShift);
00312   
00313     // <statistics> : 
00314     writer << spaces << "    <statistics"
00315          << " entries=" << sout<unsigned int>(aObject.entries())
00316          << ">" << std::endl;
00317     writer << spaces << "      <statistic"
00318          << " direction=" << sout("x")
00319          << " mean=" << soutd(aObject.mean_x())
00320          << " rms=" << soutd(aObject.rms_x()) 
00321          << "/>" << std::endl;
00322     writer << spaces << "      <statistic"
00323          << " direction=" << sout("y")
00324          << " mean=" << soutd(aObject.mean_y())
00325          << " rms=" << soutd(aObject.rms_y()) 
00326          << "/>" << std::endl;
00327     writer << spaces << "    </statistics>" << std::endl;
00328     
00329     // bins :
00330     writer << spaces << "    <data2d>" << std::endl;
00331   
00332     bn_t xbins = aObject.axis_x().bins();
00333     bn_t ybins = aObject.axis_y().bins();
00334     bn_t indexX,indexY;
00335     for(indexX=0;indexX<xbins;indexX++) {
00336       for(indexY=0;indexY<ybins;indexY++) {
00337         write_bin(writer,aObject,spaces,indexX,indexY);
00338       }
00339     }
00340     
00341     write_bin(writer,aObject,spaces,
00342                       histo::axis<double>::UNDERFLOW_BIN,histo::axis<double>::UNDERFLOW_BIN);
00343     write_bin(writer,aObject,spaces,
00344                       histo::axis<double>::OVERFLOW_BIN,histo::axis<double>::UNDERFLOW_BIN);
00345     write_bin(writer,aObject,spaces,
00346                       histo::axis<double>::UNDERFLOW_BIN,histo::axis<double>::OVERFLOW_BIN);
00347     write_bin(writer,aObject,spaces,
00348                       histo::axis<double>::OVERFLOW_BIN,histo::axis<double>::OVERFLOW_BIN);
00349   
00350     for(indexX=0;indexX<xbins;indexX++){
00351       write_bin(writer,aObject,spaces,indexX,histo::axis<double>::UNDERFLOW_BIN);
00352       write_bin(writer,aObject,spaces,indexX,histo::axis<double>::OVERFLOW_BIN);
00353     }
00354   
00355     for(indexY=0;indexY<ybins;indexY++){
00356       write_bin(writer,aObject,spaces,histo::axis<double>::UNDERFLOW_BIN,indexY);
00357       write_bin(writer,aObject,spaces,histo::axis<double>::OVERFLOW_BIN,indexY);
00358     }
00359   
00360     writer << spaces << "    </data2d>" << std::endl;
00361     writer << spaces << "  </histogram2d>" << std::endl;
00362   
00363     return true;
00364   }
00365   
00366   inline bool write(
00367    std::ostream& a_writer
00368   ,const histo::h3d& aObject
00369   ,const std::string& aPath
00370   ,const std::string& aName
00371   ,int aShift = 0
00372   ){
00373     typedef histo::axis<double>::bn_t bn_t;
00374     std::ostream& writer = a_writer;
00375   
00376     std::string spaces;
00377     for(int i=0;i<aShift;i++) spaces += " ";
00378   
00379     // <histogram3d> :
00380     writer << spaces << "  <histogram3d"
00381          << " path=" << sout(aPath)
00382          << " name=" << sout(aName)
00383          << " title=" << sout(aObject.title())
00384          << ">" << std::endl;
00385   
00386     // <axis> :
00387     write_axis(aObject.axis_x(),"x",writer,aShift);
00388     write_axis(aObject.axis_y(),"y",writer,aShift);
00389     write_axis(aObject.axis_z(),"z",writer,aShift);
00390   
00391     // <statistics> : 
00392     writer << spaces << "    <statistics"
00393          << " entries=" << sout<unsigned int>(aObject.entries())
00394          << ">" << std::endl;
00395     writer << spaces << "      <statistic"
00396          << " direction=" << sout("x")
00397          << " mean=" << soutd(aObject.mean_x())
00398          << " rms=" << soutd(aObject.rms_x())
00399          << "/>" << std::endl;
00400     writer << spaces << "      <statistic"
00401          << " direction=" << sout("y")
00402          << " mean=" << soutd(aObject.mean_y())
00403          << " rms=" << soutd(aObject.rms_y())
00404          << "/>" << std::endl;
00405     writer << spaces << "      <statistic"
00406          << " direction=" << sout("z")
00407          << " mean=" << soutd(aObject.mean_z())
00408          << " rms=" << soutd(aObject.rms_z())
00409          << "/>" << std::endl;
00410     writer << spaces << "    </statistics>" << std::endl;
00411     
00412     // bins :
00413     writer << spaces << "    <data3d>" << std::endl;
00414     bn_t xbins = aObject.axis_x().bins();
00415     bn_t ybins = aObject.axis_y().bins();
00416     bn_t zbins = aObject.axis_z().bins();
00417     bn_t indexX,indexY,indexZ;
00418     for(indexX=0;indexX<xbins;indexX++) {
00419       for(indexY=0;indexY<ybins;indexY++) {
00420         for(indexZ=0;indexZ<zbins;indexZ++) {
00421           write_bin(writer,aObject,spaces,indexX,indexY,indexZ);
00422         }
00423       }
00424     }
00425   
00426     // Corners :
00427     write_bin(writer,aObject,spaces,
00428                       histo::axis<double>::UNDERFLOW_BIN,
00429                       histo::axis<double>::UNDERFLOW_BIN,
00430                       histo::axis<double>::UNDERFLOW_BIN);
00431     write_bin(writer,aObject,spaces,
00432                       histo::axis<double>::OVERFLOW_BIN,
00433                       histo::axis<double>::UNDERFLOW_BIN,
00434                       histo::axis<double>::UNDERFLOW_BIN);
00435     write_bin(writer,aObject,spaces,
00436                       histo::axis<double>::UNDERFLOW_BIN,
00437                       histo::axis<double>::OVERFLOW_BIN,
00438                       histo::axis<double>::UNDERFLOW_BIN);
00439     write_bin(writer,aObject,spaces,
00440                       histo::axis<double>::OVERFLOW_BIN,
00441                       histo::axis<double>::OVERFLOW_BIN,
00442                       histo::axis<double>::UNDERFLOW_BIN);
00443     
00444     write_bin(writer,aObject,spaces,
00445                       histo::axis<double>::UNDERFLOW_BIN,
00446                       histo::axis<double>::UNDERFLOW_BIN,
00447                       histo::axis<double>::OVERFLOW_BIN);
00448     write_bin(writer,aObject,spaces,
00449                       histo::axis<double>::OVERFLOW_BIN,
00450                       histo::axis<double>::UNDERFLOW_BIN,
00451                       histo::axis<double>::OVERFLOW_BIN);
00452     write_bin(writer,aObject,spaces,
00453                       histo::axis<double>::UNDERFLOW_BIN,
00454                       histo::axis<double>::OVERFLOW_BIN,
00455                       histo::axis<double>::OVERFLOW_BIN);
00456     write_bin(writer,aObject,spaces,
00457                       histo::axis<double>::OVERFLOW_BIN,
00458                       histo::axis<double>::OVERFLOW_BIN,
00459                       histo::axis<double>::OVERFLOW_BIN);
00460   
00461   
00462     // Edges :
00463     for(indexX=0;indexX<xbins;indexX++){
00464       write_bin(writer,aObject,spaces,
00465                         indexX,
00466                         histo::axis<double>::UNDERFLOW_BIN,
00467                         histo::axis<double>::UNDERFLOW_BIN);
00468       write_bin(writer,aObject,spaces,
00469                         indexX,
00470                         histo::axis<double>::OVERFLOW_BIN,
00471                         histo::axis<double>::UNDERFLOW_BIN);
00472       write_bin(writer,aObject,spaces,
00473                         indexX,
00474                         histo::axis<double>::UNDERFLOW_BIN,
00475                         histo::axis<double>::OVERFLOW_BIN);
00476       write_bin(writer,aObject,spaces,
00477                         indexX,
00478                         histo::axis<double>::OVERFLOW_BIN,
00479                         histo::axis<double>::OVERFLOW_BIN);
00480     }
00481   
00482     for(indexY=0;indexY<ybins;indexY++){
00483       write_bin(writer,aObject,spaces,
00484                         histo::axis<double>::UNDERFLOW_BIN,
00485                         indexY,
00486                         histo::axis<double>::UNDERFLOW_BIN);
00487       write_bin(writer,aObject,spaces,
00488                         histo::axis<double>::OVERFLOW_BIN,
00489                         indexY,
00490                         histo::axis<double>::UNDERFLOW_BIN);
00491       write_bin(writer,aObject,spaces,
00492                         histo::axis<double>::UNDERFLOW_BIN,
00493                         indexY,
00494                         histo::axis<double>::OVERFLOW_BIN);
00495       write_bin(writer,aObject,spaces,
00496                         histo::axis<double>::OVERFLOW_BIN,
00497                         indexY,
00498                         histo::axis<double>::OVERFLOW_BIN);
00499     }
00500   
00501     for(indexZ=0;indexZ<zbins;indexZ++){
00502       write_bin(writer,aObject,spaces,
00503                         histo::axis<double>::UNDERFLOW_BIN,
00504                         histo::axis<double>::UNDERFLOW_BIN,
00505                         indexZ);
00506       write_bin(writer,aObject,spaces,
00507                         histo::axis<double>::OVERFLOW_BIN,
00508                         histo::axis<double>::UNDERFLOW_BIN,
00509                         indexZ);
00510       write_bin(writer,aObject,spaces,
00511                         histo::axis<double>::UNDERFLOW_BIN,
00512                         histo::axis<double>::OVERFLOW_BIN,
00513                         indexZ);
00514       write_bin(writer,aObject,spaces,
00515                         histo::axis<double>::OVERFLOW_BIN,
00516                         histo::axis<double>::OVERFLOW_BIN,
00517                         indexZ);
00518     }
00519   
00520   
00521     // Faces :
00522     for(indexX=0;indexX<xbins;indexX++) {
00523       for(indexY=0;indexY<ybins;indexY++) {
00524         write_bin(writer,aObject,spaces,
00525                           indexX,indexY,histo::axis<double>::UNDERFLOW_BIN);
00526         write_bin(writer,aObject,spaces,
00527                           indexX,indexY,histo::axis<double>::OVERFLOW_BIN);
00528       }
00529     }
00530     for(indexY=0;indexY<ybins;indexY++) {
00531       for(indexZ=0;indexZ<zbins;indexZ++) {
00532         write_bin(writer,aObject,spaces,
00533                           histo::axis<double>::UNDERFLOW_BIN,indexY,indexZ);
00534         write_bin(writer,aObject,spaces,
00535                           histo::axis<double>::OVERFLOW_BIN,indexY,indexZ);
00536       }
00537     }
00538     for(indexX=0;indexX<xbins;indexX++) {
00539       for(indexZ=0;indexZ<zbins;indexZ++) {
00540         write_bin(writer,aObject,spaces,
00541                           indexX,histo::axis<double>::UNDERFLOW_BIN,indexZ);
00542         write_bin(writer,aObject,spaces,
00543                           indexX,histo::axis<double>::OVERFLOW_BIN,indexZ);
00544       }
00545     }
00546   
00547     writer << spaces << "    </data3d>" << std::endl;
00548     writer << spaces << "  </histogram3d>" << std::endl;
00549   
00550     return true;
00551   }
00552   
00553   inline bool write(
00554    std::ostream& a_writer
00555   ,const histo::p1d& aObject
00556   ,const std::string& aPath
00557   ,const std::string& aName
00558   ,int aShift = 0
00559   ){
00560     typedef histo::axis<double>::bn_t bn_t;
00561     std::ostream& writer = a_writer;
00562   
00563     std::string spaces;
00564     for(int i=0;i<aShift;i++) spaces += " ";
00565   
00566     // <profile1d> :
00567     writer << spaces << "  <profile1d"
00568          << " path=" << sout(aPath)
00569          << " name=" << sout(aName)
00570          << " title=" << sout(aObject.title())
00571          << ">" << std::endl;
00572   
00573     // <axis> :
00574     write_axis(aObject.axis(),"x",writer,aShift);
00575   
00576     // <statistics> : 
00577     writer << spaces << "    <statistics"
00578          << " entries=" << sout<unsigned int>(aObject.entries())
00579            << ">" << std::endl;
00580     writer << spaces << "      <statistic"
00581          << " direction=" << sout("x") 
00582          << " mean=" << soutd(aObject.mean())
00583          << " rms=" << soutd(aObject.rms())
00584          << "/>" << std::endl;
00585     writer << spaces << "    </statistics>" << std::endl;
00586           
00587     // bins :
00588     writer << spaces << "    <data1d>" << std::endl;
00589     bn_t xbins = aObject.axis().bins();
00590     for(bn_t index=0;index<xbins;index++) {
00591       write_bin(writer,aObject,spaces,index);
00592     }
00593   
00594     write_bin(writer,aObject,spaces,histo::axis<double>::UNDERFLOW_BIN);
00595     write_bin(writer,aObject,spaces,histo::axis<double>::OVERFLOW_BIN);
00596     
00597     writer << spaces << "    </data1d>" << std::endl;
00598     writer << spaces << "  </profile1d>" << std::endl;
00599   
00600     return true;
00601   }
00602   
00603   inline bool write(
00604    std::ostream& a_writer
00605   ,const histo::p2d& aObject
00606   ,const std::string& aPath
00607   ,const std::string& aName
00608   ,int aShift = 0
00609   ){
00610     typedef histo::axis<double>::bn_t bn_t;
00611     std::ostream& writer = a_writer;
00612   
00613     std::string spaces;
00614     for(int i=0;i<aShift;i++) spaces += " ";
00615   
00616     // <profile2d> :
00617     writer << spaces << "  <profile2d"
00618          << " path=" << sout(aPath)
00619          << " name=" << sout(aName)
00620          << " title=" << sout(aObject.title())
00621          << ">" << std::endl;
00622   
00623     // <axis> :
00624     write_axis(aObject.axis_x(),"x",writer,aShift);
00625     write_axis(aObject.axis_y(),"y",writer,aShift);
00626     
00627     // <statistics> : 
00628     writer << spaces << "    <statistics"
00629          << " entries=" << sout<unsigned int>(aObject.entries())
00630            << ">" << std::endl;
00631     writer << spaces << "      <statistic"
00632          << " direction=" << sout("x")
00633          << " mean=" << soutd(aObject.mean_x())
00634          << " rms=" << soutd(aObject.rms_x())
00635          << "/>" << std::endl;
00636     writer << spaces << "      <statistic"
00637          << " direction=" << sout("y")
00638          << " mean=" << soutd(aObject.mean_y())
00639          << " rms=" << soutd(aObject.rms_y())
00640          << "/>" << std::endl;
00641     writer << spaces << "    </statistics>" << std::endl;
00642     
00643     // bins :
00644     writer << spaces << "    <data2d>" << std::endl;
00645    {bn_t xbins = aObject.axis_x().bins();
00646     bn_t ybins = aObject.axis_y().bins();
00647     for(bn_t indexX=0;indexX<xbins;indexX++) {
00648       for(bn_t indexY=0;indexY<ybins;indexY++) {
00649         write_bin(writer,aObject,spaces,indexX,indexY);
00650       }
00651     }}
00652     
00653     write_bin(writer,aObject,spaces,
00654                       histo::axis<double>::UNDERFLOW_BIN,histo::axis<double>::UNDERFLOW_BIN);
00655     write_bin(writer,aObject,spaces,
00656                       histo::axis<double>::OVERFLOW_BIN,histo::axis<double>::UNDERFLOW_BIN);
00657     write_bin(writer,aObject,spaces,
00658                       histo::axis<double>::UNDERFLOW_BIN,histo::axis<double>::OVERFLOW_BIN);
00659     write_bin(writer,aObject,spaces,
00660                       histo::axis<double>::OVERFLOW_BIN,histo::axis<double>::OVERFLOW_BIN);
00661   
00662     for(bn_t indexX=0;indexX<aObject.axis_x().bins();indexX++){
00663       write_bin(writer,aObject,spaces,indexX,histo::axis<double>::UNDERFLOW_BIN);
00664       write_bin(writer,aObject,spaces,indexX,histo::axis<double>::OVERFLOW_BIN);
00665     }
00666   
00667     for(bn_t indexY=0;indexY<aObject.axis_y().bins();indexY++){
00668       write_bin(writer,aObject,spaces,histo::axis<double>::UNDERFLOW_BIN,indexY);
00669       write_bin(writer,aObject,spaces,histo::axis<double>::OVERFLOW_BIN,indexY);
00670     }
00671   
00672     writer << spaces << "    </data2d>" << std::endl;
00673     writer << spaces << "  </profile2d>" << std::endl;
00674   
00675     return true;
00676   }
00677     
00678 }}
00679 
00680 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines