LDMX Software
ldmx::NoiseGenerator Class Reference

Public Member Functions

 NoiseGenerator (double noiseValue=0.0001, bool gauss=true)
 Constructor.
 
 ~NoiseGenerator ()=default
 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 noise_threshold_ {4}
 The noise threshold.
 
double noise_ {1}
 Mean noise.
 
double pedestal_ {0}
 Pedestal or baseline.
 
bool use_gaussian_model_ {true}
 Gaussian flag.
 
std::unique_ptr< boost::math::poisson_distribution<> > poisson_dist_
 pdf for poisson errors
 

Detailed Description

Definition at line 33 of file NoiseGenerator.h.

Constructor & Destructor Documentation

◆ NoiseGenerator()

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

Constructor.

Definition at line 11 of file NoiseGenerator.cxx.

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

References noise_, poisson_dist_, and use_gaussian_model_.

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 22 of file NoiseGenerator.cxx.

22 {
23 if (random_.get() == nullptr) {
24 EXCEPTION_RAISE("RandomSeedException",
25 "Noise generator was not seeded before use");
26 }
27 ldmx_log(trace) << "Empty channels: " << emptyChannels;
28 ldmx_log(trace) << "Normalized integration limit: " << noise_threshold_;
29
30 double integral;
32 integral = ROOT::Math::normal_cdf_c(noise_threshold_, noise_, pedestal_);
33 else
34 integral =
35 boost::math::cdf(complement(*poisson_dist_, noise_threshold_ - 1));
36 ldmx_log(trace) << "Integral: " << integral;
37
38 double noise_hit_count = random_->Binomial(emptyChannels, integral);
39 ldmx_log(trace) << "# Noise hits_: " << noise_hit_count;
40
41 std::vector<double> noise_hits;
42 for (int hit_index = 0; hit_index < noise_hit_count; ++hit_index) {
43 double rand = random_->Uniform();
44 ldmx_log(trace) << "Rand: " << rand;
45 double draw = integral * rand;
46 ldmx_log(trace) << "Draw: " << draw;
47
48 double cumulative_prob = 1.0 - integral + draw;
49 ldmx_log(trace) << "Cumulative probability: " << cumulative_prob;
50
51 double value_above_threshold;
53 value_above_threshold =
54 ROOT::Math::gaussian_quantile(cumulative_prob, noise_);
55 } else {
56 value_above_threshold =
57 boost::math::quantile(*poisson_dist_, cumulative_prob);
58 }
59 ldmx_log(trace) << "Noise value: " << value_above_threshold;
60
61 noise_hits.push_back(value_above_threshold);
62 }
63
64 return noise_hits;
65}
double pedestal_
Pedestal or baseline.
std::unique_ptr< TRandom3 > random_
Random number generator.
double noise_threshold_
The noise threshold.

References noise_, noise_threshold_, pedestal_, poisson_dist_, random_, and use_gaussian_model_.

◆ hasSeed()

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

Has been seeded?

Definition at line 45 of file NoiseGenerator.h.

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

References random_.

◆ seedGenerator()

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

Seed the generator.

Definition at line 18 of file NoiseGenerator.cxx.

18 {
19 random_ = std::make_unique<TRandom3>(seed);
20}

References random_.

◆ setNoise()

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

Set the mean noise.

Definition at line 62 of file NoiseGenerator.h.

62{ noise_ = noise; };

References noise_.

◆ setNoiseThreshold()

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

Set the noise threshold.

Definition at line 57 of file NoiseGenerator.h.

57 {
58 noise_threshold_ = noiseThreshold;
59 }

References noise_threshold_.

◆ setPedestal()

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

Set the pedestal.

Definition at line 65 of file NoiseGenerator.h.

65{ pedestal_ = pedestal; };

References pedestal_.

Member Data Documentation

◆ noise_

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

Mean noise.

Definition at line 75 of file NoiseGenerator.h.

75{1};

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

◆ noise_threshold_

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

The noise threshold.

Definition at line 72 of file NoiseGenerator.h.

72{4};

Referenced by generateNoiseHits(), and setNoiseThreshold().

◆ pedestal_

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

Pedestal or baseline.

Definition at line 78 of file NoiseGenerator.h.

78{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 84 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 69 of file NoiseGenerator.h.

69{nullptr};

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

◆ use_gaussian_model_

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

Gaussian flag.

Definition at line 81 of file NoiseGenerator.h.

81{true};

Referenced by generateNoiseHits(), and NoiseGenerator().


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