Typedefs | Functions
test_CnrByGroup.cxx File Reference
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include "dunecore/DuneInterface/Tool/TpcDataTool.h"
#include "dunecore/DuneCommon/Utility/SampleTailer.h"
#include "dunecore/ArtSupport/DuneToolManager.h"
#include "TRandom.h"
#include <cassert>

Go to the source code of this file.

Typedefs

using Index = unsigned int
 
using IndexVector = std::vector< Index >
 
using FloatVector = AdcSignalVector
 

Functions

void showSamples (const AdcChannelDataMap &acds, string pre)
 
int test_CnrByGroup (bool useExistingFcl)
 
int main (int argc, char *argv[])
 

Typedef Documentation

Definition at line 33 of file test_CnrByGroup.cxx.

using Index = unsigned int

Definition at line 31 of file test_CnrByGroup.cxx.

Definition at line 32 of file test_CnrByGroup.cxx.

Function Documentation

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

Definition at line 111 of file test_CnrByGroup.cxx.

111  {
112  bool useExistingFcl = false;
113  if ( argc > 1 ) {
114  string sarg(argv[1]);
115  if ( sarg == "-h" ) {
116  cout << "Usage: " << argv[0] << " [ARG]" << endl;
117  cout << " If ARG = true, existing FCL file is used." << endl;
118  return 0;
119  }
120  useExistingFcl = sarg == "true" || sarg == "1";
121  }
122  return test_CnrByGroup(useExistingFcl);
123 }
int test_CnrByGroup(bool useExistingFcl)
QTextStream & endl(QTextStream &s)
void showSamples ( const AdcChannelDataMap acds,
string  pre 
)

Definition at line 37 of file test_CnrByGroup.cxx.

37  {
38  for ( const auto& iacd : acds ) {
39  cout << pre << setw(2) << iacd.first << ":";
40  for ( float sam : iacd.second.samples ) {
41  cout << setw(9) << fixed << setprecision(2) << sam;
42  }
43  cout << endl;
44  }
45 }
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
QTextStream & endl(QTextStream &s)
int test_CnrByGroup ( bool  useExistingFcl)

Definition at line 49 of file test_CnrByGroup.cxx.

49  {
50  const string myname = "test_CnrByGroup: ";
51 #ifdef NDEBUG
52  cout << myname << "NDEBUG must be off." << endl;
53  abort();
54 #endif
55  string line = "-----------------------------";
56 
57  cout << myname << line << endl;
58  string fclfile = "test_CnrByGroup.fcl";
59  if ( ! useExistingFcl ) {
60  ofstream fout(fclfile.c_str());
61  fout << "tools: {" << endl;
62  fout << " mytool: {" << endl;
63  fout << " tool_type: CnrByGroup" << endl;
64  fout << " LogLevel: 2" << endl;
65  fout << " Groups: [\"grpa:0:5\", \"grpb:5:10\"]" << endl;
66  fout << " Options: []" << endl;
67  fout << " }" << endl;
68  fout << "}" << endl;
69  fout.close();
70  } else {
71  cout << myname << "Using existing top-level FCL." << endl;
72  }
73 
74  cout << myname << line << endl;
75  cout << myname << "Fetching tool manager." << endl;
77  assert ( ptm != nullptr );
78  DuneToolManager& tm = *ptm;
79  tm.print();
80  assert( tm.toolNames().size() == 1 );
81 
82  cout << myname << line << endl;
83  cout << myname << "Fetching tool." << endl;
84  auto ptoo = tm.getPrivate<TpcDataTool>("mytool");
85  assert( ptoo != nullptr );
86 
87  cout << myname << line << endl;
88  cout << myname << "Create channel data." << endl;
89  AdcChannelDataMap acds;
90  float noiseSigma = 0.5;
91  for ( Index icha=0; icha<10; ++icha ) {
92  float off = icha < 5 ? 10 : 20;
93  for ( Index isam=0; isam<8; ++isam ) {
94  acds[icha].samples.push_back(gRandom->Gaus(off, noiseSigma));
95  acds[icha].setChannelInfo(icha, 0, icha, 0);
96  }
97  }
98  showSamples(acds, myname);
99 
100  cout << myname << line << endl;
101  cout << myname << "Call tool." << endl;
102  DataMap ret = ptoo->updateMap(acds);
103  showSamples(acds, myname);
104 
105  cout << myname << "Done." << endl;
106  return 0;
107 }
const std::vector< std::string > & toolNames() const
void print() const
unsigned int Index
void showSamples(const AdcChannelDataMap &acds, string pre)
tm
Definition: demo.py:21
std::unique_ptr< T > getPrivate(std::string name)
void line(double t, double *p, double &x, double &y, double &z)
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
static DuneToolManager * instance(std::string fclname="", int dbg=1)
QTextStream & endl(QTextStream &s)