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

Go to the source code of this file.

Typedefs

using Index = unsigned int
 

Functions

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

Typedef Documentation

using Index = unsigned int

Definition at line 23 of file test_StandardAdcChannelStringTool.cxx.

Function Documentation

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

Definition at line 140 of file test_StandardAdcChannelStringTool.cxx.

140  {
141  bool useExistingFcl = false;
142  if ( argc > 1 ) {
143  string sarg(argv[1]);
144  if ( sarg == "-h" ) {
145  cout << "Usage: " << argv[0] << " [ARG]" << endl;
146  cout << " If ARG = true, existing FCL file is used." << endl;
147  return 0;
148  }
149  useExistingFcl = sarg == "true" || sarg == "1";
150  }
151  return test_StandardAdcChannelStringTool(useExistingFcl);
152 }
int test_StandardAdcChannelStringTool(bool useExistingFcl=false)
QTextStream & endl(QTextStream &s)
int test_StandardAdcChannelStringTool ( bool  useExistingFcl = false)

Definition at line 27 of file test_StandardAdcChannelStringTool.cxx.

27  {
28  const string myname = "test_StandardAdcChannelStringTool: ";
29 #ifdef NDEBUG
30  cout << myname << "NDEBUG must be off." << endl;
31  abort();
32 #endif
33  string line = "-----------------------------";
34 
35  cout << myname << line << endl;
36  string fclfile = "test_StandardAdcChannelStringTool.fcl";
37  if ( ! useExistingFcl ) {
38  cout << myname << "Creating top-level FCL." << endl;
39  ofstream fout(fclfile.c_str());
40  fout << "tools: {" << endl;
41  fout << " mytool: {" << endl;
42  fout << " tool_type: StandardAdcChannelStringTool" << endl;
43  fout << " LogLevel: 2" << endl;
44  fout << " RunWidth: 4" << endl;
45  fout << " SubRunWidth: 3" << endl;
46  fout << " EventWidth: 6" << endl;
47  fout << " ChannelWidth: 5" << endl;
48  fout << " CountWidth: 6" << endl;
49  fout << " FembWidth: 3" << endl;
50  fout << " TriggerWidth: 2" << endl;
51  fout << " TrigNames: [unknown]" << endl;
52  fout << " }" << endl;
53  fout << "}" << endl;
54  fout.close();
55  } else {
56  cout << myname << "Using existing top-level FCL." << endl;
57  }
58 
59  cout << myname << line << endl;
60  cout << myname << "Fetching tool manager." << endl;
62  assert ( ptm != nullptr );
63  DuneToolManager& tm = *ptm;
64  tm.print();
65  assert( tm.toolNames().size() == 1 );
66 
67  cout << myname << line << endl;
68  cout << myname << "Fetching tool." << endl;
69  auto past = tm.getPrivate<AdcChannelStringTool>("mytool");
70  assert( past != nullptr );
71 
72  cout << myname << line << endl;
73  cout << myname << "Create data." << endl;
74  AdcChannelData acd;
75  acd.setEventInfo(123, 246, 45, 1847483647, 123456789);
76  acd.setChannelInfo(1357, 24);
77  acd.sampleUnit = "my units";
78 
79  cout << myname << line << endl;
80  cout << myname << "Call tool." << endl;
81  vector<string> rawNames = {
82  "run%RUN%",
83  "srun%SUBRUN%",
84  "run%RUN%_srun%XXBRUN%",
85  "run%RUN%_srun%SUBRUN%",
86  "data_run%RUN%-%SUBRUN%_ev%EVENT%_ch%CHAN%_%COUNT%.dat",
87  "data_run%5RUN%-%5SUBRUN%_ev%5EVENT%_ch%5CHAN%_%5COUNT%.dat",
88  "data_run%0RUN%-%0SUBRUN%_ev%0EVENT%_ch%0CHAN%_%0COUNT%.dat",
89  "data_run%0RUN%_run%8RUN%.dat",
90  "Units are %SUNIT%",
91  "Units are %(SUNIT)%",
92  "Units are %((SUNIT))%",
93  "Units are% ((SUNIT))%",
94  "FEMB is %FEMB%",
95  "femb%4FEMB%",
96  "femb%0FEMB%",
97  "date: %UTCTIME%",
98  "time: %UTCTIME9%"
99  };
100  vector<string> expNames = {
101  "run123",
102  "srun45",
103  "run123_srun%XXBRUN%",
104  "run123_srun45",
105  "data_run123-45_ev246_ch1357_23.dat",
106  "data_run00123-00045_ev00246_ch01357_00023.dat",
107  "data_run0123-045_ev000246_ch01357_000023.dat",
108  "data_run0123_run00000123.dat",
109  "Units are my units",
110  "Units are (my units)",
111  "Units are (my units)",
112  "Units are (my units)",
113  "FEMB is 24",
114  "femb0024",
115  "femb024",
116  "date: 2028-07-17 21:54:07",
117  "time: 2028-07-17 21:54:07.123456789"
118  };
119  DataMap dm;
120  dm.setInt("count", 23);
121  assert( dm.haveInt("count") );
122 
123  for ( Index inam=0; inam<rawNames.size(); ++inam ) {
124  string rawName = rawNames[inam];
125  string expName = expNames[inam];
126  string outName = past->build(acd, dm, rawName);
127  cout << myname << " Raw name: " << rawName << endl;
128  cout << myname << " Exp name: " << expName << endl;
129  cout << myname << " Out name: " << outName << endl;
130  assert( outName == expName );
131  }
132 
133  cout << myname << line << endl;
134  cout << myname << "Done." << endl;
135  return 0;
136 }
const std::vector< std::string > & toolNames() const
bool haveInt(Name name) const
Definition: DataMap.h:207
void print() const
unsigned int Index
tm
Definition: demo.py:21
void setChannelInfo(ChannelInfoPtr pchi)
void setEventInfo(EventInfoPtr pevi)
void setInt(Name name, int val)
Definition: DataMap.h:131
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)