For the same task I used a custom factor returning the sid and created a filter with it.
Actually I hoped something like that would be builtin but I couldn't find it in the single-mega-ultra-combined-help-tutorial-reference page.
Here's what I mean, the only comment is the bit you asked for, the trick is that the asset parameter to compute() holds all the sids for the pipeline securities:
from quantopian.algorithm import attach_pipeline, pipeline_output
from quantopian.pipeline import Pipeline, CustomFactor
inputs = 
window_length = 1
def compute(self, today, assets, out):
out[:] = assets
sid = SidFactor()
# This is the filter you want
my_sid_filter = sid.eq(24)
pipe = Pipeline()
def handle_data(context, data):