Logo ROOT   6.08/07
Reference Guide
TProofDraw.h
Go to the documentation of this file.
1 // @(#)root/proofplayer:$Id$
2 // Author: Maarten Ballintijn 24/09/2003
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2003, 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 #ifndef ROOT_TProofDraw
13 #define ROOT_TProofDraw
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TProofDraw //
19 // //
20 // Implement Tree drawing using PROOF. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #ifndef ROOT_TSelector
25 #include "TSelector.h"
26 #endif
27 
28 #ifndef ROOT_TString
29 #include "TString.h"
30 #endif
31 
32 #ifndef ROOT_TTreeDrawArgsParser
33 #include "TTreeDrawArgsParser.h"
34 #endif
35 
36 #ifndef ROOT_TNamed
37 #include "TNamed.h"
38 #endif
39 
40 #include <vector>
41 
42 
43 class TTree;
45 class TTreeFormula;
46 class TStatus;
47 class TH1;
48 class TEventList;
49 class TEntryList;
50 class TProfile;
51 class TProfile2D;
52 class TGraph;
53 class TPolyMarker3D;
54 class TCollection;
55 
56 
57 class TProofDraw : public TSelector {
58 
59 friend class TProofPlayer;
60 
61 protected:
68  TTreeFormula *fVar[4]; // Pointer to variable formula
69  TTreeFormula *fSelect; // Pointer to selection formula
70  Int_t fMultiplicity; // Indicator of the variability of the size of entries
71  Bool_t fObjEval; // true if fVar1 returns an object (or pointer to).
72  Int_t fDimension; // Dimension of the current expression
73  Double_t fWeight; // Global weight for fill actions
74 
75  void FillWeight();
76  void SetCanvas(const char *objname);
77  void SetDrawAtt(TObject *o);
78  void SetError(const char *sub, const char *mesg);
79 
80 protected:
81  enum { kWarn = BIT(12) };
82 
83  virtual Bool_t CompileVariables();
84  virtual void ClearFormula();
85  virtual Bool_t ProcessSingle(Long64_t /*entry*/, Int_t /*i*/);
86  virtual void DoFill(Long64_t entry, Double_t w, const Double_t *v) = 0;
87  virtual void DefVar() = 0;
88 
89 public:
90  TProofDraw();
91  virtual ~TProofDraw();
92  virtual int Version() const { return 1; }
93  virtual void Init(TTree *);
94  virtual void Begin(TTree *);
95  virtual void SlaveBegin(TTree *);
96  virtual Bool_t Notify();
97  virtual Bool_t Process(Long64_t /*entry*/);
98  virtual void SlaveTerminate();
99  virtual void Terminate();
100 
101  ClassDef(TProofDraw,0) //Tree drawing selector for PROOF
102 };
103 
104 
105 class TProofDrawHist : public TProofDraw {
106 
107 private:
108  void DefVar1D();
109  void DefVar2D();
110  void DefVar3D();
111 
112 protected:
114 
115  virtual void Begin1D(TTree *t);
116  virtual void Begin2D(TTree *t);
117  virtual void Begin3D(TTree *t);
118  virtual void DoFill(Long64_t entry, Double_t w, const Double_t *v);
119  virtual void DefVar();
120 
121 public:
122  TProofDrawHist() : fHistogram(0) { }
123  virtual void Begin(TTree *t);
124  virtual void Init(TTree *);
125  virtual void SlaveBegin(TTree *);
126  virtual void Terminate();
127 
128  ClassDef(TProofDrawHist,0) //Tree drawing selector for PROOF
129 };
130 
131 
133 
134 protected:
135  TEventList* fElist; // event list
136  TList* fEventLists; // a list of EventLists
137 
138  virtual void DoFill(Long64_t entry, Double_t w, const Double_t *v);
139  virtual void DefVar() { }
140 
141 public:
142  TProofDrawEventList() : fElist(0), fEventLists(0) {}
144 
145  virtual void Init(TTree *);
146  virtual void SlaveBegin(TTree *);
147  virtual void SlaveTerminate();
148  virtual void Terminate();
149 
150  ClassDef(TProofDrawEventList,0) //Tree drawing selector for PROOF
151 };
152 
154  protected:
156 
157  virtual void DoFill(Long64_t entry, Double_t w, const Double_t *v);
158  virtual void DefVar() {}
159 
160  public:
161  TProofDrawEntryList() : fElist(0) {}
163 
164  virtual void Init(TTree *);
165  virtual void SlaveBegin(TTree *);
166  virtual void SlaveTerminate();
167  virtual void Terminate();
168 
169  ClassDef(TProofDrawEntryList, 0) //A Selectoor to fill a TEntryList from TTree::Draw
170 };
171 
172 
174 
175 protected:
177 
178  virtual void DoFill(Long64_t entry, Double_t w, const Double_t *v);
179  virtual void DefVar();
180 
181 public:
182  TProofDrawProfile() : fProfile(0) { }
183  virtual void Init(TTree *);
184  virtual void Begin(TTree *t);
185  virtual void SlaveBegin(TTree *);
186  virtual void Terminate();
187 
188  ClassDef(TProofDrawProfile,0) //Tree drawing selector for PROOF
189 };
190 
191 
193 
194 protected:
196 
197  virtual void DoFill(Long64_t entry, Double_t w, const Double_t *v);
198  virtual void DefVar();
199 
200 public:
201  TProofDrawProfile2D() : fProfile(0) { }
202  virtual void Init(TTree *);
203  virtual void Begin(TTree *t);
204  virtual void SlaveBegin(TTree *);
205  virtual void Terminate();
206 
207  ClassDef(TProofDrawProfile2D,0) //Tree drawing selector for PROOF
208 };
209 
210 
211 class TProofDrawGraph : public TProofDraw {
212 
213 protected:
215 
216  virtual void DoFill(Long64_t entry, Double_t w, const Double_t *v);
217  virtual void DefVar() { }
218 
219 public:
220  TProofDrawGraph() : fGraph(0) { }
221  virtual void Init(TTree *tree);
222  virtual void SlaveBegin(TTree *);
223  virtual void Terminate();
224 
225  ClassDef(TProofDrawGraph,0) //Tree drawing selector for PROOF
226 };
227 
228 
230 
231 protected:
233 
234  virtual void DoFill(Long64_t entry, Double_t w, const Double_t *v);
235  virtual void DefVar() { }
236 
237 public:
238  TProofDrawPolyMarker3D() : fPolyMarker3D(0) { }
239  virtual void Init(TTree *tree);
240  virtual void SlaveBegin(TTree *);
241  virtual void Terminate();
242 
243  ClassDef(TProofDrawPolyMarker3D,0) //Tree drawing selector for PROOF
244 };
245 
246 template <typename T>
248  // Owns an std::vector<T>.
249  // Implements Merge(TCollection*) which merges vectors holded
250  // by all the TProofVectorContainers in the collection.
251 protected:
252  std::vector<T> *fVector; // vector
253 
254 public:
255  TProofVectorContainer(std::vector<T>* anVector) : fVector(anVector) { }
256  TProofVectorContainer() : fVector(0) { }
257  ~TProofVectorContainer() { delete fVector; }
258 
259  std::vector<T> *GetVector() const { return fVector; }
260  Long64_t Merge(TCollection* list);
261 
262  ClassDef(TProofVectorContainer,1) //Class describing a vector container
263 };
264 
266 
267 public:
268  struct Point3D_t {
269  public:
270  Double_t fX, fY, fZ;
271  Point3D_t(Double_t x, Double_t y, Double_t z) : fX(x), fY(y), fZ(z) { }
272  Point3D_t() : fX(0), fY(0), fZ(0) { }
273  };
274 
275 protected:
277  virtual void DoFill(Long64_t entry, Double_t w, const Double_t *v);
278  virtual void DefVar() { }
279 
280 public:
281  TProofDrawListOfGraphs() : fPoints(0) { }
282  virtual void SlaveBegin(TTree *);
283  virtual void Terminate();
284 
285  ClassDef(TProofDrawListOfGraphs,0) //Tree drawing selector for PROOF
286 };
287 
288 
290 
291 public:
292  struct Point4D_t {
293  public:
294  Double_t fX, fY, fZ, fT;
295  Point4D_t(Double_t x, Double_t y, Double_t z, Double_t t) : fX(x), fY(y), fZ(z), fT(t) { }
296  Point4D_t() : fX(0), fY(0), fZ(0), fT(0) { }
297  };
298 
299 protected:
301  virtual void DoFill(Long64_t entry, Double_t w, const Double_t *v);
302  virtual void DefVar() { }
303 
304 public:
305  TProofDrawListOfPolyMarkers3D() : fPoints(0) { }
306  virtual void SlaveBegin(TTree *);
307  virtual void Terminate();
308 
309  ClassDef(TProofDrawListOfPolyMarkers3D,0) //Tree drawing selector for PROOF
310 };
311 
312 #ifndef __CINT__
313 template <typename T>
315 {
316  // Adds all vectors holded by all TProofVectorContainers in the collection
317  // the vector holded by this TProofVectorContainer.
318  // Returns the total number of poins in the result or -1 in case of an error.
319 
320  TIter next(li);
321 
322  std::back_insert_iterator<std::vector<T> > ii(*fVector);
323  while (TObject* o = next()) {
324  TProofVectorContainer<T> *vh = dynamic_cast<TProofVectorContainer<T>*> (o);
325  if (!vh) {
326  Error("Merge",
327  "Cannot merge - an object which doesn't inherit from TProofVectorContainer<T> found in the list");
328  return -1;
329  }
330  std::copy(vh->GetVector()->begin(), vh->GetVector()->end(), ii);
331  }
332  return fVector->size();
333 }
334 #endif
335 
336 #endif
TEntryList * fElist
Definition: TProofDraw.h:155
virtual void Begin(TTree *)
Executed by the client before processing.
Definition: TProofDraw.cxx:172
Double_t fWeight
Definition: TProofDraw.h:73
virtual void DoFill(Long64_t entry, Double_t w, const Double_t *v)=0
Int_t fMultiplicity
Definition: TProofDraw.h:70
Internal class steering processing in PROOF.
Definition: TProofPlayer.h:78
TString fSelection
Definition: TProofDraw.h:64
long long Long64_t
Definition: RtypesCore.h:69
virtual void SlaveBegin(TTree *)
Executed by each slave before processing.
Definition: TProofDraw.cxx:196
virtual void DefVar()
Definition: TProofDraw.h:278
virtual void ClearFormula()
Delete internal buffers.
Definition: TProofDraw.cxx:294
void SetDrawAtt(TObject *o)
Set the drawing attributes from the input list.
Definition: TProofDraw.cxx:326
#define BIT(n)
Definition: Rtypes.h:120
void SetError(const char *sub, const char *mesg)
Sets the error status.
Definition: TProofDraw.cxx:383
TString fInitialExp
Definition: TProofDraw.h:65
virtual void DefVar()
Definition: TProofDraw.h:158
TStatus * fStatus
Definition: TProofDraw.h:63
Implement Tree drawing using PROOF.
Definition: TProofDraw.h:57
Basic string class.
Definition: TString.h:137
Int_t fDimension
Definition: TProofDraw.h:72
virtual void Init(TTree *)
Init the tree.
Definition: TProofDraw.cxx:141
int Int_t
Definition: RtypesCore.h:41
virtual void DefVar()
Definition: TProofDraw.h:217
bool Bool_t
Definition: RtypesCore.h:59
TEventList * fElist
Definition: TProofDraw.h:135
Profile Historam.
Definition: TProfile.h:34
TProofVectorContainer< Point4D_t > * fPoints
Definition: TProofDraw.h:300
virtual void SlaveTerminate()
Executed by each slave after the processing has finished, before returning the results to the client...
Definition: TProofDraw.cxx:264
TTreeFormula * fVar[4]
Definition: TProofDraw.h:68
TTree * fTree
Definition: TProofDraw.h:67
virtual void DefVar()
Definition: TProofDraw.h:235
Double_t x[n]
Definition: legend1.C:17
Used to coordinate one or more TTreeFormula objects.
#define ClassDef(name, id)
Definition: Rtypes.h:254
This class holds the status of an ongoing operation and collects error messages.
Definition: TStatus.h:39
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TProofDraw()
Constructor.
Definition: TProofDraw.cxx:113
TProofVectorContainer(std::vector< T > *anVector)
Definition: TProofDraw.h:255
virtual Bool_t Process(Long64_t)
Executed for each entry.
Definition: TProofDraw.cxx:244
TPolyMarker3D * fPolyMarker3D
Definition: TProofDraw.h:232
TTreeFormula * fSelect
Definition: TProofDraw.h:69
Used to pass a selection expression to the Tree drawing routine.
Definition: TTreeFormula.h:64
TTreeFormulaManager * fManager
Definition: TProofDraw.h:66
A doubly linked list.
Definition: TList.h:47
Point4D_t(Double_t x, Double_t y, Double_t z, Double_t t)
Definition: TProofDraw.h:295
Long64_t Merge(TCollection *list)
Definition: TProofDraw.h:314
TProfile2D * fProfile
Definition: TProofDraw.h:195
virtual Bool_t Notify()
Called when a new tree is loaded.
Definition: TProofDraw.cxx:152
SVector< double, 2 > v
Definition: Dict.h:5
TH1 * fHistogram
Definition: TProofDraw.h:113
std::vector< T > * fVector
Definition: TProofDraw.h:252
Collection abstract base class.
Definition: TCollection.h:48
TProofVectorContainer< Point3D_t > * fPoints
Definition: TProofDraw.h:276
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:925
A TEventList object is a list of selected events (entries) in a TTree.
Definition: TEventList.h:33
void SetCanvas(const char *objname)
Move to a canvas named <name>_canvas; create the canvas if not existing.
Definition: TProofDraw.cxx:310
Bool_t fObjEval
Definition: TProofDraw.h:71
std::vector< T > * GetVector() const
Definition: TProofDraw.h:259
Point3D_t(Double_t x, Double_t y, Double_t z)
Definition: TProofDraw.h:271
virtual void Terminate()
Executed by the client after getting the processing retults.
Definition: TProofDraw.cxx:273
double Double_t
Definition: RtypesCore.h:55
virtual Bool_t CompileVariables()
Compiles each variable from fTreeDrawArgsParser for the tree fTree.
Definition: TProofDraw.cxx:403
virtual int Version() const
Definition: TProofDraw.h:92
Double_t y[n]
Definition: legend1.C:17
The TH1 histogram class.
Definition: TH1.h:80
void FillWeight()
Get weight from input list, if any.
Definition: TProofDraw.cxx:205
Profile2D histograms are used to display the mean value of Z and its RMS for each cell in X...
Definition: TProfile2D.h:31
TTreeDrawArgsParser fTreeDrawArgsParser
Definition: TProofDraw.h:62
A class that parses all parameters for TTree::Draw().
virtual ~TProofDraw()
Destructor.
Definition: TProofDraw.cxx:132
Mother of all ROOT objects.
Definition: TObject.h:37
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
virtual void DefVar()=0
A 3D polymarker.
Definition: TPolyMarker3D.h:40
virtual Bool_t ProcessSingle(Long64_t, Int_t)
Processes a single variable from an entry.
Definition: TProofDraw.cxx:217
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:53
TGraph * fGraph
Definition: TProofDraw.h:214
virtual void DefVar()
Definition: TProofDraw.h:139
Definition: tree.py:1
TProfile * fProfile
Definition: TProofDraw.h:176
A TTree object has a header with a name and a title.
Definition: TTree.h:98
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:39
A List of entry numbers in a TTree or TChain.
Definition: TEntryList.h:27