Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JRandomToAWriter.cc File Reference

Auxiliary program to write random acoustic data. More...

#include <string>
#include <iostream>
#include "TRandom3.h"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JAcoustics/JToA.hh"
#include "JAcoustics/JSupport.hh"
#include "JAcoustics/JReceiver.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to write random acoustic data.

Author
mdejong

Definition in file JRandomToAWriter.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 24 of file JRandomToAWriter.cc.

25 {
26  using namespace std;
27  using namespace JPP;
28 
29  typedef JFileRecorder<JTYPELIST<JToA, JMeta>::typelist> JFileRecorder_t;
30 
31  JFileRecorder_t outputFile;
32  string detectorFile;
33  double rate_Hz;
34  double T_s;
35  int run;
36  int id;
37  UInt_t seed;
38  int debug;
39 
40  try {
41 
42  JParser<> zap(" Auxiliary program to write random acoustic data.");
43 
44  zap['o'] = make_field(outputFile, "output file");
45  zap['a'] = make_field(detectorFile, "detector.");
46  zap['R'] = make_field(run, "run number") = -1;
47  zap['B'] = make_field(rate_Hz, "background rate [Hz]");
48  zap['T'] = make_field(T_s, "run duration [s]");
49  zap['W'] = make_field(id, "waveform identifier");
50  zap['S'] = make_field(seed, "seed") = 0;
51  zap['d'] = make_field(debug, "debug") = 0;
52 
53  zap(argc, argv);
54  }
55  catch(const exception &error) {
56  FATAL(error.what() << endl);
57  }
58 
59  if (rate_Hz <= 0.0) {
60  FATAL("Invalid rate [Hz] " << rate_Hz << endl);
61  }
62 
63  const double t_s = 1.0 / rate_Hz;
64 
65  gRandom->SetSeed(seed);
66 
68 
69  try {
70  load(detectorFile, detector);
71  }
72  catch(const JException& error) {
73  FATAL(error);
74  }
75 
76  outputFile.open();
77 
78  outputFile.put(JMeta(argc, argv));
79 
80  JToA toa;
81 
82  toa.DETID = detector.getID();
83  toa.RUN = run;
84  toa.WAVEFORMID = id;
85  toa.QUALITYFACTOR = 2.0e3;
86  toa.QUALITYNORMALISATION = 0.0e3;
87 
88  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
89 
90  if (module->getFloor() != 0) {
91 
92  const JReceiver receiver(module->getID(), module->getPosition(), module->getT0() * 1.0e-9);
93 
94  for (double t1 = 0.0 + gRandom->Exp(t_s); t1 < T_s; t1 += gRandom->Exp(t_s)) {
95 
96  toa.DOMID = receiver.getID();
97  toa.TOA_NS = llrint(1E9*receiver.putT(t1));
98 
99  outputFile.put(toa);
100  }
101  }
102  }
103 
104  outputFile.close();
105 
106  return 0;
107 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1711
General exception.
Definition: JException.hh:24
Acoustic receiver.
Definition: JReceiver.hh:27
Detector data structure.
Definition: JDetector.hh:89
Time-of-arrival data from acoustic piezo sensor or hydrophone.
Definition: JToA.hh:25
string outputFile
Detector file.
Definition: JHead.hh:226
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
int getID() const
Get identifier.
Definition: JObjectID.hh:50
#define FATAL(A)
Definition: JMessage.hh:67
int32_t DETID
Definition: JToA.hh:30
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
do set_variable DETECTOR_TXT $WORKDIR detector
int debug
debug level