A series of connected thoughts can be called a train of thought. If your dog start barking wildly while you're trying to write a complicated essay, you might lose your train of thought.
You can also use terms like "chain of thought" or "line of reasoning." Your train of thought can be as complicated as the series of ideas that lead to a specific conclusion, or as simple as the successive thoughts that happen to flit through your head. The first recorded use of train of thought was in 1651, in "Leviathan" by Thomas Hobbes, from the sense of train meaning "series or progression."