-
Notifications
You must be signed in to change notification settings - Fork 32
/
generate.C
162 lines (125 loc) · 5.38 KB
/
generate.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// Macro to generate macros for the ALICE TRAIN
// Authors: Andrea Gheata, Jan Fiete Grosse-Oetringhaus, Costin Grigoras, Markus Zimmermann
//
//
// requires env variables
void generate(const char *module = "__ALL__")
{
Int_t nFiles = 1;//TEST_FILES_NO
Int_t nTestEvents = TString(gSystem->Getenv("TEST_FILES_NO")).Atoi();//for the on the fly trains this contains the number of test events
TString dataBasePath(gSystem->Getenv("TEST_DIR"));//TEST_DIR
TString dataAnchor(gSystem->Getenv("FILE_PATTERN"));//FILE_PATTERN
Int_t splitMaxInputFileNumber = TString(gSystem->Getenv("SPLIT_MAX_INPUT_FILE_NUMBER")).Atoi();//SPLIT_MAX_INPUT_FILE_NUMBER
Int_t maxMergeFiles = TString(gSystem->Getenv("MAX_MERGE_FILES")).Atoi();//MAX_MERGE_FILES
Int_t debugLevel = TString(gSystem->Getenv("DEBUG_LEVEL")).Atoi();//DEBUG_LEVEL
Int_t ttl = TString(gSystem->Getenv("TTL")).Atoi();//TTL
TString excludeFiles(gSystem->Getenv("EXCLUDE_FILES"));//EXCLUDE_FILES
TString additionalpackages(gSystem->Getenv("ADDITIONAL_PACKAGES"));//ADDITIONAL_PACKAGES
//TString dataFolder("/home/mazimmer/Test2/dataFolder");//put here a local directory
TString dataFolder("./");
Int_t AOD = TString(gSystem->Getenv("AOD")).Atoi();//AOD: 0 ESD, 1 AOD, 2 AOD produced together with ESD, 3 Kinematics only, 4 ESD (special WSDD production) 5 ESD cpass1 (Barrel), 6 ESD cpass1 (Outer)
Int_t isPP = strcmp(gSystem->Getenv("PP"), "true"); //0 false, 1 true //PP
TString validOutputFiles = gSystem->Getenv("OUTPUT_FILES");//OUTPUT_FILES
TString periodName(gSystem->Getenv("PERIOD_NAME"));//PERIOD_NAME
const char *train_name="lego_train";
if (strcmp(module, "__ALL__") == 0)
module = "";
gSystem->Load("libANALYSIS");
gSystem->Load("libANALYSISalice");
TObjArray *arr = AliAnalysisTaskCfg::ExtractModulesFrom("MLTrainDefinition.cfg");
Printf(">>>>>>> Read train configuration");
arr->Print();
AliAnalysisAlien *plugin = new AliAnalysisAlien(train_name);
// General plugin settings here
plugin->SetProductionMode();
plugin->SetAPIVersion("V1.1x");
// libraries because we start with root!
plugin->SetAdditionalRootLibs("libVMC.so libPhysics.so libTree.so libMinuit.so libProof.so libSTEERBase.so libESD.so libAOD.so");
plugin->SetJobTag("test/test");
plugin->SetMaxMergeFiles(maxMergeFiles);
plugin->SetTTL(ttl);
plugin->SetAnalysisMacro(Form("%s.C", train_name));
plugin->SetValidationScript("validation.sh");
plugin->SetRegisterExcludes(excludeFiles + " AliAOD.root");
// jemalloc
additionalpackages += " jemalloc::v3.0.0";
plugin->AddExternalPackage(additionalpackages);
// plugin->SetExecutableCommand("root -b -q");
plugin->SetJDLName(Form("%s.jdl", train_name));
plugin->SetExecutable(Form("%s.sh", train_name));
plugin->SetSplitMode("se");
plugin->SetGridOutputDir("./");
plugin->SetGridWorkingDir("./");
plugin->SetKeepLogs(kTRUE);
plugin->SetMergeViaJDL();
if (dataFolder.Length() == 0)
{
Printf("ERROR: TRAIN_TESTDATA not set. Exiting...");
return;
}
if (dataBasePath.Length() > 0)
{
TString archiveName = "root_archive.zip";
if (AOD == 2)
archiveName = "aod_archive.zip";
TString dataFileName("data.txt");
plugin->SetFileForTestMode(Form("%s/%s", dataFolder.Data(), dataFileName.Data()));
plugin->SetNtestFiles(nFiles);
// Is MC only?
if (AOD == 3)
{
Printf(">>>> Expecting MC only production");
plugin->SetUseMCchain();
}
}
// Load modules here
plugin->AddModules(arr);
plugin->CreateAnalysisManager("train","handlers.C");
// specific if data is processed or MC is generated on the fly
if (atoi(gSystem->Getenv("AOD")) == 100) { // MC production
Long64_t totalEvents = TString(gSystem->Getenv("GEN_TOTAL_EVENTS")).Atoll();
Long64_t neededJobs = totalEvents / splitMaxInputFileNumber;
plugin->SetMCLoop(true);
plugin->SetSplitMode(Form("production:1-%d", neededJobs));
plugin->SetNMCjobs(neededJobs);
plugin->SetNMCevents(nTestEvents);
plugin->SetExecutableCommand("aliroot -b -q");
plugin->SetKeepLogs(kTRUE);
} else { // Data, ESD/AOD
plugin->SetSplitMaxInputFileNumber(splitMaxInputFileNumber);
plugin->SetExecutableCommand("root -b -q");
plugin->SetInputFormat("xml-single");
}
AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
mgr->SetDebugLevel(debugLevel);
mgr->SetNSysInfo((isPP == 1) ? 1000 : 40);
mgr->SetFileInfoLog("fileinfo.log");
// execute custom configuration
Int_t error = 0;
gROOT->Macro("globalvariables.C", &error);
if (error != 0)
{
Printf("ERROR: globalvariables.C was not executed successfully...");
return;
}
plugin->GenerateTest(train_name, module);
// check for illegally defined output files
validOutputFiles += "," + excludeFiles;
TString outputFiles = plugin->GetListOfFiles("out");
tokens = outputFiles.Tokenize(",");
Bool_t valid = kTRUE;
for (Int_t i=0; i<tokens->GetEntries(); i++)
{
if (!validOutputFiles.Contains(tokens->At(i)->GetName()))
{
Printf("ERROR: Output file %s requested which is not among the defined ones for this train (%s)", tokens->At(i)->GetName(), validOutputFiles.Data());
valid = kFALSE;
}
}
delete tokens;
if (!valid)
{
Printf(">>>>>>>>> Invalid output files requested. <<<<<<<<<<<<");
gSystem->Unlink("lego_train.C");
}
}