Histos for pbar/p corrections added and few data members deleted, plus minor changes
[u/mrichter/AliRoot.git] / PWG3 / muon / AddTaskSingleMuonAnalysis.C
CommitLineData
589e3f71 1AliAnalysisTaskSingleMu *AddTaskSingleMuonAnalysis(Int_t fillNtupleScaleDown=0, 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";
589e3f71 22 TString outputfile = mgr->GetCommonFileName();
a9d946ff 23 if ( ! outputfile.IsNull() ) outputfile += ":PWG3_muon_SingleMu";
24 else outputfile = baseOutName;
d08e8cce 25
589e3f71 26 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("SingleMuonContainer",AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,outputfile);
27 AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("SingleMuon",TList::Class(),AliAnalysisManager::kOutputContainer,outputfile);
55065f3f 28 AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("SingleMuonQA",TList::Class(),AliAnalysisManager::kOutputContainer,outputfile);
29 AliAnalysisDataContainer *coutput4 = 0x0;
30 if ( mgr->GetMCtruthEventHandler() )
31 coutput4 = mgr->CreateContainer("SingleMuonMC",TList::Class(),AliAnalysisManager::kOutputContainer,outputfile);
32
589e3f71 33
34 AliAnalysisDataContainer *coutput5 = 0x0;
35 if ( fillNtupleScaleDown > 0 ) {
36 coutput5 = mgr->CreateContainer("SingleMuonNtuple",TTree::Class(),AliAnalysisManager::kOutputContainer,outputfile);
37 coutput5->SetSpecialOutput();
b201705a 38 }
39
d394951c 40
4583fe14 41 // Create the task, add it to the manager and configure it.
d394951c 42 //===========================================================================
4583fe14 43
589e3f71 44 AliAnalysisTaskSingleMu *SingleMuonAnalysisTask = new AliAnalysisTaskSingleMu("SingleMuonAnalysisTask", fillNtupleScaleDown, keepAll);
d394951c 45 mgr->AddTask(SingleMuonAnalysisTask);
46
47 // Create ONLY the output containers for the data produced by the task.
48 // Get and connect other common input/output containers via the manager as below
49 //==============================================================================
4583fe14 50
d394951c 51 mgr->ConnectInput (SingleMuonAnalysisTask, 0, mgr->GetCommonInputContainer());
52 mgr->ConnectOutput (SingleMuonAnalysisTask, 1, coutput1);
4583fe14 53 mgr->ConnectOutput (SingleMuonAnalysisTask, 2, coutput2);
589e3f71 54 mgr->ConnectOutput (SingleMuonAnalysisTask, 3, coutput3);
55065f3f 55 if ( coutput4 )
56 mgr->ConnectOutput (SingleMuonAnalysisTask, 4, coutput4);
d394951c 57
55065f3f 58 if ( coutput5 )
589e3f71 59 mgr->ConnectOutput (SingleMuonAnalysisTask, 5, coutput5);
b201705a 60
d394951c 61 return SingleMuonAnalysisTask;
62}