I don't know if this helps, but when I have time to daydream I often intentionally run through awful situations in my mind, embracing as much anxiety as possible (it's a curse) and imagining a good response. I find that this helps me when things actually happen.
I've had tangible results with this: One scenario I used to run through often is what I would do if the brakes on my car failed. One day, while driving through NYC, my rear brakeline popped in dense high speed traffic. As I mentally practiced, I downshifted, hit the hazard lights, and used the parking brake, no issues, no panic.
Catching myself on a scaffolding collapse was another tangible success; this technique has help me developed a habit of always having response plan when in physically dangerous situations. So, for example, when I climb on things I make a mental note of the nearest stable thing I can grab, and the second nearest thing if that fails.
Experience is even better, of course (for example, a paramedic I know has seen so many rough situations that if he finds himself in any, he naturally remains calm and knows what to do -- he understands the difference between real dangers and panic, and remaining calm is second nature to him), but the technique I just described is meant to help me in new situations that I have never been in before. I've also found that it helps me think coolly in situations that I haven't mentally run through in the past, as a side-effect that I cannot explain. In fact, you asking that question here is a form of you doing this. I have asked similar types of questionssimilar types of questions in the past for this reason.
I think in situations like this, the root of panic is the fundamental sense of not knowing/understanding what's going to happen. I find that minimizing some of the unknowns ahead of time helps to naturally reduce the panic.