code: def simulate_roi(self, name=None, randomize=True, restore=False):
          
  
          self.logger.info('Simulating ROI')
  
          self._fitcache = None
  
          if restore:
              self.logger.info('Restoring')
              self._restore_counts_maps()
              self.logger.info('Finished')
              return
  
          for c in self.components:
              c.simulate_roi(name=name, clear=True, randomize=randomize)
  
          if hasattr(self.like.components[0].logLike, 'setCountsMap'):
              self._init_roi_model()
          else:
              self.write_xml('tmp')
              self._like = SummedLikelihood()
              for i, c in enumerate(self._components):
                  c._create_binned_analysis('tmp.xml')
                  self._like.addComponent(c.like)
              self._init_roi_model()
              self.load_xml('tmp')
  
          self.logger.info('Finished')
docs: Generate a simulation of the ROI using the current best-fit model
          and replace the data counts cube with this simulation.  The
          simulation is created by generating an array of Poisson random
          numbers with expectation values drawn from the model cube of
          the binned analysis instance.  This function will update the
          counts cube both in memory and in the source map file.  The
          counts cube can be restored to its original state by calling
          this method with ``restore`` = True.
  
          Parameters
          ----------
          name : str
             Name of the model component to be simulated.  If None then
             the whole ROI will be simulated.
  
          restore : bool
             Restore the data counts cube to its original state.