Similar to @Carlo's answer you can set this up within a single blendfile (and within the same scene) by making use of the Render Layers 'material override' setting. Set up each object with a pass index relating to the type of material in use. For example, we could have :
0 = Black diffuse (obscures mask)
1 = Emissive (the thing we want the mask for)
2 = Glass
3 = Glossy
You can potentially extend this to include any type of distinct material you desire (anything transmissive that you want the mask to take account of - eg, different indexes for different IORs, one for transmission, another for 'rough' glossy, etc - each assigned a suitable ID).
Then set up a material (named 'Mask' or similar) to determine the shader to use based on the object ID for each object (see nodes in the image below). Obviously this would need to be extended if you have extended the list of materials defined above.
Set up your render layer to disable Use Environment (so there is no environment lighting), and to set the 'override' Material to our new 'Mask' material - this will result in all objects in the scene being rendered with our 'Mask' material which will assign the shading based on the Object ID of each object (eg, 1 = Emissive, 2 = Refractive, etc.).
Rendering the layer will now produce something like the following - which can hopefully be used as your mask :
In the above example I have the torus emissive (index 1), the block as glass (index 2) and the floor glossy (index 3). Anything with an index of zero will act to block the mask. The Greater Than nodes are set between each of the levels - ie, 0.5, 1.5, 2.5 to be between the IDs 0, 1, 2, 3. Add as many Greater Than/Mix sets as unique IDs you require, along with the relevant Shader to mimic the effect you require that object to have on the mask.
Note that you can move lamps to specific layers and exclude them from the 'Mask' render layer if you do not want them to be included.
To still render the 'normal' image you can simply set up another render layer without the 'Mask' material override.
To demonstrate using the mask, consider the following Compositor nodes :
The above nodes simply use the Mask to mix between the original rendered image and the image multiplied by a color (set via an RGB input node). By varying the RGB color you can easily change the color of the torus purely within the compositor (including it's reflection and refraction) without having to re-render the original :
Blend file included