code: def set_directory(robject):
      
      if (not hasattr(robject, 'GetDirectory') or
          not hasattr(robject, 'SetDirectory')):
          log.warning("Cannot set the directory of a `{0}`".format(
              type(robject)))
          # Do nothing
          yield
      else:
          old_dir = robject.GetDirectory()
          try:
              robject.SetDirectory(ROOT.gDirectory)
              yield
          finally:
              robject.SetDirectory(old_dir)
docs: Context manager to temporarily set the directory of a ROOT object
      (if possible)