The number of diffraction orders to use in generating simulated
diffraction signals for a two-dimensional structure in optical metrology
is selected by generating a first simulated diffraction signal using a
first number of diffraction orders and a hypothetical profile of the
two-dimensional structure. A second simulated diffraction signal is
generated using a second number of diffraction orders using the same
hypothetical profile used to generate the first simulated diffraction
signal, where the first and second numbers of diffraction orders are
different. The first and second simulated diffraction signals are
compared. Based on the comparison of the first and second simulated
diffraction signals, a determination is made as to whether to select the
first or second number of diffraction orders.