Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rsim::NoiseMaker Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-08-11/ReadoutSim/NoiseMaker.h"

Inheritance diagram for rsim::NoiseMaker:
rsim::CommonParameters

Public Member Functions

 NoiseMaker (const fhicl::ParameterSet &pset)
 
virtual ~NoiseMaker ()
 
double GetNoise (CLHEP::RandGaussQ *gauss)
 
double GetCurrentNoise (CLHEP::RandGaussQ *gauss)
 
double GetVoltageNoise (CLHEP::RandGaussQ *gauss)
 
double GetNominalThreshold ()
 

Protected Member Functions

void ApplyDCS (std::vector< double > &rawtrace, std::vector< double > &dcstrace)
 
double GetRMS (std::vector< double > &dcstrace)
 
void Init (CLHEP::RandGaussQ *gauss)
 

Protected Attributes

double fVoltageNoiseScale
 
double fCurrentNoiseScale
 
bool fNeedInit
 
int fNumNormSamples
 num samples to use to set norm at init time More...
 
double fTrise
 rise time of shaper (ns) More...
 
double fTfall
 fall time of shaper (ns) More...
 
double fTread
 time between digitizations (ns) More...
 
double fDetectorCapacitance
 detector capacitance (pF) More...
 
double fThresholdSigma
 Sigma value used for setting thresholds. More...
 
int fFPGA_DCS_LookbackSamples
 For doing DCS to normalize. More...
 
double fLastVDraw
 
double fLastCDraw
 
double fNominalThreshold
 
double fClocktick
 digitization clock period, ns More...
 
int fNumClockticksInSpill
 number of clockticks in a spill More...
 
int fNumClockticksPerDigitization
 How many ticks between each ADC. More...
 
double fADCMaxPE
 maximum signal size that the ADC can handle without saturating (in PE) More...
 
double fAPDExcessNoiseFactor
 APD's "excess noise factor" (see .cxx for more) More...
 
double fASICBaselineInADCCounts
 ASIC baseline output level, in ADC counts. More...
 
double fGain
 APD gain (electrons per photoelectron) More...
 
bool fUseDBThresholds
 Use thresholds from DB instead of fcl defaults. More...
 
bool fUseRandomThresholds
 Use thresholds drawn from a histogram instead of fcl defaults. More...
 
bool fUseNewEmptyCellNoise
 For backwards compatibility with the old noise model until the 2nd analysis is over. More...
 
std::string fThresholdFile
 File containing thresholds for the random threshold option. More...
 
std::string fEmptyCellNoiseFile
 File containing the empty cell noise templates. More...
 
std::string fGainFile
 File containing the distribution of gains on the detector. More...
 
double fLeakageCurrent
 
double fVoltageNoiseDensity
 
double fASICRiseTime
 ASIC shaping curve: rise time, ns. More...
 
double fASICFallTime
 ASIC shaping curve: fall time, ns. More...
 

Detailed Description

Definition at line 25 of file NoiseMaker.h.

Constructor & Destructor Documentation

rsim::NoiseMaker::NoiseMaker ( const fhicl::ParameterSet pset)
explicit

Definition at line 22 of file NoiseMaker.cxx.

References rsim::CommonParameters::fASICFallTime, rsim::CommonParameters::fASICRiseTime, rsim::CommonParameters::fClocktick, fFPGA_DCS_LookbackSamples, fNeedInit, rsim::CommonParameters::fNumClockticksPerDigitization, fTfall, fTread, and fTrise.

