PandaRoot
BSEmcShapingNoiseAdder.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 BSEMCSHAPINGNOISEADDER_HH
15 #define BSEMCSHAPINGNOISEADDER_HH
16 
17 #include <vector>
18 
19 #include "Rtypes.h"
20 #include "RtypesCore.h"
21 
23 
24 class BSEmcWaveform;
26 class TBuffer;
27 class TClass;
28 class TMemberInspector;
29 
36  public:
38  BSEmcShapingNoiseAdder(Double_t t_shapingTime, Double_t t_sampleRate, Double_t t_noiseWidth, Double_t t_inputScale);
39 
40  virtual void Modify(BSEmcWaveform *t_wf) /*override*/;
41 
42  protected:
43  private:
44  Double_t fShapingTime{0};
45  Double_t fNoiseWidth{0};
46  Double_t fInputScale{0};
47 
48  Double_t fSingleNoiseWidth{0};
49 
50  class MA { // moving Average Buffer
51  private:
52  std::vector<Double_t> fBuffer{};
53  UInt_t fBPointer{0};
54  Double_t fSum{0};
55 
56  public:
57  MA(UInt_t t_size) : fBuffer(t_size, 0.0), fBPointer(0), fSum(0){};
58 
59  Double_t operator()(Double_t t_xN)
60  {
61  fSum += t_xN - fBuffer[fBPointer];
62  fBuffer[fBPointer] = t_xN;
63  fBPointer++;
64  fBPointer %= fBuffer.size();
65 
66  return fSum / fBuffer.size();
67  }
68  UInt_t GetSize() { return fBuffer.size(); };
69  } fMA_buffer;
70 
72 };
73 
74 #endif /*BSEMCSHAPINGNOISEADDER_HH*/
represents a simulated waveform in an emc crystal
Definition: BSEmcWaveform.h:75
interface for waveform modifiers
Abstract base class for waveform simulator.
ClassDef(BSEmcAbsWaveformModifier, 1)
virtual void Modify(BSEmcWaveform *t_wf)
waveform modifier to add noise to waveform