9 #include "HepMC/GenEvent.h" 10 #include "HepMC/IO_HEPEVT.h" 11 #include "HepMC/HEPEVT_Wrapper.h" 75 for (
int ip = 0; ip < 4000; ip++)
84 for (
int iv = 1; iv <= evt->vertices_size(); iv++) {
85 bool legalVtx =
false;
89 HepMC::GenVertex*
vtx = evt->barcode_to_vertex(-iv);
91 if (vtx->particles_in_size() != 1)
93 if (vtx->particles_out_size() <= 1)
96 if ((*(vtx->particles_in_const_begin()))->pdg_id() == 111)
99 if (
fOnlyPDG != 1 && (*(vtx->particles_in_const_begin()))->pdg_id() !=
fOnlyPDG) {
107 for (HepMC::GenVertex::particle_iterator pitr = vtx->particles_begin(
HepMC::children);
110 if ((*pitr)->pdg_id() ==
fOnlyPDG) {
138 for (HepMC::GenVertex::particle_iterator pitr = vtx->particles_begin(
HepMC::children);
142 if (
abs((*pitr)->pdg_id()) >= 1 &&
abs((*pitr)->pdg_id()) <= 8)
144 if (
abs((*pitr)->pdg_id()) == 21)
147 if ((*pitr)->status() == 1 || (*pitr)->end_vertex()) {
162 HepMC::HEPEVT_Wrapper::set_event_number(evt->event_number());
168 HepMC::GenVertex*
vtx = evt->barcode_to_vertex(vtxbcode);
179 HepMC::HEPEVT_Wrapper::zero_everything();
185 HepMC::HEPEVT_Wrapper::set_id(index, (*(vtx->particles_in_const_begin()))->pdg_id());
186 HepMC::FourVector
vec4;
187 vec4 = (*(vtx->particles_in_const_begin()))->momentum();
188 HepMC::HEPEVT_Wrapper::set_momentum(index, vec4.x(), vec4.y(), vec4.z(), vec4.e());
189 HepMC::HEPEVT_Wrapper::set_mass(index, (*(vtx->particles_in_const_begin()))->generated_mass());
190 HepMC::HEPEVT_Wrapper::set_position(
191 index, vtx->position().x(), vtx->position().y(), vtx->position().z(), vtx->position().t());
192 HepMC::HEPEVT_Wrapper::set_status(index, (*(vtx->particles_in_const_begin()))->status());
193 HepMC::HEPEVT_Wrapper::set_parents(index, 0, 0);
194 fBarcodes.push_back((*(vtx->particles_in_const_begin()))->barcode());
199 for (HepMC::GenVertex::particle_iterator pitr = vtx->particles_begin(
HepMC::children);
202 if ((*pitr)->status() == 1 || (*pitr)->end_vertex()) {
204 vec4 = (*pitr)->momentum();
205 HepMC::HEPEVT_Wrapper::set_id(index, (*pitr)->pdg_id());
206 HepMC::HEPEVT_Wrapper::set_momentum(index, vec4.x(), vec4.y(), vec4.z(), vec4.e());
207 HepMC::HEPEVT_Wrapper::set_mass(index, (*pitr)->generated_mass());
208 vec4 = (*pitr)->production_vertex()->position();
209 HepMC::HEPEVT_Wrapper::set_position(index, vec4.x(), vec4.y(), vec4.z(), vec4.t());
210 HepMC::HEPEVT_Wrapper::set_status(index, (*pitr)->status());
211 HepMC::HEPEVT_Wrapper::set_parents(index, 1, 1);
215 if ((*pitr)->end_vertex()) {
216 fSecVtxStore.push_back((*pitr)->end_vertex()->barcode());
222 int nentries =
index;
226 HepMC::HEPEVT_Wrapper::set_children(index, 2, lastDau);
231 HepMC::HEPEVT_Wrapper::set_number_entries(nentries);
264 unsigned int vcounter = 0;
277 if (HepMC::HEPEVT_Wrapper::number_entries() > nentries) {
287 int largestBarcode = -1;
290 for (
int ip = 1; ip < Nbcodes; ip++) {
293 if (bcode > largestBarcode)
294 largestBarcode = bcode;
297 double pz = HepMC::HEPEVT_Wrapper::pz(ip + 1);
301 if (prt->end_vertex()) {
302 HepMC::GenVertex* endVtx = prt->end_vertex();
304 std::vector<int> secVtxStorage;
305 secVtxStorage.clear();
307 secVtxStorage.push_back(endVtx->barcode());
309 const HepMC::FourVector& mom4 = prt->momentum();
312 double bet1[3], bet2[3], gam1, gam2, pb;
313 double mass = mom4.m();
314 bet1[0] = -(mom4.px() /
mass);
315 bet1[1] = -(mom4.py() /
mass);
316 bet1[2] = -(mom4.pz() /
mass);
320 gam1 = mom4.e() /
mass;
323 unsigned int vcounter = 0;
325 while (vcounter < secVtxStorage.size()) {
326 HepMC::GenVertex* theVtx = evt->barcode_to_vertex(secVtxStorage[vcounter]);
328 for (HepMC::GenVertex::particle_iterator pitr = theVtx->particles_begin(
HepMC::children);
331 if ((*pitr)->end_vertex()) {
332 secVtxStorage.push_back((*pitr)->end_vertex()->barcode());
335 if (theVtx->particles_out_size() == 1 && (*pitr)->pdg_id() == prt->pdg_id()) {
337 (*pitr)->set_momentum(HepMC::FourVector(px, py, pz, e));
341 HepMC::FourVector dmom4 = (*pitr)->momentum();
344 pb = bet1[0] * dmom4.px() + bet1[1] * dmom4.py() + bet1[2] * dmom4.pz();
345 double dpx = dmom4.px() + bet1[0] * (dmom4.e() + pb / (gam1 + 1.));
346 double dpy = dmom4.py() + bet1[1] * (dmom4.e() + pb / (gam1 + 1.));
347 double dpz = dmom4.pz() + bet1[2] * (dmom4.e() + pb / (gam1 + 1.));
348 double de = gam1 * dmom4.e() + pb;
350 pb = bet2[0] * dpx + bet2[1] * dpy + bet2[2] * dpz;
351 dpx += bet2[0] * (de + pb / (gam2 + 1.));
352 dpy += bet2[1] * (de + pb / (gam2 + 1.));
353 dpz += bet2[2] * (de + pb / (gam2 + 1.));
357 (*pitr)->set_momentum(HepMC::FourVector(dpx, dpy, dpz, de));
362 secVtxStorage.clear();
365 prt->set_momentum(HepMC::FourVector(px, py, pz, e));
369 int newlyGen = HepMC::HEPEVT_Wrapper::number_entries() - nentries;
371 if (largestBarcode < evt->particles_size()) {
376 for (
int ipp = evt->particles_size(); ipp > largestBarcode; ipp--) {
377 (evt->barcode_to_particle(ipp))->suggest_barcode(ipp + newlyGen);
383 for (
int ipnw = 1; ipnw <= newlyGen; ipnw++) {
384 int nbcode = largestBarcode + ipnw;
389 double pz = HepMC::HEPEVT_Wrapper::pz(nentries + ipnw);
394 NewPart->set_generated_mass(m);
395 NewPart->suggest_barcode(nbcode);
396 vtx->add_particle_out(NewPart);
408 if (
abs((*(vtx->particles_in_const_begin()))->pdg_id()) != 15)
411 for (HepMC::GenVertex::particle_iterator pitr = vtx->particles_begin(
HepMC::children);
414 if (
abs((*pitr)->pdg_id()) == 11 ||
abs((*pitr)->pdg_id()) == 13) {
425 <<
"PhotosInterface::flat: Attempt to generate random number when engine pointer is null\n" 426 <<
"This might mean that the code was modified to generate a random number outside the\n" 427 <<
"event and beginLuminosityBlock methods, which is not allowed.\n";
void attachParticles(HepMC::GenEvent *, HepMC::GenVertex *, int)
CLHEP::HepRandomEngine * decayRandomEngine
void configureOnlyFor(int) override
double phoran_(int *idummy)
void setRandomEngine(CLHEP::HepRandomEngine *decayRandomEngine) override
~PhotosInterface() override
std::vector< int > fBarcodes
bool fAvoidTauLeptonicDecays
Abs< T >::type abs(const T &t)
static CLHEP::HepRandomEngine * fRandomEngine
void applyToBranch(HepMC::GenEvent *, int)
HepMC::GenEvent * apply(HepMC::GenEvent *) override
std::vector< int > fSecVtxStore
void applyToVertex(HepMC::GenEvent *, int)
#define DEFINE_EDM_PLUGIN(factory, type, name)
bool isTauLeptonicDecay(HepMC::GenVertex *)
std::vector< std::string > fSpecialSettings