Ignore:
Timestamp:
01/06/09 13:07:00 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mextralgo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.cc

    r8795 r9212  
    1818!   Author(s): Markus Gaug 09/2004 <mailto:markus@ifae.es>
    1919!
    20 !   Copyright: MAGIC Software Development, 2002-2007
     20!   Copyright: MAGIC Software Development, 2002-2008
    2121!
    2222!
     
    4747//   (Note that the variables fDer are not real first derivative coefficients.)
    4848//
     49//   Note, this spline is not optimized to be evaluated many many times, but
     50//   it is optimized to be initialized very fast with new values again and
     51//   again.
     52//
    4953//////////////////////////////////////////////////////////////////////////////
    5054#include "MExtralgoSpline.h"
     
    179183// at x, until x==0. If y is not found -2 is returned.
    180184//
    181 Double_t MExtralgoSpline::SearchY(Float_t x, Float_t y) const
     185Double_t MExtralgoSpline::SearchYdn(Float_t x, Float_t y) const
    182186{
    183187    if (x>=fNum-1)
     
    185189
    186190    Int_t i = TMath::FloorNint(x);
     191    if (i<0)
     192        return -2;
     193
    187194    Double_t rc = FindY(i, kTRUE, y, 0, x-i);
    188195    while (--i>=0 && rc<0)
     
    198205
    199206    Int_t i = TMath::FloorNint(x);
     207    if (i>fNum-2)
     208        return -2;
     209
    200210    Double_t rc = FindY(i, kFALSE, y, x-i, 1.);
    201     while (i++<fNum-1 && rc<0)
     211    while (++i<fNum-1 && rc<0)
    202212        rc = FindY(i, kFALSE, y);
    203213
     
    287297    // Search downwards for fHeight/2
    288298    // By doing also a search upwards we could extract the pulse width
    289     fTime      = SearchY(maxpos, h);
     299    fTime      = SearchYdn(maxpos, h);
    290300    fTimeDev   = 0;
    291301    if (width)
  • trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.h

    r8928 r9212  
    5858
    5959    // Evaluate first derivative of spline in the interval i with x=[0;1[
    60     inline Double_t EvalDeriv1(const Float_t x, const Int_t i) const
     60    inline Double_t EvalDeriv1(const Int_t i, const Float_t x) const
    6161    {
    6262        // x := [0; 1[
     
    6464        const Double_t difder = fDer2[i+1]-fDer2[i];
    6565
    66         return 3*difder*x*x + 6*fDer2[i]*x - 2*fDer2[i] - fDer2[i+1] + difval;
     66        //return 3*difder*x*x + 6*fDer2[i]*x - 2*fDer2[i] - fDer2[i+1] + difval;
     67        return 3*difder*x*x + (6*x - 2)*fDer2[i] - fDer2[i+1] + difval;
    6768    }
    6869
    6970    // Evaluate second derivative of spline in the interval i with x=[0;1[
    70     inline Double_t EvalDeriv2(const Float_t x, const Int_t i) const
     71    inline Double_t EvalDeriv2(const Int_t i, const Float_t x) const
    7172    {
    7273        // x := [0; 1[
     
    7576
    7677    Double_t FindY(Int_t i, Bool_t downwards, Double_t y=0, Double_t min=0, Double_t max=1) const;
    77     Double_t SearchY(Float_t maxpos, Float_t y) const;
    78     Double_t SearchYup(Float_t maxpos, Float_t y) const;
    7978
    8079    Int_t EvalDerivEq0(const Int_t i, Double_t &x1, Double_t &x2) const;
     
    141140
    142141    // Calculate the intgeral of the Eval-function in
    143     // bin i from a=[0;1[ to b=[0;1[
     142    // bin i from 0 <= a < b < 1
    144143    inline Double_t EvalInteg(Int_t i, Float_t a, Float_t b) const
    145144    {
     
    268267            return kFALSE;
    269268
    270         const Bool_t ismax1 = x1>=min && x1<max && EvalDeriv2(x1, i)<0;
    271         const Bool_t ismax2 = x2>=min && x2<max && EvalDeriv2(x2, i)<0;
     269        const Bool_t ismax1 = x1>=min && x1<max && EvalDeriv2(i, x1)<0;
     270        const Bool_t ismax2 = x2>=min && x2<max && EvalDeriv2(i, x2)<0;
    272271
    273272        if (!ismax1 && !ismax2)
     
    323322
    324323    Float_t EvalAt(const Float_t x) const;
     324    Float_t Deriv1(const Float_t x) const;
     325
     326    Double_t SearchYdn(Float_t maxpos, Float_t y) const;
     327    Double_t SearchYup(Float_t maxpos, Float_t y) const;
     328
     329    Double_t SearchYdn(Float_t y) const { return SearchYdn(fNum, y); }
     330    Double_t SearchYup(Float_t y) const { return SearchYup(0,    y); }
    325331};
    326332
     
    335341}
    336342
     343inline Float_t MExtralgoSpline::Deriv1(const Float_t x) const
     344{
     345    Int_t   i = TMath::FloorNint(x);
     346    Float_t f = x-i;
     347
     348    Align(i, f);
     349
     350    return EvalDeriv1(i, f);
     351}
     352
    337353#endif
Note: See TracChangeset for help on using the changeset viewer.