# Documentation for the density mode of MadGraph Work In Progress = Density mode == Authors V. Durupt == Short description Automatic computation of density matrices and quantum information observables. This page contains the technical description of the Python library Density_functions.py used for analysis. == How to compute density matrices This module of MadGraph5 allows to compute density matrices automatically in a user-friendly way. After having generated your process {{{ generate YOUR_PROCESS output launch }}} you will be able to chose the type of run. To compute density matrices one must chose {{{ reweight = density }}} The user is then asked to edit the different cards needed for the run. The information for the density matrices computation is given in the reweight_card. Examples for different benchmark processes are given in https://arxiv.org/abs/2510.17730. At the end of the run, the density matrix for each event is written in the Les Houches Event (LHE) file. ==How to read the density matrices in the LHE file The LHE file can be read with the parser lhe_parser.py available in MadGraph. An example of code that would parse the density matrix value for each event is: {{{ import sys sys.path.append('PATH TO MADGRAPH') import madgraph.various.Density_functions as dens import madgraph.various.lhe_parser as lhe_parser lhe_path = os.path.join('PATH TO MADGRAPH', Data_Path) for event in lhe_parser.EventFile(lhe_path): density = event.density square_density = dens.square_matrix(density) }}} With this code, for each event of the file, you read the value `density` which contains the independent coefficients of the density matrix. The utility function `square_matrix` allows to write it in the usual matrix form needed for further analysis.