when I had finished my swimming, I realized my sister had gone
("now" in the past) "I realized" (simple past tense for a completed action)
("past" relative to "now" in the past) "my sister had gone" (past perfect for a completed action "earlier" than a time or completed action in the past)
I realized (now in the past) that my sister had gone (before now in the past)
I had finished my swimming (past perfect for a completed action "earlier" than a time or completed action)
When (when = the time shortly after swimming)
When (now in the past, slightly after swimming) I had finished my swimming (before now in the past)