30 const string myname =
"test_AdcRoiViewer: ";
32 cout << myname <<
"NDEBUG must be off." <<
endl;
35 string line =
"-----------------------------";
37 cout << myname << line <<
endl;
38 string fclfile =
"test_AdcRoiViewer.fcl";
39 if ( ! useExistingFcl ) {
40 cout << myname <<
"Creating top-level FCL." <<
endl;
41 ofstream
fout(fclfile.c_str());
42 fout <<
"#include \"dataprep_tools.fcl\"" <<
endl;
44 fout <<
" tool_type: AdcRoiViewer" <<
endl;
51 fout <<
" PulserStepCharge: 0.0" <<
endl;
52 fout <<
" PulserDacOffset: 0.0" <<
endl;
53 fout <<
" PulserChargeUnit: \"\"" <<
endl;
61 fout <<
" RunDataTool: \"\"" <<
endl;
62 fout <<
" TickOffsetTool: \"\"" <<
endl;
64 fout <<
" ChannelRanges: []" <<
endl;
66 fout <<
" ChannelLineModulus: 0" <<
endl;
67 fout <<
" ChannelLinePattern: []" <<
endl;
68 fout <<
" RoiRootFileName: \"roi.root\"" <<
endl;
69 fout <<
" SumRootFileName: \"\"" <<
endl;
70 fout <<
" ChanSumRootFileName: \"\"" <<
endl;
71 fout <<
" PlotLabels: [\"very\", \"nice\"]" <<
endl;
73 fout <<
"tools.mytool2: @local::tools.mytool1" <<
endl;
74 fout <<
"tools.mytool2.SumHists: [" <<
endl;
75 fout <<
" {var:\"fitHeight\" name:\"hfh_%0RUN%\"" 76 <<
" title:\"Combined fit height run %RUN%\"" 77 <<
" nbin:60 xmin:-300 xmax:300 plot:\"\"}, " <<
endl;
78 fout <<
" {var:\"fitHeight\" name:\"hfh_%0RUN%_chan%0CHAN%\"" 79 <<
" title:\"Fit height run %RUN% channel %CHAN%\"" 80 <<
" nbin:40 xmin:0 xmax:0 fit:gaus plot:\"\"}," <<
endl;
81 fout <<
" {var:\"fitWidth\" name:\"hfw_%0RUN%_chan%0CHAN%\"" 82 <<
" title:\"Fit width run %RUN% channel %CHAN%\"" 83 <<
" nbin:40 xmin:0 xmax:4.0 fit:gaus plot:\"\"}" <<
endl;
85 fout <<
"tools.mytool2.ChanSumHists: [" <<
endl;
86 fout <<
" {name:\"hcsHeight_%CRNAME%\" title:\"Pulse heights for %LAB0% %LAB1% run %RUN% %CRLABEL%\" " 87 <<
"valHist:\"hfh_%0RUN%_chan%0CHAN%\" valType:fitMean errType:fitSigma nbins:0 cr:apa1x plot:\"\" pran:\"\"}," <<
endl;
88 fout <<
" {name:\"hcsWidth_%CRNAME%\" title:\"Shaping times for run %RUN% %CRLABEL%\" " 89 <<
"valHist:\"hfw_%0RUN%_chan%0CHAN%\" valType:fitMean errType:fitSigma nbins:0 cr:apa1x plot:\"\" pran:\"\"}" <<
endl;
92 fout <<
"tools.mytool2.RoiRootFileName: \"\"" <<
endl;
93 fout <<
"tools.mytool2.SumRootFileName: \"roisum.root\"" <<
endl;
94 fout <<
"tools.mytool2.ChanSumRootFileName: \"roichan.root\"" <<
endl;
95 fout <<
"tools.channelRanges: {" <<
endl;
96 fout <<
" tool_type: FclIndexRangeTool" <<
endl;
99 fout <<
" {name:apa1x label:APA1x begin:250 end:270}" <<
endl;
104 cout << myname <<
"Using existing top-level FCL." <<
endl;
107 cout << myname << line <<
endl;
108 cout << myname <<
"Fetching tool manager." <<
endl;
110 assert ( ptm !=
nullptr );
115 cout << myname << line <<
endl;
116 cout << myname <<
"Fetching tool." <<
endl;
118 assert( ptoo1 !=
nullptr );
120 assert( ptoo2 !=
nullptr );
122 cout << myname << line <<
endl;
123 cout << myname <<
"Create test data." <<
endl;
125 vector<float> pulse = { 2.0, -3.0, 0.0, 5.0, 24.0, 56.0, 123.0, 71.0, 52.1, 26.3,
126 12.5, 8.1, 4.5, 2.0, -1.0, 3.2, 1.1, -2.2, 0.1, -0.1};
128 for (
Index icha=250; icha<270; ++icha ) {
136 for (
Index ipul=0; ipul<npul; ++ipul ) {
138 for (
Index ismp=0; ismp<pulse.
size(); ++ismp, ++itck ) {
139 acd.
samples[itck] = pulse[ismp] + gRandom->Gaus(0.0, sigma);
141 acd.
rois.emplace_back( itck0+2, itck-2);
143 assert( acd.
rois.size() == npul );
147 cout << myname << line <<
endl;
148 cout << myname <<
"Call tool for one channel." <<
endl;
149 DataMap res = ptoo1->view(acd);
151 cout << myname <<
"roiCount: " << res.
getInt(
"roiCount") <<
endl;
152 cout << myname <<
"roiHists:" <<
endl;
154 cout << myname <<
" " << ph->GetName() <<
endl;
158 assert( nroi == npul );
161 assert( res.
getIntVector(
"roiNUnderflows").size() == nroi );
162 assert( res.
getIntVector(
"roiNOverflows").size() == nroi );
163 assert( res.
getIntVector(
"roiTickMins").size() == nroi );
164 assert( res.
getIntVector(
"roiTickMaxs").size() == nroi );
173 cout << myname << line <<
endl;
174 cout << myname <<
"Call tool for channel map." <<
endl;
175 res = ptoo2->viewMap(acds);
177 cout << myname <<
"roiCount: " << res.
getInt(
"roiCount") <<
endl;
178 cout << myname <<
"roiHists:" <<
endl;
180 assert( res.
getInt(
"roiCount") ==
int(npul*acds.size()) );
182 cout << myname << line <<
endl;
183 cout << myname <<
"Done." <<
endl;
const IntVector & getIntVector(Name name) const
const FloatVector & getFloatVector(Name name) const
void print(std::ostream *pout) const
const HistVector & getHistVector(Name name) const
void setChannelInfo(ChannelInfoPtr pchi)
void setEventInfo(EventInfoPtr pevi)
int getInt(Name name, int def=0) const
void line(double t, double *p, double &x, double &y, double &z)
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
QTextStream & endl(QTextStream &s)