We use the past perfect to talk about an activity or event that was completed before another activity or event in the past.
-Reiko had forgotten to lock the door before she left the house.
-The criminal had already escaped by the time the police arrived.
+We use the past perfect progressive when the activity was in progress at the time another activity or event happened in the past.
-Juan had been getting cash from the ATM when he was mugged.
-The driver had been swerving between lanes when the police officer stopped him.