LHR T4 has an arrivals lounge and offers an excellent cooked breakfast (better than available on board in J or even F), so one strategy is to sleep through breakfast and eat on the ground (not so important on your itinerary). In MAD the airport is a zoo, but IB has some reasonably nice lounges (not sure which you will be able to access, the airport segregates international and european flights ... of course the nice louge is for non-european). I've never flown BA from there, so I don't know if BA has a lounge but doubt it. In TXL I think it is a contracted lounge (ok but very basic, not like a Terraces lounge). On your trip back you can use the MB spa (the T4 arrivals lounge also offers an MB massage which is worth seeking out if you have the time, but tends to be booked up with earlier arriving flights).