34 #include "CLHEP/Random/RandGaussQ.h" 35 #include "CLHEP/Units/GlobalSystemOfUnits.h" 36 #include "CLHEP/Units/GlobalPhysicalConstants.h" 38 #include "HepMC/SimpleVector.h" 45 using namespace CLHEP;
48 class HepRandomEngine;
61 HepMC::FourVector newVertex(CLHEP::HepRandomEngine*)
const;
63 TMatrixD GetInvLorentzBoost()
const;
66 double BetaFunction(
double z,
double z0)
const;
90 : alpha_(
p.getParameter<double>(
"Alpha") * radian),
91 phi_(
p.getParameter<double>(
"Phi") * radian),
92 beta_(
p.getParameter<double>(
"Beta")),
93 fX0(
p.getParameter<double>(
"X0") * cm),
94 fY0(
p.getParameter<double>(
"Y0") * cm),
95 fZ0(
p.getParameter<double>(
"Z0") * cm),
96 fSigmaZ(
p.getParameter<double>(
"SigmaZ") * cm),
97 fbetastar(
p.getParameter<double>(
"BetaStar") * cm),
98 femittance(
p.getParameter<double>(
"Emittance") * cm),
99 fTimeOffset(
p.getParameter<double>(
"TimeOffset") * ns * c_light),
100 boost_(GetInvLorentzBoost()),
102 verbosity_(
p.getUntrackedParameter<
bool>(
"verbosity",
false)) {
104 throw cms::Exception(
"Configuration") <<
"Error in BetaBoostEvtVtxGenerator: " 105 <<
"Illegal resolution in Z (SigmaZ is negative)";
108 produces<edm::HepMCProduct>();
114 double tmp_sigz = CLHEP::RandGaussQ::shoot(engine, 0.0,
fSigmaZ);
119 tmp_sigx /=
sqrt(2.0);
120 X = CLHEP::RandGaussQ::shoot(engine, 0.0, tmp_sigx) +
fX0;
124 tmp_sigy /=
sqrt(2.0);
125 Y = CLHEP::RandGaussQ::shoot(engine, 0.0, tmp_sigy) +
fY0;
127 double tmp_sigt = CLHEP::RandGaussQ::shoot(engine, 0.0,
fSigmaZ);
130 return HepMC::FourVector(
X,
Y,
Z,
T);
144 TMatrixD tmpboost(4, 4);
145 TMatrixD tmpboostZ(4, 4);
146 TMatrixD tmpboostXYZ(4, 4);
154 tmpboost(0, 0) = 1. /
cos(
phi_);
172 tmpboostZ(0, 0) = gama;
173 tmpboostZ(0, 1) = 0.;
174 tmpboostZ(0, 2) = -1.0 *
beta_ * gama;
175 tmpboostZ(0, 3) = 0.;
176 tmpboostZ(1, 0) = 0.;
177 tmpboostZ(1, 1) = 1.;
178 tmpboostZ(1, 2) = 0.;
179 tmpboostZ(1, 3) = 0.;
180 tmpboostZ(2, 0) = -1.0 *
beta_ * gama;
181 tmpboostZ(2, 1) = 0.;
182 tmpboostZ(2, 2) = gama;
183 tmpboostZ(2, 3) = 0.;
184 tmpboostZ(3, 0) = 0.;
185 tmpboostZ(3, 1) = 0.;
186 tmpboostZ(3, 2) = 0.;
187 tmpboostZ(3, 3) = 1.;
189 tmpboostXYZ = tmpboostZ * tmpboost;
190 tmpboostXYZ.Invert();
203 <<
"Attempt to get a random engine when the RandomNumberGeneratorService is not configured.\n" 204 "You must configure the service if you want an engine.\n";
211 auto HepMCEvt = std::make_unique<edm::HepMCProduct>(
new HepMC::GenEvent(*HepUnsmearedMCEvt.GetEvent()));
216 HepMCEvt->applyVtxGen(&
vertex);
219 HepMCEvt->boostToLab(&
boost_,
"vertex");
220 HepMCEvt->boostToLab(&
boost_,
"momentum");
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool get(ProductID const &oid, Handle< PROD > &result) const
Sin< T >::type sin(const T &t)
HepMC::FourVector newVertex(CLHEP::HepRandomEngine *) const
return a new event vertex
double BetaFunction(double z, double z0) const
beta function
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
const edm::EDGetTokenT< HepMCProduct > sourceLabel
BetaBoostEvtVtxGenerator(const edm::ParameterSet &p)
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
#define DEFINE_FWK_MODULE(type)
StreamID streamID() const
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
TMatrixD GetInvLorentzBoost() const