12 #include "CLHEP/Random/RandFlat.h" 13 #include "CLHEP/Units/GlobalSystemOfUnits.h" 14 #include "CLHEP/Units/GlobalPhysicalConstants.h" 15 #include "HepMC/SimpleVector.h" 22 constexpr double gamma34 = 1.22541670246517764513;
23 constexpr double gamma14 = 3.62560990822190831193;
24 constexpr double gamma54 = 0.90640247705547798267;
26 constexpr double sqrt2to5 = 5.65685424949;
33 desc.
add<
double>(
"MeanXIncm",0.0);
34 desc.
add<
double>(
"MeanYIncm",0.0);
35 desc.
add<
double>(
"MeanZIncm",0.0);
36 desc.
add<
double>(
"TimeOffsetInns",0.0);
37 desc.
add<
double>(
"EprotonInGeV", 7000.0);
38 desc.
add<
double>(
"CrossingAngleInurad", 510.0);
39 desc.
add<
double>(
"CrabbingAngleCrossingInurad", 380.0);
40 desc.
add<
double>(
"CrabbingAngleSeparationInurad", 0.0);
41 desc.
add<
double>(
"CrabFrequencyInMHz", 400.0);
42 desc.
add<
bool>(
"RF800",
false);
43 desc.
add<
double>(
"BetaCrossingPlaneInm", 0.20);
44 desc.
add<
double>(
"BetaSeparationPlaneInm", 0.20);
45 desc.
add<
double>(
"HorizontalEmittance", 2.5e-06);
46 desc.
add<
double>(
"VerticalEmittance", 2.05e-06);
47 desc.
add<
double>(
"BunchLengthInm", 0.09);
49 desc.
add<
bool>(
"readDB");
50 descriptions.
add(
"HLLHCEvtVtxGenerator",desc);
55 fMeanX(p.getParameter<double>(
"MeanXIncm")*cm),
56 fMeanY(p.getParameter<double>(
"MeanYIncm")*cm),
57 fMeanZ(p.getParameter<double>(
"MeanZIncm")*cm),
58 fTimeOffset(p.getParameter<double>(
"TimeOffsetInns")*ns*c_light),
59 momeV(p.getParameter<double>(
"EprotonInGeV")*1e9),
60 gamma(momeV/pmass + 1.0),
63 phi(p.getParameter<double>(
"CrossingAngleInurad")*1
e-6),
64 wcc(p.getParameter<double>(
"CrabFrequencyInMHz")*1e6),
65 RF800(p.getParameter<bool>(
"RF800")),
66 betx(p.getParameter<double>(
"BetaCrossingPlaneInm")),
67 bets(p.getParameter<double>(
"BetaSeparationPlaneInm")),
68 epsxn(p.getParameter<double>(
"HorizontalEmittance")),
69 epssn(p.getParameter<double>(
"VerticalEmittance")),
70 sigs(p.getParameter<double>(
"BunchLengthInm")),
71 alphax(p.getParameter<double>(
"CrabbingAngleCrossingInurad")*1
e-6),
72 alphay(p.getParameter<double>(
"CrabbingAngleSeparationInurad")*1
e-6),
74 epsx(epsxn/(betagamma)),
92 double x(0.),
y(0.),
z(0.),
t(0.),
i(0.);
96 auto shoot = [&](){
return CLHEP::RandFlat::shoot(engine); };
99 z=(shoot()-0.5)*6.0*
sigs;
100 t=(shoot()-0.5)*6.0*
sigs;
107 <<
"i>imax : "<<i<<
" > "<<imax<<endl;
109 }
while ((i<imax*shoot())&&count<10000);
112 <<
" count : "<<count<<endl;
125 return HepMC::FourVector(
x,
y,
z,
t );
148 const double cay=
std::cos(alphay_mod);
149 const double say=
std::sin(alphay_mod);
151 const double dy=-(z-
t)*say-y*cay;
155 const double norm = two_pi*sigmay;
157 return (
std::exp(-dy*dy/(sigmay*sigmay))*
164 constexpr double local_c_light = 2.99792458e8;
166 const double k =
wcc/local_c_light*two_pi;
167 const double k2 = k*
k;
170 const double cos2 = cos*
cos;
171 const double sin2 = sin*
sin;
174 const double sigmax2=sigx2*(1+z*z/(
betx*
betx));
178 constexpr double factorRMSgauss4 = 1./sqrt2/gamma34 * gamma14;
179 constexpr double NormFactorGauss4 = sqrt2to5 * gamma54 * gamma54;
182 const double sinCR2 = sinCR*sinCR;
187 const double norm =2.0/(two_pi*sigs2);
189 const double sinkct =
std::sin(k*ct);
192 -1.0/(4*k2*sigmax2)*(
200 - x*x*(cos2/sigmax2 + sin2/sigs2)
202 + 2*x*cos*cosks*sinkct*sinCR/k/sigmax2
209 const double norm = 2.0/(NormFactorGauss4*sigs2*factorRMSgauss4);
210 const double sigs4=sigs2*sigs2*factorRMSgauss4*factorRMSgauss4;
212 const double sinct =
std::sin(k*ct);
215 -z*z*z*z*cos2*cos2/sigs4
216 -6*ct*ct*z*z*cos2/sigs4
217 -sin2/(4*k2*sigmax2)*(
223 -4 * cosks*cosks * sinct*sinct)
virtual 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)
Cos< T >::type cos(const T &t)
double integrandCC(double x, double z, double t) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double intensity(double x, double y, double z, double t) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual ~HLLHCEvtVtxGenerator()
double sigma(double z, double epsilon, double beta, double betagamma) const