Public Member Functions | Private Attributes | List of all members
WhiteChannelNoiseService Class Reference

#include <WhiteChannelNoiseService.h>

Inheritance diagram for WhiteChannelNoiseService:
ChannelNoiseService

Public Member Functions

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

Private Attributes

int m_RandomSeed
 
int m_LogLevel
 
TH1 * fNoiseHist
 distribution of noise counts More...
 
CLHEP::HepRandomEngine * m_pran
 

Additional Inherited Members

- Public Types inherited from ChannelNoiseService
typedef unsigned int Channel
 

Detailed Description

Definition at line 23 of file WhiteChannelNoiseService.h.

Constructor & Destructor Documentation

WhiteChannelNoiseService::WhiteChannelNoiseService ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry  
)

Definition at line 23 of file WhiteChannelNoiseService_service.cc.

24 : m_RandomSeed(0), m_LogLevel(1),
25  fNoiseHist(nullptr),
26  m_pran(nullptr) {
27  const string myname = "WhiteChannelNoiseService::ctor: ";
28  // Fetch parameters.
29  bool haveSeed = pset.get_if_present<int>("RandomSeed", m_RandomSeed);
30  pset.get_if_present<int>("LogLevel", m_LogLevel);
31  if ( m_RandomSeed == 0 ) haveSeed = false;
32  // Create random number engine.
33  if ( haveSeed ) {
34  if ( m_LogLevel > 0 ) cout << myname << "WARNING: Using hardwired seed." << endl;
35  m_pran = new HepJamesRandom(m_RandomSeed);
36  } else {
37  string rname = "WhiteChannelNoiseService";
38  if ( m_LogLevel > 0 ) cout << myname << "Using NuRandomService." << endl;
40  m_pran = new HepJamesRandom;
41  if ( m_LogLevel > 0 ) cout << myname << " Initial seed: " << m_pran->getSeed() << endl;
42  seedSvc->registerEngine(NuRandomService::CLHEPengineSeeder(m_pran), rname);
43  }
44  if ( m_LogLevel > 0 ) cout << myname << " Registered seed: " << m_pran->getSeed() << endl;
46  fNoiseHist = tfs->make<TH1F>("Noise", ";Noise (ADC);", 1000, -10., 10.);
47 }
TH1 * fNoiseHist
distribution of noise counts
CLHEP::HepRandomEngine * m_pran
QTextStream & endl(QTextStream &s)
WhiteChannelNoiseService::~WhiteChannelNoiseService ( )

Definition at line 51 of file WhiteChannelNoiseService_service.cc.

51  {
52  const string myname = "WhiteChannelNoiseService::dtor: ";
53  if ( m_LogLevel > 0 ) {
54  cout << myname << "Deleting random engine with seed " << m_pran->getSeed() << endl;
55  }
56  delete m_pran;
57 }
CLHEP::HepRandomEngine * m_pran
QTextStream & endl(QTextStream &s)

Member Function Documentation

int WhiteChannelNoiseService::addNoise ( detinfo::DetectorClocksData const &  clockData,
detinfo::DetectorPropertiesData const &  detProp,
Channel  chan,
AdcSignalVector sigs 
) const
virtual

Implements ChannelNoiseService.

Definition at line 61 of file WhiteChannelNoiseService_service.cc.

63  {
65  float fASICGain = sss->GetASICGain(chan);
66  double fShapingTime = sss->GetShapingTime(chan);
67  std::map< double, int > fShapingTimeOrder;
68  fShapingTimeOrder = { {0.5, 0}, {1.0, 1}, {2.0, 2}, {3.0, 3} };
69  DoubleVec fNoiseFactVec;
70  auto tempNoiseVec = sss->GetNoiseFactVec();
71  if ( fShapingTimeOrder.find(fShapingTime) != fShapingTimeOrder.end() ) {
72  size_t i = 0;
73  fNoiseFactVec.resize(2);
74  for ( auto& item : tempNoiseVec ) {
75  fNoiseFactVec[i] = item.at(fShapingTimeOrder.find( fShapingTime )->second);
76  fNoiseFactVec[i] *= fASICGain/4.7;
77  ++i;
78  }
79  } else {
80  throw cet::exception("WhiteChannelNoiseService")
81  << "\033[93m"
82  << "Shaping Time received from signalservices_dune.fcl is not one of allowed values"
83  << std::endl
84  << "Allowed values: 0.5, 1.0, 2.0, 3.0 usec"
85  << "\033[00m"
86  << std::endl;
87  }
89  const geo::View_t view = geo->View(chan);
90  CLHEP::HepRandomEngine& engine = *m_pran;
91  CLHEP::RandGaussQ rGauss_Ind(engine, 0.0, fNoiseFactVec[0]);
92  CLHEP::RandGaussQ rGauss_Col(engine, 0.0, fNoiseFactVec[1]);
93  for ( AdcSignal& sig : sigs ) {
94  double tnoise = 0.0;
95  if ( view==geo::kU ) tnoise = rGauss_Ind.fire();
96  else if ( view==geo::kV ) tnoise = rGauss_Ind.fire();
97  else tnoise = rGauss_Col.fire();
98  sig += tnoise;
99  }
100  return 0;
101 }
double GetShapingTime(Channel channel) const override
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Planes which measure V.
Definition: geo_types.h:130
float AdcSignal
Definition: AdcTypes.h:21
std::vector< DoubleVec > GetNoiseFactVec() const override
Planes which measure U.
Definition: geo_types.h:129
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
CLHEP::HepRandomEngine * m_pran
double GetASICGain(Channel channel) const override
LArSoft geometry interface.
Definition: ChannelGeo.h:16
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
std::vector< double > DoubleVec
ostream & WhiteChannelNoiseService::print ( std::ostream &  out = std::cout,
std::string  prefix = "" 
) const
virtual

Implements ChannelNoiseService.

Definition at line 105 of file WhiteChannelNoiseService_service.cc.

105  {
106  string myprefix = prefix + " ";
107  out << myprefix << " Random seed: " << m_pran->getSeed() << endl;
108  return out;
109 }
CLHEP::HepRandomEngine * m_pran
QTextStream & endl(QTextStream &s)

Member Data Documentation

TH1* WhiteChannelNoiseService::fNoiseHist
private

distribution of noise counts

Definition at line 48 of file WhiteChannelNoiseService.h.

int WhiteChannelNoiseService::m_LogLevel
private

Definition at line 45 of file WhiteChannelNoiseService.h.

CLHEP::HepRandomEngine* WhiteChannelNoiseService::m_pran
private

Definition at line 50 of file WhiteChannelNoiseService.h.

int WhiteChannelNoiseService::m_RandomSeed
private

Definition at line 44 of file WhiteChannelNoiseService.h.


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