function sol = RangeDopplerRadar_sigfit( X, n, Y, S, t, B, beta1, f_LC)
%RANGERADAR_SIGFIT Summary of this function goes here
%   Detailed explanation goes here

nn = n*n;
% S = sorted subset in 1:nn

theta = X(1:nn) + 1i*X(nn+1:2*nn);

temp= X(2*nn+1:end);

tautil = temp(1:n);
alphatil = temp(n+1:2*n);

%tautil = tau + xi;
gammatil = repmat(tautil,n,1) + kron(alphatil,ones(n,1))/beta1;
%gammatil = gamma + zeta;


%S = find(sigma ~= 0);

%sol = Y - exp( -2i*pi*B*kron(t,transpose(tautil)) ) * (f_LC(-tautil) .* sigma);
%sol = abs( Y - exp( -2i*pi*B*kron(t,transpose(tautil)) ) * (f_LC(-tautil) .* sigma) );
%sol = abs( Y - exp( -2i*pi*B*kron(t,transpose(tautil(S))) ) * (f_LC(-tautil(S)) .* sigma(S)) );

longtautil = repmat(f_LC(-tautil),n,1); % no tautil information, all sucked in gammatil
%longtautil = f_LC(-gammatil); % no tautil information, all sucked in gammatil

sol = abs( Y - exp( -2i*pi*B*kron(t,transpose(gammatil(S))) )  * (longtautil(S).*theta(S) )  );



end

