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()));
71 throw cms::Exception(
"PPS") <<
"Cannot open input file '" << xangleBetaStarHistogramFile <<
"'.";
73 TH2D *h_xangle_beta_star = (TH2D *)f_in->Get(xangleBetaStarHistogramObject.c_str());
74 if (!h_xangle_beta_star)
75 throw cms::Exception(
"PPS") <<
"Cannot load input object '" << xangleBetaStarHistogramObject <<
"'.";
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>();
137 double xangle = 0., betaStar = 0.;
138 const double u = CLHEP::RandFlat::shoot(
m_engine.get(), 0., 1.);
140 if (
d.min <= u && u <=
d.max) {
142 betaStar =
d.betaStar;
148 output->setCrossingAngle(xangle);
149 output->setBetaStar(betaStar);
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 &)
const edm::EventSetup & c
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)
std::vector< BinData > xangleBetaStarBins
static void fillDescriptions(edm::ConfigurationDescriptions &)
CTPPSLHCInfoRandomXangleESSource(const edm::ParameterSet &)
tuple key
prepare the HTCondor submission files and eventually submit them
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
T getParameter(std::string const &) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Provides LHCInfo data necessary for CTPPS reconstruction (and direct simulation). ...