]>
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"); | |
eef42d18 | 58 | physicsSelectionTask = AddTaskPhysicsSelection(isMC,0);//FIXME |
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 | |
2bbfd8c6 | 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(); | |
8b628a20 | 77 | centrSelector->SetCentrTaskFiles(file1,file2); // for bookkeping only |
2bbfd8c6 | 78 | centrSelector->SetCentralityBin(centrBin); |
bcf2601a | 79 | if (!useSingleBin) centrSelector->SetCentralityBin(0); // FIXME: ok? |
2bbfd8c6 | 80 | centrSelector->SetCentralityEstimator(centrEstimator); |
eef42d18 | 81 | |
3b8cbf2d | 82 | |
83 | if(useOtherCentralityCut == 1){ | |
9441cdaa | 84 | cout << "Setting centrality by MULT" << endl; |
eef42d18 | 85 | centrSelector->SetUseMultRange(); |
86 | centrSelector->SetMultRange(trackMin,trackMax); | |
87 | } | |
3b8cbf2d | 88 | if(useOtherCentralityCut == 2){ |
9441cdaa | 89 | cout << "Setting centrality by V0" << endl; |
3b8cbf2d | 90 | |
91 | centrSelector->SetUseV0Range(); | |
92 | centrSelector->SetMultRange(trackMin,trackMax); | |
93 | } | |
72491d7c | 94 | if(useOtherCentralityCut == 3){ |
9441cdaa | 95 | cout << "Setting centrality by SPD outer" << endl; |
72491d7c | 96 | centrSelector->SetUseSPDOuterRange(); |
97 | centrSelector->SetMultRange(trackMin,trackMax); | |
98 | } | |
a23f7c97 | 99 | |
100 | // Parse option strings | |
101 | TString optionStr(option); | |
102 | ||
103 | // remove SAVE option if set | |
104 | // 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 | |
105 | Bool_t doSave = kFALSE; | |
106 | TString optionStr(option); | |
107 | if (optionStr.Contains("SAVE")) | |
bcf2601a | 108 | { |
109 | optionStr = optionStr(0,optionStr.Index("SAVE")) + optionStr(optionStr.Index("SAVE")+4, optionStr.Length()); | |
110 | doSave = kTRUE; | |
111 | } | |
a23f7c97 | 112 | |
bcf2601a | 113 | AliESDtrackCuts * cuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kFALSE); |
114 | TString pathsuffix = ""; | |
115 | ||
116 | if(!useSingleBin) pathsuffix += "_AllCentr"; | |
a23f7c97 | 117 | |
9441cdaa | 118 | if (optionStr.Contains("DCA")) { |
119 | delete cuts; | |
120 | cuts = AliESDtrackCuts::GetStandardITSPureSATrackCuts2009(); | |
121 | cout << ">>>> USING DCA cut" << endl; | |
122 | cuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE); | |
bcc49144 | 123 | pathsuffix+="_DCAcut"; |
9441cdaa | 124 | } |
125 | ||
a23f7c97 | 126 | if (optionStr.Contains("ITSsa")) { |
127 | delete cuts; | |
128 | cuts = AliESDtrackCuts::GetStandardITSPureSATrackCuts2009(); | |
129 | cout << ">>>> USING ITS sa tracks" << endl; | |
bcc49144 | 130 | pathsuffix+="_ITSsa"; |
a23f7c97 | 131 | } |
132 | ||
133 | if (optionStr.Contains("TPC")) { | |
134 | delete cuts; | |
135 | cuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); | |
136 | cout << ">>>> USING TPC only tracks" << endl; | |
bcc49144 | 137 | pathsuffix+="_TPC"; |
a23f7c97 | 138 | } |
54b31d6a | 139 | |
140 | Bool_t useMCKinematics = isMC; | |
141 | if (optionStr.Contains("NOMCKIN")) { | |
142 | cout << ">>>> Ignoring MC kinematics" << endl; | |
143 | useMCKinematics=kFALSE; | |
bcc49144 | 144 | pathsuffix+="_NOMCKIN"; |
54b31d6a | 145 | } |
a23f7c97 | 146 | |
147 | ||
148 | // load my task | |
bcf2601a | 149 | if (useSingleBin) { |
150 | gROOT->ProcessLine(".L $ALICE_ROOT/PWG0/multPbPb/AddTaskMultPbPbTracks.C"); | |
151 | AliAnalysisTaskMultPbTracks * task = AddTaskMultPbPbTracks("multPbPbtracks.root", cuts, centrSelector); | |
152 | task->SetIsMC(useMCKinematics); | |
153 | task->SetOfflineTrigger(AliVEvent::kMB); | |
154 | if(optionStr.Contains("TPC")) task->SetTPCOnly(); | |
155 | if(useMCKinematics) task->GetHistoManager()->SetSuffix("MC"); | |
156 | if(customSuffix!=""){ | |
157 | cout << "Setting custom suffix: " << customSuffix << endl; | |
158 | task->GetHistoManager()->SetSuffix(customSuffix); | |
159 | } | |
160 | } else { | |
161 | gROOT->ProcessLine(".L $ALICE_ROOT/PWG0/multPbPb/AddTaskMultPbPbTracksAllCentrality.C"); | |
162 | centrSelector->SetUseV0Range(kTRUE); | |
163 | Int_t ncentr = 11; | |
164 | const Float_t minCentr[] = {0, 79, 247,577, 1185,2155,3565,5527,8203, 12167,15073}; | |
165 | const Float_t maxCentr[] = {79,247,577,1185,2155,3565,5527,8203,12167,15073,21000}; | |
166 | AliAnalysisTaskMultPbTracks ** tasks = AddTaskMultPbPbTracksAllCentrality("multPbPbtracks.root", cuts, centrSelector, ncentr,minCentr,maxCentr); | |
167 | for(Int_t icentr = 0; icentr < ncentr; icentr++){ | |
168 | cout << "1 " << tasks[icentr] << endl; | |
169 | tasks[icentr]->Print(); | |
170 | tasks[icentr]->SetIsMC(useMCKinematics); | |
171 | cout << "2" << endl; | |
172 | tasks[icentr]->SetOfflineTrigger(AliVEvent::kMB); | |
173 | cout << "3" << endl; | |
174 | if(optionStr.Contains("TPC")) tasks[icentr]->SetTPCOnly(); | |
175 | cout << "4" << endl; | |
176 | if(useMCKinematics) tasks[icentr]->GetHistoManager()->SetSuffix("MC"); | |
177 | cout << "5" << endl; | |
178 | if(customSuffix!=""){ | |
179 | cout << "Setting custom suffix: " << customSuffix+long(icentr) << tasks[icentr] << endl; | |
180 | tasks[icentr]->GetHistoManager()->SetSuffix(customSuffix+long(icentr)); | |
181 | cout << "ok" << endl; | |
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 | ||
217 | ||
218 | } | |
219 | ||
220 | ||
221 | void MoveOutput(const char * data, const char * suffix = ""){ | |
222 | ||
223 | TString path("output/"); | |
224 | path = path + TString(data).Tokenize("/")->Last()->GetName() + suffix; | |
225 | ||
226 | TString fileName = "multPbPbtracks.root"; | |
227 | gSystem->mkdir(path, kTRUE); | |
228 | gSystem->Rename(fileName, path + "/" + fileName); | |
bcf2601a | 229 | for(Int_t ibin = 0; ibin < 20; ibin++){ |
230 | TString fileBin = fileName; | |
231 | fileBin.ReplaceAll(".root",Form("_%2.2d.root",ibin)); | |
232 | gSystem->Rename(fileBin, path + "/" + fileBin); | |
233 | } | |
234 | ||
a23f7c97 | 235 | gSystem->Rename("event_stat.root", path + "/event_stat.root"); |
236 | Printf(">>>>> Moved files to %s", path.Data()); | |
237 | } | |
238 | ||
239 | ||
240 | ||
241 | TChain * GetAnalysisChain(const char * incollection){ | |
242 | // Builds a chain of esd files | |
243 | // incollection can be | |
244 | // - a single root file | |
245 | // - an xml collection of files on alien | |
246 | // - a ASCII containing a list of local root files | |
247 | TChain* analysisChain = 0; | |
248 | // chain | |
249 | analysisChain = new TChain("esdTree"); | |
250 | if (TString(incollection).Contains(".root")){ | |
251 | analysisChain->Add(incollection); | |
252 | } | |
253 | else if (TString(incollection).Contains("xml")){ | |
254 | TGrid::Connect("alien://"); | |
255 | TAlienCollection * coll = TAlienCollection::Open (incollection); | |
256 | while(coll->Next()){ | |
257 | analysisChain->Add(TString("alien://")+coll->GetLFN()); | |
258 | } | |
259 | } else { | |
260 | ifstream file_collect(incollection); | |
261 | TString line; | |
262 | while (line.ReadLine(file_collect) ) { | |
263 | analysisChain->Add(line.Data()); | |
264 | } | |
265 | } | |
266 | analysisChain->GetListOfFiles()->Print(); | |
267 | ||
268 | return analysisChain; | |
269 | } | |
270 | ||
271 | ||
272 | void InitAndLoadLibs(Int_t runMode=kMyRunModeLocal, Int_t workers=0,Bool_t debug=0) { | |
e0376287 | 273 | // Loads libs and par files + custom task and classes |
274 | ||
275 | // Custom stuff to be loaded | |
276 | listToLoad->Add(new TObjString("$ALICE_ROOT/ANALYSIS/AliCentralitySelectionTask.cxx+")); | |
277 | listToLoad->Add(new TObjString("$ALICE_ROOT/PWG1/background/AliHistoListWrapper.cxx+")); | |
278 | listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisMultPbTrackHistoManager.cxx+")); | |
2bbfd8c6 | 279 | listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisMultPbCentralitySelector.cxx+")); |
e0376287 | 280 | listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisTaskMultPbTracks.cxx+")); |
281 | ||
a23f7c97 | 282 | |
283 | if (runMode == kMyRunModeCAF) | |
bcf2601a | 284 | { |
285 | cout << "Init in CAF mode" << endl; | |
a23f7c97 | 286 | |
bcf2601a | 287 | gEnv->SetValue("XSec.GSI.DelegProxy", "2"); |
288 | TProof * p = TProof::Open("alice-caf.cern.ch", workers>0 ? Form("workers=%d",workers) : ""); | |
289 | // TProof::Open("skaf.saske.sk", workers>0 ? Form("workers=%d",workers) : ""); | |
290 | p->Exec("TObject *o = gEnv->GetTable()->FindObject(\"Proof.UseMergers\"); gEnv->GetTable()->Remove(o);", kTRUE); | |
291 | ||
292 | // Enable the needed package | |
293 | gProof->UploadPackage("$ALICE_ROOT/STEERBase"); | |
294 | gProof->EnablePackage("$ALICE_ROOT/STEERBase"); | |
295 | gProof->UploadPackage("$ALICE_ROOT/ESD"); | |
296 | gProof->EnablePackage("$ALICE_ROOT/ESD"); | |
297 | gProof->UploadPackage("$ALICE_ROOT/AOD"); | |
298 | gProof->EnablePackage("$ALICE_ROOT/AOD"); | |
299 | gProof->UploadPackage("$ALICE_ROOT/ANALYSIS"); | |
300 | gProof->EnablePackage("$ALICE_ROOT/ANALYSIS"); | |
301 | gProof->UploadPackage("$ALICE_ROOT/ANALYSISalice"); | |
302 | gProof->EnablePackage("$ALICE_ROOT/ANALYSISalice"); | |
303 | gProof->UploadPackage("$ALICE_ROOT/PWG0base"); | |
304 | gProof->EnablePackage("$ALICE_ROOT/PWG0base"); | |
305 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG0/multPb")); | |
306 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background")); | |
307 | } | |
a23f7c97 | 308 | else |
bcf2601a | 309 | { |
310 | cout << "Init in Local or Grid mode" << endl; | |
311 | gSystem->Load("libCore.so"); | |
312 | gSystem->Load("libTree.so"); | |
313 | gSystem->Load("libGeom.so"); | |
314 | gSystem->Load("libVMC.so"); | |
315 | gSystem->Load("libPhysics.so"); | |
316 | gSystem->Load("libSTEERBase"); | |
317 | gSystem->Load("libESD"); | |
318 | gSystem->Load("libAOD"); | |
319 | gSystem->Load("libANALYSIS"); | |
320 | gSystem->Load("libANALYSISalice"); | |
321 | // Use AliRoot includes to compile our task | |
322 | gROOT->ProcessLine(".include $ALICE_ROOT/include"); | |
323 | ||
324 | // gSystem->Load("libVMC"); | |
325 | // gSystem->Load("libTree"); | |
326 | // gSystem->Load("libSTEERBase"); | |
327 | // gSystem->Load("libESD"); | |
328 | // gSystem->Load("libAOD"); | |
329 | // gSystem->Load("libANALYSIS"); | |
330 | // gSystem->Load("libANALYSISalice"); | |
331 | // gSystem->Load("libPWG0base"); | |
a23f7c97 | 332 | |
bcf2601a | 333 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG0/multPb")); |
334 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background")); | |
335 | // gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background/")); | |
336 | } | |
a23f7c97 | 337 | // Load helper classes |
e0376287 | 338 | TIterator * iter = listToLoad->MakeIterator(); |
339 | TObjString * name = 0; | |
340 | while (name = (TObjString *)iter->Next()) { | |
341 | gSystem->ExpandPathName(name->String()); | |
342 | cout << name->String().Data(); | |
343 | if (runMode == kMyRunModeCAF) { | |
344 | gProof->Load(name->String()+(debug?"+g":"")); | |
345 | } else { | |
346 | gROOT->LoadMacro(name->String()+(debug?"+g":"")); | |
347 | } | |
a23f7c97 | 348 | } |
349 | ||
a23f7c97 | 350 | } |