Output from the vertex shader in OpenGL after perspective divide is clipped to [-1,1], that means gl_Position.z/gl_Position.w has to be in that range. However, the depth value that is actually stored in the depth buffer gets remapped to the 0..1 range using the current depth range (glDepthRange) values. By default the depth range is 0..1, which translates to
depth_buf_value = 0.5 + 0.5 * gl_Position.z / gl_Position.w;
So in your case the depth buffer ultimately contains values of float(gl_VertexID) / ParticleCount, and thus:
vertex_id = depth_buf_value * ParticleCount