Typedefs | Functions
test_AdcRoiToTree.cxx File Reference
#include <string>
#include <iostream>
#include <fstream>
#include "dunecore/DuneInterface/Tool/TpcDataTool.h"
#include "dunecore/ArtSupport/DuneToolManager.h"
#include "TRandom.h"
#include <cassert>

Go to the source code of this file.

Typedefs

using Index = unsigned int
 

Functions

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

Typedef Documentation

using Index = unsigned int

Definition at line 25 of file test_AdcRoiToTree.cxx.

Function Documentation

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

Definition at line 103 of file test_AdcRoiToTree.cxx.

103  {
104  bool useExistingFcl = false;
105  if ( argc > 1 ) {
106  string sarg(argv[1]);
107  if ( sarg == "-h" ) {
108  cout << "Usage: " << argv[0] << " [ARG]" << endl;
109  cout << " If ARG = true, existing FCL file is used." << endl;
110  return 0;
111  }
112  useExistingFcl = sarg == "true" || sarg == "1";
113  }
114  return test_AdcRoiToTree(useExistingFcl);
115 }
int test_AdcRoiToTree(bool useExistingFcl=false)
QTextStream & endl(QTextStream &s)
int test_AdcRoiToTree ( bool  useExistingFcl = false)

Definition at line 29 of file test_AdcRoiToTree.cxx.

29  {
30  const string myname = "test_AdcRoiToTree: ";
31 #ifdef NDEBUG
32  cout << myname << "NDEBUG must be off." << endl;
33  abort();
34 #endif
35  string line = "-----------------------------";
36 
37  cout << myname << line << endl;
38  string fclfile = "test_AdcRoiToTree.fcl";
39  if ( ! useExistingFcl ) {
40  cout << myname << "Creating top-level FCL." << endl;
41  ofstream fout(fclfile.c_str());
42  fout << "tools.mytool: {" << endl;
43  fout << " tool_type: AdcRoiToTree" << endl;
44  fout << " LogLevel: 4" << endl;
45  fout << " OutFile: \"adcrois.root\"" << endl;
46  fout << " MetadataFields: [\"runevt\", \"xcha\"]" << endl;
47  fout << "}" << endl;
48  fout.close();
49  } else {
50  cout << myname << "Using existing top-level FCL." << endl;
51  }
52 
53  cout << myname << line << endl;
54  cout << myname << "Fetching tool manager." << endl;
56  assert ( ptm != nullptr );
57  DuneToolManager& tm = *ptm;
58  tm.print();
59  assert( tm.toolNames().size() == 1 );
60 
61  cout << myname << line << endl;
62  cout << myname << "Fetching tool." << endl;
63  auto ptoo = tm.getPrivate<TpcDataTool>("mytool");
64  assert( ptoo != nullptr );
65 
66  cout << myname << line << endl;
67  cout << myname << "Create test data." << endl;
68  Index irun = 123;
69  Index ievt = 456;
70  float runevt = 1000*irun + ievt;
71  AdcChannelDataMap acds;
72  Index ncha = 4;
73  Index icha1 = 100;
74  Index icha2 = icha1 + ncha;
75  for ( Index icha=icha1; icha<icha2; ++icha ) {
76  AdcChannelData& acd = acds[icha];
77  acd.setEventInfo(irun, ievt);
78  acd.setMetadata("runevt", runevt);
79  float xcha = 5*(icha%100); // Wire posn in mm.
80  acd.setMetadata("xcha", xcha);
81  acd.setChannelInfo(icha);
82  acd.samples.resize(1000, icha);
83  Index nroi = icha - icha1 + 1;
84  for ( Index iroi=0; iroi<nroi; ++iroi ) {
85  Index isam1 = 100*iroi;
86  Index isam2 = isam1 + iroi;
87  acd.rois.emplace_back(isam1, isam2);
88  }
89  }
90 
91  cout << myname << line << endl;
92  cout << myname << "Call tool." << endl;
93  DataMap res = ptoo->viewMap(acds);
94  res.print();
95 
96  cout << myname << line << endl;
97  cout << myname << "Done." << endl;
98  return 0;
99 }
const std::vector< std::string > & toolNames() const
void print() const
unsigned int Index
void print(std::ostream *pout) const
Definition: DataMap.h:245
tm
Definition: demo.py:21
void setChannelInfo(ChannelInfoPtr pchi)
AdcRoiVector rois
void setEventInfo(EventInfoPtr pevi)
std::unique_ptr< T > getPrivate(std::string name)
void line(double t, double *p, double &x, double &y, double &z)
void setMetadata(Name mname, float val)
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
static DuneToolManager * instance(std::string fclname="", int dbg=1)
AdcSignalVector samples
QTextStream & endl(QTextStream &s)