1 class AliAnalysisAlien;
3 //____________________________________________________________________
4 // Forward declarations
6 CreateAlienHandler(const TString& runMode,
7 const TString& dataDir,
9 const TString& anaSource,
10 const TString& addLibs,
11 const TString& anaName,
13 const TString& aliceTag,
14 const TString& rootTag,
15 const TString& apiTag);
17 //____________________________________________________________________
28 RunViaPlugin(const Char_t* runMode="",
29 const Char_t* dataDir=".",
30 const Char_t* what="aod",
34 gSystem->Load("libANALYSIS");
35 gSystem->Load("libANALYSISalice");
37 TString mode(runMode);
39 Bool_t proof = mode.Contains("proof");
41 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
46 // --- Creating the manager and handlers ---------------------------
47 AliAnalysisManager *mgr = new AliAnalysisManager("Analysis Train",
48 "FMD analysis train");
50 // --- ESD input handler -------------------------------------------
51 AliESDInputHandler *esdHandler = new AliESDInputHandler();
52 esdHandler->SetInactiveBranches("AliESDACORDE "
53 "AliRawDataErrorLogs "
63 mgr->SetInputEventHandler(esdHandler);
65 // --- Monte Carlo handler -----------------------------------------
67 AliMCEventHandler* mcHandler = new AliMCEventHandler();
68 mgr->SetMCtruthEventHandler(mcHandler);
69 mcHandler->SetReadTR(true);
72 // --- AOD output handler ------------------------------------------
73 AliAODHandler* aodHandler = new AliAODHandler();
74 mgr->SetOutputEventHandler(aodHandler);
75 aodHandler->SetOutputFileName("AliAODs.root");
77 // --- What to do --------------------------------------------------
78 TString anaName("FMD");
81 if (swhat.Contains("aod")) {
82 // --- Add tasks ---------------------------------------------------
84 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
85 AddTaskPhysicsSelection(mc, kTRUE, kTRUE);
89 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskFMD.C");
93 else if (swhat.Contains("eloss")) {
95 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskFMDELoss.C");
98 anaName = "FMD_ELoss";
100 else if (swhat.Contains("corr")) {
101 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskFMDCorr.C");
104 anaName = "FMD_Corr";
108 // --- Create the plug-in object -----------------------------------
109 TString mode(runMode); mode.ToLower();
110 TString dir(dataDir);
111 TString anaSource("");
113 TString aliceTag("v4-21-04-AN");
114 TString rootTag("v5-27-06b");
115 TString apiTag("V1.1x");
116 TArrayI runs; // <-- Add run numbers to this array
119 * runs.Resize(118560-118506+1);
120 * for (Int_t r = 118506; r <= 118560; r++)
121 * runs.AddAt(r-118506,r);
123 AliAnalysisAlien* alienHandler = CreateAlienHandler(mode,
134 Error("RunViaPlugin.C", "Failed to make plugin");
137 mgr->SetGridHandler(alienHandler);
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");
146 if (nEvents <= 0) nEvents = 1234567890;
147 TString amode("grid");
149 if (mode.Contains("test")) amode = local;
152 mgr->StartAnalysis(amode.Data(), nEvents);
155 //____________________________________________________________________
157 * Create an AliAnalysisGrid parameter object
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
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
170 * @return Valid object or null
173 CreateAlienHandler(const TString& runMode,
174 const TString& dataDir,
176 const TString& anaSource,
177 const TString& addLibs,
178 const TString& anaName,
180 const TString& aliceTag,
181 const TString& rootTag,
182 const TString& apiTag)
184 AliAnalysisAlien *plugin = new AliAnalysisAlien();
186 // Overwrite all generated files, datasets and output
187 // results from a previous session
188 plugin->SetOverwriteMode();
191 TString tag(anaName);
193 plugin->SetJobTag(tag);
195 // Set the running mode
196 plugin->SetRunMode(runMode.Data());
198 // Add path to our headers
199 plugin->AddIncludePath("-I$ALICE_ROOT/PWG2/FORWARD/analysis2");
201 // Set versions of used packages
202 plugin->SetAPIVersion(apiTag);
203 plugin->SetROOTVersion(rootTag);
204 plugin->SetAliROOTVersion(aliceTag);
206 // Define production directory LFN
207 plugin->SetGridDataDir(dataDir.Data());
209 // Set data search pattern
210 plugin->SetDataPattern("*ESDs*.root");
212 // Use ESD tags (same applies for AOD's)
213 //plugin->SetDataPattern("*tag.root");
215 // File used in test mode
216 plugin->SetFileForTestMode("testFiles");
218 // ...then add run numbers to be considered
219 // If not set all runs proccessed
220 for (Int_t i = 0; i < runs.fN; i++)
221 plugin->AddRunNumber(runs.fArray[i]);
223 // Set events to run over for each file !!!
224 //plugin->SetRunRange(0, 10);
226 // Define alien work directory where all files will be copied.
227 // Relative to alien $HOME.
228 TString work(anaName);
229 work.Append("_work");
230 plugin->SetGridWorkingDir(work.Data());
232 // Declare alien output directory. Relative to working directory.
233 TString outputDir(anaName);
234 outputDir.Append("_out");
235 plugin->SetGridOutputDir(outputDir.Data());
237 // Write to a single folder
238 plugin->SetOutputSingleFolder(outputDir.Data());
239 plugin->SetOutputToRunNo();
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());
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());
254 plugin->EnablePackage("STEERBase");
255 plugin->EnablePackage("ESD");
256 plugin->EnablePackage("AOD");
257 plugin->EnablePackage("ANALYSIS");
258 plugin->EnablePackage("ANALYSISalice");
259 plugin->EnablePackage("PWG2forward2");
262 // No need for output file names. Procedure is automatic.
263 // It's works better this way
264 plugin->SetDefaultOutputs(kTRUE);
266 // Set a name for the generated analysis macro (default MyAnalysis.C).
267 // Make this unique !!!
268 TString macroName(anaName);
269 macroName += "Task.C";
270 plugin->SetAnalysisMacro(macroName.Data());
272 // Optionally set maximum number of input files/subjob (default 100,
274 plugin->SetSplitMaxInputFileNumber(100);
276 // Optionally set number of failed jobs that will trigger killing
278 plugin->SetMaxInitFailed(5);
280 // Optionally resubmit threshold.
281 plugin->SetMasterResubmitThreshold(90);
283 // Optionally set time to live (default 30000 sec)
284 plugin->SetTTL(20000);
286 // Optionally set input format (default xml-single)
287 plugin->SetInputFormat("xml-single");
289 // Optionally modify the name of the generated JDL (default analysis.jdl)
290 TString jdlName(anaName);
291 jdlName.Append(".jdl");
292 plugin->SetJDLName(jdlName.Data());
294 // Optionally modify job price (default 1)
297 // Optionally modify split mode (default 'se')
298 plugin->SetSplitMode("se");
300 // connect to manager
301 // AliAnalysisManager* mgr = AliAnalysisManager::Instance();
302 // mgr->SetGridHandler(plugin);
307 //____________________________________________________________________