def test_Attribute(): # First create the event container, with Signal Process 20, event number 1 # evt = hm.GenEvent(hm.Units.GEV, hm.Units.MM) evt.set_event_number(1) evt.add_attribute("signal_process_id", hm.IntAttribute(20)) x1 = hm.VectorIntAttribute() evt.add_attribute("somevector1", x1) x2 = hm.VectorDoubleAttribute(std.vector_double([1.0, 2.0, 3.0, 4.0])) evt.add_attribute("somevector2", x2) v1 = hm.GenVertex() evt.add_vertex(v1) p1 = hm.GenParticle(hm.FourVector(0, 0, 7000, 7000), 2212, 3) evt.add_particle(p1) p1.add_attribute("flow1", hm.IntAttribute(231)) p1.add_attribute("flow1", hm.IntAttribute(233)) random1 = random.random() * math.pi p1.add_attribute("theta", hm.DoubleAttribute(random1)) random2 = random.random() * math.pi * 2 p1.add_attribute("phi", hm.DoubleAttribute(random2)) v2 = hm.GenVertex() evt.add_vertex(v2) p2 = hm.GenParticle(hm.FourVector(0, 0, -7000, 7000), 2212, 3) evt.add_particle(p2) p2.add_attribute("flow1", hm.IntAttribute(243)) random3 = random.random() * math.pi p2.add_attribute("theta", hm.DoubleAttribute(random3)) random4 = random.random() * math.pi * 2 p2.add_attribute("phi", hm.DoubleAttribute(random4)) v2.add_particle_in(p2) evt_spid_back = hm.IntAttribute() evt_spid_back.from_string(evt.attribute("signal_process_id")) assert evt_spid_back.value() == 20 p1_flow1_back = hm.IntAttribute() p1_flow1_back.from_string(p1.attribute("flow1")) assert p1_flow1_back.value() == 233 p2_flow1_back = hm.IntAttribute() p2_flow1_back.from_string(p2.attribute("flow1")) assert p2_flow1_back.value() == 243 p1_theta_back = hm.DoubleAttribute() p1_theta_back.from_string(p1.attribute("theta")) assert fuse_equal(p1_theta_back.value(), random1) p2_phi_back = hm.DoubleAttribute() p2_phi_back.from_string(p2.attribute("phi")) assert fuse_equal(p2_phi_back.value(), random4) evt.clear() return 0
def fill_next_event(self, pyev, evt, ievnum, pyinfo, pyset): # 1. Error if no event passed. if evt is None: print( "Pythia8ToHepMC3::fill_next_event error - passed null event.") return False # Event number counter. if ievnum >= 0: evt.set_event_number(ievnum) self.m_internal_event_number = ievnum else: evt.set_event_number(self.m_internal_event_number) self.m_internal_event_number = self.m_internal_event_number + 1 evt.set_units(hm.Units.GEV, hm.Units.MM) # // 2. Fill particle information hepevt_particles = [] for i in range(0, pyev.size()): hepevt_particles.append( hm.GenParticle( hm.FourVector(pyev[i].px(), pyev[i].py(), pyev[i].pz(), pyev[i].e()), pyev[i].id(), pyev[i].statusHepMC(), )) hepevt_particles[i].set_generated_mass(pyev[i].m()) # // 3. Fill vertex information and find beam particles. # For type compatibility vertex_cache = hm.GenEvent().vertices() beam_particles = hm.GenEvent().particles() for i in range(0, pyev.size()): mothers = pyev[i].motherList() if len(mothers) != 0: prod_vtx = hepevt_particles[mothers[0]].end_vertex() if prod_vtx is None: prod_vtx = hm.GenVertex() vertex_cache.append(prod_vtx) for j in range(0, len(mothers)): prod_vtx.add_particle_in(hepevt_particles[mothers[j]]) prod_pos = hm.FourVector(pyev[i].xProd(), pyev[i].yProd(), pyev[i].zProd(), pyev[i].tProd()) # // Update vertex position if necessary if (not prod_pos.is_zero()) and prod_vtx.position().is_zero(): prod_vtx.set_position(prod_pos) prod_vtx.add_particle_out(hepevt_particles[i]) else: beam_particles.append(hepevt_particles[i]) # // Add particles and vertices in topological order if len(beam_particles) < 2: print("There are ", len(beam_particles), "!=2 particles without mothers") if self.m_crash_on_problem: sys.exit(1) evt.add_tree(beam_particles) # //Attributes should be set after adding the particles to event for i in range(0, pyev.size()): # // Colour flow uses index 1 and 2. colType = pyev[i].colType() if colType == -1 or colType == 1 or colType == 2: flow1 = 0 flow2 = 0 if colType == 1 or colType == 2: flow1 = pyev[i].col() if colType == -1 or colType == 2: flow2 = pyev[i].acol() hepevt_particles[i].add_attribute("flow1", hm.IntAttribute(flow1)) hepevt_particles[i].add_attribute("flow2", hm.IntAttribute(flow2)) # // If hadronization switched on then no final coloured particles. if pyset == None: doHadr = self.m_free_parton_warnings and pyset.flag( "HadronLevel:Hadronize") else: doHadr = pyset.flag("HadronLevel:all") and pyset.flag( "HadronLevel:Hadronize") # // 4. Check for particles which come from nowhere, i.e. are without # // mothers or daughters. These need to be attached to a vertex, or else # // they will never become part of the event. for i in range(1, pyev.size()): # // Check for particles not added to the event # // NOTE: We have to check if this step makes any sense in HepMC event standard if not hepevt_particles[i]: print("hanging particle ", i) prod_vtx = hm.GenVertex() prod_vtx.add_particle_out(hepevt_particles[i]) evt.add_vertex(prod_vtx) # // Also check for free partons (= gluons and quarks; not diquarks?). if doHadr and self.m_free_parton_warnings: if hepevt_particles[i].pid() == 21 and ( hepevt_particles[i].end_vertex() is None): print("gluon without end vertex ", i) if self.m_crash_on_problem: sys.exit(1) if abs(hepevt_particles[i].pid()) <= 6 and ( hepevt_particles[i].end_vertex() is None): print("quark without end vertex ", i) if self.m_crash_on_problem: sys.exit(1) # // 5. Store PDF, weight, cross section and other event information. # // Flavours of incoming partons. if self.m_store_pdf and pyinfo is not None: id1pdf = pyinfo.id1pdf() id2pdf = pyinfo.id2pdf() if self.m_convert_gluon_to_0: if id1pdf == 21: id1pdf = 0 if id2pdf == 21: id2pdf = 0 pdfinfo = hm.GenPdfInfo() pdfinfo.set(id1pdf, id2pdf, pyinfo.x1pdf(), pyinfo.x2pdf(), pyinfo.QFac(), pyinfo.pdf1(), pyinfo.pdf2()) # // Store PDF information. evt.set_pdf_info(pdfinfo) # // Store process code, scale, alpha_em, alpha_s. if self.m_store_proc and pyinfo is not None: evt.add_attribute("mpi", hm.IntAttribute(pyinfo.nMPI())) evt.add_attribute("signal_process_id", hm.IntAttribute(pyinfo.code())) evt.add_attribute("event_scale", hm.DoubleAttribute(pyinfo.QRen())) evt.add_attribute("alphaQCD", hm.DoubleAttribute(pyinfo.alphaS())) evt.add_attribute("alphaQED", hm.DoubleAttribute(pyinfo.alphaEM())) # // Store cross-section information in pb. if self.m_store_xsec and pyinfo is not None: xsec = hm.GenCrossSection() xsec.set_cross_section(pyinfo.sigmaGen() * 1e9, pyinfo.sigmaErr() * 1e9) evt.set_cross_section(xsec) # // Store event weights. if self.m_store_weights and pyinfo is not None: evt.weights().clear() for iweight in range(0, pyinfo.nWeights()): evt.weights().append(pyinfo.weight(iweight)) # // Done. return True
def test_Boost(): evt = hm.GenEvent(hm.Units.MomentumUnit.GEV, hm.Units.LengthUnit.CM) evt.set_event_number(1) evt.add_attribute("signal_process_id", hm.IntAttribute(20)) # create vertex 1 v1 = hm.GenVertex() evt.add_vertex(v1) p1 = hm.GenParticle(hm.FourVector(1.0, 1.0, 7000, 7000), 2212, 3) evt.add_particle(p1) p1.add_attribute("flow1", hm.IntAttribute(231)) p1.add_attribute("flow1", hm.IntAttribute(231)) p1.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p1.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v2 = hm.GenVertex() evt.add_vertex(v2) p2 = hm.GenParticle(hm.FourVector(1.0, 1.0, -7000, 7000), 2212, 3) evt.add_particle(p2) p2.add_attribute("flow1", hm.IntAttribute(243)) p2.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p2.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v2.add_particle_in(p2) # # create the outgoing particles of v1 and v2 p3 = hm.GenParticle(hm.FourVector(0.750, -1.569, 32.191, 32.238), 1, 3) evt.add_particle(p3) p3.add_attribute("flow1", hm.IntAttribute(231)) p3.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p3.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v1.add_particle_out(p3) p4 = hm.GenParticle(hm.FourVector(-3.047, -19.0, -54.629, 57.920), -2, 3) evt.add_particle(p4) p4.add_attribute("flow1", hm.IntAttribute(243)) p4.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p4.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v2.add_particle_out(p4) # # create v3 v3 = hm.GenVertex() evt.add_vertex(v3) v3.add_particle_in(p3) v3.add_particle_in(p4) p6 = hm.GenParticle(hm.FourVector(-3.813, 0.113, -1.833, 4.233), 22, 1) evt.add_particle(p6) p6.add_attribute("flow1", hm.IntAttribute(231)) p6.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p6.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v3.add_particle_out(p6) p5 = hm.GenParticle(hm.FourVector(1.517, -20.68, -20.605, 85.925), -24, 3) evt.add_particle(p5) p5.add_attribute("flow1", hm.IntAttribute(243)) p5.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p5.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v3.add_particle_out(p5) # # create v4 v4 = hm.GenVertex(hm.FourVector(0.12, -0.3, 0.05, 0.004)) evt.add_vertex(v4) v4.add_particle_in(p5) p7 = hm.GenParticle(hm.FourVector(-2.445, 28.816, 6.082, 29.552), 1, 1) evt.add_particle(p7) v4.add_particle_out(p7) p8 = hm.GenParticle(hm.FourVector(3.962, -49.498, -26.687, 56.373), -2, 1) evt.add_particle(p8) v4.add_particle_out(p8) # # tell the event which vertex is the signal process vertex evt.add_attribute("signal_process_vertex", hm.IntAttribute(v3.id())) bwrong1 = hm.FourVector(-1.1, -0.3, 0.2, 0) # Test that wrong boost will not work print(dir(evt)) assert False == evt.boost(bwrong1) bwrong2 = hm.FourVector(-1.0, -0.0, 0.0, 0) # Test that boost with v=c will not work assert False == evt.boost(bwrong2) bwrong3 = hm.FourVector(sys.float_info.epsilon * 0.9, 0.0, 0.0, 0) # Test that boost with v=0 will be OK assert True == evt.boost(bwrong3) rz = hm.FourVector(0.0, 0.0, -0.9, 0) rzinv = hm.FourVector(0.0, 0.0, 0.9, 0) evt.rotate(rz) evt.rotate(rzinv) evt.clear() return 0
def test_HEPEVT(): # Build the graph, which will look like # Please note this is not physically meaningful event. # p7 # # p1 / # # \v1__p3 p5---v4 # # \_v3_/ \ # # / \ p8 # # v2__p4 \ # # / p6 # # p3 # # # define a flow pattern as p1 . p3 . p6 # and p2 . p4 . p5 # # First create the event container, with Signal Process 20, event number 1 # evt = hm.GenEvent(hm.Units.GEV, hm.Units.MM) evt.set_event_number(1) evt.add_attribute("signal_process_id", hm.IntAttribute(20)) v1 = hm.GenVertex() evt.add_vertex(v1) p1 = hm.GenParticle(hm.FourVector(0, 0, 7000, 7000), 2212, 3) evt.add_particle(p1) p1.add_attribute("flow1", hm.IntAttribute(231)) p1.add_attribute("flow1", hm.IntAttribute(231)) p1.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p1.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v1.add_particle_in(p1) v2 = hm.GenVertex() evt.add_vertex(v2) p2 = hm.GenParticle(hm.FourVector(0, 0, -7000, 7000), 2212, 3) evt.add_particle(p2) p2.add_attribute("flow1", hm.IntAttribute(243)) p2.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p2.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v2.add_particle_in(p2) p3 = hm.GenParticle(hm.FourVector(0.751, -1.569, 32.191, 32.238), 1, 3) evt.add_particle(p3) p3.add_attribute("flow1", hm.IntAttribute(231)) p3.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p3.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v1.add_particle_out(p3) p4 = hm.GenParticle(hm.FourVector(-3.047, -19.0, -54.629, 57.920), -2, 3) evt.add_particle(p4) p4.add_attribute("flow1", hm.IntAttribute(243)) p4.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p4.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v2.add_particle_out(p4) v3 = hm.GenVertex() evt.add_vertex(v3) v3.add_particle_in(p3) v3.add_particle_in(p4) p6 = hm.GenParticle(hm.FourVector(-3.813, 0.113, -1.833, 4.233), 22, 1) evt.add_particle(p6) p6.add_attribute("flow1", hm.IntAttribute(231)) p6.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p6.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v3.add_particle_out(p6) p5 = hm.GenParticle(hm.FourVector(1.517, -20.68, -20.605, 85.925), -24, 3) evt.add_particle(p5) p5.add_attribute("flow1", hm.IntAttribute(243)) p5.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p5.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v3.add_particle_out(p5) # create v4 v4 = hm.GenVertex(hm.FourVector(0.12, -0.3, 0.05, 0.004)) evt.add_vertex(v4) v4.add_particle_in(p5) p7 = hm.GenParticle(hm.FourVector(-2.445, 28.816, 6.082, 29.552), 1, 1) evt.add_particle(p7) v4.add_particle_out(p7) p8 = hm.GenParticle(hm.FourVector(3.962, -49.498, -26.687, 56.373), -2, 1) evt.add_particle(p8) v4.add_particle_out(p8) evt.add_attribute("signal_process_vertex", hm.IntAttribute(v3.id())) evt.set_beam_particles(p1, p2) # The event is complete, we now print it out hew = hm.HEPEVT_Wrapper_Runtime() hew.set_max_number_entries(200) hew.allocate_internal_storage() hew.GenEvent_to_HEPEVT(evt) hew.print_hepevt() hew.print_hepevt_particle(2) evt.clear() return 0
def test_Polarization(): xout1 = hm.WriterAscii(python_label() + "testPolarization1.dat") xout2 = hm.WriterAscii(python_label() + "testPolarization2.dat") xout4 = hm.WriterAsciiHepMC2(python_label() + "testPolarization4.dat") xout5 = hm.WriterAscii(python_label() + "testPolarization5.dat") # Build the graph, which will look like # Please note this is not physically meaningful event. # p7 # # p1 / # # \v1__p3 p5---v4 # # \_v3_/ \ # # / \ p8 # # v2__p4 \ # # / p6 # # p3 # # # define a flow pattern as p1 . p3 . p6 # and p2 . p4 . p5 # # First create the event container, with Signal Process 20, event number 1 # evt = hm.GenEvent(hm.Units.GEV, hm.Units.MM) evt.set_event_number(1) evt.add_attribute("signal_process_id", hm.IntAttribute(20)) v1 = hm.GenVertex() evt.add_vertex(v1) p1 = hm.GenParticle(hm.FourVector(0, 0, 7000, 7000), 2212, 3) evt.add_particle(p1) p1.add_attribute("flow1", hm.IntAttribute(231)) p1.add_attribute("flow1", hm.IntAttribute(231)) p1.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p1.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v1.add_particle_in(p1) v2 = hm.GenVertex() evt.add_vertex(v2) p2 = hm.GenParticle(hm.FourVector(0, 0, -7000, 7000), 2212, 3) evt.add_particle(p2) p2.add_attribute("flow1", hm.IntAttribute(243)) p2.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p2.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v2.add_particle_in(p2) p3 = hm.GenParticle(hm.FourVector(0.751, -1.569, 32.191, 32.238), 1, 3) evt.add_particle(p3) p3.add_attribute("flow1", hm.IntAttribute(231)) p3.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p3.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v1.add_particle_out(p3) p4 = hm.GenParticle(hm.FourVector(-3.047, -19.0, -54.629, 57.920), -2, 3) evt.add_particle(p4) p4.add_attribute("flow1", hm.IntAttribute(243)) p4.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p4.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v2.add_particle_out(p4) v3 = hm.GenVertex() evt.add_vertex(v3) v3.add_particle_in(p3) v3.add_particle_in(p4) p6 = hm.GenParticle(hm.FourVector(-3.813, 0.113, -1.833, 4.233), 22, 1) evt.add_particle(p6) p6.add_attribute("flow1", hm.IntAttribute(231)) p6.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p6.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v3.add_particle_out(p6) p5 = hm.GenParticle(hm.FourVector(1.517, -20.68, -20.605, 85.925), -24, 3) evt.add_particle(p5) p5.add_attribute("flow1", hm.IntAttribute(243)) p5.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p5.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v3.add_particle_out(p5) # create v4 v4 = hm.GenVertex(hm.FourVector(0.12, -0.3, 0.05, 0.004)) evt.add_vertex(v4) v4.add_particle_in(p5) p7 = hm.GenParticle(hm.FourVector(-2.445, 28.816, 6.082, 29.552), 1, 1) evt.add_particle(p7) v4.add_particle_out(p7) p8 = hm.GenParticle(hm.FourVector(3.962, -49.498, -26.687, 56.373), -2, 1) evt.add_particle(p8) v4.add_particle_out(p8) evt.add_attribute("signal_process_vertex", hm.IntAttribute(v3.id())) evt.set_beam_particles(p1,p2) # The event is complete, we now print it out hm.Print.content(evt) hm.Print.listing(evt, 8) print(hm.version()) print(hm.Print.line(v4, True)) a = 0 print(evt.particles()) print(len(evt.particles())) print(evt.particles()[0]) for ip in evt.particles(): print(hm.Print.line(ip, True)) xout1.write_event(evt) # write event in old format xout4.write_event(evt) # make a copy and write it xout5.write_event(hm.GenEvent(evt)) # try changing polarization p2.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p2.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi)) xout2.write_event(evt) xout1.close() xout2.close() xout4.close() xout5.close() # now clean-up by deleteing all objects from memory # # deleting the event deletes all contained vertices, and all particles # contained in those vertices evt.clear() assert ( COMPARE_ASCII_FILES(python_label() + "testPolarization1.dat", python_label() + "testPolarization5.dat") == 0 ) and (COMPARE_ASCII_FILES(python_label() + "testPolarization1.dat", python_label() + "testPolarization2.dat") != 0) inputA1 = hm.ReaderAscii(python_label() + "testPolarization1.dat") if inputA1.failed(): return 1 while not inputA1.failed(): evt = hm.GenEvent() inputA1.read_event(evt) if inputA1.failed(): print("End of file reached. Exit.\n") break evt.clear() inputA1.close() inputA2 = hm.ReaderAscii(python_label() + "testPolarization2.dat") if inputA2.failed(): return 2 while not inputA2.failed(): evt = hm.GenEvent() inputA2.read_event(evt) if inputA2.failed(): print("End of file reached. Exit.\n") break evt.clear() inputA2.close() inputA4 = hm.ReaderAsciiHepMC2(python_label() + "testPolarization4.dat") if inputA4.failed(): return 4 while not inputA4.failed(): evt = hm.GenEvent() inputA4.read_event(evt) if inputA4.failed(): print("End of file reached. Exit.\n") break evt.clear() inputA4.close() inputA5 = hm.ReaderAscii(python_label() + "testPolarization5.dat") if inputA5.failed(): return 4 while not inputA5.failed(): evt = hm.GenEvent() inputA5.read_event(evt) if inputA5.failed(): print("End of file reached. Exit.\n") break evt.clear() inputA5.close() return 0
def test_Print(): evt = hm.GenEvent(hm.Units.MomentumUnit.GEV, hm.Units.LengthUnit.CM) evt.set_event_number(1) evt.add_attribute("signal_process_id", hm.IntAttribute(20)) # create vertex 1 v1 = hm.GenVertex() evt.add_vertex(v1) p1 = hm.GenParticle(hm.FourVector(1.0, 1.0, 7000, 7000), 2212, 3) evt.add_particle(p1) p1.add_attribute("flow1", hm.IntAttribute(231)) p1.add_attribute("flow1", hm.IntAttribute(231)) p1.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p1.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v2 = hm.GenVertex() evt.add_vertex(v2) p2 = hm.GenParticle(hm.FourVector(1.0, 1.0, -7000, 7000), 2212, 3) evt.add_particle(p2) p2.add_attribute("flow1", hm.IntAttribute(243)) p2.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p2.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v2.add_particle_in(p2) # # create the outgoing particles of v1 and v2 p3 = hm.GenParticle(hm.FourVector(0.750, -1.569, 32.191, 32.238), 1, 3) evt.add_particle(p3) p3.add_attribute("flow1", hm.IntAttribute(231)) p3.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p3.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v1.add_particle_out(p3) p4 = hm.GenParticle(hm.FourVector(-3.047, -19.0, -54.629, 57.920), -2, 3) evt.add_particle(p4) p4.add_attribute("flow1", hm.IntAttribute(243)) p4.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p4.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v2.add_particle_out(p4) # # create v3 v3 = hm.GenVertex() evt.add_vertex(v3) v3.add_particle_in(p3) v3.add_particle_in(p4) p6 = hm.GenParticle(hm.FourVector(-3.813, 0.113, -1.833, 4.233), 22, 1) evt.add_particle(p6) p6.add_attribute("flow1", hm.IntAttribute(231)) p6.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p6.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v3.add_particle_out(p6) p5 = hm.GenParticle(hm.FourVector(1.517, -20.68, -20.605, 85.925), -24, 3) evt.add_particle(p5) p5.add_attribute("flow1", hm.IntAttribute(243)) p5.add_attribute("theta", hm.DoubleAttribute(random.random() * math.pi)) p5.add_attribute("phi", hm.DoubleAttribute(random.random() * math.pi * 2)) v3.add_particle_out(p5) # # create v4 v4 = hm.GenVertex(hm.FourVector(0.12, -0.3, 0.05, 0.004)) evt.add_vertex(v4) v4.add_particle_in(p5) p7 = hm.GenParticle(hm.FourVector(-2.445, 28.816, 6.082, 29.552), 1, 1) evt.add_particle(p7) v4.add_particle_out(p7) p8 = hm.GenParticle(hm.FourVector(3.962, -49.498, -26.687, 56.373), -2, 1) evt.add_particle(p8) v4.add_particle_out(p8) # # tell the event which vertex is the signal process vertex evt.add_attribute("signal_process_vertex", hm.IntAttribute(v3.id())) print(dir(hm)) print(hm.Print.content(evt)) # we now print it out in old format print(hm.Print.listing(evt, 8)) # print each particle so we can see the polarization for ip in evt.particles(): print(hm.Print.line(ip, True)) xout1 = hm.WriterAscii(python_label() + "testBoost1.out") xout1.set_precision(6) xout1.write_event(evt) xout1.close() # different outputs ff = io.StringIO() hm.Print.listing(ff, evt) print(ff.getvalue()) # different outputs for ip in evt.particles(): print(hm.Print.line(ip, True)) for ip in evt.particles(): print(hm.Print.line(ip, True)) xout2 = hm.WriterAscii(python_label() + "testBoost2.out") xout2.set_precision(6) xout2.write_event(evt) xout2.close() assert COMPARE_ASCII_FILES(python_label() + "testBoost1.out", python_label() + "testBoost2.out") == 0 evt.clear() return 0