AliPhysics  vAN-20150427 (e6e7aad)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AddTaskMuonFakes.C
Go to the documentation of this file.
1 AliAnalysisTaskMuonFakes* AddTaskMuonFakes(Bool_t useMCLabels = kFALSE, Bool_t combineMCId = kFALSE,
2  Bool_t matchTrig = kFALSE, Bool_t applyAccCut = kFALSE,
3  TString extension = "")
4 {
6 
7  // Get the pointer to the existing analysis manager via the static access method.
8  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
9  if(!mgr) {
10  Error("AddTaskMuonFakes","AliAnalysisManager not set!");
11  return NULL;
12  }
13 
14  // This task run on ESDs
15  TString type = mgr->GetInputEventHandler()->GetDataType();
16  if (!type.Contains("ESD")) {
17  Error("AddTaskMuonFakes", "ESD input handler needed!");
18  return NULL;
19  }
20 
21  // Create and configure task
22  TString name = Form("MUONFakes%s",extension.Data());
23  AliAnalysisTaskMuonFakes *task = new AliAnalysisTaskMuonFakes(name.Data());
24  if (!task) {
25  Error("AddTaskMuonFakes", "Muon fakes task cannot be created!");
26  return NULL;
27  }
28  task->UseMCLabels(useMCLabels);
29  task->CombineMCId(combineMCId);
30  task->MatchTrigger(matchTrig);
31  task->ApplyAccCut(applyAccCut);
32 
33  // Add task to analysis manager
34  mgr->AddTask(task);
35 
36  // Connect input container
37  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
38 
39  // Define output file directory
40  TString outputfile = AliAnalysisManager::GetCommonFileName();
41  if ( outputfile.IsNull() ) {
42  Error("AddTaskMuonFakes", "Common output file is not defined!");
43  return NULL;
44  }
45  outputfile += ":MUON_Fakes";
46  TString suffix = (!extension.IsNull()) ? Form("_%s",extension.Data()) : "";
47  outputfile += suffix;
48 
49  // Create and connect output containers
50  AliAnalysisDataContainer *cout_histo = mgr->CreateContainer(Form("histos%s",suffix.Data()), TObjArray::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
51  AliAnalysisDataContainer *cout_track = mgr->CreateContainer(Form("trackCounters%s",suffix.Data()), AliCounterCollection::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
52  AliAnalysisDataContainer *cout_fakeTrack = mgr->CreateContainer(Form("fakeTrackCounters%s",suffix.Data()), AliCounterCollection::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
53  AliAnalysisDataContainer *cout_matchTrack = mgr->CreateContainer(Form("matchedTrackCounters%s",suffix.Data()), AliCounterCollection::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
54  AliAnalysisDataContainer *cout_event = mgr->CreateContainer(Form("eventCounters%s",suffix.Data()), AliCounterCollection::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
55  AliAnalysisDataContainer *cout_histo2 = mgr->CreateContainer(Form("histos2%s",suffix.Data()), TObjArray::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
56  AliAnalysisDataContainer *cout_pair = mgr->CreateContainer(Form("pairCounters%s",suffix.Data()), AliCounterCollection::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
57  mgr->ConnectOutput(task, 1, cout_histo);
58  mgr->ConnectOutput(task, 2, cout_track);
59  mgr->ConnectOutput(task, 3, cout_fakeTrack);
60  mgr->ConnectOutput(task, 4, cout_matchTrack);
61  mgr->ConnectOutput(task, 5, cout_event);
62  mgr->ConnectOutput(task, 6, cout_histo2);
63  mgr->ConnectOutput(task, 7, cout_pair);
64 
65  return task;
66 }
67 
AliAnalysisTaskMuonFakes * AddTaskMuonFakes(Bool_t useMCLabels=kFALSE, Bool_t combineMCId=kFALSE, Bool_t matchTrig=kFALSE, Bool_t applyAccCut=kFALSE, TString extension="")
Muon task to study fake tracks.