32 TH1F h_wave(
"response",title.c_str(),
34 TH1F h_wave2(
"response2",title.c_str(),
36 cout<<
"tbins.min()"<<tbins.
min()<<
endl;
37 cout<<
"tbins.max()"<<tbins.
max()<<
endl;
38 h_wave2.SetLineColor(2);
40 h_wave.SetXTitle(
"Time (microsecond)");
41 h_wave.SetYTitle(
"Gain (mV/fC)");
42 h_wave.GetXaxis()->SetRangeUser(0,10.0);
45 for (
int ind=0; ind<
nticks; ++ind) {
50 cerr << nticks <<
" " << spec.size() <<
endl;
53 const Binning fbins(nticks, 0, 1/tick);
55 TH1F h_mag(
"mag",
"Magnitude of Fourier transform of response",
57 h_mag.SetYTitle(
"Amplitude [mV/fC]");
58 h_mag.SetXTitle(
"MHz");
60 TH1F h_phi(
"phi",
"Phase of Fourier transform of response",
62 h_phi.SetYTitle(
"Phase [radian]");
63 h_phi.SetXTitle(
"MHz");
65 for (
int ind=0; ind<
nticks; ++ind) {
67 const double freq = fbins.
center(ind);
77 auto pad = pdf.
canvas.cd(1);
81 h_wave2.Draw(
"hist,same");
83 auto spad = pdf.
canvas.cd(2);
92 double maxmag = h_mag.GetMaximum();
93 double db3 = maxmag / 1.414;
94 double db6 = maxmag / 1.995;
95 double db10 = maxmag / 3.162;
96 double db20 = maxmag / 10;
97 ndb.DrawLine(0,db3, 1.0, db3);
98 ndb.DrawLine(0,db6, 1.0, db6);
99 ndb.DrawLine(0,db10, 1.0, db10);
100 ndb.DrawLine(0,db20, 1.0, db20);
101 ndbtxt.DrawText(0.5, db3,
"-3dB");
102 ndbtxt.DrawText(0.5, db6,
"-6dB");
103 ndbtxt.DrawText(0.5, db10,
"-10dB");
104 ndbtxt.DrawText(0.5, db20,
"-20dB");
116 const std::vector<double> gains = {7.8*
GUnit, 14.0*
GUnit};
123 cerr <<
"Using nticks=" << nticks <<
endl;
127 for (
size_t ind=0; ind<gains.size(); ++ind) {
131 const double tshape_us = shapings[ind]/
units::us;
132 auto tit = Form(
"Cold Electronics Response at %.0fus peaking",
146 auto tit =
"RC Response at 1ms time constant";
155 auto tit =
"RC Response at 1ms time constant (suppress delta)";
163 auto tit =
"Response Gaussian smear by default";
170 Binning ttt(nsigma*2*smear/tick, -nsigma*smear, nsigma*smear);
174 auto tit =
"Response Gaussian 2 us smear";
183 TGraph* timings[4] = {
184 new TGraph,
new TGraph,
new TGraph,
new TGraph
188 std::vector<int> nsampleslist{128, 256,
207 const int ntries = 1000;
208 for (
auto nsamps : nsampleslist) {
210 const Binning bins(nsamps, 0, maxtime);
214 double fwd_time = 0.0;
215 for (
int itry=0; itry<ntries; ++itry) {
223 double rev_time = 0.0;
224 for (
int itry=0; itry<ntries; ++itry) {
232 cerr <<
"DFT nsamples=" << nsamps
233 <<
"\n\tforward: " << fwd_time/1000.0 <<
" us, " << fwd_time/nsamps/1000.0 <<
" us/sample" 234 <<
"\n\treverse: " << rev_time/1000.0 <<
" us, " << rev_time/nsamps/1000.0 <<
" us/sample" 235 <<
"\n\taverage: " << 0.5*(fwd_time+rev_time)/1000.0 <<
" us" 238 cout <<
"timing " << nsamps <<
" " 239 << fwd_time/1000.0 <<
" " 240 << rev_time/1000.0 <<
"\n";
242 timings[0]->SetPoint(timings[0]->GetN(), nsamps, fwd_time);
243 timings[1]->SetPoint(timings[1]->GetN(), nsamps, fwd_time/nsamps);
244 timings[2]->SetPoint(timings[2]->GetN(), nsamps, rev_time);
245 timings[3]->SetPoint(timings[3]->GetN(), nsamps, rev_time/nsamps);
251 auto text =
new TText;
253 auto pad = pdf.
canvas.cd(1);
257 auto graph = timings[0];
258 auto frame =
graph->GetHistogram();
259 frame->SetTitle(
"Fwd/rev DFT timing (absolute)");
260 frame->GetXaxis()->SetTitle(
"number of samples");
261 frame->GetYaxis()->SetTitle(
"time (ns)");
262 timings[0]->Draw(
"AL");
263 timings[2]->Draw(
"L");
264 for (
int ind=0; ind<
graph->GetN(); ++ind) {
265 auto x =
graph->GetX()[ind];
266 auto y =
graph->GetY()[ind];
267 text->DrawText(
x,
y,Form(
"%.0f",
x));
272 auto pad = pdf.
canvas.cd(2);
276 auto frame = timings[1]->GetHistogram();
277 frame->SetTitle(
"Fwd/rev DFT timing (relative)");
278 frame->GetXaxis()->SetTitle(
"number of samples");
279 frame->GetYaxis()->SetTitle(
"time per sample (ns/samp)");
280 timings[1]->Draw(
"AL");
281 timings[3]->Draw(
"L");
double center(int ind) const
internal::named_arg< T, char > arg(string_view name, const T &arg)
def graph(desc, maker=maker)
A functional object caching gain and shape.
Binning tbins(nticks, t0, t0+readout_time)
void draw_time_freq(MultiPdf &pdf, Waveform::realseq_t &res, const std::string &title, const Binning &tbins)
T gaus(T x, T amplitude, T mean, T sigma)
Tests GausssianFit object with a known input.
WireCell::Waveform::realseq_t generate(const WireCell::Waveform::Domain &domain, int nsamples)
FIXME: eradicate Domain in favor of Binning.
megahertz_as<> megahertz
Type of frequency stored in megahertz, in double precision.
int main(int argc, char *argv[])
array_xxf idft(const array_xxc &arr)
array_xxc dft(const array_xxf &arr)
QTextStream & endl(QTextStream &s)
nanosecond nanoseconds
Alias for common language habits.