23 using std::istringstream;
30 const string myname =
"test_FclRunDataTool: ";
32 cout << myname <<
"NDEBUG must be off." <<
endl;
35 string line =
"-----------------------------";
37 cout << myname << line <<
endl;
38 string fclfile =
"test_FclRunDataTool.fcl";
39 if ( ! useExistingFcl ) {
40 cout << myname <<
"Creating top-level FCL." <<
endl;
41 ofstream
fout(fclfile.c_str());
45 fout <<
" tool_type: FclRunDataTool" <<
endl;
47 fout <<
" FileNames: [\"rdtest/rundata.fcl\", \"rdtest/rundata/run000123.fcl\"]" <<
endl;
51 fout <<
"#include \"dunecommon_tools.fcl\"" <<
endl;
52 fout <<
"tools.mytool: @local::tools.protoduneRunDataTool" <<
endl;
56 cout << myname <<
"Using existing top-level FCL." <<
endl;
59 cout << myname << line <<
endl;
60 cout << myname <<
"Create rundata fcl" <<
endl;
61 if ( ! useExistingFcl ) {
62 system(
"rm -rf rdtest");
63 system(
"mkdir rdtest");
64 ofstream
fout(
"rdtest/rundata.fcl");
65 fout <<
"cryostat: protodune\n";
66 fout <<
"apas: [1, 2, 3, 4, 5, 6]\n";
67 fout <<
"gain: 14.0\n";
68 fout <<
"shaping: 2.0\n";
69 fout <<
"leakage: 500\n";
70 fout <<
"hvfrac: 1.0\n";
71 fout <<
"pulserAmplitude: 0\n";
74 if ( ! useExistingFcl ) {
75 system(
"mkdir rdtest/rundata");
76 ofstream
fout(
"rdtest/rundata/run000123.fcl");
78 fout <<
"gain: 25.0\n";
79 fout <<
"shaping: 3.0\n";
80 fout <<
"hvfrac: 0.5\n";
81 fout <<
"pulserAmplitude: 8\n";
85 cout << myname << line <<
endl;
86 cout << myname <<
"Fetching tool manager." <<
endl;
88 assert ( ptm !=
nullptr );
93 cout << myname << line <<
endl;
94 cout << myname <<
"Fetching tool." <<
endl;
96 assert( rdt !=
nullptr );
98 Index run = runin == 0 ? 123 : runin;
100 cout << myname << line <<
endl;
101 cout <<
"Fetch run data." <<
endl;
102 RunData rdat = rdt->runData(run);
103 cout << rdat <<
endl;
104 assert( rdat.
run() ==
run );
106 assert( rdat.
cryostat() ==
"protodune" );
107 assert( rdat.
apas().size() == 6 );
108 assert( rdat.
gain() == 25.0 );
109 assert( rdat.
shaping() == 3.0 );
110 assert( rdat.
leakage() == 500 );
111 assert( rdat.
hvfrac() == 0.5 );
115 cout << myname << line <<
endl;
116 cout << myname <<
"Done." <<
endl;
123 bool useExistingFcl =
false;
126 string sarg(argv[1]);
127 if ( sarg ==
"-h" ) {
128 cout <<
"Usage: " << argv[0] <<
" [keepFCL] [RUN]" <<
endl;
129 cout <<
" If keepFCL = true, existing FCL file is used." <<
endl;
130 cout <<
" If RUN is nonzero, the data for that run are displayed." <<
endl;
133 useExistingFcl = sarg ==
"true" || sarg ==
"1";
136 string sarg(argv[2]);
137 istringstream ssarg(argv[2]);
Index pulserAmplitude() const
const IndexVector & apas() const
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)