]>
Commit | Line | Data |
---|---|---|
1afce1ce | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | // | |
17 | // AliMuonAccEffSubmitter : a class to help submit Acc x Eff simulations | |
18 | // anchored to real runs for J/psi, upsilon, single muons, etc... | |
19 | // | |
20 | // This class is dealing with 3 different directories : | |
21 | // | |
22 | // - template directory ($ALICE_ROOT/PWG/muondep/AccEffTemplates) containing the | |
23 | // basic template files to be used for a simuation. A template can contain | |
24 | // some variables that will be replaced during during the copy from template | |
25 | // to local dir | |
26 | // | |
27 | // - local directory, where the files from the template directory, are copied | |
28 | // once the class has been configured properly (i.e. using the various Set, Use, | |
29 | // etc... methods). Some other files (e.g. JDL ones) are generated from | |
30 | // scratch and also copied into this directory. | |
31 | // At this point one could(should) check the files, as they are the ones | |
32 | // to be copied to the remote directory for the production | |
33 | // | |
34 | // - remote directory, the alien directory where the files will be copied | |
35 | // (from the local directory) before the actual submission | |
36 | // | |
37 | // ========================================================== | |
38 | // | |
39 | // Basic usage | |
40 | // | |
30138a88 | 41 | // AliMuonAccEffSubmitter a; // (1) |
1afce1ce | 42 | // a.UseOCDBSnapshots(kFALSE); |
43 | // a.SetRemoteDir("/alice/cern.ch/user/l/laphecet/Analysis/LHC13d/simjpsi/pp503z0"); | |
44 | // a.ShouldOverwriteFiles(true); | |
45 | // a.MakeNofEventsPropToTriggerCount("CMUL7-B-NOPF-MUON"); | |
46 | // a.SetVar("VAR_GENLIB_PARNAME","\"pp 5.03\""); | |
47 | // a.SetRunList(195682); | |
48 | // a.Print(); | |
49 | // a.Run("test"); // will do everything but the submit | |
50 | // a.Submit(false); // actual submission | |
51 | // | |
30138a88 | 52 | // (1) note that for this to work in the Root prompt you need to load (for instance |
53 | // in your rootlogon.C) all the chain of libraries up to libPWGmuondep. As | |
54 | // the time of this writing (March 2014), this means : | |
1afce1ce | 55 | // |
30138a88 | 56 | // gSystem->Load("libVMC"); |
57 | // gSystem->Load("libTree"); | |
58 | // gSystem->Load("libProofPlayer"); | |
59 | // gSystem->Load("libPhysics"); | |
60 | // gSystem->Load("libMatrix"); | |
61 | // gSystem->Load("libMinuit"); | |
62 | // gSystem->Load("libXMLParser"); | |
63 | // gSystem->Load("libGui"); | |
64 | // gSystem->Load("libSTEERBase"); | |
65 | // gSystem->Load("libESD"); | |
66 | // gSystem->Load("libAOD"); | |
67 | // gSystem->Load("libANALYSIS"); | |
68 | // gSystem->Load("libRAWDatabase"); | |
69 | // gSystem->Load("libCDB"); | |
70 | // gSystem->Load("libSTEER"); | |
71 | // gSystem->Load("libANALYSISalice"); | |
72 | // gSystem->Load("libCORRFW"); | |
73 | // gSystem->Load("libPWGmuon"); | |
74 | // gSystem->Load("libMUONcore"); | |
75 | // gSystem->Load("libMUONmapping"); | |
76 | // gSystem->Load("libMUONcalib"); | |
77 | // gSystem->Load("libMUONgeometry"); | |
78 | // gSystem->Load("libMUONtrigger"); | |
79 | // gSystem->Load("libRAWDatabase"); | |
80 | // gSystem->Load("libMUONraw"); | |
81 | // gSystem->Load("libMUONbase"); | |
82 | // gSystem->Load("libMUONshuttle"); | |
83 | // gSystem->Load("libMUONrec"); | |
84 | // gSystem->Load("libPWGmuondep"); | |
85 | // | |
86 | // author: Laurent Aphecetche (Subatech) | |
1afce1ce | 87 | // |
88 | ||
a58729a5 | 89 | #include "AliMuonAccEffSubmitter.h" |
90 | ||
91 | #include "AliAnalysisTriggerScalers.h" | |
92 | #include "AliLog.h" | |
93 | #include "TFile.h" | |
94 | #include "TGrid.h" | |
95 | #include "TGridResult.h" | |
96 | #include "TMap.h" | |
97 | #include "TMath.h" | |
98 | #include "TObjString.h" | |
1afce1ce | 99 | #include "TROOT.h" |
a58729a5 | 100 | #include "TString.h" |
101 | #include "TSystem.h" | |
102 | #include <vector> | |
c2aad3ae | 103 | #include <fstream> |
104 | using std::ifstream; | |
a58729a5 | 105 | namespace |
106 | { | |
107 | Int_t splitLevel=10; | |
108 | } | |
109 | ||
81190958 | 110 | ClassImp(AliMuonAccEffSubmitter) |
111 | ||
a58729a5 | 112 | //______________________________________________________________________________ |
30138a88 | 113 | AliMuonAccEffSubmitter::AliMuonAccEffSubmitter(const char* generator, Bool_t localOnly, |
3e7b6e7b | 114 | const char* generatorVersion) |
eb5de7ee | 115 | : AliMuonGridSubmitter(AliMuonGridSubmitter::kAccEff,localOnly), |
81190958 | 116 | fRatio(-1.0), |
1afce1ce | 117 | fFixedNofEvents(10000), |
a58729a5 | 118 | fMaxEventsPerChunk(5000), |
d484adc1 | 119 | fOCDBPath(""), |
a58729a5 | 120 | fSplitMaxInputFileNumber(20), |
121 | fCompactMode(1), | |
a58729a5 | 122 | fExternalConfig(""), |
81190958 | 123 | fUseOCDBSnapshots(kFALSE), |
d484adc1 | 124 | fSnapshotDir(""), |
a3c2a88b | 125 | fUseAODMerging(kFALSE) |
a58729a5 | 126 | { |
127 | // ctor | |
30138a88 | 128 | // |
3e7b6e7b | 129 | // if generator contains "pythia8" and generatorVersion is given then |
130 | // the pythiaversion must represent the integer part XXX of the | |
30138a88 | 131 | // include directory $ALICE_ROOT/PYTHI8/pythiaXXX/include where the file |
132 | // Analysis.h is to be found. | |
3e7b6e7b | 133 | // |
134 | // if generator contains "pythia6" then generatorVersion should be the | |
135 | // X.YY part of libpythia6.X.YY.so | |
136 | // | |
30138a88 | 137 | |
3e7b6e7b | 138 | AddIncludePath("-I$ALICE_ROOT/STEER/STEER -I$ALICE_ROOT/PYTHIA6 -I$ALICE_ROOT/LHAPDF -I$ALICE_ROOT/PWG/muon -I$ALICE_ROOT/PWG/muondep -I$ALICE_ROOT/MUON -I$ALICE_ROOT/include -I$ALICE_ROOT/EVGEN -I$ALICE_ROOT/FASTSIM"); |
a58729a5 | 139 | |
eb5de7ee | 140 | TString ocdbPath("raw://"); |
141 | ||
142 | if (localOnly) { | |
143 | ocdbPath = "local://$ALICE_ROOT/OCDB"; | |
144 | } | |
145 | ||
146 | SetOCDBPath(ocdbPath.Data()); | |
81190958 | 147 | |
148 | SetLocalDirectory("Snapshot",LocalDir()); | |
a58729a5 | 149 | |
eb5de7ee | 150 | SetVar("VAR_OCDB_PATH",Form("\"%s\"",ocdbPath.Data())); |
1afce1ce | 151 | |
30138a88 | 152 | SetVar("VAR_GENPARAM_INCLUDE","AliGenMUONlib.h"); |
eb5de7ee | 153 | SetVar("VAR_GENPARAM_NPART","1"); |
1afce1ce | 154 | SetVar("VAR_GENPARAM_GENLIB_TYPE","AliGenMUONlib::kJpsi"); |
155 | SetVar("VAR_GENPARAM_GENLIB_PARNAME","\"pPb 5.03\""); | |
156 | ||
157 | SetVar("VAR_GENCORRHF_QUARK","5"); | |
158 | SetVar("VAR_GENCORRHF_ENERGY","5"); | |
159 | ||
a3c2a88b | 160 | // some default values for J/psi |
1afce1ce | 161 | SetVar("VAR_GENPARAMCUSTOM_PDGPARTICLECODE","443"); |
162 | ||
163 | // default values below are from J/psi p+Pb (from muon_calo pass) | |
164 | SetVar("VAR_GENPARAMCUSTOM_Y_P0","4.08E5"); | |
165 | SetVar("VAR_GENPARAMCUSTOM_Y_P1","7.1E4"); | |
166 | ||
167 | SetVar("VAR_GENPARAMCUSTOM_PT_P0","1.13E9"); | |
168 | SetVar("VAR_GENPARAMCUSTOM_PT_P1","18.05"); | |
169 | SetVar("VAR_GENPARAMCUSTOM_PT_P2","2.05"); | |
170 | SetVar("VAR_GENPARAMCUSTOM_PT_P3","3.34"); | |
171 | ||
a3c2a88b | 172 | // some default values for single muons |
173 | SetVar("VAR_GENPARAMCUSTOMSINGLE_PTMIN","0.35"); | |
174 | ||
175 | SetVar("VAR_GENPARAMCUSTOMSINGLE_PT_P0","4.05962"); | |
176 | SetVar("VAR_GENPARAMCUSTOMSINGLE_PT_P1","1.0"); | |
177 | SetVar("VAR_GENPARAMCUSTOMSINGLE_PT_P2","2.46187"); | |
178 | SetVar("VAR_GENPARAMCUSTOMSINGLE_PT_P3","2.08644"); | |
179 | ||
180 | SetVar("VAR_GENPARAMCUSTOMSINGLE_Y_P0","0.729545"); | |
181 | SetVar("VAR_GENPARAMCUSTOMSINGLE_Y_P1","0.53837"); | |
182 | SetVar("VAR_GENPARAMCUSTOMSINGLE_Y_P2","0.141776"); | |
183 | SetVar("VAR_GENPARAMCUSTOMSINGLE_Y_P3","0.0130173"); | |
184 | ||
f9fda76e | 185 | // some default values for GenBox |
186 | ||
187 | SetVar("VAR_GENMUBOX_PTMIN","0"); | |
188 | SetVar("VAR_GENMUBOX_PTMAX","20"); | |
189 | SetVar("VAR_GENMUBOX_YMIN","-4.1"); | |
190 | SetVar("VAR_GENMUBOX_YMAX","-2.4"); | |
191 | ||
30138a88 | 192 | SetVar("VAR_PYTHIA8_CMS_ENERGY","8000"); |
3e7b6e7b | 193 | SetVar("VAR_PYTHIA6_CMS_ENERGY","8000"); |
30138a88 | 194 | |
eb5de7ee | 195 | SetVar("VAR_PURELY_LOCAL",Form("%d",localOnly)); |
196 | ||
8907673b | 197 | SetVar("VAR_SIM_ALIGNDATA","\"alien://folder=/alice/simulation/2008/v4-15-Release/Ideal\""); |
198 | ||
199 | SetVar("VAR_REC_ALIGNDATA","\"alien://folder=/alice/simulation/2008/v4-15-Release/Residual\""); | |
200 | ||
30138a88 | 201 | SetVar("VAR_USE_ITS_RECO","0"); |
202 | ||
81190958 | 203 | UseOCDBSnapshots(fUseOCDBSnapshots); |
30138a88 | 204 | |
205 | gSystem->Load("libEVGEN"); | |
206 | ||
3e7b6e7b | 207 | SetVar("VAR_TRIGGER_CONFIGURATION",""); |
208 | ||
209 | SetVar("VAR_PYTHIA8_INCLUDES",""); | |
210 | SetVar("VAR_PYTHIA8_SETENV",""); | |
211 | ||
212 | SetVar("VAR_PYTHIA6_INCLUDES",""); | |
213 | SetVar("VAR_PYTHIA6_SETENV",""); | |
214 | ||
57843125 | 215 | SetVar("VAR_LHAPDF","liblhapdf"); |
216 | SetVar("VAR_MUONMCMODE","1"); | |
217 | ||
30138a88 | 218 | if ( TString(generator).Contains("pythia8",TString::kIgnoreCase) ) |
219 | { | |
220 | fMaxEventsPerChunk = 500; // 5000 is not reasonable with Pythia8 (and ITS+MUON...) | |
221 | ||
222 | fCompactMode = 2; // keep AOD as for the time being the filtering driven from AODtrain.C cannot | |
223 | // add SPD tracklets to muon AODs. | |
224 | ||
225 | SetVar("VAR_USE_ITS_RECO","1"); | |
226 | ||
3e7b6e7b | 227 | if (gSystem->AccessPathName(gSystem->ExpandPathName(Form("$ALICE_ROOT/PYTHIA8/pythia%s",generatorVersion)))) |
30138a88 | 228 | { |
3e7b6e7b | 229 | AliError(Form("Directory -I$ALICE_ROOT/PYTHIA8/pythia%s/include not found",generatorVersion)); |
30138a88 | 230 | Invalidate(); |
231 | return; | |
232 | } | |
3e7b6e7b | 233 | AddIncludePath(Form("-I$ALICE_ROOT/PYTHIA8 -I$ALICE_ROOT/PYTHIA8/pythia%s/include",generatorVersion)); |
30138a88 | 234 | // SetVar("VAR_PYTHIA8_VERSION",Form("\"%d\"",pythia8version)); |
235 | ||
3e7b6e7b | 236 | SetVar("VAR_PYTHIA8_INCLUDES",Form("gSystem->AddIncludePath(\"-I$ALICE_ROOT/PYTHIA6 -I$ALICE_ROOT/STEER/STEER -I$ALICE_ROOT/LHAPDF -I$ALICE_ROOT/PYTHIA8 -I$ALICE_ROOT/PYTHIA8/pythia%s/include\");\n",generatorVersion)); |
30138a88 | 237 | |
238 | TString p8env; | |
239 | ||
3e7b6e7b | 240 | p8env += Form(" gSystem->Setenv(\"PYTHIA8DATA\", gSystem->ExpandPathName(\"$ALICE_ROOT/PYTHIA8/pythia%s/xmldoc\"));\n",generatorVersion); |
30138a88 | 241 | |
242 | p8env += " gSystem->Setenv(\"LHAPDF\",gSystem->ExpandPathName(\"$ALICE_ROOT/LHAPDF\"));\n"; | |
243 | ||
244 | p8env += " gSystem->Setenv(\"LHAPATH\",gSystem->ExpandPathName(\"$ALICE_ROOT/LHAPDF/PDFsets\"));\n"; | |
245 | ||
246 | SetVar("VAR_PYTHIA8_SETENV",p8env.Data()); | |
247 | ||
248 | gSystem->Load("libFASTSIM"); | |
249 | gSystem->Load("liblhapdf"); // Parton density functions | |
250 | gSystem->Load("libEGPythia6"); // TGenerator interface | |
3e7b6e7b | 251 | // gSystem->Load("libpythia6"); // Pythia 6.2 |
30138a88 | 252 | gSystem->Load("libAliPythia6"); // ALICE specific implementations |
3e7b6e7b | 253 | gSystem->Load("libpythia8"); |
254 | gSystem->Load("libAliPythia8"); | |
255 | ||
256 | SetVar("VAR_PYTHIA8_SETUP_STRINGS","\"\""); | |
257 | ||
258 | SetVar("VAR_TRIGGER_CONFIGURATION","p-p"); | |
30138a88 | 259 | } |
3e7b6e7b | 260 | |
261 | if ( TString(generator).Contains("pythia6",TString::kIgnoreCase) ) | |
30138a88 | 262 | { |
3e7b6e7b | 263 | fMaxEventsPerChunk = 500; // 5000 is not reasonable with Pythia6 (and ITS+MUON...) |
264 | ||
265 | fCompactMode = 2; // keep AOD as for the time being the filtering driven from AODtrain.C cannot | |
266 | // add SPD tracklets to muon AODs. | |
267 | ||
268 | gSystem->Load("libFASTSIM"); | |
269 | gSystem->Load("liblhapdf"); // Parton density functions | |
270 | gSystem->Load("libEGPythia6"); // TGenerator interface | |
271 | gSystem->Load(Form("libpythia6.%s",generatorVersion)); | |
272 | gSystem->Load("libAliPythia6"); | |
273 | ||
274 | SetVar("VAR_PYTHIA6_INCLUDES","gSystem->AddIncludePath(\"-I$ALICE_ROOT/PYTHIA6 -I$ALICE_ROOT/STEER/STEER -I$ALICE_ROOT/STEER/STEERBase -I$ALICE_ROOT/LHAPDF -I$ALICE_ROOT/FASTSIM\");"); | |
275 | ||
276 | TString p6env; | |
277 | ||
278 | p6env += Form("gSystem->Load(\"libpythia6.%s\");",generatorVersion); | |
279 | ||
280 | SetVar("VAR_PYTHIA6_SETENV",p6env.Data()); | |
281 | ||
282 | SetVar("VAR_USE_ITS_RECO","1"); | |
283 | ||
284 | SetVar("VAR_TRIGGER_CONFIGURATION","p-p"); | |
30138a88 | 285 | } |
3e7b6e7b | 286 | |
1afce1ce | 287 | SetGenerator(generator); |
1afce1ce | 288 | |
30138a88 | 289 | if (localOnly) |
290 | { | |
291 | MakeNofEventsFixed(10); | |
292 | } | |
293 | else | |
294 | { | |
295 | MakeNofEventsPropToTriggerCount(); | |
296 | } | |
1afce1ce | 297 | |
81190958 | 298 | AddToTemplateFileList("CheckESD.C"); |
299 | AddToTemplateFileList("CheckAOD.C"); | |
300 | AddToTemplateFileList("AODtrain.C"); | |
301 | AddToTemplateFileList("validation.sh"); | |
1afce1ce | 302 | |
81190958 | 303 | AddToTemplateFileList("Config.C"); |
304 | AddToTemplateFileList("rec.C"); | |
305 | AddToTemplateFileList("sim.C"); | |
306 | AddToTemplateFileList("simrun.C"); | |
307 | AddToTemplateFileList(RunJDLName().Data()); | |
1afce1ce | 308 | |
81190958 | 309 | UseExternalConfig(fExternalConfig); |
1afce1ce | 310 | } |
311 | ||
a58729a5 | 312 | //______________________________________________________________________________ |
81190958 | 313 | AliMuonAccEffSubmitter::~AliMuonAccEffSubmitter() |
a58729a5 | 314 | { |
81190958 | 315 | // dtor |
a58729a5 | 316 | } |
317 | ||
81190958 | 318 | ///______________________________________________________________________________ |
319 | Bool_t AliMuonAccEffSubmitter::Generate(const char* jdlname) const | |
a58729a5 | 320 | { |
81190958 | 321 | if ( TString(jdlname).Contains("merge",TString::kIgnoreCase) ) |
a58729a5 | 322 | { |
81190958 | 323 | return GenerateMergeJDL(jdlname); |
a58729a5 | 324 | } |
325 | else | |
326 | { | |
81190958 | 327 | return GenerateRunJDL(jdlname); |
a58729a5 | 328 | } |
a58729a5 | 329 | } |
330 | ||
331 | ///______________________________________________________________________________ | |
81190958 | 332 | Bool_t AliMuonAccEffSubmitter::GenerateMergeJDL(const char* name) const |
a58729a5 | 333 | { |
1afce1ce | 334 | /// Create the JDL for merging jobs |
335 | /// FIXME: not checked ! | |
336 | ||
337 | AliDebug(1,""); | |
338 | ||
a58729a5 | 339 | std::ostream* os = CreateJDLFile(name); |
340 | ||
341 | if (!os) | |
342 | { | |
343 | return kFALSE; | |
344 | } | |
345 | ||
346 | Bool_t final = TString(name).Contains("merge",TString::kIgnoreCase); | |
347 | ||
348 | (*os) << "# Generated merging jdl (production mode)" << std::endl | |
349 | << "# $1 = run number" << std::endl | |
350 | << "# $2 = merging stage" << std::endl | |
351 | << "# Stage_<n>.xml made via: find <OutputDir> *Stage<n-1>/*root_archive.zip" << std::endl; | |
352 | ||
81190958 | 353 | OutputToJDL(*os,"Packages", |
354 | GetMapValue("AliRoot"), | |
355 | GetMapValue("Geant3"), | |
356 | GetMapValue("Root"), | |
357 | GetMapValue("API")); | |
a58729a5 | 358 | |
81190958 | 359 | OutputToJDL(*os,"Executable","AOD_merge.sh"); |
a58729a5 | 360 | |
81190958 | 361 | OutputToJDL(*os,"Price","1"); |
a58729a5 | 362 | |
363 | if ( final ) | |
364 | { | |
81190958 | 365 | OutputToJDL(*os,"Jobtag","comment: AliMuonAccEffSubmitter final merging"); |
a58729a5 | 366 | } |
367 | else | |
368 | { | |
81190958 | 369 | OutputToJDL(*os,"Jobtag","comment: AliMuonAccEffSubmitter merging stage $2"); |
a58729a5 | 370 | } |
371 | ||
81190958 | 372 | OutputToJDL(*os,"Workdirectorysize","5000MB"); |
a58729a5 | 373 | |
81190958 | 374 | OutputToJDL(*os,"Validationcommand",Form("%s/validation_merge.sh",RemoteDir().Data())); |
a58729a5 | 375 | |
3e7b6e7b | 376 | OutputToJDL(*os,"TTL","14400"); |
30138a88 | 377 | |
81190958 | 378 | OutputToJDL(*os,"OutputArchive", |
a58729a5 | 379 | "log_archive.zip:stderr,stdout@disk=1", |
380 | "root_archive.zip:AliAOD.root,AliAOD.Muons.root,AnalysisResults.root@disk=3" | |
381 | ); | |
382 | ||
81190958 | 383 | OutputToJDL(*os,"Arguments",(final ? "2":"1")); // for AOD_merge.sh, 1 means intermediate merging stage, 2 means final merging |
a58729a5 | 384 | |
385 | if ( !final ) | |
386 | { | |
81190958 | 387 | OutputToJDL(*os,"InputFile",Form("LF:%s/AODtrain.C",RemoteDir().Data())); |
388 | OutputToJDL(*os,"OutputDir",Form("%s/$1/Stage_$2/#alien_counter_03i#",RemoteDir().Data())); | |
389 | OutputToJDL(*os,"InputDataCollection",Form("%s/$1/Stage_$2.xml,nodownload",RemoteDir().Data())); | |
390 | OutputToJDL(*os,"split","se"); | |
391 | OutputToJDL(*os,"SplitMaxInputFileNumber",GetSplitMaxInputFileNumber()); | |
392 | OutputToJDL(*os,"InputDataListFormat","xml-single"); | |
393 | OutputToJDL(*os,"InputDataList","wn.xml"); | |
a58729a5 | 394 | } |
395 | else | |
396 | { | |
81190958 | 397 | OutputToJDL(*os,"InputFile",Form("LF:%s/AODtrain.C",RemoteDir().Data()), |
398 | Form("LF:%s/$1/wn.xml",RemoteDir().Data())); | |
399 | OutputToJDL(*os,"OutputDir",Form("%s/$1",RemoteDir().Data())); | |
a58729a5 | 400 | } |
401 | ||
402 | return kTRUE; | |
403 | } | |
404 | ||
405 | //______________________________________________________________________________ | |
81190958 | 406 | Bool_t AliMuonAccEffSubmitter::GenerateRunJDL(const char* name) const |
a58729a5 | 407 | { |
408 | /// Generate (locally) the JDL to perform the simulation+reco+aod filtering | |
409 | /// (to be then copied to the grid and finally submitted) | |
410 | ||
1afce1ce | 411 | AliDebug(1,""); |
412 | ||
a58729a5 | 413 | std::ostream* os = CreateJDLFile(name); |
414 | ||
415 | if (!os) | |
416 | { | |
417 | return kFALSE; | |
418 | } | |
419 | ||
81190958 | 420 | OutputToJDL(*os,"Packages", |
421 | GetMapValue("AliRoot"), | |
422 | GetMapValue("Geant3"), | |
423 | GetMapValue("Root"), | |
424 | GetMapValue("API")); | |
425 | ||
426 | OutputToJDL(*os,"Jobtag","comment: AliMuonAccEffSubmitter RUN $1"); | |
a58729a5 | 427 | |
81190958 | 428 | OutputToJDL(*os,"split","production:1-$2"); |
a58729a5 | 429 | |
81190958 | 430 | OutputToJDL(*os,"Price","1"); |
a58729a5 | 431 | |
81190958 | 432 | OutputToJDL(*os,"OutputDir",Form("%s/$1/#alien_counter_03i#",RemoteDir().Data())); |
a58729a5 | 433 | |
81190958 | 434 | OutputToJDL(*os,"Executable","/alice/bin/aliroot_new"); |
a58729a5 | 435 | |
436 | TObjArray files; | |
437 | files.SetOwner(kTRUE); | |
670f3174 | 438 | TIter next(LocalFileList()); |
a58729a5 | 439 | TObjString* file; |
440 | ||
441 | while ( ( file = static_cast<TObjString*>(next())) ) | |
442 | { | |
443 | if ( !file->String().Contains(".jdl",TString::kIgnoreCase) || | |
444 | !file->String().Contains("OCDB_") ) | |
445 | { | |
81190958 | 446 | files.Add(new TObjString(Form("LF:%s/%s",RemoteDir().Data(),file->String().Data()))); |
a58729a5 | 447 | } |
448 | } | |
449 | ||
450 | if ( fUseOCDBSnapshots ) | |
451 | { | |
81190958 | 452 | files.Add(new TObjString(Form("LF:%s/OCDB/$1/OCDB_sim.root",RemoteDir().Data()))); |
453 | files.Add(new TObjString(Form("LF:%s/OCDB/$1/OCDB_rec.root",RemoteDir().Data()))); | |
a58729a5 | 454 | } |
455 | ||
81190958 | 456 | OutputToJDL(*os,"InputFile",files); |
a58729a5 | 457 | |
458 | if ( CompactMode() == 0 ) | |
459 | { | |
460 | // store everything | |
81190958 | 461 | OutputToJDL(*os,"OutputArchive", "log_archive.zip:stderr,stdout,aod.log,checkaod.log,checkesd.log,rec.log,sim.log@disk=1", |
a58729a5 | 462 | "root_archive.zip:galice*.root,Kinematics*.root,TrackRefs*.root,AliESDs.root,AliAOD.root,AliAOD.Muons.root,Merged.QA.Data.root,Run*.root@disk=2"); |
463 | } | |
464 | else if ( CompactMode() == 1 ) | |
465 | { | |
81190958 | 466 | // keep only muon AODs and QA |
3e7b6e7b | 467 | OutputToJDL(*os,"OutputArchive", "log_archive.zip:stderr,stdout,*.log@disk=1", |
81190958 | 468 | "root_archive.zip:galice*.root,AliAOD.Muons.root,Merged.QA.Data.root@disk=2"); |
a58729a5 | 469 | } |
30138a88 | 470 | else if ( CompactMode() == 2 ) |
471 | { | |
472 | // keep only AODs and QA | |
473 | OutputToJDL(*os,"OutputArchive", "log_archive.zip:stderr,stdout,aod.log,checkaod.log,checkesd.log,rec.log,sim.log@disk=1", | |
474 | "root_archive.zip:galice*.root,AliAOD.root,Merged.QA.Data.root@disk=2"); | |
475 | } | |
a58729a5 | 476 | else |
477 | { | |
478 | AliError(Form("Unknown CompactMode %d",CompactMode())); | |
479 | delete os; | |
480 | return kFALSE; | |
481 | } | |
482 | ||
81190958 | 483 | OutputToJDL(*os,"splitarguments","simrun.C --run $1 --chunk #alien_counter# --event $3"); |
a58729a5 | 484 | |
81190958 | 485 | OutputToJDL(*os,"Workdirectorysize","5000MB"); |
a58729a5 | 486 | |
81190958 | 487 | OutputToJDL(*os,"JDLVariables","Packages","OutputDir"); |
a58729a5 | 488 | |
81190958 | 489 | OutputToJDL(*os,"Validationcommand",Form("%s/validation.sh",RemoteDir().Data())); |
a58729a5 | 490 | |
30138a88 | 491 | if ( GetVar("VAR_GENERATOR").Contains("pythia",TString::kIgnoreCase) ) |
492 | { | |
493 | OutputToJDL(*os,"TTL","36000"); | |
494 | } | |
495 | else | |
496 | { | |
3e7b6e7b | 497 | OutputToJDL(*os,"TTL","14400"); |
30138a88 | 498 | } |
a58729a5 | 499 | |
500 | return kTRUE; | |
501 | } | |
502 | ||
a58729a5 | 503 | //______________________________________________________________________________ |
504 | Bool_t AliMuonAccEffSubmitter::MakeOCDBSnapshots() | |
505 | { | |
506 | /// Run sim.C and rec.C in a special mode to generate OCDB snapshots | |
507 | /// Can only be done after the templates have been copied locally | |
508 | ||
509 | if (!IsValid()) return kFALSE; | |
510 | ||
511 | if (!fUseOCDBSnapshots) return kTRUE; | |
512 | ||
81190958 | 513 | if (!NofRuns()) return kFALSE; |
a58729a5 | 514 | |
1afce1ce | 515 | AliDebug(1,""); |
516 | ||
a58729a5 | 517 | Bool_t ok(kTRUE); |
518 | ||
81190958 | 519 | const std::vector<int>& runs = RunList(); |
520 | ||
a58729a5 | 521 | for ( std::vector<int>::size_type i = 0; i < runs.size(); ++i ) |
522 | { | |
523 | Int_t runNumber = runs[i]; | |
524 | ||
525 | TString ocdbSim(Form("%s/OCDB/%d/OCDB_sim.root",SnapshotDir().Data(),runNumber)); | |
526 | TString ocdbRec(Form("%s/OCDB/%d/OCDB_rec.root",SnapshotDir().Data(),runNumber)); | |
527 | ||
1afce1ce | 528 | if ( !gSystem->AccessPathName(ocdbSim.Data()) && |
a58729a5 | 529 | !gSystem->AccessPathName(ocdbRec.Data()) ) |
530 | { | |
531 | AliWarning(Form("Local OCDB snapshots already there for run %d. Will not redo them. If you want to force them, delete them by hand !",runNumber)); | |
1afce1ce | 532 | continue; |
a58729a5 | 533 | } |
534 | else | |
535 | { | |
536 | gSystem->Exec(Form("aliroot -b -q -x simrun.C --run %d --snapshot",runNumber)); | |
537 | ||
538 | if ( gSystem->AccessPathName(ocdbSim.Data()) ) | |
539 | { | |
540 | AliError(Form("Could not create OCDB snapshot for simulation")); | |
541 | ok = kFALSE; | |
542 | } | |
543 | ||
544 | if ( gSystem->AccessPathName(ocdbRec.Data()) ) | |
545 | { | |
546 | AliError(Form("Could not create OCDB snapshot for reconstruction")); | |
547 | ok = kFALSE; | |
548 | } | |
549 | } | |
550 | ||
eb5de7ee | 551 | AddToLocalFileList(ocdbSim); |
552 | AddToLocalFileList(ocdbRec); | |
a58729a5 | 553 | } |
554 | ||
555 | return ok; | |
556 | } | |
557 | ||
558 | //______________________________________________________________________________ | |
559 | Bool_t AliMuonAccEffSubmitter::Merge(Int_t stage, Bool_t dryRun) | |
560 | { | |
561 | /// Submit multiple merging jobs with the format "submit AOD_merge(_final).jdl run# (stage#)". | |
562 | /// Also produce the xml collection before sending jobs | |
563 | /// Initial AODs will be taken from fRemoteDir/[RUNNUMBER] while the merged | |
564 | /// ones will be put into fMergedDir/AODs/[RUNNUMBER] | |
565 | /// | |
566 | /// Example: | |
567 | /// - inDir = "/alice/sim/2012/LHC12a10_bis" (where to find the data to merge) | |
568 | /// = 0x0 --> inDir = homeDir/outDir/resDir | |
569 | /// - outDir = "Sim/LHC11h/embedding/AODs" (where to store merged results) | |
570 | /// - runList.txt must contains the list of run number | |
571 | /// - stage=0 --> final merging / stage>0 --> intermediate merging i | |
572 | /// | |
573 | ||
81190958 | 574 | if (!RemoteDirectoryExists(MergedDir().Data())) { |
575 | AliError(Form("directory %s does not exist", MergedDir().Data())); | |
a58729a5 | 576 | return kFALSE; |
577 | } | |
578 | ||
81190958 | 579 | gGrid->Cd(MergedDir().Data()); |
a58729a5 | 580 | |
581 | TString jdl = MergeJDLName(stage==0); | |
582 | ||
583 | if (!RemoteFileExists(jdl.Data())) | |
584 | { | |
81190958 | 585 | AliError(Form("file %s does not exist in %s\n", jdl.Data(), RemoteDir().Data())); |
a58729a5 | 586 | return kFALSE; |
587 | } | |
588 | ||
81190958 | 589 | const std::vector<int>& runs = RunList(); |
a58729a5 | 590 | |
591 | if (runs.empty()) | |
592 | { | |
593 | AliError("No run to work with"); | |
3e7b6e7b | 594 | return 0; |
a58729a5 | 595 | } |
596 | ||
597 | TString currRun; | |
598 | TString reply = ""; | |
599 | gSystem->Exec("rm -f __failed__"); | |
600 | Bool_t failedRun = kFALSE; | |
601 | ||
602 | for ( std::vector<int>::size_type i = 0; i < runs.size(); ++i ) | |
603 | { | |
604 | Int_t run = runs[i]; | |
605 | AliInfo(Form("\n --- processing run %d ---\n", run)); | |
606 | ||
81190958 | 607 | TString runDir = Form("%s/%d", MergedDir().Data(), run); |
a58729a5 | 608 | |
609 | if (!RemoteDirectoryExists(runDir.Data())) | |
610 | { | |
611 | AliInfo(Form(" - creating output directory %s\n", runDir.Data())); | |
612 | gSystem->Exec(Form("alien_mkdir -p %s", runDir.Data())); | |
613 | } | |
614 | ||
615 | if (RemoteFileExists(Form("%s/root_archive.zip", runDir.Data()))) | |
616 | { | |
617 | AliWarning(" ! final merging already done"); | |
618 | continue; | |
619 | } | |
620 | ||
621 | Int_t lastStage = GetLastStage(runDir.Data()); | |
622 | ||
623 | if (stage > 0 && stage != lastStage+1) | |
624 | { | |
625 | AliError(Form(" ! lastest merging stage = %d. Next must be stage %d or final stage\n", lastStage, lastStage+1)); | |
626 | continue; | |
627 | } | |
628 | ||
629 | TString wn = (stage > 0) ? Form("Stage_%d.xml", stage) : "wn.xml"; | |
630 | TString find = (lastStage == 0) ? | |
81190958 | 631 | Form("alien_find -x %s %s/%d *root_archive.zip", wn.Data(), RemoteDir().Data(), run) : |
632 | Form("alien_find -x %s %s/%d/Stage_%d *root_archive.zip", wn.Data(), RemoteDir().Data(), run, lastStage); | |
a58729a5 | 633 | gSystem->Exec(Form("%s 1> %s 2>/dev/null", find.Data(), wn.Data())); |
634 | gSystem->Exec(Form("grep -c /event %s > __nfiles__", wn.Data())); | |
635 | ifstream f2("__nfiles__"); | |
636 | TString nFiles; | |
637 | nFiles.ReadLine(f2,kTRUE); | |
638 | f2.close(); | |
639 | gSystem->Exec("rm -f __nfiles__"); | |
640 | printf(" - number of files to merge = %d\n", nFiles.Atoi()); | |
641 | if (nFiles.Atoi() == 0) { | |
642 | printf(" ! collection of files to merge is empty\n"); | |
643 | gSystem->Exec(Form("rm -f %s", wn.Data())); | |
644 | continue; | |
645 | } else if (stage > 0 && nFiles.Atoi() <= splitLevel && !reply.BeginsWith("y")) { | |
646 | if (!reply.BeginsWith("n")) { | |
647 | printf(" ! number of files to merge <= split level (%d). Continue? [Y/n] ", splitLevel); | |
648 | fflush(stdout); | |
649 | reply.Gets(stdin,kTRUE); | |
650 | reply.ToLower(); | |
651 | } | |
652 | if (reply.BeginsWith("n")) { | |
653 | gSystem->Exec(Form("rm -f %s", wn.Data())); | |
654 | continue; | |
655 | } else reply = "y"; | |
656 | } | |
657 | ||
658 | if (!dryRun) | |
659 | { | |
660 | TString dirwn = Form("%s/%s", runDir.Data(), wn.Data()); | |
661 | if (RemoteFileExists(dirwn.Data())) gGrid->Rm(dirwn.Data()); | |
662 | gSystem->Exec(Form("alien_cp file:%s alien://%s", wn.Data(), dirwn.Data())); | |
663 | gSystem->Exec(Form("rm -f %s", wn.Data())); | |
664 | } | |
665 | ||
666 | TString query; | |
667 | if (stage > 0) query = Form("submit %s %d %d", jdl.Data(), run, stage); | |
668 | else query = Form("submit %s %d", jdl.Data(), run); | |
669 | printf(" - %s ...", query.Data()); | |
670 | fflush(stdout); | |
671 | ||
672 | if (dryRun) | |
673 | { | |
674 | AliInfo(" dry run"); | |
675 | continue; | |
676 | } | |
677 | ||
678 | Bool_t done = kFALSE; | |
679 | TGridResult *res = gGrid->Command(query); | |
680 | if (res) | |
681 | { | |
682 | TString cjobId1 = res->GetKey(0,"jobId"); | |
683 | if (!cjobId1.IsDec()) | |
684 | { | |
685 | AliError(" FAILED"); | |
686 | gGrid->Stdout(); | |
687 | gGrid->Stderr(); | |
688 | } | |
689 | else | |
690 | { | |
691 | AliInfo(Form(" DONE\n --> the job Id is: %s \n", cjobId1.Data())); | |
692 | done = kTRUE; | |
693 | } | |
694 | delete res; | |
695 | } | |
696 | else | |
697 | { | |
698 | AliError(" FAILED"); | |
699 | } | |
700 | ||
701 | if (!done) | |
702 | { | |
703 | gSystem->Exec(Form("echo %d >> __failed__", run)); | |
704 | failedRun = kTRUE; | |
705 | } | |
706 | ||
707 | } | |
708 | ||
709 | if (failedRun) | |
710 | { | |
711 | AliInfo("\n--------------------\n"); | |
712 | AliInfo("list of failed runs:\n"); | |
713 | gSystem->Exec("cat __failed__"); | |
714 | gSystem->Exec("rm -f __failed__"); | |
715 | return kFALSE; | |
716 | } | |
717 | ||
718 | return kTRUE; | |
719 | } | |
720 | ||
721 | //______________________________________________________________________________ | |
81190958 | 722 | void AliMuonAccEffSubmitter::Print(Option_t* opt) const |
a58729a5 | 723 | { |
1afce1ce | 724 | /// Printout |
725 | ||
81190958 | 726 | AliMuonGridSubmitter::Print(opt); |
727 | ||
a58729a5 | 728 | if ( fRatio > 0 ) |
729 | { | |
30138a88 | 730 | std::cout << std::endl << Form("-- For each run, will generate %5.2f times the number of real events for trigger %s", |
81190958 | 731 | fRatio,ReferenceTrigger().Data()) << std::endl; |
a58729a5 | 732 | } |
733 | else | |
734 | { | |
30138a88 | 735 | std::cout << std::endl << Form("-- For each run, will generate %10d events",fFixedNofEvents) << std::endl; |
a58729a5 | 736 | } |
737 | ||
30138a88 | 738 | std::cout << "-- MaxEventsPerChunk = " << fMaxEventsPerChunk << std::endl; |
a58729a5 | 739 | |
30138a88 | 740 | std::cout << "-- Will" << (fUseOCDBSnapshots ? "" : " NOT") << " use OCDB snaphosts" << std::endl; |
a58729a5 | 741 | } |
742 | ||
743 | //______________________________________________________________________________ | |
744 | Bool_t AliMuonAccEffSubmitter::Run(const char* mode) | |
745 | { | |
746 | /// mode can be one of (case insensitive) | |
747 | /// | |
748 | /// LOCAL : copy the template files from the template directory to the local one | |
749 | /// UPLOAD : copy the local files to the grid (requires LOCAL) | |
750 | /// OCDB : make ocdb snapshots (requires LOCAL) | |
751 | /// SUBMIT : submit the jobs (requires LOCAL + UPLOAD) | |
752 | /// FULL : all of the above (requires all of the above) | |
753 | /// | |
754 | /// TEST : as SUBMIT, but in dry mode (does not actually submit the jobs) | |
eb5de7ee | 755 | /// |
756 | /// LOCALTEST : completely local test (including execution) | |
a58729a5 | 757 | |
758 | if (!IsValid()) return kFALSE; | |
759 | ||
760 | TString smode(mode); | |
761 | smode.ToUpper(); | |
762 | ||
763 | if ( smode == "FULL") | |
764 | { | |
765 | return ( Run("LOCAL") && Run("OCDB") && Run("UPLOAD") && Run("SUBMIT") ); | |
766 | } | |
767 | ||
768 | if ( smode == "LOCAL") | |
769 | { | |
770 | return CopyTemplateFilesToLocal(); | |
771 | } | |
772 | ||
773 | if ( smode == "UPLOAD" ) | |
774 | { | |
775 | return (CopyLocalFilesToRemote()); | |
776 | } | |
777 | ||
778 | if ( smode == "OCDB" ) | |
779 | { | |
780 | Bool_t ok = Run("LOCAL"); | |
781 | if (ok) | |
782 | { | |
783 | ok = MakeOCDBSnapshots(); | |
784 | } | |
785 | return ok; | |
786 | } | |
787 | ||
788 | if ( smode == "TEST" ) | |
789 | { | |
790 | Bool_t ok = Run("LOCAL") && Run("OCDB") && Run("UPLOAD"); | |
791 | if ( ok ) | |
792 | { | |
793 | ok = (Submit(kTRUE)>0); | |
794 | } | |
795 | return ok; | |
796 | } | |
797 | ||
798 | if ( smode == "FULL" ) | |
799 | { | |
800 | Bool_t ok = Run("LOCAL") && Run("OCDB") && Run("UPLOAD"); | |
801 | if ( ok ) | |
802 | { | |
803 | ok = (Submit(kFALSE)>0); | |
804 | } | |
805 | return ok; | |
806 | } | |
807 | ||
808 | if( smode == "SUBMIT" ) | |
809 | { | |
810 | return (Submit(kFALSE)>0); | |
811 | } | |
812 | ||
eb5de7ee | 813 | if ( smode == "LOCALTEST" ) |
814 | { | |
815 | Bool_t ok = Run("LOCAL"); | |
816 | if ( ok ) | |
817 | { | |
818 | ok = LocalTest(); | |
819 | } | |
820 | return ok; | |
821 | } | |
822 | ||
a58729a5 | 823 | return kFALSE; |
824 | } | |
825 | ||
1afce1ce | 826 | //______________________________________________________________________________ |
827 | Bool_t AliMuonAccEffSubmitter::SetGenerator(const char* generator) | |
828 | { | |
829 | // set the variable to select the generator macro in Config.C | |
830 | ||
831 | gSystem->Load("libEVGEN"); | |
1afce1ce | 832 | |
81190958 | 833 | Invalidate(); |
834 | ||
835 | TString generatorFile(Form("%s/%s.C",TemplateDir().Data(),generator)); | |
1afce1ce | 836 | |
837 | Int_t nofMissingVariables(0); | |
838 | ||
839 | // first check we indeed have such a macro | |
840 | if (!gSystem->AccessPathName(generatorFile.Data())) | |
841 | { | |
842 | TObjArray* variables = GetVariables(generatorFile.Data()); | |
843 | ||
844 | TIter next(variables); | |
845 | TObjString* var; | |
846 | ||
847 | while ( ( var = static_cast<TObjString*>(next())) ) | |
848 | { | |
81190958 | 849 | if ( !Vars()->GetValue(var->String()) ) |
1afce1ce | 850 | { |
851 | ++nofMissingVariables; | |
852 | AliError(Form("file %s expect the variable %s to be defined, but we've not defined it !",generatorFile.Data(),var->String().Data())); | |
853 | } | |
854 | } | |
855 | ||
856 | delete variables; | |
857 | ||
858 | if ( !nofMissingVariables ) | |
859 | { | |
860 | if (CheckCompilation(generatorFile.Data())) | |
861 | { | |
81190958 | 862 | Validate(); |
1afce1ce | 863 | SetVar("VAR_GENERATOR",Form("%s",generator)); |
81190958 | 864 | AddToTemplateFileList(Form("%s.C",generator)); |
1afce1ce | 865 | return kTRUE; |
866 | } | |
867 | } | |
868 | else | |
869 | { | |
870 | return kFALSE; | |
871 | } | |
872 | } | |
873 | else | |
874 | { | |
875 | AliError(Form("Can not work with the macro %s",generatorFile.Data())); | |
876 | } | |
877 | return kFALSE; | |
878 | } | |
879 | ||
1afce1ce | 880 | //______________________________________________________________________________ |
881 | void AliMuonAccEffSubmitter::SetOCDBPath(const char* ocdbPath) | |
882 | { | |
883 | /// Sets the OCDB path to be used | |
884 | ||
81190958 | 885 | SetMapKeyValue("OCDBPath",ocdbPath); |
1afce1ce | 886 | } |
887 | ||
888 | ||
889 | //______________________________________________________________________________ | |
890 | void AliMuonAccEffSubmitter::SetOCDBSnapshotDir(const char* dir) | |
891 | { | |
892 | // change the directory used for snapshot | |
893 | ||
894 | if (gSystem->AccessPathName(Form("%s/OCDB",dir))) | |
895 | { | |
896 | AliError(Form("Snapshot top directory (%s) should contain an OCDB subdir with runnumbers in there",dir)); | |
897 | } | |
898 | else | |
899 | { | |
81190958 | 900 | SetMapKeyValue("OCDBSnapshot",dir); |
1afce1ce | 901 | } |
902 | } | |
903 | ||
a58729a5 | 904 | //______________________________________________________________________________ |
81190958 | 905 | void AliMuonAccEffSubmitter::MakeNofEventsPropToTriggerCount(const char* trigger, Float_t ratio) |
a58729a5 | 906 | { |
81190958 | 907 | SetMapKeyValue("ReferenceTrigger",trigger); |
908 | fRatio = ratio; | |
909 | } | |
910 | ||
911 | //______________________________________________________________________________ | |
912 | void AliMuonAccEffSubmitter::MakeNofEventsFixed(Int_t nevents) | |
913 | { | |
914 | fFixedNofEvents = nevents; | |
915 | fRatio=0.0; | |
916 | SetMapKeyValue("ReferenceTrigger",""); | |
a58729a5 | 917 | } |
918 | ||
eb5de7ee | 919 | //______________________________________________________________________________ |
920 | Int_t AliMuonAccEffSubmitter::LocalTest() | |
921 | { | |
922 | /// Generate a local macro (simrun.sh) to execute locally a full scale test | |
923 | /// Can only be used with a fixed number of events (and runnumber is fixed to zero) | |
924 | ||
925 | if ( fRatio > 0 ) | |
926 | { | |
927 | AliError("Can only work in local test with a fixed number of events"); | |
928 | return 0; | |
929 | } | |
930 | ||
931 | if ( fFixedNofEvents <= 0 ) | |
932 | { | |
933 | AliError("Please fix the number of input events using MakeNofEventsFixed()"); | |
934 | return 0; | |
935 | } | |
8907673b | 936 | |
937 | const std::vector<int>& runs = RunList(); | |
eb5de7ee | 938 | |
3e7b6e7b | 939 | if ( runs.empty() ) |
940 | { | |
941 | AliError("No run to work with"); | |
942 | return 0; | |
943 | } | |
944 | ||
eb5de7ee | 945 | std::cout << "Generating script to execute : ./simrun.sh" << std::endl; |
3e7b6e7b | 946 | |
eb5de7ee | 947 | std::ofstream out("simrun.sh"); |
948 | ||
949 | out << "#!/bin/bash" << std::endl; | |
950 | // root.exe -b -q simrun.C --run <x> --chunk <y> --event <n> | |
8907673b | 951 | out << "root.exe -b -q simrun.C --run "<< runs[0] <<" --event " << fFixedNofEvents << std::endl; |
f9208637 | 952 | |
953 | out.close(); | |
954 | ||
eb5de7ee | 955 | gSystem->Exec("chmod +x simrun.sh"); |
3e7b6e7b | 956 | |
957 | std::cout << "Cleaning up left-over files from previous simulation/reconstructions" << std::endl; | |
eb5de7ee | 958 | |
3e7b6e7b | 959 | gSystem->Exec("rm -rf TrackRefs.root *.SDigits*.root Kinematics.root *.Hits.root geometry.root gphysi.dat Run*.tag.root HLT*.root *.ps *.Digits.root *.RecPoints.root galice.root *QA*.root Trigger.root *.log AliESD* AliAOD* *.d *.so *.stat"); |
960 | ||
eb5de7ee | 961 | std::cout << "Executing the script : ./simrun.sh" << std::endl; |
962 | ||
3e7b6e7b | 963 | |
eb5de7ee | 964 | gSystem->Exec("./simrun.sh"); |
965 | ||
966 | return 1; | |
967 | } | |
81190958 | 968 | |
3e7b6e7b | 969 | namespace { |
970 | ||
971 | void OutputRunList(const char* filename, const std::vector<int>& runlist) | |
972 | { | |
973 | /// output a runlist to ASCII file | |
974 | ||
975 | std::ofstream out(filename); | |
976 | ||
977 | for ( std::vector<int>::size_type j = 0; j < runlist.size(); ++j ) | |
978 | { | |
979 | out << runlist[j] << std::endl; | |
980 | } | |
981 | } | |
982 | } | |
983 | ||
984 | //______________________________________________________________________________ | |
985 | Int_t AliMuonAccEffSubmitter::SplitRunList(const char* inputList, int maxJobs) | |
986 | { | |
987 | /// In order to be able to submit, split a given runlist into chunks that will | |
988 | /// fit within maxJobs (1500 for a typical user) | |
989 | ||
990 | std::vector<int> runs; | |
991 | ||
992 | AliAnalysisTriggerScalers tmp(inputList); | |
993 | runs = tmp.GetRunList(); | |
994 | ||
995 | AliAnalysisTriggerScalers* ts(0x0); | |
996 | std::vector<int> currentRunList; | |
997 | ||
998 | int nJobs(0); | |
999 | int nTotalJobs(0); | |
1000 | int nEvts(0); | |
1001 | int nFiles(0); | |
1002 | ||
1003 | for (std::vector<int>::size_type i=0; i < runs.size(); ++i) | |
1004 | { | |
1005 | Int_t runNumber = runs[i]; | |
1006 | ||
1007 | Int_t nEvtRun(fFixedNofEvents); | |
1008 | ||
1009 | if ( fRatio > 0 ) | |
1010 | { | |
1011 | if (!ts) | |
1012 | { | |
1013 | AliInfo(Form("Creating AliAnalysisTriggerScalers from OCDB=%s",OCDBPath().Data())); | |
1014 | ts = new AliAnalysisTriggerScalers(runs,OCDBPath().Data()); | |
1015 | } | |
1016 | ||
1017 | AliAnalysisTriggerScalerItem* trigger = ts->GetTriggerScaler(runNumber, "L2A", ReferenceTrigger().Data()); | |
1018 | ||
1019 | if (!trigger) | |
1020 | { | |
1021 | AliError(Form("Could not get trigger %s for run %09d",ReferenceTrigger().Data(),runNumber)); | |
1022 | continue; | |
1023 | } | |
1024 | nEvtRun = TMath::Nint(fRatio * trigger->Value()); | |
1025 | } | |
1026 | ||
1027 | Int_t nChunk = 1; | |
1028 | ||
1029 | while (nEvtRun/nChunk+0.5 > MaxEventsPerChunk()) | |
1030 | { | |
1031 | ++nChunk; | |
1032 | } | |
1033 | ||
1034 | Int_t nEvtChunk = TMath::Nint(nEvtRun/nChunk + 0.5); | |
1035 | ||
1036 | nJobs += nChunk; | |
1037 | ||
1038 | nTotalJobs += nChunk; | |
1039 | ||
1040 | nEvts += nChunk*nEvtChunk; | |
1041 | ||
1042 | if ( nJobs > maxJobs ) | |
1043 | { | |
1044 | ++nFiles; | |
1045 | ||
1046 | OutputRunList(Form("%s.%d",inputList,nFiles),currentRunList); | |
1047 | nJobs = 0; | |
1048 | currentRunList.clear(); | |
1049 | } | |
1050 | ||
1051 | ||
1052 | currentRunList.push_back(runNumber); | |
1053 | ||
1054 | } | |
1055 | ||
1056 | if ( !currentRunList.empty() ) | |
1057 | { | |
1058 | ++nFiles; | |
1059 | OutputRunList(Form("%s.%d",inputList,nFiles),currentRunList); | |
1060 | ||
1061 | } | |
1062 | ||
1063 | delete ts; | |
1064 | ||
1065 | std::cout << Form("input run list was split into %d files. Total number of jobs %d. Total number of events %d", | |
1066 | nFiles,nTotalJobs,nEvts) << std::endl; | |
1067 | ||
1068 | return nFiles; | |
1069 | } | |
1070 | ||
1071 | ||
a58729a5 | 1072 | //______________________________________________________________________________ |
1073 | Int_t AliMuonAccEffSubmitter::Submit(Bool_t dryRun) | |
1074 | { | |
1075 | /// Submit multiple production jobs with the format "submit jdl 000run#.xml 000run#". | |
1076 | /// | |
1077 | /// Return the number of submitted (master) jobs | |
1078 | /// | |
1079 | /// Example: | |
1080 | /// - outputDir = "/alice/cern.ch/user/p/ppillot/Sim/LHC10h/JPsiPbPb276/AlignRawVtxRaw/ESDs" | |
1081 | /// - runList must contains the list of run number | |
1082 | /// - trigger is the (fully qualified) trigger name used to compute the base number of events | |
1083 | /// - mult is the factor to apply to the number of trigger to get the number of events to be generated | |
1084 | /// (# generated events = # triggers x mult | |
1085 | ||
1086 | if (!IsValid()) return 0; | |
1087 | ||
1afce1ce | 1088 | AliDebug(1,""); |
1089 | ||
a58729a5 | 1090 | gGrid->Cd(RemoteDir()); |
1091 | ||
1092 | if (!RemoteFileExists(RunJDLName())) | |
1093 | { | |
1094 | AliError(Form("file %s does not exist in %s", RunJDLName().Data(), RemoteDir().Data())); | |
1095 | return 0; | |
1096 | } | |
1097 | ||
81190958 | 1098 | if ( !NofRuns() ) |
a58729a5 | 1099 | { |
1100 | AliError("No run list set. Use SetRunList"); | |
1101 | return 0; | |
1102 | } | |
81190958 | 1103 | const std::vector<int>& runs = RunList(); |
a58729a5 | 1104 | |
1105 | if (runs.empty()) | |
1106 | { | |
1107 | AliError("No run to work with"); | |
1108 | return 0; | |
1109 | } | |
1110 | ||
1111 | // cout << "total number of selected MB events = " << totEvt << endl; | |
1112 | // cout << "required number of generated events = " << nGenEvents << endl; | |
1113 | // cout << "number of generated events per MB event = " << ratio << endl; | |
1114 | // cout << endl; | |
1115 | ||
1116 | std::cout << "run\tchunks\tevents" << std::endl; | |
1117 | std::cout << "----------------------" << std::endl; | |
1118 | ||
1119 | Int_t nJobs(0); | |
1120 | Int_t nEvts(0); | |
1121 | ||
81190958 | 1122 | AliAnalysisTriggerScalers* ts(0x0); |
1123 | ||
a58729a5 | 1124 | for (std::vector<int>::size_type i=0; i < runs.size(); ++i) |
1125 | { | |
1126 | Int_t runNumber = runs[i]; | |
1127 | ||
1128 | Int_t nEvtRun(fFixedNofEvents); | |
1129 | ||
1130 | if ( fRatio > 0 ) | |
1131 | { | |
81190958 | 1132 | if (!ts) |
1133 | { | |
1134 | AliInfo(Form("Creating AliAnalysisTriggerScalers from OCDB=%s",OCDBPath().Data())); | |
1135 | ts = new AliAnalysisTriggerScalers(runs,OCDBPath().Data()); | |
1136 | } | |
1137 | ||
1138 | AliAnalysisTriggerScalerItem* trigger = ts->GetTriggerScaler(runNumber, "L2A", ReferenceTrigger().Data()); | |
a58729a5 | 1139 | |
1140 | if (!trigger) | |
1141 | { | |
1142 | AliError(Form("Could not get trigger %s for run %09d",ReferenceTrigger().Data(),runNumber)); | |
1143 | continue; | |
1144 | } | |
1145 | nEvtRun = TMath::Nint(fRatio * trigger->Value()); | |
1146 | } | |
1147 | ||
1148 | Int_t nChunk = 1; | |
1149 | ||
1150 | while (nEvtRun/nChunk+0.5 > MaxEventsPerChunk()) | |
1151 | { | |
1152 | ++nChunk; | |
1153 | } | |
1154 | ||
1155 | Int_t nEvtChunk = TMath::Nint(nEvtRun/nChunk + 0.5); | |
1156 | ||
1157 | nJobs += nChunk; | |
1158 | ||
1159 | nEvts += nChunk*nEvtChunk; | |
1160 | ||
1161 | std::cout << runNumber << "\t" << nChunk << "\t" << nEvtChunk << std::endl; | |
1162 | ||
1163 | TString query(Form("submit %s %d %d %d", RunJDLName().Data(), runNumber, nChunk, nEvtChunk)); | |
1164 | ||
1165 | std::cout << query.Data() << " ..." << std::flush; | |
1166 | ||
1167 | TGridResult* res = 0x0; | |
1168 | ||
1169 | if (!dryRun) | |
1170 | { | |
1171 | res = gGrid->Command(query); | |
1172 | } | |
1173 | ||
1174 | if (res) | |
1175 | { | |
1176 | TString cjobId1 = res->GetKey(0,"jobId"); | |
1177 | ||
1178 | if (!cjobId1.Length()) | |
1179 | { | |
1180 | std::cout << " FAILED" << std::endl << std::endl; | |
1181 | gGrid->Stdout(); | |
1182 | gGrid->Stderr(); | |
1183 | } | |
1184 | else | |
1185 | { | |
1186 | std::cout << "DONE" << std::endl; | |
1187 | std::cout << Form(" --> the job Id is: %s",cjobId1.Data()) << std::endl << std::endl; | |
1188 | } | |
1189 | } | |
1190 | else | |
1191 | { | |
1192 | std::cout << " FAILED" << std::endl << std::endl; | |
1193 | } | |
1194 | ||
1195 | delete res; | |
1196 | } | |
1197 | ||
1198 | std::cout << std::endl | |
1199 | << "total number of jobs = " << nJobs << std::endl | |
1200 | << "total number of generated events = " << nEvts << std::endl | |
1201 | << std::endl; | |
1202 | ||
81190958 | 1203 | delete ts; |
a58729a5 | 1204 | |
81190958 | 1205 | return nJobs; |
a58729a5 | 1206 | } |
1207 | ||
1208 | //______________________________________________________________________________ | |
1209 | void AliMuonAccEffSubmitter::UpdateLocalFileList(Bool_t clearSnapshots) | |
1210 | { | |
1afce1ce | 1211 | /// Update the list of local files |
1212 | ||
81190958 | 1213 | AliMuonGridSubmitter::UpdateLocalFileList(); |
1214 | ||
1215 | if (!NofRuns()) return; | |
a58729a5 | 1216 | |
1217 | if ( clearSnapshots ) | |
1218 | { | |
1219 | TIter next(LocalFileList()); | |
1220 | TObjString* file; | |
1221 | ||
1222 | while ( ( file = static_cast<TObjString*>(next())) ) | |
1223 | { | |
1224 | if ( file->String().Contains("OCDB_") ) | |
1225 | { | |
1226 | LocalFileList()->Remove(file); | |
1227 | } | |
1228 | } | |
1229 | LocalFileList()->Compress(); | |
1230 | } | |
1231 | ||
a58729a5 | 1232 | const char* type[] = { "sim","rec" }; |
1233 | ||
81190958 | 1234 | const std::vector<int>& runs = RunList(); |
1235 | ||
a58729a5 | 1236 | for ( std::vector<int>::size_type i = 0; i < runs.size(); ++i ) |
1237 | { | |
1238 | Int_t runNumber = runs[i]; | |
1239 | ||
1240 | for ( Int_t t = 0; t < 2; ++t ) | |
1241 | { | |
1242 | TString snapshot(Form("%s/OCDB/%d/OCDB_%s.root",SnapshotDir().Data(),runNumber,type[t])); | |
1243 | ||
1244 | if ( !gSystem->AccessPathName(snapshot.Data()) ) | |
1245 | { | |
eb5de7ee | 1246 | AddToLocalFileList(snapshot); |
a58729a5 | 1247 | } |
1248 | } | |
1249 | } | |
a58729a5 | 1250 | } |
1251 | ||
1252 | //______________________________________________________________________________ | |
1253 | void AliMuonAccEffSubmitter::UseOCDBSnapshots(Bool_t flag) | |
1254 | { | |
1afce1ce | 1255 | /// Whether or not to use OCDB snapshots |
1256 | /// Using OCDB snapshots will speed-up both the sim and reco initialization | |
1257 | /// phases on each worker node, but takes time to produce... | |
1258 | /// So using them is not always a win-win... | |
1259 | ||
a58729a5 | 1260 | fUseOCDBSnapshots = flag; |
1261 | if ( flag ) | |
1262 | { | |
1263 | SetVar("VAR_OCDB_SNAPSHOT","kTRUE"); | |
30138a88 | 1264 | |
1265 | // for some reason must include ITS objects in the snapshot | |
1266 | // (to be able to instantiante the vertexer later on ?) | |
1267 | ||
1268 | SetVar("VAR_USE_ITS_RECO","1"); | |
a58729a5 | 1269 | } |
1270 | else | |
1271 | { | |
1272 | SetVar("VAR_OCDB_SNAPSHOT","kFALSE"); | |
1273 | } | |
1274 | ||
1275 | UpdateLocalFileList(); | |
1276 | } | |
1277 | ||
a3c2a88b | 1278 | //______________________________________________________________________________ |
1279 | void AliMuonAccEffSubmitter::UseAODMerging(Bool_t flag) | |
1280 | { | |
1281 | /// whether or not we should generate JDL for merging AODs | |
1282 | ||
1283 | fUseAODMerging = flag; | |
81190958 | 1284 | |
1285 | AddToTemplateFileList(MergeJDLName(kFALSE).Data()); | |
1286 | AddToTemplateFileList(MergeJDLName(kTRUE).Data()); | |
1287 | AddToTemplateFileList("AOD_merge.sh"); | |
1288 | AddToTemplateFileList("validation_merge.sh"); | |
1289 | } | |
1290 | ||
1291 | //______________________________________________________________________________ | |
1292 | void AliMuonAccEffSubmitter::UseExternalConfig(const char* externalConfigFullFilePath) | |
1293 | { | |
1294 | // use an external config (or the default Config.C if externalConfigFullFilePath="") | |
1295 | ||
1296 | fExternalConfig = externalConfigFullFilePath; | |
1297 | if ( fExternalConfig.Length() > 0 ) | |
1298 | { | |
1299 | AddToTemplateFileList(fExternalConfig); | |
1300 | } | |
1301 | else | |
1302 | { | |
1303 | AddToTemplateFileList("Config.C"); | |
1304 | } | |
a3c2a88b | 1305 | } |