15 #include "CLHEP/Random/RandFlat.h" 16 #include "CLHEP/Random/JamesRandom.h" 43 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")),
63 m_engine(new
CLHEP::HepJamesRandom(conf.getParameter<unsigned
int>(
"seed"))) {
69 std::unique_ptr<TFile> f_in(TFile::Open(fip.fullPath().c_str()));
74 if (!h_xangle_beta_star)
79 for (
int x = 1;
x <= h_xangle_beta_star->GetNbinsX(); ++
x) {
80 for (
int y = 1;
y <= h_xangle_beta_star->GetNbinsY(); ++
y)
81 sum += h_xangle_beta_star->GetBinContent(
x,
y);
85 for (
int x = 1;
x <= h_xangle_beta_star->GetNbinsX(); ++
x) {
86 for (
int y = 1;
y <= h_xangle_beta_star->GetNbinsY(); ++
y) {
87 const double c = h_xangle_beta_star->GetBinContent(
x,
y);
88 const double xangle = h_xangle_beta_star->GetXaxis()->GetBinCenter(
x);
89 const double betaStar = h_xangle_beta_star->GetYaxis()->GetBinCenter(
y);
92 const double rc =
c / sum;
100 findingRecord<LHCInfoRcd>();
108 desc.add<
std::string>(
"label",
"")->setComment(
"label of the LHCInfo record");
110 desc.add<
unsigned int>(
"seed", 1)->setComment(
"random seed");
112 desc.add<
unsigned int>(
"generateEveryNEvents", 1)->setComment(
"how often to generate new xangle");
114 desc.add<
std::string>(
"xangleBetaStarHistogramFile",
"")->setComment(
"ROOT file with xangle distribution");
115 desc.add<
std::string>(
"xangleBetaStarHistogramObject",
"")->setComment(
"xangle distribution object in the ROOT file");
117 desc.add<
double>(
"beamEnergy", 0.)->setComment(
"beam energy");
119 descriptions.
add(
"ctppsLHCInfoRandomXangleESSource",
desc);
135 auto output = std::make_unique<LHCInfo>();
138 const double u = CLHEP::RandFlat::shoot(
m_engine.get(), 0., 1.);
140 if (
d.min <= u && u <=
d.max) {
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
edm::ESProducts< std::unique_ptr< LHCInfo > > produce(const LHCInfoRcd &)
T getParameter(std::string const &) const
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
ESProducts< std::remove_reference_t< TArgs >... > products(TArgs &&... args)
std::unique_ptr< CLHEP::HepRandomEngine > m_engine
std::pair< Time_t, Time_t > ValidityInterval
unsigned int m_generateEveryNEvents
std::vector< BinData > xangleBetaStarBins
LuminosityBlockNumber_t luminosityBlock() const
static void fillDescriptions(edm::ConfigurationDescriptions &)
CTPPSLHCInfoRandomXangleESSource(const edm::ParameterSet &)
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
xangleBetaStarHistogramFile
const EventID & eventID() const
Provides LHCInfo data necessary for CTPPS reconstruction (and direct simulation). ...
EventNumber_t event() const
xangleBetaStarHistogramObject