Typedefs | Functions
test_VintageDeconvoluter.cxx File Reference
#include <string>
#include <iostream>
#include <fstream>
#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "dunecore/DuneInterface/Tool/TpcDataTool.h"
#include "dunecore/ArtSupport/DuneToolManager.h"
#include "dunecore/ArtSupport/ArtServiceHelper.h"
#include <cassert>

Go to the source code of this file.

Typedefs

using Index = unsigned int
 

Functions

int test_VintageDeconvoluter (bool useExistingFcl=false)
 
int main (int argc, char *argv[])
 

Typedef Documentation

using Index = unsigned int

Definition at line 24 of file test_VintageDeconvoluter.cxx.

Function Documentation

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

Definition at line 106 of file test_VintageDeconvoluter.cxx.

106  {
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 }
int test_VintageDeconvoluter(bool useExistingFcl=false)
QTextStream & endl(QTextStream &s)
int test_VintageDeconvoluter ( bool  useExistingFcl = false)

Definition at line 28 of file test_VintageDeconvoluter.cxx.

28  {
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  }
54 
55  cout << myname << line << endl;
56  cout << myname << "Fetching tool manager." << endl;
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;
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 }
const std::vector< std::string > & toolNames() const
static constexpr FileOnPath_t FileOnPath
void print() const
unsigned int Index
void print(std::ostream *pout) const
Definition: DataMap.h:245
static void load_services(std::string const &config)
tm
Definition: demo.py:21
void setChannelInfo(ChannelInfoPtr pchi)
AdcRoiVector rois
static Config * config
Definition: config.cpp:1054
unsigned int AdcIndex
Definition: AdcTypes.h:15
std::unique_ptr< T > getPrivate(std::string name)
AdcFilterVector signal
void line(double t, double *p, double &x, double &y, double &z)
static DuneToolManager * instance(std::string fclname="", int dbg=1)
AdcSignalVector samples
QTextStream & endl(QTextStream &s)