ATLAS Offline Software
Loading...
Searching...
No Matches
ParallelFileMerger Struct Reference
Inheritance diagram for ParallelFileMerger:
Collaboration diagram for ParallelFileMerger:

Public Member Functions

 ParallelFileMerger (const char *filename, int compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
 ~ParallelFileMerger ()
ULong_t Hash () const
const char * GetName () const
bool syncBranches (TTree *fromTree, TTree *toTree)
Bool_t MergeTrees (TFile *input)

Public Attributes

TString fFilename
TFileMerger fMerger

Detailed Description

Definition at line 55 of file AthenaRootSharedWriterSvc.cxx.

Constructor & Destructor Documentation

◆ ParallelFileMerger()

ParallelFileMerger::ParallelFileMerger ( const char * filename,
int compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault )
inline

Definition at line 60 of file AthenaRootSharedWriterSvc.cxx.

60 : fFilename(filename), fMerger(kFALSE, kTRUE)
61 {
62 fMerger.OutputFile(filename, "RECREATE", compress);
63 }

◆ ~ParallelFileMerger()

ParallelFileMerger::~ParallelFileMerger ( )
inline

Definition at line 65 of file AthenaRootSharedWriterSvc.cxx.

66 {
67 }

Member Function Documentation

◆ GetName()

const char * ParallelFileMerger::GetName ( ) const
inline

Definition at line 74 of file AthenaRootSharedWriterSvc.cxx.

75 {
76 return fFilename;
77 }

◆ Hash()

ULong_t ParallelFileMerger::Hash ( ) const
inline

Definition at line 69 of file AthenaRootSharedWriterSvc.cxx.

70 {
71 return fFilename.Hash();
72 }

◆ MergeTrees()

Bool_t ParallelFileMerger::MergeTrees ( TFile * input)
inline

Definition at line 124 of file AthenaRootSharedWriterSvc.cxx.

125 {
126 fMerger.AddFile(input);
127 TIter nextKey(input->GetListOfKeys());
128 while (TKey* key = static_cast<TKey*>(nextKey())) {
129 TClass* cl = TClass::GetClass(key->GetClassName());
130 if (cl != nullptr && cl->InheritsFrom("TTree")) {
131 TTree* outCollTree = static_cast<TTree*>(fMerger.GetOutputFile()->Get(key->GetName()));
132 TTree* inCollTree = static_cast<TTree*>(input->Get(key->GetName()));
133 if (inCollTree != nullptr && outCollTree != nullptr) {
134 if (syncBranches(outCollTree, inCollTree)) {
135 input->Write();
136 }
137 syncBranches(inCollTree, outCollTree);
138 }
139 }
140 }
141
142 Bool_t result = fMerger.PartialMerge(TFileMerger::kIncremental | TFileMerger::kResetable | TFileMerger::kKeepCompression);
143 nextKey = input->GetListOfKeys();
144 while (TKey* key = static_cast<TKey*>(nextKey())) {
145 TClass* cl = TClass::GetClass(key->GetClassName());
146 if (cl != nullptr && 0 != cl->GetResetAfterMerge()) {
147 key->Delete();
148 input->GetListOfKeys()->Remove(key);
149 delete key;
150 }
151 }
152 return result;
153 }
T * Get(TFile &f, const std::string &n, const std::string &dir="", const chainmap_t *chainmap=0, std::vector< std::string > *saved=0)
get a histogram given a path, and an optional initial directory if histogram is not found,...
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
bool syncBranches(TTree *fromTree, TTree *toTree)

◆ syncBranches()

bool ParallelFileMerger::syncBranches ( TTree * fromTree,
TTree * toTree )
inline

Definition at line 80 of file AthenaRootSharedWriterSvc.cxx.

81 {
82 bool updated = false;
83 const TObjArray* fromBranches = fromTree->GetListOfBranches();
84 const TObjArray* toBranches = toTree->GetListOfBranches();
85 int nBranches = fromBranches->GetEntriesFast();
86 for (int k = 0; k < nBranches; ++k) {
87 TBranch* branch = static_cast<TBranch*>(fromBranches->UncheckedAt(k));
88 if (toBranches->FindObject(branch->GetName()) == nullptr) {
89 TBranch* newBranch = nullptr;
90 TClass* cl = TClass::GetClass(branch->GetClassName());
91 BranchDesc desc(cl);
92 void* empty = desc.dummyAddr();
93 if (strlen(branch->GetClassName()) > 0) {
94 newBranch = toTree->Branch(branch->GetName(), branch->GetClassName(), nullptr, branch->GetBasketSize(), branch->GetSplitLevel());
95 newBranch->SetAddress(empty);
96 } else {
97 TObjArray* outLeaves = branch->GetListOfLeaves();
98 TLeaf* leaf = static_cast<TLeaf*>(outLeaves->UncheckedAt(0));
99 std::string type = leaf->GetTypeName();
100 std::string attr = leaf->GetName();
101 if (type == "Int_t") type = attr + "/I";
102 else if (type == "Short_t") type = attr + "/S";
103 else if (type == "Long_t") type = attr + "/L";
104 else if (type == "UInt_t") type = attr + "/i";
105 else if (type == "UShort_t") type = attr + "/s";
106 else if (type == "ULong_t") type = attr + "/l";
107 else if (type == "Float_t") type = attr + "/F";
108 else if (type == "Double_t") type = attr + "/D";
109 else if (type == "Char_t") type = attr + "/B";
110 else if (type == "UChar_t") type = attr + "/b";
111 else if (type == "Bool_t") type = attr + "/O";
112 newBranch = toTree->Branch(branch->GetName(), static_cast<void*>(nullptr), type.c_str(), 2048);
113 }
114 int nEntries = toTree->GetEntries();
115 for (int m = 0; m < nEntries; ++m) {
116 newBranch->BackFill();
117 }
118 updated = true;
119 }
120 }
121 return updated;
122 }
static const Attributes_t empty

Member Data Documentation

◆ fFilename

TString ParallelFileMerger::fFilename

Definition at line 57 of file AthenaRootSharedWriterSvc.cxx.

◆ fMerger

TFileMerger ParallelFileMerger::fMerger

Definition at line 58 of file AthenaRootSharedWriterSvc.cxx.


The documentation for this struct was generated from the following file: