Police have a new ally in the hunt for drug dealers: scientists who probe the sewer system for traces of illicit substances that can give clues to where and how much is being consumed.

These drugs pass from dealer to user to toilet. By checking for metabolites of these drugs, heroin changes to morphine in urine, for example, researchers get a big picture of who is using what.

In the medium-sized town of Lausanne, Switzerland, Frederic Been, a toxicologist, collaborated with police to analyze wastewater before it entered the town's treatment plant. The cops had been following two heroin dealers, and thought they had the city's problem solved by arresting the pair, but it turns out that other dealers were picking up the slack.

RELATED: New Technique Can Date a Fingerprint

"Wastewater is an objective way of measuring drug use," said Been, now a postdoctoral researcher at the University of Antwerp in the Netherlands. Been published a study this month in the journal Forensic Science International with the results of his research.

By sampling water for heroin, cocaine and methamphetamine, Been and colleagues were able to help police assess the drug market share, decipher the structure of the drug markets, as well as the local organization of traffickers.

Based on seizures and arrests of dealers, the Lausanne police believed that dealers were selling 6 grams of pure heroin a day. In Switzerland, heroin is 10 percent pure. The amount sold was closer to 60 grams of "street" drug. .

WATCH VIDEO: Why Heroin Abuse Is On The Rise In America

But the wastewater analysis showed that approximately 12 or 13 grams of pure heroin was being consumed per day, explained Been.

"It tells you that the market was flexible enough that the drug consumers had other ways to find it," he said.

The wastewater analysis helped reveal that dealers were coming in from other neighboring towns to fill the void.

RELATED: 'Edible Barcodes' Help Fight Counterfeit Drugs

"For these three cites, there was an exchange going on," he said. "It was also interesting for the police that even if they got this guy, there is still a lot of drugs on the market."

This isn't the first time that wastewater analysis has focused on drugs. In 2013, researchers in Washington state documented the use of Ritalin and other drugs for attention-deficit hyperactivity disorder (ADHD) around exams.

Many students say the prescription medication helps them focus on their studies and the researchers found the use of both Ritalin and amphetamines jumped seven-fold around finals week.

Been says the wastewater analysis can also be used in bigger cities to get an idea of trends over time, and which areas are seeing spikes or drops in drug use. Now he wants to track other biological markers that help understand the health of a population, rather than their drug use, such as the use of tobacco or alcohol, for example or prescription medications for medical conditions.

"It's a very cost-effective tool," he said.

SEE PHOTOS: 9 Incredibly Creative Drug Smuggling Tricks