2D Raycast not detecting right layer

I got a GameObject like so: main GameObject with rigidbody2D + colider2D that has 3 child, last one got script called ShadowAffectedByLantern.
The Player script throw Raycast2d like so:
private void LanternAffectShadow()

    var hit2D = Physics2D.Raycast(transform.position, _direction, Mathf.Infinity, 11);
    if (!hit2D.collider) return;
    var shadowAffectedByLantern =   hit2D.collider.gameObject.GetComponentInChildren<ShadowAffectedByLantern>();
    if (!shadowAffectedByLantern)
        Quaternion.AngleAxis(_angle * Mathf.Rad2Deg, Vector3.forward)

Basically, I try to execute that child script throw his parent but somehow raycast hit take the parent that is not event the layer mask I try to hit.

Make sure you’re getting the LayerMask and not the layer, they are different things.
easiest way to get layermask is

LayerMask.GetMask("Your Layer name")

as the last parameter in you Raycast
For more info: