Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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;
36 class TTreeFormulaManager;
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:
54  TTreeDrawArgsParser fTreeDrawArgsParser;
55  TStatus *fStatus;
56  TString fSelection;
57  TString fInitialExp;
58  TTreeFormulaManager *fManager;
59  TTree *fTree;
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:
105  TH1 *fHistogram;
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 
124 class TProofDrawEventList : public TProofDraw {
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) {}
135  ~TProofDrawEventList() {}
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 
145 class TProofDrawEntryList : public TProofDraw {
146  protected:
147  TEntryList *fElist;
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) {}
154  ~TProofDrawEntryList() {}
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 
165 class TProofDrawProfile : public TProofDraw {
166 
167 protected:
168  TProfile *fProfile;
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 
184 class TProofDrawProfile2D : public TProofDraw {
185 
186 protected:
187  TProfile2D *fProfile;
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:
206  TGraph *fGraph;
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 
221 class TProofDrawPolyMarker3D : public TProofDraw {
222 
223 protected:
224  TPolyMarker3D *fPolyMarker3D;
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>
239 class TProofVectorContainer : public TNamed {
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 
257 class TProofDrawListOfGraphs : public TProofDraw {
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:
268  TProofVectorContainer<Point3D_t> *fPoints;
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 
281 class TProofDrawListOfPolyMarkers3D : public TProofDraw {
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:
292  TProofVectorContainer<Point4D_t> *fPoints;
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>
306 Long64_t TProofVectorContainer<T>::Merge(TCollection* li)
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