Changeset 3145 in Sophya for trunk/SophyaPI/PIext


Ignore:
Timestamp:
Jan 18, 2007, 5:33:46 PM (19 years ago)
Author:
ansari
Message:

1/ Petites modifs ds PIHisto et le P1DHistoWrapper - en particulier decodage des options et choix renvoi BinContent/Error/NEntries
2/ Codage Wrapper pour Histo-2D et modifs PIHisto2D
3/ Suppression des adaptateurs de tableaux PI des Histos2D ds pipodrw.h .cc, les
Wrappers d'histos heritant de P1D,P2DArrayAdapter
4/ Mise a jour Makefile et smakefile

Reza , 18/01/2007

Location:
trunk/SophyaPI/PIext
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/Makefile

    r3133 r3145  
    597597  $(SOPHYAINCP)pisurfdr.h pipodrw.h \
    598598  $(SOPHYAINCP)histos2.h $(SOPHYAINCP)histos.h \
    599   pintuple.h pintup3d.h pigfd1.h pigfd2.h
     599  $(SOPHYAINCP)hist2err.h pintuple.h pintup3d.h pigfd1.h \
     600  pigfd2.h
    600601        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  nobjmgr.cc
    601602 
     
    691692  $(SOPHYAINCP)generalfunc.h pipodrw.h \
    692693  $(SOPHYAINCP)histos2.h $(SOPHYAINCP)histos.h \
     694  $(SOPHYAINCP)hist2err.h \
    693695  $(SOPHYAINCP)objfitter.h \
    694696  $(SOPHYAINCP)cimage.h $(SOPHYAINCP)fioarr.h \
     
    741743  $(SOPHYAINCP)generalfunc.h \
    742744  $(SOPHYAINCP)histerr.h \
    743   $(SOPHYAINCP)hist2err.h servnobjm.h nobjmgr.h dlftypes.h \
    744   $(SOPHYAINCP)pdlmgr.h $(SOPHYAINCP)zthread.h \
    745   pihisto.h phistwrapper.h sohiswrap.h $(SOPHYAINCP)histos.h \
    746   $(SOPHYAINCP)hisprof.h \
     745  $(SOPHYAINCP)hist2err.h pihisto.h phistwrapper.h \
     746  pihisto2d.h $(SOPHYAINCP)pimenux.h \
     747  $(SOPHYAINCP)pimenugen.h \
     748  $(SOPHYAINCP)pimenubarx.h \
     749  $(SOPHYAINCP)pimenubargen.h \
     750  $(SOPHYAINCP)pioptmenux.h \
     751  $(SOPHYAINCP)pioptmenugen.h \
     752  $(SOPHYAINCP)pistdwdgx.h \
     753  $(SOPHYAINCP)pistdwdggen.h \
     754  $(SOPHYAINCP)piscdrawwdg.h \
     755  $(SOPHYAINCP)pibwdgx.h \
     756  $(SOPHYAINCP)pigraphps.h \
     757  $(SOPHYAINCP)piwindowx.h \
     758  $(SOPHYAINCP)piwindowgen.h \
     759  $(SOPHYAINCP)picontainerx.h \
     760  $(SOPHYAINCP)picontainergen.h \
     761  $(SOPHYAINCP)pieldrw.h sohiswrap.h \
     762  $(SOPHYAINCP)histos.h $(SOPHYAINCP)hisprof.h \
     763  $(SOPHYAINCP)histos2.h pipodrw.h servnobjm.h nobjmgr.h \
     764  dlftypes.h $(SOPHYAINCP)pdlmgr.h \
     765  $(SOPHYAINCP)zthread.h \
    747766  $(SOPHYAINCP)objfitter.h \
    748   $(SOPHYAINCP)cimage.h $(SOPHYAINCP)fioarr.h \
    749   $(SOPHYAINCP)histos2.h
     767  $(SOPHYAINCP)cimage.h $(SOPHYAINCP)fioarr.h
    750768        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  nomherradapter.cc
    751769 
     
    795813  $(SOPHYAINCP)generalfunc.h \
    796814  $(SOPHYAINCP)histos.h $(SOPHYAINCP)histos2.h \
    797   $(SOPHYAINCP)hisprof.h $(SOPHYAINCP)histerr.h \
    798   $(SOPHYAINCP)ntuple.h $(SOPHYAINCP)xntuple.h \
     815  $(SOPHYAINCP)hisprof.h $(SOPHYAINCP)ntuple.h \
     816  $(SOPHYAINCP)xntuple.h \
    799817  $(SOPHYAINCP)basedtable.h \
    800818  $(SOPHYAINCP)segdatablock.h pihisto.h phistwrapper.h \
    801   sohiswrap.h pihisto2d.h $(SOPHYAINCP)pimenux.h \
     819  sohiswrap.h $(SOPHYAINCP)histerr.h \
     820  $(SOPHYAINCP)hist2err.h pihisto2d.h \
     821  $(SOPHYAINCP)pimenux.h \
    802822  $(SOPHYAINCP)pimenugen.h \
    803823  $(SOPHYAINCP)pimenubarx.h \
     
    14361456  $(SOPHYAINCP)pitherm.h \
    14371457  $(SOPHYAINCP)resusage.h nomhistadapter.h \
    1438   $(SOPHYAINCP)histerr.h $(SOPHYAINCP)xntuple.h \
     1458  $(SOPHYAINCP)xntuple.h \
    14391459  $(SOPHYAINCP)basedtable.h \
    14401460  $(SOPHYAINCP)segdatablock.h nomgfdadapter.h \
     
    15471567  $(SOPHYAINCP)pievthandler.h \
    15481568  $(SOPHYAINCP)psfile.h $(SOPHYAINCP)pigratt.h \
    1549   $(SOPHYAINCP)piaxes.h phistwrapper.h
     1569  $(SOPHYAINCP)piaxes.h phistwrapper.h \
     1570  $(SOPHYAINCP)parradapter.h $(SOPHYAINCP)lut.h
    15501571        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  pihisto.cc
    15511572 
     
    15841605  $(SOPHYAINCP)pioptmenux.h \
    15851606  $(SOPHYAINCP)pioptmenugen.h \
    1586   $(SOPHYAINCP)histos2.h $(SOPHYAINCP)peida.h \
    1587   $(SOPHYAINCP)utils.h $(SOPHYAINCP)perrors.h \
    1588   $(SOPHYAINCP)pexceptions.h \
    1589   $(SOPHYAINCP)fmath.h $(SOPHYAINCP)histos.h \
    1590   $(SOPHYAINCP)objfio.h \
    1591   $(SOPHYAINCP)anydataobj.h \
    1592   $(SOPHYAINCP)ppersist.h $(SOPHYAINCP)gnumd5.h \
    1593   $(SOPHYAINCP)ppfbinstream.h \
    1594   $(SOPHYAINCP)rawstream.h \
    1595   $(SOPHYAINCP)ppfnametag.h \
    1596   $(SOPHYAINCP)tvector.h $(SOPHYAINCP)tmatrix.h \
    1597   $(SOPHYAINCP)tarray.h $(SOPHYAINCP)basarr.h \
    1598   $(SOPHYAINCP)mutyv.h $(SOPHYAINCP)timestamp.h \
    1599   $(SOPHYAINCP)dvlist.h \
    1600   $(SOPHYAINCP)ndatablock.h \
    1601   $(SOPHYAINCP)utilarr.h \
    1602   $(SOPHYAINCP)tmatrix_tsnl.h \
    1603   $(SOPHYAINCP)tvector_tsnl.h \
    16041607  $(SOPHYAINCP)pidrawer.h \
    16051608  $(SOPHYAINCP)pigratt.h $(SOPHYAINCP)piaxes.h \
     
    16071610  $(SOPHYAINCP)piwindowx.h \
    16081611  $(SOPHYAINCP)piwindowgen.h \
    1609   $(SOPHYAINCP)pieldrw.h \
     1612  $(SOPHYAINCP)pieldrw.h phistwrapper.h \
     1613  $(SOPHYAINCP)parradapter.h $(SOPHYAINCP)lut.h \
    16101614  $(SOPHYAINCP)srandgen.h
    16111615        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  pihisto2d.cc
     
    16971701  $(SOPHYAINCP)generalfunc.h \
    16981702  $(SOPHYAINCP)histos.h $(SOPHYAINCP)histos2.h \
    1699   $(SOPHYAINCP)hisprof.h $(SOPHYAINCP)histerr.h \
    1700   $(SOPHYAINCP)ntuple.h $(SOPHYAINCP)xntuple.h \
     1703  $(SOPHYAINCP)hisprof.h $(SOPHYAINCP)ntuple.h \
     1704  $(SOPHYAINCP)xntuple.h \
    17011705  $(SOPHYAINCP)basedtable.h \
    1702   $(SOPHYAINCP)segdatablock.h nomgfdadapter.h \
    1703   nomimagadapter.h $(SOPHYAINCP)cimage.h \
    1704   $(SOPHYAINCP)fioarr.h nomtmatvecadapter.h nomtarradapter.h \
     1706  $(SOPHYAINCP)segdatablock.h nomherradapter.h \
     1707  $(SOPHYAINCP)histerr.h \
     1708  $(SOPHYAINCP)hist2err.h nomgfdadapter.h nomimagadapter.h \
     1709  $(SOPHYAINCP)cimage.h $(SOPHYAINCP)fioarr.h \
     1710  nomtmatvecadapter.h nomtarradapter.h \
    17051711  $(SOPHYAINCP)datatable.h \
    17061712  $(SOPHYAINCP)swppfdtable.h \
     
    18171823  $(SOPHYAINCP)tmatrix_tsnl.h \
    18181824  $(SOPHYAINCP)tvector_tsnl.h \
     1825  $(SOPHYAINCP)hist2err.h \
    18191826  $(SOPHYAINCP)generalfit.h \
    18201827  $(SOPHYAINCP)generaldata.h \
     
    20942101  $(SOPHYAINCP)segdatablock.h \
    20952102  $(SOPHYAINCP)piyfxdrw.h \
    2096   $(SOPHYAINCP)pisurfdr.h pintuple.h pintup3d.h pipodrw.h
     2103  $(SOPHYAINCP)pisurfdr.h pintuple.h pintup3d.h pipodrw.h \
     2104  $(SOPHYAINCP)hist2err.h
    20972105        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  servnobjm.cc
    20982106 
  • trunk/SophyaPI/PIext/nomherradapter.cc

    r3139 r3145  
    77
    88#include "nomherradapter.h"
    9 #include "pihisto.h"   /* Wrapper pour HistoErr */
    10 #include "sohiswrap.h"   /* Wrapper pour HistoErr */
     9#include "pihisto.h"   /* Traceur pour Histo1D */
     10#include "pihisto2d.h"   /* Traceur pour Histo2D */
     11#include "sohiswrap.h"   /* Wrapper pour histos (HistoErr Histo2DErr ...) */
    1112
    1213#include "pipodrw.h"
     
    242243PIDrawer* NOMAdapter_Histo2DErr::GetDrawer(string & dopt)
    243244{
    244   /* A_FAIRE_REZA    -> + des options pour choisir val / err2 / nb
    245 dopt = "thinline " + dopt;
    246 return( new PIHisto2DErr(mHerr, false) );
    247   */
    248   return NULL;
     245dopt = "thinline " + dopt; // $CHECK$ CMV : faut-il ajouter thinline
     246return( new PIHisto2D(new Histo2DErrWrapper(mHerr, false), true) );
    249247}
    250248
     
    252250P2DArrayAdapter* NOMAdapter_Histo2DErr::Get2DArray(string & dopt)
    253251{
    254 return ( new POHe2DAdapter(mHerr, false) );
     252// DEL return ( new POHe2DAdapter(mHerr, false) );  -- A SUPPRIMER
     253Histo2DErrWrapper* hwp = new Histo2DErrWrapper(mHerr, false);
     254// $CHECK$ CMV  : pour les options hbincont hbinerr ...
     255// voir NOMAdapter_Histo2D::Get2DArray(string & dopt) ds nomhistadapter.cc
     256 return hwp;
    255257}
    256258
  • trunk/SophyaPI/PIext/nomhistadapter.cc

    r3139 r3145  
    331331PIDrawer* NOMAdapter_Histo2D::GetDrawer(string & dopt)
    332332{
    333 dopt = "thinline " + dopt;
    334 return( new PIHisto2D(mHis, false) );
     333dopt = "thinline " + dopt;  // $CHECK$ CMV : faut-il ajouter thinline
     334return( new PIHisto2D(new Histo2DWrapper(mHis, false), true) );
    335335}
    336336
     
    338338P2DArrayAdapter* NOMAdapter_Histo2D::Get2DArray(string & dopt)
    339339{
    340 return (new POH2DAdapter(mHis, false) );
     340// DEL return (new POH2DAdapter(mHis, false) ); -- A SUPPRIMER
     341Histo2DWrapper* hwp = new Histo2DWrapper(mHis, false);
     342// $CHECK$ CMV  : pour les options hbincont hbinerr ...
     343// On peut decoder les options si on veut, par exemple avec :
     344// vector<string> vopts;
     345// FillVStringFrString(string const & dopt, vector<string>& vopts,char sep = ' ')
     346// hwp->DecodeOptionString(vopts, false);
     347return hwp;
    341348}
    342349
  • trunk/SophyaPI/PIext/phistwrapper.h

    r3135 r3145  
    99#include <string>
    1010#include <vector>
     11#include "parradapter.h"
    1112
    1213
    1314//! Wrapper class interface for 1d-histogram like objects , used by PIHisto
    1415// methodes par defaut dans pihisto.cc
    15 class P1DHistoWrapper
     16class P1DHistoWrapper : public P1DArrayAdapter
    1617{
    1718public:
    18   P1DHistoWrapper();
     19  P1DHistoWrapper(int asz);  // asz: taille du tableau pour P1DArrayAdapter
    1920  virtual ~P1DHistoWrapper();
    2021
     
    2930
    3031  // Renvoie contenu du bin i
    31   virtual r_8 Value(int_4 i) = 0;
     32  virtual r_8 Content(int_4 i) = 0;
    3233  virtual r_8 Error(int_4 i) = 0;
    3334  virtual r_8 NbEntries(int_4 i) = 0;
    3435
    35   inline  r_8 operator()(int_4 i) { return ( Value(i)*mScale+mOff ); }
     36  inline  r_8 operator()(int_4 i)
     37  {
     38    r_8 rv = (mRetFg == 2) ? NbEntries(i) : ( (mRetFg == 1) ? Error(i) : Content(i) ) ;
     39    return ( rv*mScale+mOff );
     40  }
     41
     42  // Implementation de la methode P1DArrayAdapter::Value(int i)
     43  // Identique a l'operateur ()(i)
     44  virtual double Value(int i) { return (*this)(i); }
     45
    3646  // Methode de mise a jour du contenu
    3747  // avec implementation par defaut - ne faisant rien
     
    4555//   l'implementation par defaut ds le fichier pihisto.cc
    4656  virtual int DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
     57//   liste des options sous forme text (ds pihisto.cc )
     58  virtual int OptionToString(vector<string> & opt) const;
    4759
    4860protected:
    49   r_8 mScale, mOff;   // scaling coefficient, offset coefficient
     61  r_8 mScale, mOff;   // scaling coefficient, offset coefficient used in operator ()
     62  short mRetFg;       // operator() : 0 -> bin content , 1 -> bin error , 2 -> bin nentries
     63};
    5064
     65//-----------------------------------------------------------------------------
     66
     67//! Wrapper class interface for 2d-histogram like objects , used by PIHisto2D
     68// methodes par defaut dans pihisto2d.cc
     69class P2DHistoWrapper : public P2DArrayAdapter
     70{
     71public:
     72  P2DHistoWrapper(int_4 asx, int_4 asy); // asx,asy: tailles du tableau pour P2DArrayAdapter
     73  virtual ~P2DHistoWrapper();
     74
     75  virtual int_4 NBinX() = 0;
     76  virtual int_4 NBinY() = 0;
     77  virtual r_8 XMin() = 0;
     78  virtual r_8 XMax() = 0;
     79  virtual r_8 YMin() = 0;
     80  virtual r_8 YMax() = 0;
     81  virtual r_8 WBinX() = 0;
     82  virtual r_8 WBinY() = 0;
     83
     84  virtual void BinLowEdge(int_4 i, int_4 j, r_8& xr, r_8& yr) = 0;
     85  virtual void BinCenter(int_4 i, int_4 j, r_8& xr, r_8& yr) = 0;
     86  virtual void BinHighEdge(int_4 i, int_4 j, r_8& xr, r_8& yr) = 0;
     87
     88  // Renvoie contenu du bin i
     89  virtual r_8 Content(int_4 i, int_4 j) = 0;
     90  virtual r_8 Error(int_4 i, int_4 j) = 0;
     91  virtual r_8 NbEntries(int_4 i, int_4 j) = 0;
     92
     93  inline  r_8 operator()(int_4 i, int_4 j)
     94  {
     95    r_8 rv = (mRetFg == 2) ? NbEntries(i,j) : ( (mRetFg == 1) ? Error(i,j) : Content(i,j) ) ;
     96    return ( rv*mScale+mOff );
     97  }
     98  // Implementation de la methode P2DArrayAdapter::Value(int i, j)
     99  // Identique a l'operateur ()(i)
     100  virtual double Value(int i, int j) { return (*this)(i, j); }
     101
     102  // Methode de mise a jour du contenu
     103  // avec implementation par defaut - ne faisant rien
     104  virtual void Update() { return; }
     105
     106  // ajoute des lignes de texte avec les infos statistiques (dans text)
     107  // renvoie le nombre de lignes ajoutees - avec implementation par defaut
     108  virtual int GetStatInfoAsText(vector<string> &  text );
     109
     110//   Methode de decodage des options - avec implementation par defaut
     111//   l'implementation par defaut ds le fichier pihisto.cc
     112  virtual int DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
     113//   liste des options sous forme text (ds pihisto.cc )
     114  virtual int OptionToString(vector<string> & opt) const;
     115
     116protected:
     117  r_8 mScale, mOff;   // scaling coefficient, offset coefficient used in operator ()
     118  short mRetFg;       // operator() : 0 -> bin content , 1 -> bin error , 2 -> bin nentries
    51119};
    52120
    53121
     122
     123
    54124#endif
  • trunk/SophyaPI/PIext/pihisto.cc

    r3139 r3145  
    1212
    1313//------ Implementation classe P1DHistoWrapper
    14 P1DHistoWrapper::P1DHistoWrapper()
    15 : mScale(1.) , mOff(0.)
     14P1DHistoWrapper::P1DHistoWrapper(int_4 asx)
     15  :  P1DArrayAdapter(asx) ,
     16     mScale(1.) , mOff(0.) , mRetFg(0)
    1617{
    1718}
     
    4445      mOff = atof(opts.substr(8).c_str());
    4546    }
     47    else if(opts.substr(0,8) == "hbincont") {
     48      mRetFg = 0;
     49    }   
     50    else if(opts.substr(0,8) == "hbinerr") {
     51      mRetFg = 1;
     52    }   
     53    else if(opts.substr(0,8) == "hbinent") {
     54      mRetFg = 2;
     55    }   
    4656    else {
    4757      ndec--;
     
    5464  if (rmdecopt)  opt = udopt;
    5565  return(ndec);
     66}
     67
     68int
     69P1DHistoWrapper::OptionToString(vector<string> & opt) const
     70{
     71  char buff[64];
     72  sprintf(buff, "hscale=%g", mScale);  opt.push_back(buff);
     73  sprintf(buff, "hoffset=%g", mOff);  opt.push_back(buff);
     74  if (mRetFg == 2) opt.push_back("hbinent");
     75  else if (mRetFg == 1) opt.push_back("hbinerr");
     76  else opt.push_back("hbincont");
     77
     78  return 1;
    5679}
    5780
     
    7598//      Constructeur. Si "ad == true", l'objet "histowp" est détruit par
    7699//      le destructeur de l'objet "PIHisto"
    77 //      Note : "histowp" doit être créé par new
     100//      Note : "histowp" doit être créé par new si ad==true
    78101//
    79102//--
     
    85108  mAdDO = ad;     // Flag pour suppression automatique de mHistoWp
    86109  stats=true;
    87   // todraw = 0 draw scaled and offset value (default)
    88   //        = 1 draw bin content
    89   //        = 2 draw bin error (if exist)
    90   //        = 3 draw number of entries in the bin (if exist)
    91   todraw=0;
    92   // error = -1 pas de barre d'erreur
    93   //          1 barres d'erreurs,
    94   //          0 barres d'erreurs automatiques (si markeur demande)
    95   error=0;
     110  pline=true;
     111  error=false;
    96112  filled=false;
    97113  spoX=-0.01; spoY=-0.01;
     
    108124{
    109125  if (!mHistoWp)  return;
     126  if ( mHistoWp->NBins() < 1 ) {
     127    SetLimits(mHistoWp->XMin(), mHistoWp->XMax(), 0., 1.);
     128  }
    110129  double v,hmin,hmax;
    111   hmin = 9.e39;
    112   hmax = -9.e39;
    113   for (int i=1; i<mHistoWp->NBins(); i++) {
    114     v = DrawVal(i);
     130  hmin = hmax = (*mHistoWp)(0);
     131  for (int_4 i=1; i<mHistoWp->NBins(); i++) {
     132    v = (*mHistoWp)(i);
    115133    if(v<hmin) hmin = v;
    116134    if(v>hmax) hmax = v;
    117135  }
    118   // REZA$CHECK : Modifier pour tenir compte si axe (Y) en log
    119   v = 0.1*(hmax-hmin);
    120   hmin -= v;   hmax += v;
    121 
     136  if ( isLogScaleY() ) {
     137    if ( hmin >= 0.) {
     138      if ( hmax <= hmin ) {
     139        hmax = hmin*10.;
     140        if (hmax <= 0.) hmax = 1.;
     141        if (hmin <= 0.) hmin = hmax / 100.;
     142      }
     143      else if ( (hmin == 0.) && (hmax > hmin) ) hmin = hmax/1.e6;
     144      else hmin /= 1.1;
     145    }
     146    else if (hmax > 0.) hmax *= 1.1;
     147  }
     148  else {
     149      v = 0.05*(hmax-hmin);
     150      hmin -= v;   hmax += v;
     151  }
    122152  if(hmax<=hmin) hmax = hmin+1.;
     153   
    123154  SetLimits(mHistoWp->XMin(), mHistoWp->XMax(), hmin, hmax);
    124155}
     
    134165  mHistoWp->Update();
    135166
    136   bool oktrace=false;
    137167  // Tracer d'une polyline si demandee
    138168  bool drawpline=false;
    139   if(GetGraphicAtt().GetLineAtt() != PI_NotDefLineAtt) drawpline=true;
     169  if (pline) drawpline=true;
    140170  // Tracer des marqueurs si demande ou si HProf
    141171  bool drawmarker=false;
     
    143173  // Tracer des erreurs ?
    144174  bool drawerr=false;
    145   if(error==0) {  // Gestion automatique des erreurs
    146     // Trace les erreurs si marqueurs demandes
    147     if(drawmarker) drawerr=true;
    148   }
    149   else if(error>0) drawerr=true;
    150   else if(error<0) drawerr=false;
     175  if (error) drawerr = true;
    151176  // Fill de l'histo ?
    152177  bool drawfill=false;
    153178  if(filled) drawfill=true; else drawfill=false;
    154   // Et aussi si on ne demande ni ligne ni marqueur ?
    155   if( !drawmarker && !drawpline && !drawerr ) drawfill=true;
     179  // Et aussi si on ne demande ni ligne ni marqueur ni erreur ni fill ?
     180  if( !drawmarker && !drawfill && !drawerr ) drawpline=true;
    156181
    157182  // Remplissage des bins avec la couleur courante (trace en premier)
    158183  if(drawfill) {
    159     oktrace = true;
    160184    for(int i=0; i<mHistoWp->NBins(); i++) {
    161185      double left   = mHistoWp->BinLowEdge(i);
    162186      double width  = mHistoWp->BinWidth();
    163187      double bottom = 0;
    164       double height = DrawVal(i);
     188      double height = (*mHistoWp)(i);
    165189      g->DrawFBox(left,bottom,width,height);
    166190    }
     
    169193  // Trace des marqeurs
    170194  if(drawmarker) {
    171     double x1,y1; oktrace = true;
     195    double x1,y1;
    172196    for(int i=0; i<mHistoWp->NBins(); i++) {
    173197      x1 = mHistoWp->BinCenter(i);
    174       y1 = DrawVal(i);
     198      y1 = (*mHistoWp)(i);
    175199      g->DrawMarker(x1,y1);
    176200    }
     
    180204  if(drawerr) {
    181205    if(GetGraphicAtt().GetLineAtt()==PI_NotDefLineAtt) g->SelLine(PI_ThinLine);
    182     double x1,x2,y1,y2;  oktrace = true;
     206    double x1,x2,y1,y2; 
    183207    double bw = mHistoWp->BinWidth();
    184208    for(int i=0; i<mHistoWp->NBins(); i++) {
     
    186210        // barres d'erreur verticales
    187211        x1 = x2 = mHistoWp->BinCenter(i);
    188         y1 = DrawVal(i) - mHistoWp->Error(i);
    189         y2 = DrawVal(i) + mHistoWp->Error(i);
     212        y1 = (*mHistoWp)(i) - mHistoWp->Error(i);
     213        y2 = (*mHistoWp)(i) + mHistoWp->Error(i);
    190214        g->DrawLine(x1,y1, x1, y2);
    191215        // limites de barres d'erreurs (horizontales)
     
    199223  // Trace de la ligne continue si demandee
    200224  if(drawpline) {
     225    if(GetGraphicAtt().GetLineAtt()==PI_NotDefLineAtt) g->SelLine(PI_ThinLine);
    201226    PIGrCoord* x1 = new PIGrCoord[2*mHistoWp->NBins()+2];
    202227    PIGrCoord* y1 = new PIGrCoord[2*mHistoWp->NBins()+2];
     
    208233    for(int i=0; i<mHistoWp->NBins(); i++) {
    209234      x1[npt] = mHistoWp->BinLowEdge(i);
    210       y1[npt] = DrawVal(i);
     235      y1[npt] = (*mHistoWp)(i);
    211236      npt++;
    212237      x1[npt] = (double)x1[npt-1] + dx;
     
    219244    g->DrawPolygon(x1,y1,npt,false);
    220245    delete [] x1; delete [] y1;
    221     oktrace = true;
    222246  }
    223247
     
    243267    else if(  opts=="nsta"   || opts=="nstat"
    244268           || opts=="nostat" || opts=="nostats") stats=false;
    245     else if(opts=="err") error=1;
    246     else if(opts=="noerr" || opts=="nerr") error=-1;
    247     else if(opts=="autoerr") error=0;
    248     else if(opts=="fill") filled=true;
     269    else if(opts=="err") error=true;
     270    else if(opts=="noerr" || opts=="nerr") error=false;
     271    // $CHECK$CMV  : on desactive pline si fill ?
     272    else if(opts=="fill") { filled=true; pline=false; } 
    249273    else if(opts=="nofill" || opts=="nfill") filled=false;
     274    // $CHECK$CMV  : on desactive fill si pline ?
     275    else if(opts=="pline") { pline=true; filled=false; }
     276    else if(opts=="nopline") pline=false;
    250277    else if(opts.substr(0,11) == "statposoff=") {
    251278      float xo=0., yo=0.;
     
    253280      spoX=xo; spoY=yo;
    254281    }
    255     else if(opts.substr(0,6) == "draw=v") todraw = 1;
    256     else if(opts.substr(0,6) == "draw=e") todraw = 2;
    257     else if(opts.substr(0,6) == "draw=n") todraw = 3;
    258     else if(opts.substr(0,5) == "draw=" ) todraw = 0;
    259282    else {
    260283      ndec--;
     
    281304 PIDrawer::OptionToString(opt);
    282305
    283  if(stats) opt.push_back("stat"); else opt.push_back("nstat");
    284  if(error==-1) opt.push_back("noerr");
    285    else if(error==0) opt.push_back("autoerr");
    286      else if(error==1) opt.push_back("err");
     306 if(stats) opt.push_back("stat"); else opt.push_back("nostat");
     307 if(error) opt.push_back("err");  else opt.push_back("noerr");
    287308 if(filled) opt.push_back("fill"); else opt.push_back("nofill");
    288  if(todraw==1) opt.push_back("draw=v");
    289    else if(todraw==2) opt.push_back("draw=e");
    290      else if(todraw==3) opt.push_back("draw=n");
     309 if(pline) opt.push_back("pline"); else opt.push_back("nopline");
    291310
    292311 char str[256]; sprintf(str,"statposoff=%g,%g",spoX,spoY);
    293312 opt.push_back(str);
    294313
     314 mHistoWp->OptionToString(opt);
    295315 return 1;
    296316}
     
    300320{
    301321info += " ---- PIHisto options help info : \n" ;
    302 info += "  draw=v: draw bin content\n";
    303 info += "      =e: draw bin error (if exist)\n";
    304 info += "      =n: draw number of entries in the bin (if exist)\n";
    305 info += "      default: draw scaled and offset value (default)\n";
    306 info += "  sta,stat,stats:            activate   statistic display\n";
    307 info += "  nsta,nstat,nostat,nostats: deactivate statistic display\n";
    308 info += "  err / noerr,nerr : draw, do not draw error bars\n";
    309 info += "  autoerr : draw error bars if Marker drawing requested\n";
    310 info += "  fill / nofill,nfill : fill, do not fill bars with selected color\n";
    311 info += "  statposoff=OffsetX,OffsetY : Position offset for Stats drawing \n";
    312 info += "       as a fraction of total size \n";
     322info += " sta,stat,stats:            activate   statistic display\n";
     323info += " nsta,nstat,nostat,nostats: deactivate statistic display\n";
     324info += " pline/nopline: display/do not display as polyline (def= pline) \n";
     325info += " err/noerr,nerr: draw/do not draw error bars (def= noerr) \n";
     326info += " fill/nofill,nfill: fill/do not fill histo (def= nofill) \n";
     327info += " - Use marker attribute (marker=...) to draw markers \n";
     328info += " statposoff=OffsetX,OffsetY : Position offset for Stats drawing \n";
     329info += "      as a fraction of total size \n";
    313330info += " ---- HistoWrapper options : \n" ;
    314 info += "  hscale=value  : multiplicative factor (in Y) \n" ;
    315 info += "  hoffset=value : additive coefficient  (in Y) \n" ;
    316 info += "  hs1 : set hscale=1 hoffset=0  (default) \n" ;
     331info += " hbincont: select bin content as Y value for display (default) \n";
     332info += " hbinerr: select bin error as Y value for display \n";
     333info += " hbinent: select bin entries as Y value for display \n";
     334info += " hscale=value : multiplicative factor for Y value \n" ;
     335info += " hoffset=value : additive coefficient for Y value \n" ;
     336info += " hs1: set hscale=1 hoffset=0  (default) \n" ;
    317337// On recupere ensuite la chaine info de la classe de base
    318338PIDrawer::GetOptionsHelpInfo(info);
     
    335355  if (nlig < 1) return;
    336356
    337   double cellHeight = (nlig+0.6) * cH;
     357  double cellHeight = nlig*1.2 * cH;
    338358
    339359  int idxll = 0;
     
    383403 for(int i=0; i<mHistoWp->NBins(); i++) {
    384404   double xp=mHistoWp->BinCenter(i);
    385    double yp=DrawVal(i);
     405   double yp=(*mHistoWp)(i);
    386406   xp = (xp-x)/(XMax()-XMin())/0.5;
    387407   yp = (yp-y)/(YMax()-YMin())/0.5;
  • trunk/SophyaPI/PIext/pihisto.h

    r3135 r3145  
    2020  inline  P1DHistoWrapper*     HistoWrapper() {return(mHistoWp);}
    2121
    22 //   ce qu'on plot
    23   double DrawVal(int_4 i) {
    24     if(todraw==1) return mHistoWp->Value(i);
    25     if(todraw==2) return mHistoWp->Error(i);
    26     if(todraw==3) return mHistoWp->NbEntries(i);
    27     return (*mHistoWp)(i);
    28   }
    29 
    3022//   Methode de decodage des options
    3123  virtual int        DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
     
    4032  P1DHistoWrapper*   mHistoWp;
    4133  bool mAdDO;
    42   bool stats,filled;
    43   short error,todraw;
    44   float spoX, spoY; // Stat pos offset par rapport a position defaut
     34  bool stats;        // if true: draw text with statistical information
     35  bool filled;       // if true: fill histo with fg color
     36  bool pline;        // if true: draw histogram as polyline
     37  bool error;        // if true: draw error bars
     38  float spoX, spoY;  // Stat pos offset par rapport a position defaut
    4539};
    4640
  • trunk/SophyaPI/PIext/pihisto2d.cc

    r3075 r3145  
    33#include <pisysdep.h>
    44#include PIAPP_H
     5
     6#include <iostream>
     7#include <math.h>
     8
    59#include "sopnamsp.h"
    610#include "pihisto2d.h"
     
    913static int dbg = 0;
    1014
     15
     16//------ Implementation classe P2DHistoWrapper
     17P2DHistoWrapper::P2DHistoWrapper(int_4 asx, int_4 asy)
     18  :  P2DArrayAdapter(asx, asy) ,
     19     mScale(1.) , mOff(0.) , mRetFg(0)
     20{
     21}
     22
     23P2DHistoWrapper::~P2DHistoWrapper()
     24{
     25}
     26
     27int P2DHistoWrapper::GetStatInfoAsText(vector<string> & /* text */ )
     28{
     29  return 0;
     30}
     31
     32int P2DHistoWrapper::DecodeOptionString(vector<string> & opt, bool rmdecopt)
     33{
     34  if(opt.size() < 1) return(0);
     35
     36  vector<string> udopt;  // On gardera ici les options non decodees
     37  unsigned int k = 0;
     38  int ndec = opt.size();
     39  for( k=0; k<opt.size(); k++ ) {
     40    string & opts = opt[k];
     41    if(opts.substr(0,7) == "hs1") {
     42      mScale = 1.;  mOff = 0.;
     43    }
     44    else if(opts.substr(0,7) == "hscale=") {
     45      mScale = atof(opts.substr(7).c_str());
     46    }
     47    else if(opts.substr(0,8) == "hoffset=") {
     48      mOff = atof(opts.substr(8).c_str());
     49    }
     50    else if(opts.substr(0,8) == "hbincont") {
     51      mRetFg = 0;
     52    }   
     53    else if(opts.substr(0,8) == "hbinerr") {
     54      mRetFg = 1;
     55    }   
     56    else if(opts.substr(0,8) == "hbinent") {
     57      mRetFg = 2;
     58    }   
     59    else {
     60      ndec--;
     61      // S'il faut supprimer les options decodees
     62      if (rmdecopt)  udopt.push_back(opts);
     63    }
     64  }
     65  // S'il faut supprimer les options decodees, on remplace l'argument opt
     66  // par le vecteur des options non decodees.
     67  if (rmdecopt)  opt = udopt;
     68  return(ndec);
     69}
     70
     71int
     72P2DHistoWrapper::OptionToString(vector<string> & opt) const
     73{
     74  char buff[64];
     75  sprintf(buff, "hscale=%g", mScale);  opt.push_back(buff);
     76  sprintf(buff, "hoffset=%g", mOff);  opt.push_back(buff);
     77  if (mRetFg == 2) opt.push_back("hbinent");
     78  else if (mRetFg == 1) opt.push_back("hbinerr");
     79  else opt.push_back("hbincont");
     80
     81  return 1;
     82}
     83
    1184//++
    1285// Class        PIHisto2D
     
    28101
    29102//++
    30 PIHisto2D::PIHisto2D(Histo2D* histo, bool ad)
     103PIHisto2D::PIHisto2D(P2DHistoWrapper* histowp, bool ad)
    31104//
    32105//      Createur d'une classe de dessin pour l'histogramme 2D histo.
    33106//--
    34 : PIDrawer(), mHisto(histo), mAdDO(ad), mLogScale(10.), mFPoints(0.5)
    35 {
    36 // mAdDO : Flag pour suppression automatique de mHisto
     107: PIDrawer(), mHistoWp(histowp), mAdDO(ad), mLogScale(10.), mFPoints(0.5)
     108{
     109// mAdDO : Flag pour suppression automatique de mHistoWp
    37110// Attention: mFPoints n'est initialise que si on display par nuages de points
    38111//            mLogScale n'est initialise que si on utilise une echelle log
     
    43116UseFrac();
    44117SetStats();
    45  SetStatPosOffset();
     118SetStatPosOffset();
    46119SetName("Histo2DDrw");
    47120// PIHisto2D has specific control tools
     
    62135// ---> parametre d'appel PIBaseWdgGen* wdg=NULL
    63136DeactivateControlWindow(NULL);
    64 if(mAdDO && mHisto!=NULL) delete mHisto;
     137if(mAdDO && mHistoWp!=NULL) delete mHistoWp;
    65138}
    66139
     
    139212
    140213//++
    141 void PIHisto2D::UseDyn(float hmin,float hmax)
     214void PIHisto2D::UseDyn(float fmin,float fmax)
    142215//
    143216//      Gestion de la dynamique a representer:
     
    151224//--
    152225{
    153 if(mHisto)
    154   if(hmin>=hmax) {hmin = mHisto->VMin(); hmax = mHisto->VMax();}
    155 if(hmin>=hmax) hmax = hmin+1.;
    156 mHMin = hmin; mHMax = hmax;
     226  if( (mHistoWp) && (mHistoWp->NBinX()>0) && (mHistoWp->NBinY()>0) && (fmin>=fmax) ) {
     227    double v,hmin,hmax;
     228    hmin = hmax = (*mHistoWp)(0,0);
     229    for (int_4 i=0; i<mHistoWp->NBinX(); i++)
     230      for (int_4 j=0; j<mHistoWp->NBinY(); j++) {
     231        v = (*mHistoWp)(i, j);
     232        if(v<hmin) hmin = v;
     233        if(v>hmax) hmax = v;
     234      }
     235    fmin = hmin;  fmax = hmax;   // $CHECK$ CMV : attention, double vers float !!
     236  }
     237
     238// $CHECK$ CMV : Ne faut-il pas passer les attributs de la classe en double ??
     239if(fmin>=fmax) fmax = fmin+1.;
     240mHMin = fmin; mHMax = fmax;
    157241}
    158242
     
    189273      ,(int)mFgCol,(int)mCmap,(int)mRevCmap,mTypScal,mTypDisp,mFPoints);
    190274printf("                 Dyn=%g,%g Frac=%g,%g LogSc=%g H=%p\n"
    191       ,mHMin,mHMax,mFracMin,mFracMax,mLogScale,mHisto);
    192 if(lp>=1) mHisto->PrintStatus();
     275      ,mHMin,mHMax,mFracMin,mFracMax,mLogScale,mHistoWp);
     276// if(lp>=1) mHistoWp->PrintStatus();  $CHECK$ CMV : que faut-il faire ?
    193277fflush(stdout);
    194278}
     
    201285//--
    202286{
    203  if(!mHisto) return;
    204  SetLimits(mHisto->XMin(), mHisto->XMax(), mHisto->YMin() , mHisto->YMax());
     287 if(!mHistoWp) return;
     288 SetLimits(mHistoWp->XMin(), mHistoWp->XMax(), mHistoWp->YMin() , mHistoWp->YMax());
    205289}
    206290
     
    259343if (axesFlags != kAxesNone) DrawAxes(g);
    260344
    261 if(!mHisto) return;
    262 if(mHisto->NBinX()<=0 || mHisto->NBinY()<=0) return;
     345if(!mHistoWp) return;
     346if(mHistoWp->NBinX()<=0 || mHistoWp->NBinY()<=0) return;
    263347
    264348// Caracteristiques histogramme
    265 double dx = mHisto->WBinX(),dy = mHisto->WBinY();
     349double dx = mHistoWp->WBinX(),dy = mHistoWp->WBinY();
    266350double p1dx,p1dy;
    267351g->DGrC2UC(1.,1.,p1dx,p1dy);
     
    309393
    310394// Plot de l'histogramme
    311 for(int i=0; i<mHisto->NBinX(); i++)
    312   for(int j=0; j<mHisto->NBinY(); j++) {
     395for(int i=0; i<mHistoWp->NBinX(); i++)
     396  for(int j=0; j<mHistoWp->NBinY(); j++) {
    313397
    314398  r_8 left0,bottom0;
    315   mHisto->BinLowEdge(i,j,left0,bottom0);
     399  mHistoWp->BinLowEdge(i,j,left0,bottom0);
    316400
    317401  // Gestion de la dynamique a dessiner
    318   float frac = ((*mHisto)(i,j)-HMin())/(HMax()-HMin());
     402  float frac = ((*mHistoWp)(i,j)-HMin())/(HMax()-HMin());
    319403  if(frac<0.) continue;
    320404  if(mTypScal==1) {              // echelle log10
     
    385469//--
    386470{
    387 Histo2D* h = Histogram();
     471P2DHistoWrapper* h = HistoWrapper();
    388472if(h == NULL) return;
    389473
    390 int i,j;
    391 h->FindBin(x,y,i,j);
     474int_4 i,j;
     475i = floor((x-h->XMin())/h->WBinX());
     476j = floor((y-h->YMin())/h->WBinY());
     477
    392478if(i>=0 && i<h->NBinX() && j>=0 && j<h->NBinY()) {
    393479  char str[64];
    394480  if(fgdiff) {
    395481    int i0,j0;
    396     h->FindBin(x0,y0,i0,j0);
     482    i0 = floor((x0-h->XMin())/h->WBinX());
     483    j0 = floor((y0-h->YMin())/h->WBinY());
    397484    if(i0>=0 && i0<h->NBinX() && j0>=0 && j0<h->NBinY()) {
    398485      sprintf(str," DV=%g",(*h)(i,j)-(*h)(i0,j0));
     
    417504//--
    418505{
    419   if (!mHisto) return;
     506  if (!mHistoWp) return;
    420507  if (GetGraphicAtt().GetLineAtt() == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
    421508  g->SelFontSz((YMax() - YMin())/30);
     
    424511  PIGrCoord a, d;
    425512  double cH = (double)g->GetFontHeight(a,d);
    426   double cellHeight = 1.2 * cH;
    427 
    428   // Les labels et leurs longueurs -> largeur de la cellule
    429   char label[64];
    430   sprintf(label,"N= %-g", mHisto->NData());
    431   double cellWidth =  1.1 * (double)g->CalcStringWidth(label);
     513  vector<string> lines;
     514  int nlig = mHistoWp->GetStatInfoAsText(lines);
     515  if (nlig < 1) return;
     516
     517  double cellHeight = nlig*1.2 * cH;
     518
     519  int idxll = 0;
     520 
     521  int kl;
     522  // on recherche la ligne la plus longue
     523  for(kl=1; kl<nlig; kl++)
     524    if ( lines[kl].length() > lines[idxll].length() )  idxll = kl;
     525
     526  double cellWidth =  1.1 * (double)g->CalcStringWidth(lines[idxll].c_str());
     527
    432528
    433529  double ofpx = spoX*(XMax()-XMin());
     
    446542  cw = (g->isAxeXDirRtoL()) ? -0.05*cellWidth : -0.95*cellWidth;
    447543  xu = g->DeltaUCX(XMax(),cw);
    448   cw = (g->isAxeYDirUpDown()) ? -0.1*cH : -1.1*cH;
     544
     545  cw = (g->isAxeYDirUpDown()) ? -0.15*cH : -1.15*cH;
    449546  yu = g->DeltaUCY(YMax(),cw);
    450547  xu += ofpx;  yu += ofpy;
    451   g->DrawString(xu,yu,label);
     548
     549  for(kl=0; kl<nlig; kl++) {
     550    g->DrawString(xu, yu, lines[kl].c_str() );
     551    cw +=  -1.15*cH;
     552    yu = g->DeltaUCY(YMax(),cw);  yu += ofpy;
     553  }
     554
    452555
    453556  //  printf("H[%d,%d] Dynamique: [%g,%g] Frac [%g,%g]\n"
    454   //        ,mHisto->NBinX(),mHisto->NBinY(),HMin(),HMax(),FMin(),FMax());
     557  //        ,mHistoWp->NBinX(),mHistoWp->NBinY(),HMin(),HMax(),FMin(),FMax());
    455558}
    456559
     
    489592//--
    490593{
    491 double dx = mHisto->WBinX(),dy = mHisto->WBinY();
     594double dx = mHistoWp->WBinX(),dy = mHistoWp->WBinY();
    492595double dxg,dyg;
    493596g->DUC2GrC(dx,dy,dxg,dyg);
     
    573676  if (rmdecopt)  opt = udopt;
    574677
     678  // Decodage des options par le histo-wrapper
     679  int ndec2 = 0;
     680  if ( ( optsz1-ndec1-ndec > 0) && (mHistoWp) ) {
     681    ndec2 = mHistoWp->DecodeOptionString(opt, rmdecopt);
     682  }
     683
    575684  // Liste des options si demande
    576685  if(listopt) Print();
    577686
    578   return(ndec+ndec1);
     687  return(ndec+ndec1+ndec2);
    579688}
    580689
     
    607716 if(mRevCmap) opt.push_back("revcmap");
    608717
     718 // Les options du Histo2DWrapper :
     719 mHistoWp->OptionToString(opt);
    609720 return 1;
    610721}
     
    630741info += "- h2scale=lin/log[,logscale]: choose linear or logarithmic scale\n";
    631742info += "- h2dyn=[hmin][,hmax]: choose histogramme range for display\n";
    632 info += "- use general key to define color table (ex: grey32,midas_heat,...)\n";
     743info += "- use graphic att. to define color table (ex: grey32,midas_heat,...)\n";
    633744info += "            (see general graphicatt description)\n";
    634 info += "- use key \"revcmap\" to reverse color table\n";
     745info += "- use \"revcmap\" to reverse color table\n";
    635746info += "- h2frac=[fmin][,fmax]: choose sub-range display [0,1]\n";
     747info += " ---- HistoWrapper options : \n" ;
     748info += " hbincont: select bin content as Y value for display (default) \n";
     749info += " hbinerr: select bin error as Y value for display \n";
     750info += " hbinent: select bin entries as Y value for display \n";
     751info += " hscale=value : multiplicative factor for Y value \n" ;
     752info += " hoffset=value : additive coefficient for Y value \n" ;
     753info += " hs1: set hscale=1 hoffset=0  (default) \n" ;
    636754// On recupere ensuite la chaine info de la classe de base
    637755PIDrawer::GetOptionsHelpInfo(info);
  • trunk/SophyaPI/PIext/pihisto2d.h

    r2523 r3145  
    1212#include PIOPTMENU_H
    1313
    14 #include "histos2.h"
    1514#include "pidrawer.h"
    1615#include "piscdrawwdg.h"
     16
     17#include "phistwrapper.h"
    1718
    1819////////////////////////////////////////////////////////////////////
    1920class PIHisto2D : public PIDrawer {
    2021public:
    21   PIHisto2D(Histo2D* histo, bool ad=false);
     22  PIHisto2D(P2DHistoWrapper* h2wp, bool ad=false);
    2223  virtual ~PIHisto2D();
    2324
     
    5657
    5758  // Methodes inline
    58   inline Histo2D*       Histogram()   {return(mHisto);}
     59  inline P2DHistoWrapper*       HistoWrapper()   {return(mHistoWp);}
    5960  inline bool           Color()       {return(mFgCol);}
    6061  inline CMapId         ColMap()      {return(mCmap);}
     
    7374  char HPrint2(float f);
    7475
    75   Histo2D* mHisto;
     76  P2DHistoWrapper* mHistoWp;
    7677  bool mAdDO; bool stats;
    7778  bool mFgCol; CMapId mCmap; bool mRevCmap;
  • trunk/SophyaPI/PIext/pipodrw.cc

    r3139 r3145  
    5656
    5757
    58 // ----------------------------------------------------------
    59 // Adaptateur d'Histo-2D a P2DArrayAdapter
    60 // ----------------------------------------------------------
    61 
    62 /* --Methode-- */
    63 POH2DAdapter::POH2DAdapter(Histo2D* h2d, bool ad)
    64         : P2DArrayAdapter(h2d->NBinX(), h2d->NBinY())
    65 {
    66 aDel = ad; mH2d = h2d;
    67 DefineXYCoordinates(h2d->XMin(), h2d->YMin(), h2d->WBinX(), h2d->WBinY() );
    68 }
    69 
    70 /* --Methode-- */
    71 POH2DAdapter::~POH2DAdapter()
    72 {
    73 if (aDel)  delete mH2d;
    74 }
    75 
    76 /* --Methode-- */
    77 double POH2DAdapter::Value(int ix, int iy)
    78 {
    79 return((*mH2d)(ix, iy));
    80 }
    81 
    82 // ----------------------------------------------------------
    83 // Adaptateur d'Histo2DErr a P2DArrayAdapter
    84 // ----------------------------------------------------------
    85 
    86 /* --Methode-- */
    87 POHe2DAdapter::POHe2DAdapter(Histo2DErr* he2d, bool ad)
    88         : P2DArrayAdapter(he2d->NBinX(), he2d->NBinY())
    89 {
    90 aDel = ad; mHe2d = he2d;
    91 DefineXYCoordinates(he2d->XMin(), he2d->YMin(), he2d->WBinX(), he2d->WBinY() );
    92 }
    93 
    94 /* --Methode-- */
    95 POHe2DAdapter::~POHe2DAdapter()
    96 {
    97 if (aDel)  delete mHe2d;
    98 }
    99 
    100 /* --Methode-- */
    101 double POHe2DAdapter::Value(int ix, int iy)
    102 {
    103 return((*mHe2d)(ix, iy));
    104 }
    105 
    106 
    10758#ifdef SANS_EVOLPLANCK
    10859
     
    12980return((*mVec)(i));
    13081}
     82
     83------- FIN SUPPRESSION */
    13184
    13285// ----------------------------------------------------------
  • trunk/SophyaPI/PIext/pipodrw.h

    r3139 r3145  
    3434
    3535
    36 // Adaptateur d'Histo-2D a P2DArrayAdapter
    37 class POH2DAdapter :  public P2DArrayAdapter {
    38 public :
    39                   POH2DAdapter(Histo2D* h2d, bool ad=false);
    40   virtual         ~POH2DAdapter();
    41 
    42   virtual double  Value(int ix, int iy);   
    43 
    44 protected:
    45   bool aDel;
    46   Histo2D* mH2d;
    47 };
    48 
    49 // Adaptateur d'Histo2DErr a P2DArrayAdapter
    50 class POHe2DAdapter :  public P2DArrayAdapter {
    51 public :
    52                   POHe2DAdapter(Histo2DErr* he2d, bool ad=false);
    53   virtual         ~POHe2DAdapter();
    54 
    55   virtual double  Value(int ix, int iy);   
    56 
    57 protected:
    58   bool aDel;
    59   Histo2DErr* mHe2d;
    60 };
    61 
    6236#ifdef SANS_EVOLPLANCK
    6337#include "cvector.h"
  • trunk/SophyaPI/PIext/smakefile

    r3133 r3145  
    597597  $(SOPHYAINCP)pisurfdr.h pipodrw.h \
    598598  $(SOPHYAINCP)histos2.h $(SOPHYAINCP)histos.h \
    599   pintuple.h pintup3d.h pigfd1.h pigfd2.h
     599  $(SOPHYAINCP)hist2err.h pintuple.h pintup3d.h pigfd1.h \
     600  pigfd2.h
    600601        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  nobjmgr.cc
    601602 
     
    691692  $(SOPHYAINCP)generalfunc.h pipodrw.h \
    692693  $(SOPHYAINCP)histos2.h $(SOPHYAINCP)histos.h \
     694  $(SOPHYAINCP)hist2err.h \
    693695  $(SOPHYAINCP)objfitter.h \
    694696  $(SOPHYAINCP)cimage.h $(SOPHYAINCP)fioarr.h \
     
    741743  $(SOPHYAINCP)generalfunc.h \
    742744  $(SOPHYAINCP)histerr.h \
    743   $(SOPHYAINCP)hist2err.h servnobjm.h nobjmgr.h dlftypes.h \
    744   $(SOPHYAINCP)pdlmgr.h $(SOPHYAINCP)zthread.h \
    745   pihisto.h phistwrapper.h sohiswrap.h $(SOPHYAINCP)histos.h \
    746   $(SOPHYAINCP)hisprof.h \
     745  $(SOPHYAINCP)hist2err.h pihisto.h phistwrapper.h \
     746  pihisto2d.h $(SOPHYAINCP)pimenux.h \
     747  $(SOPHYAINCP)pimenugen.h \
     748  $(SOPHYAINCP)pimenubarx.h \
     749  $(SOPHYAINCP)pimenubargen.h \
     750  $(SOPHYAINCP)pioptmenux.h \
     751  $(SOPHYAINCP)pioptmenugen.h \
     752  $(SOPHYAINCP)pistdwdgx.h \
     753  $(SOPHYAINCP)pistdwdggen.h \
     754  $(SOPHYAINCP)piscdrawwdg.h \
     755  $(SOPHYAINCP)pibwdgx.h \
     756  $(SOPHYAINCP)pigraphps.h \
     757  $(SOPHYAINCP)piwindowx.h \
     758  $(SOPHYAINCP)piwindowgen.h \
     759  $(SOPHYAINCP)picontainerx.h \
     760  $(SOPHYAINCP)picontainergen.h \
     761  $(SOPHYAINCP)pieldrw.h sohiswrap.h \
     762  $(SOPHYAINCP)histos.h $(SOPHYAINCP)hisprof.h \
     763  $(SOPHYAINCP)histos2.h pipodrw.h servnobjm.h nobjmgr.h \
     764  dlftypes.h $(SOPHYAINCP)pdlmgr.h \
     765  $(SOPHYAINCP)zthread.h \
    747766  $(SOPHYAINCP)objfitter.h \
    748   $(SOPHYAINCP)cimage.h $(SOPHYAINCP)fioarr.h \
    749   $(SOPHYAINCP)histos2.h
     767  $(SOPHYAINCP)cimage.h $(SOPHYAINCP)fioarr.h
    750768        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  nomherradapter.cc
    751769 
     
    795813  $(SOPHYAINCP)generalfunc.h \
    796814  $(SOPHYAINCP)histos.h $(SOPHYAINCP)histos2.h \
    797   $(SOPHYAINCP)hisprof.h $(SOPHYAINCP)histerr.h \
    798   $(SOPHYAINCP)ntuple.h $(SOPHYAINCP)xntuple.h \
     815  $(SOPHYAINCP)hisprof.h $(SOPHYAINCP)ntuple.h \
     816  $(SOPHYAINCP)xntuple.h \
    799817  $(SOPHYAINCP)basedtable.h \
    800818  $(SOPHYAINCP)segdatablock.h pihisto.h phistwrapper.h \
    801   sohiswrap.h pihisto2d.h $(SOPHYAINCP)pimenux.h \
     819  sohiswrap.h $(SOPHYAINCP)histerr.h \
     820  $(SOPHYAINCP)hist2err.h pihisto2d.h \
     821  $(SOPHYAINCP)pimenux.h \
    802822  $(SOPHYAINCP)pimenugen.h \
    803823  $(SOPHYAINCP)pimenubarx.h \
     
    14361456  $(SOPHYAINCP)pitherm.h \
    14371457  $(SOPHYAINCP)resusage.h nomhistadapter.h \
    1438   $(SOPHYAINCP)histerr.h $(SOPHYAINCP)xntuple.h \
     1458  $(SOPHYAINCP)xntuple.h \
    14391459  $(SOPHYAINCP)basedtable.h \
    14401460  $(SOPHYAINCP)segdatablock.h nomgfdadapter.h \
     
    15471567  $(SOPHYAINCP)pievthandler.h \
    15481568  $(SOPHYAINCP)psfile.h $(SOPHYAINCP)pigratt.h \
    1549   $(SOPHYAINCP)piaxes.h phistwrapper.h
     1569  $(SOPHYAINCP)piaxes.h phistwrapper.h \
     1570  $(SOPHYAINCP)parradapter.h $(SOPHYAINCP)lut.h
    15501571        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  pihisto.cc
    15511572 
     
    15841605  $(SOPHYAINCP)pioptmenux.h \
    15851606  $(SOPHYAINCP)pioptmenugen.h \
    1586   $(SOPHYAINCP)histos2.h $(SOPHYAINCP)peida.h \
    1587   $(SOPHYAINCP)utils.h $(SOPHYAINCP)perrors.h \
    1588   $(SOPHYAINCP)pexceptions.h \
    1589   $(SOPHYAINCP)fmath.h $(SOPHYAINCP)histos.h \
    1590   $(SOPHYAINCP)objfio.h \
    1591   $(SOPHYAINCP)anydataobj.h \
    1592   $(SOPHYAINCP)ppersist.h $(SOPHYAINCP)gnumd5.h \
    1593   $(SOPHYAINCP)ppfbinstream.h \
    1594   $(SOPHYAINCP)rawstream.h \
    1595   $(SOPHYAINCP)ppfnametag.h \
    1596   $(SOPHYAINCP)tvector.h $(SOPHYAINCP)tmatrix.h \
    1597   $(SOPHYAINCP)tarray.h $(SOPHYAINCP)basarr.h \
    1598   $(SOPHYAINCP)mutyv.h $(SOPHYAINCP)timestamp.h \
    1599   $(SOPHYAINCP)dvlist.h \
    1600   $(SOPHYAINCP)ndatablock.h \
    1601   $(SOPHYAINCP)utilarr.h \
    1602   $(SOPHYAINCP)tmatrix_tsnl.h \
    1603   $(SOPHYAINCP)tvector_tsnl.h \
    16041607  $(SOPHYAINCP)pidrawer.h \
    16051608  $(SOPHYAINCP)pigratt.h $(SOPHYAINCP)piaxes.h \
     
    16071610  $(SOPHYAINCP)piwindowx.h \
    16081611  $(SOPHYAINCP)piwindowgen.h \
    1609   $(SOPHYAINCP)pieldrw.h \
     1612  $(SOPHYAINCP)pieldrw.h phistwrapper.h \
     1613  $(SOPHYAINCP)parradapter.h $(SOPHYAINCP)lut.h \
    16101614  $(SOPHYAINCP)srandgen.h
    16111615        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  pihisto2d.cc
     
    16971701  $(SOPHYAINCP)generalfunc.h \
    16981702  $(SOPHYAINCP)histos.h $(SOPHYAINCP)histos2.h \
    1699   $(SOPHYAINCP)hisprof.h $(SOPHYAINCP)histerr.h \
    1700   $(SOPHYAINCP)ntuple.h $(SOPHYAINCP)xntuple.h \
     1703  $(SOPHYAINCP)hisprof.h $(SOPHYAINCP)ntuple.h \
     1704  $(SOPHYAINCP)xntuple.h \
    17011705  $(SOPHYAINCP)basedtable.h \
    1702   $(SOPHYAINCP)segdatablock.h nomgfdadapter.h \
    1703   nomimagadapter.h $(SOPHYAINCP)cimage.h \
    1704   $(SOPHYAINCP)fioarr.h nomtmatvecadapter.h nomtarradapter.h \
     1706  $(SOPHYAINCP)segdatablock.h nomherradapter.h \
     1707  $(SOPHYAINCP)histerr.h \
     1708  $(SOPHYAINCP)hist2err.h nomgfdadapter.h nomimagadapter.h \
     1709  $(SOPHYAINCP)cimage.h $(SOPHYAINCP)fioarr.h \
     1710  nomtmatvecadapter.h nomtarradapter.h \
    17051711  $(SOPHYAINCP)datatable.h \
    17061712  $(SOPHYAINCP)swppfdtable.h \
     
    18171823  $(SOPHYAINCP)tmatrix_tsnl.h \
    18181824  $(SOPHYAINCP)tvector_tsnl.h \
     1825  $(SOPHYAINCP)hist2err.h \
    18191826  $(SOPHYAINCP)generalfit.h \
    18201827  $(SOPHYAINCP)generaldata.h \
     
    20942101  $(SOPHYAINCP)segdatablock.h \
    20952102  $(SOPHYAINCP)piyfxdrw.h \
    2096   $(SOPHYAINCP)pisurfdr.h pintuple.h pintup3d.h pipodrw.h
     2103  $(SOPHYAINCP)pisurfdr.h pintuple.h pintup3d.h pipodrw.h \
     2104  $(SOPHYAINCP)hist2err.h
    20972105        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  servnobjm.cc
    20982106 
  • trunk/SophyaPI/PIext/sohiswrap.h

    r3135 r3145  
    1212#include "histerr.h"
    1313
     14#include "histos2.h"
     15#include "hist2err.h"
     16
    1417#include "pexceptions.h"
    1518
     
    1821namespace SOPHYA {
    1922 
    20 //! Wrapper class for SOPHYA::Histo  , SOPHYA::HProf
     23//! Wrapper class for SOPHYA::Histo  , SOPHYA::HProf , for use by PIHisto
    2124class HistoWrapper : public P1DHistoWrapper
    2225{
    2326public:
    2427  HistoWrapper(Histo* h, bool ad=true)
     28    : P1DHistoWrapper(h->NBins())
    2529  {
    2630    if (h == NULL) throw NullPtrError("HistoWrapper(Histo* h = NULL)");
     
    2832    mHpr = dynamic_cast<HProf*>(h);
    2933    mAD = ad;
     34    DefineXCoordinate(h->XMin(), h->BinWidth()); // Pour P1DArrayAdapter
    3035  }
    3136  ~HistoWrapper() { if (mAD) delete mHis; }
     
    4045  virtual r_8 BinHighEdge(int_4 i) { return mHis->BinHighEdge(i) ; }
    4146
    42   virtual r_8 Value(int_4 i) { return (*mHis)(i) ; }
     47  virtual r_8 Content(int_4 i) { return (*mHis)(i) ; }
    4348  virtual r_8 Error(int_4 i) { return mHis->Error(i) ; }
    4449  virtual r_8 NbEntries(int_4 i) { if(mHpr) return mHpr->SumW(i); else return 0.; }
     
    7075
    7176
    72 //! Wrapper class for SOPHYA::HistoErr 
     77//! Wrapper class for SOPHYA::HistoErr  for use by PIHisto
    7378class HistoErrWrapper : public P1DHistoWrapper
    7479{
    7580public:
    7681  HistoErrWrapper(HistoErr* h, bool ad=false)
    77   {
    78     if (h == NULL) throw NullPtrError("HistoWrapper(HistoErr* h = NULL)");
     82    : P1DHistoWrapper(h->NBins())
     83  {
     84    if (h == NULL) throw NullPtrError("HistoErrWrapper(HistoErr* h = NULL)");
    7985    mHis = h;  mAD = ad;
     86    DefineXCoordinate(h->XMin(), h->BinWidth()); // Pour P1DArrayAdapter
    8087  }
    8188  ~HistoErrWrapper() { if (mAD) delete mHis; }
     
    9097  virtual r_8 BinHighEdge(int_4 i) { return mHis->BinHighEdge(i) ; }
    9198
    92   virtual r_8 Value(int_4 i) { return (*mHis)(i) ; }
     99  virtual r_8 Content(int_4 i) { return (*mHis)(i) ; }
    93100  virtual r_8 Error(int_4 i) { return mHis->Error(i) ; }
    94101  virtual r_8 NbEntries(int_4 i) { return mHis->NEntBin(i) ; }
     
    113120};
    114121
     122
     123//! Wrapper class for SOPHYA::Histo2D   for use by PIHisto2D
     124class Histo2DWrapper : public P2DHistoWrapper
     125{
     126public:
     127  Histo2DWrapper(Histo2D* h, bool ad=true)
     128    : P2DHistoWrapper(h->NBinX(), h->NBinY())
     129  {
     130    if (h == NULL) throw NullPtrError("Histo2DWrapper(Histo2D* h = NULL)");
     131    mHis = h;  mAD = ad;
     132    DefineXYCoordinates(h->XMin(), h->YMin(), h->WBinX(), h->WBinY() ); // pour P2DArrayAdapter
     133  }
     134
     135  virtual ~Histo2DWrapper() { if (mAD) delete mHis; }
     136
     137  virtual int_4 NBinX() { return mHis->NBinX(); }
     138  virtual int_4 NBinY() { return mHis->NBinY(); }
     139  virtual r_8 XMin() { return mHis->XMin() ; }
     140  virtual r_8 XMax() { return mHis->XMax() ; }
     141  virtual r_8 YMin() { return mHis->YMin() ; }
     142  virtual r_8 YMax() { return mHis->YMax() ; }
     143  virtual r_8 WBinX() { return mHis->WBinX() ; }
     144  virtual r_8 WBinY() { return mHis->WBinY() ; }
     145
     146  virtual void BinLowEdge(int_4 i, int_4 j, r_8& xr, r_8& yr)
     147    { mHis->BinLowEdge(i, j, xr, yr); return; }
     148  virtual void BinCenter(int_4 i, int_4 j, r_8& xr, r_8& yr)
     149    { mHis->BinCenter(i, j, xr, yr); return; }
     150  virtual void BinHighEdge(int_4 i, int_4 j, r_8& xr, r_8& yr)
     151    { mHis->BinHighEdge(i, j, xr, yr); return; }
     152
     153  // Renvoie contenu du bin i
     154  virtual r_8 Content(int_4 i, int_4 j) { return (*mHis)(i,j) ; }
     155  virtual r_8 Error(int_4 i, int_4 j) { return mHis->Error(i,j) ; }
     156  virtual r_8 NbEntries(int_4 i, int_4 j) { return 0.; }  // $CHECK$ CMV 0 ??
     157
     158  // Methode de mise a jour du contenu
     159  //  virtual void Update() $CHECK$ CMV  a supprimer ?
     160
     161  // ajoute des lignes de texte avec les infos statistiques (dans text)
     162  // renvoie le nombre de lignes ajoutees - avec implementation par defaut
     163  virtual int GetStatInfoAsText(vector<string> &  text )
     164  {
     165    // $CHECK$ CMV , faut-il completer ?
     166    char label[64];
     167    string s;
     168    sprintf(label,"N= %-g", mHis->NData());
     169    s = label;   text.push_back(s);
     170    return 1;
     171  }
     172
     173  inline Histo2D* getHisto2D() { return mHis; }
     174
     175protected:
     176  Histo2D* mHis;
     177  bool mAD;
     178};
     179
     180
     181
     182//! Wrapper class for SOPHYA::Histo2DErr   for use by PIHisto2D
     183class Histo2DErrWrapper : public P2DHistoWrapper
     184{
     185public:
     186  Histo2DErrWrapper(Histo2DErr* h, bool ad=true)
     187    : P2DHistoWrapper(h->NBinX(), h->NBinY())
     188  {
     189    if (h == NULL) throw NullPtrError("Histo2DErrWrapper(Histo2DErr* h = NULL)");
     190    mHis = h;    mAD = ad;
     191    DefineXYCoordinates(h->XMin(), h->YMin(), h->WBinX(), h->WBinY() ); // pour P2DArrayAdapter
     192  }
     193
     194  virtual ~Histo2DErrWrapper() { if (mAD) delete mHis; }
     195
     196  virtual int_4 NBinX() { return mHis->NBinX(); }
     197  virtual int_4 NBinY() { return mHis->NBinY(); }
     198  virtual r_8 XMin() { return mHis->XMin() ; }
     199  virtual r_8 XMax() { return mHis->XMax() ; }
     200  virtual r_8 YMin() { return mHis->YMin() ; }
     201  virtual r_8 YMax() { return mHis->YMax() ; }
     202  virtual r_8 WBinX() { return mHis->WBinX() ; }
     203  virtual r_8 WBinY() { return mHis->WBinY() ; }
     204
     205  virtual void BinLowEdge(int_4 i, int_4 j, r_8& xr, r_8& yr)
     206    { mHis->BinLowEdge(i, j, xr, yr); return; }
     207  virtual void BinCenter(int_4 i, int_4 j, r_8& xr, r_8& yr)
     208    { mHis->BinCenter(i, j, xr, yr); return; }
     209  virtual void BinHighEdge(int_4 i, int_4 j, r_8& xr, r_8& yr)
     210    { mHis->BinHighEdge(i, j, xr, yr); return; }
     211
     212  // Renvoie contenu du bin i
     213  virtual r_8 Content(int_4 i, int_4 j) { return (*mHis)(i,j) ; }
     214  virtual r_8 Error(int_4 i, int_4 j) { return mHis->Error(i,j) ; }
     215  virtual r_8 NbEntries(int_4 i, int_4 j) { return mHis->NEntBin(i,j) ; }  // $CHECK$ CMV  OK ?
     216
     217  // Methode de mise a jour du contenu
     218  //  virtual void Update() $CHECK$ CMV  a supprimer ?
     219
     220  // ajoute des lignes de texte avec les infos statistiques (dans text)
     221  // renvoie le nombre de lignes ajoutees - avec implementation par defaut
     222  virtual int GetStatInfoAsText(vector<string> &  text )
     223  {
     224    // $CHECK$ CMV , faut-il completer ?
     225    char label[64];
     226    string s;
     227    sprintf(label,"NCorrel= %d", mHis->NCorrel());
     228    text.push_back(label);
     229    return 1;
     230  }
     231
     232  inline Histo2DErr* getHisto2DErr() { return mHis; }
     233
     234protected:
     235  Histo2DErr* mHis;
     236  bool mAD;
     237};
     238
    115239} // Fin du namespace
    116240
Note: See TracChangeset for help on using the changeset viewer.