SPhaseChannelNoiseService.h
Go to the documentation of this file.
1 // SPhaseChannelNoiseService
2 
3 // Jingbo Wang (jiowang@ucdavis.edu)
4 // March 2019
5 //
6 // Implementation of a general TPC channel noise model with:
7 // (1) white noise
8 // (2) Inherent Gaussian noise in frequency
9 // (3) MicroBooNE noise in frequency
10 // (4) Coherent noise (exponential + Gaussian) in frequency
11 // (Note a: phase at each frequency bin is randamized at the moment. Will be updated soon
12 // Note b: Currently, consecutive offline channels (configurable) are grouped together and
13 // the same coherent noise waveform is assigned to channels within the same group. )
14 //
15 // The default parameters are obtained from the ProtoDUNE-SP data (run 4096)
16 // fcl file: dunetpc/fcl/protodune/detsim/protoDUNE_detsim_data_driven_noise.fcl
17 //
18 
19 #ifndef SPhaseChannelNoiseService_H
20 #define SPhaseChannelNoiseService_H
21 
23 #include <vector>
24 #include <iostream>
25 
26 class TH1;
27 namespace CLHEP {
28 class HepRandomEngine;
29 }
30 
32 
33 public:
34 
35  // Ctor.
37 
38  // Ctor.
40 
41  // Dtor.
43 
44  // Add noise to a signal array.
45  int addNoise(detinfo::DetectorClocksData const&,
47  Channel chan, AdcSignalVector& sigs) const;
48 
49  // Print the configuration.
50  std::ostream& print(std::ostream& out =std::cout, std::string prefix ="") const;
51 
52 private:
53 
54  // Fill the noise vectors.
55  void generateNoise(detinfo::DetectorClocksData const& clockData);
56 
57  // Fill a noise vector.
58  // Input vector contents are lost.
59  // The size of the vector is obtained from the FFT service.
60  void generateMicroBooNoise(detinfo::DetectorClocksData const& clockData,
61  float wirelength, float ENOB,
62  AdcSignalVector& noise, TH1* aNoiseHist) const;
63  void generateGaussianNoise(detinfo::DetectorClocksData const& clockData,
64  AdcSignalVector& noise, std::vector<float> gausNorm,
65  std::vector<float> gausMean, std::vector<float> gausSigma,
66  TH1* aNoiseHist) const;
67  void generateCoherentNoise(detinfo::DetectorClocksData const& clockData,
68  AdcSignalVector& noise, std::vector<float> gausNorm,
69  std::vector<float> gausMean, std::vector<float> gausSigma,
70  float cohExpNorm, float cohExpWidth, float cohExpOffset,
71  TH1* aNoiseHist) const;
72 
73  // Make coherent groups
74  void makeCoherentGroupsByOfflineChannel(unsigned int nchpergroup);
75  std::vector<unsigned int> fChannelGroupMap; ///< assign each channel a group number
76  std::vector<int> fGroupCoherentNoiseMap; ///< assign each group a noise
77  unsigned int getGroupNumberFromOfflineChannel(unsigned int offlinechan) const;
78  unsigned int getCohNoiseChanFromGroup(unsigned int cohgroup) const;
79 
80  // General parameters
81  unsigned int fNoiseArrayPoints; ///< number of points in randomly generated noise array
82  int fRandomSeed; ///< Seed for random number service. If absent or zero, use SeedSvc.
83  int fLogLevel; ///< Log message level: 0=quiet, 1=init only, 2+=every event
84 
85  // Inherent White noise parameters
87  float fWhiteNoiseZ; ///< Level (per freq bin) for white noise for Z.
88  float fWhiteNoiseU; ///< Level (per freq bin) for white noise for U.
89  float fWhiteNoiseV; ///< Level (per freq bin) for white noise for V.
90 
91  // Inherent Gaussian noise
93  std::vector<float> fGausNormU; ///< noise scale factor for the gaussian component in coherent noise
94  std::vector<float> fGausMeanU; ///< mean of the gaussian component in coherent noise
95  std::vector<float> fGausSigmaU; ///< sigma of the gaussian component in coherent noise
96  std::vector<float> fGausNormV; ///< noise scale factor for the gaussian component in coherent noise
97  std::vector<float> fGausMeanV; ///< mean of the gaussian component in coherent noise
98  std::vector<float> fGausSigmaV; ///< sigma of the gaussian component in coherent noise
99  std::vector<float> fGausNormZ; ///< noise scale factor for the gaussian component in coherent noise
100  std::vector<float> fGausMeanZ; ///< mean of the gaussian component in coherent noise
101  std::vector<float> fGausSigmaZ; ///< sigma of the gaussian component in coherent noise
102 
103  // Inherent MicroBoone noise parameters
104  bool fEnableMicroBooNoise; ///< enable MicroBooNE noise model
105  float fENOB; ///< Effective number of bits
109  std::vector<float> fNoiseFunctionParameters; ///< Parameters in the MicroBooNE noise model
110 
111  // Coherent Noise parameters
114  unsigned int fExpNoiseArrayPoints; ///< number of points in randomly generated noise array
115  unsigned int fCohNoiseArrayPoints; ///< number of points in randomly generated noise array
116  float fCohExpNorm; ///< noise scale factor for the exponential component component in coherent noise
117  float fCohExpWidth; ///< width of the exponential component in coherent noise
118  float fCohExpOffset; ///< Amplitude offset of the exponential background component in coherent noise
119  std::vector<float> fCohGausNorm; ///< noise scale factor for the gaussian component in coherent noise
120  std::vector<float> fCohGausMean; ///< mean of the gaussian component in coherent noise
121  std::vector<float> fCohGausSigma; ///< sigma of the gaussian component in coherent noise
122 
123 
124  // Inherent Gausian noise arrays
128 
129  // Inherent MicroBoo noise arrays
133 
134  // Coherent Noise array.
135  AdcSignalVectorVector fCohNoise; ///< noise on each channel for each time for all planes
136 
137 
138  // Histograms.
139 
140  TH1* fGausNoiseHistZ; ///< distribution of noise counts for Z
141  TH1* fGausNoiseHistU; ///< distribution of noise counts for U
142  TH1* fGausNoiseHistV; ///< distribution of noise counts for V
143  TH1* fGausNoiseChanHist; ///< distribution of accessed noise samples
144 
145  TH1* fMicroBooNoiseHistZ; ///< distribution of noise counts for Z
146  TH1* fMicroBooNoiseHistU; ///< distribution of noise counts for U
147  TH1* fMicroBooNoiseHistV; ///< distribution of noise counts for V
148  TH1* fMicroBooNoiseChanHist; ///< distribution of accessed noise samples
149 
150  TH1* fCohNoiseHist; ///< distribution of noise counts
151  TH1* fCohNoiseChanHist; ///< distribution of accessed noise samples
152 
153  CLHEP::HepRandomEngine* m_pran;
154 
155 };
156 
158 
159 #endif
std::vector< float > fGausNormV
noise scale factor for the gaussian component in coherent noise
std::vector< float > fGausSigmaV
sigma of the gaussian component in coherent noise
AdcSignalVectorVector fMicroBooNoiseU
std::vector< float > fGausMeanV
mean of the gaussian component in coherent noise
std::vector< int > fGroupCoherentNoiseMap
assign each group a noise
std::string string
Definition: nybbler.cc:12
int fLogLevel
Log message level: 0=quiet, 1=init only, 2+=every event.
TH1 * fGausNoiseHistU
distribution of noise counts for U
TH1 * fGausNoiseHistZ
distribution of noise counts for Z
DECLARE_ART_SERVICE_INTERFACE_IMPL(MySharedService, art::test::MyServiceInterface, SHARED) DEFINE_ART_SERVICE_INTERFACE_IMPL(MySharedService
TH1 * fGausNoiseChanHist
distribution of accessed noise samples
unsigned int fNoiseArrayPoints
number of points in randomly generated noise array
std::vector< unsigned int > fChannelGroupMap
assign each channel a group number
unsigned int fCohNoiseArrayPoints
number of points in randomly generated noise array
AdcSignalVectorVector fMicroBooNoiseZ
float fCohExpOffset
Amplitude offset of the exponential background component in coherent noise.
std::vector< float > fGausMeanU
mean of the gaussian component in coherent noise
float fCohExpNorm
noise scale factor for the exponential component component in coherent noise
float fWhiteNoiseV
Level (per freq bin) for white noise for V.
std::vector< float > fNoiseFunctionParameters
Parameters in the MicroBooNE noise model.
std::vector< float > fGausSigmaZ
sigma of the gaussian component in coherent noise
float fWhiteNoiseZ
Level (per freq bin) for white noise for Z.
unsigned int fExpNoiseArrayPoints
number of points in randomly generated noise array
TH1 * fCohNoiseChanHist
distribution of accessed noise samples
CLHEP::HepRandomEngine * m_pran
TH1 * fMicroBooNoiseHistZ
distribution of noise counts for Z
std::vector< float > fGausNormU
noise scale factor for the gaussian component in coherent noise
std::vector< float > fCohGausMean
mean of the gaussian component in coherent noise
std::vector< float > fGausNormZ
noise scale factor for the gaussian component in coherent noise
bool fEnableMicroBooNoise
enable MicroBooNE noise model
std::vector< float > fGausSigmaU
sigma of the gaussian component in coherent noise
std::vector< float > fGausMeanZ
mean of the gaussian component in coherent noise
float fCohExpWidth
width of the exponential component in coherent noise
std::vector< float > fCohGausSigma
sigma of the gaussian component in coherent noise
AdcSignalVectorVector fCohNoise
noise on each channel for each time for all planes
TH1 * fMicroBooNoiseHistV
distribution of noise counts for V
std::vector< float > fCohGausNorm
noise scale factor for the gaussian component in coherent noise
TH1 * fGausNoiseHistV
distribution of noise counts for V
Contains all timing reference information for the detector.
std::vector< AdcSignalVector > AdcSignalVectorVector
Definition: AdcTypes.h:23
float fWhiteNoiseU
Level (per freq bin) for white noise for U.
int fRandomSeed
Seed for random number service. If absent or zero, use SeedSvc.
float fENOB
Effective number of bits.
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
TH1 * fMicroBooNoiseHistU
distribution of noise counts for U
AdcSignalVectorVector fMicroBooNoiseV
TH1 * fCohNoiseHist
distribution of noise counts
TH1 * fMicroBooNoiseChanHist
distribution of accessed noise samples