8 #include <TDatabasePDG.h> 10 #include <TParticlePDG.h> 34 std::string isotope =
"";
35 isotope = pset.
get<std::string>(
"isotope");
39 if (not mass_specified) {
40 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
41 const TParticlePDG* definition = databasePDG->GetParticle(m_pdg);
45 if (definition != 0) {
m_mass = definition->Mass(); }
53 double min_p = 0, max_p = 0;
54 std::vector<double> bins;
55 bool minmax_mode = pset.
get_if_present<
double>(
"spectrum_p_min", min_p);
56 if (minmax_mode) { max_p = pset.
get<
double>(
"spectrum_p_max"); }
58 bins = pset.
get<std::vector<double>>(
"bins");
62 std::vector<double> parameters;
64 std::vector<double> spectrum;
65 bool func_mode = pset.
get_if_present<std::string>(
"function",
function);
68 have_params = pset.
get_if_present<std::vector<double>>(
"parameters", parameters);
71 spectrum = pset.
get<std::vector<double>>(
"spectrum");
74 if (func_mode and minmax_mode) {
75 int nbins = pset.
get<
int>(
"nbins");
76 TF1 the_func(
"spect_func",
function.c_str(), min_p, max_p);
77 if (have_params) the_func.SetParameters(parameters.data());
79 m_spectrum =
new TH1D(
"spectrum",
";p [GeV];PDF", nbins, min_p, max_p);
81 for (
int ibin = 1; ibin < nbins + 1; ++ibin) {
83 double y = the_func.Eval(x);
88 else if (func_mode and not minmax_mode) {
89 if (bins.size() <= 1) {
91 <<
"You need to specify more than 1 bin edge to use the \"bins\" option.";
94 <<
"\033[31mYou are using a function and non constant binning...\n" 95 <<
"Please please please check spectrum and momentum distribution are what you actually " 97 int nbins = bins.size() - 1;
99 TF1 the_func(
"spect_func",
function.c_str(), *bins.begin(), *bins.rbegin());
100 if (have_params) the_func.SetParameters(parameters.data());
102 m_spectrum =
new TH1D(
"spectrum",
";p [GeV];PDF", nbins, bins.data());
104 for (
int ibin = 1; ibin < nbins + 1; ++ibin) {
106 double y = the_func.Eval(x);
111 else if (not func_mode and minmax_mode) {
112 int nbins = spectrum.size();
114 m_spectrum =
new TH1D(
"spectrum",
";p [GeV];PDF", nbins, min_p, max_p);
115 for (
int ibin = 1; ibin < nbins + 1; ++ibin) {
116 m_spectrum->SetBinContent(ibin, spectrum.at(ibin - 1));
120 int nbins = spectrum.size();
121 if ((
unsigned)nbins != spectrum.size())
122 throw cet::exception(
"SpectrumVolumeGen") <<
"spectrum and bins don't have coherent size!";
124 m_spectrum =
new TH1D(
"spectrum",
";p [GeV];PDF", nbins, bins.data());
126 for (
int ibin = 1; ibin < nbins + 1; ++ibin) {
127 m_spectrum->SetBinContent(ibin, spectrum.at(ibin - 1));
134 TH1D* sp = tfs->make<TH1D>(*m_spectrum);
143 std::unique_ptr<std::vector<simb::MCTruth>> truthcol(
new std::vector<simb::MCTruth>);
148 const std::string primary_str(
"primary");
152 for (
int iDecay = 0; iDecay < n_decay; ++iDecay) {
153 TLorentzVector position;
169 truthcol->push_back(truth);
170 evt.
put(std::move(truthcol));
SpectrumVolumeGen(fhicl::ParameterSet const &pset)
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
void produce_radio(art::Event &evt)
void SetOrigin(simb::Origin_t origin)
TLorentzVector dirCalc(double p, double m)
void FillHistos(simb::MCParticle &part)
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
#define DEFINE_ART_MODULE(klass)
single particles thrown at the detector
T get(std::string const &key) const
std::vector< std::string > m_isotope
isotope to simulate. Example: "Ar39"
bool GetGoodPositionTime(TLorentzVector &position)
void Add(simb::MCParticle const &part)
std::optional< T > get_if_present(std::string const &key) const
Event generator information.
#define MF_LOG_WARNING(category)
Event Generation using GENIE, cosmics or single particles.
cet::coded_exception< error, detail::translate > exception