The past perfect is used to refer to an event or situation which took place before another past event.
Tom had interviewed five times before he got his first job.
She had already eaten by the time they arrived.
Past Perfect Continuous:
The past perfect continuous is used to express how long something had been going on before something important happened in the past.
Jane had been studying for four hours when he came home.
Jack had been driving four over six hours when he finally pulled over to have lunch.
Note: You cannot use non-action verbs in past perfect progressive tense.