Near-Earth solar wind flows and geomagnetic activity over more than four solar cycles (1963-2011)