Jpp
19.0.0
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JAcoustics
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
"
7
#include "
JDetector/JDetectorToolkit.hh
"
8
9
#include "
JAcoustics/JToA.hh
"
10
#include "
JAcoustics/JSupport.hh
"
11
#include "
JAcoustics/JReceiver.hh
"
12
13
#include "
JSupport/JFileRecorder.hh
"
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
67
JDetector
detector
;
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
}
JSUPPORT::JMeta
Auxiliary class for ROOT I/O of application specific meta data.
Definition:
JMeta.hh:70
JSUPPORT::JFileRecorder
Object writing to file.
Definition:
JFileRecorder.hh:42
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1711
JLANG::JException
General exception.
Definition:
JException.hh:24
JACOUSTICS::JReceiver
Acoustic receiver.
Definition:
JReceiver.hh:27
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JSupport.hh
ROOT TTree parameter settings.
JDETECTOR::JDetector
Detector data structure.
Definition:
JDetector.hh:89
JFileRecorder.hh
Recording of objects on file according a format that follows from the file name extension.
JACOUSTICS::JToA
Time-of-arrival data from acoustic piezo sensor or hydrophone.
Definition:
JToA.hh:25
outputFile
string outputFile
Definition:
JDAQTimesliceSelector.cc:37
JDetector.hh
Data structure for detector geometry and calibration.
JAANET::detector
Detector file.
Definition:
JHead.hh:226
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:2158
JLANG::JObjectID::getID
int getID() const
Get identifier.
Definition:
JObjectID.hh:50
JMeta.hh
ROOT I/O of application specific meta data.
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JReceiver.hh
Acoustic receiver.
JACOUSTICS::JToA::DETID
int32_t DETID
Definition:
JToA.hh:30
JDETECTOR::load
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Definition:
JDetectorToolkit.hh:484
JParser.hh
Utility class to parse command line options.
JDetectorToolkit.hh
JToA.hh
Acoustic event.
detector
do set_variable DETECTOR_TXT $WORKDIR detector
Definition:
detector-XY:fit1d.sh:38
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
Generated by
1.8.5