12 #include "TApplication.h" 17 #include "TPolyMarker.h" 26 const double mean = 1.7;
27 const double sigma = 2.0;
28 const double xmin = -5;
29 const double xmax = +5;
32 const vector<int> nbinsv{100, 50, 20, 10, 5};
33 const vector<int>
color{1,2,4,6,7,8};
35 cerr <<
"erf(+1) = " << std::erf(+1.0) <<
endl;
36 cerr <<
"erf(-1) = " << std::erf(-1.0) <<
endl;
38 for (
size_t ind=0; ind < nbinsv.size(); ++ind) {
39 const int nbins = nbinsv[ind];
42 TH1F*
h =
new TH1F(
"h",
"binint Gaussian per binsize", nbins, xmin, xmax);
46 const double integ = h->Integral();
47 cerr << ind <<
" integ=" << b.
binsize()*integ <<
" raw=" << integ <<
endl;
48 h->SetLineColor(
color[ind]);
61 const double nsigma = 3.0;
73 const double nsigma_binning = 2.0*nsigma;
76 const double t_min = t_center - nsigma_binning*t_sigma;
77 const double t_max = t_center + nsigma_binning*t_sigma;
78 const int nt = (t_max-t_min)/t_sample;
83 const double p_min = p_center - nsigma_binning*p_sigma;
84 const double p_max = p_center + nsigma_binning*p_sigma;
85 const int np = (p_max-p_min)/p_sample;
86 const Binning pbins(np, p_min, p_max);
89 const double qdepo = -1000.0;
91 auto depo = std::make_shared<SimpleDepo>(t_center, pdepo, qdepo);
99 cerr <<
"Set sampling: tbins="<<tbins<<
", pbins="<<pbins<<
", nsigma="<<nsigma<<
", fluctuate:"<<fluctuate<<
endl;
100 gd.set_sampling(tbins, pbins, nsigma, fluctuate);
103 auto patch = gd.patch();
104 const int toffset = gd.toffset_bin();
105 const int poffset = gd.poffset_bin();
107 cerr <<
"rows=" <<
patch.rows() <<
" cols=" <<
patch.cols() <<
endl;
108 cerr <<
"toffset=" << toffset <<
" poffset=" << poffset <<
endl;
116 TPolyMarker* marker =
new TPolyMarker(1);
117 marker->SetPoint(0, t_center/tunit, p_center/punit);
118 marker->SetMarkerStyle(5);
119 cerr <<
"center t=" << t_center/tunit <<
", p=" << p_center/punit <<
endl;
121 TH2F*
hist =
new TH2F(
"patch1",
"Diffusion Patch",
122 tbins.
nbins(), tbins.
min()/tunit, tbins.
max()/tunit,
123 pbins.
nbins(), pbins.
min()/punit, pbins.
max()/punit);
126 hist->SetXTitle(
"time (us)");
127 hist->SetYTitle(
"pitch (mm)");
128 for (
int it=0; it <
patch.cols(); ++it) {
129 double tval = tbins.
center(it+toffset);
131 for (
int ip=0; ip <
patch.rows(); ++ip) {
132 double pval = pbins.
edge(ip+poffset)+0.0001;
135 hist->Fill(tval/tunit, pval/punit, value);
142 cerr <<
"total=" << total <<
" integ=" << hist->Integral() <<
" maximum=" << hist->GetMaximum() <<
endl;
148 pm.
add(
"WireCellGen");
150 auto rngcfg = Factory::lookup<IConfigurable>(
"Random");
151 auto cfg = rngcfg->default_configuration();
152 rngcfg->configure(cfg);
154 auto rng = Factory::lookup<IRandom>(
"Random");
156 const char* me = argv[0];
158 TApplication* theApp = 0;
160 theApp =
new TApplication (me,0,0);
162 TFile output(Form(
"%s.root", me),
"RECREATE");
163 TCanvas canvas(
"canvas",
"canvas",500,500);
164 canvas.Print(Form(
"%s.pdf[", me),
"pdf");
165 gStyle->SetOptStat(0);
168 canvas.Print(Form(
"%s.pdf",me),
"pdf");
171 canvas.Print(Form(
"%s.pdf",me),
"pdf");
173 canvas.Print(Form(
"%s.pdf",me),
"pdf");
179 canvas.Print(Form(
"%s.pdf]",me),
"pdf");
void test_gd(IRandom::pointer fluctuate)
std::shared_ptr< IRandom > pointer
Access subclass facet by pointer.
double center(int ind) const
D3Vector< double > Point
A 3D Cartesian point in double precision.
std::vector< double > binint(double start, double step, int nbins) const
static PluginManager & instance()
Binning tbins(nticks, t0, t0+readout_time)
bool inside(double val) const
const GenericPointer< typename T::ValueType > T2 value
QTextStream & bin(QTextStream &s)
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.
int main(int argc, char *argv[])
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
QTextStream & endl(QTextStream &s)
h
training ###############################