24 #include <CLHEP/Random/RandGauss.h> 66 if (tagSrcHepMC.
label() !=
"")
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>();
90 ->setComment(
"input collection in HepMC format");
92 desc.
add<std::vector<edm::InputTag>>(
"srcGenParticle", std::vector<edm::InputTag>())
93 ->
setComment(
"input collections in GenParticle format");
95 desc.
add<
bool>(
"simulateBeamDivergence",
true)->setComment(
"account for the beam angular divergence?");
96 desc.
add<
bool>(
"simulateVertex",
true)->setComment(
"account for the vertex transverse smearing?");
98 descriptions.
add(
"beamDivergenceVtxGenerator", desc);
155 for (
const auto &
gp : *hGPCollection)
165 template <
typename T>
171 double th_x = mom.x() / mom.z();
172 double th_y = mom.y() / mom.z();
184 const double sign = (mom.z() > 0.) ? 1. : -1.;
185 const double p =
sqrt(mom.x()*mom.x() + mom.y()*mom.y() + mom.z()*mom.z());
186 const double p_z = sign * p /
sqrt(1. + th_x*th_x + th_y*th_y);
188 return HepMC::FourVector(p_z * th_x, p_z * th_y, p_z, mom.e());
199 const auto &
pos = (*vit)->position();
200 (*vit)->set_position(HepMC::FourVector(
211 for (HepMC::GenEvent::particle_iterator
part = genEvt->particles_begin();
part != genEvt->particles_end(); ++
part)
212 (*part)->set_momentum(
smearMomentum((*part)->momentum(), sp));
221 HepMC::GenVertex *
vtx =
new HepMC::GenVertex(HepMC::FourVector(
227 genEvt->add_vertex(vtx);
231 vtx->add_particle_out(particle);
T getParameter(std::string const &) const
int pdgId() const final
PDG identifier.
void setComment(std::string const &value)
std::vector< edm::EDGetTokenT< reco::GenParticleCollection > > genParticleTokens_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
static void fillDescriptions(edm::ConfigurationDescriptions &)
double vy() const override
y coordinate of vertex position
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double getBeamDivergenceX56() const
static HepMC::FourVector smearMomentum(const T &mom, const SmearingParameters &sp)
double getVtxStddevZ() const
double getVtxOffsetX45() const
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
double getBeamDivergenceX45() const
double getBeamDivergenceY56() const
#define DEFINE_FWK_MODULE(type)
const LorentzVector & p4() const final
four-momentum Lorentz vector
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< edm::HepMCProduct > sourceToken_
double vz() const override
z coordinate of vertex position
double getVtxStddevX() const
void applySmearingHepMC(const SmearingParameters &sp, HepMC::GenEvent *genEvt)
double getBeamDivergenceY45() const
const HepMC::GenEvent * GetEvent() const
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 getVtxOffsetZ45() const
double getVtxOffsetY45() const
StreamID streamID() const
bool simulateBeamDivergence_
int status() const final
status word
bool isUninitialized() const
double getVtxStddevY() const
VertexRefVector::iterator vertex_iterator
iterator over a vector of references to Vertex objects in the same collection
double vx() const override
x coordinate of vertex position
void produce(edm::Event &, const edm::EventSetup &) override