Changeset 1058 in Sophya for trunk


Ignore:
Timestamp:
Jul 7, 2000, 11:44:16 AM (25 years ago)
Author:
ansari
Message:

cmv 7/7/2000

  • Introduction methode HRebin pour les HProf
  • Passage de HRebin de Histo et HProf en virtual
Location:
trunk/SophyaLib/HiStats
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/HiStats/hisprof.cc

    r1056 r1058  
    234234}
    235235
     236/********* Methode *********/
     237/*!
     238  Pour rebinner l'histogramme de profile sur nbinew bins
     239*/
     240void HProf::HRebin(int nbinew)
     241{
     242  if( bins <= 0 ) return; // createur par default
     243  if( nbinew <= 0 ) return;
     244
     245  // memorisation de l'HProf original
     246  HProf H(*this);
     247
     248  // Rebin de la partie Histo
     249  int binold = bins;
     250  Histo::HRebin(nbinew);
     251
     252  // Le nombre de bins est il plus grand ??
     253  if( bins > binold ) {
     254    delete [] SumY;  SumY  = new double[nbinew]; memset(SumY, 0,bins*sizeof(double));
     255    delete [] SumY2; SumY2 = new double[nbinew]; memset(SumY2,0,bins*sizeof(double));
     256    delete [] SumW;  SumW  = new double[nbinew]; memset(SumW, 0,bins*sizeof(double));
     257  }
     258
     259  // Remplissage des parties propres au HPprof
     260  for(int i=0;i<bins;i++) {
     261    float xmi = BinLowEdge(i);
     262    float xma = BinHighEdge(i);
     263    int imi =  H.FindBin(xmi);
     264    if( imi < 0 ) imi = 0;
     265    int ima =  H.FindBin(xma);
     266    if( ima >= H.bins ) ima = H.bins-1;
     267    double wY = 0., wY2 = 0., wW = 0.;
     268    if( ima == imi ) {
     269      wY  = H.SumY[imi]  * binWidth/H.binWidth;
     270      wY2 = H.SumY2[imi] * binWidth/H.binWidth;
     271      wW  = H.SumW[imi]  * binWidth/H.binWidth;
     272    } else {
     273      wY  += H.SumY[imi]  * (H.BinHighEdge(imi)-xmi)/H.binWidth;
     274      wY  += H.SumY[ima]  * (xma -H.BinLowEdge(ima))/H.binWidth;
     275      wY2 += H.SumY2[imi] * (H.BinHighEdge(imi)-xmi)/H.binWidth;
     276      wY2 += H.SumY2[ima] * (xma -H.BinLowEdge(ima))/H.binWidth;
     277      wW  += H.SumW[imi]  * (H.BinHighEdge(imi)-xmi)/H.binWidth;
     278      wW  += H.SumW[ima]  * (xma -H.BinLowEdge(ima))/H.binWidth;
     279      if(ima>imi+1) for(int ii=imi+1;ii<ima;ii++)
     280        {wY += H.SumY[ii]; wY2 += H.SumY2[ii]; wW += H.SumW[ii];}
     281    }
     282    SumY[i] += wY; SumY2[i] += wY2; SumW[i] += wW;
     283  }
     284  // On synchronise les tableaux Sum?? et l'Histogramme
     285  UpdateHisto();
     286}
     287
    236288///////////////////////////////////////////////////////////
    237289// --------------------------------------------------------
  • trunk/SophyaLib/HiStats/hisprof.h

    r1056 r1058  
    5757  HProf& operator = (const HProf& h);
    5858  HProf& operator += (const HProf& a);
     59
     60  // Info, statistique et calculs sur les histogrammes
     61  virtual void HRebin(int nbinew);
    5962
    6063  // Fit
  • trunk/SophyaLib/HiStats/histos.cc

    r1056 r1058  
    11//
    2 // $Id: histos.cc,v 1.7 2000-07-07 08:41:11 ansari Exp $
     2// $Id: histos.cc,v 1.8 2000-07-07 09:44:15 ansari Exp $
    33//
    44
     
    783783void Histo::HInteg(float norm)
    784784{
     785if( bins <= 0 ) return; // createur par default
    785786if(bins>1)
    786787  for(int i=1; i<bins; i++) {
     
    802803void Histo::HDeriv()
    803804{
     805if( bins <= 0 ) return; // createur par default
    804806if( bins <= 1 ) return;
    805807float *temp = new float[bins];
     
    819821void Histo::HRebin(int nbinew)
    820822{
     823  if( bins <= 0 ) return; // createur par default
    821824  if( nbinew <= 0 ) return;
    822825
  • trunk/SophyaLib/HiStats/histos.h

    r1056 r1058  
    11// This may look like C code, but it is really -*- C++ -*-
    22//
    3 // $Id: histos.h,v 1.8 2000-07-07 08:41:11 ansari Exp $
     3// $Id: histos.h,v 1.9 2000-07-07 09:44:16 ansari Exp $
    44//
    55
     
    4242  void SetErr2(int numBin, double e2);
    4343  void SetErr(float x, float e);
    44   void   SetErr(int numBin, float e);
     44  void SetErr(int numBin, float e);
    4545
    4646  // Operators
     
    132132  void      HInteg(float norm = 0.);
    133133  void      HDeriv();
    134   void      HRebin(int nbinew);
     134  virtual void HRebin(int nbinew);
    135135
    136136  int       MaxiLocal(float& maxi,int& imax,float& maxn,int& imaxn);
Note: See TracChangeset for help on using the changeset viewer.