Is there any unsaved data in any of the background Apps?
If there is you could try connecting an external keyboard via USB and holding the key combination:
command-option-escape.
If Force Quit Applications shows up, plug an external mouse, and select each application to force quit until everything is restored.
If not, hold down the power button until the screen goes blank.
Unplug the power.
Hold down the power button 30 seconds.
Plug back in the computer.
Tap the power button.
Your computer will restart normally and hopefully give you access to everything.
Temporary files may be in the trash from your last saved session. If not and you lost data, bring in for a data recovery. This may or may not be successful.
One lesson is that Energy Saver should never allow hard drives to be put to sleep when possible, unless you are not running anything. Also never allow Energy Saver to turn on when you have peripherals attached, as that brings also the keyboard and touchpad into low power mode which could cause them to go unresponsive.
Closing the lid of the computer usually activates Energy Saver, and so does inactivity based on your system settings/preferences.
Change Energy Saver settings on a Mac desktop computer - Apple Support