22  :
23  CommonParameters(pset),
24  fNumNormSamples (pset.get< int >("NumNormSamples")),
25  fDetectorCapacitance(pset.get< double >("DetectorCapacitance")),
26  fThresholdSigma (pset.get< double >("ThresholdSigma")),
27  fFPGA_DCS_LookbackSamples(pset.get< int >("FPGA_DCS_LookbackSamples")),
28  fLastVDraw(0.0),
29  fLastCDraw(0.0),
31  {
32  fNeedInit = true;
36  }
int fNumClockticksPerDigitization
How many ticks between each ADC.
CommonParameters(const fhicl::ParameterSet &pset)
double fASICRiseTime
ASIC shaping curve: rise time, ns.
double fThresholdSigma
Sigma value used for setting thresholds.
Definition: NoiseMaker.h:54
double fDetectorCapacitance
detector capacitance (pF)
Definition: NoiseMaker.h:53
double fLastVDraw
Definition: NoiseMaker.h:61
double fLastCDraw
Definition: NoiseMaker.h:62
T get(std::string const &key) const
Definition: ParameterSet.h:231
double fTrise
rise time of shaper (ns)
Definition: NoiseMaker.h:50
double fTread
time between digitizations (ns)
Definition: NoiseMaker.h:52
int fFPGA_DCS_LookbackSamples
For doing DCS to normalize.
Definition: NoiseMaker.h:56
double fNominalThreshold
Definition: NoiseMaker.h:64
int fNumNormSamples
num samples to use to set norm at init time
Definition: NoiseMaker.h:49
double fTfall
fall time of shaper (ns)
Definition: NoiseMaker.h:51
double fClocktick
digitization clock period, ns
double fASICFallTime
ASIC shaping curve: fall time, ns.
virtual rsim::NoiseMaker::~NoiseMaker ( )
inlinevirtual

Definition at line 29 of file NoiseMaker.h.

29 {}

Member Function Documentation

void rsim::NoiseMaker::ApplyDCS ( std::vector< double > &  rawtrace,
std::vector< double > &  dcstrace 
)
protected

Definition at line 119 of file NoiseMaker.cxx.

References fFPGA_DCS_LookbackSamples.

Referenced by Init().

119  {
120  dcstrace.clear();
121  int N = rawtrace.size();
122  for (int iS=fFPGA_DCS_LookbackSamples;iS<N;iS++) {
123  dcstrace.push_back(rawtrace[iS] - rawtrace[iS-fFPGA_DCS_LookbackSamples]);
124  }
125  return;
126  }
int fFPGA_DCS_LookbackSamples
For doing DCS to normalize.
Definition: NoiseMaker.h:56
double rsim::NoiseMaker::GetCurrentNoise ( CLHEP::RandGaussQ gauss)

Definition at line 39 of file NoiseMaker.cxx.

References fCurrentNoiseScale, CLHEP::RandGaussQ::fire(), fLastCDraw, fNeedInit, fTfall, fTread, and Init().

Referenced by Init().

39  {
40  if (fNeedInit) Init(gauss);
41 
43 
45  }
void Init(CLHEP::RandGaussQ *gauss)
Definition: NoiseMaker.cxx:57
double fLastCDraw
Definition: NoiseMaker.h:62
double fCurrentNoiseScale
Definition: NoiseMaker.h:45
double fTread
time between digitizations (ns)
Definition: NoiseMaker.h:52
double fTfall
fall time of shaper (ns)
Definition: NoiseMaker.h:51
double rsim::NoiseMaker::GetNoise ( CLHEP::RandGaussQ gauss)
inline

Definition at line 32 of file NoiseMaker.h.

References Munits::gauss.

Referenced by rsim::MakeNoiseSpectrumFile::analyze(), rsim::ReadoutSim::CreateRawDigits(), and Init().

32  {return GetCurrentNoise(gauss)+
33  GetVoltageNoise(gauss);}
double GetCurrentNoise(CLHEP::RandGaussQ *gauss)
Definition: NoiseMaker.cxx:39
double GetVoltageNoise(CLHEP::RandGaussQ *gauss)
Definition: NoiseMaker.cxx:48
double rsim::NoiseMaker::GetNominalThreshold ( )
inline

Definition at line 37 of file NoiseMaker.h.

Referenced by rsim::ReadoutSim::CreateRawDigits().

37 {return fNominalThreshold;}
double fNominalThreshold
Definition: NoiseMaker.h:64
double rsim::NoiseMaker::GetRMS ( std::vector< double > &  dcstrace)
protected

Definition at line 129 of file NoiseMaker.cxx.

References ana::Sqrt(), and sum.

Referenced by Init().

