Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunecore
dunecore
DuneCommon
Tool
test
test_FixedTimeOffsetTool.cxx
Go to the documentation of this file.
1
// test_FixedTimeOffsetTool.cxx
2
//
3
// David Adams
4
// May 2018
5
//
6
// Test FixedTimeOffsetTool.
7
8
#include <string>
9
#include <iostream>
10
#include <fstream>
11
#include <sstream>
12
#include "
dunecore/ArtSupport/DuneToolManager.h
"
13
#include "
dunecore/DuneInterface/Tool/TimeOffsetTool.h
"
14
#include "TH1F.h"
15
16
#undef NDEBUG
17
#include <cassert>
18
19
using
std::string
;
20
using
std::cout;
21
using
std::endl
;
22
using
std::ofstream;
23
using
std::istringstream;
24
using
fhicl::ParameterSet
;
25
using
Index
=
unsigned
int
;
26
27
//**********************************************************************
28
29
int
test_FixedTimeOffsetTool
(
bool
useExistingFcl =
false
) {
30
const
string
myname =
"test_FixedTimeOffsetTool: "
;
31
#ifdef NDEBUG
32
cout << myname <<
"NDEBUG must be off."
<<
endl
;
33
abort();
34
#endif
35
string
line
=
"-----------------------------"
;
36
37
cout << myname << line <<
endl
;
38
string
fclfile =
"test_FixedTimeOffsetTool.fcl"
;
39
Index
val
= 369258;
40
double
rem = 0.123;
41
if
( ! useExistingFcl ) {
42
cout << myname <<
"Creating top-level FCL."
<<
endl
;
43
ofstream
fout
(fclfile.c_str());
44
fout
<<
"tools: {"
<<
endl
;
45
fout
<<
" mytool: {"
<<
endl
;
46
fout
<<
" tool_type: FixedTimeOffsetTool"
<<
endl
;
47
fout
<<
" LogLevel: 2"
<<
endl
;
48
fout
<<
" Value: "
<< val <<
endl
;
49
fout
<<
" Rem: "
<< rem <<
endl
;
50
fout
<<
" Unit: \"tick\""
<<
endl
;
51
fout
<<
" }"
<<
endl
;
52
fout
<<
"}"
<<
endl
;
53
fout
.close();
54
}
else
{
55
cout << myname <<
"Using existing top-level FCL."
<<
endl
;
56
}
57
58
cout << myname << line <<
endl
;
59
cout << myname <<
"Fetching tool manager."
<<
endl
;
60
DuneToolManager
* ptm =
DuneToolManager::instance
(fclfile);
61
assert ( ptm !=
nullptr
);
62
DuneToolManager
&
tm
= *ptm;
63
tm.
print
();
64
assert( tm.
toolNames
().size() >= 1 );
65
66
cout << myname << line <<
endl
;
67
cout << myname <<
"Create time offset file."
<<
endl
;
68
Index
run
= 123;
69
Index
evt
= 2468;
70
71
cout << myname << line <<
endl
;
72
cout << myname <<
"Fetching tool."
<<
endl
;
73
auto
tot = tm.
getPrivate
<
TimeOffsetTool
>(
"mytool"
);
74
assert( tot !=
nullptr
);
75
76
cout << myname << line <<
endl
;
77
cout <<
"Fetch the time offset in ticks."
<<
endl
;
78
TimeOffsetTool::Data
dat
;
79
dat.
run
=
run
;
80
dat.
event
=
evt
;
81
TimeOffsetTool::Offset
off = tot->offset(dat);
82
assert( off.
isValid
() );
83
assert( off.
value
== val );
84
assert( off.
rem
== rem );
85
assert( off.
unit
==
"tick"
);
86
87
cout << myname << line <<
endl
;
88
cout << myname <<
"Done."
<<
endl
;
89
return
0;
90
}
91
92
//**********************************************************************
93
94
int
main
(
int
argc,
char
*
argv
[]) {
95
bool
useExistingFcl =
false
;
96
if
( argc > 1 ) {
97
string
sarg(argv[1]);
98
if
( sarg ==
"-h"
) {
99
cout <<
"Usage: "
<< argv[0] <<
" [keepFCL] [RUN]"
<<
endl
;
100
cout <<
" If keepFCL = true, existing FCL file is used."
<<
endl
;
101
cout <<
" If RUN is nonzero, the data for that run are displayed."
<<
endl
;
102
return
0;
103
}
104
useExistingFcl = sarg ==
"true"
|| sarg ==
"1"
;
105
}
106
return
test_FixedTimeOffsetTool
(useExistingFcl);
107
}
108
109
//**********************************************************************
TimeOffsetTool::Data::event
Index event
Definition:
TimeOffsetTool.h:24
main
int main(int argc, char *argv[])
Definition:
test_FixedTimeOffsetTool.cxx:94
val
Definition:
registry_via_id_test_2.cc:15
DuneToolManager::toolNames
const std::vector< std::string > & toolNames() const
Definition:
DuneToolManager.cxx:151
string
std::string string
Definition:
nybbler.cc:12
wirecell.sigproc.paper.noise.dat
dat
Definition:
noise.py:64
TimeOffsetTool::Offset::rem
double rem
Definition:
TimeOffsetTool.h:38
DuneToolManager::print
void print() const
Definition:
DuneToolManager.cxx:157
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
TimeOffsetTool::Offset::isValid
bool isValid() const
Definition:
TimeOffsetTool.h:40
demo.tm
tm
Definition:
demo.py:21
freeze_graph.argv
argv
Definition:
freeze_graph.py:218
filelisting.run
int run
Definition:
filelisting.py:13
TimeOffsetTool.h
DuneToolManager.h
test_FixedTimeOffsetTool
int test_FixedTimeOffsetTool(bool useExistingFcl=false)
Definition:
test_FixedTimeOffsetTool.cxx:29
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
TimeOffsetTool::Offset::value
long value
Definition:
TimeOffsetTool.h:37
DuneToolManager::getPrivate
std::unique_ptr< T > getPrivate(std::string name)
Definition:
DuneToolManager.h:82
DuneToolManager
Definition:
DuneToolManager.h:34
TimeOffsetTool::Data::run
Index run
Definition:
TimeOffsetTool.h:22
pduneana::line
void line(double t, double *p, double &x, double &y, double &z)
Definition:
PDSPAnalyzer_module.cc:4741
TimeOffsetTool::Data
Definition:
TimeOffsetTool.h:20
TimeOffsetTool::Offset
Definition:
TimeOffsetTool.h:34
TimeOffsetTool
Definition:
TimeOffsetTool.h:11
tca::evt
TCEvent evt
Definition:
DataStructs.cxx:7
reco_momentum_tuples.fout
fout
Definition:
reco_momentum_tuples.py:65
TimeOffsetTool::Offset::unit
Name unit
Definition:
TimeOffsetTool.h:39
DuneToolManager::instance
static DuneToolManager * instance(std::string fclname="", int dbg=1)
Definition:
DuneToolManager.cxx:95
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11