Saying that, the important thing is also to consider all the parameters:
it's nice if a train would hypothetically "pressure wash" a panel (still, ballast is way dirtier between the tracks than outside, because of lubrication, rust etc...)
but rail is an extremely harsh environment.
- between rails, there is immense vibration at each train, that could destroy your connections between panels. Faulty train wheels happen and induce incredibly big shocks on the rail.
- wildlife will step on it, and crush the nice glass onto the ballast stone. That wildlife includes random drunk people, or hiker following/crossing the tracks.
- People will steal anything valuable on the track level, like good old copper wire between panels, general purpose solar panels, etc...
- ballast is a moving and settling stuff by design, and sharp edges will deform and crush panels from below.
- trains occasionally drop stuff. Bolts, forgotten tools, poop and lubricant, sand, trash, people.... This will break a few panels
- trains occasionally act like a car with an exhaust hanging onto the road : loose equipment will be mercilessly dragged on the ballast, and plow into every equipment there. Oh, a hanging chain just broke 200km of solar panel glass? Too bad. how many millions is that ?
- trees and overhead equipment shade the tracks
To avoid or eliminate all those problems, the panels have to go up as much as possible. Putting panels between the tracks is about as bad as putting them on a bike path: 2-6 months, and they're trash.
Roof, canopy or soundwall, or side bank is the way to go.
Open canopy mounting has the big advantage that 23kV and height is quite a deterrent to thieves and vandals.
Of course there is a fine equilibrium between the cost of support structure and the breakage level of equipment to make the most of the investment.
Washing panels is not really a consideration. If it is, you've done something very wrong.