All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RandomNoise_tool.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file RandomNoise.cc
3 /// \author F. Varanini
4 ////////////////////////////////////////////////////////////////////////
5 
6 #include <cmath>
7 #include "IGenNoise.h"
8 #include "art/Utilities/ToolMacros.h"
9 #include "messagefacility/MessageLogger/MessageLogger.h"
10 #include "cetlib_except/exception.h"
11 
12 // art extensions
13 #include "nurandom/RandomUtils/NuRandomService.h"
14 
15 // CLHEP libraries
16 #include "CLHEP/Random/RandFlat.h"
17 #include "CLHEP/Random/RandGaussQ.h"
18 
19 #include <fstream>
20 
21 namespace icarus_tool
22 {
23 
25 {
26 public:
27  explicit RandomNoise(const fhicl::ParameterSet& pset);
28 
29  ~RandomNoise();
30 
31  void configure(const fhicl::ParameterSet& pset) override;
32 
33  void nextEvent() override {return;};
34 
35  void generateNoise(CLHEP::HepRandomEngine& engine,
36  CLHEP::HepRandomEngine&,
39  double,
40  const geo::PlaneID&,
41  unsigned int) override;
42 
43 private:
44  // Member variables from the fhicl file
46  std::string fHistogramName;
47 
48  // We'll recover the bin contents and store in a vector
49  // with the likely false hope this will be faster...
50  std::vector<double> fNoiseHistVec;
51 };
52 
53 //----------------------------------------------------------------------
54 // Constructor.
55 RandomNoise::RandomNoise(const fhicl::ParameterSet& pset)
56 {
57  configure(pset);
58 }
59 
61 {
62 }
63 
64 void RandomNoise::configure(const fhicl::ParameterSet& pset)
65 {
66 
67  return;
68 }
69 
70 void RandomNoise::generateNoise(CLHEP::HepRandomEngine& engine,
71  CLHEP::HepRandomEngine&,
72  icarusutil::TimeVec& noise,
74  double noise_factor,
75  const geo::PlaneID&,
76  unsigned int)
77 {
78  CLHEP::RandGaussQ rGauss(engine, 0.0, noise_factor);
79 
80  //In this case noise_factor is a value in ADC counts
81  //It is going to be the Noise RMS
82  //loop over all bins in "noise" vector
83  //and insert random noise value
84  for (unsigned int i=0; i<noise.size(); i++)
85  noise.at(i) = rGauss.fire();
86 
87  return;
88 }
89 
90 DEFINE_ART_CLASS_TOOL(RandomNoise)
91 }
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
RandomNoise(const fhicl::ParameterSet &pset)
std::vector< SigProcPrecision > TimeVec
void generateNoise(CLHEP::HepRandomEngine &engine, CLHEP::HepRandomEngine &, icarusutil::TimeVec &, detinfo::DetectorPropertiesData const &, double, const geo::PlaneID &, unsigned int) override
std::vector< double > fNoiseHistVec
void configure(const fhicl::ParameterSet &pset) override
This is the interface class for a tool to handle a GenNoise for the overall response.