LDMX Software
Public Member Functions | Private Attributes | List of all members
ldmx::NoiseGenerator Class Reference

Public Member Functions

 NoiseGenerator (double noiseValue=0.0001, bool gauss=true)
 Constructor.
 
 ~NoiseGenerator ()
 Destructor.
 
void seedGenerator (uint64_t seed)
 Seed the generator.
 
bool hasSeed () const
 Has been seeded?
 
std::vector< double > generateNoiseHits (int emptyChannels)
 Generate noise hits.
 
void setNoiseThreshold (double noiseThreshold)
 Set the noise threshold.
 
void setNoise (double noise)
 Set the mean noise.
 
void setPedestal (double pedestal)
 Set the pedestal.
 

Private Attributes

std::unique_ptr< TRandom3 > random_ {nullptr}
 Random number generator.
 
double noiseThreshold_ {4}
 The noise threshold.
 
double noise_ {1}
 Mean noise.
 
double pedestal_ {0}
 Pedestal or baseline.
 
bool useGaussianModel_ {true}
 Gaussian flag.
 
std::unique_ptr< boost::math::poisson_distribution<> > poisson_dist_
 pdf for poisson errors
 

Detailed Description

Definition at line 31 of file NoiseGenerator.h.

Constructor & Destructor Documentation

◆ NoiseGenerator()

ldmx::NoiseGenerator::NoiseGenerator ( double  noiseValue = 0.0001,
bool  gauss = true 
)

Constructor.

Definition at line 13 of file NoiseGenerator.cxx.

13 {
14 noise_ = noiseValue;
15 useGaussianModel_ = gauss;
17 std::make_unique<boost::math::poisson_distribution<> >(noiseValue);
18}
double noise_
Mean noise.
std::unique_ptr< boost::math::poisson_distribution<> > poisson_dist_
pdf for poisson errors
bool useGaussianModel_
Gaussian flag.

References noise_, poisson_dist_, and useGaussianModel_.

◆ ~NoiseGenerator()

ldmx::NoiseGenerator::~NoiseGenerator ( )

Destructor.

Definition at line 20 of file NoiseGenerator.cxx.

20{}

Member Function Documentation

◆ generateNoiseHits()

std::vector< double > ldmx::NoiseGenerator::generateNoiseHits ( int  emptyChannels)

Generate noise hits.

Parameters
emptyChannelsThe total number of channels without a hit on them.
Returns
A vector containing the amplitude of the noise hits.

Definition at line 26 of file NoiseGenerator.cxx.

26 {
27 if (random_.get() == nullptr) {
28 EXCEPTION_RAISE("RandomSeedException",
29 "Noise generator was not seeded before use");
30 }
31 // std::cout << "[ Noise Generator ]: Empty channels: "
32 // << emptyChannels << std::endl;
33 // std::cout << "[ Noise Generator ]: Normalized integration limit: "
34 // << noiseThreshold_ << std::endl;
35
36 double integral;
38 integral = ROOT::Math::normal_cdf_c(noiseThreshold_, noise_, pedestal_);
39 else
40 integral =
41 boost::math::cdf(complement(*poisson_dist_, noiseThreshold_ - 1));
42 // std::cout << "[ Noise Generator ]: Integral: "
43 // << integral << std::endl;
44
45 double noiseHitCount = random_->Binomial(emptyChannels, integral);
46 // std::cout << "[ Noise Generator ]: # Noise hits: "
47 // << noiseHitCount << std::endl;
48
49 std::vector<double> noiseHits;
50 for (int hitIndex = 0; hitIndex < noiseHitCount; ++hitIndex) {
51 double rand = random_->Uniform();
52 // std::cout << "[ Noise Generator ]: Rand: "
53 // << rand << std::endl;
54 double draw = integral * rand;
55 // std::cout << "[ Noise Generator ]: Draw: "
56 // << draw << std::endl;
57
58 double cumulativeProb = 1.0 - integral + draw;
59 // std::cout << "[ Noise Generator ]: Cumulative probability: "
60 // << cumulativeProb << std::endl;
61
62 double valueAboveThreshold;
64 valueAboveThreshold =
65 ROOT::Math::gaussian_quantile(cumulativeProb, noise_);
66 else
67 valueAboveThreshold =
68 boost::math::quantile(*poisson_dist_, cumulativeProb);
69 // std::cout << "[ Noise Generator ]: Noise value: "
70 // << gaussAboveThreshold << std::endl;
71
72 noiseHits.push_back(valueAboveThreshold);
73 }
74
75 return noiseHits;
76}
double pedestal_
Pedestal or baseline.
double noiseThreshold_
The noise threshold.
std::unique_ptr< TRandom3 > random_
Random number generator.

