logical function TestIfDETinCASBit(ilutnI)
! In:
! iLutNI: bit string representation of a determinant.
! Returns:
! true if the determinant is in the complete active space.
integer(n_int), intent(in) :: iLutnI(0:NIfD)
! A determinant is in the CAS iff
! a) all orbitals in the core space are occupied;
! b) no orbitals in the external space are occupied;
! Thus ANDing the determinant with CASMask (containing set bits for
! the core and external orbitals) will give precisely the core
! orbitals if the determinant is in the CAS.
TestifDETinCASBit = all(iand(iLutNI, CASMask) == CoreMask)
end function TestIfDETinCASBit