Ignore:
Timestamp:
10/24/06 09:26:10 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mextralgo/MExtralgoDigitalFilter.h

    r8072 r8154  
    22#define MARS_MExtralgoDigitalFilter
    33
    4 #ifndef ROOT_TROOT
    5 #include <TROOT.h>
     4#ifndef ROOT_TMatrix
     5#include <TMatrix.h>
    66#endif
    77
     
    1212class TArrayF;
    1313
     14//#include <TMatrix.h>
     15
    1416class MExtralgoDigitalFilter
    1517{
    1618private:
    1719    // Input
    18     Float_t *fVal;
    19     Int_t    fNum;
     20    const Float_t *fVal;
     21    Int_t fNum;
    2022
    2123    Float_t const *fWeightsAmp;
    2224    Float_t const *fWeightsTime;
     25    Float_t const *fPulseShape;
     26
     27    const TMatrix *fAinv;
    2328
    2429    const Int_t fWeightsPerBin; // Number of weights per data bin
     
    3035    Float_t fSignal;
    3136    Float_t fSignalDev;
     37
     38    Float_t GetChisq(const Int_t maxp, const Int_t frac, const Float_t sum) const;
     39
     40    inline Double_t ChiSq(const Double_t sum, const Int_t startv, const Int_t startw=0) const
     41    {
     42        //
     43        // Slide with a window of size windowsize over the sample
     44        // and multiply the entries with the corresponding weights
     45        //
     46        Double_t chisq = 0;
     47
     48        // Shift the start of the weight to the center of sample 0
     49        Float_t const *w = fPulseShape + startw;
     50
     51        const Float_t *beg = fVal+startv;
     52        for (Float_t const *pex=beg; pex<beg+fWindowSize; pex++)
     53        {
     54            const Double_t c = *w - *pex/sum;
     55            chisq += c*c;
     56            w += fWeightsPerBin;
     57        }
     58        return chisq;
     59    }
    3260
    3361    // Weights: Weights to evaluate
     
    4573        Float_t const *w = weights + startw;
    4674
    47         Float_t *const beg = fVal+startv;
     75        const Float_t *beg = fVal+startv;
    4876        for (Float_t const *pex=beg; pex<beg+fWindowSize; pex++)
    4977        {
     
    115143
    116144public:
    117     MExtralgoDigitalFilter(Int_t res, Int_t windowsize, Float_t *wa, Float_t *wt)
     145    MExtralgoDigitalFilter(Int_t res, Int_t windowsize, Float_t *wa, Float_t *wt, Float_t *ps=0, TMatrix *ainv=0)
    118146        : fVal(0), fNum(0), fWeightsAmp(wa+res/2), fWeightsTime(wt+res/2),
    119         fWeightsPerBin(res), fWindowSize(windowsize),
     147        fPulseShape(ps), fAinv(ainv), fWeightsPerBin(res), fWindowSize(windowsize),
    120148        fTime(0), fTimeDev(-1), fSignal(0), fSignalDev(-1)
    121149    {
    122150    }
    123151
    124     void SetData(Int_t n, Float_t *val) { fNum=n; fVal=val; }
     152    void SetData(Int_t n, Float_t const *val) { fNum=n; fVal=val; }
    125153
    126154    Float_t GetTime() const          { return fTime; }
     
    134162
    135163    Float_t ExtractNoise(Int_t iter) const;
    136     void Extract();
     164    void Extract(Int_t maxpos=-1);
    137165
    138     static Bool_t CalculateWeights(TH1 &shape, const TH2 &autocorr, TArrayF &wa, TArrayF &wt, Int_t wpb=-1);
    139     static void CalculateWeights2(TH1F &shape, const TH2F &autocorr, TArrayF &wa, TArrayF &wt, Int_t wpb=-1);
     166    static Int_t CalculateWeights(TH1 &shape, const TH2 &autocorr, TArrayF &wa, TArrayF &wt, Int_t wpb=-1);
     167    static Int_t CalculateWeights2(TH1 &shape, const TH2 &autocorr, TArrayF &wa, TArrayF &wt, Int_t wpb=-1);
    140168};
    141169
Note: See TracChangeset for help on using the changeset viewer.