24 #include "CLHEP/Random/RandGaussQ.h" 25 #include "CLHEP/Units/GlobalSystemOfUnits.h" 26 #include "CLHEP/Units/GlobalPhysicalConstants.h" 27 #include "HepMC/SimpleVector.h" 30 readDB_ =
p.getParameter<
bool>(
"readDB");
32 fX0 =
p.getParameter<
double>(
"X0") * cm;
33 fY0 =
p.getParameter<
double>(
"Y0") * cm;
34 fZ0 =
p.getParameter<
double>(
"Z0") * cm;
35 fSigmaZ =
p.getParameter<
double>(
"SigmaZ") * cm;
36 fbetastar =
p.getParameter<
double>(
"BetaStar") * cm;
37 femittance =
p.getParameter<
double>(
"Emittance") * cm;
38 fTimeOffset =
p.getParameter<
double>(
"TimeOffset") * ns * c_light;
40 setBoost(
p.getParameter<
double>(
"Alpha") * radian,
p.getParameter<
double>(
"Phi") * radian);
42 throw cms::Exception(
"Configuration") <<
"Error in BetafuncEvtVtxGenerator: " 43 <<
"Illegal resolution in Z (SigmaZ is negative)";
49 beamToken_ = esConsumes<SimBeamSpotObjects, SimBeamSpotObjectsRcd, edm::Transition::BeginLuminosityBlock>();
60 fX0 = beamhandle->
x() * cm;
61 fY0 = beamhandle->
y() * cm;
62 fZ0 = beamhandle->
z() * cm;
74 double tmp_sigz = CLHEP::RandGaussQ::shoot(engine, 0.,
fSigmaZ);
79 tmp_sigx /=
sqrt(2.0);
80 X = CLHEP::RandGaussQ::shoot(engine, 0., tmp_sigx) +
fX0;
84 tmp_sigy /=
sqrt(2.0);
85 Y = CLHEP::RandGaussQ::shoot(engine, 0., tmp_sigy) +
fY0;
87 double tmp_sigt = CLHEP::RandGaussQ::shoot(engine, 0.,
fSigmaZ);
90 return HepMC::FourVector(
X,
Y,
Z,
T);
100 TMatrixD tmpboost(4, 4);
108 tmpboost(0, 0) = 1. /
cos(
phi);
118 tmpboost(2, 2) =
cos(
phi);
134 throw cms::Exception(
"LogicError") <<
"Error in BetafuncEvtVtxGenerator::sigmaZ: " 135 <<
"Illegal resolution in Z (negative)";
143 desc.add<
double>(
"X0", 0.0)->setComment(
"in cm");
144 desc.add<
double>(
"Y0", 0.0)->setComment(
"in cm");
145 desc.add<
double>(
"Z0", 0.0)->setComment(
"in cm");
146 desc.add<
double>(
"SigmaZ", 0.0)->setComment(
"in cm");
147 desc.add<
double>(
"BetaStar", 0.0)->setComment(
"in cm");
148 desc.add<
double>(
"Emittance", 0.0)->setComment(
"in cm");
149 desc.add<
double>(
"Alpha", 0.0)->setComment(
"in radians");
150 desc.add<
double>(
"Phi", 0.0)->setComment(
"in radians");
151 desc.add<
double>(
"TimeOffset", 0.0)->setComment(
"in ns");
153 desc.add<
bool>(
"readDB");
154 descriptions.
add(
"BetafuncEvtVtxGenerator",
desc);
void sigmaZ(double s=1.0)
set resolution in Z in cm
double BetaFunction(double z, double z0) const
beta function
BetafuncEvtVtxGenerator(const edm::ParameterSet &p)
Sin< T >::type sin(const T &t)
void setBoost(double alpha, double phi)
TMatrixD const * GetInvLorentzBoost() const override
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
edm::ESGetToken< SimBeamSpotObjects, SimBeamSpotObjectsRcd > beamToken_
void update(const edm::EventSetup &iEventSetup)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
double timeOffset() const
HepMC::FourVector newVertex(CLHEP::HepRandomEngine *) const override
return a new event vertex
edm::ESWatcher< SimBeamSpotObjectsRcd > parameterWatcher_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool check(const edm::EventSetup &iSetup)
double phi() const
get Phi, Alpha and TimeOffset
double betaStar() const
get BetaStar and Emittance
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
double x() const
get X, Y, Z position