forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveTreeTools.cxx
135 lines (109 loc) · 3.75 KB
/
TEveTreeTools.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// @(#)root/eve:$Id$
// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
//______________________________________________________________________________
// TTreeTools
//
// Collection of classes for TTree interaction.
#include "TEveTreeTools.h"
#include "TTree.h"
#include "TTreeFormula.h"
/** \class TEveSelectorToEventList
\ingroup TEve
TSelector that stores entry numbers of matching TTree entries into
an event-list.
*/
ClassImp(TEveSelectorToEventList);
////////////////////////////////////////////////////////////////////////////////
/// Constructor.
TEveSelectorToEventList::TEveSelectorToEventList(TEventList* evl, const char* sel) :
TSelectorDraw(), fEvList(evl)
{
fInput.Add(new TNamed("varexp", ""));
fInput.Add(new TNamed("selection", sel));
SetInputList(&fInput);
}
////////////////////////////////////////////////////////////////////////////////
/// Process entry.
Bool_t TEveSelectorToEventList::Process(Long64_t entry)
{
if(GetSelect()->EvalInstance(0) != 0)
fEvList->Enter(entry);
return kTRUE;
}
/** \class TEvePointSelector
\ingroup TEve
TEvePointSelector is a sub-class of TSelectorDraw for direct
extraction of point-like data from a Tree.
*/
/** \class TEvePointSelectorConsumer
\ingroup TEve
TEvePointSelectorConsumer is a virtual base for classes that can be
filled from TTree data via the TEvePointSelector class.
*/
ClassImp(TEvePointSelector);
ClassImp(TEvePointSelectorConsumer);
////////////////////////////////////////////////////////////////////////////////
/// Constructor.
TEvePointSelector::TEvePointSelector(TTree* t,
TEvePointSelectorConsumer* c,
const char* vexp, const char* sel) :
TSelectorDraw(),
fTree (t),
fConsumer (c),
fVarexp (vexp),
fSelection (sel),
fSubIdExp (),
fSubIdNum (0)
{
SetInputList(&fInput);
}
////////////////////////////////////////////////////////////////////////////////
/// Process the tree, select points matching 'selection'.
Long64_t TEvePointSelector::Select(const char* selection)
{
TString var(fVarexp);
if (fSubIdExp.IsNull()) {
fSubIdNum = 0;
} else {
fSubIdNum = fSubIdExp.CountChar(':') + 1;
var += ":" + fSubIdExp;
}
TString sel;
if (selection != 0)
sel = selection;
else
sel = fSelection;
fInput.Delete();
fInput.Add(new TNamed("varexp", var.Data()));
fInput.Add(new TNamed("selection", sel.Data()));
if (fConsumer)
fConsumer->InitFill(fSubIdNum);
if (fTree)
fTree->Process(this, "goff");
return fSelectedRows;
}
////////////////////////////////////////////////////////////////////////////////
/// Process tree 't', select points matching 'selection'.
Long64_t TEvePointSelector::Select(TTree* t, const char* selection)
{
fTree = t;
return Select(selection);
}
////////////////////////////////////////////////////////////////////////////////
/// Callback from tree-player after a chunk of data has been processed.
/// This is forwarded to the current point-consumer.
void TEvePointSelector::TakeAction()
{
fSelectedRows += fNfill;
// printf("TEvePointSelector::TakeAction nfill=%d, nall=%lld\n", fNfill, fSelectedRows);
if (fConsumer) {
fConsumer->TakeAction(this);
}
}