Similarly to the procedure that there is in airports, you'll need to pass a security check before boarding trains in Spain, during which your luggage will be scanned and you'll need to pass a metal detector.