Logo ROOT   6.08/07
Reference Guide
TEveTreeTools.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //______________________________________________________________________________
13 // TTreeTools
14 //
15 // Collection of classes for TTree interaction.
16 
17 #include "TEveTreeTools.h"
18 #include "TTree.h"
19 #include "TTreeFormula.h"
20 
21 /** \class TEveSelectorToEventList
22 \ingroup TEve
23 TSelector that stores entry numbers of matching TTree entries into
24 an event-list.
25 */
26 
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 /// Constructor.
31 
33  TSelectorDraw(), fEvList(evl)
34 {
35  fInput.Add(new TNamed("varexp", ""));
36  fInput.Add(new TNamed("selection", sel));
37  SetInputList(&fInput);
38 }
39 
40 ////////////////////////////////////////////////////////////////////////////////
41 /// Process entry.
42 
44 {
45  if(GetSelect()->EvalInstance(0) != 0)
46  fEvList->Enter(entry);
47  return kTRUE;
48 }
49 
50 /** \class TEvePointSelector
51 \ingroup TEve
52 TEvePointSelector is a sub-class of TSelectorDraw for direct
53 extraction of point-like data from a Tree.
54 */
55 
56 /** \class TEvePointSelectorConsumer
57 \ingroup TEve
58 TEvePointSelectorConsumer is a virtual base for classes that can be
59 filled from TTree data via the TEvePointSelector class.
60 */
61 
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 /// Constructor.
67 
70  const char* vexp, const char* sel) :
71  TSelectorDraw(),
72 
73  fTree (t),
74  fConsumer (c),
75  fVarexp (vexp),
76  fSelection (sel),
77  fSubIdExp (),
78  fSubIdNum (0)
79 {
81 }
82 
83 ////////////////////////////////////////////////////////////////////////////////
84 /// Process the tree, select points matching 'selection'.
85 
86 Long64_t TEvePointSelector::Select(const char* selection)
87 {
88  TString var(fVarexp);
89  if (fSubIdExp.IsNull()) {
90  fSubIdNum = 0;
91  } else {
92  fSubIdNum = fSubIdExp.CountChar(':') + 1;
93  var += ":" + fSubIdExp;
94  }
95 
96  TString sel;
97  if (selection != 0)
98  sel = selection;
99  else
100  sel = fSelection;
101 
102  fInput.Delete();
103  fInput.Add(new TNamed("varexp", var.Data()));
104  fInput.Add(new TNamed("selection", sel.Data()));
105 
106  if (fConsumer)
107  fConsumer->InitFill(fSubIdNum);
108 
109  if (fTree)
110  fTree->Process(this, "goff");
111 
112  return fSelectedRows;
113 }
114 
115 ////////////////////////////////////////////////////////////////////////////////
116 /// Process tree 't', select points matching 'selection'.
117 
118 Long64_t TEvePointSelector::Select(TTree* t, const char* selection)
119 {
120  fTree = t;
121  return Select(selection);
122 }
123 
124 ////////////////////////////////////////////////////////////////////////////////
125 /// Callback from tree-player after a chunk of data has been processed.
126 /// This is forwarded to the current point-consumer.
127 
129 {
131  // printf("TEvePointSelector::TakeAction nfill=%d, nall=%lld\n", fNfill, fSelectedRows);
132  if (fConsumer) {
133  fConsumer->TakeAction(this);
134  }
135 }
virtual void Enter(Long64_t entry)
Enter element entry into the list.
Definition: TEventList.cxx:191
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:405
long long Long64_t
Definition: RtypesCore.h:69
virtual void TakeAction()
Callback from tree-player after a chunk of data has been processed.
return c
TSelector that stores entry numbers of matching TTree entries into an event-list. ...
Definition: TEveTreeTools.h:22
Basic string class.
Definition: TString.h:137
bool Bool_t
Definition: RtypesCore.h:59
virtual void SetInputList(TList *input)
Definition: TSelector.h:73
virtual Long64_t Select(const char *selection=0)
Process the tree, select points matching 'selection'.
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TEvePointSelectorConsumer is a virtual base for classes that can be filled from TTree data via the TE...
Definition: TEveTreeTools.h:45
TTreeFormula * GetSelect() const
Definition: TSelectorDraw.h:88
virtual Bool_t Process(Long64_t entry)
Process entry.
A TEventList object is a list of selected events (entries) in a TTree.
Definition: TEventList.h:33
A specialized TSelector for TTree::Draw.
Definition: TSelectorDraw.h:33
Long64_t fSelectedRows
Definition: TSelectorDraw.h:50
virtual Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
Process this tree executing the TSelector code in the specified filename.
Definition: TTree.cxx:6922
#define ClassImp(name)
Definition: Rtypes.h:279
virtual void Add(TObject *obj)
Definition: TList.h:81
Int_t fNfill
Last entry loop number when object was drawn.
Definition: TSelectorDraw.h:47
A TTree object has a header with a name and a title.
Definition: TTree.h:98
const Bool_t kTRUE
Definition: Rtypes.h:91
TEvePointSelector is a sub-class of TSelectorDraw for direct extraction of point-like data from a Tre...
Definition: TEveTreeTools.h:66
const char * Data() const
Definition: TString.h:349