]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/Correlations/DPhi/FourierDecomposition/lrc/RunDhcTask.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGCF / Correlations / DPhi / FourierDecomposition / lrc / RunDhcTask.C
CommitLineData
ac9dcd4b 1// Macro to run AliDhcTask - A. Adare, Mar 2012
48a61f36 2// Choose dataType = "esd" or "aod".
3// Choose runMode = "local", "proof", "grid", or "terminate".
4// Choose proofCluster = "skaf.saske.sk" or "alice-caf.cern.ch".
5// When running on proof: use root, not aliroot.
6
7Int_t verbosity = 0;
ac9dcd4b 8Long64_t nEvents = 123456789;
9TString runMode = "local"; // "proof";
48a61f36 10TString dataType = "aod";
11TString localDir = "/Users/adare/esd/alice/data/2010/LHC10h/000139107/ESDs/pass2/";
12TString esdDir = localDir + TString("10000139107001.120/");
13TString aodDir = localDir + TString("AOD049/0008/");
14TString proofDataset = "/alice/data/LHC10h_000137848_p2_AOD049";
ac9dcd4b 15TString proofCluster = "aadare@skaf.saske.sk"; // or "aadare@alice-caf.cern.ch";
16TString alirootVer = "VO_ALICE@AliRoot::v4-21-21-AN"; // for PROOF
48a61f36 17TString libsBase = "Tree:Geom:VMC:STEERBase:ESD:AOD";
ac9dcd4b 18TString libsExtra = "ANALYSIS:ANALYSISalice:PWGCFCorrelationsDPhi";
48a61f36 19TList* libList = new TList();
20TChain* chain = 0;
21
22void RunDhcTask()
23{
24 // Creates the large file memstat_<pid>.root.
25 // Call TMemStat::Show() on the promp to analyze it.
26 if (0)
27 TMemStat mm("gnubuiltin");
28
29 if (runMode=="local")
30 LocalSetup();
31 else if (runMode=="proof") {
32 ProofSetup();
33 }
34
35 AddDhcTask();
36
37 /// --- All set up now...run Analysis! ---
38 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
39 if (!mgr->InitAnalysis())
40 return;
41 if (verbosity > 0)
42 mgr->PrintStatus();
43
44 if (runMode=="local") {
45 mgr->StartAnalysis(runMode.Data(), chain, nEvents);
46 }
47 else if (runMode=="proof") {
48 mgr->StartAnalysis(runMode.Data(), proofDataset.Data(), nEvents);
49 }
50 return;
51}
52
53void LocalSetup()
54{
55 // Load libraries
56 TObjArray* libs = libsExtra.Tokenize(":");
57 for (Int_t i=0; i<libs->GetEntries(); i++) {
58 const char* name = libs->At(i)->GetName();
59 Int_t ret = gSystem->Load(Form("lib%s", name));
60 if (ret > 0)
61 Warning("LocalSetup()", "lib%s already loaded", name);
62 if (ret < 0)
63 Warning("LocalSetup()", "lib%s failed to load", name);
64 }
65
66 // Add headers
67 gSystem->AddIncludePath("-I$ALICE_ROOT/include");
68
69 // Load macros/tasks
70 if (dataType == "esd") {
1c06a186 71 gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskCentrality.C");
48a61f36 72 }
63b6cbd0 73 gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskPhysicsSelection.C");
ac9dcd4b 74 // gROOT->LoadMacro("AliPool.cxx+g");
75 // gROOT->LoadMacro("AliDhcTask.cxx+g");
48a61f36 76
77 // Setup chain
78 TString chainName = dataType.Contains("aod") ? "aodTree" : "esdTree";
79 chain = new TChain(chainName.Data());
80 if (dataType.Contains("aod"))
81 chain->Add(Form("%sAliAOD.root", aodDir.Data()));
82 if (dataType.Contains("esd"))
83 chain->Add(Form("%sAliESDs.root", esdDir.Data()));
84 return;
85}
86
87void ProofSetup()
88{
89 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
90
91 // Get PROOF pointer
92 TProof *proof = gProof;
93 if (proof) {
94 TProof::Reset(proofCluster.Data()); // add kTRUE as a 2nd arg for hard reset
95 // proof->Reset("");
96 cerr << "Trying to reset proof" << endl;
97 } else {
98 proof = TProof::Open(proofCluster.Data(), "workers=60");
99 }
100 if (!proof) {
101 cerr << "Connection to " << proofCluster.Data()
102 << " failed!" << endl;
103 return;
104 }
105
106 if (0) {
107 proof->ShowPackages();
108 proof->ShowDataSets();
109 }
110
111 // Load libraries
112 int ret = 0;
113 libList->Add(new TNamed("ALIROOT_EXTRA_LIBS", libsBase.Data()));
114 libList->Add(new TNamed("ALIROOT_EXTRA_LIBS", libsExtra.Data()));
115
116 ret = proof->EnablePackage(alirootVer.Data(), libList);
117
118 proof->EnablePackage(alirootVer.Data(), 0);
119 if (ret) {
120 Error("ProofSetup()", "Failed to load all libs.");
121 return;
122 }
123
124 // Load macros/tasks
125 if (dataType == "esd") {
126 proof->Load("AddTaskCentrality.C");
127 }
128 proof->Load("AddTaskPhysicsSelection.C");
ac9dcd4b 129 proof->Load("AliPool.cxx+g");
48a61f36 130 proof->Load("AliDhcTask.cxx+g", 0);
131 return;
132}
133
134void AddDhcTask()
135{
136 // Need the following macros loaded beforehand:
1c06a186 137 // "$ALICE_ROOT/OADB/macros/AddTaskCentrality.C" (ESD only)
63b6cbd0 138 // "$ALICE_ROOT/OADB/macros/AddTaskPhysicsSelection.C"
48a61f36 139 // "AliDhcTask.cxx+g"
140
141 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
142 if (!mgr)
143 mgr = new AliAnalysisManager("DhcAnalysis");
144 AliESDInputHandler* esdH = new AliESDInputHandler();
145 AliAODInputHandler* aodH = new AliAODInputHandler();
146
147 if (dataType.Contains("aod"))
148 mgr->SetInputEventHandler(aodH);
149 if (dataType.Contains("esd"))
150 mgr->SetInputEventHandler(esdH);
151
152 if (dataType == "esd") {
153 AliCentralitySelectionTask *centTask = AddTaskCentrality();
154 centTask->SelectCollisionCandidates(AliVEvent::kAny);
155 centTask->SetPass(2);
156 }
157
158 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
159
160 AliDhcTask *dhcTask = new AliDhcTask("DhcTask");
161 dhcTask->SelectCollisionCandidates(AliVEvent::kMB);
162 dhcTask->SetVerbosity(verbosity);
163
164 // Add task(s)
165 mgr->AddTask(dhcTask);
166
167 // Create containers for input/output
168 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
169 AliAnalysisDataContainer *coutput =
170 mgr->CreateContainer("dhclist", TList::Class(),
171 AliAnalysisManager::kOutputContainer,
172 "dhctask_output.root");
173
174 // Connect input/output
175 mgr->ConnectInput(dhcTask, 0, cinput);
176 mgr->ConnectOutput(dhcTask, 1, coutput);
177
178 // Enable debug printouts
179 mgr->SetDebugLevel(verbosity);
180
181 return;
182}
183