]>
Commit | Line | Data |
---|---|---|
4ff26233 | 1 | TaskConsumer *AddTaskConsumer(const char *name, const char *prodname1, const char *prodname2) |
2 | { | |
3 | // Provide as input the name of the consumer task and the name of the | |
4 | // producer task | |
5 | // pointer to the analysis manager | |
6 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
7 | if (!mgr) { | |
8 | ::Error("AddTaskConsumer", "No analysis manager to connect to."); | |
9 | return NULL; | |
10 | } | |
11 | // create the task | |
12 | TaskConsumer *task = new TaskConsumer(name); | |
13 | mgr->AddTask(task); | |
14 | ||
15 | // connecting the input/output containers | |
16 | TString outfile = mgr->GetCommonFileName(); | |
17 | // input data feed | |
18 | AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer(); | |
19 | mgr->ConnectInput (task, 0, cinput0 ); | |
20 | // producer task | |
21 | TaskProducer *prod1 = mgr->GetTask(prodname1); | |
22 | TaskProducer *prod2 = mgr->GetTask(prodname2); | |
23 | if (!prod1 || !prod2) { | |
24 | ::Error("AddTaskConsumer", "Producer task %s or %s not found in the analysis manager", | |
25 | prodname1, prodname2); | |
26 | return 0; | |
27 | } | |
28 | // Connect to exchange container | |
29 | AliAnalysisDataContainer *cinput1 = prod1->GetOutputSlot(2)->GetContainer(); | |
30 | mgr->ConnectInput(task, 1, cinput1); | |
31 | AliAnalysisDataContainer *cinput2 = prod2->GetOutputSlot(2)->GetContainer(); | |
32 | mgr->ConnectInput(task, 2, cinput2); | |
33 | ||
34 | AliAnalysisDataContainer *coutput1 = mgr->CreateContainer( | |
35 | TString::Format("output_%s", name), | |
36 | TList::Class(), AliAnalysisManager::kOutputContainer, | |
37 | TString::Format("%s:output",outfile.Data())); | |
38 | mgr->ConnectOutput(task, 1, coutput1); | |
39 | return task; | |
40 | } |