Jpp  19.1.0
the software that should make you happy
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

◆ main()

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 }
string outputFile
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Detector data structure.
Definition: JDetector.hh:96
General exception.
Definition: JException.hh:24
Utility class to parse command line options.
Definition: JParser.hh:1698
Object writing to file.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
JExp< JF1_t > Exp(const JF1_t &f1)
Exponent of function.
Definition: JMathlib.hh:2545
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Detector file.
Definition: JHead.hh:227
Acoustic receiver.
Definition: JReceiver.hh:30
Time-of-arrival data from acoustic piezo sensor or hydrophone.
Definition: JToA.hh:26
uint32_t DOMID
DAQ run number.
Definition: JToA.hh:32
int64_t TOA_NS
Unique ID of the waveform that best described the signal around TOA_NS.
Definition: JToA.hh:34
uint32_t QUALITYFACTOR
The ticks (16ns) part of the DAQ frame timestamp.
Definition: JToA.hh:37
uint32_t QUALITYNORMALISATION
A measure of how good the waveform match was to the signal.
Definition: JToA.hh:38
int32_t WAVEFORMID
DOM unique identifeir.
Definition: JToA.hh:33
int32_t DETID
Definition: JToA.hh:30
int32_t RUN
detector identifier
Definition: JToA.hh:31
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:72