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);
std::vector< edm::EDGetTokenT< reco::GenParticleCollection > > genParticleTokens_
T getParameter(std::string const &) const
static void fillDescriptions(edm::ConfigurationDescriptions &)
double getVtxStddevX() const
static HepMC::FourVector smearMomentum(const T &mom, const SmearingParameters &sp)
double getVtxStddevZ() const
constexpr bool isUninitialized() const noexcept
edm::ESGetToken< CTPPSBeamParameters, CTPPSBeamParametersRcd > beamParametersToken_
double getVtxOffsetX45() const
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
double getVtxOffsetT45() const
double getVtxStddevY() const
double getBeamDivergenceX56() const
double getVtxOffsetZ45() const
double getVtxStddevT() const
double getVtxOffsetY45() const
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< edm::HepMCProduct > sourceToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
const HepMC::GenEvent * GetEvent() const
double getBeamDivergenceY56() const
void applySmearingHepMC(const SmearingParameters &sp, HepMC::GenEvent *genEvt)
void addSmearedGenParticle(const reco::GenParticle &gp, const SmearingParameters &sp, HepMC::GenEvent *genEvt)
BeamDivergenceVtxGenerator(const edm::ParameterSet &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~BeamDivergenceVtxGenerator() override=default
double getBeamDivergenceX45() const
bool simulateBeamDivergence_
VertexRefVector::iterator vertex_iterator
iterator over a vector of references to Vertex objects in the same collection
double getBeamDivergenceY45() const
void produce(edm::Event &, const edm::EventSetup &) override