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;
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{
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{
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
103 fInputList.Add(new TNamed("varexp", var.Data()));
104 fInputList.Add(new TNamed("selection", sel.Data()));
105
106 if (fConsumer)
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
Definition: RtypesCore.h:63
long long Long64_t
Definition: RtypesCore.h:80
const Bool_t kTRUE
Definition: RtypesCore.h:100
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.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
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:7409