Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JRandomToAWriter.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3
4#include "TRandom3.h"
5
8
9#include "JAcoustics/JToA.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 */
24int main(int argc, char **argv)
25{
26 using namespace std;
27 using namespace JPP;
28
30
31 JFileRecorder_t outputFile;
32 string detectorFile;
33 double rate_Hz;
34 double T_s;
35 int run;
36 int id;
37 ULong_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}
ROOT TTree parameter settings.
string outputFile
Data structure for detector geometry and calibration.
Recording of objects on file according a format that follows from the file name extension.
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
ROOT I/O of application specific meta data.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
Acoustic receiver.
Acoustic event.
Detector data structure.
Definition JDetector.hh:96
General exception.
Definition JException.hh:24
int getID() const
Get identifier.
Definition JObjectID.hh:50
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).
Detector file.
Definition JHead.hh:227
Acoustic receiver.
Definition JReceiver.hh:30
double putT(const double t_s) const
Get uncorrected time.
Definition JReceiver.hh:84
Time-of-arrival data from acoustic piezo sensor or hydrophone.
Definition JToA.hh:28
uint32_t DOMID
DAQ run number.
Definition JToA.hh:34
int64_t TOA_NS
Unique ID of the waveform that best described the signal around TOA_NS.
Definition JToA.hh:36
uint32_t QUALITYFACTOR
The ticks (16ns) part of the DAQ frame timestamp.
Definition JToA.hh:39
uint32_t QUALITYNORMALISATION
A measure of how good the waveform match was to the signal.
Definition JToA.hh:40
int32_t WAVEFORMID
DOM unique identifeir.
Definition JToA.hh:35
int32_t DETID
Definition JToA.hh:32
int32_t RUN
detector identifier
Definition JToA.hh:33
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72