If you are looking to activate an accessory, the easiest way would be to make an insulated rail/insulated block and connect one wire from the accessory to the insulated rail. When the train rolls through the block, the metal wheels close the circuit and trigger the accessory. You can also wire in a relay, which is helpful for operating signals.
IR sensors/motion detectors can work (Lionel and MTH both sell them), but may need to be adjusted and positioned in a way where room lights do not trigger the sensor. In general the insulated block is the easiest way to go, and as long as the rails are kept clean, you should experience no problems.
If you can post which accessory (or accessories) you want to trigger, I or other forum members can help with wiring diagrams.
-John