Updated syst for D0 RAA vs. centrality (AndreaR, Davide)
[u/mrichter/AliRoot.git] / PWG / muon / AddTaskSingleMuonAnalysis.C
CommitLineData
4ab8d5a6 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include "TString.h"
3#include "TList.h"
4
5#include "AliLog.h"
6#include "AliVEventHandler.h"
7
8#include "AliAnalysisManager.h"
9#include "AliAnalysisDataContainer.h"
10
11#include "AliCFContainer.h"
12
13#include "AliAnalysisTaskSingleMu.h"
14#endif
15
75008b31 16AliAnalysisTaskSingleMu* AddTaskSingleMuonAnalysis(Bool_t applyPhysicsSelection=kTRUE, Int_t fillNtupleScaleDown=0, Bool_t keepAll=kFALSE, Bool_t separateSpecialOut=kFALSE){
d394951c 17
18 // Get the pointer to the existing analysis manager via the static access method.
19 //==============================================================================
4583fe14 20
d394951c 21 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
22 if (!mgr) {
23 ::Error("AddtaskSingleMuonAnalysis", "No analysis manager to connect to.");
24 return NULL;
25 }
d394951c 26
b201705a 27 // This task requires an ESD or AOD output handler.
28 // Check this using the analysis manager.
29 //===============================================================================
30 TString type = mgr->GetInputEventHandler()->GetDataType();
31 if (!type.Contains("ESD") && !type.Contains("AOD")) {
32 ::Error("AddtaskSingleMuonAnalysis", "SingleMuon task needs the manager to have an ESD or AOD input handler.");
33 return NULL;
34 }
d394951c 35
4ab8d5a6 36 TString currName = "";
589e3f71 37 TString outputfile = mgr->GetCommonFileName();
4ab8d5a6 38 if ( ! outputfile.IsNull() ) {
39 currName = ( applyPhysicsSelection ) ? ":PWG3_muon_SingleMu" : ":PWG3_muon_SingleMu_NoPS";
40 outputfile += currName;
41 }
42 else outputfile = "singleMuonAnalysis.root";
43
44 currName = ( applyPhysicsSelection ) ? "SingleMuonContainer" : "SingleMuonContainerNoPS";
45 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(currName.Data(),AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,outputfile);
d08e8cce 46
4ab8d5a6 47 currName = ( applyPhysicsSelection ) ? "SingleMuon" : "SingleMuonNoPS";
48 AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(currName.Data(),TList::Class(),AliAnalysisManager::kOutputContainer,outputfile);
55065f3f 49
4ab8d5a6 50 currName = ( applyPhysicsSelection ) ? "SingleMuonQA" : "SingleMuonQANoPS";
51 AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(currName.Data(),TList::Class(),AliAnalysisManager::kOutputContainer,outputfile);
589e3f71 52
4ab8d5a6 53 currName = ( applyPhysicsSelection ) ? "SingleMuonMC" : "SingleMuonMCNoPS";
54 AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(currName.Data(),TList::Class(),AliAnalysisManager::kOutputContainer,outputfile);
55
56 AliAnalysisDataContainer *coutput5 = 0x0;
589e3f71 57 if ( fillNtupleScaleDown > 0 ) {
4ab8d5a6 58 currName = ( applyPhysicsSelection ) ? "SingleMuonNtuple" : "SingleMuonNtupleNoPS";
75008b31 59 TString specialOutFilename = separateSpecialOut ? currName + ".root" : outputfile;
60 coutput5 = mgr->CreateContainer(currName.Data(),TTree::Class(),AliAnalysisManager::kOutputContainer,specialOutFilename);
589e3f71 61 coutput5->SetSpecialOutput();
b201705a 62 }
63
d394951c 64
4583fe14 65 // Create the task, add it to the manager and configure it.
93d6def1 66 //===========================================================================
67 TString taskName = ( applyPhysicsSelection ) ? "SingleMuonAnalysisTask" : "SingleMuonAnalysisTaskNoPS";
68 AliAnalysisTaskSingleMu *singleMuonAnalysisTask = new AliAnalysisTaskSingleMu(taskName.Data(), fillNtupleScaleDown, keepAll);
4ab8d5a6 69 mgr->AddTask(singleMuonAnalysisTask);
70 if ( applyPhysicsSelection )
75008b31 71 singleMuonAnalysisTask->SelectCollisionCandidates(AliVEvent::kAny);
d394951c 72
73 // Create ONLY the output containers for the data produced by the task.
74 // Get and connect other common input/output containers via the manager as below
75 //==============================================================================
4583fe14 76
4ab8d5a6 77 mgr->ConnectInput (singleMuonAnalysisTask, 0, mgr->GetCommonInputContainer());
78 mgr->ConnectOutput (singleMuonAnalysisTask, 1, coutput1);
79 mgr->ConnectOutput (singleMuonAnalysisTask, 2, coutput2);
80 mgr->ConnectOutput (singleMuonAnalysisTask, 3, coutput3);
81 mgr->ConnectOutput (singleMuonAnalysisTask, 4, coutput4);
d394951c 82
55065f3f 83 if ( coutput5 )
4ab8d5a6 84 mgr->ConnectOutput (singleMuonAnalysisTask, 5, coutput5);
b201705a 85
4ab8d5a6 86 return singleMuonAnalysisTask;
87}