]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/muon/AddTaskMuonsHF.C
1 validate the official physics selection, centrality selection and event plane selec...
[u/mrichter/AliRoot.git] / PWG / muon / AddTaskMuonsHF.C
1 AliAnalysisTaskSEMuonsHF* AddTaskMuonsHF(Int_t mode=0, Bool_t isMC=kFALSE, Bool_t isTree=kFALSE, Bool_t isSel)
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[5] ={-999999.0,   // low limit of Ncontrs
30                           999999.0,   // up limit of |vz|
31                           999999.0,   // up limit of vt
32                          -999999.0,   // centrality min
33                           999999.0};  // centrality max
34   AliMuonTrackCuts *cutsMuon = new AliMuonTrackCuts("cutsMuon", "cutsMuon"); cutsMuon->SetIsMC(isMC);
35   AliMuonPairCuts  *cutsDimu = new  AliMuonPairCuts("cutsDimu", "cutsDimu"); cutsDimu->SetIsMC(isMC);
36   AliAnalysisTaskSEMuonsHF *taskMuonsHF = new AliAnalysisTaskSEMuonsHF("MuonsHF Analysis Task",*cutsMuon,*cutsDimu);
37   taskMuonsHF->SetAnaMode(mode);
38   taskMuonsHF->SetUseMC(isMC);
39   taskMuonsHF->SetIsOutputTree(isTree);
40   taskMuonsHF->SetEvsHCuts(cutsEvsH);
41   if (isSel) taskMuonsHF->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kMUON);
42   mgr->AddTask(taskMuonsHF);
43
44   mgr->ConnectInput(taskMuonsHF, 0, mgr->GetCommonInputContainer());
45   if (isTree) mgr->ConnectOutput(taskMuonsHF, 0, mgr->GetCommonOutputContainer());
46
47   char *fileName = "muonsHF.root";
48   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("histosList",TList::Class(),AliAnalysisManager::kOutputContainer,fileName);
49   mgr->ConnectOutput(taskMuonsHF,1,coutput1);
50
51   return taskMuonsHF;
52 }