]>
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 | ||
e0376287 | 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, Int_t centrBin = 0, const char * centrEstimator = "VOM", const char* option = "",TString customSuffix = "", Int_t workers = -1) |
a23f7c97 | 13 | { |
14 | // runMode: | |
15 | // | |
16 | // 0 local | |
17 | // 1 proof | |
18 | ||
19 | if (nev < 0) | |
20 | nev = 1234567890; | |
21 | ||
22 | InitAndLoadLibs(runMode,workers,debug); | |
23 | ||
24 | // Create the analysis manager | |
25 | mgr = new AliAnalysisManager; | |
26 | ||
27 | // Add ESD handler | |
28 | AliESDInputHandler* esdH = new AliESDInputHandler; | |
29 | // Do I need any of this? | |
54b31d6a | 30 | // esdH->SetInactiveBranches("AliESDACORDE FMD ALIESDTZERO ALIESDZDC AliRawDataErrorLogs CaloClusters Cascades EMCALCells EMCALTrigger ESDfriend Kinks AliESDTZERO ALIESDACORDE MuonTracks TrdTracks"); |
a23f7c97 | 31 | mgr->SetInputEventHandler(esdH); |
32 | ||
33 | if(isMC) { | |
34 | AliMCEventHandler* handler = new AliMCEventHandler; | |
b00e8ba9 | 35 | handler->SetPreReadMode(AliMCEventHandler::kLmPreRead); |
a23f7c97 | 36 | mgr->SetMCtruthEventHandler(handler); |
37 | } | |
38 | ||
e0376287 | 39 | |
40 | // If we are running on grid, we need the alien handler | |
41 | if (runMode == kMyRunModeGRID) { | |
42 | // Create and configure the alien handler plugin | |
43 | gROOT->LoadMacro("CreateAlienHandler.C"); | |
8b7362ee | 44 | AliAnalysisGrid *alienHandler = CreateAlienHandler(data, listToLoad, "full", isMC); |
e0376287 | 45 | if (!alienHandler) { |
46 | cout << "Cannot create alien handler" << endl; | |
47 | exit(1); | |
48 | } | |
49 | mgr->SetGridHandler(alienHandler); | |
50 | } | |
51 | ||
52 | ||
53 | ||
a23f7c97 | 54 | // physics selection |
55 | gROOT->ProcessLine(".L $ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); | |
56 | physicsSelectionTask = AddTaskPhysicsSelection(isMC); | |
57 | ||
54b31d6a | 58 | // Centrality |
59 | AliCentralitySelectionTask *taskCentr = new AliCentralitySelectionTask("CentralitySelection"); | |
60 | taskCentr->SetPercentileFile("$ALICE_ROOT/ANALYSIS/macros/test_AliCentralityBy1D.root"); | |
9d173aad | 61 | taskCentr->SetPercentileFile2("$ALICE_ROOT/ANALYSIS/macros/test_AliCentralityByFunction.root"); |
54b31d6a | 62 | mgr->AddTask(taskCentr); |
63 | mgr->ConnectInput (taskCentr,0, mgr->GetCommonInputContainer()); | |
a23f7c97 | 64 | |
65 | ||
66 | // Parse option strings | |
67 | TString optionStr(option); | |
68 | ||
69 | // remove SAVE option if set | |
70 | // 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 | |
71 | Bool_t doSave = kFALSE; | |
72 | TString optionStr(option); | |
73 | if (optionStr.Contains("SAVE")) | |
74 | { | |
75 | optionStr = optionStr(0,optionStr.Index("SAVE")) + optionStr(optionStr.Index("SAVE")+4, optionStr.Length()); | |
76 | doSave = kTRUE; | |
77 | } | |
78 | ||
e0376287 | 79 | AliESDtrackCuts * cuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE); |
a23f7c97 | 80 | TString pathsuffix = ""; |
81 | // cuts->SetPtRange(0.15,0.2);// FIXME pt cut | |
82 | // const char * pathsuffix = "_pt_015_020_nofakes"; | |
83 | ||
84 | if (optionStr.Contains("ITSsa")) { | |
85 | delete cuts; | |
86 | cuts = AliESDtrackCuts::GetStandardITSPureSATrackCuts2009(); | |
87 | cout << ">>>> USING ITS sa tracks" << endl; | |
88 | pathsuffix="ITSsa"; | |
89 | } | |
90 | ||
91 | if (optionStr.Contains("TPC")) { | |
92 | delete cuts; | |
93 | cuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); | |
94 | cout << ">>>> USING TPC only tracks" << endl; | |
95 | pathsuffix="TPC"; | |
96 | } | |
54b31d6a | 97 | |
98 | Bool_t useMCKinematics = isMC; | |
99 | if (optionStr.Contains("NOMCKIN")) { | |
100 | cout << ">>>> Ignoring MC kinematics" << endl; | |
101 | useMCKinematics=kFALSE; | |
102 | } | |
a23f7c97 | 103 | |
104 | ||
105 | // load my task | |
106 | gROOT->ProcessLine(".L $ALICE_ROOT/PWG0/multPbPb/AddTaskMultPbPbTracks.C"); | |
107 | AliAnalysisTaskMultPbTracks * task = AddTaskMultPbPbTracks("multPbPbtracks.root", cuts); // kTRUE enables DCA cut | |
54b31d6a | 108 | task->SetIsMC(useMCKinematics); |
e0376287 | 109 | if(useMCKinematics) task->GetHistoManager()->SetSuffix("MC"); |
110 | if(customSuffix!=""){ | |
111 | cout << "Setting custom suffix: " << customSuffix << endl; | |
112 | task->GetHistoManager()->SetSuffix(customSuffix); | |
113 | } | |
54b31d6a | 114 | task->SetCentralityBin(centrBin); |
115 | task->SetCentralityEstimator(centrEstimator); | |
a23f7c97 | 116 | |
117 | if (!mgr->InitAnalysis()) return; | |
118 | ||
119 | mgr->PrintStatus(); | |
120 | ||
121 | if (runMode == kMyRunModeLocal ) { | |
122 | // If running in local mode, create chain of ESD files | |
54b31d6a | 123 | cout << "RUNNING LOCAL, CHAIN" << endl; |
a23f7c97 | 124 | TChain * chain = GetAnalysisChain(data); |
125 | chain->Print(); | |
126 | mgr->StartAnalysis("local",chain,nev); | |
127 | } else if (runMode == kMyRunModeCAF) { | |
128 | mgr->StartAnalysis("proof",TString(data)+"#esdTree",nev); | |
e0376287 | 129 | } else if (runMode == kMyRunModeGRID) { |
130 | mgr->StartAnalysis("grid"); | |
a23f7c97 | 131 | } else { |
132 | cout << "ERROR: unknown run mode" << endl; | |
133 | } | |
134 | ||
e0376287 | 135 | pathsuffix = pathsuffix + "_" + centrEstimator + "_bin_"+long(centrBin); |
a23f7c97 | 136 | if (doSave) MoveOutput(data, pathsuffix.Data()); |
137 | ||
138 | ||
139 | } | |
140 | ||
141 | ||
142 | void MoveOutput(const char * data, const char * suffix = ""){ | |
143 | ||
144 | TString path("output/"); | |
145 | path = path + TString(data).Tokenize("/")->Last()->GetName() + suffix; | |
146 | ||
147 | TString fileName = "multPbPbtracks.root"; | |
148 | gSystem->mkdir(path, kTRUE); | |
149 | gSystem->Rename(fileName, path + "/" + fileName); | |
150 | gSystem->Rename("event_stat.root", path + "/event_stat.root"); | |
151 | Printf(">>>>> Moved files to %s", path.Data()); | |
152 | } | |
153 | ||
154 | ||
155 | ||
156 | TChain * GetAnalysisChain(const char * incollection){ | |
157 | // Builds a chain of esd files | |
158 | // incollection can be | |
159 | // - a single root file | |
160 | // - an xml collection of files on alien | |
161 | // - a ASCII containing a list of local root files | |
162 | TChain* analysisChain = 0; | |
163 | // chain | |
164 | analysisChain = new TChain("esdTree"); | |
165 | if (TString(incollection).Contains(".root")){ | |
166 | analysisChain->Add(incollection); | |
167 | } | |
168 | else if (TString(incollection).Contains("xml")){ | |
169 | TGrid::Connect("alien://"); | |
170 | TAlienCollection * coll = TAlienCollection::Open (incollection); | |
171 | while(coll->Next()){ | |
172 | analysisChain->Add(TString("alien://")+coll->GetLFN()); | |
173 | } | |
174 | } else { | |
175 | ifstream file_collect(incollection); | |
176 | TString line; | |
177 | while (line.ReadLine(file_collect) ) { | |
178 | analysisChain->Add(line.Data()); | |
179 | } | |
180 | } | |
181 | analysisChain->GetListOfFiles()->Print(); | |
182 | ||
183 | return analysisChain; | |
184 | } | |
185 | ||
186 | ||
187 | void InitAndLoadLibs(Int_t runMode=kMyRunModeLocal, Int_t workers=0,Bool_t debug=0) { | |
e0376287 | 188 | // Loads libs and par files + custom task and classes |
189 | ||
190 | // Custom stuff to be loaded | |
191 | listToLoad->Add(new TObjString("$ALICE_ROOT/ANALYSIS/AliCentralitySelectionTask.cxx+")); | |
192 | listToLoad->Add(new TObjString("$ALICE_ROOT/PWG1/background/AliHistoListWrapper.cxx+")); | |
193 | listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisMultPbTrackHistoManager.cxx+")); | |
194 | listToLoad->Add(new TObjString("$ALICE_ROOT/PWG0/multPbPb/AliAnalysisTaskMultPbTracks.cxx+")); | |
195 | ||
a23f7c97 | 196 | |
197 | if (runMode == kMyRunModeCAF) | |
198 | { | |
199 | cout << "Init in CAF mode" << endl; | |
200 | ||
201 | gEnv->SetValue("XSec.GSI.DelegProxy", "2"); | |
202 | TProof::Open("alice-caf.cern.ch", workers>0 ? Form("workers=%d",workers) : ""); | |
203 | ||
204 | // Enable the needed package | |
205 | gProof->UploadPackage("$ALICE_ROOT/STEERBase"); | |
206 | gProof->EnablePackage("$ALICE_ROOT/STEERBase"); | |
207 | gProof->UploadPackage("$ALICE_ROOT/ESD"); | |
208 | gProof->EnablePackage("$ALICE_ROOT/ESD"); | |
209 | gProof->UploadPackage("$ALICE_ROOT/AOD"); | |
210 | gProof->EnablePackage("$ALICE_ROOT/AOD"); | |
211 | gProof->UploadPackage("$ALICE_ROOT/ANALYSIS"); | |
212 | gProof->EnablePackage("$ALICE_ROOT/ANALYSIS"); | |
213 | gProof->UploadPackage("$ALICE_ROOT/ANALYSISalice"); | |
214 | gProof->EnablePackage("$ALICE_ROOT/ANALYSISalice"); | |
215 | gProof->UploadPackage("$ALICE_ROOT/PWG0base"); | |
216 | gProof->EnablePackage("$ALICE_ROOT/PWG0base"); | |
a28a49f6 | 217 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG0/multPb")); |
218 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background")); | |
a23f7c97 | 219 | } |
220 | else | |
221 | { | |
e0376287 | 222 | cout << "Init in Local or Grid mode" << endl; |
8b7362ee | 223 | gSystem->Load("libCore.so"); |
224 | gSystem->Load("libTree.so"); | |
225 | gSystem->Load("libGeom.so"); | |
226 | gSystem->Load("libVMC.so"); | |
227 | gSystem->Load("libPhysics.so"); | |
a23f7c97 | 228 | gSystem->Load("libSTEERBase"); |
229 | gSystem->Load("libESD"); | |
230 | gSystem->Load("libAOD"); | |
231 | gSystem->Load("libANALYSIS"); | |
8b7362ee | 232 | gSystem->Load("libANALYSISalice"); |
233 | // Use AliRoot includes to compile our task | |
234 | gROOT->ProcessLine(".include $ALICE_ROOT/include"); | |
235 | ||
236 | // gSystem->Load("libVMC"); | |
237 | // gSystem->Load("libTree"); | |
238 | // gSystem->Load("libSTEERBase"); | |
239 | // gSystem->Load("libESD"); | |
240 | // gSystem->Load("libAOD"); | |
241 | // gSystem->Load("libANALYSIS"); | |
242 | // gSystem->Load("libANALYSISalice"); | |
243 | // gSystem->Load("libPWG0base"); | |
a23f7c97 | 244 | |
a28a49f6 | 245 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG0/multPb")); |
246 | gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background")); | |
54b31d6a | 247 | // gROOT->ProcessLine(gSystem->ExpandPathName(".include $ALICE_ROOT/PWG1/background/")); |
a23f7c97 | 248 | } |
249 | // Load helper classes | |
e0376287 | 250 | TIterator * iter = listToLoad->MakeIterator(); |
251 | TObjString * name = 0; | |
252 | while (name = (TObjString *)iter->Next()) { | |
253 | gSystem->ExpandPathName(name->String()); | |
254 | cout << name->String().Data(); | |
255 | if (runMode == kMyRunModeCAF) { | |
256 | gProof->Load(name->String()+(debug?"+g":"")); | |
257 | } else { | |
258 | gROOT->LoadMacro(name->String()+(debug?"+g":"")); | |
259 | } | |
a23f7c97 | 260 | } |
261 | ||
a23f7c97 | 262 | } |