| 1 | #ifndef MARS_MExtralgoDigitalFilter
|
|---|
| 2 | #define MARS_MExtralgoDigitalFilter
|
|---|
| 3 |
|
|---|
| 4 | #ifndef ROOT_TROOT
|
|---|
| 5 | #include <TROOT.h>
|
|---|
| 6 | #endif
|
|---|
| 7 |
|
|---|
| 8 | class MExtralgoDigitalFilter
|
|---|
| 9 | {
|
|---|
| 10 | private:
|
|---|
| 11 | // Input
|
|---|
| 12 | Float_t *fVal;
|
|---|
| 13 | Int_t fNum;
|
|---|
| 14 |
|
|---|
| 15 | Float_t *fWeightsAmp;
|
|---|
| 16 | Float_t *fWeightsTime;
|
|---|
| 17 |
|
|---|
| 18 | Int_t fWeightsPerBin; // Number of weights per data bin
|
|---|
| 19 |
|
|---|
| 20 | // Result
|
|---|
| 21 | Float_t fTime;
|
|---|
| 22 | Float_t fTimeDev;
|
|---|
| 23 | Float_t fSignal;
|
|---|
| 24 | Float_t fSignalDev;
|
|---|
| 25 |
|
|---|
| 26 | inline void Eval(Double_t &sumamp, Double_t &sumtime, const Int_t windowsize, const Int_t startv, const Int_t startw=0) const
|
|---|
| 27 | {
|
|---|
| 28 | //
|
|---|
| 29 | // Slide with a window of size windowsize over the sample
|
|---|
| 30 | // and multiply the entries with the corresponding weights
|
|---|
| 31 | //
|
|---|
| 32 | sumamp = 0;
|
|---|
| 33 | sumtime = 0;
|
|---|
| 34 |
|
|---|
| 35 | // Shift the start of the weight to the center of sample 0
|
|---|
| 36 | Float_t const *wa = fWeightsAmp + fWeightsPerBin/2 + startw;
|
|---|
| 37 | Float_t const *wt = fWeightsTime + fWeightsPerBin/2 + startw;
|
|---|
| 38 | Float_t *const beg = fVal+startv;
|
|---|
| 39 |
|
|---|
| 40 | for (Float_t const *pex=beg; pex<beg+windowsize; pex++)
|
|---|
| 41 | {
|
|---|
| 42 | sumamp += *wa * *pex;
|
|---|
| 43 | sumtime += *wt * *pex;
|
|---|
| 44 |
|
|---|
| 45 | // Step forward by one bin
|
|---|
| 46 | wa += fWeightsPerBin;
|
|---|
| 47 | wt += fWeightsPerBin;
|
|---|
| 48 | }
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | public:
|
|---|
| 52 | MExtralgoDigitalFilter(Float_t *val, Int_t n, Float_t *wa, Float_t *wt)
|
|---|
| 53 | : fVal(val), fNum(n),
|
|---|
| 54 | fWeightsAmp(wa), fWeightsTime(wt), fTime(0), fTimeDev(-1), fSignal(0), fSignalDev(-1)
|
|---|
| 55 | {
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | void SetWeightsPerBin(Int_t res) { fWeightsPerBin=res; }
|
|---|
| 59 |
|
|---|
| 60 | Float_t GetTime() const { return fTime; }
|
|---|
| 61 | Float_t GetSignal() const { return fSignal; }
|
|---|
| 62 |
|
|---|
| 63 | Float_t GetTimeDev() const { return fTimeDev; }
|
|---|
| 64 | Float_t GetSignalDev() const { return fSignalDev; }
|
|---|
| 65 |
|
|---|
| 66 | void GetSignal(Float_t &sig, Float_t &dsig) const { sig=fSignal; dsig=fSignalDev; }
|
|---|
| 67 | void GetTime(Float_t &sig, Float_t &dsig) const { sig=fTime; dsig=fTimeDev; }
|
|---|
| 68 |
|
|---|
| 69 | Float_t ExtractNoise(Int_t iter, Int_t windowsize) const;
|
|---|
| 70 | void Extract(Int_t windowsize, Float_t timeshift);
|
|---|
| 71 | };
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 | #endif
|
|---|