ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
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 125 of file AthenaRootSharedWriterSvc.cxx.

126  {
127  fMerger.AddFile(input);
128  TIter nextKey(input->GetListOfKeys());
129  while (TKey* key = static_cast<TKey*>(nextKey())) {
130  TClass* cl = TClass::GetClass(key->GetClassName());
131  if (cl != nullptr && cl->InheritsFrom("TTree")) {
132  TTree* outCollTree = static_cast<TTree*>(fMerger.GetOutputFile()->Get(key->GetName()));
133  TTree* inCollTree = static_cast<TTree*>(input->Get(key->GetName()));
134  if (inCollTree != nullptr && outCollTree != nullptr) {
135  if (syncBranches(outCollTree, inCollTree)) {
136  input->Write();
137  }
138  syncBranches(inCollTree, outCollTree);
139  }
140  }
141  }
142 
143  Bool_t result = fMerger.PartialMerge(TFileMerger::kIncremental | TFileMerger::kResetable | TFileMerger::kKeepCompression);
144  nextKey = input->GetListOfKeys();
145  while (TKey* key = static_cast<TKey*>(nextKey())) {
146  TClass* cl = TClass::GetClass(key->GetClassName());
147  if (cl != nullptr && 0 != cl->GetResetAfterMerge()) {
148  key->Delete();
149  input->GetListOfKeys()->Remove(key);
150  delete key;
151  }
152  }
153  return result;
154  }

◆ 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());
92  void* empty = desc.dummyAddr();
93  char buff[32];
94  if (strlen(branch->GetClassName()) > 0) {
95  newBranch = toTree->Branch(branch->GetName(), branch->GetClassName(), nullptr, branch->GetBasketSize(), branch->GetSplitLevel());
96  newBranch->SetAddress(empty);
97  } else {
98  TObjArray* outLeaves = branch->GetListOfLeaves();
99  TLeaf* leaf = static_cast<TLeaf*>(outLeaves->UncheckedAt(0));
100  std::string type = leaf->GetTypeName();
101  std::string attr = leaf->GetName();
102  if (type == "Int_t") type = attr + "/I";
103  else if (type == "Short_t") type = attr + "/S";
104  else if (type == "Long_t") type = attr + "/L";
105  else if (type == "UInt_t") type = attr + "/i";
106  else if (type == "UShort_t") type = attr + "/s";
107  else if (type == "UShort_t") type = attr + "/s";
108  else if (type == "Float_t") type = attr + "/F";
109  else if (type == "Double_t") type = attr + "/D";
110  else if (type == "Char_t") type = attr + "/B";
111  else if (type == "UChar_t") type = attr + "/b";
112  else if (type == "Bool_t") type = attr + "/O";
113  newBranch = toTree->Branch(branch->GetName(), buff, type.c_str(), 2048);
114  }
115  int nEntries = toTree->GetEntries();
116  for (int m = 0; m < nEntries; ++m) {
117  newBranch->BackFill();
118  }
119  updated = true;
120  }
121  }
122  return updated;
123  }

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:
get_hdefs.buff
buff
Definition: get_hdefs.py:61
get_generator_info.result
result
Definition: get_generator_info.py:21
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
Amg::compress
void compress(const AmgSymMatrix(N) &covMatrix, std::vector< float > &vec)
Definition: EventPrimitivesHelpers.h:56
ParallelFileMerger::syncBranches
bool syncBranches(TTree *fromTree, TTree *toTree)
Definition: AthenaRootSharedWriterSvc.cxx:80
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
CaloCondBlobAlgs_fillNoiseFromASCII.desc
desc
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:54
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
ParallelFileMerger::fFilename
TString fFilename
Definition: AthenaRootSharedWriterSvc.cxx:57
ParallelFileMerger::fMerger
TFileMerger fMerger
Definition: AthenaRootSharedWriterSvc.cxx:58
RTTAlgmain.branch
branch
Definition: RTTAlgmain.py:61
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
BranchDesc
Definiton of a branch descriptor from RootTreeContainer.
Definition: AthenaRootSharedWriterSvc.cxx:31
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
fitman.k
k
Definition: fitman.py:528
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37