Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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
27
28////////////////////////////////////////////////////////////////////////////////
29/// Constructor.
30
33{
34 fInputList.SetOwner(kTRUE);
35 fInputList.Add(new TNamed("varexp", ""));
36 fInputList.Add(new TNamed("selection", sel));
38}
39
40////////////////////////////////////////////////////////////////////////////////
41/// Process entry.
42
44{
45 if(GetSelect()->EvalInstance(0) != 0)
46 fEvList->Enter(entry);
47 return kTRUE;
48}
49
50/** \class TEvePointSelector
51\ingroup TEve
52TEvePointSelector is a sub-class of TSelectorDraw for direct
53extraction of point-like data from a Tree.
54*/
55
56/** \class TEvePointSelectorConsumer
57\ingroup TEve
58TEvePointSelectorConsumer is a virtual base for classes that can be
59filled from TTree data via the TEvePointSelector class.
60*/
61
62
63////////////////////////////////////////////////////////////////////////////////
64/// Constructor.
65
68 const char* vexp, const char* sel) :
70
71 fSelectTree(t),
72 fConsumer (c),
73 fVarexp (vexp),
74 fSelection (sel),
75 fSubIdExp (),
76 fSubIdNum (0)
77{
78 fInputList.SetOwner(kTRUE);
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Process the tree, select points matching 'selection'.
84
85Long64_t TEvePointSelector::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 != nullptr)
97 sel = selection;
98 else
99 sel = fSelection;
100
101 fInputList.Delete();
102 fInputList.Add(new TNamed("varexp", var.Data()));
103 fInputList.Add(new TNamed("selection", sel.Data()));
104
105 if (fConsumer)
106 fConsumer->InitFill(fSubIdNum);
107
108 if (fSelectTree)
109 fSelectTree->Process(this, "goff");
110
111 return fSelectedRows;
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// Process tree 't', select points matching 'selection'.
116
117Long64_t TEvePointSelector::Select(TTree* t, const char* selection)
118{
119 fSelectTree = 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("TEvePointSelector::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
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
TEvePointSelectorConsumer is a virtual base for classes that can be filled from TTree data via the TE...
void TakeAction() override
Callback from tree-player after a chunk of data has been processed.
virtual Long64_t Select(const char *selection=nullptr)
Process the tree, select points matching 'selection'.
TEvePointSelectorConsumer * fConsumer
TEvePointSelector(const TEvePointSelector &)=delete
Bool_t Process(Long64_t entry) override
Process entry.
TEveSelectorToEventList(const TEveSelectorToEventList &)=delete
<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