Changeset 1058 in Sophya for trunk/SophyaLib/HiStats/hisprof.cc


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
File:
1 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// --------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.