2000 toyota corolla

I have replaced the spark plugs on the car which is a CE model. When the plugs were replaced by removing the connector rail that connects the coils together, I noticed a wire that leaves the rail assembly from the left side and falls behind the engine to a sensor or something related. The wire is broke off, it has a prong sticking out and the cap to it which looks brittle is broke off. It is causing the car to ride rough. I want to replace it, however I do not know what this part is called.? Please help.