11 #include "CLHEP/Random/RandFlat.h" 12 #include "CLHEP/Units/GlobalSystemOfUnits.h" 13 #include "CLHEP/Units/GlobalPhysicalConstants.h" 14 #include "HepMC/SimpleVector.h" 21 constexpr double gamma34 = 1.22541670246517764513;
22 constexpr double gamma14 = 3.62560990822190831193;
23 constexpr double gamma54 = 0.90640247705547798267;
25 constexpr double sqrt2to5 = 5.65685424949;
31 desc.add<
double>(
"MeanXIncm", 0.0);
32 desc.add<
double>(
"MeanYIncm", 0.0);
33 desc.add<
double>(
"MeanZIncm", 0.0);
34 desc.add<
double>(
"TimeOffsetInns", 0.0);
35 desc.add<
double>(
"EprotonInGeV", 7000.0);
36 desc.add<
double>(
"CrossingAngleInurad", 510.0);
37 desc.add<
double>(
"CrabbingAngleCrossingInurad", 380.0);
38 desc.add<
double>(
"CrabbingAngleSeparationInurad", 0.0);
39 desc.add<
double>(
"CrabFrequencyInMHz", 400.0);
40 desc.add<
bool>(
"RF800",
false);
41 desc.add<
double>(
"BetaCrossingPlaneInm", 0.20);
42 desc.add<
double>(
"BetaSeparationPlaneInm", 0.20);
43 desc.add<
double>(
"HorizontalEmittance", 2.5e-06);
44 desc.add<
double>(
"VerticalEmittance", 2.05e-06);
45 desc.add<
double>(
"BunchLengthInm", 0.09);
47 desc.add<
bool>(
"readDB");
48 descriptions.
add(
"HLLHCEvtVtxGenerator",
desc);
53 fMeanX(
p.getParameter<double>(
"MeanXIncm") * cm),
54 fMeanY(
p.getParameter<double>(
"MeanYIncm") * cm),
55 fMeanZ(
p.getParameter<double>(
"MeanZIncm") * cm),
56 fTimeOffset(
p.getParameter<double>(
"TimeOffsetInns") * ns * c_light),
57 momeV(
p.getParameter<double>(
"EprotonInGeV") * 1e9),
58 gamma(momeV / pmass + 1.0),
61 phi(
p.getParameter<double>(
"CrossingAngleInurad") * 1
e-6),
62 wcc(
p.getParameter<double>(
"CrabFrequencyInMHz") * 1e6),
64 betx(
p.getParameter<double>(
"BetaCrossingPlaneInm")),
65 bets(
p.getParameter<double>(
"BetaSeparationPlaneInm")),
66 epsxn(
p.getParameter<double>(
"HorizontalEmittance")),
67 epssn(
p.getParameter<double>(
"VerticalEmittance")),
68 sigs(
p.getParameter<double>(
"BunchLengthInm")),
69 alphax(
p.getParameter<double>(
"CrabbingAngleCrossingInurad") * 1
e-6),
70 alphay(
p.getParameter<double>(
"CrabbingAngleSeparationInurad") * 1
e-6),
72 epsx(epsxn / (betagamma)),
84 double x(0.),
y(0.),
z(0.),
t(0.),
i(0.);
88 auto shoot = [&]() {
return CLHEP::RandFlat::shoot(engine); };
91 z = (shoot() - 0.5) * 6.0 *
sigs;
92 t = (shoot() - 0.5) * 6.0 *
sigs;
99 edm::LogError(
"Too large intensity") <<
"i>imax : " <<
i <<
" > " << imax << endl;
101 }
while ((
i < imax * shoot()) &&
count < 10000);
117 return HepMC::FourVector(
x,
y,
z,
t);
134 const double cay =
std::cos(alphay_mod);
135 const double say =
std::sin(alphay_mod);
137 const double dy = -(
z -
t) * say -
y * cay;
141 const double norm = two_pi * sigmay;
143 return (
std::exp(-
dy *
dy / (sigmay * sigmay)) * xzt_density / norm);
150 const double k2 =
k *
k;
153 const double cos2 =
cos *
cos;
154 const double sin2 =
sin *
sin;
157 const double sigmax2 = sigx2 * (1 +
z *
z / (
betx *
betx));
162 1. / sqrt2 / gamma34 * gamma14;
163 constexpr double NormFactorGauss4 = sqrt2to5 * gamma54 * gamma54;
166 const double sinCR2 = sinCR * sinCR;
171 const double norm = 2.0 / (two_pi * sigs2);
175 std::exp(-ct * ct / sigs2 -
z *
z * cos2 / sigs2 -
176 1.0 / (4 * k2 * sigmax2) *
181 4 * k2 *
z *
z * sin2) -
182 x *
x * (cos2 / sigmax2 + sin2 / sigs2)
183 +
x * ct *
sin / sigs2
184 + 2 *
x *
cos * cosks * sinkct * sinCR /
k / sigmax2
191 const double norm = 2.0 / (NormFactorGauss4 * sigs2 * factorRMSgauss4);
192 const double sigs4 = sigs2 * sigs2 * factorRMSgauss4 * factorRMSgauss4;
197 std::exp(-ct * ct * ct * ct / sigs4 -
z *
z *
z *
z * cos2 * cos2 / sigs4 - 6 * ct * ct *
z *
z * cos2 / sigs4 -
198 sin2 / (4 * k2 * sigmax2) *
HepMC::FourVector newVertex(CLHEP::HepRandomEngine *) const override
return a new event vertex
HLLHCEvtVtxGenerator(const edm::ParameterSet &p)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Sin< T >::type sin(const T &t)
double sigma(double z, double epsilon, double beta, double betagamma) const
Log< level::Error, false > LogError
Cos< T >::type cos(const T &t)
~HLLHCEvtVtxGenerator() override
double intensity(double x, double y, double z, double t) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static constexpr float local_c_light
double integrandCC(double x, double z, double t) const