I used to often read detective novels before bed.

Literal

I [topic-は] sleep before [at-に] detective-novels [object-を] often read [nostalgic-past-ものだった].

~ものだった is the past form of ~ものだ, expressing nostalgic recollection of habitual past actions. It carries a nuance of fond reminiscence beyond simple past tense. 探偵小説 ('detective novels') — 探偵 ('detective') + 小説 ('novel'). 寝る前に ('before sleeping') — 前 with に marks a temporal boundary.