27 pm.
add(
"WireCellGen");
30 const int specsize =
ar39_mev.size();
31 const double enemin =
ar39_mev.front();
32 const double enemax =
ar39_mev.back();
33 const double enebin = (enemax-enemin)/specsize;
39 const double ele_per_mev = 28000;
46 auto rng_cfg = Factory::lookup<IConfigurable>(
"Random");
48 auto cfg = rng_cfg->default_configuration();
49 rng_cfg->configure(
cfg);
51 auto bs_cfg = Factory::lookup<IConfigurable>(
"BlipSource");
53 auto cfg = bs_cfg->default_configuration();
55 for (
int ind=0; ind<specsize; ++ind) {
59 nele[ind] = e*ele_per_mev;
63 for (
int ind=0; ind<specsize; ++ind) {
64 const double prob =
ar39_pdf[ind]/(spectot*enebin);
66 spectrum.SetPoint(ind, ene, prob);
75 bs_cfg->configure(
cfg);
80 std::cout <<
"Configuration for Ar39 blips:\n" << ene <<
std::endl;
87 auto deposrc = Factory::lookup<IDepoSource>(
"BlipSource");
91 TFile* rootfile = TFile::Open(Form(
"%s.root", argv[0]),
"recreate");
92 gStyle->SetOptStat(111111);
93 gStyle->SetOptFit(111111);
94 TCanvas canvas(
"canvas",
"canvas", 1000, 800);
96 auto hxy =
new TH2F(
"hxy",
"Decay location (Y vs X)",
97 200, -1.0, 1.0, 200, -1.0, 1.0);
98 auto hxz =
new TH2F(
"hxz",
"Decay location (Z vs X)",
99 200, -1.0, 1.0, 200, -1.0, 1.0);
101 auto ht =
new TH1D(
"ht",
"Ar39 decay time", 1000, 0, 100);
102 ht->GetXaxis()->SetTitle(
"time between decays [us]");
103 auto he =
new TH1D(
"he",
"Ar39 decay spectrum", nebins, 0, 1);
104 he->GetXaxis()->SetTitle(
"beta kinetic energy (MeV)");
105 auto hde =
new TH1D(
"hde",
"Energy bin size (round-off errors)", 200, 0.01-0.0001, 0.01+0.0001);
109 hde->Fill(
e-last_e+0.00001);
114 double last_time = 0.0;
115 for (
int ind=0; ind != 10000000; ++ind) {
117 bool ok = (*deposrc)(depo);
119 std::cerr <<
"BlipSource failed!\n";
123 std::cerr <<
"BlipSource: EOS\n";
126 const double charge = depo->charge();
128 std::cerr <<
"Got negative charge\n";
132 const double time = depo->time();
136 auto&
pos = depo->pos();
141 he->Scale(1.0/(he->Integral() / nebins));
146 canvas.Print((fname+
"[").c_str(),
"pdf");
150 canvas.Print(fname.c_str(),
"pdf");
153 spectrum.SetLineColor(2);
156 canvas.Print(fname.c_str(),
"pdf");
159 canvas.Print(fname.c_str(),
"pdf");
162 canvas.Print(fname.c_str(),
"pdf");
165 canvas.Print(fname.c_str(),
"pdf");
167 canvas.Print((fname+
"]").c_str(),
"pdf");
std::shared_ptr< const IDepo > pointer
const std::vector< double > ar39_pdf
static PluginManager & instance()
const std::vector< double > ar39_mev
Json::Value Configuration
int main(int argc, char *argv[])
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)