code: def set_event_list(tree, selection=None, fraction=None, start_fraction=None):
      
      import ROOT
  
      elist = rand_str()
  
      if selection is None:
          cuts = ''
      else:
          cuts = selection
  
      if fraction is None or fraction >= 1.0:
          n = tree.Draw(">>%s" % elist, cuts, "goff")
          tree.SetEventList(ROOT.gDirectory.Get(elist))
      elif start_fraction is None:
          nentries = int(tree.GetEntries())
          first_entry = min(int((1.0 - fraction) * nentries), nentries)
          n = tree.Draw(">>%s" % elist, cuts, "goff", nentries, first_entry)
          tree.SetEventList(ROOT.gDirectory.Get(elist))
      else:
          nentries = int(tree.GetEntries())
          first_entry = min(int(start_fraction * nentries), nentries)
          n = first_entry + int(nentries * fraction)
          n = tree.Draw(">>%s" % elist, cuts, "goff",
                        n - first_entry, first_entry)
          tree.SetEventList(ROOT.gDirectory.Get(elist))
  
      return n
docs: Set the event list for a tree or chain.
  
      Parameters
      ----------    
      tree : `ROOT.TTree`
          Input tree/chain.
      selection : str
          Cut string defining the event list.
      fraction : float
          Fraction of the total file to include in the event list
          starting from the *end* of the file.