def METHOD_NAME(self):
    self.stop()
    if self.lockbox.is_locked_and_final(loglevel=0):
        self.loop = GainOptimizerLoop(parent=self,
                                      name="gainoptimizerloop",
                                      interval=self.interval,
                                      unity_gain_frequency=self.unity_gain_frequency,
                                      amplitude=self.amplitude,
                                      plot=self.plot
                                      )
    else:
        self._logger.error('The lockbox must be "locked" in order to start gain optimization.')