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
30
31namespace ROOT {
32namespace Internal {
33
34 // Helper function to call Reset on each TBranchProxy
35 void NotifyDirected(Detail::TBranchProxy *x) { x->Notify(); }
36
37 // Helper function to call SetReadEntry on all TFriendProxy
39
40 // Helper class to call Update on all TFriendProxy
46
47 ////////////////////////////////////////////////////////////////////////////////
48 /// Simple constructor
49
51 fTree(tree),
52 fEntry(i)
53 {
54 }
55
56 ////////////////////////////////////////////////////////////////////////////////
57 /// Simple constructor
58
60 // cint has a problem casting int to long long
61 fTree(tree),
62 fEntry(i)
63 {
64 }
65
66 ////////////////////////////////////////////////////////////////////////////////
67 /// Attach a TBranchProxy object to this director. The director just
68 /// 'remembers' this BranchProxy and does not own it. It will be use
69 /// to apply Tree wide operation (like reseting).
70
75
76 ////////////////////////////////////////////////////////////////////////////////
77 /// Attach a TFriendProxy object to this director. The director just
78 /// 'remembers' this BranchProxy and does not own it. It will be use
79 /// to apply Tree wide operation (like reseting).
80
82
83 fFriends.push_back(p);
84 }
85
86 ////////////////////////////////////////////////////////////////////////////////
87 /// Create a temporary 1D histogram.
88
90 Int_t nbins = gEnv->GetValue("Hist.Binning.1D.x",100);
91 Double_t vmin=0, vmax=0;
92 Double_t xmin=0, xmax=0;
93 bool canExtend = true;
94 TString opt( options );
95 bool optSame = opt.Contains("same");
96 if (optSame) canExtend = false;
97
98 if (gPad && optSame) {
99 TListIter np(gPad->GetListOfPrimitives());
100 TObject *op;
101 TH1 *oldhtemp = nullptr;
102 while ((op = np()) && !oldhtemp) {
103 if (op->InheritsFrom(TH1::Class())) oldhtemp = (TH1 *)op;
104 }
105 if (oldhtemp) {
106 nbins = oldhtemp->GetXaxis()->GetNbins();
107 vmin = oldhtemp->GetXaxis()->GetXmin();
108 vmax = oldhtemp->GetXaxis()->GetXmax();
109 } else {
110 vmin = gPad->GetUxmin();
111 vmax = gPad->GetUxmax();
112 }
113 } else {
114 vmin = xmin;
115 vmax = xmax;
116 if (xmin < xmax) canExtend = false;
117 }
118 TH1F *hist = new TH1F("htemp","htemp",nbins,vmin,vmax);
128 hist->GetXaxis()->SetTitle("var");
129 hist->SetBit(kCanDelete);
130 hist->SetDirectory(nullptr);
131
132 if (opt.Length() && opt.Contains("e")) hist->Sumw2();
133 return hist;
134 }
135
136 ////////////////////////////////////////////////////////////////////////////////
137 /// Set the BranchProxy to be looking at a new tree.
138 /// Reset all.
139 /// Return the old tree.
140
142
144 fTree = newtree;
145 if(!Notify()) return nullptr;
146 return oldtree;
147 }
148
149 ////////////////////////////////////////////////////////////////////////////////
150
152 fEntry = -1;
153 bool retVal = true;
154 for_each(fDirected.begin(),fDirected.end(),NotifyDirected);
155 for (auto brProxy : fDirected) {
156 retVal = retVal && brProxy->Notify();
157 }
159 for_each(fFriends.begin(),fFriends.end(),update);
160 return retVal;
161 }
162
163} // namespace Internal
164} // 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
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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:370
#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:31
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:32
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:38
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:40
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:35
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:44
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:37
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:45
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:42
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:36
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition TAttMarker.h:33
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:39
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition TAttMarker.h:32
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition TAttMarker.h:34
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition TAttMarker.h:41
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition TAttMarker.h:46
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:490
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:879
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
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:8978
@ kAllAxes
Definition TH1.h:126
static TClass * Class()
TAxis * GetXaxis()
Definition TH1.h:572
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:6697
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
Definition TH1.cxx:9061
Iterator of linked list.
Definition TList.h:191
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
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:864
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:640
A TTree represents a columnar dataset.
Definition TTree.h:89
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)
void operator()(TFriendProxy *x)