Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TDSet.cxx
Go to the documentation of this file.
1// @(#)root/proof:$Id$
2// Author: Fons Rademakers 11/01/02
3
4/*************************************************************************
5 * Copyright (C) 1995-2001, 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/** \class TDSetElement
13\ingroup proofkernel
14Manages an element of a TDSet.
15
16See TDSet.
17*/
18
19#include "TDSet.h"
20
21#include "Riostream.h"
22#include "TBuffer.h"
23#include "TChain.h"
24#include "TClass.h"
25#include "TClassTable.h"
26#include "TCut.h"
27#include "TDataSetManager.h"
28#include "TError.h"
29#include "TEntryList.h"
30#include "TEnv.h"
31#include "TEventList.h"
32#include "TFile.h"
33#include "TFileInfo.h"
34#include "TFileStager.h"
35#include "TFriendElement.h"
36#include "TKey.h"
37#include "THashList.h"
38#include "TMap.h"
39#include "TROOT.h"
40#include "TTimeStamp.h"
41#include "TTree.h"
42#include "TUrl.h"
43#include "TRegexp.h"
44#include "TVirtualPerfStats.h"
45#include "TProof.h"
46#include "TProofChain.h"
47#include "TProofServ.h"
48#include "TPluginManager.h"
49#include "TChainElement.h"
50#include "TSystem.h"
51#include "TSelector.h"
52#include "TObjString.h"
53
55#include "TClassRef.h"
56
59
60////////////////////////////////////////////////////////////////////////////////
61/// Default constructor
62
64 fDirectory(), fFirst(0), fNum(0), fMsd(),
65 fTDSetOffset(0), fEntryList(0), fValid(kFALSE),
66 fEntries(0), fFriends(0), fDataSet(), fAssocObjList(0),
67 fMaxProcTime(-1)
68{
75}
76
77////////////////////////////////////////////////////////////////////////////////
78/// Create a TDSet element.
79
80TDSetElement::TDSetElement(const char *file, const char *objname, const char *dir,
82 const char *msd, const char *dataset)
83 : TNamed(file, objname)
84{
85 if (first < 0) {
86 Warning("TDSetElement", "first must be >= 0, %lld is not allowed - setting to 0", first);
87 fFirst = 0;
88 } else {
89 fFirst = first;
90 }
91 if (num < -1) {
92 Warning("TDSetElement", "num must be >= -1, %lld is not allowed - setting to -1", num);
93 fNum = -1;
94 } else {
95 fNum = num;
96 }
97 fMsd = msd;
98 fTDSetOffset = 0;
99 fEntryList = 0;
100 fFriends = 0;
101 fValid = kFALSE;
102 fEntries = -1;
103 fDataSet = dataset;
104 fAssocObjList = 0;
105 if (dir)
106 fDirectory = dir;
107 fMaxProcTime = -1.;
108
115}
116
117////////////////////////////////////////////////////////////////////////////////
118/// copy constructor
119
121 : TNamed(elem.GetFileName(), elem.GetObjName())
122{
123 fDirectory = elem.GetDirectory();
124 fFirst = elem.fFirst;
125 fNum = elem.fNum;
126 fMsd = elem.fMsd;
128 fEntryList = 0;
129 fValid = elem.fValid;
130 fEntries = elem.fEntries;
131 fFriends = 0;
132 fDataSet = elem.fDataSet;
133 fAssocObjList = 0;
141}
142
143////////////////////////////////////////////////////////////////////////////////
144/// Clean up the element.
145
147{
149 if (fAssocObjList) {
152 }
153}
154
155////////////////////////////////////////////////////////////////////////////////
156/// Reset TDSet element.
157
159{
160 fFirst = 0;
161 fNum = -1;
162 fTDSetOffset = 0;
163 fEntryList = 0;
164 fValid = kFALSE;
165 fEntries = -1;
166 fMaxProcTime = -1.;
167
172}
173
174////////////////////////////////////////////////////////////////////////////////
175/// Check if 'elem' is overlapping or subsequent and, if the case, return
176/// a merged element.
177/// Returns:
178/// 1 if the elements are overlapping
179/// 0 if the elements are subsequent
180/// -1 if the elements are neither overlapping nor subsequent
181
183{
184 // The element must be defined
185 if (!elem) return -1;
186
187 // The file names and object names must be the same
188 if (strcmp(GetName(), elem->GetName()) || strcmp(GetTitle(), elem->GetTitle()))
189 return -1;
190
191 Int_t rc = -1;
192 // Check the overlap or subsequency
193 if (fFirst == 0 && fNum == -1) {
194 // Overlap, since we cover already the full range
195 rc = 1;
196 } else if (elem->GetFirst() == 0 && elem->GetNum() == -1) {
197 // Overlap, since 'elem' cover already the full range
198 fFirst = 0;
199 fNum = -1;
200 fEntries = elem->GetEntries();
201 rc = 1;
202 } else if (fFirst >= 0 && fNum > 0 && elem->GetFirst() >= 0 && elem->GetNum() > 0) {
203 Long64_t last = fFirst + fNum - 1, lastref = 0;
204 Long64_t lastelem = elem->GetFirst() + elem->GetNum() - 1;
205 if (elem->GetFirst() == last + 1) {
206 lastref = lastelem;
207 rc = 0;
208 } else if (fFirst == lastelem + 1) {
209 fFirst += elem->GetFirst();
210 lastref = last;
211 rc = 0;
212 } else if (elem->GetFirst() < last + 1 && elem->GetFirst() >= fFirst) {
213 lastref = (lastelem > last) ? lastelem : last;
214 rc = 1;
215 } else if (fFirst < lastelem + 1 && fFirst >= elem->GetFirst()) {
216 fFirst += elem->GetFirst();
217 lastref = (lastelem > last) ? lastelem : last;
218 rc = 1;
219 }
220 fNum = lastref - fFirst + 1;
221 }
222 if (rc >= 0 && fEntries < 0 && elem->GetEntries() > 0) fEntries = elem->GetEntries();
223
224 // Done
225 return rc;
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Return the content of this element in the form of a TFileInfo
230
232{
233 // Create the TFileInfoMeta object
234 TFileInfoMeta *meta = 0;
235 Long64_t entries = (fEntries < 0 && fNum > 0) ? fNum : fEntries;
236 Printf("entries: %lld (%lld)", entries, fNum);
237 if (!strcmp(type, "TTree")) {
238 meta = new TFileInfoMeta(GetTitle(), "TTree", entries, fFirst,
239 fFirst + entries - 1);
240 } else {
241 meta = new TFileInfoMeta(GetTitle(), fDirectory, type, entries, fFirst,
242 fFirst + entries - 1);
243 }
244 TFileInfo *fi = new TFileInfo(GetName(), 0, 0, 0, meta);
245 if (!fDataSet.IsNull()) fi->SetTitle(fDataSet.Data());
247 return fi;
248}
249
250////////////////////////////////////////////////////////////////////////////////
251/// Return directory where to look for object.
252
253const char *TDSetElement::GetDirectory() const
254{
255 return fDirectory;
256}
257
258////////////////////////////////////////////////////////////////////////////////
259/// Print a TDSetElement. When option="a" print full data.
260
262{
263 if (opt && opt[0] == 'a') {
264 Printf("%s file=\"%s\" dir=\"%s\" obj=\"%s\" first=%lld num=%lld msd=\"%s\"",
265 IsA()->GetName(), GetName(), fDirectory.Data(), GetTitle(),
266 fFirst, fNum, fMsd.Data());
267 } else {
268 Printf("\tLFN: %s", GetName());
269 }
270}
271
272////////////////////////////////////////////////////////////////////////////////
273/// Validate by opening the file.
274
276{
277 Long64_t entries = GetEntries(isTree);
278 if (entries < 0) return; // Error should be reported by GetEntries()
279 if (fFirst < entries) {
280 if (fNum == -1) {
281 fNum = entries - fFirst;
282 fValid = kTRUE;
283 } else {
284 if (fNum <= entries - fFirst) {
285 fValid = kTRUE;
286 } else {
287 Error("Validate", "TDSetElement has only %lld entries starting"
288 " with entry %lld, while %lld were requested",
289 entries - fFirst, fFirst, fNum);
290 }
291 }
292 } else {
293 Error("Validate", "TDSetElement has only %lld entries with"
294 " first entry requested as %lld", entries, fFirst);
295 }
296}
297
298////////////////////////////////////////////////////////////////////////////////
299/// Validate by checking against another element.
300
302{
303 // NOTE: Since this function validates against another TDSetElement,
304 // if the other TDSetElement (elem) did not use -1 to request all
305 // entries, this TDSetElement may get less than all entries if it
306 // requests all (with -1). For the application it was developed for
307 // (TProofSuperMaster::ValidateDSet) it works, since the design was
308 // to send the elements to their mass storage domain and let them
309 // look at the file and send the info back to the supermaster. The
310 // ability to set fValid was also required to be only exist in
311 // TDSetElement through certain function and not be set externally.
312 // TDSetElement may need to be extended for more general applications.
313
314 if (!elem || !elem->GetValid()) {
315 Error("Validate", "TDSetElement to validate against is not valid");
316 return;
317 }
318
320 TString elemname = TUrl(elem->GetFileName()).GetFileAndOptions();
321 if ((name == elemname) &&
322 !strcmp(GetDirectory(), elem->GetDirectory()) &&
323 !strcmp(GetObjName(), elem->GetObjName())) {
324 Long64_t entries = elem->fFirst + elem->fNum;
325 if (fFirst < entries) {
326 if (fNum == -1) {
327 fNum = entries - fFirst;
328 fValid = kTRUE;
329 } else {
330 if (fNum <= entries - fFirst) {
331 fValid = kTRUE;
332 } else {
333 Error("Validate", "TDSetElement requests %lld entries starting"
334 " with entry %lld, while TDSetElement to validate against"
335 " has only %lld entries", fNum, fFirst, entries);
336 }
337 }
338 } else {
339 Error("Validate", "TDSetElement to validate against has only %lld"
340 " entries, but this TDSetElement requested %lld as its first"
341 " entry", entries, fFirst);
342 }
343 } else {
344 Error("Validate", "TDSetElements do not refer to same objects");
345 }
346}
347
348////////////////////////////////////////////////////////////////////////////////
349///Compare elements by filename (and the fFirst).
350
352{
353 if (this == obj) return 0;
354
355 const TDSetElement *elem = dynamic_cast<const TDSetElement*>(obj);
356 if (!elem) {
357 if (obj)
358 return (strncmp(GetName(),obj->GetName(),strlen(GetName()))) ? 1 : 0;
359 return -1;
360 }
361
362 Int_t order = strncmp(GetName(),elem->GetFileName(),strlen(GetName()));
363 if (order == 0) {
364 if (GetFirst() < elem->GetFirst())
365 return -1;
366 else if (GetFirst() > elem->GetFirst())
367 return 1;
368 return 0;
369 }
370 return order;
371}
372
373////////////////////////////////////////////////////////////////////////////////
374/// Add friend TDSetElement to this set. The friend element will be copied to this object.
375
376void TDSetElement::AddFriend(TDSetElement *friendElement, const char *alias)
377{
378 if (!friendElement) {
379 Error("AddFriend", "The friend TDSetElement is null!");
380 return;
381 }
382 if (!fFriends) {
383 fFriends = new TList();
385 }
386 // Add alias (if any) as option 'friend_alias=<alias>|'
387 if (alias && strlen(alias) > 0) {
388 TUrl uf(friendElement->GetName());
389 TString uo(uf.GetOptions());
390 uo += TString::Format("friend_alias=%s|", alias);
391 uf.SetOptions(uo);
392 friendElement->SetName(uf.GetUrl());
393 }
394 fFriends->Add(new TDSetElement(*friendElement));
395}
396
397////////////////////////////////////////////////////////////////////////////////
398/// Deletes the list of friends and all the friends on the list.
399
401{
402 if (!fFriends)
403 return;
404
406 delete fFriends;
407 fFriends = 0;
408}
409
410////////////////////////////////////////////////////////////////////////////////
411/// Returns next TDSetElement.
412
414{
415 if (!fIterator) {
417 }
418
420 return fCurrent;
421}
422
423////////////////////////////////////////////////////////////////////////////////
424/// Returns number of entries in tree or objects in file.
425/// If not yet defined and 'openfile' is TRUE, get the number from the file
426/// (may considerably slow down the application).
427/// Returns -1 in case of error.
428
430{
431 if (fEntries > -1 || !openfile)
432 return fEntries;
433
434 Double_t start = 0;
435 if (gPerfStats) start = TTimeStamp();
436
437 // Take into account possible prefixes
439 TString fname = gEnv->GetValue("Path.Localroot",""), pfx(fname);
440 // Get the locality (disable warnings or errors in connection attempts)
441 Int_t oldLevel = gErrorIgnoreLevel;
443 if ((typ = TFile::GetType(GetName(), "", &fname)) != TFile::kLocal) fname = GetName();
444 gErrorIgnoreLevel = oldLevel;
445 // Open the file
446 TFile *file = TFile::Open(fname);
447
448 if (gPerfStats)
449 gPerfStats->FileOpenEvent(file, GetName(), start);
450
451 if (file == 0) {
452 ::SysError("TDSetElement::GetEntries",
453 "cannot open file %s (type: %d, pfx: %s)", GetName(), typ, pfx.Data());
454 return -1;
455 }
456
457 // Record end-point Url and mark as looked-up; be careful to change
458 // nothing in the file name, otherwise some cross-checks may fail.
459 // The lookup is only performed if not yet done
460 if (Lookup(kFALSE) != 0) Warning("GetEntries", "lookup problems for %s", GetName());
461
462 TDirectory *dirsave = gDirectory;
463 if (!file->cd(fDirectory)) {
464 Error("GetEntries", "cannot cd to %s", fDirectory.Data());
465 delete file;
466 return -1;
467 }
468
469 TDirectory *dir = gDirectory;
470 dirsave->cd();
471
472 if (isTree) {
473
474 TString on(GetTitle());
475 TString sreg(GetTitle());
476 // If a wild card we will use the first object of the type
477 // requested compatible with the reg expression we got
478 if (sreg.Length() <= 0 || sreg == "" || sreg.Contains("*")) {
479 if (sreg.Contains("*"))
480 sreg.ReplaceAll("*", ".*");
481 else
482 sreg = ".*";
483 TRegexp re(sreg);
484 if (dir->GetListOfKeys()) {
485 TIter nxk(dir->GetListOfKeys());
486 TKey *k = 0;
487 Bool_t notfound = kTRUE;
488 while ((k = (TKey *) nxk())) {
489 if (!strcmp(k->GetClassName(), "TTree")) {
490 TString kn(k->GetName());
491 if (kn.Index(re) != kNPOS) {
492 if (notfound) {
493 on = kn;
494 notfound = kFALSE;
495 } else if (kn != on) {
496 Warning("GetEntries",
497 "additional tree found in the file: %s", kn.Data());
498 }
499 }
500 }
501 }
502 }
503 }
504
505 TKey *key = dir->GetKey(on);
506 if (key == 0) {
507 Error("GetEntries", "cannot find tree \"%s\" in %s",
508 GetTitle(), GetName());
509 delete file;
510 return -1;
511 }
512 TTree *tree = (TTree *) key->ReadObj();
513 if (tree == 0) {
514 // Error always reported?
515 delete file;
516 return -1;
517 }
518 fEntries = tree->GetEntries();
519 delete tree;
520
521 } else {
522 TList *keys = dir->GetListOfKeys();
523 fEntries = keys->GetSize();
524 }
525
526 delete file;
527 return fEntries;
528}
529
530////////////////////////////////////////////////////////////////////////////////
531/// Resolve end-point URL for this element
532/// Return 0 on success and -1 otherwise
533
535{
536 static Int_t xNetPluginOK = -1;
537 static TFileStager *xStager = 0;
538 Int_t retVal = 0;
539
540 // Check if required
541 if (!force && HasBeenLookedUp())
542 return retVal;
543
544 TUrl url(GetName());
545 // Save current options and anchor to be set ofthe final end URL
546 TString anch = url.GetAnchor();
547 TString opts = url.GetOptions();
548 // The full path
549 TString name(url.GetUrl());
550
551 // Depending on the type of backend, it might not make any sense to lookup
552 Bool_t doit = kFALSE;
554 if (type == TFile::kNet) {
555 TPluginHandler *h = 0;
556 // Network files via XROOTD
557 if (xNetPluginOK == -1) {
558 // Check the plugin the first time
559 xNetPluginOK = 0;
560 if ((h = gROOT->GetPluginManager()->FindHandler("TFile", name)) &&
561 !strcmp(h->GetClass(),"TXNetFile") && h->LoadPlugin() == 0)
562 xNetPluginOK = 1;
563 }
564 doit = (xNetPluginOK == 1) ? kTRUE : kFALSE;
565 }
566
567 // Locate the file
568 if (doit) {
569 if (!xStager || !xStager->Matches(name)) {
570 SafeDelete(xStager);
571 if (!(xStager = TFileStager::Open(name))) {
572 Error("Lookup", "TFileStager instance cannot be instantiated");
573 retVal = -1;
574 }
575 }
576 if (xStager && xStager->Locate(name.Data(), name) == 0) {
577 // Get the effective end-point Url
578 url.SetUrl(name);
579 // Restore original options and anchor, if any
580 url.SetOptions(opts);
581 url.SetAnchor(anch);
582 // Save it into the element
583 fName = url.GetUrl();
584 } else {
585 // Failure
586 Error("Lookup", "couldn't lookup %s", name.Data());
587 retVal = -1;
588 }
589 }
590
591 // Mark has looked-up
593 return retVal;
594}
595
596////////////////////////////////////////////////////////////////////////////////
597/// Set entry (or event) list for this element
598
600{
601 if (!aList) {
602 // Nothing to do, except making sure to disable any previous setting
603 fEntryList = 0;
604 return;
605 }
606
607 // Link the proper object
608 TEventList *evl = 0;
609 TEntryList *enl = dynamic_cast<TEntryList*>(aList);
610 if (!enl)
611 evl = dynamic_cast<TEventList*>(aList);
612 if (!enl && !evl) {
613 Error("SetEntryList", "type of input object must be either TEntryList "
614 "or TEventList (found: '%s' - do nothing", aList->ClassName());
615 return;
616 }
617
618 // Action depends on the type
619 if (enl) {
620 enl->SetEntriesToProcess(num);
621 } else {
622 for (; num > 0; num--, first++)
623 evl->Enter(evl->GetEntry((Int_t)first));
624 }
625 fEntryList = aList;
626
627 // Done
628 return;
629}
630
631////////////////////////////////////////////////////////////////////////////////
632/// Add an associated object to the list
633
635{
636 if (assocobj) {
638 if (fAssocObjList) fAssocObjList->Add(assocobj);
639 }
640}
641
642////////////////////////////////////////////////////////////////////////////////
643/// Get i-th associated object.
644/// If 'isentry' fFirst is subtracted, so that i == fFirst returns the first
645/// object in the list.
646/// If there are not enough elements in the list, the element i%list_size is
647/// returned (if the list has only one element this only one element is always
648/// returned.
649/// This method is used when packet processing consist in processing the objects
650/// in the associated object list.
651
653{
654 TObject *o = 0;
655 if (!fAssocObjList || fAssocObjList->GetSize() <= 0) return o;
656
657 TString s;
658 Int_t pos = -1;
659 if (isentry) {
660 if (i < fFirst) return o;
661 s.Form("%lld", i - fFirst);
662 } else {
663 if (i < 0) return o;
664 s.Form("%lld", i);
665 }
666 if (!(s.IsDigit())) return o;
667 pos = s.Atoi();
668 if (pos > fAssocObjList->GetSize() - 1) pos %= fAssocObjList->GetSize();
669 return fAssocObjList->At(pos);
670}
671
672
673/** \class TDSet
674\ingroup proofkernel
675
676This class implements a data set to be used for PROOF processing.
677The TDSet defines the class of which objects will be processed,
678the directory in the file where the objects of that type can be
679found and the list of files to be processed. The files can be
680specified as logical file names (LFN's) or as physical file names
681(PFN's). In case of LFN's the resolution to PFN's will be done
682according to the currently active GRID interface.
683Examples:
684 TDSet treeset("TTree", "AOD");
685 treeset.Add("lfn:/alien.cern.ch/alice/prod2002/file1");
686 ...
687 treeset.AddFriend(friendset);
688
689or
690
691 TDSet objset("MyEvent", "*", "/events");
692 objset.Add("root://cms.cern.ch/user/prod2002/hprod_1.root");
693 ...
694 objset.Add(set2003);
695
696Validity of file names will only be checked at processing time
697(typically on the PROOF master server), not at creation time.
698
699*/
700
701////////////////////////////////////////////////////////////////////////////////
702/// Default ctor.
703
705{
706 fElements = new THashList;
708 fIsTree = kFALSE;
709 fIterator = 0;
710 fCurrent = 0;
711 fEntryList = 0;
712 fProofChain = 0;
713 fSrvMaps = 0;
714 fSrvMapsIter = 0;
720
721 // Add to the global list
722 gROOT->GetListOfDataSets()->Add(this);
723}
724
725////////////////////////////////////////////////////////////////////////////////
726/// Create a named TDSet object. The "type" defines the class of which objects
727/// will be processed (default 'TTree'). The optional "objname" argument
728/// specifies the name of the objects of the specified class.
729/// If the "objname" is not given the behaviour depends on the 'type':
730/// for 'TTree' the first TTree is analyzed; for other types, all objects of
731/// the class found in the specified directory are processed.
732/// The "dir" argument specifies in which directory the objects are
733/// to be found, the top level directory ("/") is the default.
734/// Directories can be specified using wildcards, e.g. "*" or "/*"
735/// means to look in all top level directories, "/dir/*" in all
736/// directories under "/dir", and "/*/*" to look in all directories
737/// two levels deep.
738/// For backward compatibility the type can also be passed via 'name',
739/// in which case 'type' is ignored.
740
741TDSet::TDSet(const char *name,
742 const char *objname, const char *dir, const char *type)
743{
744 fElements = new THashList;
746 fIterator = 0;
747 fCurrent = 0;
748 fEntryList = 0;
749 fProofChain = 0;
750 fSrvMaps = 0;
751 fSrvMapsIter = 0;
757
758 fType = "TTree";
759 TClass *c = 0;
760 // Check name
761 if (name && strlen(name) > 0) {
762 // In the old constructor signature it was the 'type'
763 if (!type) {
764 TString cn(name);
765 if (cn.Contains(':')) cn.Remove(0, cn.Index(":")+1);
766 if (TClass::GetClass(cn))
767 fType = cn;
768 else
769 // Default type is 'TTree'
770 fName = name;
771 } else {
772 // Set name
773 fName = name;
774 // Check type
775 if (strlen(type) > 0)
777 fType = type;
778 }
779 } else if (type && strlen(type) > 0) {
780 // Check the type
782 fType = type;
783 }
784 // The correct class type
786
787 fIsTree = (c->InheritsFrom(TTree::Class())) ? kTRUE : kFALSE;
788
789 if (objname)
790 fObjName = objname;
791
792 if (dir)
793 fDir = dir;
794
795 // Default name is the object name
796 if (fName.Length() <= 0)
797 fName = TString::Format("TDSet:%s", fObjName.Data());
798 // We set the default title to the 'type'
799 fTitle = fType;
800
801 // Add to the global list
802 gROOT->GetListOfDataSets()->Add(this);
803}
804
805////////////////////////////////////////////////////////////////////////////////
806/// Create a named TDSet object from existing TChain 'chain'.
807/// If 'withfriends' is kTRUE add also friends.
808/// This constructor substituted the static methods TChain::MakeTDSet
809/// removing any residual dependence of 'tree' on 'proof'.
810
811TDSet::TDSet(const TChain &chain, Bool_t withfriends)
812{
813 fElements = new THashList;
815 fIterator = 0;
816 fCurrent = 0;
817 fEntryList = 0;
818 fProofChain = 0;
819 fSrvMaps = 0;
820 fSrvMapsIter = 0;
826
827 fType = "TTree";
828 fIsTree = kTRUE;
829 fObjName = chain.GetName();
830 fName = TString::Format("TChain:%s", chain.GetName());
831
832 // First fill elements without friends()
833 TIter next(chain.GetListOfFiles());
834 TChainElement *elem = 0;
835 TString key;
836 while ((elem = (TChainElement *)next())) {
837 TString file(elem->GetTitle());
838 TString tree(elem->GetName());
839 Int_t isl = tree.Last('/');
840 TString dir = "/";
841 if (isl >= 0) {
842 // Copy the tree name specification
843 TString behindSlash = tree(isl + 1, tree.Length() - isl - 1);
844 // and remove it from basename
845 tree.Remove(isl);
846 dir = tree;
847 tree = behindSlash;
848 }
849 // Find MSD if any
850 TString msd(TUrl(file).GetOptions());
851 Int_t imsd = kNPOS;
852 if ((imsd = msd.Index("msd=")) != kNPOS) {
853 msd.Remove(0, imsd+4);
854 } else {
855 // Not an MSD option
856 msd = "";
857 }
858 Long64_t nent = (elem->GetEntries() > 0 &&
859 elem->GetEntries() != TTree::kMaxEntries) ? elem->GetEntries() : -1;
860 if (Add(file, tree, dir, 0, nent, ((msd.IsNull()) ? 0 : msd.Data()))) {
861 if (elem->HasBeenLookedUp()) {
862 // Save lookup information, if any
864 if (dse) dse->SetLookedUp();
865 }
866 }
867 }
868 SetDirectory(0);
869
870 // Add friends now, if requested
871 if (withfriends) {
872 TList processed;
873 TList chainsQueue;
874 chainsQueue.Add((TObject *)&chain);
875 processed.Add((TObject *)&chain);
876 while (chainsQueue.GetSize() > 0) {
877 TChain *c = (TChain *) chainsQueue.First();
878 chainsQueue.Remove(c);
879 TIter friendsIter(c->GetListOfFriends());
880 while(TFriendElement *fe = dynamic_cast<TFriendElement*> (friendsIter()) ) {
881 if (TChain *fc = dynamic_cast<TChain*>(fe->GetTree())) {
882 if (!processed.FindObject(fc)) { // if not yet processed
883 processed.AddFirst(fc);
884 AddFriend(new TDSet((const TChain &)(*fc), kFALSE), fe->GetName());
885 chainsQueue.Add(fc); // for further processing
886 }
887 } else {
888 Reset();
889 Error("TDSet", "Only TChains supported. Found illegal tree %s",
890 fe->GetTree()->GetName());
891 return;
892 }
893 }
894 }
895 }
896}
897
898////////////////////////////////////////////////////////////////////////////////
899/// Cleanup.
900
902{
906 fSrvMaps = 0;
907 fSrvMapsIter = 0;
908
909 gROOT->GetListOfDataSets()->Remove(this);
910}
911
912////////////////////////////////////////////////////////////////////////////////
913/// Process TDSet on currently active PROOF session.
914/// The last argument 'enl' specifies an entry- or event-list to be used as
915/// event selection.
916/// The return value is -1 in case of error and TSelector::GetStatus() in
917/// in case of success.
918
920 Long64_t first, TObject *enl)
921{
922 if (!IsValid() || !fElements->GetSize()) {
923 Error("Process", "not a correctly initialized TDSet");
924 return -1;
925 }
926
927 // Set entry list
928 SetEntryList(enl);
929
930 if (gProof)
931 return gProof->Process(this, selector, option, nentries, first);
932
933 Error("Process", "no active PROOF session");
934 return -1;
935}
936
937////////////////////////////////////////////////////////////////////////////////
938/// Process TDSet on currently active PROOF session.
939/// The last argument 'enl' specifies an entry- or event-list to be used as
940/// event selection.
941/// The return value is -1 in case of error and TSelector::GetStatus() in
942/// in case of success.
943
944Long64_t TDSet::Process(const char *selector, Option_t *option, Long64_t nentries,
945 Long64_t first, TObject *enl)
946{
947 if (!IsValid() || !fElements->GetSize()) {
948 Error("Process", "not a correctly initialized TDSet");
949 return -1;
950 }
951
952 // Set entry list
953 SetEntryList(enl);
954
955 if (gProof)
956 return gProof->Process(this, selector, option, nentries, first);
957
958 Error("Process", "no active PROOF session");
959 return -1;
960}
961
962////////////////////////////////////////////////////////////////////////////////
963/// Add objects that might be needed during the processing of
964/// the selector (see Process()).
965
967{
968 if (gProof) {
969 gProof->AddInput(obj);
970 } else {
971 Error("AddInput","No PROOF session active");
972 }
973}
974
975////////////////////////////////////////////////////////////////////////////////
976/// Clear input object list.
977
979{
980 if (gProof)
982}
983
984////////////////////////////////////////////////////////////////////////////////
985/// Get specified object that has been produced during the processing
986/// (see Process()).
987
989{
990 if (gProof)
991 return gProof->GetOutput(name);
992 return 0;
993}
994
995////////////////////////////////////////////////////////////////////////////////
996/// Get list with all object created during processing (see Process()).
997
999{
1000 if (gProof)
1001 return gProof->GetOutputList();
1002 return 0;
1003}
1004
1005////////////////////////////////////////////////////////////////////////////////
1006/// Print TDSet basic or full data. When option="a" print full data.
1007
1008void TDSet::Print(const Option_t *opt) const
1009{
1010 const char *clnm = (IsA()) ? IsA()->GetName() : "TDSet";
1011 Printf("OBJ: %s\ttype %s\t%s\tin %s\telements %d", clnm, GetName(),
1012 fObjName.Data(), GetTitle(), GetListOfElements()->GetSize());
1013
1014 if (opt && opt[0] == 'a') {
1015 TIter next(GetListOfElements());
1016 TObject *obj;
1017 while ((obj = next())) {
1018 obj->Print(opt);
1019 }
1020 }
1021}
1022
1023////////////////////////////////////////////////////////////////////////////////
1024/// Set/change object name.
1025
1026void TDSet::SetObjName(const char *objname)
1027{
1028 if (objname) {
1029 fObjName = objname;
1030 TIter next(GetListOfElements());
1031 TDSetElement *e;
1032 while ((e = (TDSetElement *) next())) {
1033 e->SetTitle(objname);
1034 }
1035 }
1036}
1037
1038////////////////////////////////////////////////////////////////////////////////
1039/// Set/change directory.
1040
1041void TDSet::SetDirectory(const char *dir)
1042{
1043 if (dir)
1044 fDir = dir;
1045}
1046
1047////////////////////////////////////////////////////////////////////////////////
1048/// Add file to list of files to be analyzed. Optionally with the
1049/// objname and dir arguments the default, TDSet wide, objname and
1050/// dir can be overridden.
1051
1052Bool_t TDSet::Add(const char *file, const char *objname, const char *dir,
1053 Long64_t first, Long64_t num, const char *msd)
1054{
1055 if (!file || !*file) {
1056 Error("Add", "file name must be specified");
1057 return kFALSE;
1058 }
1059
1060 TString fn = file;
1061 if (gProof && gProof->IsLite()) {
1062 TUrl u(file, kTRUE);
1063 if (!strcmp(u.GetProtocol(), "file")) {
1064 fn = u.GetFileAndOptions();
1066 if (!gSystem->IsAbsoluteFileName(fn))
1068 }
1069 }
1070
1071 // check, if it already exists in the TDSet
1073 if (!el) {
1074 if (!objname)
1075 objname = GetObjName();
1076 if (!dir)
1077 dir = GetDirectory();
1078 fElements->Add(new TDSetElement(fn, objname, dir, first, num, msd));
1079 } else {
1080 TString msg;
1081 msg.Form("duplication detected: %40s is already in dataset - ignored", fn.Data());
1082 Warning("Add", "%s", msg.Data());
1083 if (gProofServ) {
1084 msg.Insert(0, "WARNING: ");
1086 }
1087 }
1088
1089 return kTRUE;
1090}
1091
1092////////////////////////////////////////////////////////////////////////////////
1093/// Add specified data set to the this set.
1094
1096{
1097 if (!dset)
1098 return kFALSE;
1099
1101 fElements->Add(dset);
1102 return kTRUE;
1103 }
1104
1105 if (fType != dset->GetType()) {
1106 Error("Add", "cannot add a set with a different type");
1107 return kFALSE;
1108 }
1109
1110 TDSetElement *el;
1111 TIter next(dset->fElements);
1112 TObject *last = (dset == this) ? fElements->Last() : 0;
1113 while ((el = (TDSetElement*) next())) {
1114 Add(el->GetFileName(), el->GetObjName(), el->GetDirectory(),
1115 el->GetFirst(), el->GetNum(), el->GetMsd());
1116 if (el == last) break;
1117 }
1118
1119 return kTRUE;
1120}
1121
1122////////////////////////////////////////////////////////////////////////////////
1123/// Add files passed as list of TFileInfo, TUrl or TObjString objects .
1124/// If TFileInfo, the first entry and the number of entries are also filled.
1125/// The argument 'meta' can be used to specify one of the subsets in the
1126/// file as described in the metadata of TFileInfo. By default the first one
1127/// is taken.
1128/// If 'availableOnly' is true only files available ('staged' and non corrupted)
1129/// are taken: those not satisfying this requirement are added to 'badlist', if
1130/// the latter is defined. By default availableOnly is false.
1131
1132Bool_t TDSet::Add(TCollection *filelist, const char *meta, Bool_t availableOnly,
1133 TCollection *badlist)
1134{
1135 if (!filelist)
1136 return kFALSE;
1137
1138 TObject *o = 0;
1139 TIter next(filelist);
1140 while ((o = next())) {
1141 TString cn(o->ClassName());
1142 if (cn == "TFileInfo") {
1143 TFileInfo *fi = (TFileInfo *)o;
1144 if (!availableOnly ||
1147 Int_t nf = fElements->GetSize();
1148 if (!Add(fi, meta)) return kFALSE;
1149 // Duplications count as bad files
1150 if (fElements->GetSize() <= nf && badlist) badlist->Add(fi);
1151 } else if (badlist) {
1152 // Return list of non-usable files
1153 badlist->Add(fi);
1154 }
1155 } else if (cn == "TUrl") {
1156 Add(((TUrl *)o)->GetUrl());
1157 } else if (cn == "TObjString") {
1158 Add(((TObjString *)o)->GetName());
1159 } else {
1160 Warning("Add","found object fo unexpected type %s - ignoring", cn.Data());
1161 }
1162 }
1163
1164 return kTRUE;
1165}
1166
1167////////////////////////////////////////////////////////////////////////////////
1168/// Set (or unset) the list for mapping servers coordinate for files.
1169/// Reinitialize the related iterator if needed.
1170/// Used by TProof.
1171
1173{
1174 fSrvMaps = srvmaps;
1176 if (fSrvMaps) fSrvMapsIter = new TIter(fSrvMaps);
1177}
1178
1179////////////////////////////////////////////////////////////////////////////////
1180/// Add file described by 'fi' to list of files to be analyzed.
1181/// The argument 'meta' can be used to specify a subsets in the
1182/// file as described in the metadata of TFileInfo. By default the first one
1183/// is taken.
1184
1185Bool_t TDSet::Add(TFileInfo *fi, const char *meta)
1186{
1187 if (!fi) {
1188 Error("Add", "TFileInfo object name must be specified");
1189 return kFALSE;
1190 }
1191 TString msg;
1192
1193 // Check if a remap of the server coordinates is requested
1194 const char *file = fi->GetFirstUrl()->GetUrl();
1195 Bool_t setLookedUp = kTRUE;
1196 TString file1;
1198 !(file1.IsNull())) {
1199 file = file1.Data();
1200 setLookedUp = kFALSE;
1201 }
1202 // Check if it already exists in the TDSet
1203 if (fElements->FindObject(file)) {
1204 msg.Form("duplication detected: %40s is already in dataset - ignored", file);
1205 Warning("Add", "%s", msg.Data());
1206 if (gProofServ) {
1207 msg.Insert(0, "WARNING: ");
1209 }
1210 return kTRUE;
1211 }
1212
1213 // If more than one metadata info require the specification of the objpath;
1214 // the order in which they appear is not guaranteed and the error may be
1215 // very difficult to find.
1216 TFileInfoMeta *m = 0;
1217 if (!meta || strlen(meta) <= 0 || !strcmp(meta, "/")) {
1218 TList *fil = 0;
1219 if ((fil = fi->GetMetaDataList()) && fil->GetSize() > 1) {
1220 msg.Form("\n Object name unspecified and several objects available.\n");
1221 msg += " Please choose one from the list below:\n";
1222 TIter nx(fil);
1223 while ((m = (TFileInfoMeta *) nx())) {
1224 TString nm(m->GetName());
1225 if (nm.BeginsWith("/")) nm.Remove(0,1);
1226 msg += Form(" %s -> TProof::Process(\"%s#%s\",...)\n",
1227 nm.Data(), GetName(), nm.Data());
1228 }
1229 if (gProofServ)
1231 else
1232 Warning("Add", "%s", msg.Data());
1233 return kFALSE;
1234 }
1235 }
1236
1237 // Get the metadata, if any
1238 m = fi->GetMetaData(meta);
1239
1240 // Create the element
1241 const char *objname = 0;
1242 const char *dir = 0;
1243 Long64_t first = 0;
1244 Long64_t num = -1;
1245 if (!m) {
1246 objname = GetObjName();
1247 dir = GetDirectory();
1248 } else {
1249 objname = (m->GetObject() && strlen(m->GetObject())) ? m->GetObject() : GetObjName();
1250 dir = (m->GetDirectory() && strlen(m->GetDirectory())) ? m->GetDirectory() : GetDirectory();
1251 first = m->GetFirst();
1252 num = m->GetEntries();
1253 }
1254 const char *dataset = 0;
1255 if (strcmp(fi->GetTitle(), "TFileInfo")) dataset = fi->GetTitle();
1256 TDSetElement *el = new TDSetElement(file, objname, dir, first, -1, 0, dataset);
1257 el->SetEntries(num);
1258
1259 // Set looked-up bit
1260 if (fi->TestBit(TFileInfo::kStaged) && setLookedUp)
1264
1265 // Add the element
1266 fElements->Add(el);
1267
1268 return kTRUE;
1269}
1270
1271////////////////////////////////////////////////////////////////////////////////
1272/// Export TDSetElements files as list of TFileInfo objects in file
1273/// 'fpath'. If the file exists already the action fails, unless
1274/// 'opt == "F"'.
1275/// Return 0 on success, -1 otherwise
1276
1277Int_t TDSet::ExportFileList(const char *fpath, Option_t *opt)
1278{
1279 if (!fElements)
1280 return -1;
1281 if (fElements->GetSize() <= 0)
1282 return 0;
1283
1284 Bool_t force = (opt[0] == 'F' || opt[0] == 'f');
1285
1286 if (gSystem->AccessPathName(fpath, kFileExists) == kFALSE) {
1287 if (force) {
1288 // Try removing the file
1289 if (gSystem->Unlink(fpath)) {
1290 Info("ExportFileList","error removing dataset file: %s", fpath);
1291 return -1;
1292 }
1293 }
1294 }
1295
1296 // Create the file list
1297 TList *fileinfo = new TList;
1298 fileinfo->SetOwner();
1299
1300 TDSetElement *dse = 0;
1301 TIter next(fElements);
1302 while ((dse = (TDSetElement *) next())) {
1303 TFileInfoMeta *m = new TFileInfoMeta(dse->GetTitle(), dse->GetDirectory(), GetType(),
1304 dse->GetNum(), dse->GetFirst());
1305 TFileInfo *fi = new TFileInfo(dse->GetFileName());
1306 fi->AddMetaData(m);
1307 fileinfo->Add(fi);
1308 }
1309
1310 // Write to file
1311 TFile *f = TFile::Open(fpath, "RECREATE");
1312 if (f) {
1313 f->cd();
1314 fileinfo->Write("fileList", TObject::kSingleKey);
1315 f->Close();
1316 } else {
1317 Info("ExportFileList","error creating dataset file: %s", fpath);
1318 SafeDelete(fileinfo);
1319 return -1;
1320 }
1321
1322 // Cleanup
1323 SafeDelete(f);
1324 SafeDelete(fileinfo);
1325
1326 // We are done
1327 return 0;
1328}
1329
1330////////////////////////////////////////////////////////////////////////////////
1331/// Add friend dataset to this set. Only possible if the TDSet type is
1332/// a TTree or derived class. The friendset will be owned by this class
1333/// and deleted in its destructor.
1334
1335void TDSet::AddFriend(TDSet *friendset, const char* alias)
1336{
1337 if (!friendset) {
1338 Error("AddFriend", "The friend TDSet is null!");
1339 return;
1340 }
1341
1342 if (!fIsTree) {
1343 Error("AddFriend", "a friend set can only be added to a TTree TDSet");
1344 return;
1345 }
1346 TList *thisList = GetListOfElements();
1347 TList *friendsList = friendset->GetListOfElements();
1348 if (thisList->GetSize() != friendsList->GetSize() && friendsList->GetSize() != 1) {
1349 Error("AddFriend", "the friend dataset has %d elements while the main one has %d",
1350 thisList->GetSize(), friendsList->GetSize());
1351 return;
1352 }
1353 TIter next(thisList);
1354 TIter next2(friendsList);
1355 TDSetElement *friendElem = 0;
1356 if (friendsList->GetSize() == 1)
1357 friendElem = dynamic_cast<TDSetElement*> (friendsList->First());
1358 while(TDSetElement* e = dynamic_cast<TDSetElement*> (next())) {
1359 if (friendElem) // just one elem in the friend TDSet
1360 e->AddFriend(friendElem, alias);
1361 else
1362 e->AddFriend(dynamic_cast<TDSetElement*> (next2()), alias);
1363 }
1364}
1365
1366////////////////////////////////////////////////////////////////////////////////
1367/// Reset or initialize access to the elements.
1368
1370{
1371 if (!fIterator) {
1372 fIterator = new TIter(fElements);
1373 } else {
1374 fIterator->Reset();
1375 }
1376}
1377
1378////////////////////////////////////////////////////////////////////////////////
1379/// Returns number of entries in tree or objects in file. Returns -1 in
1380/// case of error.
1381
1382Long64_t TDSet::GetEntries(Bool_t isTree, const char *filename, const char *path,
1383 TString &objname)
1384{
1385 Double_t start = 0;
1386 if (gPerfStats) start = TTimeStamp();
1387
1388 // Take into acoount possible prefixes
1390 TString fname = gEnv->GetValue("Path.Localroot",""), pfx(fname);
1391 // Get the locality (disable warnings or errors in connection attempts)
1392 Int_t oldLevel = gErrorIgnoreLevel;
1394 if ((typ = TFile::GetType(filename, "", &fname)) != TFile::kLocal) fname = filename;
1395 gErrorIgnoreLevel = oldLevel;
1396 // Open the file
1397 TFile *file = TFile::Open(fname);
1398
1399 if (gPerfStats)
1400 gPerfStats->FileOpenEvent(file, filename, start);
1401
1402 if (file == 0) {
1403 ::SysError("TDSet::GetEntries",
1404 "cannot open file %s (type: %d, pfx: %s)", filename, typ, pfx.Data());
1405 return -1;
1406 }
1407
1408 TDirectory *dirsave = gDirectory;
1409 if (!file->cd(path)) {
1410 ::Error("TDSet::GetEntries", "cannot cd to %s", path);
1411 delete file;
1412 return -1;
1413 }
1414
1415 TDirectory *dir = gDirectory;
1416 dirsave->cd();
1417
1418 Long64_t entries;
1419 Bool_t fillname = kFALSE;
1420 if (isTree) {
1421
1422 TString on(objname);
1423 TString sreg(objname);
1424 // If a wild card we will use the first object of the type
1425 // requested compatible with the reg expression we got
1426 if (sreg.Length() <= 0 || sreg == "" || sreg.Contains("*")) {
1427 fillname = kTRUE;
1428 if (sreg.Contains("*"))
1429 sreg.ReplaceAll("*", ".*");
1430 else
1431 sreg = ".*";
1432 TRegexp re(sreg);
1433 if (dir->GetListOfKeys()) {
1434 TIter nxk(dir->GetListOfKeys());
1435 TKey *k = 0;
1436 Bool_t notfound = kTRUE;
1437 while ((k = (TKey *) nxk())) {
1438 if (!strcmp(k->GetClassName(), "TTree")) {
1439 TString kn(k->GetName());
1440 if (kn.Index(re) != kNPOS) {
1441 if (notfound) {
1442 on = kn;
1443 notfound = kFALSE;
1444 } else if (kn != on) {
1445 ::Warning("TDSet::GetEntries",
1446 "additional tree found in the file: %s", kn.Data());
1447 }
1448 }
1449 }
1450 }
1451 }
1452 }
1453
1454 TKey *key = dir->GetKey(on);
1455 if (key == 0) {
1456 ::Error("TDSet::GetEntries", "cannot find tree \"%s\" in %s",
1457 objname.Data(), filename);
1458 delete file;
1459 return -1;
1460 }
1461 TTree *tree = (TTree *) key->ReadObj();
1462 if (tree == 0) {
1463 // Error always reported?
1464 delete file;
1465 return -1;
1466 }
1467 entries = tree->GetEntries();
1468 delete tree;
1469
1470 // Return full name in case of wildcards
1471 objname = (fillname) ? on : objname;
1472
1473 } else {
1474 TList *keys = dir->GetListOfKeys();
1475 entries = keys->GetSize();
1476 }
1477
1478 delete file;
1479 return entries;
1480}
1481
1482////////////////////////////////////////////////////////////////////////////////
1483/// Draw expression varexp for specified entries.
1484/// Returns -1 in case of error or number of selected events in case of success.
1485/// This function accepts a TCut objects as argument.
1486/// Use the operator+ to concatenate cuts.
1487/// Example:
1488/// dset.Draw("x",cut1+cut2+cut3);
1489
1490Long64_t TDSet::Draw(const char *varexp, const TCut &selection, Option_t *option,
1491 Long64_t nentries, Long64_t firstentry)
1492{
1493 return Draw(varexp, selection.GetTitle(), option, nentries, firstentry);
1494}
1495
1496////////////////////////////////////////////////////////////////////////////////
1497/// Draw expression varexp for specified entries.
1498/// Returns -1 in case of error or number of selected events in case of success.
1499/// For more see TTree::Draw().
1500
1501Long64_t TDSet::Draw(const char *varexp, const char *selection, Option_t *option,
1502 Long64_t nentries, Long64_t firstentry)
1503{
1504 if (!IsValid() || !fElements->GetSize()) {
1505 Error("Draw", "not a correctly initialized TDSet");
1506 return -1;
1507 }
1508
1509 if (gProof)
1510 return gProof->DrawSelect(this, varexp, selection, option, nentries,
1511 firstentry);
1512
1513 Error("Draw", "no active PROOF session");
1514 return -1;
1515}
1516
1517////////////////////////////////////////////////////////////////////////////////
1518/// Start the TTreeViewer on this TTree.
1519
1521{
1522 if (gROOT->IsBatch()) {
1523 Warning("StartViewer", "viewer cannot run in batch mode");
1524 return;
1525 }
1526
1527 if (!gProof) {
1528 Error("StartViewer", "no PROOF found");
1529 return;
1530 }
1531 if (!IsTree()) {
1532 Error("StartViewer", "TDSet contents should be of type TTree (or subtype)");
1533 return;
1534 }
1535 fProofChain = new TProofChain(this, kTRUE);
1536
1538 if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualTreeViewer"))) {
1539 if (h->LoadPlugin() == -1)
1540 return;
1542 }
1543}
1544
1545////////////////////////////////////////////////////////////////////////////////
1546/// Returns a tree header containing the branches' structure of the dataset.
1547
1549{
1550 return proof->GetTreeHeader(this);
1551}
1552
1553////////////////////////////////////////////////////////////////////////////////
1554/// Check if all elements are valid.
1555
1557{
1560
1563 TIter nextElem(GetListOfElements());
1564 while (TDSetElement *elem = dynamic_cast<TDSetElement*>(nextElem())) {
1565 if (!elem->GetValid()) {
1567 return kFALSE;
1568 }
1569 }
1570 return kTRUE;
1571}
1572
1573////////////////////////////////////////////////////////////////////////////////
1574/// Remove TDSetElement 'elem' from the list.
1575/// Return 0 on success, -1 if the element is not in the list
1576
1578{
1579 if (!elem || !(((THashList *)(GetListOfElements()))->Remove(elem)))
1580 return -1;
1581
1582 if (deleteElem)
1583 SafeDelete(elem);
1584 return 0;
1585}
1586
1587////////////////////////////////////////////////////////////////////////////////
1588/// Validate the TDSet by opening files.
1589
1591{
1592 TIter nextElem(GetListOfElements());
1593 while (TDSetElement *elem = dynamic_cast<TDSetElement*>(nextElem())) {
1594 if (!elem->GetValid())
1595 elem->Validate(IsTree());
1596 }
1597}
1598
1599////////////////////////////////////////////////////////////////////////////////
1600/// Resolve the end-point URL for the current elements of this data set
1601/// If the removeMissing option is set to kTRUE, remove the TDSetElements
1602/// that can not be located.
1603/// The method returns the list of removed TDSetElements in *listOfMissingFiles
1604/// if the latter is defined (the list must be created outside).
1605
1606void TDSet::Lookup(Bool_t removeMissing, TList **listOfMissingFiles)
1607{
1608 // If an entry- or event- list has been given, assign the relevant portions
1609 // to each element; this allows to look-up only for the elements which have
1610 // something to be processed, so it is better to do it before the real look-up
1611 // operations.
1613
1614 TString msg("Looking up for exact location of files");
1615 UInt_t n = 0;
1616 UInt_t ng = 0;
1617 UInt_t tot = GetListOfElements()->GetSize();
1618 UInt_t n2 = (tot > 50) ? (UInt_t) tot / 50 : 1;
1619 Bool_t st = kTRUE;
1620 TIter nextElem(GetListOfElements());
1621 while (TDSetElement *elem = dynamic_cast<TDSetElement*>(nextElem())) {
1622 if (elem->GetNum() != 0) { // -1 means "all entries"
1623 ng++;
1624 if (!elem->GetValid())
1625 if (elem->Lookup(kFALSE))
1626 if (removeMissing) {
1627 if (Remove(elem, kFALSE))
1628 Error("Lookup", "Error removing a missing file");
1629 if (listOfMissingFiles)
1630 (*listOfMissingFiles)->Add(elem->GetFileInfo(fType));
1631 }
1632 }
1633 n++;
1634 // Notify the client
1635 if (gProof && (n > 0 && !(n % n2)))
1636 gProof->SendDataSetStatus(msg, n, tot, st);
1637 // Break if we have been asked to stop
1639 break;
1640 }
1641 // Notify the client if not all the files have entries to be processed
1642 // (which may happen if an entry-list is used)
1643 if (ng < tot && gProofServ) {
1644 msg = Form("Files with entries to be processed: %d (out of %d)\n", ng, tot);
1646 } else {
1647 // Final notification to the client
1648 if (gProof) gProof->SendDataSetStatus(msg, n, tot, st);
1649 }
1650 // Done
1651 return;
1652}
1653
1654////////////////////////////////////////////////////////////////////////////////
1655/// Flag all the elements as looked-up, so to avoid opening the files
1656/// if the functionality is not supported
1657
1659{
1660 TIter nextElem(GetListOfElements());
1661 while (TDSetElement *elem = dynamic_cast<TDSetElement*>(nextElem()))
1662 elem->SetLookedUp();
1663}
1664
1665////////////////////////////////////////////////////////////////////////////////
1666/// Validate the TDSet against another TDSet.
1667/// Only validates elements in common from input TDSet.
1668
1670{
1671 THashList bestElements;
1672 bestElements.SetOwner();
1673 TList namedHolder;
1674 namedHolder.SetOwner();
1675 TIter nextOtherElem(dset->GetListOfElements());
1676 while (TDSetElement *elem = dynamic_cast<TDSetElement*>(nextOtherElem())) {
1677 if (!elem->GetValid()) continue;
1678 TString dir_file_obj = elem->GetDirectory();
1679 dir_file_obj += "_";
1680 dir_file_obj += TUrl(elem->GetFileName()).GetFileAndOptions();
1681 dir_file_obj += "_";
1682 dir_file_obj += elem->GetObjName();
1683 TPair *p = dynamic_cast<TPair*>(bestElements.FindObject(dir_file_obj));
1684 if (p) {
1685 TDSetElement *prevelem = dynamic_cast<TDSetElement*>(p->Value());
1686 if (prevelem) {
1687 Long64_t entries = prevelem->GetFirst()+prevelem->GetNum();
1688 if (entries<elem->GetFirst()+elem->GetNum()) {
1689 bestElements.Remove(p);
1690 bestElements.Add(new TPair(p->Key(), elem));
1691 delete p;
1692 }
1693 }
1694 } else {
1695 TNamed* named = new TNamed(dir_file_obj, dir_file_obj);
1696 namedHolder.Add(named);
1697 bestElements.Add(new TPair(named, elem));
1698 }
1699 }
1700
1701 TIter nextElem(GetListOfElements());
1702 while (TDSetElement *elem = dynamic_cast<TDSetElement*>(nextElem())) {
1703 if (!elem->GetValid()) {
1704 TString dir_file_obj = elem->GetDirectory();
1705 dir_file_obj += "_";
1706 dir_file_obj += TUrl(elem->GetFileName()).GetFileAndOptions();
1707 dir_file_obj += "_";
1708 dir_file_obj += elem->GetObjName();
1709 if (TPair *p = dynamic_cast<TPair*>(bestElements.FindObject(dir_file_obj))) {
1710 TDSetElement* validelem = dynamic_cast<TDSetElement*>(p->Value());
1711 elem->Validate(validelem);
1712 }
1713 }
1714 }
1715}
1716
1717//
1718// To handle requests coming from version 3 client / masters we need
1719// a special streamer
1720////////////////////////////////////////////////////////////////////////////////
1721/// Stream an object of class TDSetElement.
1722
1723void TDSetElement::Streamer(TBuffer &R__b)
1724{
1725 if (R__b.IsReading()) {
1726 UInt_t R__s, R__c;
1727 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1729 if (R__v > 4) {
1730 R__b.ReadClassBuffer(TDSetElement::Class(), this, R__v, R__s, R__c);
1731 } else {
1732 // For version 3 client / masters we need a special streamer
1734 if (R__v > 3) {
1735 TNamed::Streamer(R__b);
1736 } else {
1737 // Old versions were not deriving from TNamed and had the
1738 // file name and the object type name in the first two members
1739 TObject::Streamer(R__b);
1740 TString name, title;
1741 R__b >> name >> title;
1742 SetNameTitle(name, title);
1743 }
1744 // Now we read the standard part
1745 R__b >> fDirectory;
1746 R__b >> fFirst;
1747 R__b >> fNum;
1748 R__b >> fMsd;
1749 R__b >> fTDSetOffset;
1750 TEventList *evl;
1751 R__b >> evl;
1752 R__b >> fValid;
1753 R__b >> fEntries;
1754
1755 // Special treatment waiting for proper retrieving of stl containers
1756 FriendsList_t *friends = new FriendsList_t;
1757 static TClassRef classFriendsList = TClass::GetClass(typeid(FriendsList_t));
1758 R__b.ReadClassBuffer( classFriendsList, friends, classFriendsList->GetClassVersion(), 0, 0);
1759 if (friends) {
1760 // Convert friends to a TList (to be written)
1761 fFriends = new TList();
1762 fFriends->SetOwner();
1763 for (FriendsList_t::iterator i = friends->begin();
1764 i != friends->end(); ++i) {
1765 TDSetElement *dse = (TDSetElement *) i->first->Clone();
1766 fFriends->Add(new TPair(dse, new TObjString(i->second.Data())));
1767 }
1768 }
1769 // the value for fIsTree (only older versions are sending it)
1770 Bool_t tmpIsTree;
1771 R__b >> tmpIsTree;
1772 R__b.CheckByteCount(R__s, R__c, TDSetElement::IsA());
1773 }
1774 } else {
1775 if (TestBit(kWriteV3)) {
1776 // For version 3 client / masters we need a special streamer
1777 R__b << Version_t(3);
1778 TObject::Streamer(R__b);
1779 R__b << TString(GetName());
1780 R__b << TString(GetTitle());
1781 R__b << fDirectory;
1782 R__b << fFirst;
1783 R__b << fNum;
1784 R__b << fMsd;
1785 R__b << fTDSetOffset;
1786 R__b << (TEventList *)0;
1787 R__b << fValid;
1788 R__b << fEntries;
1789
1790 // Special treatment waiting for proper retrieving of stl containers
1791 FriendsList_t *friends = new FriendsList_t;
1792 if (fFriends) {
1793 TIter nxf(fFriends);
1794 TPair *p = 0;
1795 while ((p = (TPair *)nxf()))
1796 friends->push_back(std::make_pair((TDSetElement *)p->Key(),
1797 TString(((TObjString *)p->Value())->GetName())));
1798 }
1799 static TClassRef classFriendsList = TClass::GetClass(typeid(FriendsList_t));
1800 R__b.WriteClassBuffer( classFriendsList, &friends );
1801
1802 // Older versions had an unused boolean called fIsTree: we fill it
1803 // with its default value
1804 R__b << kFALSE;
1805 } else {
1806 R__b.WriteClassBuffer(TDSetElement::Class(),this);
1807 }
1808 }
1809}
1810
1811////////////////////////////////////////////////////////////////////////////////
1812/// Stream an object of class TDSet.
1813
1814void TDSet::Streamer(TBuffer &R__b)
1815{
1816 if (R__b.IsReading()) {
1817 UInt_t R__s, R__c;
1818 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1820 if (R__v > 3) {
1821 R__b.ReadClassBuffer(TDSet::Class(), this, R__v, R__s, R__c);
1822 } else {
1823 // For version 3 client / masters we need a special streamer
1825 TNamed::Streamer(R__b);
1826 R__b >> fDir;
1827 R__b >> fType;
1828 R__b >> fObjName;
1829 TList elems;
1830 elems.Streamer(R__b);
1831 elems.SetOwner(kFALSE);
1832 if (elems.GetSize() > 0) {
1833 fElements = new THashList;
1835 TDSetElement *e = 0;
1836 TIter nxe(&elems);
1837 while ((e = (TDSetElement *)nxe())) {
1838 fElements->Add(e);
1839 }
1840 } else {
1841 fElements = 0;
1842 }
1843 R__b >> fIsTree;
1844 }
1845 } else {
1846 if (TestBit(kWriteV3)) {
1847 // For version 3 client / masters we need a special streamer
1848 R__b << Version_t(3);
1849 TNamed::Streamer(R__b);
1850 R__b << fDir;
1851 R__b << fType;
1852 R__b << fObjName;
1853 TList elems;
1854 if (fElements) {
1855 elems.SetOwner(kFALSE);
1856 if (fElements->GetSize() > 0) {
1857 TDSetElement *e = 0;
1858 TIter nxe(fElements);
1859 while ((e = (TDSetElement *)nxe()))
1860 elems.Add(e);
1861 }
1862 }
1863 elems.Streamer(R__b);
1864 R__b << fIsTree;
1865 } else {
1866 R__b.WriteClassBuffer(TDSet::Class(),this);
1867 }
1868 }
1869}
1870
1871////////////////////////////////////////////////////////////////////////////////
1872/// Set/Reset the 'OldStreamer' bit in this instance and its elements.
1873/// Needed for backward compatibility in talking to old client / masters.
1874
1876{
1877 if (on)
1879 else
1881 // Loop over dataset elements
1882 TIter nxe(GetListOfElements());
1883 TObject *o = 0;
1884 while ((o = nxe()))
1885 if (on)
1887 else
1889}
1890
1891////////////////////////////////////////////////////////////////////////////////
1892/// Set entry (or event) list for this data set
1893
1895{
1896 if (!aList) {
1897 // Nothing to do, except making sure to disable any previous setting
1898 fEntryList = 0;
1899 // Reset the element lists
1900 // TEntryList
1901 TIter next(fElements);
1902 TDSetElement *el=0;
1903 while ((el=(TDSetElement*)next())){
1904 el->SetEntryList(aList);
1905 el->Reset();
1906 }
1907 return;
1908 }
1909
1911
1912 // Global entry list for all the datasets
1913 TIter nxds(fElements);
1914 TDSet *ds = 0;
1915 while ((ds = (TDSet *) nxds()))
1916 ds->SetEntryList(aList);
1917
1918 } else {
1919
1920 // Link the proper object
1921 TEventList *evl = 0;
1922 TEntryList *enl = dynamic_cast<TEntryList*>(aList);
1923 if (!enl)
1924 evl = dynamic_cast<TEventList*>(aList);
1925 if (!enl && !evl) {
1926 Error("SetEntryList", "type of input object must be either TEntryList "
1927 "or TEventList (found: '%s' - do nothing", aList->ClassName());
1928 return;
1929 }
1930
1931 // Action depends on the type
1932 fEntryList = (enl) ? enl : (TEntryList *)evl;
1933 }
1934 // Done
1935 return;
1936}
1937
1938////////////////////////////////////////////////////////////////////////////////
1939/// Splits the main entry (or event) list into sub-lists for the elements of
1940/// thet data set
1941
1943{
1945 // Global entry list for all the datasets
1946 TIter nxds(fElements);
1947 TDSet *ds = 0;
1948 while ((ds = (TDSet *) nxds()))
1949 ds->SplitEntryList();
1950 // Done
1951 return;
1952 }
1953
1954 if (!fEntryList) {
1955 if (gDebug > 0)
1956 Info("SplitEntryList", "no entry- (or event-) list to split - do nothing");
1957 return;
1958 }
1959
1960 // Action depend on type of list
1961 TEntryList *enl = dynamic_cast<TEntryList *>(fEntryList);
1962 if (enl) {
1963 // TEntryList
1964 TIter next(fElements);
1965 TDSetElement *el=0;
1966 TEntryList *sublist = 0;
1967 while ((el=(TDSetElement*)next())){
1968 sublist = enl->GetEntryList(el->GetObjName(), el->GetFileName());
1969 if (sublist){
1970 el->SetEntryList(sublist);
1971 el->SetNum(sublist->GetN());
1972 } else {
1973 sublist = new TEntryList("", "");
1974 el->SetEntryList(sublist);
1975 el->SetNum(0);
1976 }
1977 }
1978 } else {
1979 TEventList *evl = dynamic_cast<TEventList *>(fEntryList);
1980 if (evl) {
1981 // TEventList
1982 TIter next(fElements);
1983 TDSetElement *el, *prev;
1984
1985 prev = dynamic_cast<TDSetElement*> (next());
1986 if (!prev)
1987 return;
1988 Long64_t low = prev->GetTDSetOffset();
1989 Long64_t high = low;
1990 Long64_t currPos = 0;
1991 do {
1992 el = dynamic_cast<TDSetElement*> (next());
1993 // kMaxLong64 means infinity
1994 high = (el == 0) ? kMaxLong64 : el->GetTDSetOffset();
1995#ifdef DEBUG
1996 while (currPos < evl->GetN() && evl->GetEntry(currPos) < low) {
1997 Error("SplitEntryList",
1998 "TEventList: event outside of the range of any of the TDSetElements");
1999 currPos++; // unnecessary check
2000 }
2001#endif
2002 TEventList* nevl = new TEventList();
2003 while (currPos < evl->GetN() && evl->GetEntry((Int_t)currPos) < high) {
2004 nevl->Enter(evl->GetEntry((Int_t)currPos) - low);
2005 currPos++;
2006 }
2007 prev->SetEntryList(nevl);
2008 prev->SetNum(nevl->GetN());
2009 low = high;
2010 prev = el;
2011 } while (el);
2012 }
2013 }
2014}
2015
2016////////////////////////////////////////////////////////////////////////////////
2017/// Return the number of files in the dataset
2018
2020{
2021 Int_t nf = -1;
2022 if (fElements) {
2023 nf = 0;
2025 TIter nxds(fElements);
2026 TDSet *ds = 0;
2027 while ((ds = (TDSet *) nxds()))
2028 if (ds->GetListOfElements()) nf += ds->GetListOfElements()->GetSize();
2029 } else {
2030 nf = fElements->GetSize();
2031 }
2032 }
2033 // Done
2034 return nf;
2035}
#define SafeDelete(p)
Definition RConfig.hxx:537
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
const Ssiz_t kNPOS
Definition RtypesCore.h:124
short Version_t
Definition RtypesCore.h:65
unsigned int UInt_t
Definition RtypesCore.h:46
const Bool_t kFALSE
Definition RtypesCore.h:101
bool Bool_t
Definition RtypesCore.h:63
double Double_t
Definition RtypesCore.h:59
const Long64_t kMaxLong64
Definition RtypesCore.h:120
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
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
constexpr Int_t kError
Definition TError.h:46
R__EXTERN Int_t gErrorIgnoreLevel
Definition TError.h:127
char name[80]
Definition TGX11.cxx:110
int type
Definition TGX11.cxx:121
int nentries
R__EXTERN TProofServ * gProofServ
Definition TProofServ.h:347
R__EXTERN TProof * gProof
Definition TProof.h:1077
Int_t gDebug
Definition TROOT.cxx:592
#define gROOT
Definition TROOT.h:404
char * Form(const char *fmt,...)
void Printf(const char *fmt,...)
@ kFileExists
Definition TSystem.h:44
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
#define gPerfStats
T1 fFirst
Definition X11Events.mm:86
static struct mg_connection * fc(struct mg_context *ctx)
Definition civetweb.c:3728
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
Bool_t IsReading() const
Definition TBuffer.h:86
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
A TChainElement describes a component of a TChain.
virtual Long64_t GetEntries() const
virtual Bool_t HasBeenLookedUp()
A chain is a collection of files containing TTree objects.
Definition TChain.h:33
TObjArray * GetListOfFiles() const
Definition TChain.h:110
TClassRef is used to implement a permanent reference to a TClass object.
Definition TClassRef.h:28
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:80
Version_t GetClassVersion() const
Definition TClass.h:417
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2966
Collection abstract base class.
Definition TCollection.h:65
virtual const char * GetName() const
Return name of this collection.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void Add(TObject *obj)=0
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write all objects in this collection.
A specialized string object used for TTree selections.
Definition TCut.h:25
Manages an element of a TDSet.
Definition TDSet.h:66
TFileInfo * GetFileInfo(const char *type="TTree")
Return the content of this element in the form of a TFileInfo.
Definition TDSet.cxx:231
TString fDirectory
Definition TDSet.h:80
void Print(Option_t *options="") const
Print a TDSetElement. When option="a" print full data.
Definition TDSet.cxx:261
void SetEntries(Long64_t ent)
Definition TDSet.h:116
Long64_t GetEntries(Bool_t istree=kTRUE, Bool_t openfile=kTRUE)
Returns number of entries in tree or objects in file.
Definition TDSet.cxx:429
const char * GetObjName() const
Definition TDSet.h:120
Long64_t GetNum() const
Definition TDSet.h:114
@ kCorrupted
Definition TDSet.h:74
@ kNewPacket
Definition TDSet.h:76
@ kHasBeenLookedUp
Definition TDSet.h:71
void Validate(Bool_t isTree)
Validate by opening the file.
Definition TDSet.cxx:275
TString fDataSet
Definition TDSet.h:91
Bool_t HasBeenLookedUp() const
Definition TDSet.h:96
std::list< std::pair< TDSetElement *, TString > > FriendsList_t
Definition TDSet.h:68
Bool_t fValid
Definition TDSet.h:87
virtual ~TDSetElement()
Clean up the element.
Definition TDSet.cxx:146
TString fMsd
Definition TDSet.h:83
void SetLookedUp()
Definition TDSet.h:139
TList * fFriends
Definition TDSet.h:89
TList * fAssocObjList
Definition TDSet.h:92
void Reset()
Reset TDSet element.
Definition TDSet.cxx:158
void SetNum(Long64_t num)
Definition TDSet.h:118
const char * GetDirectory() const
Return directory where to look for object.
Definition TDSet.cxx:253
virtual void DeleteFriends()
Deletes the list of friends and all the friends on the list.
Definition TDSet.cxx:400
void SetEntryList(TObject *aList, Long64_t first=-1, Long64_t num=-1)
Set entry (or event) list for this element.
Definition TDSet.cxx:599
void AddAssocObj(TObject *assocobj)
Add an associated object to the list.
Definition TDSet.cxx:634
Long64_t GetTDSetOffset() const
Definition TDSet.h:128
Bool_t GetValid() const
Definition TDSet.h:119
TObject * fEntryList
Definition TDSet.h:86
Float_t fMaxProcTime
Definition TDSet.h:94
Long64_t fTDSetOffset
Definition TDSet.h:84
Int_t Lookup(Bool_t force=kFALSE)
Resolve end-point URL for this element Return 0 on success and -1 otherwise.
Definition TDSet.cxx:534
virtual void AddFriend(TDSetElement *friendElement, const char *alias)
Add friend TDSetElement to this set. The friend element will be copied to this object.
Definition TDSet.cxx:376
const char * GetMsd() const
Definition TDSet.h:117
Long64_t fFirst
Definition TDSet.h:81
const char * GetFileName() const
Definition TDSet.h:111
TDSetElement()
Default constructor.
Definition TDSet.cxx:63
Long64_t fNum
Definition TDSet.h:82
Long64_t fEntries
Definition TDSet.h:88
TObject * GetAssocObj(Long64_t i, Bool_t isentry=kFALSE)
Get i-th associated object.
Definition TDSet.cxx:652
Int_t Compare(const TObject *obj) const
Compare elements by filename (and the fFirst).
Definition TDSet.cxx:351
Long64_t GetFirst() const
Definition TDSet.h:112
Int_t MergeElement(TDSetElement *elem)
Check if 'elem' is overlapping or subsequent and, if the case, return a merged element.
Definition TDSet.cxx:182
This class implements a data set to be used for PROOF processing.
Definition TDSet.h:153
void SplitEntryList()
for browsing purposes
Definition TDSet.cxx:1942
TIter * fSrvMapsIter
list for mapping server coordinates for files
Definition TDSet.h:184
virtual TDSetElement * Next(Long64_t totalEntries=-1)
Returns next TDSetElement.
Definition TDSet.cxx:413
virtual void StartViewer()
Start the TTreeViewer on this TTree.
Definition TDSet.cxx:1520
virtual void SetEntryList(TObject *aList)
Set entry (or event) list for this data set.
Definition TDSet.cxx:1894
Int_t Remove(TDSetElement *elem, Bool_t deleteElem=kTRUE)
Remove TDSetElement 'elem' from the list.
Definition TDSet.cxx:1577
TString fDir
Definition TDSet.h:177
void AddInput(TObject *obj)
Add objects that might be needed during the processing of the selector (see Process()).
Definition TDSet.cxx:966
TProofChain * fProofChain
entry (or event) list for processing
Definition TDSet.h:169
TString fType
Definition TDSet.h:178
void SetLookedUp()
Flag all the elements as looked-up, so to avoid opening the files if the functionality is not support...
Definition TDSet.cxx:1658
virtual ~TDSet()
Cleanup.
Definition TDSet.cxx:901
virtual Bool_t Add(const char *file, const char *objname=0, const char *dir=0, Long64_t first=0, Long64_t num=-1, const char *msd=0)
Add file to list of files to be analyzed.
Definition TDSet.cxx:1052
virtual void Reset()
Reset or initialize access to the elements.
Definition TDSet.cxx:1369
Bool_t ElementsValid()
Check if all elements are valid.
Definition TDSet.cxx:1556
Bool_t IsTree() const
Definition TDSet.h:225
TList * fSrvMaps
current element
Definition TDSet.h:183
static Long64_t GetEntries(Bool_t isTree, const char *filename, const char *path, TString &objname)
Returns number of entries in tree or objects in file.
Definition TDSet.cxx:1382
Int_t GetNumOfFiles()
Return the number of files in the dataset.
Definition TDSet.cxx:2019
void Lookup(Bool_t removeMissing=kFALSE, TList **missingFiles=0)
Resolve the end-point URL for the current elements of this data set If the removeMissing option is se...
Definition TDSet.cxx:1606
TIter * fIterator
Definition TDSet.h:181
void Print(Option_t *option="") const
Print TDSet basic or full data. When option="a" print full data.
Definition TDSet.cxx:1008
Int_t ExportFileList(const char *filepath, Option_t *opt="")
Export TDSetElements files as list of TFileInfo objects in file 'fpath'.
Definition TDSet.cxx:1277
virtual TTree * GetTreeHeader(TProof *proof)
Returns a tree header containing the branches' structure of the dataset.
Definition TDSet.cxx:1548
virtual void AddFriend(TDSet *friendset, const char *alias)
Add friend dataset to this set.
Definition TDSet.cxx:1335
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
void SetSrvMaps(TList *srvmaps=0)
Set (or unset) the list for mapping servers coordinate for files.
Definition TDSet.cxx:1172
TObject * GetOutput(const char *name)
Get specified object that has been produced during the processing (see Process()).
Definition TDSet.cxx:988
TDSetElement * fCurrent
iterator on fElements
Definition TDSet.h:182
void Validate()
Validate the TDSet by opening files.
Definition TDSet.cxx:1590
const char * GetType() const
Definition TDSet.h:228
TList * GetOutputList()
Get list with all object created during processing (see Process()).
Definition TDSet.cxx:998
Bool_t IsValid() const
Definition TDSet.h:226
THashList * fElements
Definition TDSet.h:180
void SetWriteV3(Bool_t on=kTRUE)
Set/Reset the 'OldStreamer' bit in this instance and its elements.
Definition TDSet.cxx:1875
TString fObjName
Definition TDSet.h:179
TList * GetListOfElements() const
Definition TDSet.h:231
Bool_t fIsTree
Definition TDSet.h:167
void SetDirectory(const char *dir)
Set/change directory.
Definition TDSet.cxx:1041
void SetObjName(const char *objname)
Set/change object name.
Definition TDSet.cxx:1026
const char * GetDirectory() const
Definition TDSet.h:230
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
TDSet()
iterator on fSrvMaps
Definition TDSet.cxx:704
const char * GetObjName() const
Definition TDSet.h:229
void ClearInput()
Clear input object list.
Definition TDSet.cxx:978
TObject * fEntryList
Definition TDSet.h:168
@ kSomeInvalid
Definition TDSet.h:161
@ kEmpty
Definition TDSet.h:159
@ kWriteV3
Definition TDSet.h:158
@ kValidityChecked
Definition TDSet.h:160
@ kMultiDSet
Definition TDSet.h:162
static Bool_t CheckDataSetSrvMaps(TUrl *furl, TString &fn, TList *srvmaplist=0)
Check if the dataset server mappings apply to the url defined by 'furl'.
Describe directory structure in memory.
Definition TDirectory.h:45
virtual Bool_t cd()
Change current directory to "this" directory.
virtual TKey * GetKey(const char *, Short_t=9999) const
Definition TDirectory.h:221
virtual TList * GetListOfKeys() const
Definition TDirectory.h:223
A List of entry numbers in a TTree or TChain.
Definition TEntryList.h:26
virtual TEntryList * GetEntryList(const char *treename, const char *filename, Option_t *opt="")
Return the entry list, corresponding to treename and filename By default, the filename is first tried...
virtual void SetEntriesToProcess(Long64_t nen)
Definition TEntryList.h:100
virtual Long64_t GetN() const
Definition TEntryList.h:77
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
A TEventList object is a list of selected events (entries) in a TTree.
Definition TEventList.h:31
virtual Long64_t GetEntry(Int_t index) const
Return value of entry at index in the list.
virtual Int_t GetN() const
Definition TEventList.h:56
virtual void Enter(Long64_t entry)
Enter element entry into the list.
Class describing a generic file including meta information.
Definition TFileInfo.h:39
Bool_t AddMetaData(TObject *meta)
Add's a meta data object to the file info object.
TUrl * GetFirstUrl() const
Definition TFileInfo.h:72
TList * GetMetaDataList() const
Definition TFileInfo.h:83
TFileInfoMeta * GetMetaData(const char *meta=0) const
Get meta data object with specified name.
virtual Bool_t Matches(const char *s)
Definition TFileStager.h:46
static TFileStager * Open(const char *stager)
Open a stager, after having loaded the relevant plug-in.
virtual Int_t Locate(const char *u, TString &f)
Just check if the file exists locally.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition TFile.h:54
static EFileType GetType(const char *name, Option_t *option="", TString *prefix=nullptr)
Resolve the file type as a function of the protocol field in 'name'.
Definition TFile.cxx:4739
EFileType
File type.
Definition TFile.h:196
@ kDefault
Definition TFile.h:196
@ kLocal
Definition TFile.h:196
@ kNet
Definition TFile.h:196
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:4025
A TFriendElement TF describes a TTree object TF in a file.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
TObject * FindObject(const char *name) const
Find object using its name.
TObject * Remove(TObject *obj)
Remove object from the list.
TObject * Next()
void Reset()
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition TKey.h:28
virtual const char * GetClassName() const
Definition TKey.h:76
virtual TObject * ReadObj()
To read a TObject* from the file.
Definition TKey.cxx:750
A doubly linked list.
Definition TList.h:38
virtual void Add(TObject *obj)
Definition TList.h:81
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition TList.cxx:822
virtual void AddFirst(TObject *obj)
Add object at the beginning of the list.
Definition TList.cxx:100
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition TList.cxx:578
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:357
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition TList.cxx:693
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:659
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
TString fTitle
Definition TNamed.h:33
TNamed()
Definition TNamed.h:36
TString fName
Definition TNamed.h:32
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
virtual const char * GetTitle() const
Returns title of object.
Definition TNamed.h:48
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition TNamed.cxx:74
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition TNamed.cxx:154
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:41
@ kSingleKey
write collection with single key
Definition TObject.h:91
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:429
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:201
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
Definition TObject.cxx:977
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:200
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 void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:963
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
Definition TObject.cxx:622
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
Class used by TMap to store (key,value) pairs.
Definition TMap.h:102
TObject * Value() const
Definition TMap.h:121
TObject * Key() const
Definition TMap.h:120
Longptr_t ExecPlugin(int nargs, const T &... params)
void SendAsynMessage(const char *msg, Bool_t lf=kTRUE)
Send an asychronous message to the master / client .
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition TProof.h:316
@ kRunning
Definition TProof.h:371
virtual Long64_t DrawSelect(TDSet *dset, const char *varexp, const char *selection="", Option_t *option="", Long64_t nentries=-1, Long64_t firstentry=0)
Execute the specified drawing action on a data set (TDSet).
Definition TProof.cxx:6146
void SendDataSetStatus(const char *msg, UInt_t n, UInt_t tot, Bool_t st)
Send or notify data set status.
Definition TProof.cxx:9336
ERunStatus GetRunStatus() const
Definition TProof.h:943
Bool_t IsLite() const
Definition TProof.h:933
TList * GetOutputList()
Get list with all object created during processing (see Process()).
Definition TProof.cxx:9808
TObject * GetOutput(const char *name)
Get specified object that has been produced during the processing (see Process()).
Definition TProof.cxx:9762
virtual TTree * GetTreeHeader(TDSet *tdset)
Creates a tree header (a tree with nonexisting files) object for the DataSet.
Definition TProof.cxx:10042
virtual Long64_t Process(TDSet *dset, const char *selector, Option_t *option="", Long64_t nentries=-1, Long64_t firstentry=0)
Process a data set (TDSet) using the specified selector (.C) file or Tselector object Entry- or event...
Definition TProof.cxx:5303
void ClearInput()
Clear input object list.
Definition TProof.cxx:9742
void AddInput(TObject *obj)
Add objects that might be needed during the processing of the selector (see Process()).
Definition TProof.cxx:9734
Regular expression class.
Definition TRegexp.h:31
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
Ssiz_t Length() const
Definition TString.h:410
TString & Insert(Ssiz_t pos, const char *s)
Definition TString.h:649
Int_t Atoi() const
Return integer value of string.
Definition TString.cxx:1946
const char * Data() const
Definition TString.h:369
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition TString.cxx:1788
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:692
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:615
Bool_t IsNull() const
Definition TString.h:407
TString & Remove(Ssiz_t pos)
Definition TString.h:673
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2336
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2314
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:624
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:639
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1274
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1081
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1296
virtual Bool_t IsAbsoluteFileName(const char *dir)
Return true if dir is an absolute pathname.
Definition TSystem.cxx:952
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:872
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1381
The TTimeStamp encapsulates seconds and ns since EPOCH.
Definition TTimeStamp.h:71
A TTree represents a columnar dataset.
Definition TTree.h:79
static constexpr Long64_t kMaxEntries
Definition TTree.h:226
This class represents a WWW compatible URL.
Definition TUrl.h:33
const char * GetAnchor() const
Definition TUrl.h:70
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition TUrl.cxx:389
void SetAnchor(const char *anchor)
Definition TUrl.h:86
const char * GetFileAndOptions() const
Return the file and its options (the string specified behind the ?).
Definition TUrl.cxx:503
void SetUrl(const char *url, Bool_t defaultIsFile=kFALSE)
Parse url character string and split in its different subcomponents.
Definition TUrl.cxx:110
void SetOptions(const char *opt)
Definition TUrl.h:87
const char * GetOptions() const
Definition TUrl.h:71
const char * GetProtocol() const
Definition TUrl.h:64
const Int_t n
Definition legend1.C:16
Definition file.py:1
Definition first.py:1
Definition tree.py:1
th1 Draw()
auto * m
Definition textangle.C:8