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