]>
Commit | Line | Data |
---|---|---|
fdfd93b4 | 1 | /** |
2 | * @file RunTrain.C | |
3 | * @author Christian Holm Christensen <cholm@nbi.dk> | |
4 | * @date Tue Oct 16 17:49:49 2012 | |
5 | * | |
6 | * @brief Script to run a train | |
7 | * | |
8 | * @ingroup pwglf_forward_trains | |
9 | */ | |
10 | /** | |
11 | * Build a script | |
12 | * | |
13 | * @param name Name of script | |
14 | * @param verbose Whether to be verbose | |
15 | * @param force Whether to force re-compilation | |
16 | * @param debug Whether to enable debug symbols | |
17 | * | |
18 | * @return true on success | |
19 | * | |
20 | * @ingroup pwglf_forward_trains | |
21 | */ | |
22 | Bool_t | |
23 | BuildScript(const char* name, Bool_t verbose, Bool_t force, Bool_t debug) | |
24 | { | |
25 | const char opt[] = { (force ? '+' : debug ? 'g' : '\0'), | |
26 | (force && debug ? 'g' : '\0'), '\0' }; | |
27 | if (verbose) Printf("Building %s ...",name); | |
28 | Int_t error; | |
29 | Int_t ret = gROOT->LoadMacro(Form("%s.C+%s", name, opt), &error); | |
30 | if (ret < 0 || error) { | |
31 | Error("BuildScript", "Failed to build %s: %d", error); | |
32 | return false; | |
33 | } | |
34 | return true; | |
35 | ||
36 | } | |
37 | ||
38 | /** | |
39 | * Build all helper classes | |
40 | * | |
41 | * @param verbose Whether to be verbose | |
42 | * @param force Whether to force re-builds | |
43 | * @param debug Whether to enable debug symbols | |
44 | * | |
45 | * @return true on success | |
46 | * | |
47 | * @ingroup pwglf_forward_trains | |
48 | */ | |
49 | Bool_t | |
46b25775 | 50 | BuildHelpers(Bool_t verbose, Bool_t force, Bool_t debug, |
51 | Bool_t all=false) | |
fdfd93b4 | 52 | { |
53 | gSystem->AddIncludePath("-I$ALICE_ROOT/include"); | |
54 | gSystem->Load("libANALYSIS"); | |
55 | gSystem->Load("libANALYSISalice"); | |
56 | const char* scripts[] = { "AvailableSoftware", | |
57 | "ChainBuilder", | |
58 | "ParUtilities", | |
59 | "OutputUtilities", | |
60 | "Option", | |
61 | "Helper", | |
46b25775 | 62 | "TrainSetup", |
63 | (all ? "LocalHelper" : 0), | |
fdfd93b4 | 64 | "ProofHelper", |
46b25775 | 65 | "LiteHelper", |
fdfd93b4 | 66 | "AAFHelper", |
46b25775 | 67 | "PluginHelper", |
fdfd93b4 | 68 | "AAFPluginHelper", |
46b25775 | 69 | "GridHelper", |
fdfd93b4 | 70 | 0 }; |
71 | const char** ptr = scripts; | |
72 | while ((*ptr)) { | |
73 | if (!BuildScript(*ptr, verbose, force, debug)) return false; | |
74 | ptr++; | |
75 | } | |
76 | return true; | |
77 | } | |
78 | ||
79 | /** | |
80 | * Show the usage | |
81 | * | |
82 | * | |
83 | * @ingroup pwglf_forward_trains | |
84 | */ | |
85 | void PlainUsage() | |
86 | { | |
87 | std::cout << "Usage: .x RunTrain.C(NAME,CLASS,OPTIONS)\n\n" | |
88 | << " NAME Name of train (free form)\n" | |
89 | << " CLASS Name of class implementing TrainSetup\n" | |
90 | << " OPTIONS Comma separated list of options\n" | |
91 | << std::endl; | |
92 | } | |
93 | ||
94 | /** | |
95 | * Function to run a train. | |
96 | * | |
97 | * @param name Name of the train. | |
98 | * @param cls class name of train setup | |
99 | * @param opts Optons | |
100 | * | |
101 | * @return true on success | |
102 | * | |
103 | * @ingroup pwglf_forward_trains | |
104 | */ | |
105 | Bool_t RunTrain(const TString& name, const TString& cls, | |
106 | const TString& uri, const TString& opts) | |
107 | { | |
108 | // Check for help | |
109 | if (name.IsNull() || name.EqualTo("help", TString::kIgnoreCase) || | |
46b25775 | 110 | cls.IsNull() || cls.EqualTo("help", TString::kIgnoreCase) || |
111 | uri.IsNull()) { | |
fdfd93b4 | 112 | PlainUsage(); |
113 | return true; | |
114 | } | |
115 | ||
116 | Bool_t verb = opts.Contains("verbose"); | |
117 | // Build our helpers | |
118 | if (!BuildHelpers(verb, false, true)) return false; | |
119 | ||
120 | // Tokenize options | |
121 | if (!opts.EndsWith(",")) opts.Append(","); | |
122 | opts.Append("url="); | |
123 | opts.Append(uri); | |
124 | TObjArray* optList = opts.Tokenize(","); | |
46b25775 | 125 | return TrainSetup::Main(name, cls, optList, false); |
fdfd93b4 | 126 | } |
127 | /* | |
128 | * EOF | |
129 | */ | |
130 |