79 hepmc_event->set_event_number(event.
id().
event());
80 hepmc_event->set_signal_process_id(genEventInfoHandle->
signalProcessID());
81 hepmc_event->set_event_scale(genEventInfoHandle->
qScale());
82 hepmc_event->set_alphaQED(genEventInfoHandle->
alphaQED());
83 hepmc_event->set_alphaQCD(genEventInfoHandle->
alphaQCD());
85 hepmc_event->weights() = genEventInfoHandle->
weights();
89 if ( pdf !=
nullptr ) {
90 const int pdf_id1 = pdf->
id.first, pdf_id2 = pdf->
id.second;
91 const double pdf_x1 = pdf->
x.first, pdf_x2 = pdf->
x.second;
92 const double pdf_scalePDF = pdf->
scalePDF;
93 const double pdf_xPDF1 = pdf->
xPDF.first, pdf_xPDF2 = pdf->
xPDF.second;
94 HepMC::PdfInfo hepmc_pdfInfo(pdf_id1, pdf_id2, pdf_x1, pdf_x2, pdf_scalePDF, pdf_xPDF1, pdf_xPDF2);
95 hepmc_event->set_pdf_info(hepmc_pdfInfo);
99 std::map<const reco::Candidate*, HepMC::GenParticle*> genCandToHepMCMap;
101 std::vector<HepMC::GenParticle*> hepmc_particles;
103 for (
unsigned int i=0,
n=genParticlesHandle->
size();
i<
n; ++
i )
107 hepmc_particle->suggest_barcode(
i+1);
112 else particleMass = p->
mass();
114 hepmc_particle->set_generated_mass(particleMass);
116 hepmc_particles.push_back(hepmc_particle);
117 genCandToHepMCMap[
p] = hepmc_particle;
121 if ( !parton1 and p->
pz() > 0 ) {
123 hepmc_parton1 = hepmc_particle;
125 else if ( !parton2 and p->
pz() < 0 ) {
127 hepmc_parton2 = hepmc_particle;
132 HepMC::GenVertex* vertex1 =
nullptr;
133 HepMC::GenVertex* vertex2 =
nullptr;
134 if ( parton1 ==
nullptr || parton2 ==
nullptr ) {
139 vertex1 =
new HepMC::GenVertex(
FourVector(nullP4));
140 vertex2 =
new HepMC::GenVertex(
FourVector(nullP4));
147 vertex2 =
new HepMC::GenVertex(
FourVector(parton2->vertex()));
149 hepmc_event->add_vertex(vertex1);
150 hepmc_event->add_vertex(vertex2);
151 vertex1->add_particle_in(hepmc_parton1);
152 vertex2->add_particle_in(hepmc_parton2);
156 typedef std::map<const reco::Candidate*, HepMC::GenVertex*> ParticleToVertexMap;
157 ParticleToVertexMap particleToVertexMap;
158 particleToVertexMap[parton1] = vertex1;
159 particleToVertexMap[parton2] = vertex2;
160 for (
unsigned int i=0, n=genParticlesHandle->
size();
i<
n; ++
i )
163 if ( p == parton1
or p == parton2 )
continue;
166 for (
unsigned int j=0, nMothers=p->
numberOfMothers(); j<nMothers; ++j )
170 HepMC::GenVertex* vertex;
171 if ( particleToVertexMap.find(elder) == particleToVertexMap.end() )
174 hepmc_event->add_vertex(vertex);
175 particleToVertexMap[elder] = vertex;
179 vertex = particleToVertexMap[elder];
184 vertex->add_particle_in(genCandToHepMCMap[mother]);
185 vertex->add_particle_out(hepmc_particles[
i]);
190 bool hasSignalVertex =
false;
193 for (
auto v = hepmc_event->vertices_begin();
v != hepmc_event->vertices_end(); ++
v ) {
196 const int pdgId = (*p)->pdg_id();
198 hepmc_event->set_signal_process_vertex(*
v);
199 hasSignalVertex =
true;
203 if ( hasSignalVertex )
break;
207 if ( !hasSignalVertex ) hepmc_event->set_signal_process_vertex(*(vertex1->vertices_begin()));
210 hepmc_product->addHepMCData(hepmc_event);
211 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
math::XYZTLorentzVector LorentzVector
Lorentz vector.
std::vector< double > & weights()
const_reference at(size_type pos) const
virtual const Point & vertex() const =0
vertex position
unsigned int signalProcessID() const