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, std::unordered_map< TClass *, void * > *cache, 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
std::unordered_map< TClass *, void * > * m_cache

Detailed Description

Definition at line 44 of file AthenaRootSharedWriterSvc.cxx.

Constructor & Destructor Documentation

◆ ParallelFileMerger()

ParallelFileMerger::ParallelFileMerger ( const char * filename,
std::unordered_map< TClass *, void * > * cache,
int compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault )
inline

Definition at line 50 of file AthenaRootSharedWriterSvc.cxx.

51 : fFilename(filename), fMerger(kFALSE, kTRUE), m_cache(cache)
52 {
53 fMerger.OutputFile(filename, "RECREATE", compress);
54 }
std::unordered_map< TClass *, void * > * m_cache

◆ ~ParallelFileMerger()

ParallelFileMerger::~ParallelFileMerger ( )
inline

Definition at line 56 of file AthenaRootSharedWriterSvc.cxx.

57 {
58 }

Member Function Documentation

◆ GetName()

const char * ParallelFileMerger::GetName ( ) const
inline

Definition at line 65 of file AthenaRootSharedWriterSvc.cxx.

66 {
67 return fFilename;
68 }

◆ Hash()

ULong_t ParallelFileMerger::Hash ( ) const
inline

Definition at line 60 of file AthenaRootSharedWriterSvc.cxx.

61 {
62 return fFilename.Hash();
63 }

◆ MergeTrees()

Bool_t ParallelFileMerger::MergeTrees ( TFile * input)
inline

Definition at line 117 of file AthenaRootSharedWriterSvc.cxx.

118 {
119 fMerger.AddFile(input);
120 TIter nextKey(input->GetListOfKeys());
121 while (TKey* key = static_cast<TKey*>(nextKey())) {
122 TClass* cl = TClass::GetClass(key->GetClassName());
123 if (cl != nullptr && cl->InheritsFrom("TTree")) {
124 TTree* outCollTree = static_cast<TTree*>(fMerger.GetOutputFile()->Get(key->GetName()));
125 TTree* inCollTree = static_cast<TTree*>(input->Get(key->GetName()));
126 if (inCollTree != nullptr && outCollTree != nullptr) {
127 if (syncBranches(outCollTree, inCollTree)) {
128 input->Write();
129 }
130 syncBranches(inCollTree, outCollTree);
131 }
132 }
133 }
134
135 Bool_t result = fMerger.PartialMerge(TFileMerger::kIncremental | TFileMerger::kResetable | TFileMerger::kKeepCompression);
136 nextKey = input->GetListOfKeys();
137 while (TKey* key = static_cast<TKey*>(nextKey())) {
138 TClass* cl = TClass::GetClass(key->GetClassName());
139 if (cl != nullptr && 0 != cl->GetResetAfterMerge()) {
140 key->Delete();
141 input->GetListOfKeys()->Remove(key);
142 delete key;
143 }
144 }
145 return result;
146 }
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 71 of file AthenaRootSharedWriterSvc.cxx.

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

Member Data Documentation

◆ fFilename

TString ParallelFileMerger::fFilename

Definition at line 46 of file AthenaRootSharedWriterSvc.cxx.

◆ fMerger

TFileMerger ParallelFileMerger::fMerger

Definition at line 47 of file AthenaRootSharedWriterSvc.cxx.

◆ m_cache

std::unordered_map<TClass*, void*>* ParallelFileMerger::m_cache

Definition at line 48 of file AthenaRootSharedWriterSvc.cxx.


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