]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/RESONANCES/macros/mini/SetupPlugin.C
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / macros / mini / SetupPlugin.C
CommitLineData
1c7ede26 1#include <Riostream.h>
2#include <TError.h>
3#include <TObjArray.h>
4#include <TObjString.h>
5#include "AliAnalysisAlien.h"
6
7namespace PluginSetup
8{
9 //
10 // === DEFINITIONS ==============================================================================
11 //
12
13 // output object
14 AliAnalysisAlien *plugin = 0x0; // --> output of this code
15
16 // basic setup
17 Bool_t targetAlien = kTRUE; // [*all*] kTRUE --> alien, kFALSE --> proof
18
19 // executables
20 TString aliVersion = "v4-21-19-AN"; // [*all*] tag used for AliRoot
21 TString rootVersion = "v5-28-00a"; // [*all*] tag used for ROOT
22 TString apiVersion = "V1.1x"; // [AliEn] tag used for AliEn API
23
24 // file naming
25 TString jobName = ""; // [AliEn] basic name for all files
26 TString fileJDL = ""; // [AliEn] JDL filename
27 TString fileC = ""; // [AliEn] run macro name
28 TString fileSH = ""; // [AliEn] executable shell script name
29
30 // input definitions
31 Bool_t alienInputRuns = kTRUE; // [AliEn] choose if inputs are runs (kTRUE) or lists of XML (kFALSE)
32 TString runList = ""; // [AliEn] list of run numbers from which XML collections are created
33 TString runPath = ""; // [AliEn] common path where the above runs are stored
34 TString runPrefix = ""; // [AliEn] a common string prefix to all run numbers (usually, "" for MC, "000" for data)
35 TString runPattern = ""; // [AliEn] pattern to be used for the 'find -x' command
36 TString xmlList = ""; // [AliEn] alternative to runs, pass a list of already-made XML files (NOTE: cannot do "test")
37 TString dataSet = ""; // [PROOF] dataset name
38 TString proofTest = ""; // [PROOF] test TXT collection of local files for running in "test" mode for PROOF
39 TString proofCluster = "alice-caf.cern.ch"; // [PROOF] name of used PROOF cluster
40 Bool_t proofReset = kFALSE; // [PROOF] tell the cluster if compiled libraries must be cleared
41 TString alirootMode = "default"; // [PROOF] modality for AliRoot loading
42 Bool_t proofClear = kFALSE; // [PROOF] tell the cluster if compiled libraries must be cleared
43
44 // output paths
45 TString workDir = ""; // [AliEn] working dir w.r. to user $ALIEN_HOME
46 TString outDir = "out"; // [AliEn] output dir w.r. to 'workDir'
47
48 // additional libraries
49 TString addTaskRuntime = ""; // [*all*] list of tasks compiled at runtime (just the name)
50 TString addLibs = ""; // [*all*] list of all libraries to be added (order matters)
51 TString addIncludes = ""; // [*all*] list of additional include paths to use
52 TString addPar = ""; // [*all*] list of additional PARs to use
53
54 // AliEn JDL parameters
55 Int_t split = 100; // [AliEn] split parameter in JDL
56 Int_t maxMergeFiles = 50; // [AliEn] how many files to be merged per chunk
57 Int_t nRunsPerMaster = 1; // [AliEn] how many runs are used together in a single master job (for ESD: 1, for AOD: even all)
58 Int_t maxMergeStages = 2; // [AliEn] how many maximum merge stages to have
59 Int_t maxInitFailed = 0; // [AliEn] how many failed initializations are tolerated (?)
60 Int_t resubmitThr = 0; // [AliEn] threshold that triggers automatic job resubmit (?)
61 Int_t TTL = 30000; // [AliEn] time-to-live (in sec)
62 TString inputFormat = "xml-single"; // [AliEn] input format in JDL
63 TString splitMode = "se"; // [AliEn] splitting modality
64 Int_t price = 1; // [AliEn] job price
65 TString jobTag = ""; // [AliEn] tag assigned to job
66 Int_t nTestFiles = 1; // [AliEn] number of input files used locally in test mode
67
68 //
69 // === FUNCTIONS ================================================================================
70 //
71
72 Bool_t AssignNames();
73 Bool_t CreatePlugin();
74 Bool_t SetupForAlien();
75 Bool_t SetupForProof();
76
77 //_______________________________________________________________________________________________
78 //
79 // Define all 'automatic' names from the job name
80 //
81 Bool_t AssignNames()
82 {
83 if (jobName.Length() < 1) {
84 ::Error("SetupPlugin::AssignNames()", "Job name not defined");
85 return kFALSE;
86 }
87
88
89 fileC = jobName;
90 fileSH = jobName;
91 fileJDL = jobName;
92
93 fileC.Append(".C");
94 fileSH.Append(".sh");
95 fileJDL.Append(".jdl");
96
97 ::Info("SetupPlugin::AssignNames()", "macro name: \"%s\"", fileC.Data());
98 ::Info("SetupPlugin::AssignNames()", "JDL name: \"%s\"", fileJDL.Data());
99 ::Info("SetupPlugin::AssignNames()", "script name: \"%s\"", fileSH.Data());
100
101 return kTRUE;
102 }
103
104 //_______________________________________________________________________________________________
105 //
106 // Initialize plugin with all its common values
107 //
108 Bool_t CreatePlugin()
109 {
110 // create object
111 plugin = new AliAnalysisAlien;
112
113 // framework version
114 plugin->SetROOTVersion(rootVersion.Data());
115 plugin->SetAliROOTVersion(aliVersion.Data());
116
117 // additional libraries/includes
118 if (addLibs.Length() > 0) plugin->SetAdditionalLibs(addLibs.Data());
119 if (addIncludes.Length() > 0) plugin->AddIncludePath(addIncludes.Data());
120
121 // runtime tasks
122 if (addTaskRuntime.Length() > 0) {
123 TObjArray *list = addTaskRuntime.Tokenize(" ");
124 TObjArrayIter next(list);
125 TObjString *os = 0x0;
126 TString sources("");
127 while ( (os = (TObjString*)next()) ) {
128 const char *taskName = os->GetString().Data();
129 addLibs.Append(Form("%s.h %s.cxx", taskName, taskName));
130 sources.Append(Form("%s.cxx", taskName));
131 }
132 plugin->SetAnalysisSource(sources.Data());
133 }
134
135 // specific setups
136 if (targetAlien) {
137 ::Info("SetupPlugin::CreatePlugin()", "Setting up for ALIEN");
138 return SetupForAlien();
139 } else {
140 ::Info("SetupPlugin::CreatePlugin()", "Setting up for PROOF");
141 return SetupForProof();
142 }
143 }
144
145
146 //_______________________________________________________________________________________________
147 //
148 // Initialize plugin with all needed for AliEn
149 //
150 Bool_t SetupForAlien()
151 {
152 if (!plugin) {
153 ::Error("SetupPlugin::SetupForAlien()", "Initialize plugin first");
154 return kFALSE;
155 }
156
157 // create names
158 if (!AssignNames()) {
159 ::Error("SetupPlugin::SetupForAlien()", "Failed name initializations");
160 return kFALSE;
161 }
162
163 // API version
164 plugin->SetAPIVersion(apiVersion.Data());
165
166 // merging detauls
167 plugin->SetMergeViaJDL();
168 plugin->SetMaxMergeFiles(maxMergeFiles);
169 plugin->SetMaxMergeStages(maxMergeStages);
170
171 // output paths
172 plugin->SetGridWorkingDir(workDir.Data());
173 plugin->SetGridOutputDir(outDir.Data());
174 plugin->SetDefaultOutputs(kTRUE);
175
176 // excutable
177 plugin->SetExecutableCommand("aliroot -q -b");
178 plugin->SetExecutableArgs(">& std.log");
179 plugin->SetExecutable(fileSH.Data());
180
181 // automatically created files
182 plugin->SetAnalysisMacro(fileC.Data());
183 plugin->SetJDLName(fileJDL.Data());
184
185 // JDL parameters
186 plugin->SetSplitMaxInputFileNumber(split);
187 plugin->SetMaxInitFailed(maxInitFailed);
188 plugin->SetMasterResubmitThreshold(resubmitThr);
189 plugin->SetTTL(TTL);
190 plugin->SetPrice(price);
191 plugin->SetInputFormat(inputFormat.Data());
192 plugin->SetSplitMode(splitMode.Data());
193 if (jobTag.Length() > 0) plugin->SetJobTag(jobTag.Data());
194
195 // input definition
196 if (alienInputRuns) {
197 plugin->SetOutputToRunNo(kTRUE);
198 plugin->SetNtestFiles(nTestFiles);
199 plugin->SetNrunsPerMaster(nRunsPerMaster);
200 plugin->SetRunPrefix(runPrefix.Data());
201 plugin->SetGridDataDir(runPath.Data());
202 plugin->SetDataPattern(runPattern.Data());
203 plugin->AddRunList(runList.Data());
204 } else {
205 TObjArray *list = xmlList.Tokenize(" ");
206 TObjArrayIter next(list);
207 TObjString *os = 0x0;
208 while ( (os = (TObjString*)next()) ) {
209 plugin->AddDataFile(os->GetString().Data());
210 }
211 plugin->SetOutputToRunNo(kFALSE);
212 }
213
214 return kTRUE;
215 }
216
217 //_______________________________________________________________________________________________
218 //
219 // Initialize plugin with all needed for PROOF
220 //
221 Bool_t SetupForProof()
222 {
223 if (!plugin) {
224 ::Error("SetupPlugin::SetupForAlien()", "Initialize plugin first");
225 return kFALSE;
226 }
227
228 plugin->SetProofCluster(proofCluster.Data());
229 plugin->SetProofDataSet(dataSet.Data());
230 plugin->SetProofReset(proofReset);
231 plugin->SetProofConnectGrid(kTRUE);
232 plugin->SetAliRootMode(alirootMode.Data());
233 plugin->SetClearPackages(proofClear);
234 plugin->SetFileForTestMode(proofTest.Data());
235
236 return kTRUE;
237 }
238};