Mac is freezing. How to find the problem? I have Macbook Pro Retina (Late 2013) with installed El capitan.

Sometimes OSX just freezing and I can do nothing, but to reboot (by holding power button for a few seconds). All apps are continue running, for example media player or torrent client. But keyboard or trackpad doesn't respond.

I read lots of manuals, I tried reset different settings, clear user's cache. I even tried reinstall OSX (without formatting the drive). It's not helping.

I don't have much experience with OSX, so I don't know where to look for a problem. Any thoughts what should I do?
Try using Apple Diagnostics to check for hardware issues:
Restart your computer, then hold down the D key while the Mac restarts.

Check Apple knowledge base on this subject - https://support.apple.com/kb/PH21879

If you get an error-code, check this page for how to follow it up:
https://support.apple.com/en-us/HT203747