TEventList*

继承 TNamed

A list of selected entries in a TTree.

A TEventList object is a list of selected events (entries) in a TTree.

  • Use function Enter to enter an element in the list

  • The function Add may be used to merge two lists.

  • The function Subtract may be used to subtract two lists.

  • The function Reset may be used to reset a list.

  • Use TEventList::Print(option) to print the contents. (option “all” prints all the list entries).

  • Operators + and - correspond to functions Add and Subtract.

  • A TEventList object can be saved on a file via the Write function.

class

   TEventList();/// Default constructor for a EventList.
   TEventList(const char *name, const char *title="",Int_t initsize=0, Int_t delta = 0);
/// Create a EventList.
/// This Eventlist is added to the list of objects in current directory.

   TEventList(const TEventList &list);/// Copy constructor.
   virtual           ~TEventList();
   virtual void      Add(const TEventList *list);
/// Merge contents of alist with this list.
/// Both alist and this list are assumed to be sorted prior to this call

   virtual void      Clear(Option_t *option="") {Reset(option);}
   virtual Bool_t    Contains(Long64_t entry);/// Return TRUE if list contains entry.
   virtual Bool_t    ContainsRange(Long64_t entrymin, Long64_t entrymax);
/// Return TRUE if list contains entries from entrymin to entrymax included.

   virtual void      DirectoryAutoAdd(TDirectory *);
/// Called by TKey and others to automatically add us to a directory when we are read from a file.

   virtual void      Enter(Long64_t entry);/// Enter element entry into the list.
   TDirectory       *GetDirectory() const {return fDirectory;}
   virtual Long64_t  GetEntry(Int_t index) const;
/// Return value of entry at index in the list.
/// Return -1 if index is not in the list range.

   virtual Int_t     GetIndex(Long64_t entry) const;
/// Return index in the list of element with value entry
/// array is supposed  to be sorted prior to this call.
/// If match is found, function returns position of element.
/// If no match found, function returns -1.

   virtual Long64_t *GetList() const { return fList; }
   virtual Int_t     GetN() const { return fN; }
   virtual Bool_t    GetReapplyCut() const { return fReapply; };
   virtual Int_t     GetSize() const { return fSize; }
   virtual void      Intersect(const TEventList *list);/// Remove elements from this list that are NOT present in alist.
   virtual Int_t     Merge(TCollection *list);/// Merge entries in all the TEventList in the collection in this event list.
   virtual void      Print(Option_t *option="") const;/// Print contents of this list.
   virtual void      Reset(Option_t *option="");/// Reset number of entries in event list.
   virtual void      Resize(Int_t delta=0);/// Resize list by delta entries.
   virtual void      SetDelta(Int_t delta=100) {fDelta = delta;}
   virtual void      SetDirectory(TDirectory *dir);
/// Remove reference to this EventList from current directory and add
/// reference to new directory dir. dir can be 0 in which case the list
/// does not belong to any directory.

   virtual void      SetName(const char *name); // *MENU* /// Change the name of this TEventList.
   virtual void      SetReapplyCut(Bool_t apply = kFALSE) {fReapply = apply;}; // *TOGGLE*
   virtual void      Sort();/// Sort list entries in increasing order
   virtual void      Subtract(const TEventList *list);/// Remove elements from this list that are present in alist.

   TEventList&       operator=(const TEventList &list);

   friend TEventList operator+(const TEventList &list1, const TEventList &list2);
   friend TEventList operator-(const TEventList &list1, const TEventList &list2);
   friend TEventList operator*(const TEventList &list1, const TEventList &list2);

code

// A TEventList is automatically generated by TTree::Draw: example

tree->Draw(">>elist1","x<0 && y> 0");

// In this example, a TEventList object named "elist1" will be
// generated. (Previous contents are overwritten).

tree->Draw(">>+elist1","x<0 && y> 0");

// In this example, selected entries are added to the list.

// The TEventList object is added to the list of objects in the current directory.

// Use TTree:SetEventList(TEventList *list) to inform TTree that you
// want to use the list as input. The following code gets a pointer to
// the TEventList object created in the above commands:

TEventList *list = (TEventList*)gDirectory->Get("elist1");

example