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