Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TFileMerger.cxx
Go to the documentation of this file.
1// @(#)root/io:$Id$
2// Author: Andreas Peters + Fons Rademakers + Rene Brun 26/5/2005
3
4/*************************************************************************
5 * Copyright (C) 1995-2005, 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/**
13\class TFileMerger TFileMerger.cxx
14\ingroup io_files
15
16This class provides file copy and merging services.
17
18It can be used to copy files (not only ROOT files), using TFile or
19any of its remote file access plugins. It is therefore useful in
20a Grid environment where the files might be accessible only remotely.
21The merging interface allows files containing histograms and trees
22to be merged, like the standalone hadd program.
23*/
24
25#include "TFileMerger.h"
26#include "TDirectory.h"
27#include "TError.h"
28#include "TUrl.h"
29#include "TFile.h"
30#include "TUUID.h"
31#include "TSystem.h"
32#include "TKey.h"
33#include "THashList.h"
34#include "TObjString.h"
35#include "TObjArray.h"
36#include "TClass.h"
37#include "TFileMergeInfo.h"
38#include "TClassRef.h"
39#include "TROOT.h"
40#include "TMemFile.h"
41#include "TVirtualMutex.h"
42
43#ifdef WIN32
44// For _getmaxstdio
45#include <cstdio>
46#else
47// For getrlimit
48#include <sys/time.h>
49#include <sys/resource.h>
50#endif
51
52#include <cstring>
53#include <map>
54
55
58TClassRef R__RNTuple_Class("ROOT::RNTuple");
59
60static const Int_t kCpProgress = BIT(14);
61static const Int_t kClingFileNumber = 100;
62////////////////////////////////////////////////////////////////////////////////
63/// Return the maximum number of allowed opened files minus some wiggle room
64/// for Cling or at least of the standard library (stdio).
65
67{
68 int maxfiles;
69#ifdef WIN32
71#else
74 maxfiles = filelimit.rlim_cur;
75 } else {
76 // We could not get the value from getrlimit, let's return a reasonable default.
77 maxfiles = 512;
78 }
79#endif
81 // Limit the maximum number of opened files to 128 to mitigate memory
82 // consumption issues that may arise during merges with many files.
83 // For further details see analysis at:
84 // https://github.com/root-project/root/issues/21660
85 return std::min(128, maxfiles - kClingFileNumber);
86 } else if (maxfiles > 5) {
87 return maxfiles - 5;
88 } else {
89 return maxfiles;
90 }
91}
92
93////////////////////////////////////////////////////////////////////////////////
94/// Create file merger object.
95
97 : fMaxOpenedFiles( R__GetSystemMaxOpenedFiles() ),
98 fLocal(isLocal), fHistoOneGo(histoOneGo)
99{
102
104 gROOT->GetListOfCleanups()->Add(this);
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// Cleanup.
109
111{
112 {
114 gROOT->GetListOfCleanups()->Remove(this);
115 }
117}
118
119////////////////////////////////////////////////////////////////////////////////
120/// Reset merger file list.
121
129
130////////////////////////////////////////////////////////////////////////////////
131/// Closes output file
132
138
139////////////////////////////////////////////////////////////////////////////////
140/// Add file to file merger.
141
143{
144 if (fPrintLevel > 0) {
145 Printf("%s Source file %d: %s", fMsgPrefix.Data(), fFileList.GetEntries() + fExcessFiles.GetEntries() + 1, url);
146 }
147
148 TFile *newfile = nullptr;
150
151 if (fFileList.GetEntries() >= (fMaxOpenedFiles-1)) {
152
155
156 urlObj = new TObjString(url);
157 urlObj->SetBit(kCpProgress);
159 return kTRUE;
160 }
161
162 // We want gDirectory untouched by anything going on here
164
165 if (fLocal) {
166 TUUID uuid;
167 localcopy.Form("file:%s/ROOTMERGE-%s.root", gSystem->TempDirectory(), uuid.AsString());
169 Error("AddFile", "cannot get a local copy of file %s", url);
170 return kFALSE;
171 }
172 newfile = TFile::Open(localcopy, "READ");
173 } else {
174 newfile = TFile::Open(url, "READ");
175 }
176
177 // Zombie files should also be skipped
178 if (newfile && newfile->IsZombie()) {
179 delete newfile;
180 newfile = nullptr;
181 }
182
183 if (!newfile) {
184 if (fLocal)
185 Error("AddFile", "cannot open local copy %s of URL %s",
186 localcopy.Data(), url);
187 else
188 Error("AddFile", "cannot open file %s", url);
189 return kFALSE;
190 } else {
191 if (fOutputFile && fOutputFile->GetCompressionSettings() != newfile->GetCompressionSettings())
193
194 newfile->SetBit(kCanDelete);
196
199
200 return kTRUE;
201 }
202}
203
204////////////////////////////////////////////////////////////////////////////////
205/// Add the TFile to this file merger and *do not* give ownership of the TFile to this
206/// object.
207///
208/// Return kTRUE if the addition was successful.
209
214
215////////////////////////////////////////////////////////////////////////////////
216/// Add the TFile to this file merger and give ownership of the TFile to this
217/// object (unless kFALSE is returned).
218///
219/// Return kTRUE if the addition was successful.
220
225
226////////////////////////////////////////////////////////////////////////////////
227/// Add the TFile to this file merger and give ownership of the TFile to this
228/// object (unless kFALSE is returned).
229///
230/// Return kTRUE if the addition was successful.
231
233{
234 if (source == 0 || source->IsZombie()) {
235 return kFALSE;
236 }
237
238 if (fPrintLevel > 0) {
239 Printf("%s Source file %d: %s",fMsgPrefix.Data(),fFileList.GetEntries()+1,source->GetName());
240 }
241
242 TFile *newfile = 0;
244
245 // We want gDirectory untouched by anything going on here
247 if (fLocal && !source->InheritsFrom(TMemFile::Class())) {
248 TUUID uuid;
249 localcopy.Form("file:%s/ROOTMERGE-%s.root", gSystem->TempDirectory(), uuid.AsString());
250 if (!source->Cp(localcopy, cpProgress)) {
251 Error("AddFile", "cannot get a local copy of file %s", source->GetName());
252 return kFALSE;
253 }
254 newfile = TFile::Open(localcopy, "READ");
255 // Zombie files should also be skipped
256 if (newfile && newfile->IsZombie()) {
257 delete newfile;
258 newfile = 0;
259 }
260 } else {
261 newfile = source;
262 }
263
264 if (!newfile) {
265 if (fLocal)
266 Error("AddFile", "cannot open local copy %s of URL %s",
267 localcopy.Data(), source->GetName());
268 else
269 Error("AddFile", "cannot open file %s", source->GetName());
270 return kFALSE;
271 } else {
272 if (fOutputFile && fOutputFile->GetCompressionSettings() != newfile->GetCompressionSettings()) fCompressionChange = kTRUE;
273
274 if (own || newfile != source) {
275 newfile->SetBit(kCanDelete);
276 } else {
277 newfile->ResetBit(kCanDelete);
278 }
280
281 TObjString *urlObj = new TObjString(source->GetName());
283
284 if (newfile != source && own) {
285 delete source;
286 }
287 return kTRUE;
288 }
289}
290
291////////////////////////////////////////////////////////////////////////////////
292/// Open merger output file.
293
298
299////////////////////////////////////////////////////////////////////////////////
300/// Open merger output file.
301
303{
304 Bool_t res = OutputFile(outputfile,(force?"RECREATE":"CREATE"),1); // 1 is the same as the default from the TFile constructor.
307 return res;
308}
309
310////////////////////////////////////////////////////////////////////////////////
311/// Open merger output file.
312///
313/// The 'mode' parameter is passed to the TFile constructor as the option, it
314/// should be one of 'NEW','CREATE','RECREATE','UPDATE'
315/// 'UPDATE' is usually used in conjunction with IncrementalMerge.
316
318{
319 // We want gDirectory untouched by anything going on here
322 return OutputFile(std::unique_ptr<TFile>(outputFile));
323
324 Error("OutputFile", "cannot open the MERGER output file %s", fOutputFilename.Data());
325 return kFALSE;
326}
327
328////////////////////////////////////////////////////////////////////////////////
329/// Set an output file opened externally by the users
330
332{
333 if (!outputfile || outputfile->IsZombie()) {
334 Error("OutputFile", "cannot open the MERGER output file %s", (outputfile) ? outputfile->GetName() : "");
335 return kFALSE;
336 }
337
338 if (!outputfile->IsWritable()) {
339 Error("OutputFile", "output file %s is not writable", outputfile->GetName());
340 return kFALSE;
341 }
342
344
346 fOutputFile = 0; // This avoids the complaint from RecursiveRemove about the file being deleted which is here
347 // spurrious. (see RecursiveRemove).
349
350 fOutputFilename = outputfile->GetName();
351 // We want gDirectory untouched by anything going on here
353 fOutputFile = outputfile.release(); // Transfer the ownership of the file.
354
355 return kTRUE;
356}
357
358////////////////////////////////////////////////////////////////////////////////
359/// Open merger output file. 'mode' is passed to the TFile constructor as the option, it should
360/// be one of 'NEW','CREATE','RECREATE','UPDATE'
361/// 'UPDATE' is usually used in conjunction with IncrementalMerge.
362
363Bool_t TFileMerger::OutputFile(const char *outputfile, const char *mode /* = "RECREATE" */)
364{
365 Bool_t res = OutputFile(outputfile,mode,1); // 1 is the same as the default from the TFile constructor.
367 return res;
368}
369
370////////////////////////////////////////////////////////////////////////////////
371/// Print list of files being merged.
372
374{
375 fFileList.Print(options);
376 fExcessFiles.Print(options);
377}
378
379////////////////////////////////////////////////////////////////////////////////
380/// Merge the files.
381///
382/// If no output file was specified it will write into
383/// the file "FileMerger.root" in the working directory. Returns true
384/// on success, false in case of error.
385
390
391namespace {
392
394{
395 return (cl->GetMerge() || cl->InheritsFrom(TDirectory::Class()) ||
396 (cl->IsTObject() && !cl->IsLoaded() &&
397 /* If it has a dictionary and GetMerge() is nullptr then we already know the answer
398 to the next question is 'no, if we were to ask we would useless trigger
399 auto-parsing */
400 (cl->GetMethodWithPrototype("Merge", "TCollection*,TFileMergeInfo*") ||
401 cl->GetMethodWithPrototype("Merge", "TCollection*"))));
402};
403
405{
406 Bool_t status = kTRUE;
407 if (cl->InheritsFrom(TCollection::Class())) {
408 // Don't overwrite, if the object were not merged.
409 if (obj->Write(name, canBeMerged ? TObject::kSingleKey | TObject::kOverwrite : TObject::kSingleKey) <= 0) {
410 status = kFALSE;
411 }
412 ((TCollection *)obj)->SetOwner();
413 if (ownobj)
414 delete obj;
415 } else {
416 // Don't overwrite, if the object were not merged.
417 // NOTE: this is probably wrong for emulated objects.
418 if (cl->IsTObject()) {
419 if (obj->Write(name, canBeMerged ? TObject::kOverwrite : 0) <= 0) {
420 status = kFALSE;
421 }
423 } else {
424 if (target->WriteObjectAny((void *)obj, cl, name, canBeMerged ? "OverWrite" : "") <= 0) {
425 status = kFALSE;
426 }
427 }
428 if (ownobj)
429 cl->Destructor(obj); // just in case the class is not loaded.
430 }
431 return status;
432}
433
435{
436 // Recurse until we find a different name or type appear.
437 TKey *key = (TKey*)peeknextkey();
438 if (!key || name != key->GetName()) {
439 return kTRUE;
440 }
442 if (IsMergeable(cl))
443 return kTRUE;
444 // Now we can advance the real iterator
445 (void)nextkey();
447 TObject *obj = key->ReadObj();
448
449 return WriteOneAndDelete(name, cl, obj, kFALSE, kTRUE, target) && result;
450};
451
452} // anonymous namespace
453
457 TObject *obj, TIter &nextkey)
458{
459 const char *keyname = obj ? obj->GetName() : key->GetName();
460 const char *keyclassname = obj ? obj->IsA()->GetName() : key->GetClassName();
461 const char *keytitle = obj ? obj->GetTitle() : key->GetTitle();
462
463 // Keep only the highest cycle number for each key for mergeable objects. They are stored
464 // in the (hash) list consecutively and in decreasing order of cycles, so we can continue
465 // until the name changes. We flag the case here and we act consequently later.
468
469 // Read in but do not copy directly the processIds.
470 if (strcmp(keyclassname, "TProcessID") == 0 && key) {
471 key->ReadObj();
472 return kTRUE;
473 }
474
475 // If we have already seen this object [name], we already processed
476 // the whole list of files for this objects and we can just skip it
477 // and any related cycles.
478 if (allNames.FindObject(keyname)) {
480 return kTRUE;
481 }
482
484 if (!cl) {
485 Info("MergeRecursive", "cannot indentify object type (%s), name: %s title: %s",
487 return kTRUE;
488 }
489 // For mergeable objects we add the names in a local hashlist handling them
490 // again (see above)
491 if (IsMergeable(cl))
492 allNames.Add(new TObjString(keyname));
493
495 // Skip the TTree objects and any related cycles.
497 return kTRUE;
498 }
499 // Check if only the listed objects are to be merged
500 if (type & kOnlyListed) {
501 // Search for " key " in " a b c " to match whole words only.
502 // Without the leading space, a key that is a prefix or suffix of a listed name
503 // would match. AddObjectNames() guarantees a trailing space in fObjectNames.
504 TString searchName = " ";
506 searchName += " ";
507 onlyListed = (" " + fObjectNames).Contains(searchName);
508 if ((!onlyListed) && (!cl->InheritsFrom(TDirectory::Class()))) return kTRUE;
509 }
510
511 if (!(type&kResetable && type&kNonResetable)) {
512 // If neither or both are requested at the same time, we merger both types.
513 if (!(type&kResetable)) {
514 if (cl->GetResetAfterMerge()) {
515 // Skip the object with a reset after merge routine (TTree and other incrementally mergeable objects)
517 return kTRUE;
518 }
519 }
520 if (!(type&kNonResetable)) {
521 if (!cl->GetResetAfterMerge()) {
522 // Skip the object without a reset after merge routine (Histograms and other non incrementally mergeable objects)
524 return kTRUE;
525 }
526 }
527 }
528 // read object from first source file
529 if (type & kIncremental) {
530 if (!obj)
531 obj = current_sourcedir->GetList()->FindObject(keyname);
532 if (!obj && key) {
533 obj = key->ReadObj();
534 ownobj = kTRUE;
535 } else if (obj && info.fIsFirst && current_sourcedir != target
536 && !cl->InheritsFrom( TDirectory::Class() )) {
537 R__ASSERT(cl->IsTObject());
539 obj = obj->Clone();
540 ownobj = kTRUE;
541 }
542 } else if (key) {
543 obj = key->ReadObj();
544 ownobj = kTRUE;
545 }
546 if (!obj) {
547 Info("MergeRecursive", "could not read object for key {%s, %s}",
549 return kTRUE;
550 }
551 Bool_t canBeFound = (type & kIncremental) && (target->GetList()->FindObject(keyname) != nullptr);
552
553 // if (cl->IsTObject())
554 // obj->ResetBit(kMustCleanup);
555 if (cl->IsTObject() && cl != obj->IsA()) {
556 Error("MergeRecursive", "TKey and object retrieve disagree on type (%s vs %s). Continuing with %s.",
557 keyclassname, obj->IsA()->GetName(), obj->IsA()->GetName());
558 cl = obj->IsA();
559 }
561
562 std::map<std::tuple<std::string, std::string, std::string>, TDirectory*> dirtodelete;
563 auto getDirectory = [&dirtodelete](TDirectory *parent, const char *name, const TString &pathname) {
564 auto mapkey = std::make_tuple(parent->GetName(), name, pathname.Data());
565 auto result = dirtodelete.find(mapkey);
566 if (result != dirtodelete.end()) {
567 return result->second;
568 }
569
570 auto dir = dynamic_cast<TDirectory *>(parent->GetDirectory(pathname));
571 if (dir)
572 dirtodelete[mapkey] = dir;
573
574 return dir;
575 };
576
577 if ( cl->InheritsFrom( TDirectory::Class() ) ) {
578 // it's a subdirectory
579
580 target->cd();
582
583 // For incremental or already seen we may have already a directory created
584 if (type & kIncremental || alreadyseen) {
585 newdir = target->GetDirectory(obj->GetName());
586 if (!newdir) {
587 newdir = target->mkdir( obj->GetName(), obj->GetTitle() );
588 // newdir->ResetBit(kMustCleanup);
589 }
590 } else {
591 newdir = target->mkdir( obj->GetName(), obj->GetTitle() );
592 // newdir->ResetBit(kMustCleanup);
593 }
594
595 // newdir is now the starting point of another round of merging
596 // newdir still knows its depth within the target file via
597 // GetPath(), so we can still figure out where we are in the recursion
598
599 // If this folder is a onlyListed object, merge everything inside.
600 const auto mergeType = onlyListed ? type & ~kOnlyListed : type;
602
603 if ((type & kOnlyListed) && !(type & kIncremental) && !onlyListed && newdir->GetNkeys() == 0) {
604 // None of the children were merged, and the directory is not listed
605 delete newdir;
606 newdir = nullptr;
607 target->rmdir(obj->GetName());
608 }
609 // Delete newdir directory after having written it (merged)
610 if (!(type&kIncremental)) delete newdir;
612 if (!status) return kFALSE;
613 } else if (!cl->IsTObject() && cl->GetMerge()) {
614 // merge objects that don't derive from TObject
616 Warning("MergeRecursive", "Merging RNTuples is experimental");
617
618 // Collect all the data to be passed on to the merger
620 // First entry is the TKey of the ntuple
621 mergeData.Add(key);
622 // Second entry is the output file
623 mergeData.Add(target->GetFile());
624 // Remaining entries are the input files
626 while (const auto &inFile = nextFile()) {
627 mergeData.Add(inFile);
628 }
629 // Get the merge fuction and pass the data
630 ROOT::MergeFunc_t func = cl->GetMerge();
631 Long64_t result = func(obj, &mergeData, &info);
632 mergeData.Clear("nodelete");
633 if (result < 0) {
634 Error("MergeRecursive", "Could NOT merge RNTuples!");
635 return kFALSE;
636 }
637 } else {
639 Error("MergeRecursive", "Merging objects that don't inherit from TObject is unimplemented (key: %s of type %s in file %s)",
640 keyname, keyclassname, nextsource->GetName());
642 }
643 } else if (cl->IsTObject() && cl->GetMerge()) {
644 // Check if already treated
645 if (alreadyseen) return kTRUE;
646
650
651 // Loop over all source files and merge same-name object
653 if (nextsource == 0) {
654 // There is only one file in the list
655 ROOT::MergeFunc_t func = cl->GetMerge();
656 func(obj, &inputs, &info);
657 info.fIsFirst = kFALSE;
658 } else {
659 do {
660 // make sure we are at the correct directory level by cd'ing to path
661 TDirectory *ndir = getDirectory(nextsource, target->GetName(), path);
662 if (ndir) {
663 // For consistency (and persformance), we reset the MustCleanup be also for those
664 // 'key' retrieved indirectly.
665 // ndir->ResetBit(kMustCleanup);
666 ndir->cd();
667 TObject *hobj = ndir->GetList()->FindObject(keyname);
668 if (!hobj) {
669 TKey *key2 = (TKey*)ndir->GetListOfKeys()->FindObject(keyname);
670 if (key2) {
671 if (strcmp(key2->GetClassName(), keyclassname) != 0) {
672 Error("MergeRecursive",
673 "Object type mismatch for key '%s' in file '%s': expected '%s' but found '%s'.", keyname,
674 nextsource->GetName(), keyclassname, key2->GetClassName());
676 return kFALSE;
677 }
678 hobj = key2->ReadObj();
679 if (!hobj) {
680 switch (fErrBehavior) {
682 Error("MergeRecursive", "could not read object for key {%s, %s}; in file %s", keyname,
683 keytitle, nextsource->GetName());
685 return kFALSE;
687 Warning("MergeRecursive", "could not read object for key {%s, %s}; skipping file %s",
688 keyname, keytitle, nextsource->GetName());
690 return kTRUE;
691 }
692 }
693 todelete.Add(hobj);
694 }
695 }
696 if (hobj) {
697 // Set ownership for collections
698 if (hobj->InheritsFrom(TCollection::Class())) {
699 ((TCollection*)hobj)->SetOwner();
700 }
701 hobj->ResetBit(kMustCleanup);
702 inputs.Add(hobj);
703 if (!oneGo) {
704 ROOT::MergeFunc_t func = cl->GetMerge();
705 Long64_t result = func(obj, &inputs, &info);
706 info.fIsFirst = kFALSE;
707 if (result < 0) {
708 Error("MergeRecursive", "calling Merge() on '%s' with the corresponding object in '%s'",
709 keyname, nextsource->GetName());
710 }
711 inputs.Clear();
712 todelete.Delete();
713 }
714 }
715 }
717 } while (nextsource);
718 // Merge the list, if still to be done
719 if (oneGo || info.fIsFirst) {
720 ROOT::MergeFunc_t func = cl->GetMerge();
721 func(obj, &inputs, &info);
722 info.fIsFirst = kFALSE;
723 inputs.Clear();
724 todelete.Delete();
725 }
726 }
727 } else if (cl->IsTObject()) {
728 // try synthesizing the Merge method call according to the TObject
729 TList listH;
731 if (cl->GetMethodWithPrototype("Merge", "TCollection*,TFileMergeInfo*")) {
732 listHargs.Form("(TCollection*)0x%zx,(TFileMergeInfo*)0x%zx",
733 (size_t)&listH, (size_t)&info);
734 } else if (cl->GetMethodWithPrototype("Merge", "TCollection*")) {
735 listHargs.Form("((TCollection*)0x%zx)", (size_t)&listH);
736 } else {
737 // pass unmergeable objects through to the output file
739 }
740 if (canBeMerged) {
741 if (alreadyseen) {
742 // skip already seen mergeable objects, don't skip unmergeable objects
743 return kTRUE;
744 }
745 // Loop over all source files and merge same-name object
747 if (nextsource == 0) {
748 // There is only one file in the list
749 Int_t error = 0;
750 obj->Execute("Merge", listHargs.Data(), &error);
751 info.fIsFirst = kFALSE;
752 if (error) {
753 Error("MergeRecursive", "calling Merge() on '%s' with the corresponding object in '%s'",
754 obj->GetName(), keyname);
755 }
756 } else {
757 while (nextsource) {
758 // make sure we are at the correct directory level by cd'ing to path
759 TDirectory *ndir = getDirectory(nextsource, target->GetName(), path);
760 if (ndir) {
761 ndir->cd();
762 TKey *key2 = (TKey*)ndir->GetListOfKeys()->FindObject(keyname);
763 if (key2) {
764 TObject *hobj = key2->ReadObj();
765 if (!hobj) {
766 switch (fErrBehavior) {
768 Error("MergeRecursive", "could not read object for key {%s, %s}; in file %s", keyname,
769 keytitle, nextsource->GetName());
771 return kFALSE;
773 Warning("MergeRecursive", "could not read object for key {%s, %s}; skipping file %s",
774 keyname, keytitle, nextsource->GetName());
776 return kTRUE;
777 }
778 }
779 // Set ownership for collections
780 if (hobj->InheritsFrom(TCollection::Class())) {
781 ((TCollection*)hobj)->SetOwner();
782 }
783 hobj->ResetBit(kMustCleanup);
784 listH.Add(hobj);
785 Int_t error = 0;
786 obj->Execute("Merge", listHargs.Data(), &error);
787 info.fIsFirst = kFALSE;
788 if (error) {
789 Error("MergeRecursive", "calling Merge() on '%s' with the corresponding object in '%s'",
790 obj->GetName(), nextsource->GetName());
791 }
792 listH.Delete();
793 }
794 }
796 }
797 // Merge the list, if still to be done
798 if (info.fIsFirst) {
799 Int_t error = 0;
800 obj->Execute("Merge", listHargs.Data(), &error);
801 info.fIsFirst = kFALSE;
802 listH.Delete();
803 }
804 }
805 }
806 } else {
807 // Object is of no type that we can merge
809 }
810
811 // now write the merged histogram (which is "in" obj) to the target file
812 // note that this will just store obj in the current directory level,
813 // which is not persistent until the complete directory itself is stored
814 // by "target->SaveSelf()" below
815 target->cd();
816
818 // if the object is a tree, it is stored in globChain...
819 if (cl->InheritsFrom(TDirectory::Class())) {
820 // printf("cas d'une directory\n");
821
822 auto dirobj = dynamic_cast<TDirectory *>(obj);
823 TString dirpath(dirobj->GetPath());
824 // coverity[unchecked_value] 'target' is from a file so GetPath always returns path starting with filename:
825 dirpath.Remove(0, std::strlen(dirobj->GetFile()->GetPath()));
826
827 // Do not delete the directory if it is part of the output
828 // and we are in incremental mode (because it will be reused
829 // and has not been written to disk (for performance reason).
830 // coverity[var_deref_model] the IsA()->InheritsFrom guarantees that the dynamic_cast will succeed.
831 if (ownobj && (!(type & kIncremental) || dirobj->GetFile() != target)) {
832 dirobj->ResetBit(kMustCleanup);
833 delete dirobj;
834 }
835 // Let's also delete the directory from the other source (thanks to the 'allNames'
836 // mechanism above we will not process the directories when tranversing the next
837 // files).
838 for (const auto &[_, ndir] : dirtodelete) {
839 // For consistency (and performance), we reset the MustCleanup be also for those
840 // 'key' retrieved indirectly.
841 ndir->ResetBit(kMustCleanup);
842 delete ndir;
843 }
844 } else if (!canBeFound) { // object (TTree, TH1) is not yet owned by the target, thus write it
845 if (gDebug > 0)
846 Info("MergeOne", "Writing partial result of %s into target", oldkeyname.Data());
847 if (!canBeMerged) {
850 status = WriteOneAndDelete(oldkeyname, cl, obj, kFALSE, ownobj, target) && status;
851 } else {
852 status = WriteOneAndDelete(oldkeyname, cl, obj, kTRUE, ownobj, target) && status;
853 }
854 }
855 info.Reset();
856 return kTRUE;
857}
858
859////////////////////////////////////////////////////////////////////////////////
860/// Merge all objects in a directory
861///
862/// The type is defined by the bit values in TFileMerger::EPartialMergeType.
863
865{
866 Bool_t status = kTRUE;
868 if (fPrintLevel > 0) {
869 Printf("%s Target path: %s",fMsgPrefix.Data(),target->GetPath());
870 }
871
872 // Get the dir name
873 TString path(target->GetPath());
874 // coverity[unchecked_value] 'target' is from a file so GetPath always returns path starting with filename:
875 path.Remove(0, std::strlen(target->GetFile()->GetPath()));
876
877 Int_t nguess = sourcelist->GetSize()+1000;
879 allNames.SetOwner(kTRUE);
880 // If the mode is set to skipping list objects, add names to the allNames list
881 if (type & kSkipListed) {
883 arr->SetOwner(kFALSE);
884 for (Int_t iname=0; iname<arr->GetEntriesFast(); iname++)
885 allNames.Add(arr->At(iname));
886 delete arr;
887 }
888 ((THashList*)target->GetList())->Rehash(nguess);
889 ((THashList*)target->GetListOfKeys())->Rehash(nguess);
890
892 info.fIOFeatures = fIOFeatures;
893 info.fOptions = fMergeOptions;
895 info.fOptions.Append(" fast");
896 }
897
900 if (type & kIncremental) {
901 current_file = 0;
903 } else {
904 current_file = (TFile*)sourcelist->First();
905 current_sourcedir = current_file->GetDirectory(path);
906 }
908 // When current_sourcedir != 0 and current_file == 0 we are going over the target
909 // for an incremental merge.
912
913 // Loop over live objects
914 TIter nextobj( current_sourcedir->GetList() );
915 TObject *obj;
916 while ( (obj = (TKey*)nextobj())) {
918 info, oldkeyname, allNames, status, onlyListed, path,
920 nullptr, obj, nextobj);
921 if (!result)
922 return kFALSE; // Stop completely in case of error.
923 } // while ( (obj = (TKey*)nextobj()))
924
925 // loop over all keys in this directory
926 TIter nextkey( current_sourcedir->GetListOfKeys() );
927 TKey *key;
928
929 while ( (key = (TKey*)nextkey())) {
931 info, oldkeyname, allNames, status, onlyListed, path,
933 key, nullptr, nextkey);
934 if (!result)
935 return kFALSE; // Stop completely in case of error.
936 } // while ( ( TKey *key = (TKey*)nextkey() ) )
937 }
939 if (current_file) {
940 current_sourcedir = current_file->GetDirectory(path);
941 } else {
943 }
944 }
945 // save modifications to the target directory.
946 if (!(type&kIncremental)) {
947 // In case of incremental build, we will call Write on the top directory/file, so we do not need
948 // to call SaveSelf explicilty.
949 target->SaveSelf(kTRUE);
950 }
951
952 return status;
953}
954
955////////////////////////////////////////////////////////////////////////////////
956/// Merge the files. If no output file was specified it will write into
957/// the file "FileMerger.root" in the working directory. Returns true
958/// on success, false in case of error.
959/// The type is defined by the bit values in EPartialMergeType:
960///
961/// kRegular : normal merge, overwriting the output file
962/// kIncremental : merge the input file with the content of the output file (if already exising) (default)
963/// kResetable : merge only the objects with a MergeAfterReset member function.
964/// kNonResetable : merge only the objects without a MergeAfterReset member function.
965/// kDelayWrite : delay the TFile write (to reduce the number of write when reusing the file)
966/// kAll : merge all type of objects (default)
967/// kAllIncremental : merge incrementally all type of objects.
968/// kOnlyListed : merge only the objects specified in fObjectNames list
969/// kSkipListed : skip objects specified in fObjectNames list
970/// kKeepCompression: keep compression level unchanged for each input
971///
972/// If the type is not set to kIncremental, the output file is deleted at the end of this operation.
973
975{
976 if (!fOutputFile) {
978 if (outf.IsNull()) {
979 outf.Form("file:%s/FileMerger.root", gSystem->TempDirectory());
980 Info("PartialMerge", "will merge the results to the file %s\n"
981 "since you didn't specify a merge filename",
982 TUrl(outf).GetFile());
983 }
984 if (!OutputFile(outf.Data())) {
985 return kFALSE;
986 }
987 }
988
989 // Special treatment for the single file case to improve efficiency...
990 if ((fFileList.GetEntries() == 1) && !fExcessFiles.GetEntries() &&
994
995 TFile *file = (TFile *) fFileList.First();
996 if (!file || (file && file->IsZombie())) {
997 Error("PartialMerge", "one-file case: problem attaching to file");
998 return kFALSE;
999 }
1001 if (!(result = file->Cp(fOutputFilename))) {
1002 Error("PartialMerge", "one-file case: could not copy '%s' to '%s'",
1003 file->GetPath(), fOutputFilename.Data());
1004 return kFALSE;
1005 }
1006 if (file->TestBit(kCanDelete)) file->Close();
1007
1008 // Remove the temporary file
1009 if (fLocal && !file->InheritsFrom(TMemFile::Class())) {
1010 TUrl u(file->GetPath(), kTRUE);
1011 if (gSystem->Unlink(u.GetFile()) != 0)
1012 Warning("PartialMerge", "problems removing temporary local file '%s'", u.GetFile());
1013 }
1014 fFileList.Clear();
1015 return result;
1016 }
1017
1020
1022
1024 Int_t type = in_type;
1025 while (result && fFileList.GetEntries()>0) {
1027
1028 // Remove local copies if there are any
1029 TIter next(&fFileList);
1030 TFile *file;
1031 while ((file = (TFile*) next())) {
1032 // close the files
1033 if (file->TestBit(kCanDelete)) file->Close();
1034 // remove the temporary files
1035 if(fLocal && !file->InheritsFrom(TMemFile::Class())) {
1036 TString p(file->GetPath());
1037 // coverity[unchecked_value] Index is return a value with range or NPos to select the whole name.
1038 p = p(0, p.Index(':',0));
1039 gSystem->Unlink(p);
1040 }
1041 }
1042 fFileList.Clear();
1043 if (result && fExcessFiles.GetEntries() > 0) {
1044 // We merge the first set of files in the output,
1045 // we now need to open the next set and make
1046 // sure we accumulate into the output, so we
1047 // switch to incremental merging (if not already set)
1050 }
1051 }
1052 if (!result) {
1053 Error("Merge", "error during merge of your ROOT files");
1054 } else {
1055 // Close or write is required so the file is complete.
1056 if (in_type & kIncremental) {
1057 // In the case of 'kDelayWrite' the caller want to avoid having to
1058 // write the output objects once for every input file and instead
1059 // write it only once at the end of the process.
1060 if (!(in_type & kDelayWrite))
1062 } else {
1063 // If in_type is not incremental but type is incremental we are now in
1064 // the case where the user "explicitly" request a non-incremental merge
1065 // but we still have internally an incremental merge. Because the user
1066 // did not request the incremental merge they also probably do not to a
1067 // final Write of the file and thus not doing the write here would lead
1068 // to data loss ...
1069 if (type & kIncremental)
1071 gROOT->GetListOfFiles()->Remove(fOutputFile);
1072 fOutputFile->Close();
1073 }
1074 }
1075
1076 // Cleanup
1077 if (in_type & kIncremental) {
1078 Clear();
1079 } else {
1083 }
1084 return result;
1085}
1086
1087////////////////////////////////////////////////////////////////////////////////
1088/// Open up to (fMaxOpenedFiles-1) of the excess files.
1089
1091{
1092 if (fPrintLevel > 0) {
1093 Printf("%s Opening the next %d files", fMsgPrefix.Data(), std::min(fExcessFiles.GetEntries(), fMaxOpenedFiles - 1));
1094 }
1095 Int_t nfiles = 0;
1096 TIter next(&fExcessFiles);
1097 TObjString *url = 0;
1099 // We want gDirectory untouched by anything going on here
1101 while( nfiles < (fMaxOpenedFiles-1) && ( url = (TObjString*)next() ) ) {
1102 TFile *newfile = 0;
1103 if (fLocal) {
1104 TUUID uuid;
1105 localcopy.Form("file:%s/ROOTMERGE-%s.root", gSystem->TempDirectory(), uuid.AsString());
1106 if (!TFile::Cp(url->GetName(), localcopy, url->TestBit(kCpProgress))) {
1107 Error("OpenExcessFiles", "cannot get a local copy of file %s", url->GetName());
1108 return kFALSE;
1109 }
1110 newfile = TFile::Open(localcopy, "READ");
1111 } else {
1112 newfile = TFile::Open(url->GetName(), "READ");
1113 }
1114
1115 if (!newfile) {
1116 if (fLocal)
1117 Error("OpenExcessFiles", "cannot open local copy %s of URL %s",
1118 localcopy.Data(), url->GetName());
1119 else
1120 Error("OpenExcessFiles", "cannot open file %s", url->GetName());
1121 return kFALSE;
1122 } else {
1123 if (fOutputFile && fOutputFile->GetCompressionLevel() != newfile->GetCompressionLevel()) fCompressionChange = kTRUE;
1124
1125 newfile->SetBit(kCanDelete);
1127 ++nfiles;
1129 }
1130 }
1131 return kTRUE;
1132}
1133
1134////////////////////////////////////////////////////////////////////////////////
1135/// Intercept the case where the output TFile is deleted!
1136
1138{
1140 Fatal("RecursiveRemove","Output file of the TFile Merger (targeting %s) has been deleted (likely due to a TTree larger than 100Gb)", fOutputFilename.Data());
1141 }
1142
1143}
1144
1145////////////////////////////////////////////////////////////////////////////////
1146/// Set a limit to the number of files that TFileMerger will open simultaneously.
1147///
1148/// This number includes both the read input files and the output file.
1149/// \param newmax if higher than the system limit, we reset it to the system limit;
1150/// if less than two, we reset it to 2 (one for the output file and one for the input file).
1151
1153{
1155 if (newmax < sysmax) {
1157 } else {
1159 }
1160 if (fMaxOpenedFiles < 2) {
1161 fMaxOpenedFiles = 2;
1162 }
1163}
1164
1165////////////////////////////////////////////////////////////////////////////////
1166/// Set the prefix to be used when printing informational message.
1167
1168void TFileMerger::SetMsgPrefix(const char *prefix)
1169{
1170 fMsgPrefix = prefix;
1171}
1172
#define SafeDelete(p)
Definition RConfig.hxx:525
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define BIT(n)
Definition Rtypes.h:91
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
TClassRef R__TH1_Class("TH1")
static const Int_t kClingFileNumber
static Int_t R__GetSystemMaxOpenedFiles()
Return the maximum number of allowed opened files minus some wiggle room for Cling or at least of the...
TClassRef R__RNTuple_Class("ROOT::RNTuple")
TClassRef R__TTree_Class("TTree")
static const Int_t kCpProgress
winID h TVirtualViewer3D TVirtualGLPainter p
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 target
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 result
Option_t Option_t TPoint TPoint const char mode
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:148
@ kMustCleanup
Definition TObject.h:376
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:777
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:417
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2510
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
#define R__LOCKGUARD(mutex)
#define _(A, B)
Definition cfortran.h:108
const_iterator end() const
TClassRef is used to implement a permanent reference to a TClass object.
Definition TClassRef.h:29
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
TMethod * GetMethodWithPrototype(const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Find the method with a given prototype.
Definition TClass.cxx:4514
void Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
Definition TClass.cxx:5470
ROOT::ResetAfterMergeFunc_t GetResetAfterMerge() const
Return the wrapper around Merge.
Definition TClass.cxx:7604
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
Definition TClass.cxx:6017
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition TClass.cxx:6043
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4932
ROOT::MergeFunc_t GetMerge() const
Return the wrapper around Merge.
Definition TClass.cxx:7596
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:2994
Collection abstract base class.
Definition TCollection.h:65
static TClass * Class()
virtual Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
void Print(Option_t *option="") const override
Default print for collections, calls Print(option, 1).
TDirectory::TContext keeps track and restore the current directory.
Definition TDirectory.h:89
Describe directory structure in memory.
Definition TDirectory.h:45
static TClass * Class()
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
virtual const char * GetPath() const
Returns the full path of the directory.
A class to pass information from the TFileMerger to the objects being merged.
TString fObjectNames
List of object names to be either merged exclusively or skipped.
Definition TFileMerger.h:63
virtual Bool_t OutputFile(const char *url, Bool_t force)
Open merger output file.
TList fMergeList
list of TObjString containing the name of the files need to be merged
Definition TFileMerger.h:64
virtual Bool_t AddFile(TFile *source, Bool_t own, Bool_t cpProgress)
Add the TFile to this file merger and give ownership of the TFile to this object (unless kFALSE is re...
virtual void PrintFiles(Option_t *options)
Print list of files being merged.
Bool_t fHistoOneGo
Merger histos in one go (default is kTRUE)
Definition TFileMerger.h:62
virtual Bool_t MergeRecursive(TDirectory *target, TList *sourcelist, Int_t type=kRegular|kAll)
Merge all objects in a directory.
void RecursiveRemove(TObject *obj) override
Intercept the case where the output TFile is deleted!
TList fFileList
A list the file (TFile*) which shall be merged.
Definition TFileMerger.h:47
virtual Bool_t Merge(Bool_t=kTRUE)
Merge the files.
virtual Bool_t MergeOne(TDirectory *target, TList *sourcelist, Int_t type, TFileMergeInfo &info, TString &oldkeyname, THashList &allNames, Bool_t &status, Bool_t &onlyListed, const TString &path, TDirectory *current_sourcedir, TFile *current_file, TKey *key, TObject *obj, TIter &nextkey)
TString fOutputFilename
The name of the outputfile for merging.
Definition TFileMerger.h:49
TString fMsgPrefix
Prefix to be used when printing informational message (default TFileMerger)
Definition TFileMerger.h:57
TIOFeatures * fIOFeatures
IO features to use in the output file.
Definition TFileMerger.h:56
TFileMerger(const TFileMerger &)=delete
void SetMsgPrefix(const char *prefix)
Set the prefix to be used when printing informational message.
Bool_t fNoTrees
True if Trees should not be merged (default is kFALSE)
Definition TFileMerger.h:51
bool fOutFileWasExplicitlyClosed
! the user has called CloseOutputFile(), so we shouldn't error out in RecursiveRemove
Definition TFileMerger.h:67
@ kAll
Merge all type of objects (default)
Definition TFileMerger.h:87
@ kIncremental
Merge the input file with the content of the output file (if already existing).
Definition TFileMerger.h:82
@ kKeepCompression
Keep compression level unchanged for each input files.
Definition TFileMerger.h:92
@ kSkipListed
Skip objects specified in fObjectNames list.
Definition TFileMerger.h:91
@ kNonResetable
Only the objects without a MergeAfterReset member function.
Definition TFileMerger.h:84
@ kResetable
Only the objects with a MergeAfterReset member function.
Definition TFileMerger.h:83
@ kOnlyListed
Only the objects specified in fObjectNames list.
Definition TFileMerger.h:90
@ kRegular
Normal merge, overwriting the output file.
Definition TFileMerger.h:81
@ kDelayWrite
Delay the TFile write (to reduce the number of write when reusing the file)
Definition TFileMerger.h:85
Bool_t fExplicitCompLevel
True if the user explicitly requested a compression level change (default kFALSE)
Definition TFileMerger.h:52
Bool_t fCompressionChange
True if the output and input have different compression level (default kFALSE)
Definition TFileMerger.h:53
EErrorBehavior fErrBehavior
What to do in case of errors during merging.
Definition TFileMerger.h:58
Int_t fPrintLevel
How much information to print out at run time.
Definition TFileMerger.h:54
void SetMaxOpenedFiles(Int_t newmax)
Set a limit to the number of files that TFileMerger will open simultaneously.
TString fMergeOptions
Options (in string format) to be passed down to the Merge functions.
Definition TFileMerger.h:55
void CloseOutputFile()
Closes output file.
~TFileMerger() override
Cleanup.
@ kFailOnError
The merging process will stop and yield failure when encountering invalid objects.
@ kSkipOnError
The merging process will skip invalid objects and continue.
Bool_t OpenExcessFiles()
Open up to (fMaxOpenedFiles-1) of the excess files.
TList fExcessFiles
! List of TObjString containing the name of the files not yet added to fFileList due to user or syste...
Definition TFileMerger.h:65
TFile * fOutputFile
The outputfile for merging.
Definition TFileMerger.h:48
virtual Bool_t PartialMerge(Int_t type=kAll|kIncremental)
Merge the files.
Bool_t fLocal
Makes local copies of merging files if True (default is kTRUE)
Definition TFileMerger.h:61
virtual void Reset()
Reset merger file list.
Int_t fMaxOpenedFiles
Maximum number of files opened at the same time by the TFileMerger.
Definition TFileMerger.h:60
virtual Bool_t AddAdoptFile(TFile *source, Bool_t cpProgress=kTRUE)
Add the TFile to this file merger and give ownership of the TFile to this object (unless kFALSE is re...
Bool_t fFastMethod
True if using Fast merging algorithm (default)
Definition TFileMerger.h:50
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition TFile.h:130
Int_t GetCompressionSettings() const
Definition TFile.h:489
virtual Bool_t Cp(const char *dst, Bool_t progressbar=kTRUE, UInt_t bufsize=1000000)
Allows to copy this file to the dst URL.
Definition TFile.cxx:4706
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override
Write memory objects to this file.
Definition TFile.cxx:2488
Int_t GetCompressionLevel() const
Definition TFile.h:483
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:3787
void Close(Option_t *option="") override
Close a file.
Definition TFile.cxx:981
@ kCancelTTreeChangeRequest
Definition TFile.h:275
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition TKey.h:28
const char * GetTitle() const override
Returns title (title can contain 32x32 xpm thumbnail/icon).
Definition TKey.cxx:1552
virtual const char * GetClassName() const
Definition TKey.h:77
virtual TObject * ReadObj()
To read a TObject* from the file.
Definition TKey.cxx:804
A doubly linked list.
Definition TList.h:38
void Clear(Option_t *option="") override
Remove all objects from the list.
Definition TList.cxx:532
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:952
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:789
static TClass * Class()
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
An array of TObjects.
Definition TObjArray.h:31
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:42
virtual void Clear(Option_t *="")
Definition TObject.h:127
@ kOverwrite
overwrite existing object with same name
Definition TObject.h:101
@ kSingleKey
write collection with single key
Definition TObject.h:100
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:462
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition TObject.cxx:243
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1084
virtual void Execute(const char *method, const char *params, Int_t *error=nullptr)
Execute method on this object with the given parameter string, e.g.
Definition TObject.cxx:378
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition TObject.h:161
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition TObject.cxx:989
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:888
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:549
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1098
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1126
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:507
virtual TClass * IsA() const
Definition TObject.h:248
void ResetBit(UInt_t f)
Definition TObject.h:203
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:71
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition TObject.h:73
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1072
Basic string class.
Definition TString.h:138
void Clear()
Clear string without changing its capacity.
Definition TString.cxx:1241
const char * Data() const
Definition TString.h:384
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition TString.cxx:2270
TString & Remove(Ssiz_t pos)
Definition TString.h:694
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1396
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition TSystem.cxx:1497
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
Definition TUUID.h:42
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
Definition TUUID.cxx:602
This class represents a WWW compatible URL.
Definition TUrl.h:33
Long64_t(* MergeFunc_t)(void *, TCollection *, TFileMergeInfo *)
Definition Rtypes.h:121