PandaRoot
PndEmcShapingNoiseAdder.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 //#pragma once
14 #ifndef PNDEMCSHAPINGNOISEADDER_H_
15 #define PNDEMCSHAPINGNOISEADDER_H_
16 
18 
19 class PndEmcWaveform;
21 
28  public:
30  PndEmcShapingNoiseAdder(Double_t fShapingTime, Double_t sampleRate, Double_t noiseWidth, Double_t inputScale);
31 
32  virtual void Modify(PndEmcWaveform *wf);
33 
34  protected:
35  private:
36  Double_t fShapingTime;
37  Double_t fNoiseWidth;
38  Double_t fInputScale;
39 
40  Double_t fSingleNoiseWidth;
41 
42  class MA { // moving Average Buffer
43  private:
44  std::vector<Double_t> buffer;
45  UInt_t bpointer;
46  Double_t sum;
47 
48  public:
49  MA(UInt_t size) : buffer(size, 0.0), bpointer(0), sum(0){};
50 
51  Double_t operator()(Double_t xN)
52  {
53  sum += xN - buffer[bpointer];
54  buffer[bpointer] = xN;
55  bpointer++;
56  bpointer %= buffer.size();
57 
58  return sum / buffer.size();
59  }
60  UInt_t GetSize() { return buffer.size(); };
61  } fMA_buffer;
62 
64 };
65 
66 #endif
virtual void Modify(PndEmcWaveform *wf)
interface for waveform modifiers
ClassDef(PndEmcAbsWaveformModifier, 1)
Abstract base class for waveform simulator.
represents a simulated waveform in an emc crystal
waveform modifier to add noise to waveform