DPhaseRealisticNoiseService.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 // DPhaseRealisticNoiseService
3 //
4 // Andrea Scarpelli (andrea.scarpelli@cern.ch)
5 // October 2017
6 //
7 // Implementation of realistic noise from frequency spectrum in 3x1x1 data
8 // using same logic of ExponentialChannelNoiseService
9 ///////////////////////////////////////////////////////////////////////////////
10 
11 #ifndef DPhaseRealisticNoiseService_H
12 #define DPhaseRealisticNoiseService_H
13 
15 #include <vector>
16 #include <iostream>
17 
18 namespace detinfo {
19  class DetectorClocksData;
20  class DetectorPropertiesData;
21 }
22 
23 class TH1;
24 namespace CLHEP {
25 class HepRandomEngine;
26 }
27 
29 
30 public:
31 
32  // Ctor.
34 
35  // Ctor.
37 
38  // Dtor.
40 
41  // Add noise to a signal array.
42  int addNoise(detinfo::DetectorClocksData const& clockData,
43  detinfo::DetectorPropertiesData const& detProp,
44  Channel chan, AdcSignalVector& sigs) const;
45 
46  // Print the configuration.
47  std::ostream& print(std::ostream& out =std::cout, std::string prefix ="") const;
48 
49  // Fill a noise vector.
50  // Input vector contents are lost.
51  // The size of the vector is obtained from the FFT service.
52  void generateNoise(detinfo::DetectorPropertiesData const& detProp,
53  std::vector<double> frequencyVector, AdcSignalVector& noise,
54  TH1* aNoiseHist, double customRandom);
55 
56 private:
57 
58  //tool getters for use the model size everywhere in the code
59  unsigned int GetModelSize() const;
60 
61  //tool setter for use the model size everywhere in the code
62  void SetModelSize(unsigned int size);
63 
64  // Tool function used mirrorWaveform();
65  double GetShift(AdcSignalVector time_vector, int window_length) const;
66 
67  // Tool producing associations between channels and semi-random phase;
68  void Chan2Phase(std::map<Channel, double> &PhaseChannelMap) const;
69 
70  // Fill the noise vectors.
71  void generateNoise(detinfo::DetectorPropertiesData const& detProp);
72 
73  //Mirror the output waveform to match geometries dofferent from 3x1x1 geo
74  void mirrorWaveform(AdcSignalVector& noise, int TimeSamples) const;
75 
76  //import a model of realistic noise fft from a root file
77  //Store it in an array for each view
78  void importNoiseModel(std::string noiseModel, std::vector<double> & frequencyArrayX,
79  std::vector<double> & frequencyArrayY) const;
80 
81  // Parameters.
82  std::string fNoiseModel; ///< noise model root file
83  unsigned int fNoiseArrayPoints; ///< number of points in randomly generated noise array
84  double fRandomizeX; ///< randomization of the average frequency spectrum (on kX or kZ)
85  double fRandomizeY; ///<< randomization of the average frequency spectrum (on kY)
86  double fSmooth;
87  bool fSetFirst0; ///<< set the first bin of the frequency array to 0
88  bool fSetBaseline; ///<< Sum baseline model to the data
89  bool fOldNoiseIndex; ///< Use old selection of noise array index
90  int fRandomSeed; ///< Seed for random number service. If absent or zero, use SeedSvc.
91  int fLogLevel; ///< Log message level: 0=quiet, 1=init only, 2+=every event
92 
93  //frequency arrays imported
94  std::vector<double> fNoiseModelFrequenciesX; ///< Array storing the frequencies imported from the model in kHz for plane kX (kZ)
95  std::vector<double> fNoiseModelFrequenciesY; ///< Array storing the frequencies imported from the model in kHz for plane kY (kZ)
96 
97  // Noise arrays.
98  AdcSignalVectorVector fNoiseX; ///< noise on each channel for each time for X plane
99  AdcSignalVectorVector fNoiseY; ///< noise on each channel for each time for Y plane
100 
101  // Histograms.
102  //TH1* fNoiseHist; ///< distribution of noise counts // unused
103  TH1* fNoiseHistX; ///< distribution of noise counts for X
104  TH1* fNoiseHistY; ///< distribution of noise counts for Y
105  TH1* fNoiseChanHist; ///< distribution of accessed noise samples
106 
107  //more
108  //double fPhase; // unused
109  unsigned int fModelsize;
110 
111  CLHEP::HepRandomEngine* m_pran;
112 
113 };
114 
116 
117 #endif
TH1 * fNoiseHistY
distribution of noise counts for Y
AdcSignalVectorVector fNoiseX
noise on each channel for each time for X plane
TH1 * fNoiseHistX
distribution of noise counts for X
bool fSetBaseline
< Sum baseline model to the data
std::string string
Definition: nybbler.cc:12
DECLARE_ART_SERVICE_INTERFACE_IMPL(MySharedService, art::test::MyServiceInterface, SHARED) DEFINE_ART_SERVICE_INTERFACE_IMPL(MySharedService
unsigned int fNoiseArrayPoints
number of points in randomly generated noise array
double fRandomizeY
< randomization of the average frequency spectrum (on kY)
double fRandomizeX
randomization of the average frequency spectrum (on kX or kZ)
int fRandomSeed
Seed for random number service. If absent or zero, use SeedSvc.
AdcSignalVectorVector fNoiseY
noise on each channel for each time for Y plane
int fLogLevel
Log message level: 0=quiet, 1=init only, 2+=every event.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
TH1 * fNoiseChanHist
distribution of accessed noise samples
std::string fNoiseModel
noise model root file
General LArSoft Utilities.
std::vector< double > fNoiseModelFrequenciesX
Array storing the frequencies imported from the model in kHz for plane kX (kZ)
bool fOldNoiseIndex
Use old selection of noise array index.
Contains all timing reference information for the detector.
std::vector< AdcSignalVector > AdcSignalVectorVector
Definition: AdcTypes.h:23
std::vector< double > fNoiseModelFrequenciesY
Array storing the frequencies imported from the model in kHz for plane kY (kZ)
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
bool fSetFirst0
< set the first bin of the frequency array to 0