Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ShapedCohProtoDUNENoiseService Class Reference

#include <ShapedCohProtoDUNENoiseService.h>

Inheritance diagram for ShapedCohProtoDUNENoiseService:
ChannelNoiseService

Public Member Functions

 ShapedCohProtoDUNENoiseService (fhicl::ParameterSet const &)
 
 ShapedCohProtoDUNENoiseService (fhicl::ParameterSet const &, art::ActivityRegistry &)
 
 ~ShapedCohProtoDUNENoiseService ()
 
int addNoise (detinfo::DetectorClocksData const &, detinfo::DetectorPropertiesData const &, Channel, AdcSignalVector &) const
 
void newEvent ()
 
std::ostream & print (std::ostream &, std::string) const
 
- Public Member Functions inherited from ChannelNoiseService
virtual ~ChannelNoiseService ()=default
 

Protected Member Functions

int addFEMBNoise (const Channel, AdcSignalVector &, detinfo::DetectorClocksData const &) const
 
int addHVNoise (const Channel, AdcSignalVector &, detinfo::DetectorClocksData const &) const
 
int addShapedNoise (const Channel, AdcSignalVector &, detinfo::DetectorClocksData const &) const
 

Private Member Functions

void init ()
 

Private Attributes

CLHEP::HepRandomEngine * m_pran
 
art::ServiceHandle< geo::Geometrym_geo
 
double m_collection_plane_noise
 
double m_induction_plane_noise
 
double m_collection_plane_noise_rms
 
double m_induction_plane_noise_rms
 
std::map< size_t, size_t > m_channel_femb
 
bool m_random_phase
 
double m_frequency_rms
 
double m_amplitude_rms
 
std::vector< std::vector< double > > m_FEMBCo_Frq_nominal
 
std::vector< std::vector< double > > m_FEMBCo_Amp_nominal
 
std::vector< std::vector< double > > m_FEMBCo_Phs_nominal
 
double m_FEMBCo_Wfm_this_event_vec [m_n_apa][m_n_femb][m_n_tick]
 
std::vector< double > m_HV1_Frq_nominal
 
std::vector< double > m_HV1_Amp_nominal
 
std::vector< double > m_HV1_Phs_nominal
 
double m_HV1_Wfm_this_event_vec [m_n_tick]
 
bool m_init = 0
 

Static Private Attributes

static const size_t m_n_apa = 12
 
static const size_t m_n_tick = 8192
 
static const size_t m_n_wire_per_apa = 2560
 
static const size_t m_n_femb = 20
 
static const size_t m_n_max_coh_noise = 9
 

Additional Inherited Members

- Public Types inherited from ChannelNoiseService
typedef unsigned int Channel
 

Detailed Description

Definition at line 15 of file ShapedCohProtoDUNENoiseService.h.

Constructor & Destructor Documentation

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

Definition at line 19 of file ShapedCohProtoDUNENoiseService_service.cc.

