Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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;
42}
43
44////////////////////////////////////////////////////////////////////////////////
45/// Crates a new PROOF chain proxy containing the files from the chain.
46
47TProofChain::TProofChain(TChain *chain, Bool_t gettreeheader) : TChain()
48{
49 fChain = chain;
50 fTree = 0;
51 fSet = chain ? new TDSet((const TChain &)(*chain)) : 0;
53 if (gProof) {
54 gProof->AddChain(chain);
56 if (gProof->IsLite()) {
58 fTree = fChain;
59 } else {
60 if (gettreeheader && fSet)
62 }
63 }
65 fEntryList = (chain) ? chain->GetEntryList() : 0;
66 fEventList = (chain) ? chain->GetEventList() : 0;
67}
68
69////////////////////////////////////////////////////////////////////////////////
70/// Creates a new PROOF chain proxy containing the files from the dset.
71
73{
74 fChain = 0;
75 fTree = 0;
76 fSet = dset;
78 if (gProof) {
80 if (gettreeheader && dset)
81 fTree = gProof->GetTreeHeader(dset);
82 if (gProof->IsLite())
84 }
85 if (fTree && fSet) {
86 fChain = new TChain(fTree->GetName());
88 TDSetElement *e = 0;
89 while ((e = (TDSetElement *) nxe())) {
90 fChain->AddFile(e->GetName());
91 }
94 fTree = fChain;
95 }
96 TObject *en = (dset) ? dset->GetEntryList() : 0;
97 if (en) {
98 if (en->InheritsFrom("TEntryList")) {
99 fEntryList = (TEntryList *) en;
100 } else {
101 fEventList = (TEventList *) en;
102 }
103 }
104}
105
106////////////////////////////////////////////////////////////////////////////////
107/// Destructor.
108
110{
111 if (fChain) {
113 // Remove the chain from the private lists in the TProof objects
114 TIter nxp(gROOT->GetListOfSockets());
115 TObject *o = 0;
116 TProof *p = 0;
117 while ((o = nxp()))
118 if ((p = dynamic_cast<TProof *>(o)))
120 if (fTree == fChain) fTree = 0;
121 if (TestBit(kOwnsChain)) {
123 } else {
124 fChain = 0;
125 }
126 } else {
127 // Not owner
128 fSet = 0;
129 }
131 fDirectory = 0;
132
133}
134
135////////////////////////////////////////////////////////////////////////////////
136/// Forwards the execution to the dummy tree header.
137/// See TTree::Browse().
138
140{
141 fSet->Browse(b);
142}
143
144////////////////////////////////////////////////////////////////////////////////
145/// Forwards the execution to the TDSet.
146/// Returns -1 in case of error or number of selected events in case of success.
147/// See TDSet::Browse().
148
149Long64_t TProofChain::Draw(const char *varexp, const TCut &selection,
150 Option_t *option, Long64_t nentries, Long64_t firstentry)
151{
152 if (!gProof) {
153 Error("Draw", "no active PROOF session");
154 return -1;
155 }
156 ConnectProof();
157
158 fReadEntry = firstentry;
159
160 // Set either the entry-list (priority) or the event-list
161 if (fEntryList) {
163 } else if (fEventList) {
165 } else {
166 // Disable previous settings, if any
167 fSet->SetEntryList(0);
168 }
169
170 // Fill drawing attributes
172
173 // Add alias information, if any
174 AddAliases();
175
176 Long64_t rv = fSet->Draw(varexp, selection, option, nentries, firstentry);
177 return rv;
178}
179
180////////////////////////////////////////////////////////////////////////////////
181/// Forwards the execution to the TDSet.
182/// Returns -1 in case of error or number of selected events in case of success.
183/// See TDSet::Browse().
184
185Long64_t TProofChain::Draw(const char *varexp, const char *selection,
186 Option_t *option,Long64_t nentries, Long64_t firstentry)
187{
188 if (!gProof) {
189 Error("Draw", "no active PROOF session");
190 return -1;
191 }
192 ConnectProof();
193
194 fReadEntry = firstentry;
195
196 // Set either the entry-list (priority) or the event-list
197 if (fEntryList) {
199 } else if (fEventList) {
201 } else {
202 // Disable previous settings, if any
203 fSet->SetEntryList(0);
204 }
205
206 // Fill drawing attributes
208
209 // Add alias information, if any
210 AddAliases();
211
212 Long64_t rv = fSet->Draw(varexp, selection, option, nentries, firstentry);
213 return rv;
214}
215
216////////////////////////////////////////////////////////////////////////////////
217/// Aliases are added to the input list. The names are comma-separated in the
218/// TNamed 'PROOF_ListOfAliases'. For each name, there is an trey named 'alias:<name>'.
219
221{
223 if (al && al->GetSize() > 0) {
224 TIter nxa(al);
225 TNamed *nm = 0, *nmo = 0;
226 TString names, nma;
227 while ((nm = (TNamed *)nxa())) {
228 names += nm->GetName();
229 names += ",";
230 nma.Form("alias:%s", nm->GetName());
231 nmo = (TNamed *)((gProof->GetInputList()) ? gProof->GetInputList()->FindObject(nma) : 0);
232 if (nmo) {
233 nmo->SetTitle(nm->GetTitle());
234 } else {
235 gProof->AddInput(new TNamed(nma.Data(), nm->GetTitle()));
236 }
237 }
238 nmo = (TNamed *)((gProof->GetInputList()) ? gProof->GetInputList()->FindObject("PROOF_ListOfAliases") : 0);
239 if (nmo) {
240 nmo->SetTitle(names.Data());
241 } else {
242 gProof->AddInput(new TNamed("PROOF_ListOfAliases", names.Data()));
243 }
244 }
245}
246
247////////////////////////////////////////////////////////////////////////////////
248/// Communicate the drawing attributes for this chain to the input list
249/// so that the draw selectors can use them, in case of need.
250/// The drawing attributes are:
251///
252/// LineColor Line color
253/// LineStyle Line style
254/// LineWidth Line width
255/// MarkerColor Marker color index
256/// MarkerSize Marker size
257/// MarkerStyle Marker style
258/// FillColor Area fill color
259/// FillStyle Area fill style
260
262{
263 if (!p || !fChain) {
264 Error("FillDrawAttributes", "invalid PROOF or mother chain pointers!");
265 return;
266 }
267
268 // Weight
269 p->SetParameter("PROOF_ChainWeight", fChain->GetWeight());
270
271 // Line Attributes
272 p->SetParameter("PROOF_LineColor", (Int_t) fChain->GetLineColor());
273 p->SetParameter("PROOF_LineStyle", (Int_t) fChain->GetLineStyle());
274 p->SetParameter("PROOF_LineWidth", (Int_t) fChain->GetLineWidth());
275
276 // Marker Attributes
277 p->SetParameter("PROOF_MarkerColor", (Int_t) fChain->GetMarkerColor());
278 p->SetParameter("PROOF_MarkerSize", (Int_t) fChain->GetMarkerSize()*1000);
279 p->SetParameter("PROOF_MarkerStyle", (Int_t) fChain->GetMarkerStyle());
280
281 // Area fill attributes
282 p->SetParameter("PROOF_FillColor", (Int_t) fChain->GetFillColor());
283 p->SetParameter("PROOF_FillStyle", (Int_t) fChain->GetFillStyle());
284
285 if (gDebug > 0) {
286 Info("FillDrawAttributes","line: color:%d, style:%d, width:%d",
288 Info("FillDrawAttributes","marker: color:%d, style:%d, size:%f",
290 Info("FillDrawAttributes","area: color:%d, style:%d",
292 }
293}
294
295////////////////////////////////////////////////////////////////////////////////
296/// Forwards the execution to the dummy tree header.
297/// See TTree::FindBranch().
298
299TBranch *TProofChain::FindBranch(const char* branchname)
300{
301 return (fTree ? fTree->FindBranch(branchname) : (TBranch *)0);
302}
303
304////////////////////////////////////////////////////////////////////////////////
305/// Forwards the execution to the dummy tree header.
306/// See TTree::FindLeaf().
307
308TLeaf *TProofChain::FindLeaf(const char* searchname)
309{
310 return (fTree ? fTree->FindLeaf(searchname) : (TLeaf *)0);
311}
312
313////////////////////////////////////////////////////////////////////////////////
314/// Forwards the execution to the dummy tree header.
315/// See TTree::GetBranch().
316
318{
319 return (fTree ? fTree->GetBranch(name) : (TBranch *)0);
320}
321
322////////////////////////////////////////////////////////////////////////////////
323/// Forwards the execution to the dummy tree header.
324/// See TTree::GetBranchStatus().
325
326Bool_t TProofChain::GetBranchStatus(const char *branchname) const
327{
328 return (fTree ? fTree->GetBranchStatus(branchname) : kFALSE);
329}
330
331////////////////////////////////////////////////////////////////////////////////
332/// Forwards the execution to the dummy tree header.
333/// See TTree::GetPlayer().
334
336{
337 return (fTree ? fTree->GetPlayer() : (TVirtualTreePlayer *)0);
338}
339
340////////////////////////////////////////////////////////////////////////////////
341/// Forwards the execution to the TDSet.
342/// The return value is -1 in case of error and TSelector::GetStatus() in
343/// in case of success.
344/// See TDSet::Process().
345
346Long64_t TProofChain::Process(const char *filename, Option_t *option,
347 Long64_t nentries, Long64_t firstentry)
348{
349 // Set either the entry-list (priority) or the event-list
350 TObject *enl = 0;
351 if (fEntryList) {
352 enl = fEntryList;
353 } else if (fEventList) {
354 enl = fEventList;
355 }
356
357 return fSet->Process(filename, option, nentries, firstentry, enl);
358}
359
360////////////////////////////////////////////////////////////////////////////////
361/// The return value is -1 in case of error and TSelector::GetStatus() in
362/// in case of success.
363
365 Long64_t nentries, Long64_t firstentry)
366{
367 // Set either the entry-list (priority) or the event-list
368 TObject *enl = 0;
369 if (fEntryList) {
370 enl = fEntryList;
371 } else if (fEventList) {
372 enl = fEventList;
373 }
374
375 return fSet->Process(selector, option, nentries, firstentry, enl);
376}
377
378////////////////////////////////////////////////////////////////////////////////
379/// See TTree::SetDebug
380
382{
383 TTree::SetDebug(level, min, max);
384}
385
386////////////////////////////////////////////////////////////////////////////////
387/// See TTree::GetName.
388
389void TProofChain::SetName(const char *name)
390{
392}
393
394////////////////////////////////////////////////////////////////////////////////
395/// Returns the total number of entries in the TProofChain, which is
396/// the number of entries in the TDSet that it holds.
397
399{
400 // this was used for holding the total number of entries
401 if (TestBit(kProofLite)) {
402 return (fTree ? fTree->GetEntries() : (Long64_t)(-1));
403 } else {
404 return (fTree ? fTree->GetMaxEntryLoop() : (Long64_t)(-1));
405 }
406}
407
408////////////////////////////////////////////////////////////////////////////////
409/// See TTree::GetEntries(const char *selection)
410/// Not implemented in TProofChain. Shouldn't be used.
411
412Long64_t TProofChain::GetEntries(const char *selection)
413{
414 if (TestBit(kProofLite)) {
415 return (fTree ? fTree->GetEntries(selection) : (Long64_t)(-1));
416 } else {
417 Warning("GetEntries", "GetEntries(selection) not yet implemented");
418 return ((Long64_t)(-1));
419 }
420}
421
422////////////////////////////////////////////////////////////////////////////////
423/// Changes the number of processed entries.
424
426{
427 if (gROOT->IsInterrupted() && gProof)
429 if (total) { }
430
431 fReadEntry = processed;
432}
433
434////////////////////////////////////////////////////////////////////////////////
435/// Returns the number of processed entries.
436
438{
439 return fReadEntry;
440}
441
442////////////////////////////////////////////////////////////////////////////////
443/// Releases PROOF. Disconnect the "progress" signal.
444
446{
447 if (!gProof)
448 return;
449 gProof->Disconnect("Progress(Long64_t,Long64_t)",
450 this, "Progress(Long64_t,Long64_t)");
451}
452
453////////////////////////////////////////////////////////////////////////////////
454/// Connects the proof "Progress" signal.
455
457{
458 if (gProof)
459 gProof->Connect("Progress(Long64_t,Long64_t)", "TProofChain",
460 this, "Progress(Long64_t,Long64_t)");
461}
#define SafeDelete(p)
Definition RConfig.hxx:537
#define b(i)
Definition RSha256.hxx:100
#define e(i)
Definition RSha256.hxx:103
const Bool_t kFALSE
Definition RtypesCore.h:101
long long Long64_t
Definition RtypesCore.h:80
const Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:364
#define gDirectory
Definition TDirectory.h:385
static unsigned int total
char name[80]
Definition TGX11.cxx:110
int nentries
R__EXTERN TProof * gProof
Definition TProof.h:1077
Int_t gDebug
Definition TROOT.cxx:592
#define gROOT
Definition TROOT.h:404
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:30
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:31
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:33
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:35
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:34
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition TAttMarker.h:32
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition TAttMarker.h:31
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition TAttMarker.h:33
A TTree is a list of TBranches.
Definition TBranch.h:89
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
A chain is a collection of files containing TTree objects.
Definition TChain.h:33
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:474
TTree * fTree
! Pointer to current tree (Note: We do not own this tree.)
Definition TChain.h:41
virtual Double_t GetWeight() const
Return the chain weight.
Definition TChain.cxx:1221
@ kProofLite
Definition TChain.h:63
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
A specialized string object used for TTree selections.
Definition TCut.h:25
Manages an element of a TDSet.
Definition TDSet.h:66
This class implements a data set to be used for PROOF processing.
Definition TDSet.h:153
virtual void SetEntryList(TObject *aList)
Set entry (or event) list for this data set.
Definition TDSet.cxx:1894
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:1501
TObject * GetEntryList() const
Definition TDSet.h:251
TList * GetListOfElements() const
Definition TDSet.h:231
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:919
A List of entry numbers in a TTree or TChain.
Definition TEntryList.h:26
A TEventList object is a list of selected events (entries) in a TTree.
Definition TEventList.h:31
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition TLeaf.h:57
A doubly linked list.
Definition TList.h:38
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition TList.cxx:578
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
TNamed()
Definition TNamed.h:36
virtual const char * GetTitle() const
Returns title of object.
Definition TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
Mother of all ROOT objects.
Definition TObject.h:41
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition TObject.cxx:191
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:201
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:949
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:766
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:515
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:963
void ResetBit(UInt_t f)
Definition TObject.h:200
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:937
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 void Progress(Long64_t total, Long64_t processed)
Changes the number of processed entries.
virtual void ConnectProof()
Connects the proof "Progress" signal.
TVirtualTreePlayer * GetPlayer()
Forwards the execution to the dummy tree header.
virtual void SetDebug(Int_t level=1, Long64_t min=0, Long64_t max=9999999)
See TTree::SetDebug.
virtual void Browse(TBrowser *b)
Forwards the execution to the dummy tree header.
virtual TBranch * GetBranch(const char *name)
Forwards the execution to the dummy tree header.
virtual void SetName(const char *name)
See TTree::GetName.
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:43
virtual Long64_t GetReadEntry() const
Returns the number of processed entries.
TChain * fChain
Definition TProofChain.h:42
virtual Bool_t GetBranchStatus(const char *branchname) const
Forwards the execution to the dummy tree header.
TProofChain()
Crates a new PROOF chain proxy.
virtual TLeaf * FindLeaf(const char *name)
Forwards the execution to the dummy tree header.
virtual void ReleaseProof()
Releases PROOF. Disconnect the "progress" signal.
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.
virtual ~TProofChain()
Destructor.
virtual TBranch * FindBranch(const char *name)
Forwards the execution to the dummy tree header.
void AddAliases()
Aliases are added to the input list.
void FillDrawAttributes(TProof *p)
Communicate the drawing attributes for this chain to the input list so that the draw selectors can us...
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition TProof.h:316
void RemoveChain(TChain *chain)
Remove chain from data set.
Definition TProof.cxx:10231
void SetParameter(const char *par, const char *value)
Set input list parameter.
Definition TProof.cxx:9822
Bool_t IsLite() const
Definition TProof.h:933
void StopProcess(Bool_t abort, Int_t timeout=-1)
Send STOPPROCESS message to master and workers.
Definition TProof.cxx:6224
virtual TTree * GetTreeHeader(TDSet *tdset)
Creates a tree header (a tree with nonexisting files) object for the DataSet.
Definition TProof.cxx:10042
void AddChain(TChain *chain)
Add chain to data set.
Definition TProof.cxx:10223
void AddInput(TObject *obj)
Add objects that might be needed during the processing of the selector (see Process()).
Definition TProof.cxx:9734
TList * GetInputList()
Get input list.
Definition TProof.cxx:9753
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:869
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition TSelector.h:31
Basic string class.
Definition TString.h:136
const char * Data() const
Definition TString.h:369
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2314
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:4832
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition TTree.cxx:5279
TEventList * fEventList
! Pointer to event selection list (if one)
Definition TTree.h:122
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition TTree.cxx:6289
virtual TList * GetListOfAliases() const
Definition TTree.h:488
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:8894
virtual Bool_t GetBranchStatus(const char *branchname) const
Return status of branch with name branchname.
Definition TTree.cxx:5364
virtual TEntryList * GetEntryList()
Returns the entry list assigned to this tree.
Definition TTree.cxx:5838
TEntryList * fEntryList
! Pointer to event selection list (if one)
Definition TTree.h:123
virtual Long64_t GetEntries() const
Definition TTree.h:460
TEventList * GetEventList() const
Definition TTree.h:470
virtual void SetName(const char *name)
Change the name of this tree.
Definition TTree.cxx:9171
Long64_t fReadEntry
! Number of the entry being processed
Definition TTree.h:107
virtual TLeaf * FindLeaf(const char *name)
Find leaf..
Definition TTree.cxx:4904
TDirectory * fDirectory
! Pointer to directory holding this tree
Definition TTree.h:118
virtual Long64_t GetMaxEntryLoop() const
Definition TTree.h:494
Abstract base class defining the interface for the plugins that implement Draw, Scan,...