2 * Build (compile) a train script
4 * @param script Script to compile
5 * @param extra Extra stuff for AcLic ("", "+", or "+g")
6 * @param useTmp Use a temporary file
10 * @ingroup pwglf_forward_trains
13 BuildTrain(const char* script, const char* extra="", Bool_t useTmp=false)
15 // --- Load needed libraries ---------------------------------------
16 gROOT->LoadClass("TAlien", "libRAliEn");
17 gROOT->LoadClass("TVirtualMC", "libVMC");
18 gROOT->LoadClass("AliVEvent", "libSTEERBase");
19 gROOT->LoadClass("AliESDEvent", "libESD");
20 gROOT->LoadClass("AliAnalysisManager", "libANALYSIS");
21 gROOT->LoadClass("AliAnalysisTaskSE", "libANALYSISalice");
22 gROOT->LoadClass("AliAODForwardMult", "libPWGLFforward2");
24 // --- Setup script path -------------------------------------------
25 const char* aliPath = gSystem->ExpandPathName("$ALICE_ROOT");
26 const char* fwd2Path =
27 gSystem->ExpandPathName("$ALICE_ROOT/PWGLF/FORWARD/analysis2");
28 const char* macroPath = gROOT->GetMacroPath();
29 gROOT->SetMacroPath(Form(".:%s:%s/trains:%s/scripts",
30 macroPath,fwd2Path,fwd2Path));
32 // --- Setup include path ------------------------------------------
33 gSystem->AddIncludePath(Form("-I%s", fwd2Path));
34 gSystem->AddIncludePath(Form("-I%s/trains", fwd2Path));
35 gSystem->AddIncludePath(Form("-I%s", aliPath));
36 gSystem->AddIncludePath(Form("-I%s/include", aliPath));
38 // --- Check that we can find the script ---------------------------
39 TString path = gSystem->Which(gROOT->GetMacroPath(), script);
41 path = gSystem->Which(gROOT->GetMacroPath(), Form("%s.C", script));
43 Error("BuildTrain", "Cannot find script %s or %s.C in %s",
44 script, script, gROOT->GetMacroPath());
49 // --- Compile TrainSetup.C ----------------------------------------
50 Int_t ret = gROOT->LoadMacro(Form("%s/trains/TrainSetup.C+%s",
53 Error("BuildTrain", "Failed to build TrainSetup");
57 // --- Possibly make a temporary copy ------------------------------
60 FILE* fp = gSystem->TempFileName(tmp, ".");
65 gSystem->CopyFile(path, tmp);
69 // --- Now compile the thing ---------------------------------------
70 ret = gROOT->LoadMacro(Form("%s+%s", path.Data(), extra));
72 // --- If we did a temporary file, remove stuff --------------------
74 gSystem->Unlink(path);
75 path.ReplaceAll(".C", "_C.d"); gSystem->Unlink(path);
76 path.ReplaceAll("_C.d", "_C.so"); gSystem->Unlink(path);
79 // --- Warning in case of problems ---------------------------------
81 Warning("BuildSetup", "Failed to build %s (%s)", path.Data(), script);