Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JRandomToAWriter.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 
4 #include "TRandom3.h"
5 
6 #include "JDetector/JDetector.hh"
8 
9 #include "JAcoustics/JToA.hh"
10 #include "JAcoustics/JSupport.hh"
11 #include "JAcoustics/JReceiver.hh"
12 
14 #include "JSupport/JMeta.hh"
15 
16 #include "Jeep/JParser.hh"
17 #include "Jeep/JMessage.hh"
18 
19 /**
20  * \file
21  * Auxiliary program to write random acoustic data.
22  * \author mdejong
23  */
24 int main(int argc, char **argv)
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
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings.
Detector data structure.
Definition: JDetector.hh:89
Recording of objects on file according a format that follows from the file name extension.
Time-of-arrival data from acoustic piezo sensor or hydrophone.
Definition: JToA.hh:25
string outputFile
Data structure for detector geometry and calibration.
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
ROOT I/O of application specific meta data.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Acoustic receiver.
int32_t DETID
Definition: JToA.hh:30
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Utility class to parse command line options.
Acoustic event.
do set_variable DETECTOR_TXT $WORKDIR detector
int debug
debug level