test_tpcFragmentToRawDigits.cxx
Go to the documentation of this file.
1 // test_tpcFragmentToRawDigits.cxx
2 
3 // David Adams
4 // September 2015
5 //
6 // This test demonstrates how to use art::Timestamp.
7 
8 #undef NDEBUG
9 
10 #include "../tpcFragmentToRawDigits.h"
12 #include <string>
13 #include <iostream>
14 #include <iomanip>
15 #include <cassert>
16 
17 using std::string;
18 using std::cout;
19 using std::endl;
20 using std::setw;
21 using std::uint32_t;
22 using std::uint64_t;
23 
24 //**********************************************************************
25 
27  const string myname = "test_tpcFragmentToRawDigits: ";
28  cout << myname << "Starting test" << endl;
29 #ifdef NDEBUG
30  cout << myname << "NDEBUG must be off." << endl;
31  abort();
32 #endif
33  string line = "-----------------------------";
34  string scfg;
35 
36  cout << myname << line << endl;
37  cout << myname << "Create test time" << endl;
38  //uint32_t tsec = 2208988800; // 2040
39  uint32_t tsec = 1577836800; // 2020
40  //uint32_t tsec = 1483228800; // 2017
41  uint32_t trem = 123456789;
42 
43  cout << myname << line << endl;
44  cout << myname << "Create timestamp." << endl;
46  cout << myname << DuneTimeConverter::toString(ts1) << " sec " << endl;
47  assert( ts1.timeLow() == trem );
48  assert( ts1.timeHigh() == tsec );
49 
50  cout << myname << "Create nova time." << endl;
53  cout << myname << "Nova time: " <<tnova << endl;
54  cout << myname << "Timestamp: " << setw(9) << DuneTimeConverter::toString(ts2) << " sec" << endl;
55  assert( ts2.timeHigh() == tsec );
56  int64_t lodiff = ts2.timeLow();
57  lodiff -= trem;
59  cout << myname << "Low tolerance: " << tol << endl;
60  assert( abs(lodiff) < tol );
61 
62  cout << myname << line << endl;
63  cout << myname << "Test make_art_timestamp_from_nova_timestamp." << endl;
65  cout << myname << "Timestamp: " << setw(9) << ts3.timeHigh() << "."
66  << setw(9) << ts3.timeLow() << " sec" << endl;
67  assert( ts3.timeHigh() == ts2.timeHigh() );
68  assert( ts3.timeLow() == ts2.timeLow() );
69 
70  cout << myname << line << endl;
71  cout << myname << "Test old_make_art_timestamp_from_nova_timestamp." << endl;
73  cout << myname << "Timestamp: " << DuneTimeConverter::toString(ts4) << endl;
74  assert( ts4.timeHigh() == 0 );
75  assert( ts4.timeLow() == ts2.timeHigh() );
76 
77  cout << myname << line << endl;
78  cout << myname << "Done." << endl;
79  return 0;
80 }
81 
82 //**********************************************************************
83 
84 int main() {
86 }
87 
88 //**********************************************************************
def line(rflist, normalization=13700 *units.eplus)
Definition: __init__.py:701
constexpr std::uint32_t timeLow() const
Definition: Timestamp.h:29
static art::Timestamp fromNova(uint64_t tnova)
static std::string toString(art::Timestamp tart)
std::string string
Definition: nybbler.cc:12
constexpr std::uint32_t timeHigh() const
Definition: Timestamp.h:34
static art::Timestamp makeTimestamp(uint32_t tsec, uint32_t trem)
int test_tpcFragmentToRawDigits()
T abs(T value)
unsigned int uint32_t
Definition: stdint.h:126
art::Timestamp make_art_timestamp_from_nova_timestamp(lbne::TpcNanoSlice::Header::nova_timestamp_t this_nova_timestamp)
unsigned __int64 uint64_t
Definition: stdint.h:136
art::Timestamp old_make_art_timestamp_from_nova_timestamp(lbne::TpcNanoSlice::Header::nova_timestamp_t this_nova_timestamp)
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
signed __int64 int64_t
Definition: stdint.h:135
static uint64_t toNova(art::Timestamp tart)
QTextStream & endl(QTextStream &s)
static uint64_t novaTicksPerUsec()