129  {
130  int N = dcstrace.size();
131  double sum = 0;
132  double sumsq = 0;
133  for (int iS=0;iS<N;iS++) {
134  sum += dcstrace[iS];
135  sumsq += dcstrace[iS]*dcstrace[iS];
136  }
137  return ( (N>0) ? TMath::Sqrt(sumsq/N - (sum/N)*(sum/N)) : 0 );
138  }
Var Sqrt(const Var &v)
Use to take sqrt of a var.
Definition: Var.cxx:324
Double_t sum
Definition: plot.C:31
double rsim::NoiseMaker::GetVoltageNoise ( CLHEP::RandGaussQ gauss)

Definition at line 48 of file NoiseMaker.cxx.

References CLHEP::RandGaussQ::fire(), fLastVDraw, fNeedInit, fTread, fTrise, fVoltageNoiseScale, and Init().

Referenced by Init().

48  {
49  if (fNeedInit) Init(gauss);
50 
52 
54  }
void Init(CLHEP::RandGaussQ *gauss)
Definition: NoiseMaker.cxx:57
double fLastVDraw
Definition: NoiseMaker.h:61
double fVoltageNoiseScale
Definition: NoiseMaker.h:44
double fTrise
rise time of shaper (ns)
Definition: NoiseMaker.h:50
double fTread
time between digitizations (ns)
Definition: NoiseMaker.h:52
void rsim::NoiseMaker::Init ( CLHEP::RandGaussQ gauss)
protected

Definition at line 57 of file NoiseMaker.cxx.

References ApplyDCS(), E, allTimeWatchdog::endl, rsim::CommonParameters::fADCMaxPE, rsim::CommonParameters::fAPDExcessNoiseFactor, fCurrentNoiseScale, fDetectorCapacitance, rsim::CommonParameters::fGain, fLastCDraw, fLastVDraw, rsim::CommonParameters::fLeakageCurrent, fNeedInit, fNominalThreshold, fNumNormSamples, fThresholdSigma, fTread, fTrise, rsim::CommonParameters::fVoltageNoiseDensity, fVoltageNoiseScale, GetCurrentNoise(), GetNoise(), GetRMS(), GetVoltageNoise(), extractScale::rms, and ana::Sqrt().

Referenced by GetCurrentNoise(), and GetVoltageNoise().

