We investigate the alignment of the spin of dark matter haloes relative (i) to the surrounding large-scale filamentary structure, and (ii) to the tidal tensor eigenvectors using the Horizon 4π dark matter simulation which resolves over 43 million dark matter haloes at redshift zero. We detect a clear mass transition: the spin of dark matter haloes above a critical mass tends to be perpendicular to the closest large-scale filament (with an excess probability of up to 12 per cent), and aligned with the intermediate axis of the tidal tensor (with an excess probability of up to 40 per cent), whereas the spin of low-mass haloes is more likely to be aligned with the closest filament (with an excess probability of up to 15 per cent). Furthermore, this critical mass is redshift-dependent, scaling as with γs = 2.5 ± 0.2. A similar fit for the redshift evolution of the tidal tensor transition mass yields and γt = 3 ± 0.3. This critical mass also varies weakly with the scale defining filaments.
We propose an interpretation of this signal in terms of large-scale cosmic flows. In this picture, most low-mass haloes are formed through the winding of flows embedded in misaligned walls; hence, they acquire a spin parallel to the axis of the resulting filaments forming at the intersection of these walls. On the other hand, more massive haloes are typically the products of later mergers along such filaments, and thus they acquire a spin perpendicular to this direction when their orbital angular momentum is converted into spin. We show that this scenario is consistent with both measured excess probabilities of alignment with respect to the eigendirections of the tidal tensor, and halo merger histories. On a more qualitative level, it also seems compatible with 3D visualization of the structure of the cosmic web as traced by ‘smoothed’ dark matter simulations or gas tracer particles. Finally, it provides extra support to the disc-forming paradigm presented by Pichon et al. as it extends it by characterizing the geometry of secondary infall at high redshift.