#include "WireCellUtil/Units.h"
#include "WireCellUtil/Testing.h"
#include "WireCellUtil/PluginManager.h"
#include "WireCellUtil/NamedFactory.h"
#include "WireCellIface/IChannelResponse.h"
#include "WireCellIface/IConfigurable.h"
#include "TCanvas.h"
#include "TGraph.h"
#include "TH1F.h"
#include "TAxis.h"
#include <vector>
#include <string>
#include <iostream>
Go to the source code of this file.
|
int | main (int argc, char *argv[]) |
|
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
The typename of the component to use here. Normally this is given in the configuration for whatever component wants to use the channel response.
User code should never do this but in this test we will abuse the configuration mechanism to reuse the same component to draw many responses.
Finally, we pretend to be user code.
WARNING: user code should never call configure(). We are abusing the system here to keep this test short.
Users: do not do this.
Definition at line 27 of file test_nomchanresp.cxx.
32 pm.
add(
"WireCellSigProc");
40 const std::string ncr_tn =
"NominalChannelResponse";
46 auto incrcfg = Factory::lookup<IConfigurable>(ncr_tn);
47 auto cfg = incrcfg->default_configuration();
48 cfg[
"nbins"] = binning.nbins();
49 cfg[
"tmin"] = binning.min();
50 cfg[
"tmax"] = binning.max();
51 incrcfg->configure(cfg);
54 auto ncr = Factory::find<IChannelResponse>(ncr_tn);
56 const double GU =
mV/
fC;
58 const std::vector<double> gains{7.8*GU, 14*GU};
59 const std::vector<double> shapes{0.5*
us,1.0*
us,2.0*
us,3.0*
us};
61 std::vector<TGraph*> graphs;
63 for (
auto gain : gains) {
65 for (
auto shape : shapes) {
66 cfg[
"shaping"] = shape;
70 incrcfg->configure(cfg);
73 auto wave = ncr->channel_response(0);
74 const int nbins = wave.size();
75 cerr << nbins <<
" " << binning.nbins() <<
endl;
76 Assert(nbins == binning.nbins());
77 TGraph*
g =
new TGraph(binning.nbins());
78 for (
int ind=0; ind<binning.nbins(); ++ind) {
79 g->SetPoint(ind, binning.center(ind)/
us, wave[ind]/GU);
85 const int colors[] = {1,2,4,6};
86 TCanvas
c(
"c",
"c",500,500);
87 auto frame =
c.DrawFrame(0.0, 0.0, 10.0, 15.0);
88 frame->SetTitle(
"Nominal Channel Response various gains/shaping");
89 frame->GetXaxis()->SetTitle(
"time [us]");
90 frame->GetYaxis()->SetTitle(
"gain [mV/fC]");
91 for (
size_t ind=0; ind<graphs.size(); ++ind) {
92 TGraph* g = graphs[ind];
93 g->SetLineColor(colors[ind%4]);
94 g->SetMarkerColor(colors[ind%4]);
97 c.Print(Form(
"%s.pdf",
argv[0]),
"pdf");
const std::string instance
Plugin * add(const std::string &plugin_name, const std::string &libname="")
Add a plugin. If libname is not given, try to derive it.
QTextStream & endl(QTextStream &s)