Ignore:
Timestamp:
02/06/07 09:10:59 (18 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

    r8165 r8308  
    126126        x = x3;
    127127
    128     return x<0 ? -1 : x+i;
     128    return x<0 ? -2 : x+i;
    129129}
    130130
     
    132132//
    133133// Search analytically downward for the value y of the spline, starting
    134 // at x, until x==0. If y is not found -1 is returned.
     134// at x, until x==0. If y is not found -2 is returned.
    135135//
    136136Double_t MExtralgoSpline::SearchY(Float_t x, Float_t y) const
     
    142142    Double_t rc = FindY(i, y, 0, x-i);
    143143    while (--i>=0 && rc<0)
     144        rc = FindY(i, y);
     145
     146    return rc;
     147}
     148
     149Double_t MExtralgoSpline::SearchYup(Float_t x, Float_t y) const
     150{
     151    if (x<0)
     152        x = 0.0001;
     153
     154    Int_t i = TMath::FloorNint(x);
     155    Double_t rc = FindY(i, y, x-i, 1.);
     156    while (i++<fNum-1 && rc<0)
    144157        rc = FindY(i, y);
    145158
     
    227240}
    228241
    229 void MExtralgoSpline::Extract(Byte_t sat, Int_t maxbin)
     242void MExtralgoSpline::Extract(Byte_t sat, Int_t maxbin, Bool_t width)
    230243{
    231244    fSignal    =  0;
    232245    fTime      =  0;
     246    fWidth     =  0;
    233247    fSignalDev = -1;
    234248    fTimeDev   = -1;
     249    fWidthDev  = -1;
    235250
    236251    if (fNum<2)
     
    381396    }*/
    382397
    383     Float_t maxpos, maxval;
     398    Float_t maxpos;
    384399    // FIXME: Check the default if no maximum found!!!
    385     GetMaxAroundI(maxbin, maxpos, maxval);
     400    GetMaxAroundI(maxbin, maxpos, fHeight);
    386401
    387402    // --- End NEW ---
     
    391406        fTime      = maxpos;
    392407        fTimeDev   = 0;
    393         fSignal    = maxval;
     408        fSignal    = fHeight;
    394409        fSignalDev = 0;  // means: is valid
    395410        return;
    396411    }
    397412
    398     // Search downwards for maxval/2
     413    const Float_t h = fExtractionType==kIntegralAbs ? fHeightTm : fHeight*fHeightTm;
     414
     415    // Search downwards for fHeight/2
    399416    // By doing also a search upwards we could extract the pulse width
    400     const Double_t x1 = SearchY(maxpos, maxval/2);
    401 
    402     fTime      = x1;
     417    fTime      = SearchY(maxpos, h);
    403418    fTimeDev   = 0;
     419    if (width)
     420    {
     421        fWidth    = SearchYup(maxpos, h)-fTime;
     422        fWidthDev = 0;
     423    }
    404424    fSignal    = CalcIntegral(maxpos);
    405425    fSignalDev = 0;  // means: is valid
  • trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.h

    r8158 r8308  
    1212{
    1313public: 
    14     enum ExtractionType_t { kAmplitude, kIntegral };    //! Possible time and charge extraction types
     14    enum ExtractionType_t { kAmplitude, kIntegralRel, kIntegralAbs };    //! Possible time and charge extraction types
    1515
    1616private:
     
    3030    Float_t fFallTime;
    3131
     32    Float_t fHeightTm;
     33
    3234//    Float_t fResolution;
    3335
     
    3537    Float_t fTime;
    3638    Float_t fTimeDev;
     39    Float_t fWidth;
     40    Float_t fWidthDev;
    3741    Float_t fSignal;
    3842    Float_t fSignalDev;
     43    Float_t fHeight;
    3944
    4045    Double_t ReMul(const TComplex &c1, const TComplex &th) const;
     
    8994    Double_t FindY(Int_t i, Double_t y=0, Double_t min=0, Double_t max=1) const;
    9095    Double_t SearchY(Float_t maxpos, Float_t y) const;
     96    Double_t SearchYup(Float_t maxpos, Float_t y) const;
    9197/*
    9298    // Evaluate first solution for a possible maximum (x|first deriv==0)
     
    230236            rc1 = kTRUE;
    231237        }
    232         if (i>fNum-2)
     238        if (i>=fNum-1)
    233239        {
    234240            xmax2 = fNum-1;
     
    440446public:
    441447    MExtralgoSpline(const Float_t *val, Int_t n, Float_t *der1, Float_t *der2)
    442         : fExtractionType(kIntegral), fVal(val), fNum(n), fDer1(der1), fDer2(der2), fTime(0), fTimeDev(-1), fSignal(0), fSignalDev(-1)
     448        : fExtractionType(kIntegralRel), fVal(val), fNum(n), fDer1(der1), fDer2(der2), fHeightTm(0.5), fTime(0), fTimeDev(-1), fSignal(0), fSignalDev(-1)
    443449    {
    444450        InitDerivatives();
     
    447453    void SetRiseFallTime(Float_t rise, Float_t fall) { fRiseTime=rise; fFallTime=fall; }
    448454    void SetExtractionType(ExtractionType_t typ)     { fExtractionType = typ; }
    449 //    void SetResolution(Float_t res)                  { fResolution=res; }
     455    void SetHeightTm(Float_t h)                      { fHeightTm = h; }
     456        //    void SetResolution(Float_t res)                  { fResolution=res; }
    450457
    451458    Float_t GetTime() const      { return fTime; }
     459    Float_t GetWidth() const     { return fWidth; }
    452460    Float_t GetSignal() const    { return fSignal; }
     461    Float_t GetHeight() const    { return fHeight; }
    453462
    454463    Float_t GetTimeDev() const   { return fTimeDev; }
     464    Float_t GetWidthDev() const  { return fWidthDev; }
    455465    Float_t GetSignalDev() const { return fSignalDev; }
    456466
    457467    void GetSignal(Float_t &sig, Float_t &dsig) const { sig=fSignal; dsig=fSignalDev; }
     468    void GetWidth(Float_t &sig, Float_t &dsig) const  { sig=fWidth; dsig=fWidthDev; }
    458469    void GetTime(Float_t &sig, Float_t &dsig) const   { sig=fTime; dsig=fTimeDev; }
    459470
    460471    Float_t ExtractNoise(/*Int_t iter*/);
    461     void Extract(Byte_t sat, Int_t maxpos);
     472    void Extract(Byte_t sat, Int_t maxpos, Bool_t width=kFALSE);
    462473};
    463474
Note: See TracChangeset for help on using the changeset viewer.