pull detId push_back out of if statement