ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TProofChain.cxx
Go to the documentation of this file.
1 
2 // @(#)root/proof:$Id$
3 // Author: G. Ganis Nov 2006
4 
5 /*************************************************************************
6  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
7  * All rights reserved. *
8  * *
9  * For the licensing terms see $ROOTSYS/LICENSE. *
10  * For the list of contributors see $ROOTSYS/README/CREDITS. *
11  *************************************************************************/
12 
13 //////////////////////////////////////////////////////////////////////////
14 // //
15 // TProofChain //
16 // //
17 // A TChain proxy on PROOF. //
18 // Uses an internal TDSet to handle processing. //
19 // //
20 //////////////////////////////////////////////////////////////////////////
21 
22 #include "TProofChain.h"
23 #include "TDSet.h"
24 #include "TList.h"
25 #include "TProof.h"
26 #include "TROOT.h"
27 #include "TEventList.h"
28 #include "TEntryList.h"
29 
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// Crates a new PROOF chain proxy.
34 
36 {
37  fChain = 0;
38  fTree = 0;
39  fSet = 0;
40  fDirectory = gDirectory;
41  ResetBit(kOwnsChain);
42 }
43 
44 ////////////////////////////////////////////////////////////////////////////////
45 /// Crates a new PROOF chain proxy containing the files from the chain.
46 
48 {
49  fChain = chain;
50  fTree = 0;
51  fSet = chain ? new TDSet((const TChain &)(*chain)) : 0;
53  if (gProof) {
54  gProof->AddChain(chain);
55  ConnectProof();
56  if (gProof->IsLite()) {
58  fTree = fChain;
59  } else {
60  if (gettreeheader && fSet)
62  }
63  }
65 }
66 
67 ////////////////////////////////////////////////////////////////////////////////
68 /// Creates a new PROOF chain proxy containing the files from the dset.
69 
70 TProofChain::TProofChain(TDSet *dset, Bool_t gettreeheader) : TChain()
71 {
72  fChain = 0;
73  fTree = 0;
74  fSet = dset;
76  if (gProof) {
77  ConnectProof();
78  if (gettreeheader && dset)
79  fTree = gProof->GetTreeHeader(dset);
80  if (gProof->IsLite())
82  }
83  if (fTree && fSet) {
84  fChain = new TChain(fTree->GetName());
86  TDSetElement *e = 0;
87  while ((e = (TDSetElement *) nxe())) {
88  fChain->AddFile(e->GetName());
89  }
91  if (TestBit(kProofLite))
92  fTree = fChain;
93  }
94 }
95 
96 ////////////////////////////////////////////////////////////////////////////////
97 /// Destructor.
98 
100 {
101  if (fChain) {
102  SafeDelete(fSet);
103  // Remove the chain from the private lists in the TProof objects
104  TIter nxp(gROOT->GetListOfSockets());
105  TObject *o = 0;
106  TProof *p = 0;
107  while ((o = nxp()))
108  if ((p = dynamic_cast<TProof *>(o)))
109  p->RemoveChain(fChain);
110  if (fTree == fChain) fTree = 0;
111  if (TestBit(kOwnsChain)) {
113  } else {
114  fChain = 0;
115  }
116  } else {
117  // Not owner
118  fSet = 0;
119  }
120  SafeDelete(fTree);
121  fDirectory = 0;
122 
123 }
124 
125 ////////////////////////////////////////////////////////////////////////////////
126 /// Forwards the execution to the dummy tree header.
127 /// See TTree::Browse().
128 
130 {
131  fSet->Browse(b);
132 }
133 
134 ////////////////////////////////////////////////////////////////////////////////
135 /// Forwards the execution to the TDSet.
136 /// Returns -1 in case of error or number of selected events in case of success.
137 /// See TDSet::Browse().
138 
139 Long64_t TProofChain::Draw(const char *varexp, const TCut &selection,
140  Option_t *option, Long64_t nentries, Long64_t firstentry)
141 {
142  if (!gProof) {
143  Error("Draw", "no active PROOF session");
144  return -1;
145  }
146  ConnectProof();
147 
148  fReadEntry = firstentry;
149 
150  // Set either the entry-list (priority) or the event-list
151  if (fEntryList) {
153  } else if (fEventList) {
155  }
156 
157  // Fill drawing attributes
159 
160  // Add alias information, if any
161  AddAliases();
162 
163  Long64_t rv = fSet->Draw(varexp, selection, option, nentries, firstentry);
164  return rv;
165 }
166 
167 ////////////////////////////////////////////////////////////////////////////////
168 /// Forwards the execution to the TDSet.
169 /// Returns -1 in case of error or number of selected events in case of success.
170 /// See TDSet::Browse().
171 
172 Long64_t TProofChain::Draw(const char *varexp, const char *selection,
173  Option_t *option,Long64_t nentries, Long64_t firstentry)
174 {
175  if (!gProof) {
176  Error("Draw", "no active PROOF session");
177  return -1;
178  }
179  ConnectProof();
180 
181  fReadEntry = firstentry;
182 
183  // Set either the entry-list (priority) or the event-list
184  if (fEntryList) {
186  } else if (fEventList) {
188  }
189 
190  // Fill drawing attributes
192 
193  // Add alias information, if any
194  AddAliases();
195 
196  Long64_t rv = fSet->Draw(varexp, selection, option, nentries, firstentry);
197  return rv;
198 }
199 
200 ////////////////////////////////////////////////////////////////////////////////
201 /// Aliases are added to the input list. The names are comma-separated in the
202 /// TNamed 'PROOF_ListOfAliases'. For each name, there is an trey named 'alias:<name>'.
203 
205 {
206  TList *al = fChain->GetListOfAliases();
207  if (al && al->GetSize() > 0) {
208  TIter nxa(al);
209  TNamed *nm = 0, *nmo = 0;
210  TString names, nma;
211  while ((nm = (TNamed *)nxa())) {
212  names += nm->GetName();
213  names += ",";
214  nma.Form("alias:%s", nm->GetName());
215  nmo = (TNamed *)((gProof->GetInputList()) ? gProof->GetInputList()->FindObject(nma) : 0);
216  if (nmo) {
217  nmo->SetTitle(nm->GetTitle());
218  } else {
219  gProof->AddInput(new TNamed(nma.Data(), nm->GetTitle()));
220  }
221  }
222  nmo = (TNamed *)((gProof->GetInputList()) ? gProof->GetInputList()->FindObject("PROOF_ListOfAliases") : 0);
223  if (nmo) {
224  nmo->SetTitle(names.Data());
225  } else {
226  gProof->AddInput(new TNamed("PROOF_ListOfAliases", names.Data()));
227  }
228  }
229 }
230 
231 ////////////////////////////////////////////////////////////////////////////////
232 /// Communicate the drawing attributes for this chain to the input list
233 /// so that the draw selectors can use them, in case of need.
234 /// The drawing attributes are:
235 ///
236 /// LineColor Line color
237 /// LineStyle Line style
238 /// LineWidth Line width
239 /// MarkerColor Marker color index
240 /// MarkerSize Marker size
241 /// MarkerStyle Marker style
242 /// FillColor Area fill color
243 /// FillStyle Area fill style
244 
246 {
247  if (!p || !fChain) {
248  Error("FillDrawAttributes", "invalid PROOF or mother chain pointers!");
249  return;
250  }
251 
252  // Weight
253  p->SetParameter("PROOF_ChainWeight", fChain->GetWeight());
254 
255  // Line Attributes
256  p->SetParameter("PROOF_LineColor", (Int_t) fChain->GetLineColor());
257  p->SetParameter("PROOF_LineStyle", (Int_t) fChain->GetLineStyle());
258  p->SetParameter("PROOF_LineWidth", (Int_t) fChain->GetLineWidth());
259 
260  // Marker Attributes
261  p->SetParameter("PROOF_MarkerColor", (Int_t) fChain->GetMarkerColor());
262  p->SetParameter("PROOF_MarkerSize", (Int_t) fChain->GetMarkerSize()*1000);
263  p->SetParameter("PROOF_MarkerStyle", (Int_t) fChain->GetMarkerStyle());
264 
265  // Area fill attributes
266  p->SetParameter("PROOF_FillColor", (Int_t) fChain->GetFillColor());
267  p->SetParameter("PROOF_FillStyle", (Int_t) fChain->GetFillStyle());
268 
269  if (gDebug > 0) {
270  Info("FillDrawAttributes","line: color:%d, style:%d, width:%d",
272  Info("FillDrawAttributes","marker: color:%d, style:%d, size:%f",
274  Info("FillDrawAttributes","area: color:%d, style:%d",
276  }
277 }
278 
279 ////////////////////////////////////////////////////////////////////////////////
280 /// Forwards the execution to the dummy tree header.
281 /// See TTree::FindBranch().
282 
283 TBranch *TProofChain::FindBranch(const char* branchname)
284 {
285  return (fTree ? fTree->FindBranch(branchname) : (TBranch *)0);
286 }
287 
288 ////////////////////////////////////////////////////////////////////////////////
289 /// Forwards the execution to the dummy tree header.
290 /// See TTree::FindLeaf().
291 
292 TLeaf *TProofChain::FindLeaf(const char* searchname)
293 {
294  return (fTree ? fTree->FindLeaf(searchname) : (TLeaf *)0);
295 }
296 
297 ////////////////////////////////////////////////////////////////////////////////
298 /// Forwards the execution to the dummy tree header.
299 /// See TTree::GetBranch().
300 
302 {
303  return (fTree ? fTree->GetBranch(name) : (TBranch *)0);
304 }
305 
306 ////////////////////////////////////////////////////////////////////////////////
307 /// Forwards the execution to the dummy tree header.
308 /// See TTree::GetBranchStatus().
309 
310 Bool_t TProofChain::GetBranchStatus(const char *branchname) const
311 {
312  return (fTree ? fTree->GetBranchStatus(branchname) : kFALSE);
313 }
314 
315 ////////////////////////////////////////////////////////////////////////////////
316 /// Forwards the execution to the dummy tree header.
317 /// See TTree::GetPlayer().
318 
320 {
321  return (fTree ? fTree->GetPlayer() : (TVirtualTreePlayer *)0);
322 }
323 
324 ////////////////////////////////////////////////////////////////////////////////
325 /// Forwards the execution to the TDSet.
326 /// The return value is -1 in case of error and TSelector::GetStatus() in
327 /// in case of success.
328 /// See TDSet::Process().
329 
331  Long64_t nentries, Long64_t firstentry)
332 {
333  // Set either the entry-list (priority) or the event-list
334  if (fEntryList) {
336  } else if (fEventList) {
338  }
339 
340  return fSet->Process(filename, option, nentries, firstentry);
341 }
342 
343 ////////////////////////////////////////////////////////////////////////////////
344 /// The return value is -1 in case of error and TSelector::GetStatus() in
345 /// in case of success.
346 
348  Long64_t nentries, Long64_t firstentry)
349 {
350  // Set either the entry-list (priority) or the event-list
351  if (fEntryList) {
353  } else if (fEventList) {
355  }
356 
357  return fSet->Process(selector, option, nentries, firstentry);
358 }
359 
360 ////////////////////////////////////////////////////////////////////////////////
361 /// See TTree::SetDebug
362 
364 {
365  TTree::SetDebug(level, min, max);
366 }
367 
368 ////////////////////////////////////////////////////////////////////////////////
369 /// See TTree::GetName.
370 
371 void TProofChain::SetName(const char *name)
372 {
373  TTree::SetName(name);
374 }
375 
376 ////////////////////////////////////////////////////////////////////////////////
377 /// Returns the total number of entries in the TProofChain, which is
378 /// the number of entries in the TDSet that it holds.
379 
381 {
382  // this was used for holding the total number of entries
383  if (TestBit(kProofLite)) {
384  return (fTree ? fTree->GetEntries() : (Long64_t)(-1));
385  } else {
386  return (fTree ? fTree->GetMaxEntryLoop() : (Long64_t)(-1));
387  }
388 }
389 
390 ////////////////////////////////////////////////////////////////////////////////
391 /// See TTree::GetEntries(const char *selection)
392 /// Not implemented in TProofChain. Shouldn't be used.
393 
394 Long64_t TProofChain::GetEntries(const char *selection)
395 {
396  if (TestBit(kProofLite)) {
397  return (fTree ? fTree->GetEntries(selection) : (Long64_t)(-1));
398  } else {
399  Warning("GetEntries", "GetEntries(selection) not yet implemented");
400  return ((Long64_t)(-1));
401  }
402 }
403 
404 ////////////////////////////////////////////////////////////////////////////////
405 /// Changes the number of processed entries.
406 
408 {
409  if (gROOT->IsInterrupted() && gProof)
411  if (total) { }
412 
413  fReadEntry = processed;
414 }
415 
416 ////////////////////////////////////////////////////////////////////////////////
417 /// Returns the number of processed entries.
418 
420 {
421  return fReadEntry;
422 }
423 
424 ////////////////////////////////////////////////////////////////////////////////
425 /// Releases PROOF. Disconnect the "progress" signal.
426 
428 {
429  if (!gProof)
430  return;
431  gProof->Disconnect("Progress(Long64_t,Long64_t)",
432  this, "Progress(Long64_t,Long64_t)");
433 }
434 
435 ////////////////////////////////////////////////////////////////////////////////
436 /// Connects the proof "Progress" signal.
437 
439 {
440  if (gProof)
441  gProof->Connect("Progress(Long64_t,Long64_t)", "TProofChain",
442  this, "Progress(Long64_t,Long64_t)");
443 }
virtual TBranch * FindBranch(const char *name)
Return the branch that correspond to the path 'branchname', which can include the name of the tree or...
Definition: TTree.cxx:4492
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
virtual Style_t GetLineStyle() const
Definition: TAttLine.h:48
virtual Style_t GetFillStyle() const
Definition: TAttFill.h:44
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition: TLeaf.h:37
virtual TList * GetListOfAliases() const
Definition: TTree.h:412
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
TChain * fChain
Definition: TProofChain.h:44
long long Long64_t
Definition: RtypesCore.h:69
void RemoveChain(TChain *chain)
Remove chain from data set.
Definition: TProof.cxx:10809
const char Option_t
Definition: RtypesCore.h:62
virtual Double_t GetWeight() const
Return the chain weight.
Definition: TChain.cxx:1176
virtual Long64_t Process(TSelector *selector, Option_t *option="", Long64_t nentries=-1, Long64_t firstentry=0, TObject *enl=0)
Process TDSet on currently active PROOF session.
Definition: TDSet.cxx:897
This class implements a data set to be used for PROOF processing.
Definition: TDSet.h:153
void SetParameter(const char *par, const char *value)
Set input list parameter.
Definition: TProof.cxx:10400
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
virtual void SetDebug(Int_t level=1, Long64_t min=0, Long64_t max=9999999)
See TTree::SetDebug.
TDirectory * fDirectory
Object to be notified when loading a Tree.
Definition: TTree.h:133
static const char * filename()
#define gROOT
Definition: TROOT.h:344
Basic string class.
Definition: TString.h:137
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition: TObject.cxx:178
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void ConnectProof()
Connects the proof "Progress" signal.
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:497
virtual Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=TTree::kMaxEntries, Long64_t firstentry=0)
Forwards the execution to the TDSet.
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition: TTree.cxx:5634
virtual TBranch * GetBranch(const char *name)
Forwards the execution to the dummy tree header.
TTree * fTree
If true, TProcessIDs are deleted when closing a file.
Definition: TChain.h:43
virtual void Progress(Long64_t total, Long64_t processed)
Changes the number of processed entries.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:732
TChain chain("h42")
virtual void Browse(TBrowser *b)
Forwards the execution to the dummy tree header.
const char * Data() const
Definition: TString.h:349
Manages an element of a TDSet.
Definition: TDSet.h:68
#define SafeDelete(p)
Definition: RConfig.h:436
void StopProcess(Bool_t abort, Int_t timeout=-1)
Send STOPPROCESS message to master and workers.
Definition: TProof.cxx:6222
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
void FillDrawAttributes(TProof *p)
Communicate the drawing attributes for this chain to the input list so that the draw selectors can us...
TList * GetListOfElements() const
Definition: TDSet.h:231
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
Bool_t IsLite() const
Definition: TProof.h:969
virtual void ReleaseProof()
Releases PROOF. Disconnect the "progress" signal.
A specialized string object used for TTree selections.
Definition: TCut.h:27
A doubly linked list.
Definition: TList.h:47
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition: TTree.cxx:4803
void AddChain(TChain *chain)
Add chain to data set.
Definition: TProof.cxx:10801
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
Definition: TQObject.cxx:1135
TEntryList * fEntryList
Pointer to event selection list (if one)
Definition: TTree.h:138
virtual Long64_t Draw(const char *varexp, const TCut &selection, Option_t *option="", Long64_t nentries=TTree::kMaxEntries, Long64_t firstentry=0)
Forwards the execution to the TDSet.
virtual Size_t GetMarkerSize() const
Definition: TAttMarker.h:46
virtual Long64_t GetMaxEntryLoop() const
Definition: TTree.h:418
Long64_t fReadEntry
Offset of 1st entry of this Tree in a TChain.
Definition: TTree.h:123
virtual Color_t GetFillColor() const
Definition: TAttFill.h:43
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2308
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
virtual void SetName(const char *name)
See TTree::GetName.
virtual TLeaf * FindLeaf(const char *name)
Find leaf..
Definition: TTree.cxx:4564
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
virtual Long64_t Draw(const char *varexp, const char *selection, Option_t *option="", Long64_t nentries=-1, Long64_t firstentry=0)
Draw expression varexp for specified entries.
Definition: TDSet.cxx:1479
virtual Color_t GetLineColor() const
Definition: TAttLine.h:47
TEventList * fEventList
Definition: TTree.h:137
void AddInput(TObject *obj)
Add objects that might be needed during the processing of the selector (see Process()).
Definition: TProof.cxx:10312
TH1F * total
Definition: threadsh2.C:15
virtual Int_t AddFile(const char *name, Long64_t nentries=TTree::kMaxEntries, const char *tname="")
Add a new file to this chain.
Definition: TChain.cxx:433
virtual void SetDebug(Int_t level=1, Long64_t min=0, Long64_t max=9999999)
Set the debug level and the debug range.
Definition: TTree.cxx:8026
TVirtualTreePlayer * GetPlayer()
Forwards the execution to the dummy tree header.
virtual Long64_t GetReadEntry() const
Returns the number of processed entries.
TList * GetInputList()
Get input list.
Definition: TProof.cxx:10331
R__EXTERN TProof * gProof
Definition: TProof.h:1113
virtual Int_t GetSize() const
Definition: TCollection.h:95
virtual ~TProofChain()
Destructor.
Definition: TProofChain.cxx:99
virtual TBranch * FindBranch(const char *name)
Forwards the execution to the dummy tree header.
virtual void SetEntryList(TObject *aList)
Set entry (or event) list for this data set.
Definition: TDSet.cxx:1872
ClassImp(TProofChain) TProofChain
Crates a new PROOF chain proxy.
Definition: TProofChain.cxx:30
TNamed()
Definition: TNamed.h:40
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition: TProof.h:342
int nentries
Definition: THbookFile.cxx:89
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
Definition: TQObject.cxx:1293
virtual TTree * GetTreeHeader(TDSet *tdset)
Creates a tree header (a tree with nonexisting files) object for the DataSet.
Definition: TProof.cxx:10620
virtual Bool_t GetBranchStatus(const char *branchname) const
Forwards the execution to the dummy tree header.
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
void AddAliases()
Aliases are added to the input list.
virtual Color_t GetMarkerColor() const
Definition: TAttMarker.h:44
Abstract base class defining the interface for the plugins that implement Draw, Scan, Process, MakeProxy, etc.
A chain is a collection of files containg TTree objects.
Definition: TChain.h:35
virtual Long64_t GetEntries() const
Returns the total number of entries in the TProofChain, which is the number of entries in the TDSet t...
TDSet * fSet
Definition: TProofChain.h:45
R__EXTERN Int_t gDebug
Definition: Rtypes.h:128
virtual Long64_t GetEntries() const
Definition: TTree.h:386
#define gDirectory
Definition: TDirectory.h:221
void ResetBit(UInt_t f)
Definition: TObject.h:172
A TTree is a list of TBranches.
Definition: TBranch.h:58
virtual Bool_t GetBranchStatus(const char *branchname) const
Return status of branch with name branchname.
Definition: TTree.cxx:4899
virtual Style_t GetMarkerStyle() const
Definition: TAttMarker.h:45
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:39
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual Width_t GetLineWidth() const
Definition: TAttLine.h:49
virtual void SetName(const char *name)
Change the name of this tree.
Definition: TTree.cxx:8269
virtual TLeaf * FindLeaf(const char *name)
Forwards the execution to the dummy tree header.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904