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
35{
36 fInputList.SetOwner(kTRUE);
37 fInputList.Add(new TNamed("varexp", ""));
38 fInputList.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 fSelectTree (t),
73 fConsumer (c),
74 fVarexp (vexp),
75 fSelection (sel),
76 fSubIdExp (),
77 fSubIdNum (0)
78{
79 fInputList.SetOwner(kTRUE);
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Process the tree, select points matching 'selection'.
85
86Long64_t REvePointSelector::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)
98 sel = selection;
99 else
100 sel = fSelection;
101
102 fInputList.Delete();
103 fInputList.Add(new TNamed("varexp", var.Data()));
104 fInputList.Add(new TNamed("selection", sel.Data()));
105
106 if (fConsumer)
107 fConsumer->InitFill(fSubIdNum);
108
109 if (fSelectTree)
110 fSelectTree->Process(this, "goff");
111
112 return fSelectedRows;
113}
114
115////////////////////////////////////////////////////////////////////////////////
116/// Process tree 't', select points matching 'selection'.
117
118Long64_t REvePointSelector::Select(TTree *t, const char *selection)
119{
120 fSelectTree = 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("REvePointSelector::TakeAction nfill=%d, nall=%lld\n", fNfill, fSelectedRows);
132 if (fConsumer) {
133 fConsumer->TakeAction(this);
134 }
135}
#define c(i)
Definition RSha256.hxx:101
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
REvePointSelector(const REvePointSelector &)=delete
REvePointSelectorConsumer * fConsumer
virtual Long64_t Select(const char *selection=nullptr)
Process the tree, select points matching 'selection'.
void TakeAction() override
Callback from tree-player after a chunk of data has been processed.
REveSelectorToEventList(const REveSelectorToEventList &)=delete
Bool_t Process(Long64_t entry) override
Process entry.
<div class="legacybox"><h2>Legacy Code</h2> TEventList is a legacy interface: there will be no bug fi...
Definition TEventList.h:31
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
TTreeFormula * GetSelect() const
TSelectorDraw(const TSelectorDraw &)
Long64_t fSelectedRows
Number of selected entries.
Int_t fNfill
! Total number of histogram fills
virtual void SetInputList(TList *input)
Definition TSelector.h:66
Basic string class.
Definition TString.h:138
const char * Data() const
Definition TString.h:384
A TTree represents a columnar dataset.
Definition TTree.h:89
Namespace for ROOT features in testing.
Definition TROOT.h:100