AliAODEvent::GetHeader now return AliVHeader
[u/mrichter/AliRoot.git] / PWG / muon / AddTaskTreeBuilder.C
CommitLineData
c9726e00 1AliAnalysisTaskMuonTreeBuilder *AddTaskTreeBuilder(Bool_t ismc=kFALSE, Int_t run_num=0){
2 printf("Inside add task\n");
3 // Get the pointer to the existing analysis manager via the static access method
4 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
5 if (!mgr) {
6 ::Error("AddTaskMuonTreeBuilder", "No analysis manager to connect to");
7 return NULL;
8 }
9
10 // MC handler if needed
11 if(ismc){
12 AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
13 if (!mcH) {
14 ::Error("AddTaskTreeBuilder", "No MC handler connected");
15 return NULL;
16 }
17 }
18
19 // The task
20 AliAnalysisTaskMuonTreeBuilder *task = new AliAnalysisTaskMuonTreeBuilder("AliAnalysisTaskMuonTreeBuilder");
21 if(ismc) task->SetIsMC(kTRUE);
22
23 //outputs
24// AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("chist0",TList::Class(),AliAnalysisManager::kOutputContainer,"final02.root");
25// AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("ctree0",TTree::Class(),AliAnalysisManager::kOutputContainer,"final02.root");
26 char outname[30];
27 sprintf(outname,"TreeRUN%d.root",run_num);
28 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("ctree0",TTree::Class(),AliAnalysisManager::kOutputContainer,outname);
29
30 // Adding the task to the analysis manager
31 mgr->AddTask(task);
32 mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
33 mgr->ConnectOutput(task,1,coutput1);
34// mgr->ConnectOutput(task,2,coutput2);
35
36 return task;
37}