12 void QAmergeRefHists(
char* listFile,
char* oldFile,
char* modFile,
char* newFile) {
15 gSystem->Load(
"St_base");
16 gSystem->Load(
"StarClassLibrary");
17 gSystem->Load(
"StUtilities");
19 TFile oldFi(oldFile,
"READ");
20 TFile modFi(modFile,
"READ");
21 TFile newFi(newFile,
"RECREATE");
23 TList* oldKeys = oldFi.GetListOfKeys();
24 TList* modKeys = modFi.GetListOfKeys();
28 TString histName,modName;
32 nkeys = oldKeys->GetSize();
34 for (i = 0; i < nkeys; i++) newKeys.Add(oldKeys->At(i));
36 ifstream listFi(listFile);
37 while (listFi.good()) {
40 Bool_t modifyName = histName.BeginsWith(
"__");
44 Ssiz_t endNewName = histName.Index(
"__x__",5,2);
45 if (endNewName > 0 && endNewName < histName.Length()-5) {
46 modName = histName(2,endNewName-2);
47 histName.Remove(0,endNewName+5);
48 }
else modifyName = kFALSE;
50 TKey* modKey = (TKey*) (modKeys->FindObject(histName.Data()));
52 histName.ReplaceAll(
'_',
' ');
53 if (modifyName) modName.ReplaceAll(
'_',
' ');
54 modKey = (TKey*) (modKeys->FindObject(histName.Data()));
58 if (newKeys.FindObject(modKey))
continue;
61 TObject* oldKey = newKeys.FindObject(modifyName ?
62 modName.Data() : histName.Data());
64 newKeys.AddAfter(oldKey,modKey);
65 newKeys.Remove(oldKey);
69 if (modifyName) modNames.Add(modKey,
new TNamed(modName,modName));
75 nkeys = newKeys.GetSize();
76 for (i = 0; i < nkeys; i++) {
77 TKey* key = (TKey*) (newKeys.At(i));
78 TObject* obj = key->ReadObj();
79 TObject* modValue = modNames.GetValue(key);
81 if (modValue) ((TNamed*) obj)->SetName(modValue->GetName());