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
28
29////////////////////////////////////////////////////////////////////////////////
30/// Constructor.
31
33 TSelectorDraw(), fEvList(evl)
34{
36 fInputList.Add(new TNamed("varexp", ""));
37 fInputList.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 TEvePointSelector
52\ingroup TEve
53TEvePointSelector is a sub-class of TSelectorDraw for direct
54extraction of point-like data from a Tree.
55*/
56
57/** \class TEvePointSelectorConsumer
58\ingroup TEve
59TEvePointSelectorConsumer is a virtual base for classes that can be
60filled from TTree data via the TEvePointSelector class.
61*/
62
65
66////////////////////////////////////////////////////////////////////////////////
67/// Constructor.
68
71 const char* vexp, const char* sel) :
73
74 fSelectTree(t),
75 fConsumer (c),
76 fVarexp (vexp),
77 fSelection (sel),
78 fSubIdExp (),
79 fSubIdNum (0)
80{
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Process the tree, select points matching 'selection'.
87
88Long64_t TEvePointSelector::Select(const char* selection)
89{
90 TString var(fVarexp);
91 if (fSubIdExp.IsNull()) {
92 fSubIdNum = 0;
93 } else {
94 fSubIdNum = fSubIdExp.CountChar(':') + 1;
95 var += ":" + fSubIdExp;
96 }
97
99 if (selection != 0)
100 sel = selection;
101 else
102 sel = fSelection;
103
105 fInputList.Add(new TNamed("varexp", var.Data()));
106 fInputList.Add(new TNamed("selection", sel.Data()));
107
108 if (fConsumer)
110
111 if (fSelectTree)
112 fSelectTree->Process(this, "goff");
113
114 return fSelectedRows;
115}
116
117////////////////////////////////////////////////////////////////////////////////
118/// Process tree 't', select points matching 'selection'.
119
120Long64_t TEvePointSelector::Select(TTree* t, const char* selection)
121{
122 fSelectTree = t;
123 return Select(selection);
124}
125
126////////////////////////////////////////////////////////////////////////////////
127/// Callback from tree-player after a chunk of data has been processed.
128/// This is forwarded to the current point-consumer.
129
131{
133 // printf("TEvePointSelector::TakeAction nfill=%d, nall=%lld\n", fNfill, fSelectedRows);
134 if (fConsumer) {
135 fConsumer->TakeAction(this);
136 }
137}
#define c(i)
Definition RSha256.hxx:101
long long Long64_t
Definition RtypesCore.h:80
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t sel
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
TEvePointSelectorConsumer is a virtual base for classes that can be filled from TTree data via the TE...
virtual void TakeAction(TEvePointSelector *)=0
virtual void InitFill(Int_t)
TEvePointSelector is a sub-class of TSelectorDraw for direct extraction of point-like data from a Tre...
virtual Long64_t Select(const char *selection=nullptr)
Process the tree, select points matching 'selection'.
TEvePointSelectorConsumer * fConsumer
TEvePointSelector(const TEvePointSelector &)=delete
virtual void TakeAction()
Callback from tree-player after a chunk of data has been processed.
TSelector that stores entry numbers of matching TTree entries into an event-list.
virtual Bool_t Process(Long64_t entry)
Process entry.
TEveSelectorToEventList(const TEveSelectorToEventList &)=delete
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.
void Add(TObject *obj) override
Definition TList.h:81
void Delete(Option_t *option="") override
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
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:139
const char * Data() const
Definition TString.h:380
Bool_t IsNull() const
Definition TString.h:418
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
Definition TString.cxx:508
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:7441