Functions
test_ArtServiceHelper.cxx File Reference
#include "dunecore/ArtSupport/ArtServiceHelper.h"
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cassert>
#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "art/Framework/Services/Optional/RandomNumberGenerator.h"
#include "art_root_io/TFileService.h"
#include "art/Framework/Services/System/TriggerNamesService.h"
#include "TFile.h"
#include "TROOT.h"

Go to the source code of this file.

Functions

int test_ArtServiceHelper (int opt)
 
int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 68 of file test_ArtServiceHelper.cxx.

68  {
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 }
opt
Definition: train.py:196
int test_ArtServiceHelper(int opt)
QTextStream & endl(QTextStream &s)
int test_ArtServiceHelper ( int  opt)

Definition at line 30 of file test_ArtServiceHelper.cxx.

30  {
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;
54  cout << myname << " " << &*hrng << endl;
55 
56  cout << myname << line << endl;
57  cout << myname << "Check TFileService is available." << endl;
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 }
opt
Definition: train.py:196
static void load(std::string const &filename)
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)