Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TBranchProxyDirector.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Philippe Canal 13/05/2003
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun, Fons Rademakers and al. *
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/** \class TBranchProxyDirector
13This class is used to 'drive' and hold a serie of TBranchProxy objects
14which represent and give access to the content of TTree object.
15This is intended to be used as part of a generate Selector class
16which will hold the directory and its associate
17*/
18
20#include "TBranchProxy.h"
21#include "TFriendProxy.h"
22#include "TTree.h"
23#include "TEnv.h"
24#include "TH1F.h"
25#include "TVirtualPad.h"
26#include "TList.h"
27
28#include <algorithm>
29
31
32namespace ROOT {
33namespace Internal {
34
35 // Helper function to call Reset on each TBranchProxy
36 void NotifyDirected(Detail::TBranchProxy *x) { x->Notify(); }
37
38 // Helper function to call SetReadEntry on all TFriendProxy
40
41 // Helper class to call Update on all TFriendProxy
42 struct Update {
43 Update(TTree *newtree) : fNewTree(newtree) {}
45 void operator()(TFriendProxy *x) { x->Update(fNewTree); }
46 };
47
48 ////////////////////////////////////////////////////////////////////////////////
49 /// Simple constructor
50
52 fTree(tree),
53 fEntry(i)
54 {
55 }
56
57 ////////////////////////////////////////////////////////////////////////////////
58 /// Simple constructor
59
61 // cint has a problem casting int to long long
62 fTree(tree),
63 fEntry(i)
64 {
65 }
66
67 ////////////////////////////////////////////////////////////////////////////////
68 /// Attach a TBranchProxy object to this director. The director just
69 /// 'remembers' this BranchProxy and does not own it. It will be use
70 /// to apply Tree wide operation (like reseting).
71
73
74 fDirected.push_back(p);
75 }
76
77 ////////////////////////////////////////////////////////////////////////////////
78 /// Attach a TFriendProxy object to this director. The director just
79 /// 'remembers' this BranchProxy and does not own it. It will be use
80 /// to apply Tree wide operation (like reseting).
81
83
84 fFriends.push_back(p);
85 }
86
87 ////////////////////////////////////////////////////////////////////////////////
88 /// Create a temporary 1D histogram.
89
91 Int_t nbins = gEnv->GetValue("Hist.Binning.1D.x",100);
92 Double_t vmin=0, vmax=0;
93 Double_t xmin=0, xmax=0;
94 bool canExtend = true;
95 TString opt( options );
96 bool optSame = opt.Contains("same");
97 if (optSame) canExtend = false;
98
99 if (gPad && optSame) {
100 TListIter np(gPad->GetListOfPrimitives());
101 TObject *op;
102 TH1 *oldhtemp = nullptr;
103 while ((op = np()) && !oldhtemp) {
104 if (op->InheritsFrom(TH1::Class())) oldhtemp = (TH1 *)op;
105 }
106 if (oldhtemp) {
107 nbins = oldhtemp->GetXaxis()->GetNbins();
108 vmin = oldhtemp->GetXaxis()->GetXmin();
109 vmax = oldhtemp->GetXaxis()->GetXmax();
110 } else {
111 vmin = gPad->GetUxmin();
112 vmax = gPad->GetUxmax();
113 }
114 } else {
115 vmin = xmin;
116 vmax = xmax;
117 if (xmin < xmax) canExtend = false;
118 }
119 TH1F *hist = new TH1F("htemp","htemp",nbins,vmin,vmax);
128 if (canExtend) hist->SetCanExtend(TH1::kAllAxes);
129 hist->GetXaxis()->SetTitle("var");
130 hist->SetBit(kCanDelete);
131 hist->SetDirectory(nullptr);
132
133 if (opt.Length() && opt.Contains("e")) hist->Sumw2();
134 return hist;
135 }
136
137 ////////////////////////////////////////////////////////////////////////////////
138 /// Set the BranchProxy to be looking at a new tree.
139 /// Reset all.
140 /// Return the old tree.
141
143
144 TTree* oldtree = fTree;
145 fTree = newtree;
146 if(!Notify()) return nullptr;
147 return oldtree;
148 }
149
150 ////////////////////////////////////////////////////////////////////////////////
151
153 fEntry = -1;
154 bool retVal = true;
155 for_each(fDirected.begin(),fDirected.end(),NotifyDirected);
156 for (auto brProxy : fDirected) {
157 retVal = retVal && brProxy->Notify();
158 }
160 for_each(fFriends.begin(),fFriends.end(),update);
161 return retVal;
162 }
163
164} // namespace Internal
165} // namespace ROOT
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
long long Long64_t
Definition RtypesCore.h:69
#define ClassImp(name)
Definition Rtypes.h:382
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
winID h TVirtualViewer3D TVirtualGLPainter p
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 np
float xmin
float xmax
@ kCanDelete
Definition TObject.h:367
#define gPad
Base class for all the proxy object.
Long64_t fEntry
Entry currently being read (in the local TTree rather than the TChain)
TTree * fTree
TTree we are currently looking at.
std::list< Detail::TBranchProxy * > fDirected
std::vector< TFriendProxy * > fFriends
TTree * SetTree(TTree *newtree)
Set the BranchProxy to be looking at a new tree.
TBranchProxyDirector(const TBranchProxyDirector &)
TH1F * CreateHistogram(const char *options)
Create a temporary 1D histogram.
void Attach(Detail::TBranchProxy *p)
Attach a TBranchProxy object to this director.
void ResetReadEntry()
Refresh the cached read entry number from the original tree.
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:30
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:31
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:37
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:39
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:33
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:42
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:35
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:40
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:34
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition TAttMarker.h:32
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:38
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition TAttMarker.h:31
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition TAttMarker.h:33
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition TAttMarker.h:40
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition TAttMarker.h:45
Double_t GetXmax() const
Definition TAxis.h:140
Double_t GetXmin() const
Definition TAxis.h:139
Int_t GetNbins() const
Definition TAxis.h:125
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:623
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
Definition TH1.cxx:8970
@ kAllAxes
Definition TH1.h:76
static TClass * Class()
TAxis * GetXaxis()
Definition TH1.h:325
virtual UInt_t SetCanExtend(UInt_t extendBitMask)
Make the histogram axes extendable / not extendable according to the bit mask returns the previous bi...
Definition TH1.cxx:6678
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
Definition TH1.cxx:9053
Iterator of linked list.
Definition TList.h:191
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
Mother of all ROOT objects.
Definition TObject.h:41
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:798
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:542
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
A TTree represents a columnar dataset.
Definition TTree.h:79
Double_t x[n]
Definition legend1.C:17
void ResetReadEntry(TFriendProxy *fp)
Helper function to call SetReadEntry on all TFriendProxy.
void NotifyDirected(Detail::TBranchProxy *x)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
void operator()(TFriendProxy *x)