19  {
20 
22  m_pran = new CLHEP::HepJamesRandom();
23  seedSvc->registerEngine(rndm::NuRandomService::CLHEPengineSeeder(m_pran), "ShapedCohProtoDUNENoiseService_rand");
24 
25  std::cout << "Initialising ShapedCohProtoDUNENoiseService\n";
26  double amplitude_col = pset.get<double>("amplitude_multiplicator_collection");
27  double amplitude_ind = pset.get<double>("amplitude_multiplicator_induction");
28  m_collection_plane_noise = pset.get<double>("collection_plane_noise") * amplitude_col;
29  m_induction_plane_noise = pset.get<double>("induction_plane_noise" ) * amplitude_ind;
30  m_collection_plane_noise_rms = pset.get<double>("collection_plane_noise_rms") * amplitude_col;
31  m_induction_plane_noise_rms = pset.get<double>("induction_plane_noise_rms" ) * amplitude_ind;
32 
33  m_FEMBCo_Frq_nominal = pset.get<std::vector<std::vector<double>>>("FEMBCo_Frq");
34  m_FEMBCo_Amp_nominal = pset.get<std::vector<std::vector<double>>>("FEMBCo_Amp");
35  m_FEMBCo_Phs_nominal = pset.get<std::vector<std::vector<double>>>("FEMBCo_Phs");
36  m_random_phase = pset.get<bool>("random_phase_noise");
37 
38  assert(m_FEMBCo_Frq_nominal.size() == m_n_femb);
39  assert(m_FEMBCo_Amp_nominal.size() == m_n_femb);
40  assert(m_FEMBCo_Phs_nominal.size() == m_n_femb);
41 
42  for (size_t femb=0; femb<m_n_femb; ++femb) {
43  assert(m_FEMBCo_Frq_nominal[femb].size() <= m_n_max_coh_noise);
44  assert(m_FEMBCo_Amp_nominal[femb].size() <= m_n_max_coh_noise);
45  assert(m_FEMBCo_Phs_nominal[femb].size() <= m_n_max_coh_noise);
46  }
47 
48  // HV noise
49  m_HV1_Frq_nominal = pset.get<std::vector<double>>("HV1_Frq");
50  m_HV1_Amp_nominal = pset.get<std::vector<double>>("HV1_Amp");
51  m_HV1_Phs_nominal = pset.get<std::vector<double>>("HV1_Phs");
52  assert(m_HV1_Frq_nominal.size() <= m_n_max_coh_noise);
53  assert(m_HV1_Amp_nominal.size() <= m_n_max_coh_noise);
54  assert(m_HV1_Phs_nominal.size() <= m_n_max_coh_noise);
55  m_init = false;
56 }
T * get() const
Definition: ServiceHandle.h:63
std::vector< std::vector< double > > m_FEMBCo_Phs_nominal
std::vector< std::vector< double > > m_FEMBCo_Amp_nominal
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
std::vector< std::vector< double > > m_FEMBCo_Frq_nominal
ShapedCohProtoDUNENoiseService::ShapedCohProtoDUNENoiseService ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry  
)
ShapedCohProtoDUNENoiseService::~ShapedCohProtoDUNENoiseService ( )

Definition at line 76 of file ShapedCohProtoDUNENoiseService_service.cc.

76 { }

Member Function Documentation

int ShapedCohProtoDUNENoiseService::addFEMBNoise ( const Channel  c,
AdcSignalVector adcs,
detinfo::DetectorClocksData const &  clock 
) const
protected

Definition at line 123 of file ShapedCohProtoDUNENoiseService_service.cc.

123  {
124  const size_t femb = m_channel_femb.at(c%m_n_wire_per_apa);
125  const size_t apa = c/m_n_wire_per_apa;
126 
127  for (size_t sample=0; sample<adcs.size(); ++sample)
128  adcs[sample] += m_FEMBCo_Wfm_this_event_vec[apa][femb][sample];
129 
130  return 0;
131 }
double m_FEMBCo_Wfm_this_event_vec[m_n_apa][m_n_femb][m_n_tick]
int ShapedCohProtoDUNENoiseService::addHVNoise ( const Channel  c,
AdcSignalVector adcs,
detinfo::DetectorClocksData const &  clock 
) const
protected

Definition at line 133 of file ShapedCohProtoDUNENoiseService_service.cc.

133  {
134 
135  for (size_t sample=0; sample<adcs.size(); ++sample)
136  adcs[sample] += m_HV1_Wfm_this_event_vec[sample];
137 
138  return 0;
139 }
int ShapedCohProtoDUNENoiseService::addNoise ( detinfo::DetectorClocksData const &  clock,
detinfo::DetectorPropertiesData const &  ,
Channel  c,
AdcSignalVector adcs 
) const
virtual

Implements ChannelNoiseService.

Definition at line 80 of file ShapedCohProtoDUNENoiseService_service.cc.

