Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
23TSelector that stores entry numbers of matching TTree entries into
24an 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));
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
52TEvePointSelector is a sub-class of TSelectorDraw for direct
53extraction of point-like data from a Tree.
54*/
55
56/** \class TEvePointSelectorConsumer
57\ingroup TEve
58TEvePointSelectorConsumer is a virtual base for classes that can be
59filled from TTree data via the TEvePointSelector class.
60*/
61
64
65////////////////////////////////////////////////////////////////////////////////
66/// Constructor.
67
70 const char* vexp, const char* sel) :
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
86Long64_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)
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
118Long64_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}
#define c(i)
Definition RSha256.hxx:101
long long Long64_t
Definition RtypesCore.h:73
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
TEvePointSelectorConsumer is a virtual base for classes that can be filled from TTree data via the TE...
virtual void TakeAction(TEvePointSelector *)=0
virtual void InitFill(Int_t)
TEvePointSelector is a sub-class of TSelectorDraw for direct extraction of point-like data from a Tre...
TEvePointSelector(const TEvePointSelector &)
virtual Long64_t Select(const char *selection=0)
Process the tree, select points matching 'selection'.
TEvePointSelectorConsumer * fConsumer
virtual void TakeAction()
Callback from tree-player after a chunk of data has been processed.
TSelector that stores entry numbers of matching TTree entries into an event-list.
TEveSelectorToEventList(const TEveSelectorToEventList &)
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:31
virtual void Enter(Long64_t entry)
Enter element entry into the list.
virtual void Add(TObject *obj)
Definition TList.h:87
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:470
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
A specialized TSelector for TTree::Draw.
TTreeFormula * GetSelect() const
Long64_t fSelectedRows
Int_t fNfill
Last entry loop number when object was drawn.
virtual void SetInputList(TList *input)
Definition TSelector.h:66
Basic string class.
Definition TString.h:136
const char * Data() const
Definition TString.h:369
Bool_t IsNull() const
Definition TString.h:407
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
Definition TString.cxx:496
A TTree represents a columnar dataset.
Definition TTree.h:79
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:7431