adding flag for non-field data
[u/mrichter/AliRoot.git] / PWG0 / dNdEta / run.C
CommitLineData
7a1ac44b 1void Load(const char* taskName, Bool_t debug)
2{
3 TString compileTaskName;
51f6de65 4 compileTaskName.Form("%s.cxx++", taskName);
7a1ac44b 5 if (debug)
51f6de65 6 compileTaskName += "g";
7a1ac44b 7
8 if (gProof) {
9 gProof->Load(compileTaskName);
10 } else
11 gROOT->Macro(compileTaskName);
12
13 // Enable debug printouts
14 if (debug)
15 {
16 AliLog::SetClassDebugLevel(taskName, AliLog::kDebug+2);
17 }
18 else
19 AliLog::SetClassDebugLevel(taskName, AliLog::kWarning);
20}
21
745d6088 22void run(Int_t runWhat, const Char_t* data, Int_t nRuns=20, Int_t offset=0, Bool_t aDebug = kFALSE, Int_t aProof = kFALSE, Bool_t mc = kTRUE, const char* option = "")
0f67a57c 23{
0fc41645 24 // runWhat options: 0 = AlidNdEtaTask
25 // 1 = AlidNdEtaCorrectionTask
7a1ac44b 26 // 2 = both
0fc41645 27 //
28 // aProof option: 0 no proof
29 // 1 proof with chain
30 // 2 proof with dataset
a7f69e56 31 //
32 // option is passed to the task(s)
33 // option SAVE is removed and results in moving the output files to maps/<ds name>/<trigger>/<det>
34 //
69b09e3b 35
0fc41645 36 TString taskName;
7a1ac44b 37 if (runWhat == 0 || runWhat == 2)
0fc41645 38 {
7a1ac44b 39 Printf("Running AlidNdEtaTask");
0fc41645 40 }
7a1ac44b 41 if (runWhat == 1 || runWhat == 2)
0fc41645 42 {
7a1ac44b 43 Printf("Running AlidNdEtaCorrectionTask");
0fc41645 44 if (!mc)
45 {
7a1ac44b 46 Printf("AlidNdEtaCorrectionTask needs MC. Exiting...");
0fc41645 47 return;
48 }
49 }
0fc41645 50
51 if (nRuns < 0)
52 nRuns = 1234567890;
53
0f67a57c 54 if (aProof)
55 {
a7f69e56 56 TProof::Open("alicecaf");
0fc41645 57 //gProof->SetParallel(1);
0f67a57c 58
59 // Enable the needed package
567160d6 60 if (1)
61 {
62 gProof->UploadPackage("$ALICE_ROOT/STEERBase");
63 gProof->EnablePackage("$ALICE_ROOT/STEERBase");
64 gProof->UploadPackage("$ALICE_ROOT/ESD");
65 gProof->EnablePackage("$ALICE_ROOT/ESD");
66 gProof->UploadPackage("$ALICE_ROOT/AOD");
67 gProof->EnablePackage("$ALICE_ROOT/AOD");
68 gProof->UploadPackage("$ALICE_ROOT/ANALYSIS");
69 gProof->EnablePackage("$ALICE_ROOT/ANALYSIS");
70 gProof->UploadPackage("$ALICE_ROOT/ANALYSISalice");
71 gProof->EnablePackage("$ALICE_ROOT/ANALYSISalice");
72 }
73 else
74 {
a7f69e56 75 gProof->UploadPackage("/afs/cern.ch/alice/caf/sw/ALICE/PARs/v4-17-Release/AF-v4-17");
76 gProof->EnablePackage("AF-v4-17");
567160d6 77 }
0fc41645 78
79 gProof->UploadPackage("$ALICE_ROOT/PWG0base");
80 gProof->EnablePackage("$ALICE_ROOT/PWG0base");
0f67a57c 81 }
82 else
83 {
69b09e3b 84 gSystem->AddIncludePath("-I${ALICE_ROOT}/include/ -I${ALICE_ROOT}/PWG0/ -I${ALICE_ROOT}/PWG0/dNdEta/");
0f67a57c 85 gSystem->Load("libVMC");
86 gSystem->Load("libTree");
69b09e3b 87 gSystem->Load("libProof");
0f67a57c 88 gSystem->Load("libSTEERBase");
89 gSystem->Load("libESD");
1c15d51a 90 gSystem->Load("libAOD");
0f67a57c 91 gSystem->Load("libANALYSIS");
745d6088 92 gSystem->Load("libANALYSISalice");
0f67a57c 93 gSystem->Load("libPWG0base");
94 }
95
0f67a57c 96 // Create the analysis manager
97 mgr = new AliAnalysisManager;
98
861795a8 99 // Add ESD handler
100 AliESDInputHandler* esdH = new AliESDInputHandler;
101 esdH->SetInactiveBranches("AliESDACORDE FMD ALIESDTZERO ALIESDVZERO ALIESDZDC AliRawDataErrorLogs CaloClusters Cascades EMCALCells EMCALTrigger ESDfriend Kinks Kinks Cascades AliESDTZERO ALIESDACORDE MuonTracks TrdTracks CaloClusters");
102 mgr->SetInputEventHandler(esdH);
103
a7f69e56 104 AliPWG0Helper::AnalysisMode analysisMode = AliPWG0Helper::kTPC | AliPWG0Helper::kFieldOn;
5a6310fe 105 AliPWG0Helper::Trigger trigger = AliPWG0Helper::kMB1;
0fc41645 106
107 AliPWG0Helper::PrintConf(analysisMode, trigger);
770a1f1d 108
0fc41645 109 AliESDtrackCuts* esdTrackCuts = 0;
a7f69e56 110 if (!(analysisMode & AliPWG0Helper::kSPD))
770a1f1d 111 {
112 // selection of esd tracks
113 gROOT->ProcessLine(".L ../CreateStandardCuts.C");
0fc41645 114 esdTrackCuts = CreateTrackCuts(analysisMode);
770a1f1d 115 if (!esdTrackCuts)
116 {
117 printf("ERROR: esdTrackCuts could not be created\n");
118 return;
119 }
1c15d51a 120 esdTrackCuts->SetHistogramsOn(kTRUE);
0fc41645 121 }
122
a7f69e56 123 cInput = mgr->GetCommonInputContainer();
124
125 // remove SAVE option if set
126 Bool_t save = kFALSE;
127 TString optStr(option);
128 if (optStr.Contains("SAVE"))
129 {
130 optStr = optStr(0,optStr.Index("SAVE")) + optStr(optStr.Index("SAVE")+4, optStr.Length());
131 save = kTRUE;
132 }
133
7a1ac44b 134 // Create, add task
135 if (runWhat == 0 || runWhat == 2)
0fc41645 136 {
7a1ac44b 137 Load("AlidNdEtaTask", aDebug);
a7f69e56 138 task = new AlidNdEtaTask(optStr);
770a1f1d 139
0fc41645 140 if (mc)
141 task->SetReadMC();
142
51f6de65 143 // syst. error flags
0fc41645 144 //task->SetUseMCVertex();
145 //task->SetUseMCKine();
7a1ac44b 146 //task->SetOnlyPrimaries();
69b09e3b 147 //task->SetFillPhi();
148
7a1ac44b 149 task->SetTrigger(trigger);
150 task->SetAnalysisMode(analysisMode);
151 task->SetTrackCuts(esdTrackCuts);
a7f69e56 152 //task->SetDeltaPhiCut(0.05);
7a1ac44b 153
154 mgr->AddTask(task);
51f6de65 155
7a1ac44b 156 // Attach input
157 mgr->ConnectInput(task, 0, cInput);
158
159 // Attach output
160 cOutput = mgr->CreateContainer("cOutput", TList::Class(), AliAnalysisManager::kOutputContainer);
161 mgr->ConnectOutput(task, 0, cOutput);
770a1f1d 162 }
7a1ac44b 163 if (runWhat == 1 || runWhat == 2)
0fc41645 164 {
7a1ac44b 165 Load("AlidNdEtaCorrectionTask", aDebug);
a7f69e56 166 task2 = new AlidNdEtaCorrectionTask(optStr);
51f6de65 167
168 // syst. error flags
69b09e3b 169 //task2->SetFillPhi();
7a1ac44b 170 //task2->SetOnlyPrimaries();
171
172 task2->SetTrigger(trigger);
173 task2->SetAnalysisMode(analysisMode);
174 task2->SetTrackCuts(esdTrackCuts);
69b09e3b 175 //task2->SetDeltaPhiCut(0.05);
7a1ac44b 176
177 mgr->AddTask(task2);
51f6de65 178
7a1ac44b 179 // Attach input
180 mgr->ConnectInput(task2, 0, cInput);
51f6de65 181
7a1ac44b 182 // Attach output
183 cOutput = mgr->CreateContainer("cOutput2", TList::Class(), AliAnalysisManager::kOutputContainer);
184 mgr->ConnectOutput(task2, 0, cOutput);
0fc41645 185 }
0f67a57c 186
0f67a57c 187 if (mc) {
188 // Enable MC event handler
189 AliMCEventHandler* handler = new AliMCEventHandler;
190 handler->SetReadTR(kFALSE);
191 mgr->SetMCtruthEventHandler(handler);
192 }
193
0f67a57c 194 // Enable debug printouts
195 if (aDebug)
196 mgr->SetDebugLevel(2);
197
198 // Run analysis
199 mgr->InitAnalysis();
200 mgr->PrintStatus();
201
0fc41645 202 if (aProof == 2)
203 {
204 // process dataset
205
206 mgr->StartAnalysis("proof", data, nRuns, offset);
a7f69e56 207
208 if (save)
209 {
210 TString path("maps/");
211 path += TString(data).Tokenize("/")->Last()->GetName();
212
213 switch (trigger)
214 {
215 case AliPWG0Helper::kMB1:
216 case AliPWG0Helper::kOfflineMB1: path += "/mb1"; break;
217 case AliPWG0Helper::kMB2:
218 case AliPWG0Helper::kOfflineMB2: path += "/mb2"; break;
219 case AliPWG0Helper::kMB3:
220 case AliPWG0Helper::kOfflineMB3: path += "/mb3"; break;
221 case AliPWG0Helper::kFASTOR:
222 case AliPWG0Helper::kOfflineFASTOR: path += "/fastor"; break;
223 default: Printf("ERROR: Trigger undefined for path to files"); return;
224 }
225
226 if (analysisMode & AliPWG0Helper::kSPD)
227 path += "/spd";
228
229 if (analysisMode & AliPWG0Helper::kTPC)
230 path += "/tpc";
231
232 gSystem->mkdir(path, kTRUE);
233 if (runWhat == 0 || runWhat == 2)
234 gSystem->Rename("analysis_esd_raw.root", path + "/analysis_esd_raw.root");
235 if (runWhat == 1 || runWhat == 2)
236 {
237 gSystem->Rename("analysis_mc.root", path + "/analysis_mc.root");
238 gSystem->Rename("correction_map.root", path + "/correction_map.root");
239 }
240
241 Printf(">>>>> Moved files to %s", path.Data());
242 }
0fc41645 243 }
51f6de65 244 else if (aProof == 3)
245 {
69b09e3b 246 gROOT->ProcessLine(".L CreateChainFromDataSet.C");
247 ds = gProof->GetDataSet(data)->GetStagedSubset();
51f6de65 248 chain = CreateChainFromDataSet(ds);
249 mgr->StartAnalysis("local", chain, nRuns, offset);
250 }
0fc41645 251 else
252 {
253 // Create chain of input files
254 gROOT->LoadMacro("../CreateESDChain.C");
51f6de65 255
0fc41645 256 chain = CreateESDChain(data, nRuns, offset);
1c15d51a 257 //chain = CreateChain("TE", data, nRuns, offset);
0fc41645 258
259 mgr->StartAnalysis((aProof > 0) ? "proof" : "local", chain);
260 }
0f67a57c 261}
dd367a14 262