-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddTask.C.template
More file actions
70 lines (58 loc) · 2.31 KB
/
AddTask.C.template
File metadata and controls
70 lines (58 loc) · 2.31 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* File : AddTask.C.template
* Author : Anton Riedel <anton.riedel@tum.de>
* Date : 07.05.2021
* Last Modified Date: 04.02.2022
* Last Modified By : Anton Riedel <anton.riedel@tum.de>
*/
#include <fstream>
#include <nlohmann/json.hpp>
void AddTask(const char *ConfigFileName, Int_t RunNumber, Float_t CenterMin,
Float_t CenterMax) {
// Get the pointer to the existing analysis manager
// via the static access method.
AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
if (!mgr) {
Error("AddTask.C macro", "No analysis manager to connect to.");
return;
}
// Check the analysis type using the event handlers connected to the analysis
// manager. The availability of MC handler can also be checked here.
if (!mgr->GetInputEventHandler()) {
Error("AddTask.C macro", "This task requires an input event handler");
return;
}
// load config file
std::fstream ConfigFile(ConfigFileName);
nlohmann::json Jconfig = nlohmann::json::parse(ConfigFile);
// CONFIGURE TASK BELOW THIS LINE
// create first task here
AliAnalysisTaskAR *task = new AliAnalysisTaskAR(Form(
"%s_%.1f-%.1f", Jconfig["task"]["BaseName"].get<std::string>().c_str(),
CenterMin, CenterMax));
// set default cuts
task->SetDefaultConfiguration();
task->SetDefaultBinning();
task->SetDefaultCuts(128, CenterMin, CenterMax);
task->SetFillControlHistogramsOnly(kTRUE);
// add all tasks to the analysis manager in a loop
std::vector<AliAnalysisTaskAR *> tasks = {task};
// CONFIGURE TASKS ABOVE THIS LINE
// Define input/output containers:
std::string OutputFile =
Jconfig["task"]["GridOutputFile"].get<std::string>() + std::string(":") +
Jconfig["task"]["OutputTDirectory"].get<std::string>();
AliAnalysisDataContainer *cinput = nullptr;
AliAnalysisDataContainer *coutput = nullptr;
// loop over all tasks
for (auto T : tasks) {
mgr->AddTask(T);
cout << "Added to manager: " << T->GetName() << endl;
cinput = mgr->GetCommonInputContainer();
coutput = mgr->CreateContainer(T->GetName(), TList::Class(),
AliAnalysisManager::kOutputContainer,
OutputFile.c_str());
mgr->ConnectInput(T, 0, cinput);
mgr->ConnectOutput(T, 1, coutput);
}
}