Is there a formula for processing a rendered area in compositor without affecting other areas? In various scenes I have areas that could be isolated using cryptomatte or material id or view layer and I want to effect that area only. With colorramp, the result applies color to the entire output rather than the isolated area. On a case by case basis, I can fiddle with the result using color key, alpha over, mix etc. and get an acceptable result. But, what I really want is a way to do this simply every time.
I tried using holdout shaders and view layers. For example, from back to front is:

background
torus
plane
sphere

So, I created view layers:
Background collection:
background + torus holdout + plane holdout + sphere holdout
Torus collection:
Torus + plane holdout + sphere holdout
Plane collection:
Plane + sphere holdout
Sphere collection:
Sphere
But this didn't work. Combining them, in compositor with Mix blend mode, the result does not show the background behind semi-transparent areas of the sphere. Plane does not show the torus in transparent areas, etc.
It seems to me like such an obviously needed thing, that I'm hoping there is a formula to achieve this in compositor. Is there?
Sorry long day ... I'm not sure if I catch the point ... if your issue is lost alpha after Colorramp add Set Aplha node behind. Colorramp is black&amp;white node only.