Ryan's Daughter

The beach between Slea Head and Dunmore Head on the Dingle Peninsula, Ireland, a location where scenes for Ryan's Daughter were filmed.
The daughter of the local publican, Tom Ryan (Leo McKern), Rosy Ryan (Sarah Miles) is bored with life in Kirrary, an isolated village on the Dingle Peninsula in County Kerry, Ireland. She falls in love with the local schoolmaster, Charles Shaughnessy (Robert Mitchum). She imagines, though he tries to convince her otherwise, that he will somehow add excitement to her life. The villagers are nationalists, taunting British soldiers from a nearby army base. Mr. Ryan publicly supports the recently suppressed Easter Rising, but secretly serves the British as an informer. Major Randolph Doryan (Christopher Jones) arrives to take command of the base. A veteran of World War I, he has been awarded a Victoria Cross, but has a crippled leg and suffers from shell shock.
Rosy is instantly and passionately attracted to Doryan, who suffers from intermittent flashbacks to the trenches of the First World War, also known as the Great War. He collapses. When he recovers, he is comforted by Rosy. The two passionately kiss until they are interrupted by the arrival of Ryan and the townspeople. The next day, the two meet in the forest for a passionate liaison. Charles becomes suspicious of Rosy, but keeps his thoughts to himself.
There is an intermission and an entracte.
Charles takes his students to the beach, where he notices Doryan's telltale footprints accompanied by a woman's in the sand. He tracks the prints to a cave and imagines Doryan and Rosy conducting an affair. Local halfwit Michael (John Mills) notices the footprints as well and searches the cave. He finds Doryan's Victoria Cross, which he pins on his own lapel. He proudly parades through town with the medal on his chest, but suffers abuse from the villagers. When Rosy comes riding through town, Michael approaches her tenderly. Between Rosy's feelings of guilt and Michael's pantomime, the villagers surmise that she is having an affair with Doryan.
One night, during a fierce storm, IRB leader Tim O'Leary (Barry Foster) â who had killed a police constable earlier â and a small band of his men arrive in Ryan's pub seeking help to recover a shipment of German arms smuggled by boat from the storm. When they leave, Ryan tips off the British. The entire town turns out to help the rebels. Ryan is the most outwardly devoted to the task, wading into the breakers to repeatedly salvage boxes of bullets and dynamite. O'Leary is overwhelmed by Ryan's devotion, and the town is ebullient. They gleefully free the rebels' truck from the wet sand, and follow it up the hill where Doryan and his troops lie in wait. O'Leary runs for his life. Doryan climbs atop the truck and wounds O'Leary with a rifle, but then he suffers a flashback and collapses. Rosy presses through the crowd in concern, outraging the villagers.
Charles tells Rosy that he had let her affair run its course, hoping that the infatuation would pass. He tells her that he will arrange for an amicable divorce. Rosy tells him the affair is over, but that night she returns to Doryan. In dismay, Charles wanders in his nightclothes to the beach, where local priest Father Collins (Trevor Howard) finds him. The villagers storm into the Shaughnessys' quarters at the schoolhouse and demand Rosy. They are convinced that she informed the British of the arms shipment. Ryan watches in shame and horror as his daughter takes the blame for his actions. The mob shears off her hair and strips off her clothes.
Doryan walks along the beach and gives his cigarette case to Michael. In gratitude, Michael leads Doryan to a cache of armsâ-including dynamiteâ-that was not recovered. After Michael runs off, Doryan commits suicide by detonating the explosives. The next day, Rosy and Charles leave for Dublin, enduring the taunts of the villagers as they go.

Question: Who tracks He tracks the prints to a cave and imagines Doryan and Rosy conducting an affair?
Answer: Charles