Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 2 // See the file tools.license for terms. 3 3 4 #ifndef tools_waxml_histos 4 #ifndef tools_waxml_histos 5 #define tools_waxml_histos 5 #define tools_waxml_histos 6 6 7 #include "../histo/h1d" 7 #include "../histo/h1d" 8 #include "../histo/h2d" 8 #include "../histo/h2d" 9 #include "../histo/h3d" 9 #include "../histo/h3d" 10 #include "../histo/p1d" 10 #include "../histo/p1d" 11 #include "../histo/p2d" 11 #include "../histo/p2d" 12 12 13 #include "../sout" 13 #include "../sout" 14 #include "../num2s" 14 #include "../num2s" 15 #include "../srep" 15 #include "../srep" 16 16 17 #include <sstream> 17 #include <sstream> 18 18 19 namespace tools { 19 namespace tools { 20 namespace waxml { 20 namespace waxml { 21 21 22 inline std::string soutd(std::ostringstream& 22 inline std::string soutd(std::ostringstream& a_oss,double a_value) { 23 a_oss.str(""); 23 a_oss.str(""); 24 a_oss << a_value; 24 a_oss << a_value; 25 std::string _s("\""); 25 std::string _s("\""); 26 _s += a_oss.str(); 26 _s += a_oss.str(); 27 _s += "\""; 27 _s += "\""; 28 return _s; 28 return _s; 29 } 29 } 30 30 31 inline std::string bin_to_string(std::ostrin 31 inline std::string bin_to_string(std::ostringstream& a_oss,int a_index) { 32 if(a_index==histo::axis_UNDERFLOW_BIN) { 32 if(a_index==histo::axis_UNDERFLOW_BIN) { 33 return "UNDERFLOW"; 33 return "UNDERFLOW"; 34 } else if(a_index==histo::axis_OVERFLOW_BI 34 } else if(a_index==histo::axis_OVERFLOW_BIN) { 35 return "OVERFLOW"; 35 return "OVERFLOW"; 36 } else { 36 } else { 37 a_oss.str(""); 37 a_oss.str(""); 38 a_oss << a_index; 38 a_oss << a_index; 39 return a_oss.str(); 39 return a_oss.str(); 40 } 40 } 41 } 41 } 42 42 43 typedef std::map<std::string,std::string> an 43 typedef std::map<std::string,std::string> annotations_t; 44 44 45 inline void write_annotations( 45 inline void write_annotations( 46 const annotations_t& a_annotations 46 const annotations_t& a_annotations 47 ,std::ostream& a_writer 47 ,std::ostream& a_writer 48 ,int aShift 48 ,int aShift 49 ){ 49 ){ 50 if(a_annotations.empty()) return; 50 if(a_annotations.empty()) return; 51 51 52 std::string spaces; 52 std::string spaces; 53 for(int i=0;i<aShift;i++) spaces += " "; 53 for(int i=0;i<aShift;i++) spaces += " "; 54 54 55 a_writer << spaces << " <annotation>" < 55 a_writer << spaces << " <annotation>" << std::endl; 56 56 57 annotations_t::const_iterator it; 57 annotations_t::const_iterator it; 58 for(it=a_annotations.begin();it!=a_annotat 58 for(it=a_annotations.begin();it!=a_annotations.end();++it){ 59 a_writer << spaces << " <item" 59 a_writer << spaces << " <item" 60 << " key=" << sout(to_xml((*it).fir 60 << " key=" << sout(to_xml((*it).first)) 61 << " value=" << sout(to_xml((*it).s 61 << " value=" << sout(to_xml((*it).second)) 62 << "/>" << std::endl; 62 << "/>" << std::endl; 63 } 63 } 64 a_writer << spaces << " </annotation>" 64 a_writer << spaces << " </annotation>" << std::endl; 65 } 65 } 66 66 67 inline void write_axis( 67 inline void write_axis( 68 const histo::axis<double,unsigned int>& aAx 68 const histo::axis<double,unsigned int>& aAxis 69 ,const std::string& aDirection 69 ,const std::string& aDirection 70 ,std::ostream& a_writer 70 ,std::ostream& a_writer 71 ,std::ostringstream& a_oss 71 ,std::ostringstream& a_oss 72 ,int aShift 72 ,int aShift 73 ){ 73 ){ 74 typedef histo::axis<double,unsigned int>:: 74 typedef histo::axis<double,unsigned int>::bn_t bn_t; 75 75 76 std::string spaces; 76 std::string spaces; 77 for(int i=0;i<aShift;i++) spaces += " "; 77 for(int i=0;i<aShift;i++) spaces += " "; 78 78 79 if(aAxis.is_fixed_binning()) { 79 if(aAxis.is_fixed_binning()) { 80 a_writer << spaces << " <axis" 80 a_writer << spaces << " <axis" 81 << " direction=" << sout(aDirection 81 << " direction=" << sout(aDirection) 82 << " numberOfBins=" << num_out<bn_t 82 << " numberOfBins=" << num_out<bn_t>(aAxis.bins()) 83 << " min=" << soutd(a_oss,aAxis.low 83 << " min=" << soutd(a_oss,aAxis.lower_edge()) 84 << " max=" << soutd(a_oss,aAxis.upp 84 << " max=" << soutd(a_oss,aAxis.upper_edge()) 85 << "/>" << std::endl; 85 << "/>" << std::endl; 86 } else { 86 } else { 87 a_writer << spaces << " <axis" 87 a_writer << spaces << " <axis" 88 << " direction=" << sout(aDirection 88 << " direction=" << sout(aDirection) 89 << " numberOfBins=" << num_out<bn_t 89 << " numberOfBins=" << num_out<bn_t>(aAxis.bins()) 90 << " min=" << soutd(a_oss,aAxis.low 90 << " min=" << soutd(a_oss,aAxis.lower_edge()) 91 << " max=" << soutd(a_oss,aAxis.upp 91 << " max=" << soutd(a_oss,aAxis.upper_edge()) 92 << ">" << std::endl; 92 << ">" << std::endl; 93 bn_t number = aAxis.bins()-1; 93 bn_t number = aAxis.bins()-1; 94 for(bn_t index=0;index<number;index++) { 94 for(bn_t index=0;index<number;index++) { 95 a_writer << spaces << " <binBorde 95 a_writer << spaces << " <binBorder" 96 << " value=" << soutd(a_oss,aAxis 96 << " value=" << soutd(a_oss,aAxis.bin_upper_edge(index)) 97 << "/>" << std::endl; 97 << "/>" << std::endl; 98 } 98 } 99 a_writer << spaces << " </axis>" << s 99 a_writer << spaces << " </axis>" << std::endl; 100 } 100 } 101 } 101 } 102 102 103 inline void write_bin( 103 inline void write_bin( 104 std::ostream& a_writer 104 std::ostream& a_writer 105 ,std::ostringstream& a_oss 105 ,std::ostringstream& a_oss 106 ,const histo::h1d& aObject 106 ,const histo::h1d& aObject 107 ,const std::string& aSpaces 107 ,const std::string& aSpaces 108 ,int aIndex 108 ,int aIndex 109 ){ 109 ){ 110 unsigned int entries = aObject.bin_entries 110 unsigned int entries = aObject.bin_entries(aIndex); 111 if(entries) { 111 if(entries) { 112 a_writer << aSpaces << " <bin1d" 112 a_writer << aSpaces << " <bin1d" 113 << " binNum=" << sout(bin_to_string 113 << " binNum=" << sout(bin_to_string(a_oss,aIndex)) 114 << " entries=" << num_out<unsigned 114 << " entries=" << num_out<unsigned int>(entries) 115 << " height=" << soutd(a_oss,aObjec 115 << " height=" << soutd(a_oss,aObject.bin_height(aIndex)) 116 << " error=" << soutd(a_oss,aObject 116 << " error=" << soutd(a_oss,aObject.bin_error(aIndex)); 117 117 118 double mean = aObject.bin_mean(aIndex); 118 double mean = aObject.bin_mean(aIndex); 119 if(mean!=0) { 119 if(mean!=0) { 120 a_writer << " weightedMean=" << soutd( 120 a_writer << " weightedMean=" << soutd(a_oss,mean); 121 } 121 } 122 122 123 double stddev = aObject.bin_rms(aIndex); 123 double stddev = aObject.bin_rms(aIndex); 124 if(stddev!=0) { 124 if(stddev!=0) { 125 a_writer << " weightedRms=" << soutd(a 125 a_writer << " weightedRms=" << soutd(a_oss,stddev); 126 } 126 } 127 127 128 a_writer << "/>" << std::endl; 128 a_writer << "/>" << std::endl; 129 } 129 } 130 } 130 } 131 131 132 inline void write_bin( 132 inline void write_bin( 133 std::ostream& a_writer 133 std::ostream& a_writer 134 ,std::ostringstream& a_oss 134 ,std::ostringstream& a_oss 135 ,const histo::h2d& aObject 135 ,const histo::h2d& aObject 136 ,const std::string& aSpaces 136 ,const std::string& aSpaces 137 ,int aIndexX 137 ,int aIndexX 138 ,int aIndexY 138 ,int aIndexY 139 ){ 139 ){ 140 unsigned int entries = aObject.bin_entries 140 unsigned int entries = aObject.bin_entries(aIndexX,aIndexY); 141 if(entries) { 141 if(entries) { 142 a_writer << aSpaces << " <bin2d" 142 a_writer << aSpaces << " <bin2d" 143 << " binNumX=" << sout(bin_to_strin 143 << " binNumX=" << sout(bin_to_string(a_oss,aIndexX)) 144 << " binNumY=" << sout(bin_to_strin 144 << " binNumY=" << sout(bin_to_string(a_oss,aIndexY)) 145 << " entries=" << num_out<unsigned 145 << " entries=" << num_out<unsigned int>(entries) 146 << " height=" << soutd(a_oss,aObjec 146 << " height=" << soutd(a_oss,aObject.bin_height(aIndexX,aIndexY)) 147 << " error=" << soutd(a_oss,aObject 147 << " error=" << soutd(a_oss,aObject.bin_error(aIndexX,aIndexY)); 148 148 149 double mean_x = aObject.bin_mean_x(aInde 149 double mean_x = aObject.bin_mean_x(aIndexX,aIndexY); 150 if(mean_x!=0) { 150 if(mean_x!=0) { 151 a_writer << " weightedMeanX=" << soutd 151 a_writer << " weightedMeanX=" << soutd(a_oss,mean_x); 152 } 152 } 153 double mean_y = aObject.bin_mean_y(aInde 153 double mean_y = aObject.bin_mean_y(aIndexX,aIndexY); 154 if(mean_y!=0) { 154 if(mean_y!=0) { 155 a_writer << " weightedMeanY=" << soutd 155 a_writer << " weightedMeanY=" << soutd(a_oss,mean_y); 156 } 156 } 157 157 158 double stddevX = aObject.bin_rms_x(aInde 158 double stddevX = aObject.bin_rms_x(aIndexX,aIndexY); 159 if(stddevX!=0) { 159 if(stddevX!=0) { 160 a_writer << " weightedRmsX=" << soutd( 160 a_writer << " weightedRmsX=" << soutd(a_oss,stddevX); 161 } 161 } 162 double stddevY = aObject.bin_rms_y(aInde 162 double stddevY = aObject.bin_rms_y(aIndexX,aIndexY); 163 if(stddevY!=0) { 163 if(stddevY!=0) { 164 a_writer << " weightedRmsY=" << soutd( 164 a_writer << " weightedRmsY=" << soutd(a_oss,stddevY); 165 } 165 } 166 166 167 a_writer << "/>" << std::endl; 167 a_writer << "/>" << std::endl; 168 } 168 } 169 } 169 } 170 170 171 inline void write_bin( 171 inline void write_bin( 172 std::ostream& a_writer 172 std::ostream& a_writer 173 ,std::ostringstream& a_oss 173 ,std::ostringstream& a_oss 174 ,const histo::h3d& aObject 174 ,const histo::h3d& aObject 175 ,const std::string& aSpaces 175 ,const std::string& aSpaces 176 ,int aIndexX 176 ,int aIndexX 177 ,int aIndexY 177 ,int aIndexY 178 ,int aIndexZ 178 ,int aIndexZ 179 ){ 179 ){ 180 unsigned int entries = aObject.bin_entries 180 unsigned int entries = aObject.bin_entries(aIndexX,aIndexY,aIndexZ); 181 if(entries) { 181 if(entries) { 182 a_writer << aSpaces << " <bin3d" 182 a_writer << aSpaces << " <bin3d" 183 << " binNumX=" << sout(bin_to_strin 183 << " binNumX=" << sout(bin_to_string(a_oss,aIndexX)) 184 << " binNumY=" << sout(bin_to_strin 184 << " binNumY=" << sout(bin_to_string(a_oss,aIndexY)) 185 << " binNumZ=" << sout(bin_to_strin 185 << " binNumZ=" << sout(bin_to_string(a_oss,aIndexZ)) 186 << " entries=" << num_out<unsigned 186 << " entries=" << num_out<unsigned int>(entries) 187 << " height=" << soutd(a_oss,aObjec 187 << " height=" << soutd(a_oss,aObject.bin_height(aIndexX,aIndexY,aIndexZ)) 188 << " error=" << soutd(a_oss,aObject 188 << " error=" << soutd(a_oss,aObject.bin_error(aIndexX,aIndexY,aIndexZ)); 189 189 190 190 191 double mean_x = aObject.bin_mean_x(aInde 191 double mean_x = aObject.bin_mean_x(aIndexX,aIndexY,aIndexZ); 192 if(mean_x!=0) { 192 if(mean_x!=0) { 193 a_writer << " weightedMeanX=" << soutd 193 a_writer << " weightedMeanX=" << soutd(a_oss,mean_x); 194 } 194 } 195 double mean_y = aObject.bin_mean_y(aInde 195 double mean_y = aObject.bin_mean_y(aIndexX,aIndexY,aIndexZ); 196 if(mean_y!=0) { 196 if(mean_y!=0) { 197 a_writer << " weightedMeanY=" << soutd 197 a_writer << " weightedMeanY=" << soutd(a_oss,mean_y); 198 } 198 } 199 double mean_z = aObject.bin_mean_z(aInde 199 double mean_z = aObject.bin_mean_z(aIndexX,aIndexY,aIndexZ); 200 if(mean_y!=0) { 200 if(mean_y!=0) { 201 a_writer << " weightedMeanZ=" << soutd 201 a_writer << " weightedMeanZ=" << soutd(a_oss,mean_z); 202 } 202 } 203 203 204 double stddevX = aObject.bin_rms_x(aInde 204 double stddevX = aObject.bin_rms_x(aIndexX,aIndexY,aIndexZ); 205 if(stddevX!=0) { 205 if(stddevX!=0) { 206 a_writer << " weightedRmsX=" << soutd( 206 a_writer << " weightedRmsX=" << soutd(a_oss,stddevX); 207 } 207 } 208 double stddevY = aObject.bin_rms_y(aInde 208 double stddevY = aObject.bin_rms_y(aIndexX,aIndexY,aIndexZ); 209 if(stddevY!=0) { 209 if(stddevY!=0) { 210 a_writer << " weightedRmsY=" << soutd( 210 a_writer << " weightedRmsY=" << soutd(a_oss,stddevY); 211 } 211 } 212 double stddevZ = aObject.bin_rms_z(aInde 212 double stddevZ = aObject.bin_rms_z(aIndexX,aIndexY,aIndexZ); 213 if(stddevZ!=0) { 213 if(stddevZ!=0) { 214 a_writer << " weightedRmsZ=" << soutd( 214 a_writer << " weightedRmsZ=" << soutd(a_oss,stddevZ); 215 } 215 } 216 216 217 a_writer << "/>" << std::endl; 217 a_writer << "/>" << std::endl; 218 } 218 } 219 } 219 } 220 220 221 inline void write_bin( 221 inline void write_bin( 222 std::ostream& a_writer 222 std::ostream& a_writer 223 ,std::ostringstream& a_oss 223 ,std::ostringstream& a_oss 224 ,const histo::p1d& aObject 224 ,const histo::p1d& aObject 225 ,const std::string& aSpaces 225 ,const std::string& aSpaces 226 ,int aIndex 226 ,int aIndex 227 ){ 227 ){ 228 if(aObject.bin_entries(aIndex)) { 228 if(aObject.bin_entries(aIndex)) { 229 a_writer << aSpaces << " <bin1d" 229 a_writer << aSpaces << " <bin1d" 230 << " binNum=" << sout(bin_to_string 230 << " binNum=" << sout(bin_to_string(a_oss,aIndex)) 231 << " entries=" << num_out<unsigned 231 << " entries=" << num_out<unsigned int>(aObject.bin_entries(aIndex)) 232 << " height=" << soutd(a_oss,aObjec 232 << " height=" << soutd(a_oss,aObject.bin_height(aIndex)) 233 << " error=" << soutd(a_oss,aObject 233 << " error=" << soutd(a_oss,aObject.bin_error(aIndex)) 234 << " weightedMean=" << soutd(a_oss, 234 << " weightedMean=" << soutd(a_oss,aObject.bin_mean(aIndex)); 235 235 236 double stddev = aObject.bin_rms(aIndex); 236 double stddev = aObject.bin_rms(aIndex); 237 if(stddev!=0) { 237 if(stddev!=0) { 238 a_writer << " weightedRms=" << soutd(a 238 a_writer << " weightedRms=" << soutd(a_oss,stddev); 239 } 239 } 240 240 241 a_writer << " rms=" << soutd(a_oss,aObje 241 a_writer << " rms=" << soutd(a_oss,aObject.bin_rms_value(aIndex)); 242 a_writer << "/>" << std::endl; 242 a_writer << "/>" << std::endl; 243 } 243 } 244 } 244 } 245 245 246 inline void write_bin( 246 inline void write_bin( 247 std::ostream& a_writer 247 std::ostream& a_writer 248 ,std::ostringstream& a_oss 248 ,std::ostringstream& a_oss 249 ,const histo::p2d& aObject 249 ,const histo::p2d& aObject 250 ,const std::string& aSpaces 250 ,const std::string& aSpaces 251 ,int aIndexX 251 ,int aIndexX 252 ,int aIndexY 252 ,int aIndexY 253 ){ 253 ){ 254 if(aObject.bin_entries(aIndexX,aIndexY)) { 254 if(aObject.bin_entries(aIndexX,aIndexY)) { 255 a_writer << aSpaces << " <bin2d" 255 a_writer << aSpaces << " <bin2d" 256 << " binNumX=" << sout(bin_to_strin 256 << " binNumX=" << sout(bin_to_string(a_oss,aIndexX)) 257 << " binNumY=" << sout(bin_to_strin 257 << " binNumY=" << sout(bin_to_string(a_oss,aIndexY)) 258 << " entries=" << num_out<unsigned 258 << " entries=" << num_out<unsigned int>(aObject.bin_entries(aIndexX,aIndexY)) 259 << " height=" << soutd(a_oss,aObjec 259 << " height=" << soutd(a_oss,aObject.bin_height(aIndexX,aIndexY)) 260 << " error=" << soutd(a_oss,aObject 260 << " error=" << soutd(a_oss,aObject.bin_error(aIndexX,aIndexY)) 261 << " weightedMeanX=" << soutd(a_oss 261 << " weightedMeanX=" << soutd(a_oss,aObject.bin_mean_x(aIndexX,aIndexY)) 262 << " weightedMeanY=" << soutd(a_oss 262 << " weightedMeanY=" << soutd(a_oss,aObject.bin_mean_y(aIndexX,aIndexY)); 263 263 264 double stddevX = aObject.bin_rms_x(aInde 264 double stddevX = aObject.bin_rms_x(aIndexX,aIndexY); 265 if(stddevX!=0) { 265 if(stddevX!=0) { 266 a_writer << " weightedRmsX=" << soutd( 266 a_writer << " weightedRmsX=" << soutd(a_oss,stddevX); 267 } 267 } 268 double stddevY = aObject.bin_rms_y(aInde 268 double stddevY = aObject.bin_rms_y(aIndexX,aIndexY); 269 if(stddevY!=0) { 269 if(stddevY!=0) { 270 a_writer << " weightedRmsY=" << soutd( 270 a_writer << " weightedRmsY=" << soutd(a_oss,stddevY); 271 } 271 } 272 272 273 a_writer << " rms=" << soutd(a_oss,aObje 273 a_writer << " rms=" << soutd(a_oss,aObject.bin_rms_value(aIndexX,aIndexY)); 274 a_writer << "/>" << std::endl; 274 a_writer << "/>" << std::endl; 275 } 275 } 276 } 276 } 277 277 278 inline bool write( 278 inline bool write( 279 std::ostream& a_writer 279 std::ostream& a_writer 280 ,const histo::h1d& aObject 280 ,const histo::h1d& aObject 281 ,const std::string& aPath 281 ,const std::string& aPath 282 ,const std::string& aName 282 ,const std::string& aName 283 ,int aShift = 0 283 ,int aShift = 0 284 ){ 284 ){ 285 std::ostringstream ossd; 285 std::ostringstream ossd; 286 ossd.precision(25); 286 ossd.precision(25); 287 287 288 typedef histo::axis<double,unsigned int>:: 288 typedef histo::axis<double,unsigned int>::bn_t bn_t; 289 289 290 std::ostream& writer = a_writer; 290 std::ostream& writer = a_writer; 291 291 292 std::string spaces; 292 std::string spaces; 293 for(int i=0;i<aShift;i++) spaces += " "; 293 for(int i=0;i<aShift;i++) spaces += " "; 294 294 295 // <histogram1d> : 295 // <histogram1d> : 296 writer << spaces << " <histogram1d" 296 writer << spaces << " <histogram1d" 297 << " path=" << sout(to_xml(aPath)) 297 << " path=" << sout(to_xml(aPath)) 298 << " name=" << sout(to_xml(aName)) 298 << " name=" << sout(to_xml(aName)) 299 << " title=" << sout(to_xml(aObject.t 299 << " title=" << sout(to_xml(aObject.title())) 300 << ">" << std::endl; 300 << ">" << std::endl; 301 301 302 // <annotations> : 302 // <annotations> : 303 write_annotations(aObject.annotations(),wr 303 write_annotations(aObject.annotations(),writer,aShift); 304 304 305 // <axis> : 305 // <axis> : 306 write_axis(aObject.axis(),"x",writer,ossd, 306 write_axis(aObject.axis(),"x",writer,ossd,aShift); 307 307 308 // <statistics> : 308 // <statistics> : 309 writer << spaces << " <statistics" 309 writer << spaces << " <statistics" 310 << " entries=" << num_out<unsigned 310 << " entries=" << num_out<unsigned int>(aObject.entries()) 311 << ">" << std::endl; 311 << ">" << std::endl; 312 writer << spaces << " <statistic" 312 writer << spaces << " <statistic" 313 << " direction=" << sout("x") 313 << " direction=" << sout("x") 314 << " mean=" << soutd(ossd,aObject.mea 314 << " mean=" << soutd(ossd,aObject.mean()) 315 << " rms=" << soutd(ossd,aObject.rms( 315 << " rms=" << soutd(ossd,aObject.rms()) 316 << "/>" << std::endl; 316 << "/>" << std::endl; 317 writer << spaces << " </statistics>" << 317 writer << spaces << " </statistics>" << std::endl; 318 318 319 // bins : 319 // bins : 320 writer << spaces << " <data1d>" << std: 320 writer << spaces << " <data1d>" << std::endl; 321 321 322 bn_t xbins = aObject.axis().bins(); 322 bn_t xbins = aObject.axis().bins(); 323 for(bn_t index=0;index<xbins;index++) 323 for(bn_t index=0;index<xbins;index++) 324 write_bin(writer,ossd,aObject,spaces,ind 324 write_bin(writer,ossd,aObject,spaces,index); 325 325 326 write_bin(writer,ossd,aObject,spaces,histo 326 write_bin(writer,ossd,aObject,spaces,histo::axis_UNDERFLOW_BIN); 327 write_bin(writer,ossd,aObject,spaces,histo 327 write_bin(writer,ossd,aObject,spaces,histo::axis_OVERFLOW_BIN); 328 328 329 writer << spaces << " </data1d>" << std 329 writer << spaces << " </data1d>" << std::endl; 330 writer << spaces << " </histogram1d>" << 330 writer << spaces << " </histogram1d>" << std::endl; 331 331 332 return true; 332 return true; 333 } 333 } 334 334 335 inline bool write( 335 inline bool write( 336 std::ostream& a_writer 336 std::ostream& a_writer 337 ,const histo::h2d& aObject 337 ,const histo::h2d& aObject 338 ,const std::string& aPath 338 ,const std::string& aPath 339 ,const std::string& aName 339 ,const std::string& aName 340 ,int aShift = 0 340 ,int aShift = 0 341 ){ 341 ){ 342 std::ostringstream ossd; 342 std::ostringstream ossd; 343 ossd.precision(25); 343 ossd.precision(25); 344 344 345 typedef histo::axis<double,unsigned int>:: 345 typedef histo::axis<double,unsigned int>::bn_t bn_t; 346 346 347 std::ostream& writer = a_writer; 347 std::ostream& writer = a_writer; 348 348 349 std::string spaces; 349 std::string spaces; 350 for(int i=0;i<aShift;i++) spaces += " "; 350 for(int i=0;i<aShift;i++) spaces += " "; 351 351 352 // <histogram2d> : 352 // <histogram2d> : 353 writer << spaces << " <histogram2d" 353 writer << spaces << " <histogram2d" 354 << " path=" << sout(to_xml(aPath)) 354 << " path=" << sout(to_xml(aPath)) 355 << " name=" << sout(to_xml(aName)) 355 << " name=" << sout(to_xml(aName)) 356 << " title=" << sout(to_xml(aObject.t 356 << " title=" << sout(to_xml(aObject.title())) 357 << ">" << std::endl; 357 << ">" << std::endl; 358 358 359 // <annotations> : 359 // <annotations> : 360 write_annotations(aObject.annotations(),wr 360 write_annotations(aObject.annotations(),writer,aShift); 361 361 362 // <axis> : 362 // <axis> : 363 write_axis(aObject.axis_x(),"x",writer,oss 363 write_axis(aObject.axis_x(),"x",writer,ossd,aShift); 364 write_axis(aObject.axis_y(),"y",writer,oss 364 write_axis(aObject.axis_y(),"y",writer,ossd,aShift); 365 365 366 // <statistics> : 366 // <statistics> : 367 writer << spaces << " <statistics" 367 writer << spaces << " <statistics" 368 << " entries=" << num_out<unsigned in 368 << " entries=" << num_out<unsigned int>(aObject.entries()) 369 << ">" << std::endl; 369 << ">" << std::endl; 370 writer << spaces << " <statistic" 370 writer << spaces << " <statistic" 371 << " direction=" << sout("x") 371 << " direction=" << sout("x") 372 << " mean=" << soutd(ossd,aObject.mea 372 << " mean=" << soutd(ossd,aObject.mean_x()) 373 << " rms=" << soutd(ossd,aObject.rms_ 373 << " rms=" << soutd(ossd,aObject.rms_x()) 374 << "/>" << std::endl; 374 << "/>" << std::endl; 375 writer << spaces << " <statistic" 375 writer << spaces << " <statistic" 376 << " direction=" << sout("y") 376 << " direction=" << sout("y") 377 << " mean=" << soutd(ossd,aObject.mea 377 << " mean=" << soutd(ossd,aObject.mean_y()) 378 << " rms=" << soutd(ossd,aObject.rms_ 378 << " rms=" << soutd(ossd,aObject.rms_y()) 379 << "/>" << std::endl; 379 << "/>" << std::endl; 380 writer << spaces << " </statistics>" << 380 writer << spaces << " </statistics>" << std::endl; 381 381 382 // bins : 382 // bins : 383 writer << spaces << " <data2d>" << std: 383 writer << spaces << " <data2d>" << std::endl; 384 384 385 bn_t xbins = aObject.axis_x().bins(); 385 bn_t xbins = aObject.axis_x().bins(); 386 bn_t ybins = aObject.axis_y().bins(); 386 bn_t ybins = aObject.axis_y().bins(); 387 bn_t indexX,indexY; 387 bn_t indexX,indexY; 388 for(indexX=0;indexX<xbins;indexX++) { 388 for(indexX=0;indexX<xbins;indexX++) { 389 for(indexY=0;indexY<ybins;indexY++) { 389 for(indexY=0;indexY<ybins;indexY++) { 390 write_bin(writer,ossd,aObject,spaces,i 390 write_bin(writer,ossd,aObject,spaces,indexX,indexY); 391 } 391 } 392 } 392 } 393 393 394 write_bin(writer,ossd,aObject,spaces,histo 394 write_bin(writer,ossd,aObject,spaces,histo::axis_UNDERFLOW_BIN,histo::axis_UNDERFLOW_BIN); 395 write_bin(writer,ossd,aObject,spaces,histo 395 write_bin(writer,ossd,aObject,spaces,histo::axis_OVERFLOW_BIN,histo::axis_UNDERFLOW_BIN); 396 write_bin(writer,ossd,aObject,spaces,histo 396 write_bin(writer,ossd,aObject,spaces,histo::axis_UNDERFLOW_BIN,histo::axis_OVERFLOW_BIN); 397 write_bin(writer,ossd,aObject,spaces,histo 397 write_bin(writer,ossd,aObject,spaces,histo::axis_OVERFLOW_BIN,histo::axis_OVERFLOW_BIN); 398 398 399 for(indexX=0;indexX<xbins;indexX++){ 399 for(indexX=0;indexX<xbins;indexX++){ 400 write_bin(writer,ossd,aObject,spaces,ind 400 write_bin(writer,ossd,aObject,spaces,indexX,histo::axis_UNDERFLOW_BIN); 401 write_bin(writer,ossd,aObject,spaces,ind 401 write_bin(writer,ossd,aObject,spaces,indexX,histo::axis_OVERFLOW_BIN); 402 } 402 } 403 403 404 for(indexY=0;indexY<ybins;indexY++){ 404 for(indexY=0;indexY<ybins;indexY++){ 405 write_bin(writer,ossd,aObject,spaces,his 405 write_bin(writer,ossd,aObject,spaces,histo::axis_UNDERFLOW_BIN,indexY); 406 write_bin(writer,ossd,aObject,spaces,his 406 write_bin(writer,ossd,aObject,spaces,histo::axis_OVERFLOW_BIN,indexY); 407 } 407 } 408 408 409 writer << spaces << " </data2d>" << std 409 writer << spaces << " </data2d>" << std::endl; 410 writer << spaces << " </histogram2d>" << 410 writer << spaces << " </histogram2d>" << std::endl; 411 411 412 return true; 412 return true; 413 } 413 } 414 414 415 inline bool write( 415 inline bool write( 416 std::ostream& a_writer 416 std::ostream& a_writer 417 ,const histo::h3d& aObject 417 ,const histo::h3d& aObject 418 ,const std::string& aPath 418 ,const std::string& aPath 419 ,const std::string& aName 419 ,const std::string& aName 420 ,int aShift = 0 420 ,int aShift = 0 421 ){ 421 ){ 422 std::ostringstream ossd; 422 std::ostringstream ossd; 423 ossd.precision(25); 423 ossd.precision(25); 424 424 425 typedef histo::axis<double,unsigned int>:: 425 typedef histo::axis<double,unsigned int>::bn_t bn_t; 426 std::ostream& writer = a_writer; 426 std::ostream& writer = a_writer; 427 427 428 std::string spaces; 428 std::string spaces; 429 for(int i=0;i<aShift;i++) spaces += " "; 429 for(int i=0;i<aShift;i++) spaces += " "; 430 430 431 // <histogram3d> : 431 // <histogram3d> : 432 writer << spaces << " <histogram3d" 432 writer << spaces << " <histogram3d" 433 << " path=" << sout(to_xml(aPath)) 433 << " path=" << sout(to_xml(aPath)) 434 << " name=" << sout(to_xml(aName)) 434 << " name=" << sout(to_xml(aName)) 435 << " title=" << sout(to_xml(aObject.t 435 << " title=" << sout(to_xml(aObject.title())) 436 << ">" << std::endl; 436 << ">" << std::endl; 437 437 438 // <annotations> : 438 // <annotations> : 439 write_annotations(aObject.annotations(),wr 439 write_annotations(aObject.annotations(),writer,aShift); 440 440 441 // <axis> : 441 // <axis> : 442 write_axis(aObject.axis_x(),"x",writer,oss 442 write_axis(aObject.axis_x(),"x",writer,ossd,aShift); 443 write_axis(aObject.axis_y(),"y",writer,oss 443 write_axis(aObject.axis_y(),"y",writer,ossd,aShift); 444 write_axis(aObject.axis_z(),"z",writer,oss 444 write_axis(aObject.axis_z(),"z",writer,ossd,aShift); 445 445 446 // <statistics> : 446 // <statistics> : 447 writer << spaces << " <statistics" 447 writer << spaces << " <statistics" 448 << " entries=" << num_out<unsigned in 448 << " entries=" << num_out<unsigned int>(aObject.entries()) 449 << ">" << std::endl; 449 << ">" << std::endl; 450 writer << spaces << " <statistic" 450 writer << spaces << " <statistic" 451 << " direction=" << sout("x") 451 << " direction=" << sout("x") 452 << " mean=" << soutd(ossd,aObject.mea 452 << " mean=" << soutd(ossd,aObject.mean_x()) 453 << " rms=" << soutd(ossd,aObject.rms_ 453 << " rms=" << soutd(ossd,aObject.rms_x()) 454 << "/>" << std::endl; 454 << "/>" << std::endl; 455 writer << spaces << " <statistic" 455 writer << spaces << " <statistic" 456 << " direction=" << sout("y") 456 << " direction=" << sout("y") 457 << " mean=" << soutd(ossd,aObject.mea 457 << " mean=" << soutd(ossd,aObject.mean_y()) 458 << " rms=" << soutd(ossd,aObject.rms_ 458 << " rms=" << soutd(ossd,aObject.rms_y()) 459 << "/>" << std::endl; 459 << "/>" << std::endl; 460 writer << spaces << " <statistic" 460 writer << spaces << " <statistic" 461 << " direction=" << sout("z") 461 << " direction=" << sout("z") 462 << " mean=" << soutd(ossd,aObject.mea 462 << " mean=" << soutd(ossd,aObject.mean_z()) 463 << " rms=" << soutd(ossd,aObject.rms_ 463 << " rms=" << soutd(ossd,aObject.rms_z()) 464 << "/>" << std::endl; 464 << "/>" << std::endl; 465 writer << spaces << " </statistics>" << 465 writer << spaces << " </statistics>" << std::endl; 466 466 467 // bins : 467 // bins : 468 writer << spaces << " <data3d>" << std: 468 writer << spaces << " <data3d>" << std::endl; 469 bn_t xbins = aObject.axis_x().bins(); 469 bn_t xbins = aObject.axis_x().bins(); 470 bn_t ybins = aObject.axis_y().bins(); 470 bn_t ybins = aObject.axis_y().bins(); 471 bn_t zbins = aObject.axis_z().bins(); 471 bn_t zbins = aObject.axis_z().bins(); 472 bn_t indexX,indexY,indexZ; 472 bn_t indexX,indexY,indexZ; 473 for(indexX=0;indexX<xbins;indexX++) { 473 for(indexX=0;indexX<xbins;indexX++) { 474 for(indexY=0;indexY<ybins;indexY++) { 474 for(indexY=0;indexY<ybins;indexY++) { 475 for(indexZ=0;indexZ<zbins;indexZ++) { 475 for(indexZ=0;indexZ<zbins;indexZ++) { 476 write_bin(writer,ossd,aObject,spaces 476 write_bin(writer,ossd,aObject,spaces,indexX,indexY,indexZ); 477 } 477 } 478 } 478 } 479 } 479 } 480 480 481 // Corners : 481 // Corners : 482 write_bin(writer,ossd,aObject,spaces, 482 write_bin(writer,ossd,aObject,spaces, 483 histo::axis_UNDERFLOW_BI 483 histo::axis_UNDERFLOW_BIN, 484 histo::axis_UNDERFLOW_BI 484 histo::axis_UNDERFLOW_BIN, 485 histo::axis_UNDERFLOW_BI 485 histo::axis_UNDERFLOW_BIN); 486 write_bin(writer,ossd,aObject,spaces, 486 write_bin(writer,ossd,aObject,spaces, 487 histo::axis_OVERFLOW_BIN 487 histo::axis_OVERFLOW_BIN, 488 histo::axis_UNDERFLOW_BI 488 histo::axis_UNDERFLOW_BIN, 489 histo::axis_UNDERFLOW_BI 489 histo::axis_UNDERFLOW_BIN); 490 write_bin(writer,ossd,aObject,spaces, 490 write_bin(writer,ossd,aObject,spaces, 491 histo::axis_UNDERFLOW_BI 491 histo::axis_UNDERFLOW_BIN, 492 histo::axis_OVERFLOW_BIN 492 histo::axis_OVERFLOW_BIN, 493 histo::axis_UNDERFLOW_BI 493 histo::axis_UNDERFLOW_BIN); 494 write_bin(writer,ossd,aObject,spaces, 494 write_bin(writer,ossd,aObject,spaces, 495 histo::axis_OVERFLOW_BIN 495 histo::axis_OVERFLOW_BIN, 496 histo::axis_OVERFLOW_BIN 496 histo::axis_OVERFLOW_BIN, 497 histo::axis_UNDERFLOW_BI 497 histo::axis_UNDERFLOW_BIN); 498 498 499 write_bin(writer,ossd,aObject,spaces, 499 write_bin(writer,ossd,aObject,spaces, 500 histo::axis_UNDERFLOW_BI 500 histo::axis_UNDERFLOW_BIN, 501 histo::axis_UNDERFLOW_BI 501 histo::axis_UNDERFLOW_BIN, 502 histo::axis_OVERFLOW_BIN 502 histo::axis_OVERFLOW_BIN); 503 write_bin(writer,ossd,aObject,spaces, 503 write_bin(writer,ossd,aObject,spaces, 504 histo::axis_OVERFLOW_BIN 504 histo::axis_OVERFLOW_BIN, 505 histo::axis_UNDERFLOW_BI 505 histo::axis_UNDERFLOW_BIN, 506 histo::axis_OVERFLOW_BIN 506 histo::axis_OVERFLOW_BIN); 507 write_bin(writer,ossd,aObject,spaces, 507 write_bin(writer,ossd,aObject,spaces, 508 histo::axis_UNDERFLOW_BI 508 histo::axis_UNDERFLOW_BIN, 509 histo::axis_OVERFLOW_BIN 509 histo::axis_OVERFLOW_BIN, 510 histo::axis_OVERFLOW_BIN 510 histo::axis_OVERFLOW_BIN); 511 write_bin(writer,ossd,aObject,spaces, 511 write_bin(writer,ossd,aObject,spaces, 512 histo::axis_OVERFLOW_BIN 512 histo::axis_OVERFLOW_BIN, 513 histo::axis_OVERFLOW_BIN 513 histo::axis_OVERFLOW_BIN, 514 histo::axis_OVERFLOW_BIN 514 histo::axis_OVERFLOW_BIN); 515 515 516 516 517 // Edges : 517 // Edges : 518 for(indexX=0;indexX<xbins;indexX++){ 518 for(indexX=0;indexX<xbins;indexX++){ 519 write_bin(writer,ossd,aObject,spaces, 519 write_bin(writer,ossd,aObject,spaces, 520 indexX, 520 indexX, 521 histo::axis_UNDERFLOW_ 521 histo::axis_UNDERFLOW_BIN, 522 histo::axis_UNDERFLOW_ 522 histo::axis_UNDERFLOW_BIN); 523 write_bin(writer,ossd,aObject,spaces, 523 write_bin(writer,ossd,aObject,spaces, 524 indexX, 524 indexX, 525 histo::axis_OVERFLOW_B 525 histo::axis_OVERFLOW_BIN, 526 histo::axis_UNDERFLOW_ 526 histo::axis_UNDERFLOW_BIN); 527 write_bin(writer,ossd,aObject,spaces, 527 write_bin(writer,ossd,aObject,spaces, 528 indexX, 528 indexX, 529 histo::axis_UNDERFLOW_ 529 histo::axis_UNDERFLOW_BIN, 530 histo::axis_OVERFLOW_B 530 histo::axis_OVERFLOW_BIN); 531 write_bin(writer,ossd,aObject,spaces, 531 write_bin(writer,ossd,aObject,spaces, 532 indexX, 532 indexX, 533 histo::axis_OVERFLOW_B 533 histo::axis_OVERFLOW_BIN, 534 histo::axis_OVERFLOW_B 534 histo::axis_OVERFLOW_BIN); 535 } 535 } 536 536 537 for(indexY=0;indexY<ybins;indexY++){ 537 for(indexY=0;indexY<ybins;indexY++){ 538 write_bin(writer,ossd,aObject,spaces, 538 write_bin(writer,ossd,aObject,spaces, 539 histo::axis_UNDERFLOW_ 539 histo::axis_UNDERFLOW_BIN, 540 indexY, 540 indexY, 541 histo::axis_UNDERFLOW_ 541 histo::axis_UNDERFLOW_BIN); 542 write_bin(writer,ossd,aObject,spaces, 542 write_bin(writer,ossd,aObject,spaces, 543 histo::axis_OVERFLOW_B 543 histo::axis_OVERFLOW_BIN, 544 indexY, 544 indexY, 545 histo::axis_UNDERFLOW_ 545 histo::axis_UNDERFLOW_BIN); 546 write_bin(writer,ossd,aObject,spaces, 546 write_bin(writer,ossd,aObject,spaces, 547 histo::axis_UNDERFLOW_ 547 histo::axis_UNDERFLOW_BIN, 548 indexY, 548 indexY, 549 histo::axis_OVERFLOW_B 549 histo::axis_OVERFLOW_BIN); 550 write_bin(writer,ossd,aObject,spaces, 550 write_bin(writer,ossd,aObject,spaces, 551 histo::axis_OVERFLOW_B 551 histo::axis_OVERFLOW_BIN, 552 indexY, 552 indexY, 553 histo::axis_OVERFLOW_B 553 histo::axis_OVERFLOW_BIN); 554 } 554 } 555 555 556 for(indexZ=0;indexZ<zbins;indexZ++){ 556 for(indexZ=0;indexZ<zbins;indexZ++){ 557 write_bin(writer,ossd,aObject,spaces, 557 write_bin(writer,ossd,aObject,spaces, 558 histo::axis_UNDERFLOW_ 558 histo::axis_UNDERFLOW_BIN, 559 histo::axis_UNDERFLOW_ 559 histo::axis_UNDERFLOW_BIN, 560 indexZ); 560 indexZ); 561 write_bin(writer,ossd,aObject,spaces, 561 write_bin(writer,ossd,aObject,spaces, 562 histo::axis_OVERFLOW_B 562 histo::axis_OVERFLOW_BIN, 563 histo::axis_UNDERFLOW_ 563 histo::axis_UNDERFLOW_BIN, 564 indexZ); 564 indexZ); 565 write_bin(writer,ossd,aObject,spaces, 565 write_bin(writer,ossd,aObject,spaces, 566 histo::axis_UNDERFLOW_ 566 histo::axis_UNDERFLOW_BIN, 567 histo::axis_OVERFLOW_B 567 histo::axis_OVERFLOW_BIN, 568 indexZ); 568 indexZ); 569 write_bin(writer,ossd,aObject,spaces, 569 write_bin(writer,ossd,aObject,spaces, 570 histo::axis_OVERFLOW_B 570 histo::axis_OVERFLOW_BIN, 571 histo::axis_OVERFLOW_B 571 histo::axis_OVERFLOW_BIN, 572 indexZ); 572 indexZ); 573 } 573 } 574 574 575 575 576 // Faces : 576 // Faces : 577 for(indexX=0;indexX<xbins;indexX++) { 577 for(indexX=0;indexX<xbins;indexX++) { 578 for(indexY=0;indexY<ybins;indexY++) { 578 for(indexY=0;indexY<ybins;indexY++) { 579 write_bin(writer,ossd,aObject,spaces, 579 write_bin(writer,ossd,aObject,spaces, 580 indexX,indexY,histo: 580 indexX,indexY,histo::axis_UNDERFLOW_BIN); 581 write_bin(writer,ossd,aObject,spaces, 581 write_bin(writer,ossd,aObject,spaces, 582 indexX,indexY,histo: 582 indexX,indexY,histo::axis_OVERFLOW_BIN); 583 } 583 } 584 } 584 } 585 for(indexY=0;indexY<ybins;indexY++) { 585 for(indexY=0;indexY<ybins;indexY++) { 586 for(indexZ=0;indexZ<zbins;indexZ++) { 586 for(indexZ=0;indexZ<zbins;indexZ++) { 587 write_bin(writer,ossd,aObject,spaces, 587 write_bin(writer,ossd,aObject,spaces, 588 histo::axis_UNDERFLO 588 histo::axis_UNDERFLOW_BIN,indexY,indexZ); 589 write_bin(writer,ossd,aObject,spaces, 589 write_bin(writer,ossd,aObject,spaces, 590 histo::axis_OVERFLOW 590 histo::axis_OVERFLOW_BIN,indexY,indexZ); 591 } 591 } 592 } 592 } 593 for(indexX=0;indexX<xbins;indexX++) { 593 for(indexX=0;indexX<xbins;indexX++) { 594 for(indexZ=0;indexZ<zbins;indexZ++) { 594 for(indexZ=0;indexZ<zbins;indexZ++) { 595 write_bin(writer,ossd,aObject,spaces, 595 write_bin(writer,ossd,aObject,spaces, 596 indexX,histo::axis_U 596 indexX,histo::axis_UNDERFLOW_BIN,indexZ); 597 write_bin(writer,ossd,aObject,spaces, 597 write_bin(writer,ossd,aObject,spaces, 598 indexX,histo::axis_O 598 indexX,histo::axis_OVERFLOW_BIN,indexZ); 599 } 599 } 600 } 600 } 601 601 602 writer << spaces << " </data3d>" << std 602 writer << spaces << " </data3d>" << std::endl; 603 writer << spaces << " </histogram3d>" << 603 writer << spaces << " </histogram3d>" << std::endl; 604 604 605 return true; 605 return true; 606 } 606 } 607 607 608 inline bool write( 608 inline bool write( 609 std::ostream& a_writer 609 std::ostream& a_writer 610 ,const histo::p1d& aObject 610 ,const histo::p1d& aObject 611 ,const std::string& aPath 611 ,const std::string& aPath 612 ,const std::string& aName 612 ,const std::string& aName 613 ,int aShift = 0 613 ,int aShift = 0 614 ){ 614 ){ 615 std::ostringstream ossd; 615 std::ostringstream ossd; 616 ossd.precision(25); 616 ossd.precision(25); 617 617 618 typedef histo::axis<double,unsigned int>:: 618 typedef histo::axis<double,unsigned int>::bn_t bn_t; 619 std::ostream& writer = a_writer; 619 std::ostream& writer = a_writer; 620 620 621 std::string spaces; 621 std::string spaces; 622 for(int i=0;i<aShift;i++) spaces += " "; 622 for(int i=0;i<aShift;i++) spaces += " "; 623 623 624 // <profile1d> : 624 // <profile1d> : 625 writer << spaces << " <profile1d" 625 writer << spaces << " <profile1d" 626 << " path=" << sout(to_xml(aPath)) 626 << " path=" << sout(to_xml(aPath)) 627 << " name=" << sout(to_xml(aName)) 627 << " name=" << sout(to_xml(aName)) 628 << " title=" << sout(to_xml(aObject.t 628 << " title=" << sout(to_xml(aObject.title())) 629 << ">" << std::endl; 629 << ">" << std::endl; 630 630 631 // <annotations> : 631 // <annotations> : 632 write_annotations(aObject.annotations(),wr 632 write_annotations(aObject.annotations(),writer,aShift); 633 633 634 // <axis> : 634 // <axis> : 635 write_axis(aObject.axis(),"x",writer,ossd, 635 write_axis(aObject.axis(),"x",writer,ossd,aShift); 636 636 637 // <statistics> : 637 // <statistics> : 638 writer << spaces << " <statistics" 638 writer << spaces << " <statistics" 639 << " entries=" << num_out<unsigned int>(a 639 << " entries=" << num_out<unsigned int>(aObject.entries()) 640 << ">" << std::endl; 640 << ">" << std::endl; 641 writer << spaces << " <statistic" 641 writer << spaces << " <statistic" 642 << " direction=" << sout("x") 642 << " direction=" << sout("x") 643 << " mean=" << soutd(ossd,aObject.mea 643 << " mean=" << soutd(ossd,aObject.mean()) 644 << " rms=" << soutd(ossd,aObject.rms( 644 << " rms=" << soutd(ossd,aObject.rms()) 645 << "/>" << std::endl; 645 << "/>" << std::endl; 646 writer << spaces << " </statistics>" << 646 writer << spaces << " </statistics>" << std::endl; 647 647 648 // bins : 648 // bins : 649 writer << spaces << " <data1d>" << std: 649 writer << spaces << " <data1d>" << std::endl; 650 bn_t xbins = aObject.axis().bins(); 650 bn_t xbins = aObject.axis().bins(); 651 for(bn_t index=0;index<xbins;index++) { 651 for(bn_t index=0;index<xbins;index++) { 652 write_bin(writer,ossd,aObject,spaces,ind 652 write_bin(writer,ossd,aObject,spaces,index); 653 } 653 } 654 654 655 write_bin(writer,ossd,aObject,spaces,histo 655 write_bin(writer,ossd,aObject,spaces,histo::axis_UNDERFLOW_BIN); 656 write_bin(writer,ossd,aObject,spaces,histo 656 write_bin(writer,ossd,aObject,spaces,histo::axis_OVERFLOW_BIN); 657 657 658 writer << spaces << " </data1d>" << std 658 writer << spaces << " </data1d>" << std::endl; 659 writer << spaces << " </profile1d>" << st 659 writer << spaces << " </profile1d>" << std::endl; 660 660 661 return true; 661 return true; 662 } 662 } 663 663 664 inline bool write( 664 inline bool write( 665 std::ostream& a_writer 665 std::ostream& a_writer 666 ,const histo::p2d& aObject 666 ,const histo::p2d& aObject 667 ,const std::string& aPath 667 ,const std::string& aPath 668 ,const std::string& aName 668 ,const std::string& aName 669 ,int aShift = 0 669 ,int aShift = 0 670 ){ 670 ){ 671 std::ostringstream ossd; 671 std::ostringstream ossd; 672 ossd.precision(25); 672 ossd.precision(25); 673 673 674 typedef histo::axis<double,unsigned int>:: 674 typedef histo::axis<double,unsigned int>::bn_t bn_t; 675 std::ostream& writer = a_writer; 675 std::ostream& writer = a_writer; 676 676 677 std::string spaces; 677 std::string spaces; 678 for(int i=0;i<aShift;i++) spaces += " "; 678 for(int i=0;i<aShift;i++) spaces += " "; 679 679 680 // <profile2d> : 680 // <profile2d> : 681 writer << spaces << " <profile2d" 681 writer << spaces << " <profile2d" 682 << " path=" << sout(to_xml(aPath)) 682 << " path=" << sout(to_xml(aPath)) 683 << " name=" << sout(to_xml(aName)) 683 << " name=" << sout(to_xml(aName)) 684 << " title=" << sout(to_xml(aObject.t 684 << " title=" << sout(to_xml(aObject.title())) 685 << ">" << std::endl; 685 << ">" << std::endl; 686 686 687 // <annotations> : 687 // <annotations> : 688 write_annotations(aObject.annotations(),wr 688 write_annotations(aObject.annotations(),writer,aShift); 689 689 690 // <axis> : 690 // <axis> : 691 write_axis(aObject.axis_x(),"x",writer,oss 691 write_axis(aObject.axis_x(),"x",writer,ossd,aShift); 692 write_axis(aObject.axis_y(),"y",writer,oss 692 write_axis(aObject.axis_y(),"y",writer,ossd,aShift); 693 693 694 // <statistics> : 694 // <statistics> : 695 writer << spaces << " <statistics" 695 writer << spaces << " <statistics" 696 << " entries=" << num_out<unsigned int>(a 696 << " entries=" << num_out<unsigned int>(aObject.entries()) 697 << ">" << std::endl; 697 << ">" << std::endl; 698 writer << spaces << " <statistic" 698 writer << spaces << " <statistic" 699 << " direction=" << sout("x") 699 << " direction=" << sout("x") 700 << " mean=" << soutd(ossd,aObject.mea 700 << " mean=" << soutd(ossd,aObject.mean_x()) 701 << " rms=" << soutd(ossd,aObject.rms_ 701 << " rms=" << soutd(ossd,aObject.rms_x()) 702 << "/>" << std::endl; 702 << "/>" << std::endl; 703 writer << spaces << " <statistic" 703 writer << spaces << " <statistic" 704 << " direction=" << sout("y") 704 << " direction=" << sout("y") 705 << " mean=" << soutd(ossd,aObject.mea 705 << " mean=" << soutd(ossd,aObject.mean_y()) 706 << " rms=" << soutd(ossd,aObject.rms_ 706 << " rms=" << soutd(ossd,aObject.rms_y()) 707 << "/>" << std::endl; 707 << "/>" << std::endl; 708 writer << spaces << " </statistics>" << 708 writer << spaces << " </statistics>" << std::endl; 709 709 710 // bins : 710 // bins : 711 writer << spaces << " <data2d>" << std: 711 writer << spaces << " <data2d>" << std::endl; 712 {bn_t xbins = aObject.axis_x().bins(); 712 {bn_t xbins = aObject.axis_x().bins(); 713 bn_t ybins = aObject.axis_y().bins(); 713 bn_t ybins = aObject.axis_y().bins(); 714 for(bn_t indexX=0;indexX<xbins;indexX++) { 714 for(bn_t indexX=0;indexX<xbins;indexX++) { 715 for(bn_t indexY=0;indexY<ybins;indexY++) 715 for(bn_t indexY=0;indexY<ybins;indexY++) { 716 write_bin(writer,ossd,aObject,spaces,i 716 write_bin(writer,ossd,aObject,spaces,indexX,indexY); 717 } 717 } 718 }} 718 }} 719 719 720 write_bin(writer,ossd,aObject,spaces, 720 write_bin(writer,ossd,aObject,spaces, 721 histo::axis_UNDERFLOW_BI 721 histo::axis_UNDERFLOW_BIN,histo::axis_UNDERFLOW_BIN); 722 write_bin(writer,ossd,aObject,spaces, 722 write_bin(writer,ossd,aObject,spaces, 723 histo::axis_OVERFLOW_BIN 723 histo::axis_OVERFLOW_BIN,histo::axis_UNDERFLOW_BIN); 724 write_bin(writer,ossd,aObject,spaces, 724 write_bin(writer,ossd,aObject,spaces, 725 histo::axis_UNDERFLOW_BI 725 histo::axis_UNDERFLOW_BIN,histo::axis_OVERFLOW_BIN); 726 write_bin(writer,ossd,aObject,spaces, 726 write_bin(writer,ossd,aObject,spaces, 727 histo::axis_OVERFLOW_BIN 727 histo::axis_OVERFLOW_BIN,histo::axis_OVERFLOW_BIN); 728 728 729 for(bn_t indexX=0;indexX<aObject.axis_x(). 729 for(bn_t indexX=0;indexX<aObject.axis_x().bins();indexX++){ 730 write_bin(writer,ossd,aObject,spaces,ind 730 write_bin(writer,ossd,aObject,spaces,indexX,histo::axis_UNDERFLOW_BIN); 731 write_bin(writer,ossd,aObject,spaces,ind 731 write_bin(writer,ossd,aObject,spaces,indexX,histo::axis_OVERFLOW_BIN); 732 } 732 } 733 733 734 for(bn_t indexY=0;indexY<aObject.axis_y(). 734 for(bn_t indexY=0;indexY<aObject.axis_y().bins();indexY++){ 735 write_bin(writer,ossd,aObject,spaces,his 735 write_bin(writer,ossd,aObject,spaces,histo::axis_UNDERFLOW_BIN,indexY); 736 write_bin(writer,ossd,aObject,spaces,his 736 write_bin(writer,ossd,aObject,spaces,histo::axis_OVERFLOW_BIN,indexY); 737 } 737 } 738 738 739 writer << spaces << " </data2d>" << std 739 writer << spaces << " </data2d>" << std::endl; 740 writer << spaces << " </profile2d>" << st 740 writer << spaces << " </profile2d>" << std::endl; 741 741 742 return true; 742 return true; 743 } 743 } 744 744 745 }} 745 }} 746 746 747 #endif 747 #endif