]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/muon/AddTaskMuonsHF.C
a5ff5aa4379e71a6c516a88c8ce134d9682641f7
[u/mrichter/AliRoot.git] / PWG3 / muon / AddTaskMuonsHF.C
1 AliAnalysisTaskSEMuonsHF* AddTaskMuonsHF(Int_t mode=0, Bool_t isMC=kFALSE, Bool_t isTree=kFALSE)
2 {
3   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
4   if (!mgr) {
5     ::Error("AddTaskMuonsHF", "No analysis manager to connect to.");
6     return NULL;
7   }
8   TString type = mgr->GetInputEventHandler()->GetDataType();
9   if (!type.Contains("ESD") && !type.Contains("AOD")) {
10     ::Error("AddTaskMuonsHF", "MuonsHF task needs the manager to have an ESD or AOD input handler.");
11     return NULL;
12   }
13   if (isMC && type.Contains("ESD")) {
14     AliMCEventHandler *mcH = mgr->GetMCtruthEventHandler();
15     if (!mcH) {
16       ::Error("AddTaskMuonsHF", "MuonsHF task needs the manager to have an MC evnet handler.");
17       return NULL;
18     }
19   }
20   if (isTree) {
21     AliAODHandler *aodH = (AliAODHandler*)mgr->GetOutputEventHandler();
22     if (!aodH) {
23       ::Error("AddTaskMuonsHF", "MuonsHF task needs the manager to have an AOD output handler.");
24       return NULL;
25     }
26   }
27
28   // set cuts for events or muons selection
29   Double_t cutsEvsH[3] ={-999999.0,   // low limit of Ncontrs
30                           999999.0,   // up limit of |vz|
31                           999999.0};  // up limit of vt
32   Double_t cutsMuon[12]={-999999.0,   //   0, min of 3-momentum
33                           999999.0,   //   1, max of 3-momnentum
34                          -999999.0,   //   2, PtMin
35                           999999.0,   //   3, PtMax
36                          -999999.0,   //   4, EtaMin
37                           999999.0,   //   5, EtaMax
38                          -999999.0,   //   6, DCAmin
39                           999999.0,   //   7, DCAmax
40                          -999999.0,   //   8, for trigger
41                           999999.0,   //   9, for trigger
42                          -999999.0,   //  10, RabsEndMin
43                           999999.0,};  // 11, RabsEndMax
44   Double_t cutsDimu[12]={-999999.0, 999999.0,  // single muon cuts used for dimuon selection
45                          -999999.0, 999999.0,
46                          -999999.0, 999999.0,
47                          -999999.0, 999999.0,
48                          -999999.0, 999999.0,
49                          -999999.0, 999999.0};
50   AliAnalysisTaskSEMuonsHF *taskMuonsHF = new AliAnalysisTaskSEMuonsHF("MuonsHF Analysis Task");
51   taskMuonsHF->SetAnaMode(mode);
52   taskMuonsHF->SetUseMC(isMC);
53   taskMuonsHF->SetIsOutputTree(isTree);
54   taskMuonsHF->SetEvsHCuts(cutsEvsH);
55   taskMuonsHF->SetMuonCuts(cutsMuon);
56   taskMuonsHF->SetDimuCuts(cutsDimu);
57   taskMuonsHF->SelectCollisionCandidates();
58   mgr->AddTask(taskMuonsHF);
59
60   mgr->ConnectInput(taskMuonsHF, 0, mgr->GetCommonInputContainer());
61   if (isTree) mgr->ConnectOutput(taskMuonsHF, 0, mgr->GetCommonOutputContainer());
62
63   char *fileName = "muonsHF.root";
64   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("histosList",TList::Class(),AliAnalysisManager::kOutputContainer,fileName);
65   mgr->ConnectOutput(taskMuonsHF,1,coutput1);
66
67   return taskMuonsHF;
68 }