Include standard cuts in analysis. Make it more suitable for proof analysis: eliminat...
[u/mrichter/AliRoot.git] / PWG / muon / AddTaskSingleMuonAnalysis.C
... / ...
CommitLineData
1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include "TString.h"
3#include "TObjArray.h"
4
5#include "AliLog.h"
6#include "AliVEventHandler.h"
7
8#include "AliAnalysisManager.h"
9#include "AliAnalysisDataContainer.h"
10
11#include "AliMuonTrackCuts.h"
12#include "AliAnalysisTaskSingleMu.h"
13#endif
14
15AliAnalysisTaskSingleMu* AddTaskSingleMuonAnalysis(Bool_t isMC = kFALSE)
16{
17 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
18 if (!mgr) {
19 ::Error("AddtaskSingleMu", "No analysis manager to connect to.");
20 return NULL;
21 }
22
23 TString type = mgr->GetInputEventHandler()->GetDataType();
24 if (!type.Contains("ESD") && !type.Contains("AOD")) {
25 ::Error("AddtaskSingleMu", "SingleMu task needs the manager to have an ESD or AOD input handler.");
26 return NULL;
27 }
28
29 // Create container
30 TString currName = "";
31 TString outputfile = mgr->GetCommonFileName();
32 if ( ! outputfile.IsNull() ) outputfile += ":PWG3_SingleMu";
33 else outputfile = "SingleMuAnalysis.root";
34
35 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("SingleMuOut",TObjArray::Class(),AliAnalysisManager::kOutputContainer,outputfile);
36
37 // Create cuts
38 AliMuonTrackCuts* muonTrackCuts = new AliMuonTrackCuts("TestStandardMuonTrackCuts", "TestStandardMuonTrackCuts", type.Contains("ESD"));
39 muonTrackCuts->SetIsMC(isMC);
40
41 // Create task
42 AliAnalysisTaskSingleMu *singleMuAnalysisTask = new AliAnalysisTaskSingleMu("SingleMuTask", *muonTrackCuts);
43 if ( isMC ) singleMuAnalysisTask->SetTrigClassPatterns("ANY");
44 mgr->AddTask(singleMuAnalysisTask);
45
46 // Connect containers
47 mgr->ConnectInput (singleMuAnalysisTask, 0, mgr->GetCommonInputContainer());
48 mgr->ConnectOutput (singleMuAnalysisTask, 1, coutput1);
49
50 return singleMuAnalysisTask;
51}