Package: graphicle
graphicleUtilities for representing high energy physics data as graphs /
networks.InstallationpipinstallgraphicleFeaturesObject oriented interface to track-level particle data for collider
physics, with routines for constructing and performing calculations over
graph-structured data.Provides data structures for:4-momentaPDG codesParticle status codesColor codesHelicity / spin polarisation dataCOO adjacency lists (for graph-structured data)>>>importgraphicleasgcl# query pdg records>>>pdgs=gcl.PdgArray([1,3,6,-6,25,2212])>>>pdgs.name['d','s','t','t~','H0','p'],dtype=object)>>>pdgs.chargearray([-0.33333333,-0.33333333,0.66666667,-0.66666667,0.,1.])# extract information from momentum data>>>pmu_dataarray([(1.95057378e-02,3.12923088e-02,3.53556064e-01,3.55473730e-01),(2.60116947e+01,-3.63466398e+00,-3.33718718e+00,2.64755711e+01),(5.91884324e-05,-7.62144267e-06,-6.76385314e-06,6.00591927e-05),(2.82881807e+01,4.32224823e+00,2.14691072e+02,2.16589841e+02),(-8.73280642e-02,-6.48540201e-02,3.73744945e-01,6.28679140e-01),(1.06204871e-01,5.78888984e-01,-1.44899819e+02,1.44901081e+02)],dtype=[('x','<f8'),('y','<f8'),('z','<f8'),('e','<f8')])>>>pmu=gcl.MomentumArray(pmu_data)...pmuMomentumArray([[1.95057378e-023.12923088e-023.53556064e-013.55473730e-01][2.60116947e+01-3.63466398e+00-3.33718718e+002.64755711e+01][5.91884324e-05-7.62144267e-06-6.76385314e-066.00591927e-05][2.82881807e+014.32224823e+002.14691072e+022.16589841e+02][-8.73280642e-02-6.48540201e-023.73744945e-016.28679140e-01][1.06204871e-015.78888984e-01-1.44899819e+021.44901081e+02]],dtype=[('x','<f8'),('y','<f8'),('z','<f8'),('e','<f8')])>>>pmu.ptarray([3.68738715e-02,2.62644064e+01,5.96771055e-05,2.86164812e+01,1.08776076e-01,5.88550704e-01])>>>pmu.massarray([-7.45058060e-09,5.11000489e-04,9.09494702e-13,5.10991478e-04,4.93680000e-01,1.39570000e-01])>>>pmu.etaarray([2.95639434,-0.12672178,-0.11309956,2.71277683,1.94796328,-6.1992861])>>>pmu.phiarray([1.01339184,-0.138833,-0.12806107,0.15162078,-2.5028134,1.38935084])# calculate the inter-particle distances>>>pmu.delta_R(pmu)array([[0.,3.2913868,3.27485993,0.89554388,2.94501476,9.16339617],[3.2913868,0.,0.01736661,2.85431528,3.14526968,6.26189934],[3.27485993,0.01736661,0.,2.83968296,3.14442819,6.27249595],[0.89554388,2.85431528,2.83968296,0.,2.76241933,8.99760198],[2.94501476,3.14526968,3.14442819,2.76241933,0.,8.4908571],[9.16339617,6.26189934,6.27249595,8.99760198,8.4908571,0.]])Graphicle really shines with its composite data structures. These can be
used to filter and query heterogeneous particle data records
simultaneously, either using user provided boolean masks, orMaskArrayinstances produced with routines in theselectmodule.
Additionally, routines in thecalculateandtransformmodules
take composite data structures to standardise useful calculations which
blends multiple particle data records.To see an example, let’s generate a collision event using Pythia,
wrapped withshowerpipe.>>>fromshowerpipe.generatorimportPythiaGenerator......lhe_path="https://zenodo.org/record/6034610/files/unweighted_events.lhe.gz"...gen=PythiaGenerator("pythia-settings.cmnd",lhe_path,1)>>>foreventingen:...graph=gcl.Graphicle.from_event(event)...break>>>print(graph)namepxpypzenergycoloranticolorhelicitystatusfinalsrcdstp0.00E+000.00E+006.50E+036.50E+03009-12False0-1p0.00E+000.00E+00-6.50E+036.50E+03009-12False0-2g0.00E+000.00E+002.99E+022.99E+025035021-21False-6-3g-0.00E+00-0.00E+00-5.99E+025.99E+025015031-21False-7-3t2.34E+02-2.20E+01-4.76E+025.58E+0250100-22False-3-4....................................gamma1.30E-02-1.30E+00-3.24E+003.49E+0000991True-969979gamma1.70E-01-8.21E-01-2.32E+002.47E+0000991True-970980gamma3.12E-01-2.26E+00-6.82E+007.19E+0000991True-970981gamma9.38E-03-3.58E-01-7.98E-018.75E-0100991True-971982gamma3.08E-02-4.36E-02-4.56E-027.02E-0200991True-971983[1065particles×12attributes]>>>graph.pdgPdgArray([2212221221...222222],dtype=int32)>>>graph.adjAdjacencyList([[0-1][0-2][-6-3]...[-970981][-971982][-971983]],dtype=[('src','<i4'),('dst','<i4')])# select all descendants of the W bosons from the hard process>>>W_mask=gcl.select.hard_descendants(graph,{24})>>>W_maskMaskGroup(mask_arrays=["W+","W-"],agg_op=OR)# filter data record to get final state W+ boson descendants>>>Wp_desc=graph[W_mask["W+"]&graph.final]>>>print(Wp_desc)namepxpypzenergycoloranticolorhelicitystatusfinalsrcdstgamma2.46E-05-5.65E-06-1.54E-052.95E-0500951True-350353nu(tau)1.72E+023.52E+01-3.18E+023.63E+0200952True-351354nu(tau)~1.73E+01-4.48E+00-1.08E+012.09E+0100991True-352687pi+1.19E+01-3.15E+00-7.51E+001.44E+0100991True-352690gamma4.12E+00-1.09E+00-2.19E+004.79E+0000991True-688879gamma1.54E+00-4.72E-01-8.87E-011.84E+0000991True-688880gamma2.11E+00-4.94E-01-9.96E-012.38E+0000991True-689881gamma3.22E+00-7.42E-01-1.71E+003.72E+0000991True-689882[8particles×12attributes]# numpy can interface with graphicle - let's sum the momenta>>>Wp_sum=np.sum(Wp_desc.pmu,axis=0)>>>Wp_sum.mass80.419002446More information on the API is available in thedocumentation