Typedefs | Functions | Variables
test_ExponentialChannelNoiseService.cxx File Reference
#include "../ExponentialChannelNoiseService.h"
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include "dunecore/ArtSupport/ArtServiceHelper.h"
#include "art_root_io/TFileService.h"
#include "art/Framework/Services/Optional/RandomNumberGenerator.h"
#include "fhiclcpp/ParameterSet.h"
#include "lardata/DetectorInfoServices/DetectorClocksService.h"
#include "lardata/DetectorInfoServices/DetectorPropertiesService.h"
#include "lardata/Utilities/LArFFT.h"
#include "larcore/Geometry/Geometry.h"
#include "lardataobj/RawData/raw.h"
#include <cassert>

Go to the source code of this file.

Typedefs

typedef std::vector< short > AdcVector
 

Functions

int test_ExponentialChannelNoiseService (unsigned int ntick, unsigned int maxchan=100)
 
int main (int argc, char *argv[])
 

Variables

const std::string LArPropertiesServiceConfigurationString
 
const std::string DetectorPropertiesServiceConfigurationString
 

Typedef Documentation

typedef std::vector<short> AdcVector

Definition at line 37 of file test_ExponentialChannelNoiseService.cxx.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 237 of file test_ExponentialChannelNoiseService.cxx.

237  {
238  int fftsize = 0;
239  int maxchan = 2000;
240  int ntick = 1000;
241  if ( argc > 1 ) {
242  istringstream ssarg(argv[1]);
243  ssarg >> fftsize;
244  }
245  if ( argc > 2 ) {
246  istringstream ssarg(argv[2]);
247  ssarg >> maxchan;
248  }
249  load_services(fftsize);
250  test_ExponentialChannelNoiseService(ntick, maxchan);
251  // We must close TFileService to write out histograms.
252  cout << "Close services." << endl;
253  return 0;
254 }
int test_ExponentialChannelNoiseService(unsigned int ntick, unsigned int maxchan=100)
QTextStream & endl(QTextStream &s)
int test_ExponentialChannelNoiseService ( unsigned int  ntick,
unsigned int  maxchan = 100 
)

Definition at line 91 of file test_ExponentialChannelNoiseService.cxx.