82  {
83 
84  assert(adcs.size() <= m_n_tick);
85  int ret = addFEMBNoise(c, adcs, clock) + addHVNoise(c, adcs, clock) + addShapedNoise(c, adcs, clock);
86  return ret;
87 }
int addHVNoise(const Channel, AdcSignalVector &, detinfo::DetectorClocksData const &) const
int addFEMBNoise(const Channel, AdcSignalVector &, detinfo::DetectorClocksData const &) const
int addShapedNoise(const Channel, AdcSignalVector &, detinfo::DetectorClocksData const &) const
int ShapedCohProtoDUNENoiseService::addShapedNoise ( const Channel  c,
AdcSignalVector adcs,
detinfo::DetectorClocksData const &  clock 
) const
protected

Definition at line 89 of file ShapedCohProtoDUNENoiseService_service.cc.

89  {
90 
92  const geo::View_t view = geo->View(c);
93  CLHEP::HepRandomEngine& engine = *m_pran;
94  CLHEP::RandGauss g_ind(engine, m_induction_plane_noise , m_induction_plane_noise_rms );
96 
97  double ampl=-1;
98  while (ampl<0) {
99  switch (view) {
100  case geo::kU:
101  case geo::kV:
102  ampl = g_ind.fire();
103  break;
104  default:
105  ampl = g_col.fire();
106  break;
107  }
108  }
109  CLHEP::RandGauss rgauss(engine, 0, ampl);
110 
111  std::vector<double> noise_vec;
112  for (size_t i=0; i<m_n_tick; ++i)
113  noise_vec.push_back(rgauss.fire());
114 
116  sss->ConvoluteElectronicResponse(clock, c, noise_vec);
117 
118  std::transform(adcs.begin(), adcs.end(), noise_vec.begin(), adcs.begin(), std::plus<double>());
119 
120  return 0;
121 }
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Planes which measure V.
Definition: geo_types.h:130
Planes which measure U.
Definition: geo_types.h:129
static int g_col
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
void ConvoluteElectronicResponse(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
LArSoft geometry interface.
Definition: ChannelGeo.h:16
void ShapedCohProtoDUNENoiseService::init ( )
private

Definition at line 58 of file ShapedCohProtoDUNENoiseService_service.cc.

58  {
60 
61  std::map<size_t,std::vector<size_t>> femb_se;
62  for (size_t chan=0; chan<m_n_wire_per_apa; ++chan) {
63  // int n_wire = chan%m_n_wire_per_apa; // that is one little useless statement
64  int femb = channel_map->FEMBFromOfflineChannel (chan)-1; // so that it starts from 0
65  int slot = channel_map->SlotIdFromOfflineChannel(chan); // if we ever need this...
66  // int femb_asic = channel_map->FEMBChannelFromOfflineChannel(chan) / 32; or this
67  femb_se[femb+slot*4].push_back(chan);
68  m_channel_femb[chan] = femb+slot*4;
69  }
70  m_init = true;
71  std::cout << "ShapedCohProtoDUNENoiseService initialised!\n";
72 }
unsigned int SlotIdFromOfflineChannel(unsigned int offlineChannel) const
Returns global slot ID.
unsigned int FEMBFromOfflineChannel(unsigned int offlineChannel) const
Returns FEMB/fiber.
void ShapedCohProtoDUNENoiseService::newEvent ( )
virtual

Reimplemented from ChannelNoiseService.

Definition at line 143 of file ShapedCohProtoDUNENoiseService_service.cc.

143  {
144  if (not m_init) init();
145 
146  CLHEP::RandGauss gaus(*m_pran);
147  CLHEP::RandFlat flat(*m_pran);
148  const double two_pi_tick_period = 6.2831853072/2000000;
149  for (size_t apa=0; apa<m_n_apa; ++apa) {
150  for (size_t femb=0; femb<m_FEMBCo_Frq_nominal.size(); ++femb) {
151  for (size_t noise=0; noise<m_FEMBCo_Frq_nominal[femb].size(); ++noise) {
152 
153  double frq = -1;
154  double amp = -1;
155  double phs = -1;
156 
157  while (frq<0)
158  frq = gaus.fire(m_FEMBCo_Frq_nominal[femb][noise], m_frequency_rms);
159 
160  while (amp<0)
161  amp = gaus.fire(m_FEMBCo_Amp_nominal[femb][noise], m_amplitude_rms);
162 
163  if (m_random_phase) {
164  while (phs<0)
165  phs = flat.fire(0, 6.2831853072);
166  } else {
167  throw std::runtime_error("ShapedCohProtoDUNENoiseService::newEvent(): Non random phases are not implemented yet");
168  }
169 
170  if (noise == 0) {
171  for (size_t sample=0; sample<m_n_tick; ++sample){
172  double two_pi_t_f = two_pi_tick_period*sample*frq;
173  m_FEMBCo_Wfm_this_event_vec[apa][femb][sample] = amp * sin(phs+two_pi_t_f);
174  }
175  } else {
176  for (size_t sample=0; sample<m_n_tick; ++sample){
177  double two_pi_t_f = two_pi_tick_period*sample*frq;
178  m_FEMBCo_Wfm_this_event_vec[apa][femb][sample] += amp * sin(phs+two_pi_t_f);
179  }
180  }
181  }
182  }
183  }
184 
185  for (size_t noise=0; noise<m_HV1_Frq_nominal.size(); ++noise) {
186  double frq = -1;
187  double amp = -1;
188  double phs = -1;
189 
190  while (frq<0)
191  frq = gaus.fire(m_HV1_Frq_nominal[noise], m_frequency_rms);
192 
193  while (amp<0)
194  amp = gaus.fire(m_HV1_Amp_nominal[noise], m_amplitude_rms);
195 
196  if (m_random_phase) {
197  while (phs<0)
198  phs = flat.fire(0, 6.2831853072);
199  } else {
200  throw std::runtime_error("ShaoedCohProtoDUNENoise::newEvent(): Non random phases are not implemented yet");
201  }
202 
203  if (noise == 0) {
204  for (size_t sample=0; sample<m_n_tick; ++sample){
205  double two_pi_t_f = two_pi_tick_period*sample*frq;
206  m_HV1_Wfm_this_event_vec[sample] = amp * sin(phs+two_pi_t_f);
207  }
208  } else {
209  for (size_t sample=0; sample<m_n_tick; ++sample){
210  double two_pi_t_f = two_pi_tick_period*sample*frq;
211  m_HV1_Wfm_this_event_vec[sample] += amp * sin(phs+two_pi_t_f);
212  }
213  }
214  }
215 }
std::vector< std::vector< double > > m_FEMBCo_Amp_nominal
T gaus(T x, T amplitude, T mean, T sigma)
Tests GausssianFit object with a known input.
std::vector< std::vector< double > > m_FEMBCo_Frq_nominal
double m_FEMBCo_Wfm_this_event_vec[m_n_apa][m_n_femb][m_n_tick]
std::ostream & ShapedCohProtoDUNENoiseService::print ( std::ostream &  o,
std::string   
) const
virtual

Implements ChannelNoiseService.

Definition at line 217 of file ShapedCohProtoDUNENoiseService_service.cc.

217  {
218  return o;
219 }

Member Data Documentation

double ShapedCohProtoDUNENoiseService::m_amplitude_rms
private

Definition at line 55 of file ShapedCohProtoDUNENoiseService.h.

std::map<size_t, size_t> ShapedCohProtoDUNENoiseService::m_channel_femb
private

Definition at line 51 of file ShapedCohProtoDUNENoiseService.h.

double ShapedCohProtoDUNENoiseService::m_collection_plane_noise
private

Definition at line 46 of file ShapedCohProtoDUNENoiseService.h.

double ShapedCohProtoDUNENoiseService::m_collection_plane_noise_rms
private

Definition at line 48 of file ShapedCohProtoDUNENoiseService.h.

std::vector<std::vector<double> > ShapedCohProtoDUNENoiseService::m_FEMBCo_Amp_nominal
private

Definition at line 58 of file ShapedCohProtoDUNENoiseService.h.

std::vector<std::vector<double> > ShapedCohProtoDUNENoiseService::m_FEMBCo_Frq_nominal
private

Definition at line 57 of file ShapedCohProtoDUNENoiseService.h.

std::vector<std::vector<double> > ShapedCohProtoDUNENoiseService::m_FEMBCo_Phs_nominal
private

Definition at line 59 of file ShapedCohProtoDUNENoiseService.h.

double ShapedCohProtoDUNENoiseService::m_FEMBCo_Wfm_this_event_vec[m_n_apa][m_n_femb][m_n_tick]
private

Definition at line 62 of file ShapedCohProtoDUNENoiseService.h.

double ShapedCohProtoDUNENoiseService::m_frequency_rms
private

Definition at line 54 of file ShapedCohProtoDUNENoiseService.h.

art::ServiceHandle<geo::Geometry> ShapedCohProtoDUNENoiseService::m_geo
private

Definition at line 44 of file ShapedCohProtoDUNENoiseService.h.

std::vector<double> ShapedCohProtoDUNENoiseService::m_HV1_Amp_nominal
private

Definition at line 66 of file ShapedCohProtoDUNENoiseService.h.

std::vector<double> ShapedCohProtoDUNENoiseService::m_HV1_Frq_nominal
private

Definition at line 65 of file ShapedCohProtoDUNENoiseService.h.

std::vector<double> ShapedCohProtoDUNENoiseService::m_HV1_Phs_nominal
private

Definition at line 67 of file ShapedCohProtoDUNENoiseService.h.

double ShapedCohProtoDUNENoiseService::m_HV1_Wfm_this_event_vec[m_n_tick]
private

Definition at line 70 of file ShapedCohProtoDUNENoiseService.h.

double ShapedCohProtoDUNENoiseService::m_induction_plane_noise
private

Definition at line 47 of file ShapedCohProtoDUNENoiseService.h.

double ShapedCohProtoDUNENoiseService::m_induction_plane_noise_rms
private

Definition at line 49 of file ShapedCohProtoDUNENoiseService.h.

bool ShapedCohProtoDUNENoiseService::m_init = 0
private

Definition at line 72 of file ShapedCohProtoDUNENoiseService.h.

const size_t ShapedCohProtoDUNENoiseService::m_n_apa = 12
staticprivate

Definition at line 37 of file ShapedCohProtoDUNENoiseService.h.

const size_t ShapedCohProtoDUNENoiseService::m_n_femb = 20
staticprivate

Definition at line 40 of file ShapedCohProtoDUNENoiseService.h.

const size_t ShapedCohProtoDUNENoiseService::m_n_max_coh_noise = 9
staticprivate

Definition at line 41 of file ShapedCohProtoDUNENoiseService.h.

const size_t ShapedCohProtoDUNENoiseService::m_n_tick = 8192
staticprivate

Definition at line 38 of file ShapedCohProtoDUNENoiseService.h.

const size_t ShapedCohProtoDUNENoiseService::m_n_wire_per_apa = 2560
staticprivate

Definition at line 39 of file ShapedCohProtoDUNENoiseService.h.

CLHEP::HepRandomEngine* ShapedCohProtoDUNENoiseService::m_pran
private

Definition at line 43 of file ShapedCohProtoDUNENoiseService.h.

bool ShapedCohProtoDUNENoiseService::m_random_phase
private

Definition at line 53 of file ShapedCohProtoDUNENoiseService.h.


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