Typedefs | Functions
test_ChannelStatusServiceTool.cxx File Reference
#include "dunecore/DuneInterface/Data/AdcTypes.h"
#include "dunecore/ArtSupport/ArtServiceHelper.h"
#include "dunecore/ArtSupport/DuneToolManager.h"
#include "dunecore/DuneInterface/Tool/IndexMapTool.h"
#include "TH1F.h"
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cassert>

Go to the source code of this file.

Typedefs

using Index = unsigned int
 

Functions

int test_ChannelStatusServiceTool (bool useExistingFcl=false, string extrafcl="")
 
int main (int argc, char *argv[])
 

Typedef Documentation

using Index = unsigned int

Definition at line 30 of file test_ChannelStatusServiceTool.cxx.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 105 of file test_ChannelStatusServiceTool.cxx.

105  {
106  bool useExistingFcl = false;
107  string extrafcl;
108  if ( argc > 1 ) {
109  string sarg(argv[1]);
110  if ( sarg == "-h" ) {
111  cout << "Usage: " << argv[0] << " [keepFCL] [extrafcl]" << endl;
112  cout << " If keepFCL = true, existing FCL file is used." << endl;
113  cout << " If extrafcl is give, that file is included in the config" << endl;
114  return 0;
115  }
116  useExistingFcl = sarg == "true" || sarg == "1";
117  }
118  if ( argc > 2 ) {
119  extrafcl = argv[2];
120  }
121  return test_ChannelStatusServiceTool(useExistingFcl, extrafcl);
122 }
QTextStream & endl(QTextStream &s)
int test_ChannelStatusServiceTool(bool useExistingFcl=false, string extrafcl="")
int test_ChannelStatusServiceTool ( bool  useExistingFcl = false,
string  extrafcl = "" 
)

Definition at line 34 of file test_ChannelStatusServiceTool.cxx.

34  {
35  const string myname = "test_ChannelStatusServiceTool: ";
36 #ifdef NDEBUG
37  cout << myname << "NDEBUG must be off." << endl;
38  abort();
39 #endif
40  string line = "-----------------------------";
41 
42  cout << myname << line << endl;
43  string fclfile = "test_ChannelStatusServiceTool.fcl";
44  if ( ! useExistingFcl ) {
45  cout << myname << "Creating top-level FCL." << endl;
46  ofstream fout(fclfile.c_str());
47  fout << "#include \"services_dune.fcl\"" << endl;
48  fout << "services.Geometry: @local::protodune_geo" << endl;
49  fout << "services.ExptGeoHelperInterface: @local::dune_geometry_helper" << endl;
50  fout << "services.ChannelStatusService: {" << endl;
51  fout << " service_provider: SimpleChannelStatusService" << endl;
52  fout << " BadChannels: [ 1 ]" << endl;
53  fout << " NoisyChannels: [3, 4]" << endl;
54  fout << "}" << endl;
55  fout << "tools: {" << endl;
56  fout << " mytool: {" << endl;
57  fout << " tool_type: ChannelStatusServiceTool" << endl;
58  fout << " LogLevel: 1" << endl;
59  fout << " }" << endl;
60  fout << "}" << endl;
61  if ( extrafcl.size() ) {
62  fout << "#include \"" + extrafcl + "\"" << endl;
63  }
64  fout.close();
65  } else {
66  cout << myname << "Using existing top-level FCL." << endl;
67  }
68 
69  cout << myname << line << endl;
70  cout << myname << "Load services." << endl;
71  ArtServiceHelper::load(fclfile);
72 
73  cout << myname << line << endl;
74  cout << myname << "Fetching tool manager." << endl;
76  assert ( ptm != nullptr );
77  DuneToolManager& tm = *ptm;
78  tm.print();
79  assert( tm.toolNames().size() >= 1 );
80 
81  cout << myname << line << endl;
82  cout << myname << "Fetching tool." << endl;
83  auto pcs = tm.getPrivate<IndexMapTool>("mytool");
84  assert( pcs != nullptr );
85 
86  cout << myname << line << endl;
87  cout << "Check some channels." << endl;
88  vector<Index> chks(20, 0);
89  chks[1] = 1;
90  chks[3] = 2;
91  chks[4] = 2;
92  for ( Index icha=0; icha<20; ++icha ) {
93  Index chanStat = pcs->get(icha);
94  cout << setw(8) << icha << ": " << setw(2) << chanStat << endl;
95  assert( chanStat == chks[icha] );
96  }
97 
98  cout << myname << line << endl;
99  cout << myname << "Done." << endl;
100  return 0;
101 }
const std::vector< std::string > & toolNames() const
void print() const
unsigned int Index
tm
Definition: demo.py:21
static void load(std::string const &filename)
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
std::unique_ptr< T > getPrivate(std::string name)
void line(double t, double *p, double &x, double &y, double &z)
static DuneToolManager * instance(std::string fclname="", int dbg=1)
QTextStream & endl(QTextStream &s)