21 #include "HepMC/IO_HEPEVT.h"
22 #include <HepMC/HEPEVT_Wrapper.h>
23 #include "HepPID/ParticleIDTranslations.hh"
25 #include <Math/VectorUtil.h>
37 beamEnergy_(cfg.getParameter<double>(
"beamEnergy")),
55 heprup.
IDBMUP.first = 2212;
56 heprup.
IDBMUP.second = 2212;
61 heprup.
PDFSUP.first = 10042;
62 heprup.
PDFSUP.second = 10042;
66 heprup.
XERRUP.push_back(0.);
67 heprup.
XMAXUP.push_back(1.);
68 heprup.
LPRUP.push_back(1);
75 for ( HepMC::GenEvent::particle_const_iterator genParticle =
genEvt_->particles_begin();
76 genParticle !=
genEvt_->particles_end(); ++genParticle ) {
80 hepeup.
NUP = numParticles;
90 std::map<int, int> barcodeToIdxMap;
91 int genParticleIdx = 0;
92 for ( HepMC::GenEvent::particle_const_iterator genParticle =
genEvt_->particles_begin();
93 genParticle !=
genEvt_->particles_end(); ++genParticle ) {
94 barcodeToIdxMap[(*genParticle)->barcode()] = genParticleIdx + 1;
95 int pdgId = (*genParticle)->pdg_id();
97 if ( pdgId == 2212 && !(*genParticle)->production_vertex() ) {
98 hepeup.
ISTUP[genParticleIdx] = -1;
100 hepeup.
ISTUP[genParticleIdx] = (*genParticle)->status();
102 if ( (*genParticle)->production_vertex() ) {
104 bool firstMother_initialized =
false;
106 bool lastMother_initialized =
false;
107 for ( HepMC::GenVertex::particles_in_const_iterator genMother = (*genParticle)->production_vertex()->particles_in_const_begin();
108 genMother != (*genParticle)->production_vertex()->particles_in_const_end(); ++genMother ) {
109 int genMotherBarcode = (*genMother)->barcode();
110 assert(barcodeToIdxMap.find(genMotherBarcode) != barcodeToIdxMap.end());
111 int genMotherIdx = barcodeToIdxMap[genMotherBarcode];
112 if ( genMotherIdx < firstMother || !firstMother_initialized ) {
113 firstMother = genMotherIdx;
114 firstMother_initialized =
true;
116 if ( genMotherIdx > lastMother || !lastMother_initialized ) {
117 lastMother = genMotherIdx;
118 lastMother_initialized =
true;
121 hepeup.
MOTHUP[genParticleIdx].first = firstMother;
122 hepeup.
MOTHUP[genParticleIdx].second = ( lastMother > firstMother ) ? lastMother : 0;
124 hepeup.
MOTHUP[genParticleIdx].first = 0;
125 hepeup.
MOTHUP[genParticleIdx].second = 0;
127 hepeup.
ICOLUP[genParticleIdx].first = 0;
128 hepeup.
ICOLUP[genParticleIdx].second = 0;
129 hepeup.
PUP[genParticleIdx][0] = (*genParticle)->momentum().px();
130 hepeup.
PUP[genParticleIdx][1] = (*genParticle)->momentum().py();
131 hepeup.
PUP[genParticleIdx][2] = (*genParticle)->momentum().pz();
132 hepeup.
PUP[genParticleIdx][3] = (*genParticle)->momentum().e();
133 hepeup.
PUP[genParticleIdx][4] = (*genParticle)->momentum().m();
134 if ( (*genParticle)->status() == 1 ) hepeup.
VTIMUP[genParticleIdx] = 1.e+6;
135 else hepeup.
VTIMUP[genParticleIdx] = 0.;
136 hepeup.
SPINUP[genParticleIdx] = 9;
138 std::cout <<
"adding genParticle #" << (genParticleIdx + 1)
139 <<
" (pdgId = " << hepeup.
IDUP[genParticleIdx] <<
", status = " << hepeup.
ISTUP[genParticleIdx] <<
"):"
140 <<
" En = " << hepeup.
PUP[genParticleIdx][3] <<
","
141 <<
" Px = " << hepeup.
PUP[genParticleIdx][0] <<
","
142 <<
" Py = " << hepeup.
PUP[genParticleIdx][1] <<
","
143 <<
" Pz = " << hepeup.
PUP[genParticleIdx][2] <<
" (mass = " << hepeup.
PUP[genParticleIdx][4] <<
")" << std::endl;
144 std::cout <<
"(mothers = " << hepeup.
MOTHUP[genParticleIdx].first <<
":" << hepeup.
MOTHUP[genParticleIdx].second <<
")" << std::endl;
164 : beamEnergy_(cfg.getParameter<double>(
"beamEnergy")),
172 <<
" Invalid Configuration Parameter 'mode' = " << mode_string <<
" !!\n";
204 if ( p4.energy() > 1.e+3 ) {
205 double scaleFactor = 1.e+3/p4.energy();
206 double px_limited = scaleFactor*p4.px();
207 double py_limited = scaleFactor*p4.py();
208 double pz_limited = scaleFactor*p4.pz();
210 p4_limited.SetPxPyPzE(
223 return ROOT::Math::VectorUtil::boost(p4ToBoost, -boost);
234 <<
"The GenMuonRadiationAlgorithm module requires the RandomNumberGeneratorService\n"
235 <<
"which appears to be absent. Please add that service to your configuration\n"
236 <<
"or remove the modules that require it.\n";
243 std::cout <<
"<GenMuonRadiationAlgorithm::compMuonFSR>:" << std::endl;
244 std::cout <<
" muon: En = " << muonP4.E() <<
", Pt = " << muonP4.pt() <<
", eta = " << muonP4.eta() <<
", phi = " << muonP4.phi() <<
", charge = " << muonCharge << std::endl;
245 std::cout <<
" other: En = " << otherP4.E() <<
", Pt = " << otherP4.pt() <<
", eta = " << otherP4.eta() <<
", phi = " << otherP4.phi() << std::endl;
249 int muonPdgId = -13*muonCharge;
251 int otherPdgId = +13*muonCharge;
255 std::cout <<
"muon(limited): En = " << muonP4_limited.E() <<
", Pt = " << muonP4_limited.pt() <<
", eta = " << muonP4_limited.eta() <<
", phi = " << muonP4_limited.phi() << std::endl;
256 std::cout <<
"other: En = " << otherP4_limited.E() <<
", Pt = " << otherP4_limited.pt() <<
", eta = " << otherP4_limited.eta() <<
", phi = " << otherP4_limited.phi() << std::endl;
257 std::cout <<
"Z: En = " << zP4.E() <<
", Pt = " << zP4.pt() <<
", eta = " << zP4.eta() <<
", phi = " << zP4.phi() << std::endl;
260 HepMC::GenEvent* genEvt_beforeFSR =
new HepMC::GenEvent();
261 HepMC::GenVertex* genVtx_in =
new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.,0.));
264 genVtx_in->add_particle_in(
new HepMC::GenParticle(HepMC::FourVector(0., 0., +protonPz, protonEn), 2212, 3));
265 genVtx_in->add_particle_in(
new HepMC::GenParticle(HepMC::FourVector(0., 0., -protonPz, protonEn), 2212, 3));
266 genEvt_beforeFSR->add_vertex(genVtx_in);
268 double protonEn_rf = 0.5*ppP4_scattered.mass();
274 genVtx_in->add_particle_out(
new HepMC::GenParticle(HepMC::FourVector(proton1P4_scattered.px(), proton1P4_scattered.py(), proton1P4_scattered.pz(), proton1P4_scattered.E()), 2212, 1));
275 genVtx_in->add_particle_out(
new HepMC::GenParticle(HepMC::FourVector(proton2P4_scattered.px(), proton2P4_scattered.py(), proton2P4_scattered.pz(), proton2P4_scattered.E()), 2212, 1));
276 HepMC::GenVertex* genVtx_out =
new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.,0.));
278 genVtx_in->add_particle_out(genZ);
279 genVtx_out->add_particle_in(genZ);
281 genVtx_out->add_particle_out(genMuon);
283 genVtx_out->add_particle_out(genOther);
284 genEvt_beforeFSR->add_vertex(genVtx_out);
286 std::cout <<
"genEvt (beforeFSR):" << std::endl;
292 HepMC::GenEvent* genEvt_afterFSR = 0;
302 call_pyinit(
"USER",
"",
"", 0.);
308 std::cout <<
"HEPEUP (beforeFSR):" << std::endl;
315 std::cout <<
"PYJETS (afterFSR):" << std::endl;
321 std::cout <<
"HepMC (afterFSR):" << std::endl;
326 HepMC::IO_HEPEVT
conv;
327 conv.set_print_inconsistency_errors(
false);
328 genEvt_afterFSR = conv.read_next_event();
336 HepMC::IO_HEPEVT
conv;
337 conv.write_event(genEvt_beforeFSR);
342 std::cout <<
"genEvt (afterFSR):" << std::endl;
349 for ( HepMC::GenEvent::particle_iterator genParticle = genEvt_afterFSR->particles_begin();
350 genParticle != genEvt_afterFSR->particles_end(); ++genParticle ) {
351 if ( (*genParticle)->pdg_id() == muonPdgId && (*genParticle)->momentum().e() < muonP4afterFSR.E() ) {
352 muonP4afterFSR.SetPxPyPzE(
353 (*genParticle)->momentum().px(),
354 (*genParticle)->momentum().py(),
355 (*genParticle)->momentum().pz(),
356 (*genParticle)->momentum().e());
361 std::cout <<
"sumPhotons: En = " << sumPhotonP4.E() <<
", Pt = " << sumPhotonP4.pt() <<
", eta = " << sumPhotonP4.eta() <<
", phi = " << sumPhotonP4.phi() << std::endl;
364 delete genEvt_beforeFSR;
365 if ( genEvt_afterFSR != genEvt_beforeFSR )
delete genEvt_afterFSR;
T getParameter(std::string const &) const
math::XYZVector Vector
point in the space
CLHEP::HepRandomEngine * decayRandomEngine
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
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
myPythia6ServiceWithCallback(const edm::ParameterSet &cfg)
virtual void setRandomEngine(CLHEP::HepRandomEngine *decayRandomEngine)=0
def gen
run2 Cosmic #### Run 256259 @ 0T 2015C### Run 272133 @ 3.8T 2016B###
std::pair< int, int > PDFGUP
T x() const
Cartesian x coordinate.
gen::PhotosInterfaceBase * photos_
static bool photos_isInitialized_
virtual HepMC::GenEvent * apply(HepMC::GenEvent *evt)
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
void call_pyedit(int mode)
~GenMuonRadiationAlgorithm()
std::vector< double > XERRUP
reco::Candidate::LorentzVector compFSR(const edm::StreamID &streamID, const reco::Candidate::LorentzVector &, int, const reco::Candidate::LorentzVector &, int &)
std::vector< double > XMAXUP
~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)
std::vector< double > XSECUP
static bool pythia_isInitialized_
std::vector< std::pair< int, int > > ICOLUP
T get(const Candidate &c)
static void fillHEPRUP(const HEPRUP *heprup)