DPhaseCoherentNoiseService.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 // DPhaseCoherentNoiseService
3 //
4 // Andrea Scarpelli (mailto:andrea.scarpelli@cern.ch)
5 // August 2018
6 //
7 // Implementation of realistic noise from frequency spectrum in 3x1x1 data
8 // Phase and amplitude randomization following the correlation patterns seen in
9 // the 3x1x1 detector
10 //
11 ///////////////////////////////////////////////////////////////////////////////
12 
13 #ifndef DPhaseCoherentNoiseService_H
14 #define DPhaseCoherentNoiseService_H
15 
17 #include <vector>
18 #include <iostream>
19 
20 class TH1;
21 namespace CLHEP {
22 class HepRandomEngine;
23 }
24 
26 
27 public:
28 
29  //rename the most used std::map definition into Map
30  typedef std::map<int, std::vector< float >> Map;
31  typedef std::map<Channel, AdcSignalVector> Mask;
32 
33  //FFT frequency and amplitude maps
34  Map fChFrequencyMap; ///< Map storing the frequency vector for each channel
35  Map fChAmplitudeMap; ///< Map holding the amplitude of the frequency for each channel
36 
37  // Ctor.
39 
40  // Ctor.
42 
43  // Dtor.
45 
46  // Add noise to a signal array.
47  int addNoise(detinfo::DetectorClocksData const& clockData,
48  detinfo::DetectorPropertiesData const& detProp,
49  Channel chan, AdcSignalVector& sigs) const;
50 
51  // Print the configuration.
52  std::ostream& print(std::ostream& out =std::cout, std::string prefix ="") const;
53 
54 private:
55 
56  //
57  void getAmplitudeArray( Channel chan, std::vector<float> & array ) const;
58 
59  //
60  void getFrequencyArray( Channel chan, std::vector<float> & array ) const;
61 
62  //generate the array with phases
63  void makePhaseMap( Map & phaseMap, int size, float minShift, float maxShift);
64 
65  //get the correct map number (one new per event)
66  int getNumber( Channel chan ) const;
67 
68  //fill noise
69  void getNoiseArray(detinfo::DetectorClocksData const& clockData,
70  std::vector< float > & noiseArray,
71  std::vector< float > ampArray, std::vector< float > freqArray, std::vector< float > phaseArray, float randAmp ) const;
72 
73  void getPhases();
74 
75  //import a model of realistic noise fft from a root file
76  //Store it in an array for each view
77  void importNoiseModel(std::string noiseModel,
78  Map & chFrequencyMap, Map & chAmplitudeMap, double cut, int &normalization ) const;
79 
80  // Parameters.
81  std::string fNoiseModel; ///<< noise model root file
82  double fAmplitudeCut; ///<< only frequencies with amplitude above this cut will be considered
83  int fNormalization; ///<< Normalization factor ( similar to the one for the InFFT )
84  std::vector< float > fRandomize; ///<< randomization of the amplitude
85  std::vector< float > fPhaseShift; ///<< Phase shift for each group of 30 channels
86  std::vector<int> fChannelGroup; ///<< Channels in the same group get the same phase
87  std::vector< float > fInchoerentNoise; ///<< Mean and std of the incoherent noise
88  int fNumberOfPhases; ///<< Number of pregenerated phase shift maps
89  int fRandomSeed; ///<< Seed for random number service. If absent or zero, use SeedSvc.
90  int fLogLevel; ///<< Log message level: 0=quiet, 1=init only, 2+=every event
91 
92 
94  std::vector< Map > fPhaseMap; ///< Pregenerated phase shift maps
95  mutable int fNum=0; ///< Hold the correct event number
96 
97 
98  CLHEP::HepRandomEngine* m_pran;
99 
100 };
101 
103 
104 #endif
std::string fNoiseModel
< noise model root file
std::vector< float > fRandomize
< randomization of the amplitude
std::string string
Definition: nybbler.cc:12
int fLogLevel
< Log message level: 0=quiet, 1=init only, 2+=every event
int fNumberOfPhases
< Number of pregenerated phase shift maps
Map fChFrequencyMap
Map storing the frequency vector for each channel.
int fNormalization
< Normalization factor ( similar to the one for the InFFT )
DECLARE_ART_SERVICE_INTERFACE_IMPL(MySharedService, art::test::MyServiceInterface, SHARED) DEFINE_ART_SERVICE_INTERFACE_IMPL(MySharedService
std::vector< int > fChannelGroup
< Channels in the same group get the same phase
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
Map fChAmplitudeMap
Map holding the amplitude of the frequency for each channel.
std::vector< float > fInchoerentNoise
< Mean and std of the incoherent noise
int fRandomSeed
< Seed for random number service. If absent or zero, use SeedSvc.
auto array(Array const &a)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:228
Contains all timing reference information for the detector.
std::vector< Map > fPhaseMap
Pregenerated phase shift maps.
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
double fAmplitudeCut
< only frequencies with amplitude above this cut will be considered
std::vector< float > fPhaseShift
< Phase shift for each group of 30 channels
std::map< int, std::vector< float > > Map
std::map< Channel, AdcSignalVector > Mask