Anaphe Home Page Reference Documentation

Main Page     Namespaces     Classes     Source Code    

H_Printout.cpp

Go to the documentation of this file.
00001 /*
00002 
00003 //
00004 // ***************************************************************************
00005 //
00006 
00007 Warning:
00008 This file is just an update of the existing (Kuba's) HistPrintout.
00009 I have just added some small changes to meet the new histo interface.
00010 The rest is unchanged: syntax, indentation, variable names...
00011 
00012 That's why the style is so different from my other files.
00013 
00014 //
00015 // ***************************************************************************
00016 //
00017 
00018 */
00019 
00020 
00021 #include "HTL/H_Printout.h"
00022 #include "HTL/H_Statistics.h"
00023 
00024 
00025 HTL_STREAM_STD::ostream& operator << (HTL_STREAM_STD::ostream&os, H_Printout::spaces sp)
00026 {
00027  for(int i=0; i<sp.n; i++)
00028    os << sp.x;
00029 
00030  return os;
00031 }
00032 
00033 HTL_STREAM_STD::ostream& operator << (HTL_STREAM_STD::ostream&os, H_Printout::bar3d b)
00034 {
00035 
00036  char c = (char)(b.x*ZSPECTRUM);
00037 
00038  switch(c)
00039    {
00040    case 0 : return os << '.';
00041    case 1 : return os << '+';          
00042    }
00043 
00044  if(c<10) return os << (char)('2'+c-2);
00045  //return os << '$';
00046  
00047  return os << (char)('A'+c-10);
00048  
00049 }
00050 
00051 
00052 /*
00053  automatically sets up the printing page from UNIX environment
00054  COLUMNS, LINES 
00055 */
00056 
00057 #include <stdlib.h>
00058 
00059 #include <string.h>
00060 
00061 int H_Printout::auto_setup()
00062 {
00063         lines = 0;
00064         HTL_STREAM_STD::istrstream is(getenv("COLUMNS"));
00065         is >> columns;
00066         if( is.bad() || is.fail() ) { columns = 0; return 0; }
00067         return 1;
00068 }
00069 
00070 
00071 void H_Printout::print( const I_Histo &a_histo )
00072 {
00073   I_Histo &h = (I_Histo &) a_histo;
00074   if ((h.dim() == 1) || (h.dim()==2)) {
00075     switch( h.dim() ) {
00076     case 1: print1( a_histo ); break;
00077     case 2: print2( a_histo ); break;
00078     default:
00079       break;
00080     }
00081   } else
00082     HTL_ERR("Invalid dimension in print(..)");
00083 }
00084 
00085 
00086 void H_Printout::print1( const I_Histo &a_histo )
00087 {
00088         I_Histo &h = (I_Histo &) a_histo;
00089 
00090 
00092 
00093  const char ENDSTR = '\0';
00094  char buf[255];
00095 
00096  // int lines_printed = 0; // counter of printed lines
00097 
00099  double ymin = H_Bin_Helper::in_range_min_value(h);
00100  double ymax = H_Bin_Helper::in_range_max_value(h);
00101  // double xmin = h.i_partition(0).i_lower_point();
00102  // double xmax = h.i_partition(0).i_upper_point();
00103 
00104  Size nBins = h.bin_count();
00105 
00106 
00108  double y_left_label = ymin;
00109  double y_right_label = ymax;
00110 
00112 
00113  /* // bin content printed along X axis - now commented out
00114 
00115  //1//
00116  */
00117 
00118  const HTL_STREAM_STD::ios::fmtflags binpos_flags = HTL_STREAM_STD::ios::internal|HTL_STREAM_STD::ios::dec|HTL_STREAM_STD::ios::showpoint|HTL_STREAM_STD::ios::scientific;
00119  const int binpos_prec = 3;
00120  const unsigned int binpos_width = binpos_prec+7; /* we automatically calculate field width for scientific mode, if you want to set your own width it should not be less that calculated here, for example: if(binpos_width<14) binpos_width = 14; */
00121 
00122  const HTL_STREAM_STD::ios::fmtflags binid_flags = 
00123    HTL_STREAM_STD::ios::left|HTL_STREAM_STD::ios::dec;
00124  const unsigned int binid_width = 4;
00125 
00126  const HTL_STREAM_STD::ios::fmtflags binval_flags = HTL_STREAM_STD::ios::internal|HTL_STREAM_STD::ios::dec|HTL_STREAM_STD::ios::showpoint|HTL_STREAM_STD::ios::scientific;
00127  const int binval_prec = 3;
00128  const unsigned int binval_width = binval_prec+8; //-ap allow for sign ...
00129 
00130  const HTL_STREAM_STD::ios::fmtflags y_left_label_flags = HTL_STREAM_STD::ios::left|HTL_STREAM_STD::ios::dec|HTL_STREAM_STD::ios::showpoint|HTL_STREAM_STD::ios::scientific;
00131  const HTL_STREAM_STD::ios::fmtflags y_right_label_flags = HTL_STREAM_STD::ios::right|HTL_STREAM_STD::ios::dec|HTL_STREAM_STD::ios::showpoint|HTL_STREAM_STD::ios::scientific;
00132  const int y_label_width = 8;
00133  const int y_label_prec = 2;
00134 
00136  
00137  int yMargin = 0; /* horizontal margin of the form: YValue  BinIdentifier */
00138  int yAxisLen = 0; /* minimal length of horizontal axis */
00139  int yAxisLabelGap = 0; /* length of the right x label -- to have a nice prinout */
00140  
00142 
00144  // due to a bug in AIX compiler (xlC) one cannot use manipulator 
00145  // as the first object inserted into temporary stream
00146  // like this: ostrstream(buf,255) << HTL_STREAM_STD::setw(5) << ... ;
00147  // due to a bug in DEC compiler one cannot use temporary streams at all
00148 
00149  {
00150   HTL_STREAM_STD::ostrstream s(buf,255);
00151   s << "" << HTL_STREAM_STD::setw(binpos_width) << HTL_STREAM_STD::setprecision(binpos_prec) << HTL_STREAM_STD::setiosflags(binpos_flags) << ymax << ENDSTR;
00152  }
00153 
00154  yMargin = strlen(buf);
00155 
00156  // due to bug in AIX compiler (xlC) I must insert trailing "" 
00157  // due to a bug in DEC compiler one cannot use temporary streams at all
00158  {
00159   HTL_STREAM_STD::ostrstream s(buf,255);
00160   s << "" << HTL_STREAM_STD::setw(binid_width) << HTL_STREAM_STD::setiosflags(binid_flags) << nBins << ENDSTR;
00161  }
00162 
00163  yMargin += strlen(buf);
00164 
00165   // due to bug in AIX compiler (xlC) I must insert trailing ""
00166  // due to a bug in DEC compiler one cannot use temporary streams at all
00167 
00168  {
00169   HTL_STREAM_STD::ostrstream s(buf,255);
00170   s << "" << HTL_STREAM_STD::setw(binval_width) << HTL_STREAM_STD::setprecision(binval_prec) << HTL_STREAM_STD::setiosflags(binval_flags) << ymax << ENDSTR;
00171  }
00172 
00173  yMargin += strlen(buf);
00174 
00175  yMargin += 3; /* to leave some space between columns */
00176 
00178 
00179  // due to bug in AIX compiler (xlC) I must insert trailing ""
00180  // due to a bug in DEC compiler one cannot use temporary streams at all
00181 
00182  {
00183   HTL_STREAM_STD::ostrstream s(buf,255);
00184   s << "" << HTL_STREAM_STD::setw(y_label_width) << HTL_STREAM_STD::setprecision(y_label_prec) << HTL_STREAM_STD::setiosflags(y_left_label_flags) << y_left_label << ENDSTR;
00185  }
00186 
00187  yAxisLen = strlen(buf);
00188 
00189  // due to bug in AIX compiler (xlC) I must insert trailing ""
00190  // due to a bug in DEC compiler one cannot use temporary streams at all
00191  {
00192  HTL_STREAM_STD::ostrstream s(buf,255);
00193  s << "" << HTL_STREAM_STD::setw(y_label_width) << HTL_STREAM_STD::setprecision(y_label_prec) << HTL_STREAM_STD::setiosflags(y_right_label_flags) << y_right_label << ENDSTR;
00194  }
00195 
00196  yAxisLen += strlen(buf);
00197 
00198  yAxisLabelGap = yMargin; /* now it is only summed length of both labels */
00199 
00200  yAxisLen += 3+1; /* to leave some space between labels */
00201   
00203 
00204  if( (yMargin + 1 + yAxisLen + 1 > columns && columns != 0) ||
00205      (2 + (long) nBins + 1 > lines && lines != 0) ) 
00206    os << HTL_STREAM_STD::endl << "****** WARNING *******" << HTL_STREAM_STD::endl << "HISTOGRAM GRAPH DOES NOT FIT INTO REQUESTED PAGE (columns=" << columns << ",lines=" << lines << ")"<< HTL_STREAM_STD::endl << "Graph may be either truncated or distorted or may exceed the page" << HTL_STREAM_STD::endl << spaces(20,'*') << HTL_STREAM_STD::endl;
00207 
00208  if(columns > 0) yAxisLen = columns-yMargin-2; // expand yAxisLen to a full possible size
00209 
00210  yAxisLabelGap = yAxisLen - yAxisLabelGap; // calculate the final gap. -2 for "Y" at the end
00211 
00212  /* HISTOGRAM TITLE AND MAIN LABEL */
00213  
00214  os
00215     << "TYPE       : Histo1D" << HTL_STREAM_STD::endl 
00216     << "TITLE      : " << h.name() << HTL_STREAM_STD::endl
00217     << "BIN COUNT  : " << nBins << HTL_STREAM_STD::endl
00218     << "BIN WIDTH  : " << h.i_partition(0).i_bin_width(0) << HTL_STREAM_STD::endl << HTL_STREAM_STD::endl;
00219 
00220 #if 0 // NEW_HISTO
00221  else
00222  {
00223   os 
00224     << "TYPE        : Histo1D Variable Length Bins" << HTL_STREAM_STD::endl 
00225     << "TITLE       : " << h.get_name() << HTL_STREAM_STD::endl
00226     << "BIN NUMBER  : " << nBins << HTL_STREAM_STD::endl
00227     << "BINS' ENDPTS: ";
00228 
00229    os << "-und-";
00230 
00231    size_t nbins = h.get_nBins();
00232 
00233    for(int k=0; k<nbins; k++) {
00234       char a,b;
00235 
00236       if( h.bin_left_open(k) ) { a =  ']'; b = '('; }
00237       else { a = ')'; b = '['; }
00238 
00239       os << a <<  h.get_bin_xmin(k) << b;
00240 
00241       if( !(k%3) && k ) os << HTL_STREAM_STD::endl << spaces(17);
00242 
00243       os << "--";
00244      }
00245     
00246    {
00247     char a,b;
00248 
00249     if( h.bin_right_open(nbins-1) ) { a = ')'; b = '['; }
00250        else
00251         {
00252          a =  ']'; b = '(';
00253         }
00254     
00255       os << a << h.get_bin_xmax(nbins-1) << b << "-ovr-";
00256    }
00257 
00258    /*
00259    os << ( h.bin_left_open(nbins) ? ']' : ')' ) <<  h.get_bin_xmin(k) 
00260          << ( h.bin_right_open(k) ? '(' : '[' ) <<"--ovr";
00261          */
00262              //   os << ( h.bin_right_open(nbins-1) ? ')' : ']' ) << "--ovrflw";
00263 
00264   /*  HepVArray(double)& eps = ((Histo1DVar&)h).get_end_point_list();
00265 
00266    for(int k=0; k<eps.size(); k++)
00267      os << eps[k] << "--";
00268      */
00269    os << HTL_STREAM_STD::endl << HTL_STREAM_STD::endl;
00270   }
00271   
00272 #endif
00273 
00274 
00275  /* Y AXIS LABEL */
00276 
00277  os << spaces(yMargin);
00278 
00279  os.flags(y_left_label_flags);
00280  os << HTL_STREAM_STD::setw(y_label_width) << HTL_STREAM_STD::setprecision(y_label_prec) << y_left_label ;
00281 
00282  os << spaces(yAxisLabelGap+10);
00283 
00284  os.flags(y_right_label_flags);
00285  os << HTL_STREAM_STD::setw(y_label_width) << HTL_STREAM_STD::setprecision(y_label_prec) << y_right_label;
00286 
00287  os << " Y";
00288  os << HTL_STREAM_STD::endl;
00289 
00290  if ((ymin < 0) && (ymax > 0)) {        // crossing zero at -ymin ...
00291    os << spaces(yMargin);
00292    os << " |";
00293    int n0 = int(yAxisLen*( (double)(-ymin)/(double)(ymax-ymin)));
00294    os << spaces(n0-1);
00295    os << spaces(1,'0');
00296    os << spaces(yAxisLabelGap-n0);
00297    os << HTL_STREAM_STD::endl;
00298  }
00299 
00300  /* Y AXIS */
00301 
00302  // os << spaces(yMargin/2) << "X" << spaces(yMargin/2 + (yMargin%2 ? 0 : -1)) << '|' << spaces(yAxisLen,'-') << '>';
00303 
00304  //char *STR_CONTENTS = "CONTENTS";
00305 
00306  char STR_POS[16];
00307  char STR_BIN[16];
00308  char STR_BVAL[16];
00309  strcpy(STR_POS,"X POSITION");
00310  strcpy(STR_BIN,"BIN");
00311  strcpy(STR_BVAL,"VALUE");
00312 
00313  //if( binval_width < strlen(STR_CONTENTS) ) STR_CONTENTS[binval_width] = '\0';
00314 
00315  if( binpos_width < strlen(STR_POS) ) STR_POS[binpos_width] = '\0';
00316  if( binid_width < strlen(STR_BIN) ) STR_BIN[binid_width] = '\0';
00317  if( binval_width < strlen(STR_BVAL) ) STR_BVAL[binval_width] = '\0';
00318   
00319  // os.flags(binval_flags);
00320  // os << HTL_STREAM_STD::setw(binval_width) << STR_CONTENTS;
00321 
00322  os.flags(binpos_flags);
00323  os << HTL_STREAM_STD::setw(binpos_width) << STR_POS;
00324  
00325  os << spaces(3);
00326     
00327  os.flags(binid_flags);
00328  os << HTL_STREAM_STD::setw(binid_width) << STR_BIN;
00329 
00330  os << spaces(1);
00331 
00332  os.flags(binval_flags);
00333  os << HTL_STREAM_STD::setw(binval_width) << STR_BVAL;
00334  
00335  os << '|' << spaces(yAxisLen,'-') << '>';
00336 
00337  os << HTL_STREAM_STD::endl;
00338 
00339  /* bins along with X axis */
00340 
00341   for(Size i = 0; i < nBins; i++ )
00342    {
00343      
00344      double val = h.i_bin(i).value(); 
00345 
00346      /*
00347      os.flags(binval_flags);
00348      os << HTL_STREAM_STD::setw(binval_width) << HTL_STREAM_STD::setprecision(binval_prec) << val;
00349      */
00350 
00351      os.flags(binpos_flags);
00352      os << HTL_STREAM_STD::setw(binpos_width) << HTL_STREAM_STD::setprecision(binpos_prec) 
00353      << h.i_partition(0).i_lower_point(i);
00354  
00355      os << spaces(3);
00356     
00357      os.flags(binid_flags);
00358      os << HTL_STREAM_STD::setw(binid_width) << i;
00359 
00360      os << spaces(1);
00361 
00362      os.flags(binval_flags);
00363      os << HTL_STREAM_STD::setw(binval_width) << HTL_STREAM_STD::setprecision(binval_prec) << val;     
00364 
00365      os << "|";
00366      
00367      /* protect against divide by zero */
00368      if( ymax != ymin ) {
00369        if ((ymin < 0) && (ymax > 0)) {  // crossing zero at -ymin ...
00370          int nX = int(yAxisLen*( (double)(val-ymin)/(double)(ymax-ymin)));
00371          int n0 = int(yAxisLen*( (double)(-ymin)/(double)(ymax-ymin)));
00372          if (n0 > nX) {
00373            os << spaces(      nX, 'X');
00374            os << spaces( n0-nX-1, ' ');
00375            os << spaces(       1, '|');
00376          } else if (n0 == nX) {
00377            os << spaces(      nX, 'X');
00378          } else {               // n0 < nX
00379            os << spaces(  n0-1, 'X');
00380            os << spaces(     1, '|');
00381            os << spaces( nX-n0, 'X');
00382          }
00383        } else {
00384          os  << spaces( int(yAxisLen*( (double)(val-ymin)/(double)(ymax-ymin))), 'X');
00385        }
00386      } else {
00387       os  << spaces( 1, 'X');   // at least an "X" if Histo is constant (max==min)
00388      }
00389      os << HTL_STREAM_STD::endl; 
00390    }
00391 
00392  
00393  os << spaces(yMargin-2) << " X |" << HTL_STREAM_STD::endl;
00394  os << spaces(yMargin) << " V" << HTL_STREAM_STD::endl;
00395 
00396 /* HISTOGRAM CHARACTERISTICS */
00397 
00398  int chfield_width = 10;
00399 
00400  os << "UNDERFLOW : " << HTL_STREAM_STD::setw(chfield_width)
00401     << h.i_bin( h.bin_count() ).value()
00402     << " OVERFLOW : " << HTL_STREAM_STD::setw(chfield_width)
00403     << h.i_bin( h.bin_count()+2 ).value()
00404     << HTL_STREAM_STD::endl;
00405  os << " IN RANGE : " << HTL_STREAM_STD::setw(chfield_width)
00406     << H_Statistics::in_range_entries_count(h)
00407     << " EXTRA    : " << HTL_STREAM_STD::setw(chfield_width)
00408     << H_Statistics::extra_entries_count(h)
00409     << HTL_STREAM_STD::endl;
00410 
00411  double h_mean = H_Statistics::mean(h); 
00412  os << " MEAN B.C.: " << HTL_STREAM_STD::setw(chfield_width)
00413     << h_mean
00414     << " RMS B.C. : " << HTL_STREAM_STD::setw(chfield_width)
00415     << H_Statistics::rms(h, h_mean )
00416     << HTL_STREAM_STD::endl;
00417 
00418 }
00419 
00420 
00421 
00422 void H_Printout::print2( const I_Histo &a_histo )
00423 {
00424         I_Histo &h = (I_Histo &) a_histo;
00425 
00426 
00428 
00429  const char ENDSTR = '\0';
00430  char buf[255];
00431 
00433 
00434  double zmin = H_Bin_Helper::in_range_min_value(h);
00435  double zmax = H_Bin_Helper::in_range_max_value(h);
00436 
00437  double xmin = h.i_partition(0).i_lower_point();
00438  double xmax = h.i_partition(0).i_upper_point();
00439  Size nxBins = h.i_partition(0).bin_count();
00440 
00441  double ymin = h.i_partition(1).i_lower_point();
00442  double ymax = h.i_partition(1).i_upper_point();
00443  Size nyBins = h.i_partition(1).bin_count();
00444 
00445  const HTL_STREAM_STD::ios::fmtflags binid_flags = 
00446    HTL_STREAM_STD::ios::right|HTL_STREAM_STD::ios::dec;
00447  const int binid_width = 4;
00448 
00449 //  const int y_left_label_flags = HTL_STREAM_STD::ios::left|HTL_STREAM_STD::ios::dec|HTL_STREAM_STD::ios::showpoint|HTL_STREAM_STD::ios::scientific;
00450 //  const int y_right_label_flags = HTL_STREAM_STD::ios::right|HTL_STREAM_STD::ios::dec|HTL_STREAM_STD::ios::showpoint|HTL_STREAM_STD::ios::scientific;
00451 //  const int y_label_width = 8;
00452 //  const int y_label_prec = 2;
00453 
00455  
00456  int xMargin = 0; /* horizontal margin of the form: YValue  BinIdentifier */
00457  int xAxisLen = 0; /* minimal length of horizontal axis */
00458 
00459  int yMargin = 0;
00460  int yAxisLen = 0;
00461  
00463 
00465 
00466  // due to bug in AIX compiler (xlC) I must insert trailing ""
00467  // due to a bug in DEC compiler one cannot use temporary streams at all
00468  {
00469   HTL_STREAM_STD::ostrstream s(buf,255);
00470   s<< "" << HTL_STREAM_STD::setw(binid_width) << HTL_STREAM_STD::setiosflags(binid_flags) << nyBins << ENDSTR;
00471  }
00472 
00473  yMargin = strlen(buf);
00474  yMargin += 3; /* to leave some space between label and the graph */
00475 
00476 // due to a bug in DEC compiler one cannot use temporary streams at all
00477  {
00478   HTL_STREAM_STD::ostrstream s(buf,255);
00479   s << nxBins << ENDSTR;
00480  }
00481 
00482  xMargin = strlen(buf);
00483 
00485 
00486  xAxisLen = nxBins + 2; 
00487  yAxisLen = nyBins + 4; // now for space (previously for overflow/underflow bins)
00488   
00490 
00491  if( (xMargin + 1 + xAxisLen + 1 > columns && columns != 0) ||
00492      (yMargin + 1 + yAxisLen + 1 > lines && lines != 0) ) 
00493    os << HTL_STREAM_STD::endl << "****** WARNING *******" << HTL_STREAM_STD::endl << "HISTOGRAM GRAPH DOES NOT FIT INTO REQUESTED PAGE (columns=" << columns << ",lines=" << lines << ")"<< HTL_STREAM_STD::endl << "Graph may exceed the page" << HTL_STREAM_STD::endl << spaces(20,'*') << HTL_STREAM_STD::endl;
00494  /*
00495  if(columns > 0) yAxisLen = columns-yMargin-2; // expand yAxisLen to a full possible size
00496  
00497  yAxisLabelGap = yAxisLen - yAxisLabelGap; // calculate the final gap. -2 for "Y" at the end
00498  */
00499 
00500  /* HISTOGRAM TITLE AND MAIN LABEL */
00501 
00502  os.flags(HTL_STREAM_STD::ios::scientific);
00503 
00504  //if(h.get_typeid() == Histo2D::class_typeid())
00505 
00506  os
00507     << "TYPE     : Histo2D" << HTL_STREAM_STD::endl 
00508     << "TITLE    : " << h.name() << HTL_STREAM_STD::endl
00509     << "X:  BINS : " << HTL_STREAM_STD::setw(5) << nxBins 
00510     << "  WIDTH  : " << HTL_STREAM_STD::setprecision(3) << h.i_partition(0).i_bin_width(0)
00511     << "  MIN    : " << HTL_STREAM_STD::setprecision(3) << xmin
00512     << "  MAX    : " << HTL_STREAM_STD::setprecision(3) << xmax 
00513     << HTL_STREAM_STD::endl
00514     << "Y:  BINS : " << HTL_STREAM_STD::setw(5) << nyBins 
00515     << "  WIDTH  : " << HTL_STREAM_STD::setprecision(3) << h.i_partition(1).i_bin_width(0)
00516     << "  MIN    : " << HTL_STREAM_STD::setprecision(3) << ymin
00517     << "  MAX    : " << HTL_STREAM_STD::setprecision(3) << ymax << HTL_STREAM_STD::endl << HTL_STREAM_STD::endl;
00518 
00519 #if 0 // NEW_HISTO
00520 
00521  else
00522    { 
00523    os
00524     << "TYPE     : Histo2D" << HTL_STREAM_STD::endl 
00525     << "TITLE    : " << h.get_name() << HTL_STREAM_STD::endl
00526     << "X:  BINS : " << HTL_STREAM_STD::setw(5) << h.get_nxBins();
00527 
00528    os << "    ";
00529  
00530    os << "-und-";
00531 
00532    size_t nbins = h.get_nxBins();
00533 
00534    for(Index k=0; k<nbins; k++)
00535      {
00536       char a,b;
00537       
00538       if( h.bin_leftx_open(k) ) { a =  ']'; b = '('; }
00539        else
00540         { 
00541          a = ')'; b = '[';
00542         }
00543 
00544       os << a <<  h.get_bin_xmin(k) << b;
00545 
00546       if( !(k%3) && k ) os << HTL_STREAM_STD::endl << spaces(23);
00547       os << "--";
00548      }
00549     
00550    {
00551     char a,b;
00552     
00553     if( h.bin_rightx_open(nbins-1) ) { a = ')'; b = '['; }
00554        else
00555         {
00556          a =  ']'; b = '(';
00557         }
00558         
00559     
00560     os << a << h.get_bin_xmax(nbins-1) << b << "-ovr-";
00561    }
00562    os << HTL_STREAM_STD::endl;
00563 
00564    os << "Y:  BINS : " << HTL_STREAM_STD::setw(5) << h.get_nyBins();
00565 
00566    os << "    ";
00567    os << "-und-";
00568 
00569    nbins = h.get_nyBins();
00570 
00571    for(k=0; k<nbins; k++)
00572      {
00573       char a,b;
00574 
00575       if( h.bin_lefty_open(k) ) { a =  ']'; b = '('; }
00576        else
00577         { 
00578          a = ')'; b = '[';
00579         }
00580 
00581       os << a <<  h.get_bin_ymin(k) << b;
00582 
00583       if( !(k%3) && k ) os << HTL_STREAM_STD::endl << spaces(23);
00584       os << "--";
00585      }
00586     
00587    {
00588     char a,b;
00589 
00590     if( h.bin_righty_open(nbins-1) ) { a = ')'; b = '['; }
00591        else
00592         {
00593          a =  ']'; b = '(';
00594         }
00595     
00596       os << a << h.get_bin_ymax(nbins-1) << b << "-ovr-";
00597    }   
00598 
00599    os <<  HTL_STREAM_STD::endl;
00600    }
00601 
00602 #endif
00603  
00604  
00605  os << HTL_STREAM_STD::endl;
00606 
00607  /* X AXIS LABEL */
00608 
00609  Index i;
00610  for(i=xMargin-1; i>=0; i--)
00611    {
00612      os << spaces(yMargin);
00613 
00614      //if(i==0) os << "U"; else 
00615 
00616      os << "  ";
00617 
00618      long base = long( pow( (double) 10, (int) i) );
00619      
00620      for(Size j=0; j<nxBins; j++)
00621          if( j%base == 0 ) os << (j/base)%10;
00622           else
00623             os << " ";
00624 
00625      //if(i==0) os << "O"; else 
00626 
00627      os << "  ";
00628 
00629      os << HTL_STREAM_STD::endl;
00630    }
00631 
00632  os << spaces(yMargin) << " " << spaces(xAxisLen,'*');
00633 
00634  
00635 #if 0
00636  os.flags(y_left_label_flags);
00637  os << HTL_STREAM_STD::setw(y_label_width) << HTL_STREAM_STD::setprecision(y_label_prec) << y_left_label ;
00638 
00639  os << spaces(yAxisLabelGap);
00640 
00641  os.flags(y_right_label_flags);
00642  os << HTL_STREAM_STD::setw(y_label_width) << HTL_STREAM_STD::setprecision(y_label_prec) << y_right_label;
00643 
00644  os << " Y";
00645  os << HTL_STREAM_STD::endl;
00646 
00647 
00648  /* Y AXIS */
00649 
00650  // os << spaces(yMargin/2) << "X" << spaces(yMargin/2 + (yMargin%2 ? 0 : -1)) << '|' << spaces(yAxisLen,'-') << '>';
00651 
00652  //char *STR_CONTENTS = "CONTENTS";
00653 
00654  char *STR_POS = "X POSITION";
00655  char *STR_BIN = "BIN";
00656 
00657  //if( binval_width < strlen(STR_CONTENTS) ) STR_CONTENTS[binval_width] = '\0';
00658 
00659  if( binpos_width < strlen(STR_POS) ) STR_POS[binpos_width] = '\0';
00660  if( binid_width < strlen(STR_BIN) ) STR_BIN[binid_width] = '\0';
00661   
00662  // os.flags(binval_flags);
00663  // os << HTL_STREAM_STD::setw(binval_width) << STR_CONTENTS;
00664 
00665  os.flags(binpos_flags);
00666  os << HTL_STREAM_STD::setw(binpos_width) << STR_POS;
00667  
00668  os << spaces(3);
00669     
00670  os.flags(binid_flags);
00671  os << HTL_STREAM_STD::setw(binid_width) << STR_BIN;
00672  
00673  os << '|' << spaces(yAxisLen,'-') << '>';
00674 
00675  os << HTL_STREAM_STD::endl;
00676 
00677 #endif 
00678 
00679  /* bins along with Y axis */
00680 
00681  os << HTL_STREAM_STD::endl;
00682 
00683  os << spaces(yMargin) << '*' << spaces(xAxisLen) << '*'  << HTL_STREAM_STD::endl; // extra space
00684 
00685   I_Histo::I_Bin_Location l( h.dim() );
00686 
00687   for(i = 0; i < nyBins; i++ )
00688    {
00689 
00690      os.flags(binid_flags);
00691      os << HTL_STREAM_STD::setw(binid_width) << i;
00692      os << spaces(yMargin-binid_width-1) << "*";     
00693 
00694      os << "  ";
00695 
00696      for( Size j = 0; j < nxBins; j++ )
00697        {
00698          l[0] = j; l[1] = i;
00699          double val = h.i_bin(l).value();
00700           
00701          /* protect against divide by zero */
00702 
00703          if( zmax != zmin ) 
00704            os << bar3d((double)(val-zmin)/(double)(zmax-zmin));
00705           else
00706             os << " ";
00707 
00708        }
00709 
00710      os << "  " << "*" << HTL_STREAM_STD::endl;
00711          
00712    }
00713  os << spaces(yMargin) << '*' << spaces(xAxisLen) << '*'  << HTL_STREAM_STD::endl; // extra space
00714  os << spaces(yMargin) << " " << spaces(xAxisLen,'*');
00715 
00716  os << HTL_STREAM_STD::endl << HTL_STREAM_STD::endl;
00717 
00718 
00719 /* HISTOGRAM CHARACTERISTICS */
00720 
00721  int chfield_width = 10;
00722 
00723  os << "ENTRIES  : " << HTL_STREAM_STD::setw(chfield_width) 
00724     << H_Statistics::in_range_entries_count(h)
00725     + H_Statistics::extra_entries_count(h)
00726     << spaces(3)
00727     << "Z MIN    : " << HTL_STREAM_STD::setw(chfield_width) << zmin << HTL_STREAM_STD::endl;
00728 
00729  os << "TOTAL C. : " << HTL_STREAM_STD::setw(chfield_width)
00730     << H_Bin_Helper::in_range_value(h)  << spaces(3)
00731     << "Z STEP   : " << HTL_STREAM_STD::setw(chfield_width) << (zmax-zmin)/ZSPECTRUM << HTL_STREAM_STD::endl;
00732 
00733  os << "Z SCALE  : .+23456789ABCDE" << HTL_STREAM_STD::endl << HTL_STREAM_STD::endl;
00734 
00735  os << spaces(4) 
00736     << HTL_STREAM_STD::setw(chfield_width) 
00737     << un_ov_value(h,H_UNDERFLOW, H_OVERFLOW) << " | " 
00738     << HTL_STREAM_STD::setw(chfield_width)
00739     << un_ov_value(h,H_IN_RANGE, H_OVERFLOW) <<" | "
00740     << HTL_STREAM_STD::setw(chfield_width) 
00741     << un_ov_value(h,H_OVERFLOW, H_OVERFLOW) << HTL_STREAM_STD::endl;
00742  
00743  os << spaces(4) 
00744     << spaces(chfield_width,'-') << "-|-" 
00745     << spaces(chfield_width,'-') << "-|-" 
00746     << spaces(chfield_width,'-')
00747     << HTL_STREAM_STD::endl;
00748 
00749  os << spaces(4) 
00750     << HTL_STREAM_STD::setw(chfield_width) 
00751     << un_ov_value(h,H_UNDERFLOW, H_IN_RANGE) << " | " 
00752     << HTL_STREAM_STD::setw(chfield_width) 
00753     << H_Bin_Helper::in_range_value(h) << " | "
00754     << HTL_STREAM_STD::setw(chfield_width) 
00755     << un_ov_value(h,H_OVERFLOW, H_IN_RANGE) <<HTL_STREAM_STD::endl;
00756 
00757  os << spaces(4) 
00758     << spaces(chfield_width,'-') << "-|-" 
00759     << spaces(chfield_width,'-') << "-|-" 
00760     << spaces(chfield_width,'-')
00761     << HTL_STREAM_STD::endl;
00762 
00763  os << spaces(4) 
00764     << HTL_STREAM_STD::setw(chfield_width) 
00765     << un_ov_value(h,H_UNDERFLOW, H_UNDERFLOW) << " | " 
00766     << HTL_STREAM_STD::setw(chfield_width) 
00767     << un_ov_value(h,H_IN_RANGE, H_UNDERFLOW) << " | "
00768     << HTL_STREAM_STD::setw(chfield_width) 
00769     << un_ov_value(h,H_OVERFLOW, H_UNDERFLOW) << HTL_STREAM_STD::endl;
00770 
00771 
00772 }
00773 
00774 double H_Printout::un_ov_value(const I_Histo &h,Extra_Index ei,Extra_Index ej)
00775 {
00776   // Compute out-of-range bins:
00777   I_Histo::I_Extra_Bin_Location e(2);
00778   e[0]=ei;
00779   e[1]=ej;
00780   I_Histo &hNonConst = (const_cast<I_Histo &>(h));
00781   return (hNonConst.i_extra_bin(e)).value();
00782 }


Anaphe documentation generated by Doxygen (www.doxygen.org)