7 #include "art/Framework/Services/Registry/ServiceDefinitionMacros.h"
13 using std::ostringstream;
14 using rndm::NuRandomService;
15 using CLHEP::HepJamesRandom;
16 using CLHEP::HepRandomEngine;
22 m_pran(nullptr), fNoiseEngine(nullptr)
25 const string myname =
"SBNDThermalNoiseServiceInTime::ctor: ";
27 bool haveSeed = pset.get_if_present<
int>(
"RandomSeed",
fRandomSeed);
32 pset.get_if_present<
int>(
"LogLevel",
fLogLevel);
35 string rname =
"SBNDThermalNoiseServiceInTime";
37 if (
fLogLevel > 0 )
cout << myname <<
"WARNING: Using hardwired seed." << endl;
38 m_pran =
new HepJamesRandom(seed);
40 if (
fLogLevel > 0 )
cout << myname <<
"Using NuRandomService." << endl;
41 art::ServiceHandle<NuRandomService> seedSvc;
42 m_pran =
new HepJamesRandom;
44 seedSvc->registerEngine(NuRandomService::CLHEPengineSeeder(
m_pran), rname);
59 const string myname =
"SBNDThermalNoiseServiceInTime::dtor: ";
61 cout << myname <<
"Deleting random engine with seed " <<
m_pran->getSeed() << endl;
72 art::ServiceHandle<geo::Geometry> geo;
73 art::ServiceHandle<util::SignalShapingServiceSBND> sss;
76 size_t view = (size_t)geo->View(chan);
79 auto tempNoiseVec = sss->GetNoiseFactVec();
80 double shapingTime = 2.0;
81 double asicGain = sss->GetASICGain(chan);
84 noise_factor = tempNoiseVec[view].at(
fShapingTimeOrder.find( shapingTime )->second );
85 noise_factor *= asicGain/4.7;
88 throw cet::exception(
"SBNDThermalNoiseServiceInTime_service")
90 <<
"Shaping Time recieved from signalshapingservices_sbnd.fcl is not one of the allowed values"
92 <<
"Allowed values: 0.5, 1.0, 2.0, 3.0 us"
97 CLHEP::RandGaussQ rGauss(*
fNoiseEngine, 0.0, noise_factor);
105 for (
unsigned int i = 0; i < sigs.size(); i++){
106 sigs.at(i) = rGauss.fire();
116 out << prefix <<
"SBNDThermalNoiseServiceInTime: " << endl;
118 out << prefix <<
" LogLevel: " <<
fLogLevel << endl;
119 out << prefix <<
" RandomSeed: " <<
fRandomSeed << endl;
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)
std::map< double, int > fShapingTimeOrder
unsigned int fNoiseArrayPoints
number of points in randomly generated noise array
~SBNDThermalNoiseServiceInTime()
CLHEP::HepRandomEngine * m_pran
int addNoise(detinfo::DetectorClocksData const &clockData, Channel chan, AdcSignalVector &sigs) const override
std::vector< AdcSignal > AdcSignalVector
Contains all timing reference information for the detector.
CLHEP::HepRandomEngine * fNoiseEngine
int fRandomSeed
Seed for random number service. If absent or zero, use SeedSvc.
BEGIN_PROLOG could also be cout