-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetHists.C
More file actions
46 lines (35 loc) · 1.21 KB
/
GetHists.C
File metadata and controls
46 lines (35 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* File : GetHists.C
* Author : Anton Riedel <anton.riedel@tum.de>
* Date : 15.09.2021
* Last Modified Date: 09.12.2021
* Last Modified By : Anton Riedel <anton.riedel@tum.de>
*/
#include "GridHelperMacros.H"
#include <algorithm>
Int_t GetHists(const char *DataFile, const char *OutputFileName,
const char *Search) {
TFile *dataFile = new TFile(DataFile, "READ");
// open output directory
TDirectoryFile *tdirFile = dynamic_cast<TDirectoryFile *>(
dataFile->Get(std::getenv("OUTPUT_TDIRECTORY_FILE")));
TFile *outputFile = new TFile(OutputFileName, "UPDATE");
TList *searchList;
TObject *obj;
TH1D *hist;
std::string searchString(Search);
std::string name;
for (auto KeyTask : *(tdirFile->GetListOfKeys())) {
std::cout << "Working on Task: " << KeyTask->GetName() << std::endl;
searchList = dynamic_cast<TList *>(tdirFile->Get(KeyTask->GetName()));
name = std::string(KeyTask->GetName());
name += "_";
obj = IterateList(searchList, searchString);
name += obj->GetName();
hist = dynamic_cast<TH1D *>(obj->Clone(name.c_str()));
hist->Write();
}
outputFile->Close();
dataFile->Close();
return 0;
}