22 #include "HepMC/IO_HEPEVT.h"
23 #include <HepMC/HEPEVT_Wrapper.h>
24 #include "HepPID/ParticleIDTranslations.hh"
26 #include <Math/VectorUtil.h>
38 beamEnergy_(cfg.getParameter<double>(
"beamEnergy")),
56 heprup.
IDBMUP.first = 2212;
57 heprup.
IDBMUP.second = 2212;
62 heprup.
PDFSUP.first = 10042;
63 heprup.
PDFSUP.second = 10042;
67 heprup.
XERRUP.push_back(0.);
68 heprup.
XMAXUP.push_back(1.);
69 heprup.
LPRUP.push_back(1);
76 for ( HepMC::GenEvent::particle_const_iterator genParticle =
genEvt_->particles_begin();
77 genParticle !=
genEvt_->particles_end(); ++genParticle ) {
81 hepeup.
NUP = numParticles;
91 std::map<int, int> barcodeToIdxMap;
92 int genParticleIdx = 0;
93 for ( HepMC::GenEvent::particle_const_iterator genParticle =
genEvt_->particles_begin();
94 genParticle !=
genEvt_->particles_end(); ++genParticle ) {
95 barcodeToIdxMap[(*genParticle)->barcode()] = genParticleIdx + 1;
96 int pdgId = (*genParticle)->pdg_id();
98 if ( pdgId == 2212 && !(*genParticle)->production_vertex() ) {
99 hepeup.
ISTUP[genParticleIdx] = -1;
101 hepeup.
ISTUP[genParticleIdx] = (*genParticle)->status();
103 if ( (*genParticle)->production_vertex() ) {
105 bool firstMother_initialized =
false;
107 bool lastMother_initialized =
false;
108 for ( HepMC::GenVertex::particles_in_const_iterator genMother = (*genParticle)->production_vertex()->particles_in_const_begin();
109 genMother != (*genParticle)->production_vertex()->particles_in_const_end(); ++genMother ) {
110 int genMotherBarcode = (*genMother)->barcode();
111 assert(barcodeToIdxMap.find(genMotherBarcode) != barcodeToIdxMap.end());
112 int genMotherIdx = barcodeToIdxMap[genMotherBarcode];
113 if ( genMotherIdx < firstMother || !firstMother_initialized ) {
114 firstMother = genMotherIdx;
115 firstMother_initialized =
true;
117 if ( genMotherIdx > lastMother || !lastMother_initialized ) {
118 lastMother = genMotherIdx;
119 lastMother_initialized =
true;
122 hepeup.
MOTHUP[genParticleIdx].first = firstMother;
123 hepeup.
MOTHUP[genParticleIdx].second = ( lastMother > firstMother ) ? lastMother : 0;
125 hepeup.
MOTHUP[genParticleIdx].first = 0;
126 hepeup.
MOTHUP[genParticleIdx].second = 0;
128 hepeup.
ICOLUP[genParticleIdx].first = 0;
129 hepeup.
ICOLUP[genParticleIdx].second = 0;
130 hepeup.
PUP[genParticleIdx][0] = (*genParticle)->momentum().px();
131 hepeup.
PUP[genParticleIdx][1] = (*genParticle)->momentum().py();
132 hepeup.
PUP[genParticleIdx][2] = (*genParticle)->momentum().pz();
133 hepeup.
PUP[genParticleIdx][3] = (*genParticle)->momentum().e();
134 hepeup.
PUP[genParticleIdx][4] = (*genParticle)->momentum().m();
135 if ( (*genParticle)->status() == 1 ) hepeup.
VTIMUP[genParticleIdx] = 1.e+6;
136 else hepeup.
VTIMUP[genParticleIdx] = 0.;
137 hepeup.
SPINUP[genParticleIdx] = 9;
139 std::cout <<
"adding genParticle #" << (genParticleIdx + 1)
140 <<
" (pdgId = " << hepeup.
IDUP[genParticleIdx] <<
", status = " << hepeup.
ISTUP[genParticleIdx] <<
"):"
141 <<
" En = " << hepeup.
PUP[genParticleIdx][3] <<
","
142 <<
" Px = " << hepeup.
PUP[genParticleIdx][0] <<
","
143 <<
" Py = " << hepeup.
PUP[genParticleIdx][1] <<
","
144 <<
" Pz = " << hepeup.
PUP[genParticleIdx][2] <<
" (mass = " << hepeup.
PUP[genParticleIdx][4] <<
")" << std::endl;
145 std::cout <<
"(mothers = " << hepeup.
MOTHUP[genParticleIdx].first <<
":" << hepeup.
MOTHUP[genParticleIdx].second <<
")" << std::endl;
165 : beamEnergy_(cfg.getParameter<double>(
"beamEnergy")),
172 <<
"The RandomNumberProducer module requires the RandomNumberGeneratorService\n"
173 <<
"which appears to be absent. Please add that service to your configuration\n"
174 <<
"or remove the modules that require it.\n";
183 <<
" Invalid Configuration Parameter 'mode' = " << mode_string <<
" !!\n";
211 if ( p4.energy() > 1.e+3 ) {
212 double scaleFactor = 1.e+3/p4.energy();
213 double px_limited = scaleFactor*p4.px();
214 double py_limited = scaleFactor*p4.py();
215 double pz_limited = scaleFactor*p4.pz();
217 p4_limited.SetPxPyPzE(
230 return ROOT::Math::VectorUtil::boost(p4ToBoost, -boost);
238 std::cout <<
"<GenMuonRadiationAlgorithm::compMuonFSR>:" << std::endl;
239 std::cout <<
" muon: En = " << muonP4.E() <<
", Pt = " << muonP4.pt() <<
", eta = " << muonP4.eta() <<
", phi = " << muonP4.phi() <<
", charge = " << muonCharge << std::endl;
240 std::cout <<
" other: En = " << otherP4.E() <<
", Pt = " << otherP4.pt() <<
", eta = " << otherP4.eta() <<
", phi = " << otherP4.phi() << std::endl;
244 int muonPdgId = -13*muonCharge;
246 int otherPdgId = +13*muonCharge;
250 std::cout <<
"muon(limited): En = " << muonP4_limited.E() <<
", Pt = " << muonP4_limited.pt() <<
", eta = " << muonP4_limited.eta() <<
", phi = " << muonP4_limited.phi() << std::endl;
251 std::cout <<
"other: En = " << otherP4_limited.E() <<
", Pt = " << otherP4_limited.pt() <<
", eta = " << otherP4_limited.eta() <<
", phi = " << otherP4_limited.phi() << std::endl;
252 std::cout <<
"Z: En = " << zP4.E() <<
", Pt = " << zP4.pt() <<
", eta = " << zP4.eta() <<
", phi = " << zP4.phi() << std::endl;
255 HepMC::GenEvent* genEvt_beforeFSR =
new HepMC::GenEvent();
256 HepMC::GenVertex* genVtx_in =
new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.,0.));
259 genVtx_in->add_particle_in(
new HepMC::GenParticle(HepMC::FourVector(0., 0., +protonPz, protonEn), 2212, 3));
260 genVtx_in->add_particle_in(
new HepMC::GenParticle(HepMC::FourVector(0., 0., -protonPz, protonEn), 2212, 3));
261 genEvt_beforeFSR->add_vertex(genVtx_in);
263 double protonEn_rf = 0.5*ppP4_scattered.mass();
269 genVtx_in->add_particle_out(
new HepMC::GenParticle(HepMC::FourVector(proton1P4_scattered.px(), proton1P4_scattered.py(), proton1P4_scattered.pz(), proton1P4_scattered.E()), 2212, 1));
270 genVtx_in->add_particle_out(
new HepMC::GenParticle(HepMC::FourVector(proton2P4_scattered.px(), proton2P4_scattered.py(), proton2P4_scattered.pz(), proton2P4_scattered.E()), 2212, 1));
271 HepMC::GenVertex* genVtx_out =
new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.,0.));
273 genVtx_in->add_particle_out(genZ);
274 genVtx_out->add_particle_in(genZ);
276 genVtx_out->add_particle_out(genMuon);
278 genVtx_out->add_particle_out(genOther);
279 genEvt_beforeFSR->add_vertex(genVtx_out);
281 std::cout <<
"genEvt (beforeFSR):" << std::endl;
287 HepMC::GenEvent* genEvt_afterFSR = 0;
297 call_pyinit(
"USER",
"",
"", 0.);
303 std::cout <<
"HEPEUP (beforeFSR):" << std::endl;
310 std::cout <<
"PYJETS (afterFSR):" << std::endl;
316 std::cout <<
"HepMC (afterFSR):" << std::endl;
321 HepMC::IO_HEPEVT
conv;
322 conv.set_print_inconsistency_errors(
false);
323 genEvt_afterFSR = conv.read_next_event();
331 HepMC::IO_HEPEVT
conv;
332 conv.write_event(genEvt_beforeFSR);
337 std::cout <<
"genEvt (afterFSR):" << std::endl;
344 for ( HepMC::GenEvent::particle_iterator genParticle = genEvt_afterFSR->particles_begin();
345 genParticle != genEvt_afterFSR->particles_end(); ++genParticle ) {
346 if ( (*genParticle)->pdg_id() == muonPdgId && (*genParticle)->momentum().e() < muonP4afterFSR.E() ) {
347 muonP4afterFSR.SetPxPyPzE(
348 (*genParticle)->momentum().px(),
349 (*genParticle)->momentum().py(),
350 (*genParticle)->momentum().pz(),
351 (*genParticle)->momentum().e());
356 std::cout <<
"sumPhotons: En = " << sumPhotonP4.E() <<
", Pt = " << sumPhotonP4.pt() <<
", eta = " << sumPhotonP4.eta() <<
", phi = " << sumPhotonP4.phi() << std::endl;
359 delete genEvt_beforeFSR;
360 if ( genEvt_afterFSR != genEvt_beforeFSR )
delete genEvt_afterFSR;
gen::PhotosInterface * photos_
T getParameter(std::string const &) const
math::XYZVector Vector
point in the space
static HepMC::IO_HEPEVT conv
std::pair< double, double > EBMUP
GenMuonRadiationAlgorithm(const edm::ParameterSet &)
bool call_pygive(const std::string &line)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::vector< double > VTIMUP
std::pair< int, int > IDBMUP
const HepMC::GenEvent * genEvt_
std::pair< double, double > XPDWUP
myPythia6ServiceWithCallback(const edm::ParameterSet &cfg)
std::pair< int, int > PDFGUP
static bool photos_isInitialized_
std::vector< std::pair< int, int > > MOTHUP
void call_pylist(int mode)
std::vector< FiveVector > PUP
static void fillHEPEUP(const HEPEUP *hepeup)
std::vector< double > SPINUP
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
void call_pyedit(int mode)
~GenMuonRadiationAlgorithm()
std::vector< double > XERRUP
std::vector< double > XMAXUP
reco::Candidate::LorentzVector compFSR(const reco::Candidate::LorentzVector &, int, const reco::Candidate::LorentzVector &, int &)
~myPythia6ServiceWithCallback()
std::pair< int, int > PDFSUP
math::XYZTLorentzVector LorentzVector
Lorentz vector.
void repairBarcodes(HepMC::GenEvent *)
myPythia6ServiceWithCallback * pythia_
double square(const double a)
void setEvent(const HepMC::GenEvent *genEvt)
CLHEP::HepRandomEngine * decayRandomEngine
std::vector< double > XSECUP
static bool pythia_isInitialized_
std::vector< std::pair< int, int > > ICOLUP
static void fillHEPRUP(const HEPRUP *heprup)
HepMC::GenEvent * apply(HepMC::GenEvent *)