Typedefs | Functions
test_CnrGroupWeighted.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_CnrGroupWeighted (bool useExistingFcl)
 
int main (int argc, char *argv[])
 

Typedef Documentation

Definition at line 33 of file test_CnrGroupWeighted.cxx.

using Index = unsigned int

Definition at line 31 of file test_CnrGroupWeighted.cxx.

Definition at line 32 of file test_CnrGroupWeighted.cxx.

Function Documentation

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

Definition at line 115 of file test_CnrGroupWeighted.cxx.

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

Definition at line 37 of file test_CnrGroupWeighted.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_CnrGroupWeighted ( bool  useExistingFcl)

Definition at line 49 of file test_CnrGroupWeighted.cxx.

49  {
50  const string myname = "test_CnrGroupWeighted: ";
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_CnrGroupWeighted.fcl";
59  if ( ! useExistingFcl ) {
60  ofstream fout(fclfile.c_str());
61  fout << "tools: {" << endl;
62  fout << " mytool: {" << endl;
63  fout << " tool_type: CnrGroupWeighted" << endl;
64  fout << " LogLevel: 2" << endl;
65  fout << " Weight: gain" << endl;
66  fout << " Groups: [\"grpa:0:5\", \"grpb:5:10\"]" << endl;
67  fout << " Options: []" << endl;
68  fout << " }" << endl;
69  fout << "}" << endl;
70  fout.close();
71  } else {
72  cout << myname << "Using existing top-level FCL." << endl;
73  }
74 
75  cout << myname << line << endl;
76  cout << myname << "Fetching tool manager." << endl;
78  assert ( ptm != nullptr );
79  DuneToolManager& tm = *ptm;
80  tm.print();
81  assert( tm.toolNames().size() == 1 );
82 
83  cout << myname << line << endl;
84  cout << myname << "Fetching tool." << endl;
85  auto ptoo = tm.getPrivate<TpcDataTool>("mytool");
86  assert( ptoo != nullptr );
87 
88  cout << myname << line << endl;
89  cout << myname << "Create channel data." << endl;
90  Index ncha = 10;
91  std::vector<float> gain = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
92  AdcChannelDataMap acds;
93  float noiseSigma = 0.5;
94  for ( Index icha=0; icha<ncha; ++icha ) {
95  float off = icha < 5 ? 100 : 200;
96  for ( Index isam=0; isam<8; ++isam ) {
97  acds[icha].samples.push_back(gain[icha]*gRandom->Gaus(off, noiseSigma));
98  acds[icha].setChannelInfo(icha, 0, icha, 0);
99  acds[icha].setMetadata("gain", gain[icha]);
100  }
101  }
102  showSamples(acds, myname);
103 
104  cout << myname << line << endl;
105  cout << myname << "Call tool." << endl;
106  DataMap ret = ptoo->updateMap(acds);
107  showSamples(acds, myname);
108 
109  cout << myname << "Done." << endl;
110  return 0;
111 }
const std::vector< std::string > & toolNames() const
void print() const
unsigned int Index
tm
Definition: demo.py:21
void showSamples(const AdcChannelDataMap &acds, string pre)
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)