Coding conventions
[u/mrichter/AliRoot.git] / PWG3 / muondep / AddTaskMuonFakes.C
CommitLineData
0ffd1c5a 1AliAnalysisTaskMuonFakes* AddTaskMuonFakes(Bool_t useMCLabels = kFALSE, Bool_t matchTrig = kFALSE, Bool_t applyAccCut = kFALSE)
fa97374c 2{
3 /// Add AliAnalysisTaskMuonFakes to the train (Philippe Pillot)
4
5 // Get the pointer to the existing analysis manager via the static access method.
6 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
7 if(!mgr) {
8 Error("AddTaskMuonFakes","AliAnalysisManager not set!");
9 return NULL;
10 }
11
12 // This task run on ESDs
13 TString type = mgr->GetInputEventHandler()->GetDataType();
14 if (!type.Contains("ESD")) {
15 Error("AddTaskMuonFakes", "ESD input handler needed!");
16 return NULL;
17 }
18
19 // Create and configure task
20 AliAnalysisTaskMuonFakes *task = new AliAnalysisTaskMuonFakes("MUONFakes");
21 if (!task) {
22 Error("AddTaskMuonFakes", "Muon fakes task cannot be created!");
23 return NULL;
24 }
25 task->UseMCLabels(useMCLabels);
0ffd1c5a 26 task->MatchTrigger(matchTrig);
27 task->ApplyAccCut(applyAccCut);
fa97374c 28
29 // Add task to analysis manager
30 mgr->AddTask(task);
31
32 // Connect input container
33 mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
34
35 // Define output file directory
36 TString outputfile = AliAnalysisManager::GetCommonFileName();
37 if ( outputfile.IsNull() ) {
38 Error("AddTaskMuonFakes", "Common output file is not defined!");
39 return NULL;
40 }
41 outputfile += ":MUON_Fakes";
42
43 // Create and connect output containers
44 AliAnalysisDataContainer *cout_histo = mgr->CreateContainer("histos", TObjArray::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
c121b0eb 45 AliAnalysisDataContainer *cout_track = mgr->CreateContainer("trackCounters", AliCounterCollection::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
46 AliAnalysisDataContainer *cout_fakeTrack = mgr->CreateContainer("fakeTrackCounters", AliCounterCollection::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
47 AliAnalysisDataContainer *cout_matchTrack = mgr->CreateContainer("matchedTrackCounters", AliCounterCollection::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
48 AliAnalysisDataContainer *cout_event = mgr->CreateContainer("eventCounters", AliCounterCollection::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
0ffd1c5a 49 AliAnalysisDataContainer *cout_histo2 = mgr->CreateContainer("histos2", TObjArray::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
50 AliAnalysisDataContainer *cout_pair = mgr->CreateContainer("pairCounters", AliCounterCollection::Class(), AliAnalysisManager::kOutputContainer, outputfile.Data());
fa97374c 51 mgr->ConnectOutput(task, 1, cout_histo);
52 mgr->ConnectOutput(task, 2, cout_track);
53 mgr->ConnectOutput(task, 3, cout_fakeTrack);
54 mgr->ConnectOutput(task, 4, cout_matchTrack);
55 mgr->ConnectOutput(task, 5, cout_event);
0ffd1c5a 56 mgr->ConnectOutput(task, 6, cout_histo2);
57 mgr->ConnectOutput(task, 7, cout_pair);
fa97374c 58
59 return task;
60}
61