Changeset 8545


Ignore:
Timestamp:
06/11/07 16:49:41 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8543 r8545  
    1919                                                 -*-*- END OF LINE -*-*-
    2020
    21  2007/06/06 Markus Meyer
    22 
    23    * Cosy/tpoint/:
    24      - added tpoint files from Jan. 2007 to June 2007
     21 2007/06/11 Thomas Bretz
     22
     23   * sponde.cc:
     24     - added check for validity of resource file
     25
     26   * mbase/MMath.cc:
     27     - small speed improvement to calclation of three solutions
     28       for the third order pol.
     29     - for a second order pol. set x1 and x2 if it has only one
     30       solution
     31
     32   * mbase/MMath.h:
     33     - speed improvement using ::cbrt instead of pow(x, 1/3)
     34
     35   * mcalib/MCalibrationChargeCalc.cc:
     36     - improved output
     37
     38   * mextralgo/MExtralgoSpline.cc:
     39     - speed improvement by using a look up table for often used
     40       and identical coefficients
     41     - use MMath::SolvePol2 to get the null-points of the first
     42       derivative (EvalDerivEq0)
     43     - removed a lot of old an obsolete comments
    2544
    2645
  • trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.cc

    r8500 r8545  
    1818!   Author(s): Markus Gaug 09/2004 <mailto:markus@ifae.es>
    1919!
    20 !   Copyright: MAGIC Software Development, 2002-2006
     20!   Copyright: MAGIC Software Development, 2002-2007
    2121!
    2222!
     
    5353
    5454#include "../mbase/MMath.h"
     55#include "../mbase/MArrayF.h"
    5556
    5657using namespace std;
     
    7273        return;
    7374
     75    // Look up table for coefficients
     76    static MArrayF lut;
     77
     78    // If the lut is not et large enough resize and reclaculate
     79    if (fNum>(Int_t)lut.GetSize())
     80    {
     81        lut.Set(fNum);
     82
     83        lut[0] = 0.;
     84        for (Int_t i=1; i<fNum-1; i++)
     85            lut[i] = -1.0/(lut[i-1] + 4);
     86    }
     87
     88    // Calculate the coefficients used to get reproduce the first and
     89    // second derivative.
    7490    fDer1[0] = 0.;
    75     fDer2[0] = 0.;
    76 
    7791    for (Int_t i=1; i<fNum-1; i++)
    7892    {
    79         const Float_t pp = fDer2[i-1] + 4.;
    80 
    81         fDer2[i] = -1.0/pp;
    82 
    8393        const Float_t d1 = fVal[i+1] - 2*fVal[i] + fVal[i-1];
    84         fDer1[i] = (6.0*d1-fDer1[i-1])/pp;
     94        fDer1[i] = (fDer1[i-1]-d1)*lut[i];
    8595    }
    8696
    8797    fDer2[fNum-1] = 0.;
    88 
    8998    for (Int_t k=fNum-2; k>=0; k--)
    90         fDer2[k] = fDer2[k]*fDer2[k+1] + fDer1[k];
    91 
    92     for (Int_t k=fNum-2; k>=0; k--)
    93         fDer2[k] /= 6.;
     99        fDer2[k] = lut[k]*fDer2[k+1] + fDer1[k];
     100}
     101
     102// --------------------------------------------------------------------------
     103//
     104// Return the two results x1 and x2 of f'(x)=0 for the third order
     105// polynomial (spline) in the interval i. Return the number of results.
     106// (0 if the fist derivative does not have a null-point)
     107//
     108Int_t MExtralgoSpline::EvalDerivEq0(const Int_t i, Double_t &x1, Double_t &x2) const
     109{
     110    const Double_t difder = fDer2[i+1]-fDer2[i];
     111    const Double_t difval = fVal[i+1] -fVal[i];
     112
     113    return MMath::SolvePol2(3*difder, 6*fDer2[i], difval-2*fDer2[i]-fDer2[i+1], x1, x2);
    94114}
    95115
     
    114134    const Double_t c = fVal[i+1]-fVal[i] -2*fDer2[i]-fDer2[i+1];
    115135    const Double_t d = fVal[i] - y;
     136
     137    // If the first derivative is nowhere==0 and it is increasing
     138    // in one point, and the value we search is outside of the
     139    // y-interval... it cannot be there
     140    // if (c>0 && (d>0 || fVal[i+1]<y) && b*b<3*c*a)
     141    //     return -2;
    116142
    117143    Double_t x1, x2, x3;
  • trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.h

    r8524 r8545  
    3030
    3131    Float_t fHeightTm;
    32 
    33 //    Float_t fResolution;
    3432
    3533    // Result
     
    117115    */
    118116
     117    Int_t EvalDerivEq0(const Int_t i, Double_t &x1, Double_t &x2) const;
     118/*
    119119    inline void EvalDerivEq0(const Int_t i, Float_t &rc1, Float_t &rc2) const
    120120    {
    121         /* --- ORIGINAL CODE ---
     121        // --- ORIGINAL CODE ---
    122122        Double_t sumder = fDer2[i]+fDer2[i+1];
    123123        Double_t difder = fDer2[i]-fDer2[i+1];
     
    128128        Double_t denom = -3*(fDer2[i+1]-fDer2[i]);
    129129
    130         rc1 = -(3*fDer2[i] + sqt3)/denom;
    131         rc2 = -(3*fDer2[i] - sqt3)/denom;
    132          */
    133 
     130        rc1 = (3*fDer2[i] + sqt3)/denom;
     131        rc2 = (3*fDer2[i] - sqt3)/denom;
     132
     133        // --- NEW CODE ---
    134134        Double_t sumder = fDer2[i]+fDer2[i+1];
    135135        Double_t difder = fDer2[i]-fDer2[i+1];
     
    139139        Double_t sqt3  = sqt1+sqt2<0 ? 0 : sqrt((sqt1 + sqt2)/3);
    140140
    141         rc1 = -(fDer2[i] + sqt3)/difder;
    142         rc2 = -(fDer2[i] - sqt3)/difder;
    143     }
     141        rc1 = (fDer2[i] + sqt3)/difder;
     142        rc2 = (fDer2[i] - sqt3)/difder;
     143    }*/
    144144
    145145    // Calculate the "Stammfunktion" of the Eval-function
     
    355355        // Find analytical maximum in the bin i in the interval [min,max[
    356356
    357         Float_t x1, x2;
    358         EvalDerivEq0(i, x1, x2);
     357        Double_t x1, x2;
     358        if (!EvalDerivEq0(i, x1, x2))
     359            return kFALSE;
     360
    359361        // const Float_t x1 = EvalDerivEq0S1(i);
    360362        // const Float_t x2 = EvalDerivEq0S2(i);
     
    479481    void SetExtractionType(ExtractionType_t typ)     { fExtractionType = typ; }
    480482    void SetHeightTm(Float_t h)                      { fHeightTm = h; }
    481         //    void SetResolution(Float_t res)                  { fResolution=res; }
    482483
    483484    Float_t GetTime() const      { return fTime; }
Note: See TracChangeset for help on using the changeset viewer.