33 const double tmin = tbins.
min();
35 const int ntbins = tbins.
bin(tmin+tspan);
36 const double tmax = tbins.
edge(ntbins);
38 const int nwires = pir->nwires();
39 cerr <<
"Plane " << iplane <<
" with " << nwires <<
" wires\n";
41 const char *uvw =
"UVW";
43 const double half_pitch = 0.5*pir->pitch_range();
44 const double impact_dist = pir->impact();
47 const int npbins = (pmax-pmin)/impact_dist;
52 vector<double> zextent{1.0, 1.0, 2.0};
54 zunit =
"induced electrons";
56 zextent = vector<double>{0.3, 0.15, 0.6};
58 std::cerr <<
"zunits: " << zunit
71 gStyle->SetOptStat(0);
72 TH2F*
hist =
new TH2F(Form(
"h%s_%c", name.c_str(), uvw[iplane]),
73 Form(
"%s, 1e-/impact %c-plane", title.c_str(), uvw[iplane]),
76 hist->SetXTitle(
"time (us)");
77 hist->SetYTitle(
"pitch (mm)");
78 hist->SetZTitle(zunit.c_str());
80 hist->GetZaxis()->SetRangeUser(-zextent[iplane], +zextent[iplane]);
82 TH1F* htot =
new TH1F(Form(
"htot%s_%c", name.c_str(), uvw[iplane]),
83 Form(
"%s total, 1e-/impact %c-plane", title.c_str(), uvw[iplane]),
85 htot->SetXTitle(
"pitch (mm)");
86 htot->SetYTitle(Form(
"impact total [%s]", zunit.c_str()));
88 for (
double pitch = -half_pitch; pitch <= half_pitch; pitch += impact_dist) {
89 auto ir = pir->closest(pitch);
91 std::cerr <<
"No closest for pitch " << pitch <<
endl;
94 auto spec = ir->spectrum();
96 pitch += 0.001*impact_dist;
97 for (
int ind=0; ind < ntbins; ++ind) {
100 htot->Fill(pitch/
units::mm, wave[ind]/zunitval);
106 mpdf.
canvas.SetRightMargin(0.15);
107 mpdf.
canvas.SetLeftMargin(0.15);
110 wline.SetLineColorAlpha(1, 0.5);
111 wline.SetLineStyle(1);
112 hline.SetLineColorAlpha(2, 0.5);
113 hline.SetLineStyle(2);
114 for (
int iwire=0; iwire<nwires/2; ++iwire) {
115 double wpitch = iwire * pir->pitch();
120 wpitch += 0.5*pir->pitch();
138 pm.
add(
"WireCellGen");
139 pm.
add(
"WireCellSigProc");
151 string out_basename = argv[0];
152 string response_file =
"ub-10-half.json.bz2";
154 response_file = argv[1];
157 out_basename = argv[2];
159 cerr <<
"Using response file: " << response_file <<
endl;
160 cerr <<
"Writing to " << out_basename <<
endl;
163 const std::string er_tn =
"ElecResponse", rc_tn =
"RCResponse";
166 auto icfg = Factory::lookup_tn<IConfigurable>(er_tn);
167 auto cfg = icfg->default_configuration();
169 cfg[
"shaping"] = shaping;
171 cerr <<
"Setting: " << cfg[
"nticks"].asInt() <<
" ticks\n";
174 icfg->configure(cfg);
177 auto icfg = Factory::lookup_tn<IConfigurable>(rc_tn);
178 auto cfg = icfg->default_configuration();
182 icfg->configure(cfg);
185 auto icfg = Factory::lookup<IConfigurable>(
"FieldResponse");
186 auto cfg = icfg->default_configuration();
187 cfg[
"filename"] = response_file;
188 icfg->configure(cfg);
191 std::vector<std::string> pir_tns{
"PlaneImpactResponse:frU",
"PlaneImpactResponse:frV",
"PlaneImpactResponse:frW"};
193 for (
int iplane=0; iplane<3; ++iplane) {
194 auto icfg = Factory::lookup_tn<IConfigurable>(pir_tns[iplane]);
195 auto cfg = icfg->default_configuration();
196 cfg[
"plane"] = iplane;
199 icfg->configure(cfg);
202 std::vector<std::string> pir_ele_tns{
"PlaneImpactResponse:frerU",
"PlaneImpactResponse:frerV",
"PlaneImpactResponse:frerW"};
204 for (
int iplane=0; iplane<3; ++iplane) {
205 auto icfg = Factory::lookup_tn<IConfigurable>(pir_ele_tns[iplane]);
206 auto cfg = icfg->default_configuration();
207 cfg[
"plane"] = iplane;
210 cfg[
"other_responses"][0] = er_tn;
211 cfg[
"other_responses"][1] = rc_tn;
212 cfg[
"other_responses"][2] = rc_tn;
213 icfg->configure(cfg);
220 TFile* rootfile = TFile::Open(Form(
"%s.root", out_basename.c_str()),
"recreate");
223 MultiPdf mpdf(out_basename.c_str());
224 for (
int iplane=0; iplane<3; ++iplane) {
225 auto pir = Factory::find_tn<IPlaneImpactResponse>(pir_tns[iplane]);
226 plot_time(mpdf, pir, iplane, tbins,
"fr",
"Field Response");
228 auto pir_ele = Factory::find_tn<IPlaneImpactResponse>(pir_ele_tns[iplane]);
229 plot_time(mpdf, pir_ele, iplane, tbins,
"dr",
"Detector Response");
234 cerr <<
"Closing ROOT file: " << rootfile->GetName() <<
endl;
code to link reconstructed objects back to the MC truth information
static const double eplus
void set_palette(int pal=-1)
std::shared_ptr< IPlaneImpactResponse > pointer
Access subclass facet by pointer.
double center(int ind) const
static PluginManager & instance()
Binning tbins(nticks, t0, t0+readout_time)
static const double microvolt
int bin(double val) const
double edge(int ind) const
Plugin * add(const std::string &plugin_name, const std::string &libname="")
Add a plugin. If libname is not given, try to derive it.
void plot_time(MultiPdf &mpdf, IPlaneImpactResponse::pointer pir, int iplane, Binning tbins, const std::string &name, const std::string &title)
int main(int argc, const char *argv[])
QTextStream & endl(QTextStream &s)
const double readout_time