15 #include "CLHEP/Random/RandFlat.h" 16 #include "CLHEP/Random/JamesRandom.h" 44 std::unique_ptr<CLHEP::HepRandomEngine>
m_engine;
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;
80 binData.push_back({cw, cw +
w, xangle});
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) {
137 output->setCrossingAngle(xangle);
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
EventNumber_t event() const
void setComment(std::string const &value)
edm::ESProducts< std::unique_ptr< LHCInfo > > produce(const LHCInfoRcd &)
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
const EventID & eventID() const
std::unique_ptr< CLHEP::HepRandomEngine > m_engine
std::pair< Time_t, Time_t > ValidityInterval
unsigned int m_generateEveryNEvents
LuminosityBlockNumber_t luminosityBlock() const
ESProducts< std::remove_reference_t< TArgs >... > products(TArgs &&...args)
static void fillDescriptions(edm::ConfigurationDescriptions &)
CTPPSLHCInfoRandomXangleESSource(const edm::ParameterSet &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< BinData > binData
void add(std::string const &label, ParameterSetDescription const &psetDescription)
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Provides LHCInfo data necessary for CTPPS reconstruction (and direct simulation). ...