91  {
92  const string myname = "test_ExponentialChannelNoiseService: ";
93 #ifdef NDEBUG
94  cout << myname << "NDEBUG must be off." << endl;
95  abort();
96 #endif
97  const string line = "-----------------------------";
98 
99  load_services();
100 
101  cout << myname << line << endl;
102  cout << myname << "Create noise service." << endl;
103  fhicl::ParameterSet pset;
104  pset.put("NoiseNormZ", 3.16);
105  pset.put("NoiseNormU", 3.16);
106  pset.put("NoiseNormV", 3.16);
107  pset.put("NoiseWidthZ", 2000.0);
108  pset.put("NoiseWidthU", 2000.0);
109  pset.put("NoiseWidthV", 2000.0);
110  pset.put("LowCutoffZ", 7.5);
111  pset.put("LowCutoffU", 7.5);
112  pset.put("LowCutoffV", 7.5);
113  pset.put("WhiteNoiseZ", 0.0);
114  pset.put("WhiteNoiseU", 0.0);
115  pset.put("WhiteNoiseV", 0.0);
116  pset.put("NoiseArrayPoints", 1000);
117  pset.put("OldNoiseIndex", true);
118  pset.put("RandomSeed", 54321);
119  ExponentialChannelNoiseService noisvc(pset);
120 
121  ServiceHandle<LArFFT> hfftsvc;
123 
124  AdcSignal ped = 1000;
125  cout << myname << line << endl;
126  cout << myname << "Create signal with ped=" << ped << " and " << ntick << " ticks." << endl;
127  cout << myname << "FFT size: " << hfftsvc->FFTSize() << endl;
128  cout << myname << "Detector: " << hgeosvc->DetectorName() << endl;
129  AdcSignalVector sigsin(ntick, ped);
130  for ( unsigned int isig=0; isig<20; ++isig ) {
131  }
132  double sum = 0.0;
133  double sumsq = 0.0;
134  double sumdsq = 0.0;
135  double sumcol = 0.0;
136  double sumsqcol = 0.0;
137  double sumdsqcol = 0.0;
138  double sumind = 0.0;
139  double sumsqind = 0.0;
140  double sumdsqind = 0.0;
141  unsigned int nchan = 0;
142  unsigned int nchancol = 0;
143  unsigned int nchanind = 0;
144  unsigned int count = 0;
145  unsigned int countcol = 0;
146  unsigned int countind = 0;
147  // Loop over channels.
148  cout << myname << "Looping over channels." << endl;
149  for ( unsigned int icha=0; icha<1000000; ++icha ) {
150  geo::SigType_t sigtyp = hgeosvc->SignalType(icha);
151  if ( sigtyp == geo::kMysteryType ) break;
152  if ( icha >= maxchan ) break;
153  ++nchan;
154  bool firstcol = false;
155  bool firstind = false;
156  string labtyp = "unknown";
157  if ( sigtyp == geo::kCollection ) {
158  firstcol = nchancol == 0;
159  labtyp = "collection";
160  ++nchancol;
161  } else if ( sigtyp == geo::kInduction ) {
162  firstind = nchanind == 0;
163  labtyp = "induction";
164  ++nchanind;
165  } else abort();
166  AdcSignalVector sigs = sigsin;
167  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
168  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob(clockData);
169  assert( noisvc.addNoise(clockData, detProp, icha, sigs) == 0 );
170  if ( firstcol || firstind ) {
171  cout << myname << "First " << labtyp << " channel: " << icha << endl;
172  }
173  for ( unsigned int isig=0; isig<ntick; ++isig ) {
174  if ( firstcol || firstind ) {
175  if ( isig < 20 || ntick-isig < 20 ) {
176  cout << myname << setw(5) << isig << ": " << setw(8) << sigs[isig] << endl;
177  }
178  if ( isig == 20 && ntick-isig > 20 ) {
179  cout << myname << setw(5) << "..." << endl;
180  }
181  }
182  float sig = sigs[isig];
183  double dif = sig - ped;
184  sum += sig;
185  sumsq += sig*sig;
186  sumdsq += dif*dif;
187  ++count;
188  if ( sigtyp == geo::kCollection ) {
189  sumcol += sig;
190  sumsqcol += sig*sig;
191  sumdsqcol += dif*dif;
192  ++countcol;
193  } else if ( sigtyp == geo::kInduction ) {
194  sumind += sig;
195  sumsqind += sig*sig;
196  sumdsqind += dif*dif;
197  ++countind;
198  }
199  }
200  }
201  cout << myname << " # channels: " << nchan << endl;
202  cout << myname << "# collection channels: " << nchancol << endl;
203  cout << myname << " # induction channels: " << nchanind << endl;
204  double nticktot = double(nchan)*ntick;
205  double nticktotcol = double(nchancol)*ntick;
206  double nticktotind = double(nchanind)*ntick;
207  cout << myname << " # tick total: " << nticktot << endl;
208  cout << myname << " Count: " << count << endl;
209  cout << myname << " Collection # tick total: " << nticktotcol << endl;
210  cout << myname << " Collection Count: " << countcol << endl;
211  cout << myname << " Induction # tick total: " << nticktotind << endl;
212  cout << myname << " Induction Count: " << countind << endl;
213  assert( nchan > 0 );
214  float mean = sum/nticktot;
215  float rms = sqrt(sumsq/nticktot - mean*mean);
216  float rms2 = sqrt(sumdsq/nticktot);
217  float meancol = sumcol/nticktotcol;
218  float rmscol = sqrt(sumsqcol/nticktotcol - meancol*meancol);
219  float rms2col = sqrt(sumdsqcol/nticktotcol);
220  float meanind = sumind/nticktotind;
221  float rmsind = sqrt(sumsqind/nticktotind - meanind*meanind);
222  float rms2ind = sqrt(sumdsqind/nticktotind);
223  cout << myname << " Mean: " << mean << endl;
224  cout << myname << " RMS: " << rms << endl;
225  cout << myname << " RMS2: " << rms2 << endl;
226  cout << myname << " Collection Mean: " << meancol << endl;
227  cout << myname << " Collection RMS: " << rmscol << endl;
228  cout << myname << " Collection RMS2: " << rms2col << endl;
229  cout << myname << " Induction Mean: " << meanind << endl;
230  cout << myname << " Induction RMS: " << rmsind << endl;
231  cout << myname << " Induction RMS2: " << rms2ind << endl;
232 
233  cout << myname << "Done." << endl;
234  return 0;
235 }
Who knows?
Definition: geo_types.h:147
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:40
float AdcSignal
Definition: AdcTypes.h:21
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
int FFTSize() const
Definition: LArFFT.h:69
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
Signal from induction planes.
Definition: geo_types.h:145
enum geo::_plane_sigtype SigType_t
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
void line(double t, double *p, double &x, double &y, double &z)
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:16
void put(std::string const &key)
QTextStream & endl(QTextStream &s)
Signal from collection planes.
Definition: geo_types.h:146

Variable Documentation

const std::string DetectorPropertiesServiceConfigurationString
Initial value:
{ R"cfg(
service_provider: "DetectorPropertiesServiceStandard"
# Drift properties
SternheimerA: 0.1956 # Ar Sternheimer parameter a.
SternheimerK: 3.0000 # Ar Sternheimer parameter k.
SternheimerX0: 0.2000 # Ar Sternheimer parameter x0.
SternheimerX1: 3.0000 # Ar Sternheimer parameter x0.
SternheimerCbar: 5.2146 # Ar Sternheimer parameter Cbar.
Temperature: 87
Electronlifetime: 3.0e3
Efield: [0.5,0.666,0.8] #(predicted for microBooNE)
ElectronsToADC: 6.8906513e-3 # 1fC = 43.008 ADC counts for DUNE fd
NumberTimeSamples: 4492 # drift length/drift velocity*sampling rate = (359.4 cm)/(0.16 cm/us)*(2 MHz)
ReadOutWindowSize: 4492 # drift length/drift velocity*sampling rate = (359.4 cm)/(0.16 cm/us)*(2 MHz)
TimeOffsetU: 0.
TimeOffsetV: 0.
TimeOffsetZ: 0.
DriftVelFudgeFactor: 1.
SimpleBoundaryProcess: true #enable opticalBoundaryProcessSimple instead of G4 default
)cfg"}

Definition at line 346 of file test_ExponentialChannelNoiseService.cxx.

const std::string LArPropertiesServiceConfigurationString

Definition at line 262 of file test_ExponentialChannelNoiseService.cxx.