Updates to Trains. create a job-script to help
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / IdentifiedHighPt / grid / CreateAlienHandler.C
CommitLineData
4ebdd20e 1void SetDataFromConfigFile(AliAnalysisAlien *plugin, const char* filename, Int_t AnalysisMC, Bool_t esdAna, Int_t nMaxRuns);
2
3
4//AliAnalysisGrid* CreateAlienHandler(Int_t nFiles, Bool_t AnalysisMC, Int_t runtype, const char* taskname, const char* mode)
5AliAnalysisGrid* CreateAlienHandler(Int_t nMaxRuns, Int_t AnalysisMC, Bool_t esdAna, const char* taskname, const char* nameoutputs, const char* mode, const char* label, const char* alirootver, Int_t task_num)
6{
7
8 AliAnalysisAlien *plugin = new AliAnalysisAlien();
9
10 plugin->SetRunMode(mode);
11
12 // Set versions of used packages
13 plugin->SetAPIVersion("V1.1x");
14 plugin->SetROOTVersion("v5-30-06");
15 plugin->SetAliROOTVersion(alirootver);
16
17 Char_t configfile[64];
18 sprintf(configfile,"%s.conf",label);
19
20 cout << "Configuration file: " << configfile << endl;
21
22 if(AnalysisMC){
23 if(esdAna)
24 sprintf(label, "%s_MC_ESDs_%d", label, AnalysisMC);
25 else
26 sprintf(label, "%s_MC_AODs_%d", label, AnalysisMC);
27 }
28 else{
29 if(esdAna)
30 sprintf(label, "%s_Data_ESDs", label);
31 else
32 sprintf(label, "%s_Data_AODs", label);
33 }
34 cout << "Label: " << label << endl;
35
36 // output to run numbers
37 plugin->SetOutputToRunNo();
38
39 SetDataFromConfigFile(plugin, configfile, AnalysisMC, esdAna, nMaxRuns);
40
41 // sprintf(outputfiles,"%s_%s.root %sDebug.root",taskname,label,taskname);
42 //Char_t outputfiles[256];
43 //sprintf(outputfiles,"%s_Tree.root",taskname);
44
45// Method 2: Declare existing data files (raw collections, xml
46// collections, root file) If no path mentioned data is supposed to be
47// in the work directory (see SetGridWorkingDir()) XML collections
48// added via this method can be combined with the first method if the
49// content is compatible (using or not tags)
50// plugin->AddDataFile("tag.xml");
51// plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
52
53
54// Define alien work directory where all files will be copied. Relative to alien $HOME.
55 Char_t tmpname[128];
56 sprintf(tmpname,"work_%s_%s",taskname,label);
57 plugin->SetGridWorkingDir(tmpname);
58
59 // Declare alien output directory. Relative to working directory.
60 plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output
61
62 // Declare the analysis source files names separated by blancs. To be compiled runtime
63 // using ACLiC on the worker nodes.
64 plugin->AddIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include");
65 Char_t anasource[256];
66 if(task_num!=4){
67 sprintf(anasource, "DebugClasses.C AliAnalysisTask%s.cxx", taskname);
68 }
69 else{
70 sprintf(anasource, "DebugClasses.C AliAnalysisTask%s.cxx AliAnalysisTask%sV0.cxx", taskname, taskname);
71 }
72 plugin->SetAnalysisSource(anasource);
73
74 // Declare all libraries (other than the default ones for the framework. These will be
75 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
76 Char_t addlib[256];
77 if(task_num!=4){
78 sprintf(addlib, "DebugClasses.C AliAnalysisTask%s.h AliAnalysisTask%s.cxx", taskname, taskname);
79 }else{
80 sprintf(addlib, "DebugClasses.C AliAnalysisTask%s.h AliAnalysisTask%s.cxx AliAnalysisTask%sV0.h AliAnalysisTask%sV0.cxx", taskname, taskname, taskname, taskname);
81 }
82 plugin->SetAdditionalLibs(addlib);
83
84 // Declare the output file names separated by blancs.
85 // (can be like: file.root or file.root@ALICE::Niham::File)
86 plugin->SetDefaultOutputs(kFALSE);
87 plugin->SetOutputFiles(nameoutputs);
88
89 //plugin->SetMergeViaJDL(kTRUE);
90
91
92
93 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
94 sprintf(tmpname,"macro_%s_%s.C",taskname,label);
95 plugin->SetAnalysisMacro(tmpname);
96
97// Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
98 plugin->SetSplitMaxInputFileNumber(100);
99
100// Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
101 plugin->SetMaxInitFailed(500);
102
103 // Optionally resubmit threshold.
104 plugin->SetMasterResubmitThreshold(90);
105
106 // Optionally set time to live (default 30000 sec)
107 // plugin->SetTTL(7200);
108 plugin->SetTTL(30000);
109
110 // Optionally set input format (default xml-single)
111 plugin->SetInputFormat("xml-single");
112
113 // Optionally modify the name of the generated JDL (default analysis.jdl)
114 sprintf(tmpname,"%s_%s.jdl",taskname,label);
115 plugin->SetJDLName(tmpname);
116
117 // Optionally modify the executable name (default analysis.sh)
118 sprintf(tmpname,"%s_%s.sh",taskname,label);
119 plugin->SetExecutable(tmpname);
120
121 // Optionally modify job price (default 1)
122 plugin->SetPrice(1);
123 // Merge via JDL
124 plugin->SetMergeViaJDL(kTRUE);
125 // Use fastread option
126 plugin->SetFastReadOption(kTRUE);
127 // Optionally modify split mode (default 'se')
128 plugin->SetSplitMode("se");
129 plugin->SetExecutableCommand("aliroot -b -q");
130
131
132
133 return plugin;
134}
135
136
137
138
139
140void SetDataFromConfigFile(AliAnalysisAlien *plugin, const char* fileName, Int_t AnalysisMC, Bool_t esdAna, Int_t nMaxRuns)
141{
142
143
144 FILE* file = fopen(fileName,"r");
145 if(!file) {
146 cout << "File " << fileName << " not found!" << endl;
147 return;
148 }
149
150 Char_t dummy[128];
151
152 Char_t runperiodpattern[128];
153 if(AnalysisMC)
154 sprintf(runperiodpattern,"Run period MC%d: %s", AnalysisMC, "%s %s %s");
155 else
156 sprintf(runperiodpattern,"Run period: %s", "%s %s %s");
157
158 cout << "PATTERN: " << runperiodpattern << endl;
159
160 Int_t nRuns = 0;
161 while (fgets(dummy,128,file) != NULL && (nRuns<nMaxRuns||nMaxRuns<=0)) {
162 char runperiod[128], pass[64], aodDir[64];
163 Int_t run, a, b;
164 if(sscanf(dummy, runperiodpattern, &runperiod, &pass, &aodDir)){
165 //if(sscanf(dummy, "Run period: %d %d",&a,&b)){
166 Char_t griddatadir[256];
167 Char_t datapattern[256];
168
169 if(AnalysisMC){
170 sprintf(griddatadir, "/alice/sim/%s", runperiod);
171 if(esdAna) {
172 sprintf(datapattern,"/*/AliESDs.root");
173 } else {
174 sprintf(datapattern,"/%s/*/AliAOD.root", aodDir);
175 }
176 }
177 else{
178 plugin->SetRunPrefix("000");
179 Int_t year = 0;
180 sscanf(runperiod, "LHC%d", &year);
181 sprintf(griddatadir, "/alice/data/20%d/%s", year, runperiod);
182 if(esdAna) {
183 sprintf(datapattern,"*ESDs/%s/*/AliESDs.root",pass);
184 //sprintf(datapattern,"*ESDs/%s/10000121040024.40/AliESDs.root",pass);
185 } else {
186 sprintf(datapattern,"*ESDs/%s/%s/*/AliAOD.root",pass, aodDir);
187 }
188 }
189 cout << "GridDataDir: " << griddatadir << endl;
190 cout << "DataPatter: " << datapattern << endl;
191 plugin->SetGridDataDir(griddatadir);
192 plugin->SetDataPattern(datapattern);
193 continue;
194 }
195 if(sscanf(dummy,"Run: %d %s", &run)){
196 plugin->AddRunNumber(run);
197 nRuns++;
198 continue;
199 }
200 }
201
202
203
204}