57  {
58 
59  fNeedInit = false;
60 
61  // Draw a bunch of noise, apply DCS to it, get RMS, and use
62  // that to set the scale factors. See doc-4401.
63 
64  mf::LogInfo("NoiseMaker") << "rsim::NoiseMaker Initializing..." << std::endl;
65 
66  // Start with arbitrary scales of 1
69 
70  fLastVDraw = 0;
71  fLastCDraw = 0;
72 
73  std::vector<double> rawtrace(0);
74  std::vector<double> dcstrace(0);
75 
76  const double Qe = 1.6022E-10; // e in nC
77 
78  // a "leakage rate", of sorts, in GHz:
79  double I_L =
80  fLeakageCurrent / Qe
81  * fGain * fAPDExcessNoiseFactor * 1E-9; // last factor for 1/s-->1/ns
82 
83  // --- first, current noise:
84  rawtrace.clear();
85  for (int iS=0;iS<fNumNormSamples;iS++) {
86  rawtrace.push_back(GetCurrentNoise(gauss));
87  }
88  ApplyDCS(rawtrace,dcstrace);
89  double rms = GetRMS(dcstrace);
90  double enc = TMath::Sqrt(I_L*(2*fTread - fTrise));
91  mf::LogInfo("NoiseMaker") << "rsim::NoiseMaker: equivalent noise charge (current) = " << enc << " electrons" << std::endl;
92  fCurrentNoiseScale = enc / rms / fGain;
93 
94  // --- then, voltage noise:
95  rawtrace.clear();
96  for (int iS=0;iS<fNumNormSamples;iS++) {
97  rawtrace.push_back(GetVoltageNoise(gauss));
98  }
99  ApplyDCS(rawtrace,dcstrace);
100  rms = GetRMS(dcstrace);
101  enc =
103  / Qe / TMath::Sqrt(2*fTrise*1E-9) * 1E-12; // last factor for pF-->F
104  mf::LogInfo("NoiseMaker") << "rsim::NoiseMaker: equivalent noise charge (voltage) = " << enc << " electrons" << std::endl;
105  fVoltageNoiseScale = enc / rms / fGain;
106 
107  // --- then, extract nominal threshold
108  rawtrace.clear();
109  for (int iS=0; iS<fNumNormSamples;iS++) {
110  rawtrace.push_back(GetNoise(gauss)/fADCMaxPE*( (1<<12) - 1 ));
111  }
112  ApplyDCS(rawtrace,dcstrace);
113  rms = GetRMS(dcstrace);
115  mf::LogInfo("NoiseMaker") << "rsim::NoiseMaker: nominal threshold (" << fThresholdSigma << "*sigma_dcs) = " << fNominalThreshold << std::endl;
116  }
double fAPDExcessNoiseFactor
APD&#39;s "excess noise factor" (see .cxx for more)
double fThresholdSigma
Sigma value used for setting thresholds.
Definition: NoiseMaker.h:54
double fDetectorCapacitance
detector capacitance (pF)
Definition: NoiseMaker.h:53
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
double fLastVDraw
Definition: NoiseMaker.h:61
double fLastCDraw
Definition: NoiseMaker.h:62
double fCurrentNoiseScale
Definition: NoiseMaker.h:45
double GetNoise(CLHEP::RandGaussQ *gauss)
Definition: NoiseMaker.h:32
Float_t E
Definition: plot.C:20
double fVoltageNoiseScale
Definition: NoiseMaker.h:44
double fGain
APD gain (electrons per photoelectron)
double fTrise
rise time of shaper (ns)
Definition: NoiseMaker.h:50
void ApplyDCS(std::vector< double > &rawtrace, std::vector< double > &dcstrace)
Definition: NoiseMaker.cxx:119
double fTread
time between digitizations (ns)
Definition: NoiseMaker.h:52
double fADCMaxPE
maximum signal size that the ADC can handle without saturating (in PE)
double fNominalThreshold
Definition: NoiseMaker.h:64
Var Sqrt(const Var &v)
Use to take sqrt of a var.
Definition: Var.cxx:324
double GetCurrentNoise(CLHEP::RandGaussQ *gauss)
Definition: NoiseMaker.cxx:39
double GetVoltageNoise(CLHEP::RandGaussQ *gauss)
Definition: NoiseMaker.cxx:48
int fNumNormSamples
num samples to use to set norm at init time
Definition: NoiseMaker.h:49
double GetRMS(std::vector< double > &dcstrace)
Definition: NoiseMaker.cxx:129

Member Data Documentation

double rsim::CommonParameters::fADCMaxPE
inherited

maximum signal size that the ADC can handle without saturating (in PE)

Definition at line 25 of file CommonParameters.h.

Referenced by rsim::MakeNoiseSpectrumFile::analyze(), rsim::CommonParameters::CommonParameters(), rsim::ReadoutSim::CreateRawDigits(), Init(), and rsim::ReadoutSim::PE2ADC().

double rsim::CommonParameters::fAPDExcessNoiseFactor
inherited
double rsim::CommonParameters::fASICBaselineInADCCounts
inherited

ASIC baseline output level, in ADC counts.

Definition at line 27 of file CommonParameters.h.

Referenced by rsim::MakeNoiseSpectrumFile::analyze(), and rsim::ReadoutSim::CreateRawDigits().

double rsim::CommonParameters::fASICFallTime
inherited

ASIC shaping curve: fall time, ns.

Definition at line 39 of file CommonParameters.h.

Referenced by NoiseMaker(), and rsim::FPGA_MatchedFiltering::PerfectASICCurve().

double rsim::CommonParameters::fASICRiseTime
inherited

ASIC shaping curve: rise time, ns.

Definition at line 38 of file CommonParameters.h.

Referenced by NoiseMaker(), and rsim::FPGA_MatchedFiltering::PerfectASICCurve().

double rsim::CommonParameters::fClocktick
inherited
double rsim::NoiseMaker::fCurrentNoiseScale
protected

Definition at line 45 of file NoiseMaker.h.

Referenced by GetCurrentNoise(), and Init().

double rsim::NoiseMaker::fDetectorCapacitance
protected

detector capacitance (pF)

Definition at line 53 of file NoiseMaker.h.

Referenced by Init().

std::string rsim::CommonParameters::fEmptyCellNoiseFile
inherited

