Find a local gun range that has rentals available and shoot each, both in 9mm and 40 caliber. Then chose the gun that you shoot best with. I went through a month long process of test shooting a variety of pistols and chose the XDm because I shot best with the XD40. Which seems a bit odd because the Smith & Wesson M&P felt best in my hand but for some reason that didn't translate to the range. Most likely it was a trigger position issue, the trigger placement on the XD probably fits my hand better than on the M&P. When I compared the 2 side by side, my groups were 1/2 to 1 inch tigher with the XD.
Now, I did take a chance on getting the XDm instead of the XD40. Unfortunately, my local range didn't have any XDm's available for rental. However, with the standard backstrap the XDm is supposed to match the grip of the XD40 so it wasn't that great a risk. What I can say is that now that I have run 300 rounds through the XDm, I am shooting better and better. I finished up last Saturday by putting 13 out of 15 rounds into a 3 inch circle at 40 feet with only 2 flyers. Which aint bad for someone who hadn't shot a handgun in nearly 35 years.
As for why I chose the handgun that I shot best with, it's pretty simple. What it means is that the ergonomics of the gun fit your natural grip. So it will point better and permit you to shoot without having to adapt your body to a gun that doesn't fit well. This also means that in a defensive shooting situation you'll be more likely to hit your target well without having to take the time to use the sights.
BTW, guns that I tried out were as follows. First was a Glock 19, did not shoot at all well with it. Second was a Walther P99, shot well with it in singla action but the trigger pull in DA was so heavy that I couldn't hit an 8 inch target repeatedly at 20 feet. Since the first round after a magazine change is always DA on the P99 I passed on it. Third up was an XD9, which I shot very well with. Fourth up was a Smith & Wesson M&P in 40 caliber, which I shot OK with but the grouping wasn't as tight as the XD9. Next up was my CPL class and range certification, where I shot with a rented XD40 and shot very well with. The next weekend after that I did a side by side test of the XD40 against the S & W M&P 40, where the XD was obviously better in my hands.
PS, I really didn't notice much difference in recoil between the 9mm and the 40 caliber. There is a slight cost difference but with range ammo from wallyworld the difference is slight enough that brown bagging lunch 1 day a week will make up for that difference. I like the extra stopping power of the 40, If SA was offering the XDm in 45 ACP that would have been my first choice. Maybe someday when they do offer one, I'll get one in Bi-tone.