Fires raged, chemicals leaked, smoke climbed to the sky and the possibility of an explosion was a constant worry.
And amid it all, in the middle of a century-old tunnel where temperatures were approaching 1,500 degrees, an investigation had to begin.
It started with a call to the National Transportation Safety Board in Washington about 5 p.m. July 18. Officials there must quickly try to assess the seriousness of an accident and whether it's likely to become a high-profile event. When they heard a 60-car freight train loaded with hazardous chemicals derailed beneath Baltimore, NTSB officials knew they'd be counted on to determine how it happened.
To do that, agency investigators hit the road immediately, moving to examine the tracks and signals. They also needed to check the site for clues, equipment for defects and paperwork for problems.
In short, they began a task certain to be long and arduous.
"We begin our work as soon as we receive the call, right away," said Keith Holloway, a spokesman for the NTSB. "The investigations can take a long time, but it's extremely important that we get there as soon as we can."
The agency's primary goal since its inception in 1967 has been to investigate accidents in an effort to reduce their number.
But in addition to making suggestions to improve safety, the agency's conclusions often have enormous financial repercussions. Its determination of what caused the derailment and fire that shut down half of Baltimore's main business district could help determine who is responsible for paying millions of dollars in damage.
When the first investigator arrived outside the tunnel, just hours after the derailment, it was apparent one of the team's goals would be tough to achieve.
"First thing they want to do is secure the area," said Wyman Jones, a rail safety expert at the federal Transportation Safety Institute.
"Police and fire have already contaminated it, but they want to contain the evidence as best they can."
As it turned out, the investigators couldn't get inside until Sunday, July 22, nearly four days after the wreck. Which is not to say they had nothing to do until then.
As charred and smoldering freight cars were being pulled from the tunnel, the investigators examined them from top to bottom, paying especially close attention to the steel wheels.
"They're trying to determine what was the first wheel to derail, then where it derailed," said Jones, who has instructed NTSB workers on train investigations. "That is very, very important, and you usually find that in the wheels and tracks."
The wheels and tracks are inspected for deep scrapes and gouges, signs of trouble. Those that have unusual markings are taken to an NTSB laboratory for testing where scientists can tell whether a piece of rail or wheel has been weakened to the point at which it could cause an accident.
In most cases they can determine with confidence whether a piece of equipment was damaged by an accident or before it.
The NTSB has enjoyed a solid reputation, in no small part because the pictures of its work are nothing short of amazing. Americans have become accustomed to seeing news video and newspaper pictures of airplanes, exploded or crashed into literally thousands of pieces, reconstructed in airline hangars as investigators try to determine what went wrong.
In railroad accidents, such extensive reconstructions are not necessary, though investigators sometimes will try to re-create the path of a freight car's "truck" - the wheel assembly - on a stretch of railroad track.
By doing so, Jones said, they can match patterns of damage on wheels and track.
Robyn Cicero, a safety expert with iJET Travel in Annapolis, a consulting firm, said the structural damage will be only one part of the investigation.
"They look at virtually everything, especially in a case like this," she said. "In something this catastrophic it never seems to be one particular cause. It's usually a series of things that went wrong."
Reviewing the data
Trains carry less sophisticated versions of the "black box" that is the focus of so many aviation accidents. Investigators will scrutinize the data from that, determining the train's speed and, with the help of mathematical equations, they can determine the portion of track where something went wrong.
Most locomotives now have a high-tech feature called touch panels. If the engineer fails to touch a piece of driving equipment in a given period of time - often 30 seconds to one minute - an alarm sounds. If he doesn't respond, the train brakes automatically.
"The industry as a whole is a lot more advanced as far as technology goes than people realize," said Aaron G. Gellman, a former director of the Transportation Center at Northwestern University. "In some areas it's extremely sophisticated."
The communication systems between train crews and dispatchers are a good example. When the CSX train derailed, the crew first called company dispatchers at a headquarters in Jacksonville, Fla.