Please: What does the "forecast" command actually

I am sure someone knows the answer to this…

Dear all,
I was wondering whether there is documentation on what the “forecast” command actually does. I know that it puts deterministic, i.e. foreseen shocks into an otherwise stochastic model to see how the economy reacts (Tommasos user guide page 27.) However, I would like to know the following:
-How is the deterministic shock incorporated into the policy functions? For instance, if I have a deterministic shock lasting from period 1 to 5, are the approximations to the policy functions calculated again with the presence of a deterministic shock? How is that done?
-The forecast is referred to as mean. Is this then really the conditional expectation of the respective variable given that the deterministic shock has hit the economy in periods 1 to 5?
-How is the forecast mean calculated in case of a second order approximation to the policy function? How are the expectations of the second order terms dealt with? Are those calculated using a first order approximation to the policy functions?
-If we shock the economy in period 1 to 5 let us say and choose a forecast period of 5000, will the forecast mean at some point equal the unconditional expectation of the variable?

Thank you so much for your help!!!
Best,
Ansgar