47 return HepMC::FourVector(10 * point.x(), 10 * point.y(), 10 * point.z(), 0);
52 return HepMC::FourVector(lvec.px(), lvec.py(), lvec.pz(), std::hypot(lvec.P(),
std::max(0., lvec.mass())));
58 : cmEnergy_(pset.getUntrackedParameter<double>(
"cmEnergy", 13000)) {
62 pTable_ = esConsumes<HepPDT::ParticleDataTable, PDTRecord>();
65 produces<edm::HepMCProduct>(
"unsmeared");
72 xsec_.set_cross_section(genRunInfoHandle->internalXSec().value(), genRunInfoHandle->internalXSec().error());
85 hepmc_event->set_event_number(event.
id().
event());
86 hepmc_event->set_signal_process_id(genEventInfoHandle->signalProcessID());
87 hepmc_event->set_event_scale(genEventInfoHandle->qScale());
88 hepmc_event->set_alphaQED(genEventInfoHandle->alphaQED());
89 hepmc_event->set_alphaQCD(genEventInfoHandle->alphaQCD());
91 hepmc_event->weights() = genEventInfoHandle->weights();
93 hepmc_event->set_cross_section(
xsec_);
98 const int pdf_id1 = pdf->
id.first, pdf_id2 = pdf->
id.second;
99 const double pdf_x1 = pdf->
x.first, pdf_x2 = pdf->
x.second;
100 const double pdf_scalePDF = pdf->
scalePDF;
101 const double pdf_xPDF1 = pdf->
xPDF.first, pdf_xPDF2 = pdf->
xPDF.second;
102 HepMC::PdfInfo hepmc_pdfInfo(pdf_id1, pdf_id2, pdf_x1, pdf_x2, pdf_scalePDF, pdf_xPDF1, pdf_xPDF2);
103 hepmc_event->set_pdf_info(hepmc_pdfInfo);
107 std::map<const reco::Candidate*, HepMC::GenParticle*> genCandToHepMCMap;
109 std::vector<HepMC::GenParticle*> hepmc_particles;
111 for (
unsigned int i = 0,
n = genParticlesHandle->size();
i <
n; ++
i) {
114 hepmc_particle->suggest_barcode(
i + 1);
118 if (pTableData.particle(p->
pdgId()))
119 particleMass = pTableData.particle(p->
pdgId())->
mass();
121 particleMass = p->
mass();
123 hepmc_particle->set_generated_mass(particleMass);
125 hepmc_particles.push_back(hepmc_particle);
126 genCandToHepMCMap[
p] = hepmc_particle;
130 if (!parton1 and p->
pz() > 0) {
132 hepmc_parton1 = hepmc_particle;
133 }
else if (!parton2 and p->
pz() < 0) {
135 hepmc_parton2 = hepmc_particle;
140 HepMC::GenVertex* vertex1 =
nullptr;
141 HepMC::GenVertex* vertex2 =
nullptr;
142 if (parton1 ==
nullptr || parton2 ==
nullptr) {
147 vertex1 =
new HepMC::GenVertex(
FourVector(nullP4));
148 vertex2 =
new HepMC::GenVertex(
FourVector(nullP4));
154 vertex2 =
new HepMC::GenVertex(
FourVector(parton2->vertex()));
156 hepmc_event->add_vertex(vertex1);
157 hepmc_event->add_vertex(vertex2);
158 vertex1->add_particle_in(hepmc_parton1);
159 vertex2->add_particle_in(hepmc_parton2);
163 typedef std::map<const reco::Candidate*, HepMC::GenVertex*> ParticleToVertexMap;
164 ParticleToVertexMap particleToVertexMap;
165 particleToVertexMap[parton1] = vertex1;
166 particleToVertexMap[parton2] = vertex2;
167 for (
unsigned int i = 0, n = genParticlesHandle->size();
i <
n; ++
i) {
169 if (p == parton1
or p == parton2)
176 HepMC::GenVertex* vertex;
177 if (particleToVertexMap.find(elder) == particleToVertexMap.end()) {
179 hepmc_event->add_vertex(vertex);
180 particleToVertexMap[elder] = vertex;
182 vertex = particleToVertexMap[elder];
187 vertex->add_particle_in(genCandToHepMCMap[mother]);
188 vertex->add_particle_out(hepmc_particles[
i]);
193 bool hasSignalVertex =
false;
196 for (
auto v = hepmc_event->vertices_begin();
v != hepmc_event->vertices_end(); ++
v) {
197 for (
auto p = (*v)->particles_begin(HepMC::children);
p != (*v)->particles_end(HepMC::children); ++
p) {
198 const int pdgId = (*p)->pdg_id();
201 hepmc_event->set_signal_process_vertex(*
v);
202 hasSignalVertex =
true;
211 if (!hasSignalVertex)
212 hepmc_event->set_signal_process_vertex(*(vertex1->vertices_begin()));
215 hepmc_product->addHepMCData(hepmc_event);
216 event.put(
std::move(hepmc_product),
"unsmeared");
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
EventNumber_t event() const
edm::EDGetTokenT< GenRunInfoProduct > genRunInfoToken_
edm::EDGetTokenT< GenEventInfoProduct > genEventInfoToken_
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
#define DEFINE_FWK_MODULE(type)
void beginRun(edm::Run const &iRun, edm::EventSetup const &) override
virtual double mass() const =0
mass
virtual int status() const =0
status word
std::pair< double, double > x
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
virtual double pz() const =0
z coordinate of momentum vector
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
HepMC::FourVector FourVector(const reco::Candidate::Point &point)
edm::EDGetTokenT< reco::CandidateView > genParticlesToken_
HepMC::GenCrossSection xsec_
edm::ESGetToken< HepPDT::ParticleDataTable, PDTRecord > pTable_
std::pair< double, double > xPDF
bool getData(T &iHolder) const
HepMC::FourVector FourVector(const reco::Candidate::LorentzVector &lvec)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< int > signalParticlePdgIds_
Abs< T >::type abs(const T &t)
virtual const Point & vertex() const =0
vertex position
virtual int pdgId() const =0
PDG identifier.
T getParameter(std::string const &) const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
math::XYZPoint Point
point in the space
GenParticles2HepMCConverter(const edm::ParameterSet &pset)
~GenParticles2HepMCConverter() override
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
virtual double eta() const =0
momentum pseudorapidity
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector