]>
Commit | Line | Data |
---|---|---|
b201705a | 1 | AliAnalysisTaskSingleMu *AddTaskSingleMuonAnalysis(Bool_t fillNtuple=kFALSE, Bool_t keepAll=kFALSE){ |
d394951c | 2 | |
3 | // Get the pointer to the existing analysis manager via the static access method. | |
4 | //============================================================================== | |
4583fe14 | 5 | |
d394951c | 6 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); |
7 | if (!mgr) { | |
8 | ::Error("AddtaskSingleMuonAnalysis", "No analysis manager to connect to."); | |
9 | return NULL; | |
10 | } | |
d394951c | 11 | |
b201705a | 12 | // This task requires an ESD or AOD output handler. |
13 | // Check this using the analysis manager. | |
14 | //=============================================================================== | |
15 | TString type = mgr->GetInputEventHandler()->GetDataType(); | |
16 | if (!type.Contains("ESD") && !type.Contains("AOD")) { | |
17 | ::Error("AddtaskSingleMuonAnalysis", "SingleMuon task needs the manager to have an ESD or AOD input handler."); | |
18 | return NULL; | |
19 | } | |
d394951c | 20 | |
a9d946ff | 21 | TString baseOutName = "singleMuonAnalysis.root"; |
d08e8cce | 22 | TString outputfile = AliAnalysisManager::GetCommonFileName(); |
a9d946ff | 23 | if ( ! outputfile.IsNull() ) outputfile += ":PWG3_muon_SingleMu"; |
24 | else outputfile = baseOutName; | |
d08e8cce | 25 | |
26 | AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("SingleMuon",TList::Class(),AliAnalysisManager::kOutputContainer,outputfile); | |
4583fe14 | 27 | AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("SingleMuonMC",TList::Class(),AliAnalysisManager::kOutputContainer,outputfile); |
b201705a | 28 | AliAnalysisDataContainer *coutput3 = 0x0; |
29 | ||
30 | if ( fillNtuple ) { | |
31 | coutput3 = mgr->CreateContainer("SingleMuonNtuple",TTree::Class(),AliAnalysisManager::kOutputContainer,outputfile); | |
32 | coutput3->SetSpecialOutput(); | |
33 | } | |
34 | ||
d394951c | 35 | |
4583fe14 | 36 | // Create the task, add it to the manager and configure it. |
d394951c | 37 | //=========================================================================== |
4583fe14 | 38 | |
a9d946ff | 39 | AliAnalysisTaskSingleMu *SingleMuonAnalysisTask = new AliAnalysisTaskSingleMu("SingleMuonAnalysisTask", fillNtuple, keepAll); |
d394951c | 40 | mgr->AddTask(SingleMuonAnalysisTask); |
41 | ||
42 | // Create ONLY the output containers for the data produced by the task. | |
43 | // Get and connect other common input/output containers via the manager as below | |
44 | //============================================================================== | |
4583fe14 | 45 | |
d394951c | 46 | mgr->ConnectInput (SingleMuonAnalysisTask, 0, mgr->GetCommonInputContainer()); |
47 | mgr->ConnectOutput (SingleMuonAnalysisTask, 1, coutput1); | |
4583fe14 | 48 | mgr->ConnectOutput (SingleMuonAnalysisTask, 2, coutput2); |
d394951c | 49 | |
b201705a | 50 | if ( fillNtuple ) |
51 | mgr->ConnectOutput (SingleMuonAnalysisTask, 3, coutput3); | |
52 | ||
d394951c | 53 | return SingleMuonAnalysisTask; |
54 | } |