]>
Commit | Line | Data |
---|---|---|
1c762251 | 1 | class AliAnalysisAlien; |
2 | ||
3 | //____________________________________________________________________ | |
4 | // Forward declarations | |
5 | AliAnalysisAlien* | |
6 | CreateAlienHandler(const TString& runMode, | |
7 | const TString& dataDir, | |
fed25682 | 8 | const TArrayI& runs, |
1c762251 | 9 | const TString& anaSource, |
10 | const TString& addLibs, | |
11 | const TString& anaName, | |
fed25682 | 12 | Bool_t uPar, |
1c762251 | 13 | const TString& aliceTag, |
14 | const TString& rootTag, | |
15 | const TString& apiTag); | |
16 | ||
17 | //____________________________________________________________________ | |
fed25682 | 18 | /** |
19 | * | |
20 | * | |
21 | * @param runMode | |
22 | * @param dataDir | |
23 | * @param what | |
24 | * @param nEvents | |
25 | * @param mc | |
26 | */ | |
1c762251 | 27 | void |
28 | RunViaPlugin(const Char_t* runMode="", | |
29 | const Char_t* dataDir=".", | |
fed25682 | 30 | const Char_t* what="aod", |
1c762251 | 31 | Long64_t nEvents=-1, |
32 | Bool_t mc=false) | |
33 | { | |
34 | gSystem->Load("libANALYSIS"); | |
35 | gSystem->Load("libANALYSISalice"); | |
36 | ||
fed25682 | 37 | TString mode(runMode); |
38 | mode.ToLower(); | |
39 | Bool_t proof = mode.Contains("proof"); | |
40 | if (proof) { | |
41 | gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C"); | |
42 | LoadPars(0); | |
43 | } | |
44 | ||
45 | ||
1c762251 | 46 | // --- Creating the manager and handlers --------------------------- |
47 | AliAnalysisManager *mgr = new AliAnalysisManager("Analysis Train", | |
48 | "FMD analysis train"); | |
49 | ||
50 | // --- ESD input handler ------------------------------------------- | |
51 | AliESDInputHandler *esdHandler = new AliESDInputHandler(); | |
52 | esdHandler->SetInactiveBranches("AliESDACORDE " | |
53 | "AliRawDataErrorLogs " | |
54 | "CaloClusters " | |
55 | "Cascades " | |
56 | "EMCALCells " | |
57 | "EMCALTrigger " | |
58 | "Kinks " | |
59 | "Cascades " | |
60 | "MuonTracks " | |
61 | "TrdTracks " | |
62 | "HLTGlobalTrigger"); | |
63 | mgr->SetInputEventHandler(esdHandler); | |
64 | ||
65 | // --- Monte Carlo handler ----------------------------------------- | |
66 | if (mc) { | |
67 | AliMCEventHandler* mcHandler = new AliMCEventHandler(); | |
68 | mgr->SetMCtruthEventHandler(mcHandler); | |
69 | mcHandler->SetReadTR(true); | |
70 | } | |
71 | ||
72 | // --- AOD output handler ------------------------------------------ | |
73 | AliAODHandler* aodHandler = new AliAODHandler(); | |
74 | mgr->SetOutputEventHandler(aodHandler); | |
75 | aodHandler->SetOutputFileName("AliAODs.root"); | |
76 | ||
fed25682 | 77 | // --- What to do -------------------------------------------------- |
78 | TString anaName("FMD"); | |
79 | TString swhat(what); | |
80 | swhat.ToLower(); | |
81 | if (swhat.Contains("aod")) { | |
82 | // --- Add tasks --------------------------------------------------- | |
83 | // Physics selection | |
84 | gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); | |
85 | AddTaskPhysicsSelection(mc, kTRUE, kTRUE); | |
86 | ||
87 | ||
88 | // FMD | |
89 | gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskFMD.C"); | |
90 | AddTaskFMD(mc); | |
91 | anaName = "FMD_AOD"; | |
92 | } | |
93 | else if (swhat.Contains("eloss")) { | |
94 | // FMD Eloss fitter | |
95 | gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskFMDELoss.C"); | |
96 | AddTaskFMDELoss(mc); | |
1c762251 | 97 | |
fed25682 | 98 | anaName = "FMD_ELoss"; |
99 | } | |
100 | else if (swhat.Contains("corr")) { | |
101 | gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskFMDCorr.C"); | |
102 | AddTaskFMDCorr(); | |
103 | ||
104 | anaName = "FMD_Corr"; | |
105 | } | |
106 | ||
1c762251 | 107 | |
108 | // --- Create the plug-in object ----------------------------------- | |
fed25682 | 109 | TString mode(runMode); mode.ToLower(); |
1c762251 | 110 | TString dir(dataDir); |
111 | TString anaSource(""); | |
112 | TString addLibs(""); | |
1c762251 | 113 | TString aliceTag("v4-21-04-AN"); |
114 | TString rootTag("v5-27-06b"); | |
115 | TString apiTag("V1.1x"); | |
fed25682 | 116 | TArrayI runs; // <-- Add run numbers to this array |
117 | /* For example | |
118 | * | |
119 | * runs.Resize(118560-118506+1); | |
120 | * for (Int_t r = 118506; r <= 118560; r++) | |
121 | * runs.AddAt(r-118506,r); | |
122 | */ | |
1c762251 | 123 | AliAnalysisAlien* alienHandler = CreateAlienHandler(mode, |
124 | dir, | |
fed25682 | 125 | runs, |
1c762251 | 126 | anaSource, |
127 | addLibs, | |
128 | anaName, | |
fed25682 | 129 | proof, |
1c762251 | 130 | aliceTag, |
131 | rootTag, | |
132 | apiTag); | |
133 | if (!alienHandler) { | |
134 | Error("RunViaPlugin.C", "Failed to make plugin"); | |
135 | return; | |
136 | } | |
137 | mgr->SetGridHandler(alienHandler); | |
138 | ||
139 | // --- final job setup and execution ------------------------------- | |
140 | // Enable debug printouts | |
141 | // mgr->SetDebugLevel(2); | |
142 | if (!mgr->InitAnalysis()) { | |
143 | Error("RunViaPlugin.C", "Failed to initialise the train"); | |
144 | return; | |
145 | } | |
146 | if (nEvents <= 0) nEvents = 1234567890; | |
147 | TString amode("grid"); | |
148 | mode.ToLower(); | |
149 | if (mode.Contains("test")) amode = local; | |
150 | ||
151 | mgr->PrintStatus(); | |
152 | mgr->StartAnalysis(amode.Data(), nEvents); | |
153 | } | |
154 | ||
155 | //____________________________________________________________________ | |
156 | /** | |
157 | * Create an AliAnalysisGrid parameter object | |
158 | * | |
159 | * @param runMode Running mode (full, test, terminate, submit, offline) | |
160 | * @param dataDir Input data directory | |
161 | * @param anaSource Possible source to compile on worker node | |
162 | * (must also be compiled and addet to train on | |
163 | * submitter machine) | |
164 | * @param addLibs Extra libraries to add | |
165 | * @param anaName Analysis name (i.e., script created) | |
166 | * @param aliceTag Tag on AliROOT | |
167 | * @param rootTag Tag on ROOT | |
168 | * @param apiTag AliEN tag | |
169 | * | |
170 | * @return Valid object or null | |
171 | */ | |
172 | AliAnalysisAlien* | |
173 | CreateAlienHandler(const TString& runMode, | |
174 | const TString& dataDir, | |
fed25682 | 175 | const TArrayI& runs, |
1c762251 | 176 | const TString& anaSource, |
177 | const TString& addLibs, | |
178 | const TString& anaName, | |
fed25682 | 179 | Bool_t usePars, |
1c762251 | 180 | const TString& aliceTag, |
181 | const TString& rootTag, | |
182 | const TString& apiTag) | |
183 | { | |
184 | AliAnalysisAlien *plugin = new AliAnalysisAlien(); | |
185 | ||
186 | // Overwrite all generated files, datasets and output | |
187 | // results from a previous session | |
188 | plugin->SetOverwriteMode(); | |
189 | ||
fed25682 | 190 | // Set tag on job |
191 | TString tag(anaName); | |
192 | tag.Append(" job"); | |
193 | plugin->SetJobTag(tag); | |
194 | ||
1c762251 | 195 | // Set the running mode |
196 | plugin->SetRunMode(runMode.Data()); | |
197 | ||
198 | // Add path to our headers | |
199 | plugin->AddIncludePath("-I$ALICE_ROOT/PWG2/FORWARD/analysis2"); | |
200 | ||
201 | // Set versions of used packages | |
202 | plugin->SetAPIVersion(apiTag); | |
203 | plugin->SetROOTVersion(rootTag); | |
204 | plugin->SetAliROOTVersion(aliceTag); | |
205 | ||
206 | // Define production directory LFN | |
207 | plugin->SetGridDataDir(dataDir.Data()); | |
208 | ||
209 | // Set data search pattern | |
210 | plugin->SetDataPattern("*ESDs*.root"); | |
211 | ||
212 | // Use ESD tags (same applies for AOD's) | |
213 | //plugin->SetDataPattern("*tag.root"); | |
214 | ||
215 | // File used in test mode | |
216 | plugin->SetFileForTestMode("testFiles"); | |
217 | ||
218 | // ...then add run numbers to be considered | |
219 | // If not set all runs proccessed | |
fed25682 | 220 | for (Int_t i = 0; i < runs.fN; i++) |
221 | plugin->AddRunNumber(runs.fArray[i]); | |
1c762251 | 222 | |
223 | // Set events to run over for each file !!! | |
224 | //plugin->SetRunRange(0, 10); | |
225 | ||
226 | // Define alien work directory where all files will be copied. | |
227 | // Relative to alien $HOME. | |
fed25682 | 228 | TString work(anaName); |
229 | work.Append("_work"); | |
230 | plugin->SetGridWorkingDir(work.Data()); | |
1c762251 | 231 | |
232 | // Declare alien output directory. Relative to working directory. | |
fed25682 | 233 | TString outputDir(anaName); |
234 | outputDir.Append("_out"); | |
1c762251 | 235 | plugin->SetGridOutputDir(outputDir.Data()); |
fed25682 | 236 | |
237 | // Write to a single folder | |
238 | plugin->SetOutputSingleFolder(outputDir.Data()); | |
239 | plugin->SetOutputToRunNo(); | |
1c762251 | 240 | |
241 | // Declare the analysis source files names separated by blancs. | |
242 | // To be compiled runtime using ACLiC on the worker nodes. | |
243 | if (!anaSource.IsNull()) | |
244 | plugin->SetAnalysisSource(anaSource.Data()); | |
245 | ||
246 | // Declare all libraries (other than the default ones for the framework. | |
247 | // These will be loaded by the generated analysis macro. | |
248 | // Add all extra files (task .cxx/.h) here. | |
249 | if (!addLibs.IsNull()) | |
250 | plugin->SetAdditionalLibs(addLibs.Data()); | |
fed25682 | 251 | |
252 | // Load PAR files | |
253 | if (usePars) { | |
254 | plugin->EnablePackage("STEERBase"); | |
255 | plugin->EnablePackage("ESD"); | |
256 | plugin->EnablePackage("AOD"); | |
257 | plugin->EnablePackage("ANALYSIS"); | |
258 | plugin->EnablePackage("ANALYSISalice"); | |
259 | plugin->EnablePackage("PWG2forward2"); | |
260 | } | |
261 | ||
1c762251 | 262 | // No need for output file names. Procedure is automatic. |
263 | // It's works better this way | |
264 | plugin->SetDefaultOutputs(kTRUE); | |
265 | ||
266 | // Set a name for the generated analysis macro (default MyAnalysis.C). | |
267 | // Make this unique !!! | |
fed25682 | 268 | TString macroName(anaName); |
1c762251 | 269 | macroName += "Task.C"; |
270 | plugin->SetAnalysisMacro(macroName.Data()); | |
271 | ||
272 | // Optionally set maximum number of input files/subjob (default 100, | |
273 | // put 0 to ignore) | |
274 | plugin->SetSplitMaxInputFileNumber(100); | |
275 | ||
276 | // Optionally set number of failed jobs that will trigger killing | |
277 | // waiting sub-jobs. | |
278 | plugin->SetMaxInitFailed(5); | |
279 | ||
280 | // Optionally resubmit threshold. | |
281 | plugin->SetMasterResubmitThreshold(90); | |
282 | ||
283 | // Optionally set time to live (default 30000 sec) | |
284 | plugin->SetTTL(20000); | |
285 | ||
286 | // Optionally set input format (default xml-single) | |
287 | plugin->SetInputFormat("xml-single"); | |
288 | ||
289 | // Optionally modify the name of the generated JDL (default analysis.jdl) | |
fed25682 | 290 | TString jdlName(anaName); |
291 | jdlName.Append(".jdl"); | |
1c762251 | 292 | plugin->SetJDLName(jdlName.Data()); |
293 | ||
294 | // Optionally modify job price (default 1) | |
295 | plugin->SetPrice(1); | |
296 | ||
297 | // Optionally modify split mode (default 'se') | |
298 | plugin->SetSplitMode("se"); | |
299 | ||
300 | // connect to manager | |
301 | // AliAnalysisManager* mgr = AliAnalysisManager::Instance(); | |
302 | // mgr->SetGridHandler(plugin); | |
303 | ||
304 | return plugin; | |
305 | } | |
306 | ||
307 | //____________________________________________________________________ | |
308 | // | |
309 | // EOF | |
310 | // |