ABSTRACT We study the relation between halo mass and its environment from a probabilisticperspective. We nd that halo mass depends not only on local dark matter density,but also on non-local quantities such as the cosmic web environment and the halo-exclusion e ect. Given these accurate relations, we have developed the hadron-code(Halo mAss Distribution ReconstructiON), a technique which permits us to assignhalo masses to a distribution of haloes in three-dimensional space. This can be ap-plied to the fast production of mock galaxy catalogues, by assigning halo masses,and reproducing accurately the bias for di erent mass cuts. The resulting clusteringof the halo populations agree well with that drawn from the BigMultiDark N-bodysimulation: the power spectra are within 1-˙up to scales of k= 0:2hMpc 1 , whenusing augmented Lagrangian perturbation theory based mock catalogues. Only themost massive haloes show a larger deviation. For these, we nd evidence of the halo-exclusion e ect. A clear improvement is achieved when assigning the highest massesto haloes with a minimum distance separation. We also compute the 2- and 3-pointcorrelation functions, and nd an excellent agreement with N-body results. Our workrepresents a quantitative application of the cosmic web classi cation. It can have fur-ther interesting applications in the multi-tracer analysis of the large-scale structurefor future galaxy surveys.Key words: (cosmology:) large-scale structure of Universe { galaxies: clusters: gen-eral { catalogues { galaxies: statistics