]>
Commit | Line | Data |
---|---|---|
a23f7c97 | 1 | // TODO: |
2 | // 1. Check cuts for 2010 (Jochen?) | |
54b31d6a | 3 | // 2. Run with many centrality bins at once |
e0376287 | 4 | #include <string.h> |
a23f7c97 | 5 | |
e0376287 | 6 | enum { kMyRunModeLocal = 0, kMyRunModeCAF, kMyRunModeGRID}; |
7 | ||
8 | TList * listToLoad = new TList(); | |
a23f7c97 | 9 | |
10 | TChain * GetAnalysisChain(const char * incollection); | |
11 | ||
eef42d18 | 12 | void run(Char_t* data, Long64_t nev = -1, Long64_t offset = 0, Bool_t debug = kFALSE, Int_t runMode = 0, Bool_t isMC = 0, |
3b8cbf2d | 13 | Int_t centrBin = 0, const char * centrEstimator = "VOM", Int_t useOtherCentralityCut = 0, Int_t trackMin=0, Int_t trackMax=10000, |
bcf2601a | 14 | const char* option = "",TString customSuffix = "", Int_t workers = -1, Bool_t useSingleBin=kTRUE) |
a23f7c97 | 15 | { |
16 | // runMode: | |
17 | // | |
18 | // 0 local | |
19 | // 1 proof | |
20 | ||
21 | if (nev < 0) | |
22 | nev = 1234567890; | |
23 | ||
24 | InitAndLoadLibs(runMode,workers,debug); | |
25 | ||
26 | // Create the analysis manager | |
27 | mgr = new AliAnalysisManager; | |
28 | ||
29 | // Add ESD handler | |
30 | AliESDInputHandler* esdH = new AliESDInputHandler; | |
31 | // Do I need any of this? | |
eef42d18 | 32 | esdH->SetInactiveBranches("AliESDACORDE FMD ALIESDTZERO ALIESDZDC AliRawDataErrorLogs CaloClusters Cascades EMCALCells EMCALTrigger ESDfriend Kinks AliESDTZERO ALIESDACORDE MuonTracks TrdTracks"); |
a23f7c97 | 33 | mgr->SetInputEventHandler(esdH); |
34 | ||
35 | if(isMC) { | |
36 | AliMCEventHandler* handler = new AliMCEventHandler; | |
b00e8ba9 | 37 | handler->SetPreReadMode(AliMCEventHandler::kLmPreRead); |
a23f7c97 | 38 | mgr->SetMCtruthEventHandler(handler); |
39 | } | |
40 | ||
e0376287 | 41 | |
42 | // If we are running on grid, we need the alien handler | |
43 | if (runMode == kMyRunModeGRID) { | |
44 | // Create and configure the alien handler plugin | |
45 | gROOT->LoadMacro("CreateAlienHandler.C"); | |
8b7362ee | 46 | AliAnalysisGrid *alienHandler = CreateAlienHandler(data, listToLoad, "full", isMC); |
e0376287 | 47 | if (!alienHandler) { |
48 | cout << "Cannot create alien handler" << endl; | |
49 | exit(1); | |
50 | } | |
51 | mgr->SetGridHandler(alienHandler); | |
52 | } | |
53 | ||
54 | ||
55 | ||
a23f7c97 | 56 | // physics selection |
57 | gROOT->ProcessLine(".L $ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); | |
e9c445f5 | 58 | physicsSelectionTask = AddTaskPhysicsSelection(isMC); |
8b628a20 | 59 | |
54b31d6a | 60 | // Centrality |
61 | AliCentralitySelectionTask *taskCentr = new AliCentralitySelectionTask("CentralitySelection"); | |
3b8cbf2d | 62 | const char * file1 = "$ALICE_ROOT/ANALYSIS/macros/test_AliCentralityBy1D.root"; |
63 | const char * file2 = "$ALICE_ROOT/ANALYSIS/macros/test_AliCentralityByFunction.root"; | |
64 | // const char * file1 = "$ALICE_ROOT/ANALYSIS/macros/AliCentralityBy1D_LHC10g2a_100.root"; | |
65 | // const char * file2 = "$ALICE_ROOT/ANALYSIS/macros/AliCentralityByFunction_LHC10g2a_100.root"; | |
66 | // const char * file1 = "$ALICE_ROOT/ANALYSIS/macros/AliCentralityBy1D_137161_GLAU.root"; | |
7f5f2e0c | 67 | // const char * file2 = "$ALICE_ROOT/ANALYSIS/macros/test_AliCentralityByFunction.root"; |
3b8cbf2d | 68 | |
9ef42f6c | 69 | // taskCentr->SetPercentileFile (file1); |
70 | // taskCentr->SetPercentileFile2(file2); | |
9441cdaa | 71 | //FIXME: include back centrality estimator |
3b8cbf2d | 72 | // mgr->AddTask(taskCentr); |
73 | // mgr->ConnectInput (taskCentr,0, mgr->GetCommonInputContainer()); | |
a23f7c97 | 74 | |
2bbfd8c6 | 75 | // Create my own centrality selector |
76 | AliAnalysisMultPbCentralitySelector * centrSelector = new AliAnalysisMultPbCentralitySelector(); | |
bfae2924 | 77 | centrSelector->SetIsMC(isMC); |
8b628a20 | 78 | centrSelector->SetCentrTaskFiles(file1,file2); // for bookkeping only |
2bbfd8c6 | 79 | centrSelector->SetCentralityBin(centrBin); |
bcf2601a | 80 | if (!useSingleBin) centrSelector->SetCentralityBin(0); // FIXME: ok? |
2bbfd8c6 | 81 | centrSelector->SetCentralityEstimator(centrEstimator); |
eef42d18 | 82 | |
3b8cbf2d | 83 | |
84 | if(useOtherCentralityCut == 1){ | |
9441cdaa | 85 | cout << "Setting centrality by MULT" << endl; |
eef42d18 | 86 | centrSelector->SetUseMultRange(); |
87 | centrSelector->SetMultRange(trackMin,trackMax); | |
88 | } | |
3b8cbf2d | 89 | if(useOtherCentralityCut == 2){ |
9441cdaa | 90 | cout << "Setting centrality by V0" << endl; |
3b8cbf2d | 91 | |
92 | centrSelector->SetUseV0Range(); | |
93 | centrSelector->SetMultRange(trackMin,trackMax); | |
94 | } | |
72491d7c | 95 | if(useOtherCentralityCut == 3){ |
9441cdaa | 96 | cout << "Setting centrality by SPD outer" << endl; |
72491d7c | 97 | centrSelector->SetUseSPDOuterRange(); |
98 | centrSelector->SetMultRange(trackMin,trackMax); | |
99 | } | |
a23f7c97 | 100 | |
101 | // Parse option strings | |
102 | TString optionStr(option); | |
103 | ||
104 | // remove SAVE option if set | |
105 | // This is copied from a macro by Jan. The reason I kept it is that I may want to pass textual options to the new task at some point | |
106 | Bool_t doSave = kFALSE; | |
107 | TString optionStr(option); | |
108 | if (optionStr.Contains("SAVE")) | |
bcf2601a | 109 | { |
110 | optionStr = optionStr(0,optionStr.Index("SAVE")) + optionStr(optionStr.Index("SAVE")+4, optionStr.Length()); | |
111 | doSave = kTRUE; | |
112 | } | |
a23f7c97 | 113 | |
bcf2601a | 114 | AliESDtrackCuts * cuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kFALSE); |
115 | TString pathsuffix = ""; | |
116 | ||
117 | if(!useSingleBin) pathsuffix += "_AllCentr"; | |
a23f7c97 | 118 | |
9441cdaa | 119 | if (optionStr.Contains("DCA")) { |
120 | delete cuts; | |
9ef42f6c | 121 | // cuts = AliESDtrackCuts::GetStandardITSPureSATrackCuts2009(); |
9441cdaa | 122 | cout << ">>>> USING DCA cut" << endl; |
9ef42f6c | 123 | cuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kFALSE); |
bcc49144 | 124 | pathsuffix+="_DCAcut"; |
9441cdaa | 125 | } |
126 | ||
a23f7c97 | 127 | if (optionStr.Contains("ITSsa")) { |
128 | delete cuts; | |
129 | cuts = AliESDtrackCuts::GetStandardITSPureSATrackCuts2009(); | |
130 | cout << ">>>> USING ITS sa tracks" << endl; | |
bcc49144 | 131 | pathsuffix+="_ITSsa"; |
a23f7c97 | 132 | } |
133 | ||
134 | if (optionStr.Contains("TPC")) { | |
135 | delete cuts; | |
136 | cuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); | |
137 | cout << ">>>> USING TPC only tracks" << endl; | |
bcc49144 | 138 | pathsuffix+="_TPC"; |
a23f7c97 | 139 | } |
54b31d6a | 140 | |
141 | Bool_t useMCKinematics = isMC; | |
142 | if (optionStr.Contains("NOMCKIN")) { | |
143 | cout << ">>>> Ignoring MC kinematics" << endl; | |
144 | useMCKinematics=kFALSE; | |
bcc49144 | 145 | pathsuffix+="_NOMCKIN"; |
54b31d6a | 146 | } |
a23f7c97 | 147 | |
9ef42f6c | 148 | AliLog::SetClassDebugLevel("AliESDtrackCuts", AliLog::kDebug);// FIXME |
149 | cuts->DefineHistograms(); | |
a23f7c97 | 150 | |
151 | // load my task | |
bcf2601a | 152 | if (useSingleBin) { |
153 | gROOT->ProcessLine(".L $ALICE_ROOT/PWG0/multPbPb/AddTaskMultPbPbTracks.C"); | |
154 | AliAnalysisTaskMultPbTracks * task = AddTaskMultPbPbTracks("multPbPbtracks.root", cuts, centrSelector); | |
155 | task->SetIsMC(useMCKinematics); | |
156 | task->SetOfflineTrigger(AliVEvent::kMB); | |
157 | if(optionStr.Contains("TPC")) task->SetTPCOnly(); | |
158 | if(useMCKinematics) task->GetHistoManager()->SetSuffix("MC"); | |
159 | if(customSuffix!=""){ | |
160 | cout << "Setting custom suffix: " << customSuffix << endl; | |
161 | task->GetHistoManager()->SetSuffix(customSuffix); | |
162 | } | |
163 | } else { | |
164 | gROOT->ProcessLine(".L $ALICE_ROOT/PWG0/multPbPb/AddTaskMultPbPbTracksAllCentrality.C"); | |
165 | centrSelector->SetUseV0Range(kTRUE); | |
166 | Int_t ncentr = 11; | |
abd808b9 | 167 | |
168 | const Float_t minCentr[] = {0 ,79 ,239,559 ,1165,2135,3555,5525,8213 ,12191,15079}; | |
169 | const Float_t maxCentr[] = {79,239,559,1165,2135,3555,5525,8213,12191,15079,21000}; | |
bcf2601a | 170 | AliAnalysisTaskMultPbTracks ** tasks = AddTaskMultPbPbTracksAllCentrality("multPbPbtracks.root", cuts, centrSelector, ncentr,minCentr,maxCentr); |
171 | for(Int_t icentr = 0; icentr < ncentr; icentr++){ | |
bcf2601a | 172 | tasks[icentr]->Print(); |
e9c445f5 | 173 | cout << "MC KINEMATICS:" << useMCKinematics << endl; |
174 | ||
bcf2601a | 175 | tasks[icentr]->SetIsMC(useMCKinematics); |
bcf2601a | 176 | tasks[icentr]->SetOfflineTrigger(AliVEvent::kMB); |
bcf2601a | 177 | if(optionStr.Contains("TPC")) tasks[icentr]->SetTPCOnly(); |
bcf2601a | 178 | if(useMCKinematics) tasks[icentr]->GetHistoManager()->SetSuffix("MC"); |
bcf2601a | 179 | if(customSuffix!=""){ |
e9c445f5 | 180 | cout << "Setting custom suffix: " << customSuffix+long(icentr) << endl; |
bcf2601a | 181 | tasks[icentr]->GetHistoManager()->SetSuffix(customSuffix+long(icentr)); |
bcf2601a | 182 | } |
183 | } | |
e0376287 | 184 | } |
bcf2601a | 185 | // Init and run the analy |
a23f7c97 | 186 | if (!mgr->InitAnalysis()) return; |
bcf2601a | 187 | |
a23f7c97 | 188 | mgr->PrintStatus(); |
189 | ||
190 | if (runMode == kMyRunModeLocal ) { | |
191 | // If running in local mode, create chain of ESD files | |
54b31d6a | 192 | cout << "RUNNING LOCAL, CHAIN" << endl; |
a23f7c97 | 193 | TChain * chain = GetAnalysisChain(data); |
5ec1c2f5 | 194 | // chain->Print(); |
a23f7c97 | 195 | mgr->StartAnalysis("local",chain,nev); |
196 | } else if (runMode == kMyRunModeCAF) { | |
197 | mgr->StartAnalysis("proof",TString(data)+"#esdTree",nev); | |
e0376287 | 198 | } else if (runMode == kMyRunModeGRID) { |
199 | mgr->StartAnalysis("grid"); | |
a23f7c97 | 200 | } else { |
201 | cout << "ERROR: unknown run mode" << endl; | |
202 | } | |
203 | ||
3b8cbf2d | 204 | if (!useOtherCentralityCut) { |
eef42d18 | 205 | pathsuffix = pathsuffix + "_" + centrEstimator + "_bin_"+long(centrBin); |
3b8cbf2d | 206 | } else if(useOtherCentralityCut==1){ |
eef42d18 | 207 | pathsuffix = pathsuffix + "_TrackRange_" + long(trackMin) + "_" + long(trackMax); |
3b8cbf2d | 208 | } else if(useOtherCentralityCut==2){ |
209 | pathsuffix = pathsuffix + "_V0Range_" + long(trackMin) + "_" + long(trackMax); | |
72491d7c | 210 | } else if(useOtherCentralityCut==3){ |
211 | pathsuffix = pathsuffix + "_SPDOutRange_" + long(trackMin) + "_" + long(trackMax); | |
eef42d18 | 212 | } |
7f5f2e0c | 213 | pathsuffix += customSuffix; |
214 | ||
a23f7c97 | 215 | if (doSave) MoveOutput(data, pathsuffix.Data()); |
216 | ||
9ef42f6c | 217 | // FIXME |
218 | TFile * f = new TFile("cuts.root", "recreate"); | |
219 | cuts->SaveHistograms(); | |
220 | f->Close(); | |
a23f7c97 | 221 | |
222 | } | |
223 | ||
224 | ||
225 | void MoveOutput(const char * data, const char * suffix = ""){ | |
226 | ||
227 | TString path("output/"); | |
228 | path = path + TString(data).Tokenize("/")->Last()->GetName() + suffix; | |
229 | ||
230 | TString fileName = "multPbPbtracks.root"; | |
231 | gSystem->mkdir(path, kTRUE); | |
232 | gSystem->Rename(fileName, path + "/" + fileName); | |
bcf2601a | 233 | for(Int_t ibin = 0; ibin < 20; ibin++){ |
234 | TString fileBin = fileName; | |
235 | fileBin.ReplaceAll(".root",Form("_%2.2d.root",ibin)); | |
236 | gSystem->Rename(fileBin, path + "/" + fileBin); | |
237 | } | |
238 | ||
a23f7c97 | 239 | gSystem->Rename("event_stat.root", path + "/event_stat.root"); |
240 | Printf(">>>>> Moved files to %s", path.Data()); | |
241 | } | |
242 | ||
243 | ||
244 | ||
245 | TChain * GetAnalysisChain(const char * incollection){ | |
246 | // Builds a chain of esd files | |
247 | // incollection can be | |
248 | // - a single root file | |
249 | // - an xml collection of files on alien | |
250 | // - a ASCII containing a list of local root files | |
251 | TChain* analysisChain = 0; | |
252 | // chain | |
253 | analysisChain = new TChain("esdTree"); | |
254 | if (TString(incollection).Contains(".root")){ | |
255 | analysisChain->Add(incollection); | |
256 | } | |
257 | else if (TString(incollection).Contains("xml")){ | |
258 | TGrid::Connect("alien://"); | |
259 | TAlienCollection * coll = TAlienCollection::Open (incollection); | |
260 | while(coll->Next()){ | |
261 | analysisChain->Add(TString("alien://")+coll->GetLFN()); | |
262 | } | |
263 | } else { | |
264 | ifstream file_collect(incollection); | |
265 | TString line; | |
266 | while (line.ReadLine(file_collect) ) { | |
267 | analysisChain->Add(line.Data()); | |
268 | } | |
269 | } | |
270 | analysisChain->GetListOfFiles()->Print(); | |
271 | ||
272 | return analysisChain; | |
273 | } | |
274 | ||
275 | ||
276 | void InitAndLoadLibs(Int_t runMode=kMyRunModeLocal, Int_t workers=0,Bool_t debug=0) { | |
e0376287 | 277 | // Loads libs and par files + custom task and classes |
278 | ||
279 | // Custom stuff to be loaded | |
280 | listToLoad->Add(new TObjString("$ALICE_ROOT/ANALYSIS/AliCentralitySelectionTask.cxx+")); | |
281 | listToLoad->Add(new TObjString("$ALICE_ROOT/PWG1/background/AliHistoListWrapper.cxx+")); | |
282 | listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisMultPbTrackHistoManager.cxx+")); | |
2bbfd8c6 | 283 | listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisMultPbCentralitySelector.cxx+")); |
e0376287 | 284 | listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisTaskMultPbTracks.cxx+")); |
285 | ||
a23f7c97 | 286 | |
287 | if (runMode == kMyRunModeCAF) | |
bcf2601a | 288 | { |
289 | cout << "Init in CAF mode" << endl; | |
a23f7c97 | 290 | |
91ea438c | 291 | //gEnv->SetValue("XSec.GSI.DelegProxy", "2"); |
f07573a6 | 292 | TProof * p = TProof::Open("alice-caf.cern.ch", workers>0 ? Form("workers=%d",workers) : ""); |
293 | // TProof * p = TProof::Open("skaf.saske.sk", workers>0 ? Form("workers=%d",workers) : ""); | |
bcf2601a | 294 | p->Exec("TObject *o = gEnv->GetTable()->FindObject(\"Proof.UseMergers\"); gEnv->GetTable()->Remove(o);", kTRUE); |
295 | ||
9ef42f6c | 296 | // gProof->EnablePackage("VO_ALICE@AliRoot::v4-21-17b-AN"); |
297 | // gSystem->Load("libCore.so"); | |
298 | // gSystem->Load("libTree.so"); | |
299 | // gSystem->Load("libGeom.so"); | |
300 | // gSystem->Load("libVMC.so"); | |
301 | // gSystem->Load("libPhysics.so"); | |
302 | // gSystem->Load("libSTEERBase"); | |
303 | // gSystem->Load("libESD"); | |
304 | // gSystem->Load("libAOD"); | |
305 | // gSystem->Load("libANALYSIS"); | |
306 | // gSystem->Load("libOADB"); | |
307 | // gSystem->Load("libANALYSISalice"); | |
308 | ||
bcf2601a | 309 | // Enable the needed package |
9ef42f6c | 310 | gProof->UploadPackage("$ALICE_ROOT/obj/STEERBase"); |
311 | gProof->EnablePackage("$ALICE_ROOT/obj/STEERBase"); | |
312 | gProof->UploadPackage("$ALICE_ROOT/obj/ESD"); | |
313 | gProof->EnablePackage("$ALICE_ROOT/obj/ESD"); | |
314 | gProof->UploadPackage("$ALICE_ROOT/obj/AOD"); | |
315 | gProof->EnablePackage("$ALICE_ROOT/obj/AOD"); | |
316 | gProof->UploadPackage("$ALICE_ROOT/obj/ANALYSIS"); | |
317 | gProof->EnablePackage("$ALICE_ROOT/obj/ANALYSIS"); | |
318 | gProof->UploadPackage("$ALICE_ROOT/obj/OADB"); | |
319 | gProof->EnablePackage("$ALICE_ROOT/obj/OADB"); | |
320 | gProof->UploadPackage("$ALICE_ROOT/obj/ANALYSISalice"); | |
321 | gProof->EnablePackage("$ALICE_ROOT/obj/ANALYSISalice"); | |
322 | gProof->UploadPackage("$ALICE_ROOT/obj/PWG0base"); | |
323 | gProof->EnablePackage("$ALICE_ROOT/obj/PWG0base"); | |
bcf2601a | 324 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG0/multPb")); |
325 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background")); | |
326 | } | |
a23f7c97 | 327 | else |
bcf2601a | 328 | { |
329 | cout << "Init in Local or Grid mode" << endl; | |
330 | gSystem->Load("libCore.so"); | |
331 | gSystem->Load("libTree.so"); | |
332 | gSystem->Load("libGeom.so"); | |
333 | gSystem->Load("libVMC.so"); | |
334 | gSystem->Load("libPhysics.so"); | |
335 | gSystem->Load("libSTEERBase"); | |
336 | gSystem->Load("libESD"); | |
337 | gSystem->Load("libAOD"); | |
338 | gSystem->Load("libANALYSIS"); | |
9ef42f6c | 339 | gSystem->Load("libOADB"); |
bcf2601a | 340 | gSystem->Load("libANALYSISalice"); |
341 | // Use AliRoot includes to compile our task | |
342 | gROOT->ProcessLine(".include $ALICE_ROOT/include"); | |
343 | ||
344 | // gSystem->Load("libVMC"); | |
345 | // gSystem->Load("libTree"); | |
346 | // gSystem->Load("libSTEERBase"); | |
347 | // gSystem->Load("libESD"); | |
348 | // gSystem->Load("libAOD"); | |
349 | // gSystem->Load("libANALYSIS"); | |
350 | // gSystem->Load("libANALYSISalice"); | |
351 | // gSystem->Load("libPWG0base"); | |
a23f7c97 | 352 | |
bcf2601a | 353 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG0/multPb")); |
354 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background")); | |
355 | // gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background/")); | |
356 | } | |
a23f7c97 | 357 | // Load helper classes |
e0376287 | 358 | TIterator * iter = listToLoad->MakeIterator(); |
359 | TObjString * name = 0; | |
360 | while (name = (TObjString *)iter->Next()) { | |
361 | gSystem->ExpandPathName(name->String()); | |
362 | cout << name->String().Data(); | |
363 | if (runMode == kMyRunModeCAF) { | |
364 | gProof->Load(name->String()+(debug?"+g":"")); | |
365 | } else { | |
366 | gROOT->LoadMacro(name->String()+(debug?"+g":"")); | |
367 | } | |
a23f7c97 | 368 | } |
369 | ||
a23f7c97 | 370 | } |