Moving PbPb multiplicity in the new directory structure
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / ChargedHadrons / multPbPb / AddTaskMultPbPbTracks.C
1 AliAnalysisTaskMultPbTracks * AddTaskMultPbPbTracks(const char * outfilename, AliESDtrackCuts * esdTrackCuts = 0, AliAnalysisMultPbCentralitySelector * centr)
2 {
3   // TODO: add some parameters to set the centrality for this task, and maybe the name of the task
4   // TODO: shall I use the same file and different dirs for the different centralities?
5
6   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
7   if (!mgr) {
8     ::Error("AddTaskPhysicsSelection", "No analysis manager to connect to.");
9     return NULL;
10   }  
11   
12   // Check the analysis type using the event handlers connected to the analysis manager.
13   //==============================================================================
14   if (!mgr->GetInputEventHandler()) {
15     ::Error("AddTaskPhysicsSelection", "This task requires an input event handler");
16     return NULL;
17   }
18   TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
19   
20   if (inputDataType != "ESD") {
21     Printf("ERROR! This task can only run on ESDs!");
22   }
23
24   // Configure analysis
25   //===========================================================================
26     
27     
28
29   AliAnalysisTaskMultPbTracks *task = new AliAnalysisTaskMultPbTracks("TaskMultPbTracks");
30   mgr->AddTask(task);
31   
32   // Set Cuts
33   if (!esdTrackCuts)
34     {
35       printf("ERROR: esdTrackCuts could not be created\n");
36       return;
37     }  
38   task->SetTrackCuts(esdTrackCuts);
39
40   // set centrality
41   task->SetCentralitySelector(centr);
42
43   // TODO:
44   // IO into folders in a file?
45
46   // Set I/O
47   AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer();
48   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("cmultPbTracksOutHM",
49                                                             AliAnalysisMultPbTrackHistoManager::Class(),
50                                                             AliAnalysisManager::kOutputContainer,
51                                                             outfilename);
52   AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("cmultPbTracksOutCT",
53                                                             AliESDtrackCuts::Class(),
54                                                             AliAnalysisManager::kOutputContainer,
55                                                             outfilename);
56   AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("cmultPbTracksOutCM",
57                                                             AliAnalysisMultPbCentralitySelector::Class(),
58                                                             AliAnalysisManager::kOutputContainer,
59                                                             outfilename);
60
61   mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
62   mgr->ConnectOutput(task,1,coutput1);
63   mgr->ConnectOutput(task,2,coutput2);
64   mgr->ConnectOutput(task,3,coutput3);
65
66   return task;
67 }