BERKELEY — An Ocean County father whose neglect of his children led to the accidental drowning of his 2-year-old daughter is on his way to being a free man.

Robert S. Trella, 42, was sentenced Friday to three years in prison. But he has already served much of that time in Ocean County jail, where he has been locked up since his arrest in January 2016.

The sentence was the result of a deal in which he agreed to plead guilty to second-degree endangering the welfare of a child. Officials dropped drug charges against Trella was facing after police said they found marijuana, Suboxone and heroin in the family's home.

Police found the body of Maddigan Grace McCarthy on Aug. 17, 2015, floating in a neighbor's pool. Police were called to the neighborhood after people saw the girl's 9-year-old sister running through the street trying to find her sibling.

Authorities said the girls' parents were so drug-addled and irresponsible that the 9-year-old girl had assumed much of the care-taking responsibilities of the toddler. Neighbors said the little girl had been seen wandering the neighborhood before.

The mother, Brigitte M. McCarthy, also was arrested and later pleaded guilty to drug and child abuse charges. The Asbury Park Press reported that McCarthy was sentenced to Drug Court probation.