@@ -38,6 +38,7 @@ class GenParticles2HepMCConverter : public edm::stream::EDProducer<>
38
38
edm::ESHandle<ParticleDataTable> pTable_;
39
39
40
40
std::vector<int > signalParticlePdgIds_;
41
+ const double cmEnergy_;
41
42
42
43
private:
43
44
inline HepMC::FourVector FourVector (const reco::Candidate::Point & point)
@@ -54,7 +55,8 @@ class GenParticles2HepMCConverter : public edm::stream::EDProducer<>
54
55
55
56
};
56
57
57
- GenParticles2HepMCConverter::GenParticles2HepMCConverter (const edm::ParameterSet& pset)
58
+ GenParticles2HepMCConverter::GenParticles2HepMCConverter (const edm::ParameterSet& pset):
59
+ cmEnergy_(pset.getUntrackedParameter<double >(" cmEnergy" , 13000 )) // dummy value to set incident proton pz for particle gun samples
58
60
{
59
61
genParticlesToken_ = consumes<reco::CandidateView>(pset.getParameter <edm::InputTag>(" genParticles" ));
60
62
genEventInfoToken_ = consumes<GenEventInfoProduct>(pset.getParameter <edm::InputTag>(" genEventInfo" ));
@@ -84,12 +86,14 @@ void GenParticles2HepMCConverter::produce(edm::Event& event, const edm::EventSet
84
86
85
87
// Set PDF
86
88
const gen::PdfInfo* pdf = genEventInfoHandle->pdf ();
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);
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);
96
+ }
93
97
94
98
// Prepare list of HepMC::GenParticles
95
99
std::map<const reco::Candidate*, HepMC::GenParticle*> genCandToHepMCMap;
@@ -125,9 +129,23 @@ void GenParticles2HepMCConverter::produce(edm::Event& event, const edm::EventSet
125
129
}
126
130
}
127
131
128
- // Put incident beam particles : proton -> parton vertex
129
- HepMC::GenVertex* vertex1 = new HepMC::GenVertex (FourVector (parton1->vertex ()));
130
- HepMC::GenVertex* vertex2 = new HepMC::GenVertex (FourVector (parton2->vertex ()));
132
+ HepMC::GenVertex* vertex1 = nullptr ;
133
+ HepMC::GenVertex* vertex2 = nullptr ;
134
+ if ( parton1 == nullptr and parton2 == nullptr ) {
135
+ // Particle gun samples do not have incident partons. Put dummy incident particle and prod vertex
136
+ // Note: leave parton1 and parton2 as nullptr since it is not used anymore after creating hepmc_parton1 and 2
137
+ const reco::Candidate::LorentzVector nullP4 (0 ,0 ,0 ,0 );
138
+ const reco::Candidate::LorentzVector beamP4 (0 ,0 ,cmEnergy_/2 , cmEnergy_/2 );
139
+ vertex1 = new HepMC::GenVertex (FourVector (nullP4));
140
+ vertex2 = new HepMC::GenVertex (FourVector (nullP4));
141
+ hepmc_parton1 = new HepMC::GenParticle (FourVector (+beamP4), 2212 , 4 );
142
+ hepmc_parton2 = new HepMC::GenParticle (FourVector (-beamP4), 2212 , 4 );
143
+ }
144
+ else {
145
+ // Put incident beam particles : proton -> parton vertex
146
+ vertex1 = new HepMC::GenVertex (FourVector (parton1->vertex ()));
147
+ vertex2 = new HepMC::GenVertex (FourVector (parton2->vertex ()));
148
+ }
131
149
hepmc_event->add_vertex (vertex1);
132
150
hepmc_event->add_vertex (vertex2);
133
151
vertex1->add_particle_in (hepmc_parton1);
0 commit comments