References noise_, noiseThreshold_, pedestal_, poisson_dist_, random_, and useGaussianModel_.

◆ hasSeed()

bool ldmx::NoiseGenerator::hasSeed ( ) const
inline

Has been seeded?

Definition at line 43 of file NoiseGenerator.h.

43{ return random_.get() != nullptr; }

References random_.

◆ seedGenerator()

void ldmx::NoiseGenerator::seedGenerator ( uint64_t  seed)

Seed the generator.

Definition at line 22 of file NoiseGenerator.cxx.

22 {
23 random_ = std::make_unique<TRandom3>(seed);
24}

References random_.

◆ setNoise()

void ldmx::NoiseGenerator::setNoise ( double  noise)
inline

Set the mean noise.

Definition at line 60 of file NoiseGenerator.h.

60{ noise_ = noise; };

References noise_.

◆ setNoiseThreshold()

void ldmx::NoiseGenerator::setNoiseThreshold ( double  noiseThreshold)
inline

Set the noise threshold.

Definition at line 55 of file NoiseGenerator.h.

55 {
56 noiseThreshold_ = noiseThreshold;
57 }

References noiseThreshold_.

◆ setPedestal()

void ldmx::NoiseGenerator::setPedestal ( double  pedestal)
inline

Set the pedestal.

Definition at line 63 of file NoiseGenerator.h.

63{ pedestal_ = pedestal; };

References pedestal_.

Member Data Documentation

◆ noise_

double ldmx::NoiseGenerator::noise_ {1}
private

Mean noise.

Definition at line 73 of file NoiseGenerator.h.

73{1};

Referenced by generateNoiseHits(), NoiseGenerator(), and setNoise().

◆ noiseThreshold_

double ldmx::NoiseGenerator::noiseThreshold_ {4}
private

The noise threshold.

Definition at line 70 of file NoiseGenerator.h.

70{4};

Referenced by generateNoiseHits(), and setNoiseThreshold().

◆ pedestal_

double ldmx::NoiseGenerator::pedestal_ {0}
private

Pedestal or baseline.

Definition at line 76 of file NoiseGenerator.h.

76{0};

Referenced by generateNoiseHits(), and setPedestal().

◆ poisson_dist_

std::unique_ptr<boost::math::poisson_distribution<> > ldmx::NoiseGenerator::poisson_dist_
private

pdf for poisson errors

Definition at line 82 of file NoiseGenerator.h.

Referenced by generateNoiseHits(), and NoiseGenerator().

◆ random_

std::unique_ptr<TRandom3> ldmx::NoiseGenerator::random_ {nullptr}
private

Random number generator.

Definition at line 67 of file NoiseGenerator.h.

67{nullptr};

Referenced by generateNoiseHits(), hasSeed(), and seedGenerator().

◆ useGaussianModel_

bool ldmx::NoiseGenerator::useGaussianModel_ {true}
private

Gaussian flag.

Definition at line 79 of file NoiseGenerator.h.

79{true};

Referenced by generateNoiseHits(), and NoiseGenerator().


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