Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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;
23
24/** \class REveSelectorToEventList
25\ingroup REve
26TSelector that stores entry numbers of matching TTree entries into
27an event-list.
28*/
29
30////////////////////////////////////////////////////////////////////////////////
31/// Constructor.
32
33REveSelectorToEventList::REveSelectorToEventList(TEventList* evl, const char* sel) :
34 TSelectorDraw(), fEvList(evl)
35{
36 fInput.Add(new TNamed("varexp", ""));
37 fInput.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 REvePointSelectorConsumer
52\ingroup REve
53REvePointSelectorConsumer is a virtual base for classes that can be
54filled from TTree data via the REvePointSelector class.
55*/
56
57/** \class REvePointSelector
58\ingroup REve
59REvePointSelector is a sub-class of TSelectorDraw for direct
60extraction of point-like data from a Tree.
61*/
62
63////////////////////////////////////////////////////////////////////////////////
64/// Constructor.
65
68 const char* vexp, const char* sel) :
70
71 fTree (t),
72 fConsumer (c),
73 fVarexp (vexp),
74 fSelection (sel),
75 fSubIdExp (),
76 fSubIdNum (0)
77{
79}
80
81////////////////////////////////////////////////////////////////////////////////
82/// Process the tree, select points matching 'selection'.
83
84Long64_t REvePointSelector::Select(const char* selection)
85{
86 TString var(fVarexp);
87 if (fSubIdExp.IsNull()) {
88 fSubIdNum = 0;
89 } else {
90 fSubIdNum = fSubIdExp.CountChar(':') + 1;
91 var += ":" + fSubIdExp;
92 }
93
94 TString sel;
95 if (selection)
96 sel = selection;
97 else
98 sel = fSelection;
99
100 fInput.Delete();
101 fInput.Add(new TNamed("varexp", var.Data()));
102 fInput.Add(new TNamed("selection", sel.Data()));
103
104 if (fConsumer)
106
107 if (fTree)
108 fTree->Process(this, "goff");
109
110 return fSelectedRows;
111}
112
113////////////////////////////////////////////////////////////////////////////////
114/// Process tree 't', select points matching 'selection'.
115
116Long64_t REvePointSelector::Select(TTree *t, const char *selection)
117{
118 fTree = t;
119 return Select(selection);
120}
121
122////////////////////////////////////////////////////////////////////////////////
123/// Callback from tree-player after a chunk of data has been processed.
124/// This is forwarded to the current point-consumer.
125
127{
129 // printf("REvePointSelector::TakeAction nfill=%d, nall=%lld\n", fNfill, fSelectedRows);
130 if (fConsumer) {
131 fConsumer->TakeAction(this);
132 }
133}
#define c(i)
Definition RSha256.hxx:101
long long Long64_t
Definition RtypesCore.h:73
const Bool_t kTRUE
Definition RtypesCore.h:91
virtual void TakeAction(REvePointSelector *)=0
virtual void TakeAction()
Callback from tree-player after a chunk of data has been processed.
REvePointSelector(const REvePointSelector &)=delete
REvePointSelectorConsumer * fConsumer
virtual Long64_t Select(const char *selection=nullptr)
Process the tree, select points matching 'selection'.
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