AliPhysics  1168478 (1168478)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AddTaskMuonCuts.C
Go to the documentation of this file.
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"
13 #endif
14 
16 {
17  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
18  if (!mgr) {
19  ::Error("AddtaskMuonCuts", "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("AddtaskMuonCuts", "MuonCuts 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_muonCuts";
33  else outputfile = "muonCutsAnalysis.root";
34 
35  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("MuonTrackCuts",TObjArray::Class(),AliAnalysisManager::kOutputContainer,outputfile);
36 
37  // Create cuts
38  AliMuonTrackCuts* muonTrackCuts = new AliMuonTrackCuts("TestStandardMuonTrackCuts", "TestStandardMuonTrackCuts");
39  muonTrackCuts->SetIsMC(isMC);
40  muonTrackCuts->SetAllowDefaultParams();
41  muonTrackCuts->SetCustomParamFromRun();
42 
43  // Create task
44  AliAnalysisTaskMuonCuts *muonCutsAnalysisTask = new AliAnalysisTaskMuonCuts("MuonCutsTask", *muonTrackCuts);
45  if ( isMC ) muonCutsAnalysisTask->SetTrigClassPatterns("ANY");
46  mgr->AddTask(muonCutsAnalysisTask);
47 
48  // Connect containers
49  mgr->ConnectInput (muonCutsAnalysisTask, 0, mgr->GetCommonInputContainer());
50  mgr->ConnectOutput (muonCutsAnalysisTask, 1, coutput1);
51 
52  return muonCutsAnalysisTask;
53 }
AliAnalysisTaskMuonCuts * AddTaskMuonCuts(Bool_t isMC=kFALSE)
Bool_t isMC
bool Bool_t
Definition: External.C:53