28 std::vector<float> charge(nticks,0);
29 for (
int ind=0; ind<
nticks; ++ind) {
30 const double t = bins.
center(ind);
31 const double rel = (t-
time)/sigma;
32 const double val =
mag * exp(-0.5*rel*rel);
38 float maximum(
const std::vector<float>& wave) {
40 for (
auto q : wave ) {
49 TH1F*
hist =
new TH1F(name.c_str(), title.c_str(), wave.size(), 0, wave.size()+1);
52 hist->Fill(tick+0.5, q);
55 hist->SetXTitle(
"tick");
56 hist->SetYTitle(
"amplitude");
64 TH2F* out = (TH2F*)f1->Clone(
"ratio");
65 out->SetTitle(
"Ratio - no time shift correction");
67 out->SetXTitle(
"ticks");
68 out->SetYTitle(
"channels");
77 auto traces = frame->traces();
79 int maxchan=0, maxtick=0;
80 for (
auto trace : (*traces)) {
81 auto& charge =
trace->charge();
86 int chan =
trace->channel();
90 cerr << name <<
" " << chan <<
" " << tick <<
" " <<
maximum(charge) <<
"\n";
93 TH2F*
hist =
new TH2F(name.c_str(), name.c_str(),
94 maxtick+1, 0, maxtick+1,
95 maxchan+1, 0, maxchan+1);
97 for (
auto trace : (*traces)) {
99 int chan =
trace->channel();
100 auto& charge =
trace->charge();
101 for (
float q : charge) {
102 hist->Fill(tick+0.5, chan+0.5, q);
106 hist->SetXTitle(
"ticks");
107 hist->SetYTitle(
"channels");
108 hist->SetContour(50);
111 hist->GetXaxis()->SetRangeUser(0, mtick);
114 hist->GetYaxis()->SetRangeUser(0, mchan);
125 pm.
add(
"WireCellGen");
126 pm.
add(
"WireCellRoot");
129 double gain, shaping,
tick;
133 cfg[
"nsamples"] = nsamples;
134 cfg[
"truncate"] =
true;
136 gain = cfg[
"from"][
"gain"].asDouble();
137 shaping = cfg[
"from"][
"shaping"].asDouble();
138 tick = cfg[
"tick"].asInt();
139 mccfg->configure(cfg);
145 auto resp = ce.generate(
Binning(200, 0, 200*tick));
146 auto resp2 = ce.generate(
Binning(400, 0, 400*tick));
147 auto resp3 = ce.generate(
Binning(50, 0, 50*tick));
157 for (
int nbins : {50, 100, 200, 400}) {
160 auto q1 =
blip(bins, 0.25 *
nbins * tick);
162 auto q3 =
blip(bins, 0.75 *
nbins * tick);
166 q_traces.push_back(std::make_shared<SimpleTrace>(qchannel++, 0, q1));
167 q_traces.push_back(std::make_shared<SimpleTrace>(qchannel++, 0, q2));
168 q_traces.push_back(std::make_shared<SimpleTrace>(qchannel++, 0, q3));
169 q_traces.push_back(std::make_shared<SimpleTrace>(qchannel++, 0, q4));
176 out_traces.push_back(std::make_shared<SimpleTrace>(channel++, 0, e1));
177 out_traces.push_back(std::make_shared<SimpleTrace>(channel++, 0, e2));
178 out_traces.push_back(std::make_shared<SimpleTrace>(channel++, 0, e3));
179 out_traces.push_back(std::make_shared<SimpleTrace>(channel++, 0, e4));
182 auto qorig = std::make_shared<SimpleFrame>(0, 0.0, q_traces,
tick);
183 auto orig = std::make_shared<SimpleFrame>(0, 0.0, out_traces,
tick);
186 bool ok = (*mc)(orig, mced);
187 if (!ok) {
return -1; }
191 gStyle->SetOptStat(0);
192 gStyle->SetOptFit(0);
195 plot_wave(pdf,resp,
"resp",
"Electronics response waveform - 200 bins");
196 plot_wave(pdf,resp2,
"resp2",
"Electronics response waveform - 400 bins");
197 plot_wave(pdf,resp3,
"resp3",
"Electronics response waveform - 50 bins");
202 plot_frame(pdf, qorig,
"ChargeZoomed", 50., 5.);
203 plot_frame(pdf, orig,
"ShapedZoomed", 50., 5.);
204 plot_frame(pdf, mced,
"MisconfiguredZoomed", 50, 5);
double center(int ind) const
const std::string instance
A functional object caching gain and shape.
std::shared_ptr< IFrameFilter > pointer
Json::Value Configuration
cet::LibraryManager dummy("noplugin")
Plugin * add(const std::string &plugin_name, const std::string &libname="")
Add a plugin. If libname is not given, try to derive it.
const GenericPointer< typename T::ValueType > & pointer
array_xxc dft(const array_xxf &arr)