28 using std::ostringstream;
29 using std::istringstream;
46 Plot(
Index npad) : topman(400, 800) {
47 topman.
split(1, npad);
50 string myname =
"Plot::addData: ";
53 for (
auto& ent : data ) {
55 if ( pman ==
nullptr ) {
56 cout << myname <<
"ERROR: Unable to find subpad " << iman <<
endl;
60 Index icha = ent.first;
63 Index nsam = sams.size();
66 Name hnam =
"hch" + scha;
67 Name httl =
"Channel " + scha +
";Tick;Charge";
68 TH1* ph =
new TH1F(hnam.c_str(), httl.c_str(), nsam, 0, nsam);
70 ph->SetLineWidth(lwid);
71 ph->SetLineStyle(lsty);
72 ph->SetLineColor(col);
73 for (
Index isam=0; isam<nsam; ++isam ) {
75 ph->Fill(isam+1, sams[isam]);
87 string myname =
"Plot::print: ";
96 if ( x1 == x2 )
return true;
97 if ( x1 > 0.0 && x2 > 0.0 ) {
98 return fabs(x1-x2)/x1+x2 < 1.e-6;
107 const string mypre =
"test_Adc2dConvolute";
108 const string myname = mypre +
": ";
110 cout << myname <<
"NDEBUG must be off." <<
endl;
113 string line =
"-----------------------------";
115 cout << myname << line <<
endl;
116 string fclfile =
"test_Adc2dConvolute.fcl";
121 if ( ! useExistingFcl ) {
122 cout << myname <<
"Creating top-level FCL." <<
endl;
123 ofstream
fout(fclfile.c_str());
126 fout <<
" tool_type: Adc2dConvolute" <<
endl;
128 fout <<
" ResponseVectors: [" <<
endl;
129 fout <<
" [0.2, 0.4, 0.3, 0.1], [0.2, 0.4, 0.3, 0.1]," <<
endl;
130 fout <<
" [0.1, 0.2, 0.15, 0.05], [0.05, 0.10, 0.075, 0.025]," <<
endl;
131 fout <<
" [0.025, 0.050, 0.0375, 0.0125], [0.0125, 0.025, 0.01875, 0.00625]" <<
endl;
133 fout <<
" ResponseCenter: 1" <<
endl;;
136 fout <<
" MinChannel: 101" <<
endl;;
137 fout <<
" MaxChannel: 104" <<
endl;;
142 cout << myname <<
"Using existing top-level FCL." <<
endl;
145 cout << myname << line <<
endl;
146 cout << myname <<
"Fetching tool manager." <<
endl;
148 assert ( ptm !=
nullptr );
153 cout << myname << line <<
endl;
154 cout << myname <<
"Fetching tool." <<
endl;
156 assert( pcondir !=
nullptr );
158 cout << myname << line <<
endl;
159 cout << myname <<
"Create empty input data." <<
endl;
163 for (
Index icha=100; icha<105; ++icha ) {
169 std::map<Index,float> expAreas;
170 for (
Index icha=100; icha<106; ++icha ) expAreas[icha] = 0.0;
176 cout << myname <<
"Add signal " << ++isig <<
endl;
177 data[103].binSamples[3][10] = 100.0;
178 expAreas[102] += 6.25;
179 expAreas[103] += 100.0;
180 expAreas[104] += 50.0;
184 cout << myname <<
"Add signal " << ++isig <<
endl;
185 data[102].binSamples[1][20] = 100.0;
186 expAreas[101] += 25.0;
187 expAreas[102] += 100.0;
188 expAreas[103] += 12.5;
191 cout << myname << line <<
endl;
192 cout << myname <<
"Check signals." <<
endl;
194 cout << myname <<
"Add signal " << ++isig <<
endl;
195 data[101].binSamples[0][30] = 100.0;
196 expAreas[101] += 100.0;
197 expAreas[102] += 6.25;
200 cout << myname << line <<
endl;
201 cout << myname <<
"Check signals." <<
endl;
202 cout << myname <<
"Signal count: " << nsig <<
endl;
203 assert( isig == nsig );
205 cout << myname << line <<
endl;
206 cout << myname <<
"Call tool." <<
endl;
207 DataMap ret = pcondir->updateMap(data);
210 assert( ret.
getInt(
"responseVectorCount") == 6 );
211 assert( ret.
getInt(
"channelMin") == 101 );
212 assert( ret.
getInt(
"channelMax") == 104 );
214 cout << myname << line <<
endl;
215 cout << myname <<
"Check areas" <<
endl;
216 cout << myname <<
"Chan Nsam Area" <<
endl;
217 cout << myname <<
"---- ---- -----------" <<
endl;
218 for (
const auto& kdat : data ) {
219 Index icha = kdat.first;
223 for (
float sam : sams ) area +=
sam;
224 cout << myname <<
setw(4) << icha <<
setw(6) << nsam <<
setw(13) << area <<
endl;
228 cout << myname << line <<
endl;
229 string fnam =
"convhist.png";
230 cout << myname <<
"Create plot " << fnam <<
endl;
231 Plot plt(data.size());
232 plt.addData(data, 1, 2, 1);
235 cout << myname << line <<
endl;
236 cout << myname <<
"Done." <<
endl;
243 bool useExistingFcl =
false;
245 string sarg(argv[1]);
246 if ( sarg ==
"-h" ) {
247 cout <<
"Usage: " << argv[0] <<
" [KEEPFCL [NOISE [SIGMAFIL [NSAM [SETSEED]]]]]" <<
endl;
248 cout <<
" KEEPFCL = if 1 (or true), existing FCL file is used [false]" <<
endl;
251 useExistingFcl = sarg ==
"true" || sarg ==
"1";
int setGridY(bool flag=true)
AdcSignalVectorVector binSamples
int add(unsigned int ipad, TObject *pobj, std::string sopt="", bool replace=false)
ChannelGroupService::Name Name
int split(Index nx, Index ny)
int main(int argc, char *argv[])
int test_Adc2dConvolute(bool useExistingFcl)
void print(std::ostream *pout) const
bool checkEqual(string s1, string s2)
void setChannelInfo(ChannelInfoPtr pchi)
void setEventInfo(EventInfoPtr pevi)
TPadManipulator * man(unsigned int ipad=0)
Q_EXPORT QTSManip setw(int w)
int getInt(Name name, int def=0) const
void line(double t, double *p, double &x, double &y, double &z)
std::vector< AdcSignal > AdcSignalVector
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
int setRangeY(double y1, double y2)
std::string to_string(ModuleType const mt)
int print(std::string fname, std::string spat="{,}")
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
QTextStream & endl(QTextStream &s)