34 const string myname =
"test_AdcChannelDftPlotter: ";
36 cout << myname <<
"NDEBUG must be off." <<
endl;
39 string line =
"-----------------------------";
41 cout << myname << line <<
endl;
42 string fclfile =
"test_AdcChannelDftPlotter.fcl";
44 if ( ! useExistingFcl ) {
45 cout << myname <<
"Creating top-level FCL." <<
endl;
46 ofstream
fout(fclfile.c_str());
47 fout <<
"#include \"dataprep_tools.fcl\"" <<
endl;
48 fout <<
"tools.mytemplate: {" <<
endl;
49 fout <<
" tool_type: AdcChannelDftPlotter" <<
endl;
51 fout <<
" ChannelStatusFlag: 0" <<
endl;
52 fout <<
" ChannelSelection: \"\"" <<
endl;
59 fout <<
" HistSummaryTitles: []" <<
endl;
60 fout <<
" PlotDataView: \"\"" <<
endl;
62 fout <<
" PlotSummaryNames: []" <<
endl;
63 fout <<
" PlotChannelRanges: []" <<
endl;
64 fout <<
" PlotChannelGroups: []" <<
endl;
65 fout <<
" PlotOverlayGroups: 1" <<
endl;
72 fout <<
"tools.myphases: @local::tools.mytemplate" <<
endl;
73 fout <<
"tools.myphases.Variable: phase" <<
endl;
74 fout <<
"tools.myphases.HistName: \"hdftphase_run%0RUN%_evt%0EVENT%\"" <<
endl;
75 fout <<
"tools.myphases.HistTitle: \"DFT phases for run %RUN% event %EVENT% channel %CHAN%\"" <<
endl;
76 fout <<
"tools.myphases.PlotName: \"dftphase_run%0RUN%_evt%0EVENT%.png\"" <<
endl;
78 fout <<
"tools.mymags: @local::tools.mytemplate" <<
endl;
79 fout <<
"tools.mymags.Variable: magnitude" <<
endl;
80 fout <<
"tools.mymags.YMax: 0.0" <<
endl;
81 fout <<
"tools.mymags.HistName: \"hdftmags_run%0RUN%_evt%0EVENT%\"" <<
endl;
82 fout <<
"tools.mymags.HistTitle: \"DFT amplitudes for run %RUN% event %EVENT% channel %CHAN%\"" <<
endl;
83 fout <<
"tools.mymags.PlotName: \"dftmag_run%0RUN%_evt%0EVENT%.png\"" <<
endl;
85 fout <<
"tools.mypwr: @local::tools.mytemplate" <<
endl;
86 fout <<
"tools.mypwr.Variable: power" <<
endl;
87 fout <<
"tools.mypwr.YMax: 65.0" <<
endl;
88 fout <<
"tools.mypwr.NBinX: 5" <<
endl;
89 fout <<
"tools.mypwr.HistName: \"hdftpower_run%0RUN%_evt%0EVENT%\"" <<
endl;
90 fout <<
"tools.mypwr.HistTitle: \"DFT power for run %RUN% event %EVENT% channel %CHAN%\"" <<
endl;
91 fout <<
"tools.mypwr.PlotName: \"dftpower_run%0RUN%_evt%0EVENT%_ch%0CHAN%.png\"" <<
endl;
93 fout <<
"tools.mypwt: @local::tools.mytemplate" <<
endl;
94 fout <<
"tools.mypwt.Variable: \"power/tick\"" <<
endl;
95 fout <<
"tools.mypwt.YMax: 6.0" <<
endl;
96 fout <<
"tools.mypwt.NBinX: 5" <<
endl;
97 fout <<
"tools.mypwt.HistName: \"hdftpowt_run%0RUN%_evt%0EVENT%\"" <<
endl;
98 fout <<
"tools.mypwt.HistTitle: \"DFT power for run %RUN% event %EVENT% channel %CHAN%\"" <<
endl;
99 fout <<
"tools.mypwt.PlotName: \"dftpowt_run%0RUN%_evt%0EVENT%_ch%0CHAN%.png\"" <<
endl;
100 fout <<
"tools.mvpwr: @local::tools.mypwr" <<
endl;
101 fout <<
"tools.mvpwr.PlotDataView: " << vnam <<
endl;
102 fout <<
"tools.mvpwr.HistTitle: \"DFT power for run %RUN% event %EVENT% channel %CHAN% view %VIEW%\"" <<
endl;
103 fout <<
"tools.mvpwr.PlotName: \"dftpower_run%0RUN%_evt%0EVENT%_ch%0CHAN%_view%VIEW%.png\"" <<
endl;
106 cout << myname <<
"Using existing top-level FCL." <<
endl;
109 cout << myname << line <<
endl;
110 cout << myname <<
"Fetching tool manager." <<
endl;
112 assert ( ptm !=
nullptr );
117 cout << myname << line <<
endl;
118 cout << myname <<
"Fetching tools." <<
endl;
124 assert( ppha !=
nullptr );
125 assert( pmag !=
nullptr );
126 assert( ppwr !=
nullptr );
127 assert( ppwt !=
nullptr );
128 assert( ppwrv !=
nullptr );
130 cout << myname << line <<
endl;
131 cout << myname <<
"Create data." <<
endl;
136 float pi = acos(-1.0);
137 vector<float> mags = { 1.0, 2.0, 3.0, 4.0, 5.0, 4.0, 2.0, 1.0, 1.0, 1.0, 1.0 };
138 vector<float> phas = { 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, -2.0, -1.5, -1.0 };
141 cout << myname <<
" Mag size: " << mags.
size() <<
endl;
142 cout << myname <<
"Phase size: " << phas.
size() <<
endl;
144 cout << myname << line <<
endl;
145 cout << myname <<
"Create data map." <<
endl;
147 for (
Index icha=10000; icha<10010; ++icha ) {
149 acds[icha].setChannelInfo(icha);
150 acds[icha].dftmags = mags;
151 acds[icha].dftphases = phas;
152 for (
float&
mag : mags )
mag *= 1.02;
153 for (
float& pha : phas ) { pha += 0.2;
if ( pha > pi ) pha -= 2.0*
pi; }
156 for (
float&
mag : vmags )
mag *= sqrt(0.70);
158 for (
float& pha : vphas ) { pha += 0.4;
if ( pha > pi ) pha -= 2.0*
pi; }
159 acds[icha].updateView(vnam).push_back(acds[icha]);
160 acds[icha].updateView(vnam).back().dftmags = vmags;
161 acds[icha].updateView(vnam).back().dftphases = vphas;
163 for (
float&
mag : vmags )
mag *= sqrt(0.30);
165 for (
float& pha : vphas ) { pha += 0.4;
if ( pha > pi ) pha -= 2.0*
pi; }
166 acds[icha].updateView(vnam).push_back(acds[icha]);
167 acds[icha].updateView(vnam).back().dftmags = vmags;
168 acds[icha].updateView(vnam).back().dftphases = vphas;
171 cout << myname << line <<
endl;
172 cout << myname <<
"Call phase tool." <<
endl;
177 cout << myname << line <<
endl;
178 cout << myname <<
"Call mag tool." <<
endl;
179 dm = pmag->
view(acd);
183 cout << myname << line <<
endl;
184 cout << myname <<
"Call power tool." <<
endl;
185 dm = ppwr->
view(acd);
189 cout << myname << line <<
endl;
190 cout << myname <<
"Call tick power tool." <<
endl;
191 dm = ppwt->
view(acd);
195 cout << myname << line <<
endl;
196 cout << myname <<
"Call power tool with map." <<
endl;
201 cout << myname << line <<
endl;
202 cout << myname <<
"Call tick power tool with map." <<
endl;
207 cout << myname << line <<
endl;
208 cout << myname <<
"Call tick power view tool with map." <<
endl;
213 cout << myname << line <<
endl;
214 cout << myname <<
"Done." <<
endl;
ChannelGroupService::Name Name
void print(std::ostream *pout) const
void setChannelInfo(ChannelInfoPtr pchi)
void setEventInfo(EventInfoPtr pevi)
AdcSignalVector dftphases
void line(double t, double *p, double &x, double &y, double &z)
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
QTextStream & endl(QTextStream &s)