76 HepMC::GenEvent* hepmc_event =
new HepMC::GenEvent();
77 hepmc_event->set_event_number(event.
id().
event());
78 hepmc_event->set_signal_process_id(genEventInfoHandle->
signalProcessID());
79 hepmc_event->set_event_scale(genEventInfoHandle->
qScale());
80 hepmc_event->set_alphaQED(genEventInfoHandle->
alphaQED());
81 hepmc_event->set_alphaQCD(genEventInfoHandle->
alphaQCD());
83 hepmc_event->weights() = genEventInfoHandle->
weights();
87 const int pdf_id1 = pdf->
id.first, pdf_id2 = pdf->
id.second;
88 const double pdf_x1 = pdf->
x.first, pdf_x2 = pdf->
x.second;
89 const double pdf_scalePDF = pdf->
scalePDF;
90 const double pdf_xPDF1 = pdf->
xPDF.first, pdf_xPDF2 = pdf->
xPDF.second;
91 HepMC::PdfInfo hepmc_pdfInfo(pdf_id1, pdf_id2, pdf_x1, pdf_x2, pdf_scalePDF, pdf_xPDF1, pdf_xPDF2);
92 hepmc_event->set_pdf_info(hepmc_pdfInfo);
95 std::map<const reco::Candidate*, HepMC::GenParticle*> genCandToHepMCMap;
97 std::vector<HepMC::GenParticle*> hepmc_particles;
99 for (
unsigned int i=0,
n=genParticlesHandle->
size();
i<
n; ++
i )
103 hepmc_particle->suggest_barcode(
i+1);
108 else particleMass = p->
mass();
110 hepmc_particle->set_generated_mass(particleMass);
112 hepmc_particles.push_back(hepmc_particle);
113 genCandToHepMCMap[
p] = hepmc_particle;
117 if ( !parton1 and p->
pz() > 0 ) {
119 hepmc_parton1 = hepmc_particle;
121 else if ( !parton2 and p->
pz() < 0 ) {
123 hepmc_parton2 = hepmc_particle;
129 HepMC::GenVertex* vertex1 =
new HepMC::GenVertex(
FourVector(parton1->
vertex()));
130 HepMC::GenVertex* vertex2 =
new HepMC::GenVertex(
FourVector(parton2->vertex()));
131 hepmc_event->add_vertex(vertex1);
132 hepmc_event->add_vertex(vertex2);
133 vertex1->add_particle_in(hepmc_parton1);
134 vertex2->add_particle_in(hepmc_parton2);
138 typedef std::map<const reco::Candidate*, HepMC::GenVertex*> ParticleToVertexMap;
139 ParticleToVertexMap particleToVertexMap;
140 particleToVertexMap[parton1] = vertex1;
141 particleToVertexMap[parton2] = vertex2;
142 for (
unsigned int i=0, n=genParticlesHandle->
size();
i<
n; ++
i )
145 if ( p == parton1
or p == parton2 )
continue;
148 for (
unsigned int j=0, nMothers=p->
numberOfMothers(); j<nMothers; ++j )
152 HepMC::GenVertex* vertex;
153 if ( particleToVertexMap.find(elder) == particleToVertexMap.end() )
156 hepmc_event->add_vertex(vertex);
157 particleToVertexMap[elder] = vertex;
161 vertex = particleToVertexMap[elder];
166 vertex->add_particle_in(genCandToHepMCMap[mother]);
167 vertex->add_particle_out(hepmc_particles[
i]);
172 bool hasSignalVertex =
false;
175 for (
auto v = hepmc_event->vertices_begin();
v != hepmc_event->vertices_end(); ++
v ) {
178 const int pdgId = (*p)->pdg_id();
180 hepmc_event->set_signal_process_vertex(*
v);
181 hasSignalVertex =
true;
185 if ( hasSignalVertex )
break;
189 if ( !hasSignalVertex ) hepmc_event->set_signal_process_vertex(*(vertex1->vertices_begin()));
192 hepmc_product->addHepMCData(hepmc_event);
193 event.put(
std::move(hepmc_product),
"unsmeared");
EventNumber_t event() const
virtual double pz() const =0
z coordinate of momentum vector
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) ...
std::pair< double, double > x
edm::ESHandle< ParticleDataTable > pTable_
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
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_
void getData(T &iHolder) const
std::pair< double, double > xPDF
virtual int status() const =0
status word
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
virtual int pdgId() const =0
PDG identifier.
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::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
std::vector< int > signalParticlePdgIds_
Abs< T >::type abs(const T &t)
virtual double eta() const =0
momentum pseudorapidity
virtual double mass() const =0
mass
std::vector< double > & weights()
const_reference at(size_type pos) const
virtual const Point & vertex() const =0
vertex position
unsigned int signalProcessID() const