All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SBNDThermalNoiseServiceInTime Class Reference

#include <SBNDThermalNoiseServiceInTime.h>

Inheritance diagram for SBNDThermalNoiseServiceInTime:
ChannelNoiseService

Public Member Functions

 SBNDThermalNoiseServiceInTime (fhicl::ParameterSet const &pset)
 
 SBNDThermalNoiseServiceInTime (fhicl::ParameterSet const &pset, art::ActivityRegistry &)
 
 ~SBNDThermalNoiseServiceInTime ()
 
int addNoise (detinfo::DetectorClocksData const &clockData, Channel chan, AdcSignalVector &sigs) const override
 
std::ostream & print (std::ostream &out=std::cout, std::string prefix="") const override
 
- Public Member Functions inherited from ChannelNoiseService
virtual ~ChannelNoiseService ()=default
 
virtual void generateNoise (detinfo::DetectorClocksData const &)
 

Private Member Functions

void InitialiseProducerDeps (art::EDProducer *EDProdPointer, fhicl::ParameterSet const &pset) override
 

Private Attributes

unsigned int fNoiseArrayPoints
 number of points in randomly generated noise array More...
 
int fRandomSeed
 Seed for random number service. If absent or zero, use SeedSvc. More...
 
int fLogLevel
 Log message level: 0=quiet, 1=init only, 2+=every event. More...
 
std::map< double, int > fShapingTimeOrder
 
CLHEP::HepRandomEngine * m_pran
 
CLHEP::HepRandomEngine * fNoiseEngine
 

Additional Inherited Members

- Public Types inherited from ChannelNoiseService
typedef unsigned int Channel
 

Detailed Description

Definition at line 46 of file SBNDThermalNoiseServiceInTime.h.

Constructor & Destructor Documentation

SBNDThermalNoiseServiceInTime::SBNDThermalNoiseServiceInTime ( fhicl::ParameterSet const &  pset)

Definition at line 21 of file SBNDThermalNoiseServiceInTime_service.cc.

21  : fRandomSeed(0), fLogLevel(1),
22  m_pran(nullptr), fNoiseEngine(nullptr)
23  {
24 
25  const string myname = "SBNDThermalNoiseServiceInTime::ctor: ";
26  fNoiseArrayPoints = pset.get<unsigned int>("NoiseArrayPoints",1);
27  bool haveSeed = pset.get_if_present<int>("RandomSeed", fRandomSeed);
28 
29  fShapingTimeOrder = { {0.5, 0 }, {1.0, 1}, {2.0, 2}, {3.0, 3} };
30 
31  if ( fRandomSeed == 0 ) haveSeed = false;
32  pset.get_if_present<int>("LogLevel", fLogLevel);
33  int seed = fRandomSeed;
34 
35  string rname = "SBNDThermalNoiseServiceInTime";
36  if ( haveSeed ) {
37  if ( fLogLevel > 0 ) cout << myname << "WARNING: Using hardwired seed." << endl;
38  m_pran = new HepJamesRandom(seed);
39  } else {
40  if ( fLogLevel > 0 ) cout << myname << "Using NuRandomService." << endl;
41  art::ServiceHandle<NuRandomService> seedSvc;
42  m_pran = new HepJamesRandom;
43  if ( fLogLevel > 0 ) cout << myname << " Initial seed: " << m_pran->getSeed() << endl;
44  seedSvc->registerEngine(NuRandomService::CLHEPengineSeeder(m_pran), rname);
45  }
46  if ( fLogLevel > 0 ) cout << myname << " Registered seed: " << m_pran->getSeed() << endl;
47  if ( fLogLevel > 1 ) print() << endl;
48 }
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
unsigned int fNoiseArrayPoints
number of points in randomly generated noise array
unsigned int seed
int fRandomSeed
Seed for random number service. If absent or zero, use SeedSvc.
BEGIN_PROLOG could also be cout
SBNDThermalNoiseServiceInTime::SBNDThermalNoiseServiceInTime ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry &   
)

Definition at line 53 of file SBNDThermalNoiseServiceInTime_service.cc.

SBNDThermalNoiseServiceInTime(fhicl::ParameterSet const &pset)
SBNDThermalNoiseServiceInTime::~SBNDThermalNoiseServiceInTime ( )

Definition at line 58 of file SBNDThermalNoiseServiceInTime_service.cc.

58  {
59  const string myname = "SBNDThermalNoiseServiceInTime::dtor: ";
60  if ( fLogLevel > 0 ) {
61  cout << myname << "Deleting random engine with seed " << m_pran->getSeed() << endl;
62  }
63  delete m_pran;
64 }
int fLogLevel
Log message level: 0=quiet, 1=init only, 2+=every event.
BEGIN_PROLOG could also be cout

Member Function Documentation

int SBNDThermalNoiseServiceInTime::addNoise ( detinfo::DetectorClocksData const &  clockData,
Channel  chan,
AdcSignalVector sigs 
) const
overridevirtual

Implements ChannelNoiseService.

Definition at line 68 of file SBNDThermalNoiseServiceInTime_service.cc.

69  {
70 
71  //Get services.
72  art::ServiceHandle<geo::Geometry> geo;
73  art::ServiceHandle<util::SignalShapingServiceSBND> sss;
74 
75  //Generate Noise:
76  size_t view = (size_t)geo->View(chan);
77 
78  double noise_factor;
79  auto tempNoiseVec = sss->GetNoiseFactVec();
80  double shapingTime = 2.0; //sss->GetShapingTime(chan);
81  double asicGain = sss->GetASICGain(chan);
82 
83  if (fShapingTimeOrder.find( shapingTime ) != fShapingTimeOrder.end() ) {
84  noise_factor = tempNoiseVec[view].at( fShapingTimeOrder.find( shapingTime )->second );
85  noise_factor *= asicGain/4.7;
86  }
87  else {
88  throw cet::exception("SBNDThermalNoiseServiceInTime_service")
89  << "\033[93m"
90  << "Shaping Time recieved from signalshapingservices_sbnd.fcl is not one of the allowed values"
91  << std::endl
92  << "Allowed values: 0.5, 1.0, 2.0, 3.0 us"
93  << "\033[00m"
94  << std::endl;
95  }
96 
97  CLHEP::RandGaussQ rGauss(*fNoiseEngine, 0.0, noise_factor);
98 
99 
100  //In this case fNoiseFact is a value in ADC counts
101  //It is going to be the Noise RMS
102  //loop over all bins in "noise" vector
103  //and insert random noise value
104 
105  for (unsigned int i = 0; i < sigs.size(); i++){
106  sigs.at(i) = rGauss.fire();
107  }
108 
109  return 0;
110 }
void SBNDThermalNoiseServiceInTime::InitialiseProducerDeps ( art::EDProducer *  EDProdPointer,
fhicl::ParameterSet const &  pset 
)
inlineoverrideprivatevirtual

Reimplemented from ChannelNoiseService.

Definition at line 79 of file SBNDThermalNoiseServiceInTime.h.

79  {
80 
81  CLHEP::HepRandomEngine& NoiseEngine((art::ServiceHandle<rndm::NuRandomService>{}->createEngine(*EDProdPointer,"HepJamesRandom","noise",pset,"Seed")));
82  fNoiseEngine = &NoiseEngine;
83  return;
84  }
ostream & SBNDThermalNoiseServiceInTime::print ( std::ostream &  out = std::cout,
std::string  prefix = "" 
) const
overridevirtual

Implements ChannelNoiseService.

Definition at line 115 of file SBNDThermalNoiseServiceInTime_service.cc.

115  {
116  out << prefix << "SBNDThermalNoiseServiceInTime: " << endl;
117 
118  out << prefix << " LogLevel: " << fLogLevel << endl;
119  out << prefix << " RandomSeed: " << fRandomSeed << endl;
120  out << prefix << " NoiseArrayPoints: " << fNoiseArrayPoints << endl;
121 
122  return out;
123 }
int fLogLevel
Log message level: 0=quiet, 1=init only, 2+=every event.
unsigned int fNoiseArrayPoints
number of points in randomly generated noise array
int fRandomSeed
Seed for random number service. If absent or zero, use SeedSvc.

Member Data Documentation

int SBNDThermalNoiseServiceInTime::fLogLevel
private

Log message level: 0=quiet, 1=init only, 2+=every event.

Definition at line 71 of file SBNDThermalNoiseServiceInTime.h.

unsigned int SBNDThermalNoiseServiceInTime::fNoiseArrayPoints
private

number of points in randomly generated noise array

Definition at line 69 of file SBNDThermalNoiseServiceInTime.h.

CLHEP::HepRandomEngine* SBNDThermalNoiseServiceInTime::fNoiseEngine
private

Definition at line 76 of file SBNDThermalNoiseServiceInTime.h.

int SBNDThermalNoiseServiceInTime::fRandomSeed
private

Seed for random number service. If absent or zero, use SeedSvc.

Definition at line 70 of file SBNDThermalNoiseServiceInTime.h.

std::map< double, int > SBNDThermalNoiseServiceInTime::fShapingTimeOrder
private

Definition at line 72 of file SBNDThermalNoiseServiceInTime.h.

CLHEP::HepRandomEngine* SBNDThermalNoiseServiceInTime::m_pran
private

Definition at line 75 of file SBNDThermalNoiseServiceInTime.h.


The documentation for this class was generated from the following files: