All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SBNDThermalNoiseServiceInFreq.h
Go to the documentation of this file.
1 // SBNDThermalNoiseServiceInFreq.h
2 // Andrew Scarff (University of Sheffield)
3 // July 2019
4 
5 // Based upon SPhaseChannelNoiseService.h created by Jingbo Wang (UC Davis) for ProtoDUNE.
6 // This Service runs the thermal noise model, but implemeted in frequency, not time.
7 //
8 // The default parameters set in: sbndcode/DetectorSim/Services/noiseservice_sbnd.fcl
9 //
10 
11 #ifndef SBNDThermalNoiseServiceInFreq_H
12 #define SBNDThermalNoiseServiceInFreq_H
13 
15 
16 #include "CLHEP/Random/RandFlat.h"
17 #include "CLHEP/Random/RandGaussQ.h"
18 #include "CLHEP/Random/JamesRandom.h"
19 #include "CLHEP/Random/RandomEngine.h"
20 
21 #include "fhiclcpp/ParameterSet.h"
22 #include "art/Framework/Services/Registry/ServiceHandle.h"
23 #include "art/Framework/Services/Registry/ServiceDeclarationMacros.h"
24 #include "art_root_io/TFileService.h"
29 #include "nurandom/RandomUtils/NuRandomService.h"
31 
32 #include "TH1F.h"
33 #include "TRandom3.h"
34 #include "TF1.h"
35 #include "TMath.h"
36 
37 #include <sstream>
38 #include <vector>
39 #include <iostream>
40 
41 
42 class TH1;
43 namespace CLHEP {
44 class HepRandomEngine;
45 }
46 
48 
49 public:
50 
51  // Ctor.
52  SBNDThermalNoiseServiceInFreq(fhicl::ParameterSet const& pset);
53 
54  // Ctor.
55  SBNDThermalNoiseServiceInFreq(fhicl::ParameterSet const& pset, art::ActivityRegistry&);
56 
57  // Dtor.
59 
60  // Add noise to a signal array.
61  int addNoise(detinfo::DetectorClocksData const& clockData,
62  Channel chan, AdcSignalVector& sigs) const override;
63 
64  // Print the configuration.
65  std::ostream& print(std::ostream& out =std::cout, std::string prefix ="") const override;
66 
67 private:
68 
69  // General parameters
70  unsigned int fNoiseArrayPoints; ///< number of points in randomly generated noise array
71  int fRandomSeed; ///< Seed for random number service. If absent or zero, use SeedSvc.
72  int fLogLevel; ///< Log message level: 0=quiet, 1=init only, 2+=every event
73  std::map< double, int > fShapingTimeOrder;
74  double fSampleRate;
75  double fNoiseWidth; ///< exponential noise width (kHz)
76  double fNoiseRand; ///< fraction of random "wiggle" in noise in freq. spectrum
77  double fLowCutoff; ///< low frequency filter cutoff (kHz)
78 
79  //Declare noise engines.
80  CLHEP::HepRandomEngine* m_pran;
81  CLHEP::HepRandomEngine* fNoiseEngine;
82 
83  // Function to allow use of noise engine in ChannelNoiseService setup.
84  void InitialiseProducerDeps(art::EDProducer * EDProdPointer, fhicl::ParameterSet const& pset) override{
85 
86  CLHEP::HepRandomEngine& NoiseEngine((art::ServiceHandle<rndm::NuRandomService>{}->createEngine(*EDProdPointer,"HepJamesRandom","noise",pset,"Seed")));
87  fNoiseEngine = &NoiseEngine;
88  return;
89  }
90 
91 };
92 
93 DECLARE_ART_SERVICE_INTERFACE_IMPL(SBNDThermalNoiseServiceInFreq, ChannelNoiseService, LEGACY)
94 
95 #endif
double fNoiseRand
fraction of random &quot;wiggle&quot; in noise in freq. spectrum
unsigned int fNoiseArrayPoints
number of points in randomly generated noise array
double fLowCutoff
low frequency filter cutoff (kHz)
SBNDThermalNoiseServiceInFreq(fhicl::ParameterSet const &pset)
void InitialiseProducerDeps(art::EDProducer *EDProdPointer, fhicl::ParameterSet const &pset) override
Service to provide microboone-specific signal shaping for simulation (convolution) and reconstruction...
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const override
int addNoise(detinfo::DetectorClocksData const &clockData, Channel chan, AdcSignalVector &sigs) const override
int fRandomSeed
Seed for random number service. If absent or zero, use SeedSvc.
double fNoiseWidth
exponential noise width (kHz)
std::vector< AdcSignal > AdcSignalVector
Contains all timing reference information for the detector.
art framework interface to geometry description
BEGIN_PROLOG could also be cout
int fLogLevel
Log message level: 0=quiet, 1=init only, 2+=every event.