FairRoot/PandaRoot
PndEmcShapingNoiseAdder.cxx
Go to the documentation of this file.
3 
4 #include "PndEmcWaveform.h"
5 #include "TRandom.h"
6 #include "TMath.h"
7 
9  fShapingTime(0),
10  fNoiseWidth(0.),
11  fInputScale(0.0),
12  fSingleNoiseWidth(0.0),
13  fMA_buffer(0) {
14 }
15 
16 PndEmcShapingNoiseAdder::PndEmcShapingNoiseAdder(Double_t shapingTime, Double_t sampleRate, Double_t noiseWidth, Double_t inputScale) :
17  fShapingTime(shapingTime),
18  fNoiseWidth(noiseWidth),
19  fInputScale(inputScale),
20  //MA buffer size as long as no of samples forming rising edge of wf
21 
22  fMA_buffer((Int_t) (shapingTime*sampleRate)) {
23  Int_t bufferSize = fMA_buffer.GetSize();
24 
25  if(!bufferSize) {
26  std::cout << "-E PndEmcShapedNoiseWaveformSimulator: pulse raises in less than one sample. Noise generation will fail" << std::endl;
27  }
28 
29  //noise of individual sample is averaged over bufferSize samples --> fNoiseWidth² = bufferSize * fSingleNoiseWidth²
30  fSingleNoiseWidth = fNoiseWidth * TMath::Sqrt(bufferSize); //still in GeV
31 
32  //Init buffer
33  while(bufferSize--) { //init buffer
34  fMA_buffer(gRandom->Gaus(0, fSingleNoiseWidth*fInputScale));
35  }
36  }
37 
38 
40 
41  for(std::vector<Double_t>::iterator it=GetWaveformReference(wf).begin(); it!=GetWaveformReference(wf).end(); ++it) {
42 
43  (*it) += fMA_buffer(gRandom->Gaus(0, fSingleNoiseWidth*fInputScale)); //smear with shaping noise
44  }
45 }
virtual void Modify(PndEmcWaveform *wf)
class PndEmcShapingNoiseAdder::MA fMA_buffer
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
Double_t
represents a simulated waveform in an emc crystal
std::vector< Double_t > & GetWaveformReference(PndEmcWaveform *wf)