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
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
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
long long Long64_t
Definition RtypesCore.h:80
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
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 TakeAction(REvePointSelector *)=0
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.
Bool_t Process(Long64_t entry) override
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.
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:468
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:376
Bool_t IsNull() const
Definition TString.h:414
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
Definition TString.cxx:515
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:7450