File containing the empty cell noise templates.

Definition at line 33 of file CommonParameters.h.

Referenced by rsim::ReadoutSim::beginRun(), and rsim::CommonParameters::CommonParameters().

int rsim::NoiseMaker::fFPGA_DCS_LookbackSamples
protected

For doing DCS to normalize.

Definition at line 56 of file NoiseMaker.h.

Referenced by ApplyDCS(), and NoiseMaker().

double rsim::CommonParameters::fGain
inherited
std::string rsim::CommonParameters::fGainFile
inherited

File containing the distribution of gains on the detector.

Definition at line 34 of file CommonParameters.h.

Referenced by rsim::ReadoutSim::beginRun(), and rsim::CommonParameters::CommonParameters().

double rsim::NoiseMaker::fLastCDraw
protected

Definition at line 62 of file NoiseMaker.h.

Referenced by GetCurrentNoise(), and Init().

double rsim::NoiseMaker::fLastVDraw
protected

Definition at line 61 of file NoiseMaker.h.

Referenced by GetVoltageNoise(), and Init().

double rsim::CommonParameters::fLeakageCurrent
inherited

Definition at line 35 of file CommonParameters.h.

Referenced by rsim::CommonParameters::CommonParameters(), and Init().

bool rsim::NoiseMaker::fNeedInit
protected

Definition at line 47 of file NoiseMaker.h.

Referenced by GetCurrentNoise(), GetVoltageNoise(), Init(), and NoiseMaker().

double rsim::NoiseMaker::fNominalThreshold
protected

Definition at line 64 of file NoiseMaker.h.

Referenced by Init().

int rsim::CommonParameters::fNumClockticksInSpill
inherited
int rsim::CommonParameters::fNumClockticksPerDigitization
inherited
int rsim::NoiseMaker::fNumNormSamples
protected

num samples to use to set norm at init time

Definition at line 49 of file NoiseMaker.h.

Referenced by Init().

double rsim::NoiseMaker::fTfall
protected

fall time of shaper (ns)

Definition at line 51 of file NoiseMaker.h.

Referenced by GetCurrentNoise(), and NoiseMaker().

std::string rsim::CommonParameters::fThresholdFile
inherited

File containing thresholds for the random threshold option.

Definition at line 32 of file CommonParameters.h.

Referenced by rsim::IFPGAAlgorithm::IFPGAAlgorithm().

double rsim::NoiseMaker::fThresholdSigma
protected

Sigma value used for setting thresholds.

Definition at line 54 of file NoiseMaker.h.

Referenced by Init().

double rsim::NoiseMaker::fTread
protected

time between digitizations (ns)

Definition at line 52 of file NoiseMaker.h.

Referenced by GetCurrentNoise(), GetVoltageNoise(), Init(), and NoiseMaker().

double rsim::NoiseMaker::fTrise
protected

rise time of shaper (ns)

Definition at line 50 of file NoiseMaker.h.

Referenced by GetVoltageNoise(), Init(), and NoiseMaker().

bool rsim::CommonParameters::fUseDBThresholds
inherited
bool rsim::CommonParameters::fUseNewEmptyCellNoise
inherited

For backwards compatibility with the old noise model until the 2nd analysis is over.

Definition at line 31 of file CommonParameters.h.

Referenced by rsim::CommonParameters::CommonParameters(), and rsim::ReadoutSim::CreateRawDigits().

bool rsim::CommonParameters::fUseRandomThresholds
inherited

Use thresholds drawn from a histogram instead of fcl defaults.

Definition at line 30 of file CommonParameters.h.

Referenced by rsim::IFPGAAlgorithm::FetchThresholds(), rsim::IFPGAAlgorithm::IFPGAAlgorithm(), and rsim::IFPGAAlgorithm::ThresholdADC().

double rsim::CommonParameters::fVoltageNoiseDensity
inherited

Definition at line 36 of file CommonParameters.h.

Referenced by rsim::CommonParameters::CommonParameters(), and Init().

double rsim::NoiseMaker::fVoltageNoiseScale
protected

Definition at line 44 of file NoiseMaker.h.

Referenced by GetVoltageNoise(), and Init().


The documentation for this class was generated from the following files: