I've also got a pet theory about not being able to get it up - I think a lot of it comes down to expectation.
Eg most of the time you get hard by the EXPECTATION of sex - ie thinking about it when you CAN'T have it. It's like anything else - the smell of coffee can be tantalisingly wonderful but when you finally get a cup you think...well...it's just coffee really.
Same with sex. If you don't have it often, you build up all sorts of frenzied expectations about how brilliant it will be, but this is all in your head. When you've finally got a woman waiting underneath you, the 'conquest' is over and it becomes difficult to 'connect' with the reality of the situation. It can almost be a disappointment.
This is why you need to refocus on the great sensations you are getting - how she looks, smells, feels, tastes, and how she's making you feel.
I also have problems peeing in a public lavatory when other men are standing near me. The more I worry the worse it gets. But if I just relax, forget about the surroundings and concentrate on how good the relief will feel. It's the same with sex I think. When you start worrying about getting it up, it's time to forget about it and just enjoy the sensations you are getting.