23 std::vector<TH1F*>
plot_wave(TCanvas& canvas,
int padnum,
31 const double vbin = vmax/
nbins;
33 TH1F* ht =
new TH1F(
"ht", Form(
"%s - waveform", name.c_str()),
35 ht->SetXTitle(Form(
"time (ms, %d bins)", nbins));
37 ht->GetXaxis()->SetRangeUser(bounds.first, bounds.second);
39 TH1F* hm =
new TH1F(
"hm", Form(
"%s - magnitude", name.c_str()),
41 hm->SetXTitle(Form(
"frequency (MHz, %d bins)", nbins));
44 TH1F* hp =
new TH1F(
"hp", Form(
"%s - phase", name.c_str()),
46 hp->SetXTitle(Form(
"frequency (MHz, %d bins)", nbins));
49 for (
int ind=0; ind<bins.
nbins(); ++ind) {
50 const double tms = bins.
center(ind);
51 const double fMHz = (ind+0.5)*vbin;
53 hm->Fill(fMHz,
std::abs(fdomain[ind]));
54 hp->Fill(fMHz,
std::arg(fdomain[ind]));
59 gpad = canvas.cd(padnum++);
62 gpad = canvas.cd(padnum++);
66 gpad = canvas.cd(padnum++);
69 return std::vector<TH1F*>{ht,hm,hp};
75 std::cerr <<
"This test requires an Wire Cell Field Response input file." <<
std::endl;
79 const char* uvw=
"UVW";
84 Binning bins(nticks, 0, nticks*tick);
90 TCanvas canvas(
"h",
"h",900,1200);
91 canvas.Print(Form(
"%s.pdf[", argv[0]),
"pdf");
93 const int nplanes = 3;
94 for (
int iplane=0; iplane<nplanes; ++iplane) {
96 auto plane_response = fr.planes[iplane];
98 const int npaths = plane_response.paths.size();
100 for (
int ipath=0; ipath<npaths; ++ipath) {
101 auto& path_response = plane_response.paths[ipath];
105 const int rawresp_size = raw_response.size();
107 const double rawresp_min = fr.tstart;
108 const double rawresp_tick = fr.period;
109 const double rawresp_max = rawresp_min + rawresp_size*rawresp_tick;
110 Binning rawresp_bins(rawresp_size, rawresp_min, rawresp_max);
114 for (
int ind=0; ind<rawresp_size; ++ind) {
116 const int bin = bins.
bin(time);
117 response[
bin] += raw_response[ind];
121 const double charge_const = 1000.0;
126 for (
int ind=0; ind<
nticks; ++ind) {
127 const double t = bins.
center(ind);
128 const double rel = (t-charge_time)/charge_sigma;
129 const double val = charge_const * exp(-0.5*rel*rel);
130 electrons[ind] =
val;
140 for (
int ind=0; ind <
nticks; ++ind) {
141 conv_spectrum[ind] = response_spectrum[ind]*charge_spectrum[ind];
144 for (
int ind=0; ind <
nticks; ++ind) {
151 std::string extra = Form(
" %c-%.1f", uvw[iplane], path_response.pitchpos);
153 plot_wave(canvas, 1,
"Response"+extra, std::make_pair(0,.1),
154 rawresp_bins, raw_response, raw_response_spectrum);
155 plot_wave(canvas, 4,
"Response"+extra, std::make_pair(0,.1),
156 bins, response, response_spectrum);
157 plot_wave(canvas, 7,
"Electrons"+extra, std::make_pair(.9,1.1),
158 bins, electrons, charge_spectrum);
159 plot_wave(canvas, 10,
"Signal"+extra, std::make_pair(.9,1.1),
160 bins, conv, conv_spectrum);
162 canvas.Print(Form(
"%s.pdf", argv[0]),
"pdf");
167 canvas.Print(Form(
"%s.pdf]", argv[0]),
"pdf");
int main(int argc, char *argv[])
double center(int ind) const
internal::named_arg< T, char > arg(string_view name, const T &arg)
std::vector< TH1F * > plot_wave(TCanvas &canvas, int padnum, std::string name, std::pair< double, double > bounds, const Binning &bins, const Waveform::realseq_t &tdomain, const Waveform::compseq_t &fdomain)
int bin(double val) const
BoundingBox bounds(int x, int y, int w, int h)
FieldResponse load(const char *filename)
static const double second
QTextStream & bin(QTextStream &s)
QTextStream & endl(QTextStream &s)