Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunecore
dunecore
ArtSupport
test
test_ArtServiceHelper.cxx
Go to the documentation of this file.
1
// test_ArtServiceHelper.cxx
2
3
//#include "AXService/ArtServiceHelper.h"
4
#include "
dunecore/ArtSupport/ArtServiceHelper.h
"
5
6
#include <string>
7
#include <iostream>
8
#include <fstream>
9
#include <sstream>
10
#include <iomanip>
11
#include <cassert>
12
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
13
#include "
art/Framework/Services/Optional/RandomNumberGenerator.h
"
14
#include "art_root_io/TFileService.h"
15
#include "
art/Framework/Services/System/TriggerNamesService.h
"
16
17
#include "TFile.h"
18
#include "TROOT.h"
19
20
using
std::string
;
21
using
std::cout;
22
using
std::endl
;
23
using
std::istringstream;
24
using
std::ofstream;
25
using
art::ServiceHandle
;
26
27
#undef NDEBUG
28
#include <cassert>
29
30
int
test_ArtServiceHelper
(
int
opt
) {
31
const
string
myname =
"test_ArtServiceHelper: "
;
32
cout << myname <<
"Starting test"
<<
endl
;
33
#ifdef NDEBUG
34
cout << myname <<
"NDEBUG must be off."
<<
endl
;
35
abort();
36
#endif
37
string
line
=
"-----------------------------"
;
38
string
scfg;
39
string
fclfile =
"test_ArtServiceHelper.fcl"
;
40
string
datafile =
"mytest.root"
;
41
42
if
( opt == 1 ) {
43
ofstream
fout
(fclfile);
44
fout <<
"services: {"
<<
endl
;
45
fout <<
" RandomNumberGenerator: {}"
<<
endl
;
46
fout <<
" TFileService: {fileName: \""
<< datafile <<
"\"}"
<<
endl
;
47
fout <<
"}"
<<
endl
;
48
}
49
ArtServiceHelper::load
(fclfile);
50
51
cout << myname << line <<
endl
;
52
cout << myname <<
"Check RandomNumberGenerator is available."
<<
endl
;
53
ServiceHandle<art::RandomNumberGenerator>
hrng;
54
cout << myname <<
" "
<< &*hrng <<
endl
;
55
56
cout << myname << line <<
endl
;
57
cout << myname <<
"Check TFileService is available."
<<
endl
;
58
ServiceHandle<art::TFileService>
htf;
59
cout << myname <<
" "
<< &*hrng <<
endl
;
60
cout << myname <<
" TFile name: "
<< htf->file().GetName() <<
endl
;
61
//assert( htf->file().GetName() == datafile );
62
63
cout << myname << line <<
endl
;
64
cout << myname <<
"Done."
<<
endl
;
65
return
0;
66
}
67
68
int
main
(
int
argc,
char
**
argv
) {
69
const
string
myname =
"main: "
;
70
int
opt
= 1;
71
if
( argc > 1 ) {
72
opt = -1;
73
istringstream ssopt(argv[1]);
74
ssopt >>
opt
;
75
if
( opt < 0 ) {
76
cout <<
"Usage: test_ArtServiceHelper [OPT]"
<<
endl
;
77
cout <<
" OPT = 0 to skip test."
<<
endl
;
78
cout <<
" 1 to load from string."
<<
endl
;
79
cout <<
" 2 to load all services from a file."
<<
endl
;
80
}
81
}
82
83
if
( opt == 0 )
return
0;
84
int
rstat =
test_ArtServiceHelper
(opt);
85
return
rstat;
86
}
main
int main(int argc, char **argv)
Definition:
test_ArtServiceHelper.cxx:68
art::ServiceHandle
Definition:
ServiceHandle.h:37
RandomNumberGenerator.h
ArtServiceHelper.h
string
std::string string
Definition:
nybbler.cc:12
train.opt
opt
Definition:
train.py:196
TriggerNamesService.h
freeze_graph.argv
argv
Definition:
freeze_graph.py:218
ServiceHandle.h
ArtServiceHelper::load
static void load(std::string const &filename)
Definition:
ArtServiceHelper.h:121
test_ArtServiceHelper
int test_ArtServiceHelper(int opt)
Definition:
test_ArtServiceHelper.cxx:30
pduneana::line
void line(double t, double *p, double &x, double &y, double &z)
Definition:
PDSPAnalyzer_module.cc:4741
reco_momentum_tuples.fout
fout
Definition:
reco_momentum_tuples.py:65
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11