25 #include <CLHEP/Random/RandGauss.h>
63 simulateVertex_(iConfig.getParameter<
bool>(
"simulateVertex")),
64 simulateBeamDivergence_(iConfig.getParameter<
bool>(
"simulateBeamDivergence")) {
66 if (!tagSrcHepMC.
label().empty())
69 for (
const auto &it : iConfig.
getParameter<std::vector<edm::InputTag>>(
"srcGenParticle"))
75 <<
"The BeamDivergenceVtxGenerator requires the RandomNumberGeneratorService\n"
76 "which is not present in the configuration file. \n"
77 "You must add the service\n"
78 "in the configuration file or remove the modules that require it.";
80 produces<edm::HepMCProduct>();
89 ->setComment(
"input collection in HepMC format");
91 desc.add<std::vector<edm::InputTag>>(
"srcGenParticle", std::vector<edm::InputTag>())
92 ->setComment(
"input collections in GenParticle format");
94 desc.add<
bool>(
"simulateBeamDivergence",
true)->setComment(
"account for the beam angular divergence?");
95 desc.add<
bool>(
"simulateVertex",
true)->setComment(
"account for the vertex transverse smearing?");
97 descriptions.
add(
"beamDivergenceVtxGenerator",
desc);
149 for (
const auto &
gp : *hGPCollection)
159 template <
typename T>
164 double th_x = mom.x() / mom.z();
165 double th_y = mom.y() / mom.z();
176 const double sign = (mom.z() > 0.) ? 1. : -1.;
177 const double p =
sqrt(mom.x() * mom.x() + mom.y() * mom.y() + mom.z() * mom.z());
178 const double p_z =
sign *
p /
sqrt(1. + th_x * th_x + th_y * th_y);
180 return HepMC::FourVector(p_z * th_x, p_z * th_y, p_z, mom.e());
188 const auto &
pos = (*vit)->position();
189 (*vit)->set_position(HepMC::FourVector(
pos.x() + sp.
vtx_x * 1E1,
198 (*part)->set_momentum(
smearMomentum((*part)->momentum(), sp));
208 HepMC::GenVertex *
vtx =
new HepMC::GenVertex(HepMC::FourVector(
212 ( +sp.
vtx_t) * 1E1));
217 vtx->add_particle_out(particle);