All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SBNDThermalNoiseServiceInTime.h
Go to the documentation of this file.
1 // SBNDThermalNoiseService_InTime.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 (random) noise model, and adds it to the channel in time.
7 //
8 // The default parameters set in: sbndcode/DetectorSim/Services/noiseservice_sbnd.fcl
9 //
10 
11 #ifndef SBNDThermalNoiseServiceInTime_H
12 #define SBNDThermalNoiseServiceInTime_H
13 
15 
16 #include "fhiclcpp/ParameterSet.h"
17 #include "art/Framework/Services/Registry/ServiceHandle.h"
18 #include "art/Framework/Services/Registry/ServiceDeclarationMacros.h"
19 #include "art_root_io/TFileService.h"
23 #include "nurandom/RandomUtils/NuRandomService.h"
25 namespace detinfo { class DetectorClocksData; }
26 
27 #include "CLHEP/Random/RandFlat.h"
28 #include "CLHEP/Random/RandGaussQ.h"
29 #include "CLHEP/Random/JamesRandom.h"
30 #include "CLHEP/Random/RandomEngine.h"
31 
32 #include "TH1F.h"
33 #include "TRandom3.h"
34 #include "TF1.h"
35 #include "TMath.h"
36 
37 #include <vector>
38 #include <iostream>
39 #include <sstream>
40 
41 class TH1;
42 namespace CLHEP {
43 class HepRandomEngine;
44 }
45 
47 
48 public:
49 
50  // Ctor.
51  SBNDThermalNoiseServiceInTime(fhicl::ParameterSet const& pset);
52 
53  // Ctor.
54  SBNDThermalNoiseServiceInTime(fhicl::ParameterSet const& pset, art::ActivityRegistry&);
55 
56  // Dtor.
58 
59  // Add noise to a signal array.
60  int addNoise(detinfo::DetectorClocksData const& clockData,
61  Channel chan, AdcSignalVector& sigs) const override;
62 
63  // Print the configuration.
64  std::ostream& print(std::ostream& out =std::cout, std::string prefix ="") const override;
65 
66 private:
67 
68  // General parameters
69  unsigned int fNoiseArrayPoints; ///< number of points in randomly generated noise array
70  int fRandomSeed; ///< Seed for random number service. If absent or zero, use SeedSvc.
71  int fLogLevel; ///< Log message level: 0=quiet, 1=init only, 2+=every event
72  std::map< double, int > fShapingTimeOrder;
73 
74  // Declare noise engines.
75  CLHEP::HepRandomEngine* m_pran;
76  CLHEP::HepRandomEngine* fNoiseEngine;
77 
78  //Function to allow use of noise engine in ChannelNoiseService setup.
79  void InitialiseProducerDeps(art::EDProducer * EDProdPointer, fhicl::ParameterSet const& pset) override{
80 
81  CLHEP::HepRandomEngine& NoiseEngine((art::ServiceHandle<rndm::NuRandomService>{}->createEngine(*EDProdPointer,"HepJamesRandom","noise",pset,"Seed")));
82  fNoiseEngine = &NoiseEngine;
83  return;
84  }
85 
86 };
87 
88 DECLARE_ART_SERVICE_INTERFACE_IMPL(SBNDThermalNoiseServiceInTime, ChannelNoiseService, LEGACY)
89 
90 #endif
int fLogLevel
Log message level: 0=quiet, 1=init only, 2+=every event.
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const override
SBNDThermalNoiseServiceInTime(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...
unsigned int fNoiseArrayPoints
number of points in randomly generated noise array
int addNoise(detinfo::DetectorClocksData const &clockData, Channel chan, AdcSignalVector &sigs) const override
std::vector< AdcSignal > AdcSignalVector
Contains all timing reference information for the detector.
int fRandomSeed
Seed for random number service. If absent or zero, use SeedSvc.
art framework interface to geometry description
BEGIN_PROLOG could also be cout