Logo ROOT  
Reference Guide
REveTreeTools.cxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2019, 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
18
19#include "TTree.h"
20#include "TTreeFormula.h"
21
22using namespace ROOT::Experimental;
23namespace REX = ROOT::Experimental;
24
25/** \class REveSelectorToEventList
26\ingroup REve
27TSelector that stores entry numbers of matching TTree entries into
28an event-list.
29*/
30
31////////////////////////////////////////////////////////////////////////////////
32/// Constructor.
33
35 TSelectorDraw(), fEvList(evl)
36{
37 fInput.Add(new TNamed("varexp", ""));
38 fInput.Add(new TNamed("selection", sel));
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// Process entry.
44
46{
47 if(GetSelect()->EvalInstance(0) != 0)
48 fEvList->Enter(entry);
49 return kTRUE;
50}
51
52/** \class REvePointSelectorConsumer
53\ingroup REve
54REvePointSelectorConsumer is a virtual base for classes that can be
55filled from TTree data via the REvePointSelector class.
56*/
57
58/** \class REvePointSelector
59\ingroup REve
60REvePointSelector is a sub-class of TSelectorDraw for direct
61extraction of point-like data from a Tree.
62*/
63
64////////////////////////////////////////////////////////////////////////////////
65/// Constructor.
66
69 const char* vexp, const char* sel) :
71
72 fTree (t),
73 fConsumer (c),
74 fVarexp (vexp),
75 fSelection (sel),
76 fSubIdExp (),
77 fSubIdNum (0)
78{
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Process the tree, select points matching 'selection'.
84
85Long64_t REvePointSelector::Select(const char* selection)
86{
87 TString var(fVarexp);
88 if (fSubIdExp.IsNull()) {
89 fSubIdNum = 0;
90 } else {
91 fSubIdNum = fSubIdExp.CountChar(':') + 1;
92 var += ":" + fSubIdExp;
93 }
94
95 TString sel;
96 if (selection)
97 sel = selection;
98 else
99 sel = fSelection;
100
101 fInput.Delete();
102 fInput.Add(new TNamed("varexp", var.Data()));
103 fInput.Add(new TNamed("selection", sel.Data()));
104
105 if (fConsumer)
107
108 if (fTree)
109 fTree->Process(this, "goff");
110
111 return fSelectedRows;
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// Process tree 't', select points matching 'selection'.
116
117Long64_t REvePointSelector::Select(TTree *t, const char *selection)
118{
119 fTree = t;
120 return Select(selection);
121}
122
123////////////////////////////////////////////////////////////////////////////////
124/// Callback from tree-player after a chunk of data has been processed.
125/// This is forwarded to the current point-consumer.
126
128{
130 // printf("REvePointSelector::TakeAction nfill=%d, nall=%lld\n", fNfill, fSelectedRows);
131 if (fConsumer) {
132 fConsumer->TakeAction(this);
133 }
134}
#define c(i)
Definition: RSha256.hxx:101
bool Bool_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:69
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual void TakeAction(REvePointSelector *)=0
virtual void TakeAction()
Callback from tree-player after a chunk of data has been processed.
REvePointSelectorConsumer * fConsumer
REvePointSelector(const REvePointSelector &)
virtual Long64_t Select(const char *selection=nullptr)
Process the tree, select points matching 'selection'.
REveSelectorToEventList(const REveSelectorToEventList &)
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.
Definition: TEventList.cxx:191
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:467
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:31
TTreeFormula * GetSelect() const
Definition: TSelectorDraw.h:86
Long64_t fSelectedRows
Definition: TSelectorDraw.h:48
Int_t fNfill
Last entry loop number when object was drawn.
Definition: TSelectorDraw.h:45
virtual void SetInputList(TList *input)
Definition: TSelector.h:68
Basic string class.
Definition: TString.h:131
const char * Data() const
Definition: TString.h:364
Bool_t IsNull() const
Definition: TString.h:402
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
Definition: TString.cxx:476
A TTree represents a columnar dataset.
Definition: TTree.h:72
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:7265