Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
test
test_VintageDeconvoluter.cxx
Go to the documentation of this file.
1
// test_VintageDeconvoluter.cxx
2
//
3
// David Adams
4
// May 2018
5
//
6
// Test VintageDeconvoluter.
7
8
#include <string>
9
#include <iostream>
10
#include <fstream>
11
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
12
#include "
dunecore/DuneInterface/Tool/TpcDataTool.h
"
13
#include "
dunecore/ArtSupport/DuneToolManager.h
"
14
#include "
dunecore/ArtSupport/ArtServiceHelper.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
fhicl::ParameterSet
;
24
using
Index
=
unsigned
int
;
25
26
//**********************************************************************
27
28
int
test_VintageDeconvoluter
(
bool
useExistingFcl =
false
) {
29
const
string
myname =
"test_VintageDeconvoluter: "
;
30
#ifdef NDEBUG
31
cout << myname <<
"NDEBUG must be off."
<<
endl
;
32
abort();
33
#endif
34
string
line
=
"-----------------------------"
;
35
36
cout << myname << line <<
endl
;
37
string
fclfile =
"test_VintageDeconvoluter.fcl"
;
38
if
(useExistingFcl) {
39
cout << myname <<
"Using existing top-level FCL."
<<
endl
;
40
}
else
{
41
cout << myname <<
"Creating top-level FCL."
<<
endl
;
42
std::ofstream
config
{fclfile};
43
config
<<
"#include \"services_dune.fcl\""
<<
endl
;
44
//config << "services: @local::protodune_reco_services" << endl;
45
config
<<
"services: @local::dune35t_services_legacy"
<<
endl
;
46
config
<<
"tools: {"
<<
endl
;
47
config
<<
" mytool: {"
<<
endl
;
48
config
<<
" tool_type: VintageDeconvoluter"
<<
endl
;
49
config
<<
" LogLevel: 1"
<<
endl
;
50
config
<<
" }"
<<
endl
;
51
config
<<
"}"
<<
endl
;
52
}
53
ArtServiceHelper::load_services
(fclfile,
ArtServiceHelper::FileOnPath
);
54
55
cout << myname << line <<
endl
;
56
cout << myname <<
"Fetching tool manager."
<<
endl
;
57
DuneToolManager
* ptm =
DuneToolManager::instance
(fclfile);
58
assert ( ptm !=
nullptr
);
59
DuneToolManager
&
tm
= *ptm;
60
tm.
print
();
61
assert( tm.
toolNames
().size() == 1 );
62
63
cout << myname << line <<
endl
;
64
cout << myname <<
"Fetching tool."
<<
endl
;
65
auto
psgf = tm.
getPrivate
<
TpcDataTool
>(
"mytool"
);
66
assert( psgf !=
nullptr
);
67
auto
psgfmod = tm.
getPrivate
<
TpcDataTool
>(
"mytool"
);
68
assert( psgfmod !=
nullptr
);
69
70
cout << myname << line <<
endl
;
71
cout << myname <<
"Create data and call tool."
<<
endl
;
72
AdcChannelData
data
;
73
data.
setChannelInfo
(123);
74
for
(
AdcIndex
itic=0; itic<100; ++itic ) {
75
float
xadc = rand()%20 - 10.0;
76
data.
samples
.push_back(xadc);
77
}
78
data.
samples
[30] = 150.0;
79
assert( data.
signal
.size() == 0 );
80
assert( data.
rois
.size() == 0 );
81
assert( data.
samples
[30] = 150 );
82
AdcChannelData
data0 =
data
;
83
data0.
signal
= data.
signal
;
84
data0.
rois
= data.
rois
;
85
data0.
samples
= data.
samples
;
86
87
cout << myname << line <<
endl
;
88
cout << myname <<
"Running tool."
<<
endl
;
89
DataMap
resmod = psgfmod->update(data);
90
resmod.
print
();
91
92
cout << myname << line <<
endl
;
93
cout << myname <<
"Checking results."
<<
endl
;
94
assert( data.
samples
.size() == data0.
samples
.size() );
95
for
(
Index
isam=0; isam<data0.
samples
.size(); ++isam ) {
96
cout << isam <<
": "
<< data0.
samples
[isam] <<
" "
<< data.
samples
[isam] <<
endl
;
97
}
98
99
cout << myname << line <<
endl
;
100
cout << myname <<
"Done."
<<
endl
;
101
return
0;
102
}
103
104
//**********************************************************************
105
106
int
main
(
int
argc,
char
*
argv
[]) {
107
bool
useExistingFcl =
false
;
108
if
( argc > 1 ) {
109
string
sarg(argv[1]);
110
if
( sarg ==
"-h"
) {
111
cout <<
"Usage: "
<< argv[0] <<
" [ARG]"
<<
endl
;
112
cout <<
" If ARG = true, existing FCL file is used."
<<
endl
;
113
return
0;
114
}
115
useExistingFcl = sarg ==
"true"
|| sarg ==
"1"
;
116
}
117
return
test_VintageDeconvoluter
(useExistingFcl);
118
}
119
120
//**********************************************************************
ArtServiceHelper.h
DuneToolManager::toolNames
const std::vector< std::string > & toolNames() const
Definition:
DuneToolManager.cxx:151
string
std::string string
Definition:
nybbler.cc:12
TpcDataTool.h
ArtServiceHelper::FileOnPath
static constexpr FileOnPath_t FileOnPath
Definition:
ArtServiceHelper.h:113
DuneToolManager::print
void print() const
Definition:
DuneToolManager.cxx:157
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
AdcChannelData
Definition:
AdcChannelData.h:95
DataMap::print
void print(std::ostream *pout) const
Definition:
DataMap.h:245
ArtServiceHelper::load_services
static void load_services(std::string const &config)
Definition:
ArtServiceHelper.cxx:15
demo.tm
tm
Definition:
demo.py:21
freeze_graph.argv
argv
Definition:
freeze_graph.py:218
TpcDataTool
Definition:
TpcDataTool.h:17
ServiceHandle.h
AdcChannelData::setChannelInfo
void setChannelInfo(ChannelInfoPtr pchi)
Definition:
AdcChannelData.h:184
AdcChannelData::rois
AdcRoiVector rois
Definition:
AdcChannelData.h:137
config
static Config * config
Definition:
config.cpp:1054
main
int main(int argc, char *argv[])
Definition:
test_VintageDeconvoluter.cxx:106
DuneToolManager.h
AdcIndex
unsigned int AdcIndex
Definition:
AdcTypes.h:15
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
make_THn_beam_input.data
data
Definition:
make_THn_beam_input.py:80
DuneToolManager::getPrivate
std::unique_ptr< T > getPrivate(std::string name)
Definition:
DuneToolManager.h:82
DuneToolManager
Definition:
DuneToolManager.h:34
AdcChannelData::signal
AdcFilterVector signal
Definition:
AdcChannelData.h:136
test_VintageDeconvoluter
int test_VintageDeconvoluter(bool useExistingFcl=false)
Definition:
test_VintageDeconvoluter.cxx:28
pduneana::line
void line(double t, double *p, double &x, double &y, double &z)
Definition:
PDSPAnalyzer_module.cc:4741
DataMap
Definition:
DataMap.h:43
DuneToolManager::instance
static DuneToolManager * instance(std::string fclname="", int dbg=1)
Definition:
DuneToolManager.cxx:95
AdcChannelData::samples
AdcSignalVector samples
Definition:
AdcChannelData.h:131
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11