DuneTimeConverter.h
Go to the documentation of this file.
1 // DuneTimeConverter
2 
3 #ifndef DuneTimeConverter_H
4 #define DuneTimeConverter_H
5 
6 // David Adams
7 // March 2016
8 //
9 // Utility that converts between NOvA time and DUNE time.
10 //
11 // DUNE uses art::Timestamp with
12 // Unix time in sec in the high word
13 // Remainder in ns in the low word
14 // NOvA time is the # ticks since 2010 with 1 tick = 1/(64 MHz),
15 // i.e. there are 64 ticks/us.
16 
17 #include <stdint.h>
18 #include <string>
20 
22 public:
23 
24  // Unix time when NOvA time is zero.
25  static uint64_t novaT0Sec() {
26  return 1262304000; // 01Jan2010 UTC in unix time
27  }
28 
29  // Number of NOvA ticks per microsecond.
30  static uint64_t novaTicksPerUsec() {
31  return 64;
32  }
33 
34  // Number of NOvA ticks per second.
35  static uint64_t novaTicksPerSec() {
36  return 1000000*novaTicksPerUsec();
37  }
38 
39  // Convert NOvA time to DUNE time.
40  static art::Timestamp fromNova(uint64_t tnova);
41 
42  // Convert NOvA time to dune time.
43  static uint64_t toNova(art::Timestamp tart);
44 
45  // Construct timestamp from the time in sec and remainder in ns
46  static art::Timestamp makeTimestamp(uint32_t tsec, uint32_t trem);
47 
48  // Convert to a string with format "SSS.NNNNNNNNN" where SSS is the truncated
49  // time in seconds and NNNNNNNNN is the remainder in ns.
50  static std::string toString(art::Timestamp tart);
51 
52  // Convert from a string in the above format.
54 
55 };
56 
57 #endif
static art::Timestamp fromNova(uint64_t tnova)
static std::string toString(art::Timestamp tart)
std::string string
Definition: nybbler.cc:12
static art::Timestamp makeTimestamp(uint32_t tsec, uint32_t trem)
static uint64_t novaTicksPerSec()
static art::Timestamp fromString(std::string stime)
static uint64_t novaT0Sec()
static uint64_t toNova(art::Timestamp tart)
static uint64_t novaTicksPerUsec()