15 #include "CLHEP/Random/RandFlat.h"
16 #include "CLHEP/Random/JamesRandom.h"
44 std::unique_ptr<CLHEP::HepRandomEngine>
m_engine;
57 : m_label(conf.getParameter<
std::
string>(
"label")),
59 m_generateEveryNEvents(conf.getParameter<unsigned
int>(
"generateEveryNEvents")),
61 m_beamEnergy(conf.getParameter<double>(
"beamEnergy")),
62 m_betaStar(conf.getParameter<double>(
"betaStar")),
64 m_engine(new
CLHEP::HepJamesRandom(conf.getParameter<unsigned
int>(
"seed"))) {
68 TFile *f_in = TFile::Open(xangleHistogramFile.c_str());
69 TH1D *h_xangle = (TH1D *)f_in->Get(xangleHistogramObject.c_str());
72 for (
int bi = 1; bi <= h_xangle->GetNbinsX(); ++bi)
73 s += h_xangle->GetBinContent(bi);
76 for (
int bi = 1; bi <= h_xangle->GetNbinsX(); ++bi) {
77 double xangle = h_xangle->GetBinCenter(bi);
78 double w = h_xangle->GetBinContent(bi) /
s;
88 findingRecord<LHCInfoRcd>();
96 desc.
add<
std::string>(
"label",
"")->setComment(
"label of the LHCInfo record");
98 desc.
add<
unsigned int>(
"seed", 1)->setComment(
"random seed");
100 desc.
add<
unsigned int>(
"generateEveryNEvents", 1)->setComment(
"how often to generate new xangle");
102 desc.
add<
std::string>(
"xangleHistogramFile",
"")->setComment(
"ROOT file with xangle distribution");
103 desc.
add<
std::string>(
"xangleHistogramObject",
"")->setComment(
"xangle distribution object in the ROOT file");
105 desc.
add<
double>(
"beamEnergy", 0.)->
setComment(
"beam energy");
108 descriptions.
add(
"ctppsLHCInfoRandomXangleESSource", desc);
124 auto output = std::make_unique<LHCInfo>();
126 const double u = CLHEP::RandFlat::shoot(
m_engine.get(), 0., 1.);
130 if (
d.min <= u && u <=
d.max) {