You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: calcGBFit.m
    path of file: ./repos/mtex/EBSDAnalysis/@parentGrainReconstructor
    
    the code of the file until where you have to start completion: function [fit, pairs] = calcGBFit(job,varargin)
% fit between child to child misorientations and job.p2c
%
% Syntax
%

    
function [fit, pairs] = calcGBFit(job,varargin)
% fit between child to child misorientations and job.p2c
%
% Syntax
%
%   [fit, pairs] = job.calcGBFit
%
%   % visualize the result
%   [gB, pairId] = job.grains.boundary.selectByGrainId(pairs);
%   plot(gB, fit(pairId) ./ degree, 'linewidth',2);
%   setColorRange([2,8])
%   mtexColorMap white2black
%
%   % consider only P2C neighbors
%   [fit, p2cPairs] = job.calcGBFit('p2c')
%
%   % consider only C2C neighbors
%   [fit, c2cPairs] = job.calcGBFit('c2c')
%s
% Input
%  job - @parentGrainReconstructor
%
% Output
%  fit   - fit between the grain boundary misorientations and job.p2c
%  pairs - list of grainId of the neighboring grains
%

noOpt = ~check_option(varargin,{'p2c','c2c'});

% parent to child neighbors
if noOpt || check_option(varargin,'p2c')
  
  % extract all parent to child neighbors
  [pairs, oriParent, oriChild] = getP2CPairs(job, varargin{:});
  
  % compute the misorientation
  mori = inv(oriChild).*oriParent;
  
  % compute the fit
  fit = angle(mori, job.p2c);
  
else
  
  fit = []; 
  pairs = [];
  
end