Logo ROOT  
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
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{
36 fInputList.Add(new TNamed("varexp", ""));
37 fInputList.Add(new TNamed("selection", sel));
39}
40
41////////////////////////////////////////////////////////////////////////////////
42/// Process entry.
43
45{
46 if(GetSelect()->EvalInstance(0) != 0)
47 fEvList->Enter(entry);
48 return kTRUE;
49}
50
51/** \class TEvePointSelector
52\ingroup TEve
53TEvePointSelector is a sub-class of TSelectorDraw for direct
54extraction of point-like data from a Tree.
55*/
56
57/** \class TEvePointSelectorConsumer
58\ingroup TEve
59TEvePointSelectorConsumer is a virtual base for classes that can be
60filled from TTree data via the TEvePointSelector class.
61*/
62
65
66////////////////////////////////////////////////////////////////////////////////
67/// Constructor.
68
71 const char* vexp, const char* sel) :
73
74 fSelectTree(t),
75 fConsumer (c),
76 fVarexp (vexp),
77 fSelection (sel),
78 fSubIdExp (),
79 fSubIdNum (0)
80{
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Process the tree, select points matching 'selection'.
87
88Long64_t TEvePointSelector::Select(const char* selection)
89{
90 TString var(fVarexp);
91 if (fSubIdExp.IsNull()) {
92 fSubIdNum = 0;
93 } else {
94 fSubIdNum = fSubIdExp.CountChar(':') + 1;
95 var += ":" + fSubIdExp;
96 }
97
98 TString sel;
99 if (selection != 0)
100 sel = selection;
101 else
102 sel = fSelection;
103
105 fInputList.Add(new TNamed("varexp", var.Data()));
106 fInputList.Add(new TNamed("selection", sel.Data()));
107
108 if (fConsumer)
110
111 if (fSelectTree)
112 fSelectTree->Process(this, "goff");
113
114 return fSelectedRows;
115}
116
117////////////////////////////////////////////////////////////////////////////////
118/// Process tree 't', select points matching 'selection'.
119
120Long64_t TEvePointSelector::Select(TTree* t, const char* selection)
121{
122 fSelectTree = t;
123 return Select(selection);
124}
125
126////////////////////////////////////////////////////////////////////////////////
127/// Callback from tree-player after a chunk of data has been processed.
128/// This is forwarded to the current point-consumer.
129
131{
133 // printf("TEvePointSelector::TakeAction nfill=%d, nall=%lld\n", fNfill, fSelectedRows);
134 if (fConsumer) {
135 fConsumer->TakeAction(this);
136 }
137}
#define c(i)
Definition: RSha256.hxx:101
bool Bool_t
Definition: RtypesCore.h:63
long long Long64_t
Definition: RtypesCore.h:80
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassImp(name)
Definition: Rtypes.h:364
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
TEvePointSelectorConsumer is a virtual base for classes that can be filled from TTree data via the TE...
Definition: TEveTreeTools.h:46
virtual void TakeAction(TEvePointSelector *)=0
virtual void InitFill(Int_t)
Definition: TEveTreeTools.h:57
TEvePointSelector is a sub-class of TSelectorDraw for direct extraction of point-like data from a Tre...
Definition: TEveTreeTools.h:67
virtual Long64_t Select(const char *selection=0)
Process the tree, select points matching 'selection'.
TEvePointSelectorConsumer * fConsumer
Definition: TEveTreeTools.h:73
TEvePointSelector(const TEvePointSelector &)=delete
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.
Definition: TEveTreeTools.h:23
virtual Bool_t Process(Long64_t entry)
Process entry.
TEveSelectorToEventList(const TEveSelectorToEventList &)=delete
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.
Definition: TEventList.cxx:194
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.
Definition: TSelectorDraw.h:33
TTreeFormula * GetSelect() const
Definition: TSelectorDraw.h:88
Long64_t fSelectedRows
Number of selected entries.
Definition: TSelectorDraw.h:50
Int_t fNfill
! Total number of histogram fills
Definition: TSelectorDraw.h:47
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:500
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:7418