24 #include <CLHEP/Random/RandGauss.h>
60 : simulateVertex_(iConfig.getParameter<
bool>(
"simulateVertex")),
61 simulateBeamDivergence_(iConfig.getParameter<
bool>(
"simulateBeamDivergence")) {
63 if (!tagSrcHepMC.
label().empty())
66 for (
const auto &it : iConfig.
getParameter<std::vector<edm::InputTag>>(
"srcGenParticle"))
72 <<
"The BeamDivergenceVtxGenerator requires the RandomNumberGeneratorService\n"
73 "which is not present in the configuration file. \n"
74 "You must add the service\n"
75 "in the configuration file or remove the modules that require it.";
77 produces<edm::HepMCProduct>();
86 ->setComment(
"input collection in HepMC format");
88 desc.
add<std::vector<edm::InputTag>>(
"srcGenParticle", std::vector<edm::InputTag>())
89 ->setComment(
"input collections in GenParticle format");
91 desc.
add<
bool>(
"simulateBeamDivergence",
true)->setComment(
"account for the beam angular divergence?");
92 desc.
add<
bool>(
"simulateVertex",
true)->setComment(
"account for the vertex transverse smearing?");
94 descriptions.
add(
"beamDivergenceVtxGenerator", desc);
146 for (
const auto &
gp : *hGPCollection)
156 template <
typename T>
161 double th_x = mom.x() / mom.z();
162 double th_y = mom.y() / mom.z();
173 const double sign = (mom.z() > 0.) ? 1. : -1.;
174 const double p =
sqrt(mom.x() * mom.x() + mom.y() * mom.y() + mom.z() * mom.z());
175 const double p_z =
sign *
p /
sqrt(1. + th_x * th_x + th_y * th_y);
177 return HepMC::FourVector(p_z * th_x, p_z * th_y, p_z, mom.e());
185 const auto &
pos = (*vit)->position();
186 (*vit)->set_position(HepMC::FourVector(
pos.x() + sp.
vtx_x * 1E1,
195 (*part)->set_momentum(
smearMomentum((*part)->momentum(), sp));
205 HepMC::GenVertex *
vtx =
new HepMC::GenVertex(HepMC::FourVector((
gp.vx() + sp.
vtx_x) * 1E1,
213 vtx->add_particle_out(particle);