23 const char* uvw =
"UVW";
27 const int ntbins = par0.
current.size();
29 const double period = fr.
period;
30 const double pitch = pr.
pitch;
32 const char*
type =
"Fine";
37 int minregion = 999, maxregion = -999;
38 std::vector<double> impacts;
39 for (
auto path : pr.
paths) {
40 const int region = round((path.pitchpos-0.001)/pitch);
41 const double impact = path.pitchpos - region*pitch;
43 minregion =
std::min(minregion, region);
44 maxregion =
std::max(maxregion, region);
46 impacts.push_back(impact);
49 sort(impacts.begin(), impacts.end());
50 double dimpact = impacts[1] - impacts[0];
51 double maximpact = impacts[impacts.size()-1];
53 maximpact = dimpact = 0.0;
56 int npitchbins = pr.
paths.size();
57 double minpitch = -npitchbins/2;
58 double maxpitch = +npitchbins/2;
60 maxpitch = maxregion * pitch + maximpact;
61 minpitch = minregion * pitch - maximpact;
62 npitchbins = (maxpitch-minpitch) / dimpact;
82 TH2F
h(
"h", Form(
"%s %c-plane", type, uvw[pr.
planeid]),
83 ntbins, tstart, tstart + ntbins*period,
84 npitchbins, minpitch, maxpitch);
85 h.SetXTitle(
"time [us]");
86 h.SetYTitle(
"wire region");
89 for (
auto path : pr.
paths) {
91 for (
int ind=0; ind<ntbins; ++ind) {
92 double value = response[ind];
93 const double t = tstart + period*ind;
95 h.Fill(t, path.pitchpos/pitch, value);
98 h.Fill(t, path.pitchpos+0.5*dimpact, value);
114 const int ntbins = p0p0r.
current.size();
116 const double period = fr.
period;
117 const double pitch = p0r.
pitch;
120 std::vector<double> impacts;
121 std::vector<int> regions;
122 for (
auto path : p0r.
paths) {
123 const int region = round((path.pitchpos-0.001)/pitch);
124 const double impact = path.pitchpos - region*pitch;
126 impacts.push_back(impact);
129 regions.push_back(region);
132 sort(impacts.begin(), impacts.end());
133 sort(regions.begin(), regions.end());
135 int plane_colors[] = {2,4,1};
138 int nimpacts = impacts.size();
139 int nregions = regions.size();
140 std::vector<TH1F*>
hists[3];
141 for (
int iplane=0; iplane<3; ++iplane) {
142 hists[iplane].resize(nimpacts*nregions);
143 for (
int imp=0; imp<nimpacts; ++imp) {
145 int wire =
reg - nregions/2;
148 if (wire>0) { sign=
'+'; }
149 if (wire<0) { sign=
'-'; }
153 title = Form(
"Avg Response wire:%c%d", sign,
std::abs(wire));
156 title = Form(
"Fine Response wire:%c%d (impact=%.1f)", sign,
std::abs(wire), impacts[imp]);
159 TH1F*
h =
new TH1F(Form(
"h_%d_%d_%d", iplane, imp,
reg),
161 ntbins,
tstart, tstart + period*ntbins);
162 h->SetLineColor(plane_colors[iplane]);
163 hists[iplane][imp*nregions +
reg] =
h;
168 for (
auto plane : fr.
planes) {
169 int iplane = plane.planeid;
170 for (
auto path : plane.paths) {
172 const int region = round((path.pitchpos-0.001)/pitch);
173 const double impact = path.pitchpos - region*pitch;
176 for (
size_t ind=0; ind<impacts.size(); ++ind) {
177 if (
std::abs(impact-impacts[ind]) < 0.001) {
182 for (
size_t ind=0; ind<regions.size(); ++ind) {
183 if (
std::abs(region-regions[ind]) < 0.001) {
189 TH1F*
hist = hists[iplane][imp*nregions +
reg];
190 for (
int ind=0; ind<ntbins; ++ind) {
191 double value = response[ind];
192 hist->SetBinContent(ind+1, value);
199 mpdf.
canvas.Divide(1,nimpacts);
200 for (
int imp=0; imp<nimpacts; ++imp) {
202 double minval = 999,
maxval=-999;
203 for (
int iplane=0; iplane<3; ++iplane) {
204 TH1F*
hist = hists[iplane][imp*nregions +
reg];
205 minval =
min(minval, hist->GetMinimum());
206 maxval =
max(maxval, hist->GetMaximum());
209 double extraval = 0.01*(
maxval-minval);
210 for (
int iplane=0; iplane<3; ++iplane) {
211 TH1F*
hist = hists[iplane][imp*nregions +
reg];
212 hist->SetMinimum(minval-extraval);
213 hist->SetMaximum(
maxval+extraval);
225 for (
int imp=0; imp<nimpacts; ++imp) {
227 for (
int iplane=0; iplane<3; ++iplane) {
228 TH1F*
hist = hists[iplane][imp*nregions +
reg];
230 hists[iplane][imp*nregions +
reg] =
nullptr;
236 const std::vector<double>
all_gains{4.7, 7.8, 14.0, 25.0};
240 typedef std::map<GainShape, Waveform::realseq_t>
CerfMap;
247 for (
int igain=0; igain<4;++igain) {
248 for (
int ishap=0; ishap<4;++ishap) {
250 auto rf = ele.generate(dom, ntbins);
260 const double deltat = (tmax-tmin)/ntbins;
262 auto frame = mpdf.
canvas.DrawFrame(0,0,10,25);
265 frame->SetTitle(
"Electronics Responses");
266 frame->SetXTitle(
"time [us]");
267 frame->SetYTitle(
"gain [mV/fC]");
271 std::vector<TGraph*> garbage_collection;
272 for (
int igain=0; igain<4;++igain) {
273 for (
int ishap=0; ishap<4;++ishap) {
275 TGraph*
g =
new TGraph(ntbins);
276 for (
int ind=0; ind<ntbins; ++ind) {
277 g->SetPoint(ind, (tmin + ind*deltat)/
units::us, rf[ind]);
280 g->SetLineColor(colors[ishap]);
281 garbage_collection.push_back(g);
285 for (
auto g : garbage_collection) {
294 cerr <<
"This test requires an Wire Cell Field Response input file." <<
endl;
310 mpdf.
canvas.SetRightMargin(.15);
314 for (
int ind=0; ind<3; ++ind) {
319 em(
"done with fine responses");
321 for (
int ind=0; ind<3; ++ind) {
322 em(
"plot_plane avg");
326 em(
"done with avg responses");
double pitch
The pitch distance between neighboring wires.
double tstart
Time at which drift paths begin.
CerfMap make_cerf(double tmin=0, double tmax=100 *units::us, int ntbins=1000)
std::pair< int, int > GainShape
const std::vector< double > all_shapings
Schema::FieldResponse wire_region_average(const Schema::FieldResponse &fr)
double period
The sampling period of the response function.
A functional object caching gain and shape.
void plot_plane_2d(MultiPdf &mpdf, const Response::Schema::FieldResponse &fr, int planeind, bool isavg)
void plot_all_impact(MultiPdf &mpdf, const Response::Schema::FieldResponse &fr, bool isavg)
void plot_cerf(MultiPdf &mpdf, CerfMap &cerf, double tmin=0, double tmax=100 *units::us, int ntbins=1000)
std::vector< PlaneResponse > planes
List of PlaneResponse objects.
std::map< GainShape, Waveform::realseq_t > CerfMap
static int max(int a, int b)
FieldResponse load(const char *filename)
WireCell::Waveform::realseq_t current
An array holding the induced current for the path on the wire-of-interest.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
int main(int argc, const char *argv[])
const GenericPointer< typename T::ValueType > T2 value
std::vector< PathResponse > paths
List of PathResponse objects.
const std::vector< double > all_gains
cet::registry_via_id< success_t, val > reg
Hold info about multiple plane responses in the detector.
int planeid
A numerical identifier for the plane.
std::string summary() const
Return summary up to now.
QTextStream & endl(QTextStream &s)
h
training ###############################