648 const std::string& tagName = a_tree.tag_name();
656 }
else if(tagName==
"statistics") {
658 if(!a_tree.attribute_value(s_entries(),svalue))
return false;
663 unsigned int found = 0;
665 {looper _for(a_tree);
666 while(element* _elem = _for.next_element()) {
668 if(_elem->name()==s_statistic()) {
670 if(!_elem->attribute_value(s_mean(),svalue))
return false;
671 if(!to<double>(svalue,mean))
return false;
673 if(!_elem->attribute_value(s_rms(),svalue))
return false;
674 if(!to<double>(svalue,rms))
return false;
676 if(!_elem->attribute_value(s_direction(),svalue))
return false;
678 if(!
axis_index(aData.m_dimension,svalue,iaxis))
return false;
687 if(
found!=aData.m_dimension)
return false;
691 }
else if(tagName==
s_axis()) {
697 unsigned int dimension = 0;
698 if(tagName==s_data1d()) {
700 }
else if(tagName==s_data2d()) {
702 }
else if(tagName==s_data3d()) {
708 if(dimension!=aData.m_dimension)
return false;
711 sprintf(sbin,32,
"bin%dd",dimension);
713 {looper _for(a_tree);
714 while(element* _elem = _for.next_element()) {
716 if(_elem->name()==sbin) {
718 std::vector<int>
is(dimension);
720 unsigned int entries = 0;
723 double weightedMean = 0;
724 double weightedMeanX = 0;
725 double weightedMeanY = 0;
726 double weightedMeanZ = 0;
727 double weightedRms = 0;
728 double weightedRmsX = 0;
729 double weightedRmsY = 0;
730 double weightedRmsZ = 0;
734 if(!_elem->attribute_value(s_entries(),svalue)) {
735 a_out <<
"tools::xml::aidas::read_bins :"
736 <<
" a <bin1d> has no " <<
"entries"
741 if(!to<unsigned int>(svalue,entries)) {
742 a_out <<
"tools::xml::aidas::read_bins :"
743 <<
" problem converting a entries attribute to an unsigned int."
744 <<
" Value was " << sout(svalue) <<
"."
751 if(_elem->attribute_value(s_height(),svalue)) {
752 if(!
to_double(svalue,height,a_out,s_height()))
return false;
759 height = double(entries);
760 height_given =
false;
763 if(_elem->attribute_value(s_error(),svalue)) {
764 if(!
to_double(svalue,error,a_out,s_error()))
return false;
777 error = ::sqrt(::fabs( ((height*height)/entries) ));
785 error = ::sqrt(::fabs(
double(entries)));
789 if(_elem->attribute_value(s_rms(),svalue)) {
790 if(!
to_double(svalue,rms,a_out,s_rms()))
return false;
794 if(_elem->attribute_value(s_weightedMean(),svalue)) {
795 if(!
to_double(svalue,weightedMean,a_out,s_weightedMean()))
return false;
797 if(_elem->attribute_value(s_weightedRms(),svalue)) {
798 if(!
to_double(svalue,weightedRms,a_out,s_weightedRms()))
return false;
800 }
else if(dimension==2) {
801 if(_elem->attribute_value(s_weightedMeanX(),svalue)) {
802 if(!
to_double(svalue,weightedMeanX,a_out,s_weightedMeanX()))
return false;
804 if(_elem->attribute_value(s_weightedMeanY(),svalue)) {
805 if(!
to_double(svalue,weightedMeanY,a_out,s_weightedMeanY()))
return false;
807 if(_elem->attribute_value(s_weightedRmsX(),svalue)) {
808 if(!
to_double(svalue,weightedRmsX,a_out,s_weightedRmsX()))
return false;
810 if(_elem->attribute_value(s_weightedRmsY(),svalue)) {
811 if(!
to_double(svalue,weightedRmsY,a_out,s_weightedRmsY()))
return false;
813 }
else if(dimension==3) {
814 if(_elem->attribute_value(s_weightedMeanX(),svalue)) {
815 if(!
to_double(svalue,weightedMeanX,a_out,s_weightedMeanX()))
return false;
817 if(_elem->attribute_value(s_weightedMeanY(),svalue)) {
818 if(!
to_double(svalue,weightedMeanY,a_out,s_weightedMeanY()))
return false;
820 if(_elem->attribute_value(s_weightedMeanZ(),svalue)) {
821 if(!
to_double(svalue,weightedMeanZ,a_out,s_weightedMeanZ()))
return false;
823 if(_elem->attribute_value(s_weightedRmsX(),svalue)) {
824 if(!
to_double(svalue,weightedRmsX,a_out,s_weightedRmsX()))
return false;
826 if(_elem->attribute_value(s_weightedRmsY(),svalue)) {
827 if(!
to_double(svalue,weightedRmsY,a_out,s_weightedRmsY()))
return false;
829 if(_elem->attribute_value(s_weightedRmsZ(),svalue)) {
830 if(!
to_double(svalue,weightedRmsZ,a_out,s_weightedRmsZ()))
return false;
834 {
for(
unsigned int index=0;index<dimension;index++) {
835 std::string s =
"binNum";
837 if(index==0) s +=
"X";
838 else if(index==1) s +=
"Y";
839 else if(index==2) s +=
"Z";
841 if(!_elem->attribute_value(s,svalue)) {
842 a_out <<
"tools::xml::aidas::read_bins :"
843 <<
" a <bin1d> has no " << s << std::endl;
846 if(svalue==
"UNDERFLOW") {
848 }
else if(svalue==
"OVERFLOW") {
852 if(!to<int>(svalue,ival)) {
853 a_out <<
"tools::xml::aidas::read_bins :"
854 <<
" problem converting binNum to an int."
855 <<
" Value was " << sout(svalue) <<
"."
860 if( (ibin<0) || (ibin>=(
int)aData.m_axes[index].bins()) ) {
861 a_out <<
"tools::xml::aidas::read_bins :"
862 <<
" a binNum is out of range."
873 aData.m_bin_entries[offset] = entries;
884 aData.m_bin_Sw[offset] = sw;
885 aData.m_bin_Sw2[offset] = error * error;
887 aData.m_bin_Sxw[offset][0] = weightedMean * sw;
888 aData.m_bin_Sx2w[offset][0] =
889 (weightedRms * weightedRms + weightedMean * weightedMean) * sw;
890 }
else if(dimension==2){
892 aData.m_bin_Sxw[offset][0] = weightedMeanX * sw;
893 aData.m_bin_Sx2w[offset][0] =
894 (weightedRmsX*weightedRmsX + weightedMeanX*weightedMeanX) * sw;
896 aData.m_bin_Sxw[offset][1] = weightedMeanY * sw;
897 aData.m_bin_Sx2w[offset][1] =
898 (weightedRmsY*weightedRmsY + weightedMeanY*weightedMeanY) * sw;
899 }
else if(dimension==3){
901 aData.m_bin_Sxw[offset][0] = weightedMeanX * sw;
902 aData.m_bin_Sx2w[offset][0] =
903 (weightedRmsX*weightedRmsX + weightedMeanX*weightedMeanX) * sw;
905 aData.m_bin_Sxw[offset][1] = weightedMeanY * sw;
906 aData.m_bin_Sx2w[offset][1] =
907 (weightedRmsY*weightedRmsY + weightedMeanY*weightedMeanY) * sw;
909 aData.m_bin_Sxw[offset][2] = weightedMeanZ * sw;
910 aData.m_bin_Sx2w[offset][2] =
911 (weightedRmsZ*weightedRmsZ + weightedMeanZ*weightedMeanZ) * sw;
944 sw = (double)entries;
946 double r_e = rms/error;
949 aData.m_bin_Sw[offset] = sw;
950 aData.m_bin_Sw2[offset] = 0;
952 aData.m_bin_Sxw[offset][0] = weightedMean * sw;
953 aData.m_bin_Sx2w[offset][0] =
954 (weightedRms * weightedRms + weightedMean * weightedMean) * sw;
955 }
else if(dimension==2){
956 aData.m_bin_Sxw[offset][0] = weightedMeanX * sw;
957 aData.m_bin_Sxw[offset][1] = weightedMeanY * sw;
958 aData.m_bin_Sx2w[offset][0] =
959 (weightedRmsX*weightedRmsX + weightedMeanX*weightedMeanX) * sw;
960 aData.m_bin_Sx2w[offset][1] =
961 (weightedRmsY*weightedRmsY + weightedMeanY*weightedMeanY) * sw;
963 aData.m_bin_Svw[offset] = sw * height;
964 aData.m_bin_Sv2w[offset] = sw * (rms * rms + height * height);