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\"",
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
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
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
1537 const char *hname = gEnv->GetValue("TreeViewer.Name", "TTreeViewer");
1538 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualTreeViewer", hname)) {
1539 if (h->LoadPlugin() != -1)
1540 h->ExecPlugin(1,fProofChain);
1541 }
1542}
1543
1544////////////////////////////////////////////////////////////////////////////////
1545/// Returns a tree header containing the branches' structure of the dataset.
1546
1548{
1549 return proof->GetTreeHeader(this);
1550}
1551
1552////////////////////////////////////////////////////////////////////////////////
1553/// Check if all elements are valid.
1554
1556{
1559
1562 TIter nextElem(GetListOfElements());
1563 while (TDSetElement *elem = dynamic_cast<TDSetElement*>(nextElem())) {
1564 if (!elem->GetValid()) {
1566 return kFALSE;
1567 }
1568 }
1569 return kTRUE;
1570}
1571
1572////////////////////////////////////////////////////////////////////////////////
1573/// Remove TDSetElement 'elem' from the list.
1574/// Return 0 on success, -1 if the element is not in the list
1575
1577{
1578 if (!elem || !(((THashList *)(GetListOfElements()))->Remove(elem)))
1579 return -1;
1580
1581 if (deleteElem)
1582 SafeDelete(elem);
1583 return 0;
1584}
1585
1586////////////////////////////////////////////////////////////////////////////////
1587/// Validate the TDSet by opening files.
1588
1590{
1591 TIter nextElem(GetListOfElements());
1592 while (TDSetElement *elem = dynamic_cast<TDSetElement*>(nextElem())) {
1593 if (!elem->GetValid())
1594 elem->Validate(IsTree());
1595 }
1596}
1597
1598////////////////////////////////////////////////////////////////////////////////
1599/// Resolve the end-point URL for the current elements of this data set
1600/// If the removeMissing option is set to kTRUE, remove the TDSetElements
1601/// that can not be located.
1602/// The method returns the list of removed TDSetElements in *listOfMissingFiles
1603/// if the latter is defined (the list must be created outside).
1604
1605void TDSet::Lookup(Bool_t removeMissing, TList **listOfMissingFiles)
1606{
1607 // If an entry- or event- list has been given, assign the relevant portions
1608 // to each element; this allows to look-up only for the elements which have
1609 // something to be processed, so it is better to do it before the real look-up
1610 // operations.
1612
1613 TString msg("Looking up for exact location of files");
1614 UInt_t n = 0;
1615 UInt_t ng = 0;
1616 UInt_t tot = GetListOfElements()->GetSize();
1617 UInt_t n2 = (tot > 50) ? (UInt_t) tot / 50 : 1;
1618 Bool_t st = kTRUE;
1619 TIter nextElem(GetListOfElements());
1620 while (TDSetElement *elem = dynamic_cast<TDSetElement*>(nextElem())) {
1621 if (elem->GetNum() != 0) { // -1 means "all entries"
1622 ng++;
1623 if (!elem->GetValid())
1624 if (elem->Lookup(kFALSE))
1625 if (removeMissing) {
1626 if (Remove(elem, kFALSE))
1627 Error("Lookup", "Error removing a missing file");
1628 if (listOfMissingFiles)
1629 (*listOfMissingFiles)->Add(elem->GetFileInfo(fType));
1630 }
1631 }
1632 n++;
1633 // Notify the client
1634 if (gProof && (n > 0 && !(n % n2)))
1635 gProof->SendDataSetStatus(msg, n, tot, st);
1636 // Break if we have been asked to stop
1638 break;
1639 }
1640 // Notify the client if not all the files have entries to be processed
1641 // (which may happen if an entry-list is used)
1642 if (ng < tot && gProofServ) {
1643 msg = Form("Files with entries to be processed: %d (out of %d)\n", ng, tot);
1645 } else {
1646 // Final notification to the client
1647 if (gProof) gProof->SendDataSetStatus(msg, n, tot, st);
1648 }
1649 // Done
1650 return;
1651}
1652
1653////////////////////////////////////////////////////////////////////////////////
1654/// Flag all the elements as looked-up, so to avoid opening the files
1655/// if the functionality is not supported
1656
1658{
1659 TIter nextElem(GetListOfElements());
1660 while (TDSetElement *elem = dynamic_cast<TDSetElement*>(nextElem()))
1661 elem->SetLookedUp();
1662}
1663
1664////////////////////////////////////////////////////////////////////////////////
1665/// Validate the TDSet against another TDSet.
1666/// Only validates elements in common from input TDSet.
1667
1669{
1670 THashList bestElements;
1671 bestElements.SetOwner();
1672 TList namedHolder;
1673 namedHolder.SetOwner();
1674 TIter nextOtherElem(dset->GetListOfElements());
1675 while (TDSetElement *elem = dynamic_cast<TDSetElement*>(nextOtherElem())) {
1676 if (!elem->GetValid()) continue;
1677 TString dir_file_obj = elem->GetDirectory();
1678 dir_file_obj += "_";
1679 dir_file_obj += TUrl(elem->GetFileName()).GetFileAndOptions();
1680 dir_file_obj += "_";
1681 dir_file_obj += elem->GetObjName();
1682 TPair *p = dynamic_cast<TPair*>(bestElements.FindObject(dir_file_obj));
1683 if (p) {
1684 TDSetElement *prevelem = dynamic_cast<TDSetElement*>(p->Value());
1685 if (prevelem) {
1686 Long64_t entries = prevelem->GetFirst()+prevelem->GetNum();
1687 if (entries<elem->GetFirst()+elem->GetNum()) {
1688 bestElements.Remove(p);
1689 bestElements.Add(new TPair(p->Key(), elem));
1690 delete p;
1691 }
1692 }
1693 } else {
1694 TNamed* named = new TNamed(dir_file_obj, dir_file_obj);
1695 namedHolder.Add(named);
1696 bestElements.Add(new TPair(named, elem));
1697 }
1698 }
1699
1700 TIter nextElem(GetListOfElements());
1701 while (TDSetElement *elem = dynamic_cast<TDSetElement*>(nextElem())) {
1702 if (!elem->GetValid()) {
1703 TString dir_file_obj = elem->GetDirectory();
1704 dir_file_obj += "_";
1705 dir_file_obj += TUrl(elem->GetFileName()).GetFileAndOptions();
1706 dir_file_obj += "_";
1707 dir_file_obj += elem->GetObjName();
1708 if (TPair *p = dynamic_cast<TPair*>(bestElements.FindObject(dir_file_obj))) {
1709 TDSetElement* validelem = dynamic_cast<TDSetElement*>(p->Value());
1710 elem->Validate(validelem);
1711 }
1712 }
1713 }
1714}
1715
1716//
1717// To handle requests coming from version 3 client / masters we need
1718// a special streamer
1719////////////////////////////////////////////////////////////////////////////////
1720/// Stream an object of class TDSetElement.
1721
1723{
1724 if (R__b.IsReading()) {
1725 UInt_t R__s, R__c;
1726 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1728 if (R__v > 4) {
1729 R__b.ReadClassBuffer(TDSetElement::Class(), this, R__v, R__s, R__c);
1730 } else {
1731 // For version 3 client / masters we need a special streamer
1733 if (R__v > 3) {
1734 TNamed::Streamer(R__b);
1735 } else {
1736 // Old versions were not deriving from TNamed and had the
1737 // file name and the object type name in the first two members
1738 TObject::Streamer(R__b);
1739 TString name, title;
1740 R__b >> name >> title;
1741 SetNameTitle(name, title);
1742 }
1743 // Now we read the standard part
1744 R__b >> fDirectory;
1745 R__b >> fFirst;
1746 R__b >> fNum;
1747 R__b >> fMsd;
1748 R__b >> fTDSetOffset;
1749 TEventList *evl;
1750 R__b >> evl;
1751 R__b >> fValid;
1752 R__b >> fEntries;
1753
1754 // Special treatment waiting for proper retrieving of stl containers
1755 FriendsList_t *friends = new FriendsList_t;
1756 static TClassRef classFriendsList = TClass::GetClass(typeid(FriendsList_t));
1757 R__b.ReadClassBuffer( classFriendsList, friends, classFriendsList->GetClassVersion(), 0, 0);
1758 if (friends) {
1759 // Convert friends to a TList (to be written)
1760 fFriends = new TList();
1761 fFriends->SetOwner();
1762 for (FriendsList_t::iterator i = friends->begin();
1763 i != friends->end(); ++i) {
1764 TDSetElement *dse = (TDSetElement *) i->first->Clone();
1765 fFriends->Add(new TPair(dse, new TObjString(i->second.Data())));
1766 }
1767 }
1768 // the value for fIsTree (only older versions are sending it)
1769 Bool_t tmpIsTree;
1770 R__b >> tmpIsTree;
1771 R__b.CheckByteCount(R__s, R__c, TDSetElement::IsA());
1772 }
1773 } else {
1774 if (TestBit(kWriteV3)) {
1775 // For version 3 client / masters we need a special streamer
1776 R__b << Version_t(3);
1777 TObject::Streamer(R__b);
1778 R__b << TString(GetName());
1779 R__b << TString(GetTitle());
1780 R__b << fDirectory;
1781 R__b << fFirst;
1782 R__b << fNum;
1783 R__b << fMsd;
1784 R__b << fTDSetOffset;
1785 R__b << (TEventList *)0;
1786 R__b << fValid;
1787 R__b << fEntries;
1788
1789 // Special treatment waiting for proper retrieving of stl containers
1790 FriendsList_t *friends = new FriendsList_t;
1791 if (fFriends) {
1792 TIter nxf(fFriends);
1793 TPair *p = 0;
1794 while ((p = (TPair *)nxf()))
1795 friends->push_back(std::make_pair((TDSetElement *)p->Key(),
1796 TString(((TObjString *)p->Value())->GetName())));
1797 }
1798 static TClassRef classFriendsList = TClass::GetClass(typeid(FriendsList_t));
1799 R__b.WriteClassBuffer( classFriendsList, &friends );
1800
1801 // Older versions had an unused boolean called fIsTree: we fill it
1802 // with its default value
1803 R__b << kFALSE;
1804 } else {
1806 }
1807 }
1808}
1809
1810////////////////////////////////////////////////////////////////////////////////
1811/// Stream an object of class TDSet.
1812
1814{
1815 if (R__b.IsReading()) {
1816 UInt_t R__s, R__c;
1817 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1819 if (R__v > 3) {
1820 R__b.ReadClassBuffer(TDSet::Class(), this, R__v, R__s, R__c);
1821 } else {
1822 // For version 3 client / masters we need a special streamer
1824 TNamed::Streamer(R__b);
1825 R__b >> fDir;
1826 R__b >> fType;
1827 R__b >> fObjName;
1828 TList elems;
1829 elems.Streamer(R__b);
1830 elems.SetOwner(kFALSE);
1831 if (elems.GetSize() > 0) {
1832 fElements = new THashList;
1834 TDSetElement *e = 0;
1835 TIter nxe(&elems);
1836 while ((e = (TDSetElement *)nxe())) {
1837 fElements->Add(e);
1838 }
1839 } else {
1840 fElements = 0;
1841 }
1842 R__b >> fIsTree;
1843 }
1844 } else {
1845 if (TestBit(kWriteV3)) {
1846 // For version 3 client / masters we need a special streamer
1847 R__b << Version_t(3);
1848 TNamed::Streamer(R__b);
1849 R__b << fDir;
1850 R__b << fType;
1851 R__b << fObjName;
1852 TList elems;
1853 if (fElements) {
1854 elems.SetOwner(kFALSE);
1855 if (fElements->GetSize() > 0) {
1856 TDSetElement *e = 0;
1857 TIter nxe(fElements);
1858 while ((e = (TDSetElement *)nxe()))
1859 elems.Add(e);
1860 }
1861 }
1862 elems.Streamer(R__b);
1863 R__b << fIsTree;
1864 } else {
1865 R__b.WriteClassBuffer(TDSet::Class(),this);
1866 }
1867 }
1868}
1869
1870////////////////////////////////////////////////////////////////////////////////
1871/// Set/Reset the 'OldStreamer' bit in this instance and its elements.
1872/// Needed for backward compatibility in talking to old client / masters.
1873
1875{
1876 if (on)
1878 else
1880 // Loop over dataset elements
1881 TIter nxe(GetListOfElements());
1882 TObject *o = 0;
1883 while ((o = nxe()))
1884 if (on)
1886 else
1888}
1889
1890////////////////////////////////////////////////////////////////////////////////
1891/// Set entry (or event) list for this data set
1892
1894{
1895 if (!aList) {
1896 // Nothing to do, except making sure to disable any previous setting
1897 fEntryList = 0;
1898 // Reset the element lists
1899 // TEntryList
1900 TIter next(fElements);
1901 TDSetElement *el=0;
1902 while ((el=(TDSetElement*)next())){
1903 el->SetEntryList(aList);
1904 el->Reset();
1905 }
1906 return;
1907 }
1908
1910
1911 // Global entry list for all the datasets
1912 TIter nxds(fElements);
1913 TDSet *ds = 0;
1914 while ((ds = (TDSet *) nxds()))
1915 ds->SetEntryList(aList);
1916
1917 } else {
1918
1919 // Link the proper object
1920 TEventList *evl = 0;
1921 TEntryList *enl = dynamic_cast<TEntryList*>(aList);
1922 if (!enl)
1923 evl = dynamic_cast<TEventList*>(aList);
1924 if (!enl && !evl) {
1925 Error("SetEntryList", "type of input object must be either TEntryList "
1926 "or TEventList (found: '%s' - do nothing", aList->ClassName());
1927 return;
1928 }
1929
1930 // Action depends on the type
1931 fEntryList = (enl) ? enl : (TEntryList *)evl;
1932 }
1933 // Done
1934 return;
1935}
1936
1937////////////////////////////////////////////////////////////////////////////////
1938/// Splits the main entry (or event) list into sub-lists for the elements of
1939/// thet data set
1940
1942{
1944 // Global entry list for all the datasets
1945 TIter nxds(fElements);
1946 TDSet *ds = 0;
1947 while ((ds = (TDSet *) nxds()))
1948 ds->SplitEntryList();
1949 // Done
1950 return;
1951 }
1952
1953 if (!fEntryList) {
1954 if (gDebug > 0)
1955 Info("SplitEntryList", "no entry- (or event-) list to split - do nothing");
1956 return;
1957 }
1958
1959 // Action depend on type of list
1960 TEntryList *enl = dynamic_cast<TEntryList *>(fEntryList);
1961 if (enl) {
1962 // TEntryList
1963 TIter next(fElements);
1964 TDSetElement *el=0;
1965 TEntryList *sublist = 0;
1966 while ((el=(TDSetElement*)next())){
1967 sublist = enl->GetEntryList(el->GetObjName(), el->GetFileName());
1968 if (sublist){
1969 el->SetEntryList(sublist);
1970 el->SetNum(sublist->GetN());
1971 } else {
1972 sublist = new TEntryList("", "");
1973 el->SetEntryList(sublist);
1974 el->SetNum(0);
1975 }
1976 }
1977 } else {
1978 TEventList *evl = dynamic_cast<TEventList *>(fEntryList);
1979 if (evl) {
1980 // TEventList
1981 TIter next(fElements);
1982 TDSetElement *el, *prev;
1983
1984 prev = dynamic_cast<TDSetElement*> (next());
1985 if (!prev)
1986 return;
1987 Long64_t low = prev->GetTDSetOffset();
1988 Long64_t high = low;
1989 Long64_t currPos = 0;
1990 do {
1991 el = dynamic_cast<TDSetElement*> (next());
1992 // kMaxLong64 means infinity
1993 high = (el == 0) ? kMaxLong64 : el->GetTDSetOffset();
1994#ifdef DEBUG
1995 while (currPos < evl->GetN() && evl->GetEntry(currPos) < low) {
1996 Error("SplitEntryList",
1997 "TEventList: event outside of the range of any of the TDSetElements");
1998 currPos++; // unnecessary check
1999 }
2000#endif
2001 TEventList* nevl = new TEventList();
2002 while (currPos < evl->GetN() && evl->GetEntry((Int_t)currPos) < high) {
2003 nevl->Enter(evl->GetEntry((Int_t)currPos) - low);
2004 currPos++;
2005 }
2006 prev->SetEntryList(nevl);
2007 prev->SetNum(nevl->GetN());
2008 low = high;
2009 prev = el;
2010 } while (el);
2011 }
2012 }
2013}
2014
2015////////////////////////////////////////////////////////////////////////////////
2016/// Return the number of files in the dataset
2017
2019{
2020 Int_t nf = -1;
2021 if (fElements) {
2022 nf = 0;
2024 TIter nxds(fElements);
2025 TDSet *ds = 0;
2026 while ((ds = (TDSet *) nxds()))
2027 if (ds->GetListOfElements()) nf += ds->GetListOfElements()->GetSize();
2028 } else {
2029 nf = fElements->GetSize();
2030 }
2031 }
2032 // Done
2033 return nf;
2034}
#define SafeDelete(p)
Definition RConfig.hxx:525
#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
constexpr Long64_t kMaxLong64
Definition RtypesCore.h:120
short Version_t
Definition RtypesCore.h:65
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:124
long long Long64_t
Definition RtypesCore.h:80
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
#define gDirectory
Definition TDirectory.h:384
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
constexpr Int_t kError
Definition TError.h:46
Int_t gErrorIgnoreLevel
Error handling routines.
Definition TError.cxx:31
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
int nentries
R__EXTERN TProofServ * gProofServ
Definition TProofServ.h:347
R__EXTERN TProof * gProof
Definition TProof.h:1077
Int_t gDebug
Definition TROOT.cxx:597
#define gROOT
Definition TROOT.h:407
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2467
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2481
@ kFileExists
Definition TSystem.h:44
R__EXTERN TSystem * gSystem
Definition TSystem.h:560
#define gPerfStats
T1 fFirst
Definition X11Events.mm:86
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=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:111
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:81
Version_t GetClassVersion() const
Definition TClass.h:420
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:2968
Collection abstract base class.
Definition TCollection.h:65
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) override
Write all objects in 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.
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 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
void Print(Option_t *options="") const override
Print a TDSetElement. When option="a" print full data.
Definition TDSet.cxx:261
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
static TClass * Class()
TString fMsd
Definition TDSet.h:83
void SetLookedUp()
Definition TDSet.h:139
Int_t Compare(const TObject *obj) const override
Compare elements by filename (and the fFirst).
Definition TDSet.cxx:351
void Streamer(TBuffer &) override
Stream an object of class TDSetElement.
Definition TDSet.cxx:1722
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
TClass * IsA() const override
Definition TDSet.h:149
TObject * GetAssocObj(Long64_t i, Bool_t isentry=kFALSE)
Get i-th associated object.
Definition TDSet.cxx:652
Long64_t GetFirst() const
Definition TDSet.h:112
~TDSetElement() override
Clean up the element.
Definition TDSet.cxx:146
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:1941
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:1893
Int_t Remove(TDSetElement *elem, Bool_t deleteElem=kTRUE)
Remove TDSetElement 'elem' from the list.
Definition TDSet.cxx:1576
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 Print(Option_t *option="") const override
Print TDSet basic or full data. When option="a" print full data.
Definition TDSet.cxx:1008
void SetLookedUp()
Flag all the elements as looked-up, so to avoid opening the files if the functionality is not support...
Definition TDSet.cxx:1657
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:1555
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:2018
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:1605
TIter * fIterator
Definition TDSet.h:181
Int_t ExportFileList(const char *filepath, Option_t *opt="")
Export TDSetElements files as list of TFileInfo objects in file 'fpath'.
Definition TDSet.cxx:1277
void Streamer(TBuffer &) override
Stream an object of class TDSet.
Definition TDSet.cxx:1813
virtual TTree * GetTreeHeader(TProof *proof)
Returns a tree header containing the branches' structure of the dataset.
Definition TDSet.cxx:1547
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:1589
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
~TDSet() override
Cleanup.
Definition TDSet.cxx:901
TClass * IsA() const override
Definition TDSet.h:262
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:1874
TString fObjName
Definition TDSet.h:179
TList * GetListOfElements() const
Definition TDSet.h:231
Bool_t fIsTree
Definition TDSet.h:167
static TClass * Class()
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:101
virtual Long64_t GetN() const
Definition TEntryList.h:78
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=nullptr) 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 composed of a header, followed by consecutive data records (TKey instances) with a wel...
Definition TFile.h:53
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:4807
EFileType
File type.
Definition TFile.h:202
@ kDefault
Definition TFile.h:202
@ kLocal
Definition TFile.h:202
@ kNet
Definition TFile.h:202
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:4075
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 * Remove(TObject *obj) override
Remove object from the list.
TObject * FindObject(const char *name) const override
Find object using its name.
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:75
virtual TObject * ReadObj()
To read a TObject* from the file.
Definition TKey.cxx:758
A doubly linked list.
Definition TList.h:38
void Streamer(TBuffer &) override
Stream all objects in the collection to or from the I/O buffer.
Definition TList.cxx:1191
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:578
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:822
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
Definition TList.cxx:693
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:659
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:357
void AddFirst(TObject *obj) override
Add object at the beginning of the list.
Definition TList.cxx:100
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
Definition TNamed.cxx:74
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
void Streamer(TBuffer &) override
Stream an object of class TObject.
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
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 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:439
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:888
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
Definition TObject.cxx:1001
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:207
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:973
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:780
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:987
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
Definition TObject.cxx:636
void ResetBit(UInt_t f)
Definition TObject.h:198
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:961
Class used by TMap to store (key,value) pairs.
Definition TMap.h:102
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:139
Ssiz_t Length() const
Definition TString.h:421
TString & Insert(Ssiz_t pos, const char *s)
Definition TString.h:661
Int_t Atoi() const
Return integer value of string.
Definition TString.cxx:1966
const char * Data() const
Definition TString.h:380
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition TString.cxx:1808
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:627
Bool_t IsNull() const
Definition TString.h:418
TString & Remove(Ssiz_t pos)
Definition TString.h:685
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:2356
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2334
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:636
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:651
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1261
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1068
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:1283
virtual Bool_t IsAbsoluteFileName(const char *dir)
Return true if dir is an absolute pathname.
Definition TSystem.cxx:938
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:858
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1368
The TTimeStamp encapsulates seconds and ns since EPOCH.
Definition TTimeStamp.h:45
A TTree represents a columnar dataset.
Definition TTree.h:79
static TClass * Class()
static constexpr Long64_t kMaxEntries
Definition TTree.h:229
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:390
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:504
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()
TMarker m
Definition textangle.C:8