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
software
JAcoustics
JToAImp.cc
Go to the documentation of this file.
1
#include <chrono>
2
#include "
JAcoustics/JToA.hh
"
3
4
// FIXME: to be replaced by std::chrono::round once we move to C++17
5
namespace
{
6
template
<
class
To,
class
Duration>
7
To round(
const
Duration&
d
)
8
{
9
To t0 = std::chrono::duration_cast<To>(
d
);
10
To t1 = t0 + To{1};
11
auto
diff0 = d - t0;
12
auto
diff1 = t1 -
d
;
13
if
(diff0 == diff1) {
14
if
(t0.count() & 1) {
15
return
t1;
16
}
17
return
t0;
18
}
else
if
(diff0 < diff1) {
19
return
t0;
20
}
21
return
t1;
22
}
23
}
24
25
namespace
JACOUSTICS {
26
27
constexpr
double
ONE_TICK_IN_NS
= 16
E
-9;
// one tick of the 62.5 MHz clock = 16 nanoseconds
28
constexpr
double
SECOND_IN_NANOSECOND
= 1
E
-9;
29
constexpr
double
SECOND_IN_MICROSECOND
= 1
E
-6;
30
constexpr int64_t
NANOSECONDS_IN_ONE_SECOND
= 1000000000LL;
31
constexpr int64_t
NANOSECONDS_IN_ONE_TICK
= 16LL;
32
33
JToA::JToA
() =
default
;
34
35
double
JToA::daqFrameTimeStart_s
()
const
36
{
37
return
(static_cast<double>(
SECONDS
) + static_cast<double>(
TICKS
) *
ONE_TICK_IN_NS
);
38
}
39
40
double
JToA::TOA_S
()
const
41
{
42
return
relativeToA_s
() +
daqFrameTimeStart_s
();
43
}
44
45
int64_t
JToA::relativeToA_ns
()
const
46
{
47
return
TOA_NS
-
daqFrameTimeStart_ns
();
48
}
49
50
double
JToA::relativeToA_s
()
const
51
{
52
// to mimic what's done in the streamds retrieval, we truncate
53
// to microseconds first, then go to seconds.
54
std::chrono::microseconds mus = round<std::chrono::microseconds>(std::chrono::nanoseconds{
relativeToA_ns
()});
55
return
static_cast<
double
>
(mus.count()) *
SECOND_IN_MICROSECOND
;
56
}
57
58
int64_t
JToA::daqFrameTimeStart_ns
()
const
59
{
60
return
SECONDS
*
NANOSECONDS_IN_ONE_SECOND
+
TICKS
*
NANOSECONDS_IN_ONE_TICK
;
61
}
62
63
}
// namespace JACOUSTICS
E
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
Definition:
JMuonPostfit.sh:40
JACOUSTICS::JToA::relativeToA_s
double relativeToA_s() const
Time of Arrival, expressed in seconds relative to the DAQ frame start.
Definition:
JToAImp.cc:50
JACOUSTICS::SECOND_IN_NANOSECOND
constexpr double SECOND_IN_NANOSECOND
Definition:
JToAImp.cc:28
JACOUSTICS::JToA::relativeToA_ns
int64_t relativeToA_ns() const
Time of Arrival, expressed in nanoseconds relative to the DAQ frame start.
Definition:
JToAImp.cc:45
JACOUSTICS::JToA::JToA
JToA()
JACOUSTICS::NANOSECONDS_IN_ONE_TICK
constexpr int64_t NANOSECONDS_IN_ONE_TICK
Definition:
JToAImp.cc:31
JACOUSTICS::SECOND_IN_MICROSECOND
constexpr double SECOND_IN_MICROSECOND
Definition:
JToAImp.cc:29
JACOUSTICS::JToA::TOA_S
double TOA_S() const
Time of Arrival, expressed in seconds relative to Unix epoch (1 January 1970 00:00:00 UTC) ...
Definition:
JToAImp.cc:40
JACOUSTICS::ONE_TICK_IN_NS
constexpr double ONE_TICK_IN_NS
Definition:
JToAImp.cc:27
JACOUSTICS::NANOSECONDS_IN_ONE_SECOND
constexpr int64_t NANOSECONDS_IN_ONE_SECOND
Definition:
JToAImp.cc:30
JACOUSTICS::JToA::daqFrameTimeStart_s
double daqFrameTimeStart_s() const
Time stamp of the DAQ frame start, in seconds since the Unix epoch (1 January 1970 00:00:00 UTC) ...
Definition:
JToAImp.cc:35
d
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition:
JMuonStart.sh:47
JACOUSTICS::JToA::TICKS
uint32_t TICKS
The seconds part of the DAQ frame timestamp.
Definition:
JToA.hh:36
JToA.hh
Acoustic event.
JACOUSTICS::JToA::daqFrameTimeStart_ns
int64_t daqFrameTimeStart_ns() const
Normalization for the quality factor.
Definition:
JToAImp.cc:58
JACOUSTICS::JToA::TOA_NS
int64_t TOA_NS
Unique ID of the waveform that best described the signal around TOA_NS.
Definition:
JToA.hh:34
JACOUSTICS::JToA::SECONDS
uint32_t SECONDS
Time of Arrival, in ns (relative to Unix epoch, 1 January 1970 00:00:00 UTC)
Definition:
JToA.hh:35
Generated by
1.8.5