]>
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 | ||
30138a88 | 185 | SetVar("VAR_PYTHIA8_CMS_ENERGY","8000"); |
3e7b6e7b | 186 | SetVar("VAR_PYTHIA6_CMS_ENERGY","8000"); |
30138a88 | 187 | |
eb5de7ee | 188 | SetVar("VAR_PURELY_LOCAL",Form("%d",localOnly)); |
189 | ||
8907673b | 190 | SetVar("VAR_SIM_ALIGNDATA","\"alien://folder=/alice/simulation/2008/v4-15-Release/Ideal\""); |
191 | ||
192 | SetVar("VAR_REC_ALIGNDATA","\"alien://folder=/alice/simulation/2008/v4-15-Release/Residual\""); | |
193 | ||
30138a88 | 194 | SetVar("VAR_USE_ITS_RECO","0"); |
195 | ||
81190958 | 196 | UseOCDBSnapshots(fUseOCDBSnapshots); |
30138a88 | 197 | |
198 | gSystem->Load("libEVGEN"); | |
199 | ||
3e7b6e7b | 200 | SetVar("VAR_TRIGGER_CONFIGURATION",""); |
201 | ||
202 | SetVar("VAR_PYTHIA8_INCLUDES",""); | |
203 | SetVar("VAR_PYTHIA8_SETENV",""); | |
204 | ||
205 | SetVar("VAR_PYTHIA6_INCLUDES",""); | |
206 | SetVar("VAR_PYTHIA6_SETENV",""); | |
207 | ||
30138a88 | 208 | if ( TString(generator).Contains("pythia8",TString::kIgnoreCase) ) |
209 | { | |
210 | fMaxEventsPerChunk = 500; // 5000 is not reasonable with Pythia8 (and ITS+MUON...) | |
211 | ||
212 | fCompactMode = 2; // keep AOD as for the time being the filtering driven from AODtrain.C cannot | |
213 | // add SPD tracklets to muon AODs. | |
214 | ||
215 | SetVar("VAR_USE_ITS_RECO","1"); | |
216 | ||
3e7b6e7b | 217 | if (gSystem->AccessPathName(gSystem->ExpandPathName(Form("$ALICE_ROOT/PYTHIA8/pythia%s",generatorVersion)))) |
30138a88 | 218 | { |
3e7b6e7b | 219 | AliError(Form("Directory -I$ALICE_ROOT/PYTHIA8/pythia%s/include not found",generatorVersion)); |
30138a88 | 220 | Invalidate(); |
221 | return; | |
222 | } | |
3e7b6e7b | 223 | AddIncludePath(Form("-I$ALICE_ROOT/PYTHIA8 -I$ALICE_ROOT/PYTHIA8/pythia%s/include",generatorVersion)); |
30138a88 | 224 | // SetVar("VAR_PYTHIA8_VERSION",Form("\"%d\"",pythia8version)); |
225 | ||
3e7b6e7b | 226 | 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 | 227 | |
228 | TString p8env; | |
229 | ||
3e7b6e7b | 230 | p8env += Form(" gSystem->Setenv(\"PYTHIA8DATA\", gSystem->ExpandPathName(\"$ALICE_ROOT/PYTHIA8/pythia%s/xmldoc\"));\n",generatorVersion); |
30138a88 | 231 | |
232 | p8env += " gSystem->Setenv(\"LHAPDF\",gSystem->ExpandPathName(\"$ALICE_ROOT/LHAPDF\"));\n"; | |
233 | ||
234 | p8env += " gSystem->Setenv(\"LHAPATH\",gSystem->ExpandPathName(\"$ALICE_ROOT/LHAPDF/PDFsets\"));\n"; | |
235 | ||
236 | SetVar("VAR_PYTHIA8_SETENV",p8env.Data()); | |
237 | ||
238 | gSystem->Load("libFASTSIM"); | |
239 | gSystem->Load("liblhapdf"); // Parton density functions | |
240 | gSystem->Load("libEGPythia6"); // TGenerator interface | |
3e7b6e7b | 241 | // gSystem->Load("libpythia6"); // Pythia 6.2 |
30138a88 | 242 | gSystem->Load("libAliPythia6"); // ALICE specific implementations |
3e7b6e7b | 243 | gSystem->Load("libpythia8"); |
244 | gSystem->Load("libAliPythia8"); | |
245 | ||
246 | SetVar("VAR_PYTHIA8_SETUP_STRINGS","\"\""); | |
247 | ||
248 | SetVar("VAR_TRIGGER_CONFIGURATION","p-p"); | |
30138a88 | 249 | } |
3e7b6e7b | 250 | |
251 | if ( TString(generator).Contains("pythia6",TString::kIgnoreCase) ) | |
30138a88 | 252 | { |
3e7b6e7b | 253 | fMaxEventsPerChunk = 500; // 5000 is not reasonable with Pythia6 (and ITS+MUON...) |
254 | ||
255 | fCompactMode = 2; // keep AOD as for the time being the filtering driven from AODtrain.C cannot | |
256 | // add SPD tracklets to muon AODs. | |
257 | ||
258 | gSystem->Load("libFASTSIM"); | |
259 | gSystem->Load("liblhapdf"); // Parton density functions | |
260 | gSystem->Load("libEGPythia6"); // TGenerator interface | |
261 | gSystem->Load(Form("libpythia6.%s",generatorVersion)); | |
262 | gSystem->Load("libAliPythia6"); | |
263 | ||
264 | 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\");"); | |
265 | ||
266 | TString p6env; | |
267 | ||
268 | p6env += Form("gSystem->Load(\"libpythia6.%s\");",generatorVersion); | |
269 | ||
270 | SetVar("VAR_PYTHIA6_SETENV",p6env.Data()); | |
271 | ||
272 | SetVar("VAR_USE_ITS_RECO","1"); | |
273 | ||
274 | SetVar("VAR_TRIGGER_CONFIGURATION","p-p"); | |
30138a88 | 275 | } |
3e7b6e7b | 276 | |
1afce1ce | 277 | SetGenerator(generator); |
1afce1ce | 278 | |
30138a88 | 279 | if (localOnly) |
280 | { | |
281 | MakeNofEventsFixed(10); | |
282 | } | |
283 | else | |
284 | { | |
285 | MakeNofEventsPropToTriggerCount(); | |
286 | } | |
1afce1ce | 287 | |
81190958 | 288 | AddToTemplateFileList("CheckESD.C"); |
289 | AddToTemplateFileList("CheckAOD.C"); | |
290 | AddToTemplateFileList("AODtrain.C"); | |
291 | AddToTemplateFileList("validation.sh"); | |
1afce1ce | 292 | |
81190958 | 293 | AddToTemplateFileList("Config.C"); |
294 | AddToTemplateFileList("rec.C"); | |
295 | AddToTemplateFileList("sim.C"); | |
296 | AddToTemplateFileList("simrun.C"); | |
297 | AddToTemplateFileList(RunJDLName().Data()); | |
1afce1ce | 298 | |
81190958 | 299 | UseExternalConfig(fExternalConfig); |
1afce1ce | 300 | } |
301 | ||
a58729a5 | 302 | //______________________________________________________________________________ |
81190958 | 303 | AliMuonAccEffSubmitter::~AliMuonAccEffSubmitter() |
a58729a5 | 304 | { |
81190958 | 305 | // dtor |
a58729a5 | 306 | } |
307 | ||
81190958 | 308 | ///______________________________________________________________________________ |
309 | Bool_t AliMuonAccEffSubmitter::Generate(const char* jdlname) const | |
a58729a5 | 310 | { |
81190958 | 311 | if ( TString(jdlname).Contains("merge",TString::kIgnoreCase) ) |
a58729a5 | 312 | { |
81190958 | 313 | return GenerateMergeJDL(jdlname); |
a58729a5 | 314 | } |
315 | else | |
316 | { | |
81190958 | 317 | return GenerateRunJDL(jdlname); |
a58729a5 | 318 | } |
a58729a5 | 319 | } |
320 | ||
321 | ///______________________________________________________________________________ | |
81190958 | 322 | Bool_t AliMuonAccEffSubmitter::GenerateMergeJDL(const char* name) const |
a58729a5 | 323 | { |
1afce1ce | 324 | /// Create the JDL for merging jobs |
325 | /// FIXME: not checked ! | |
326 | ||
327 | AliDebug(1,""); | |
328 | ||
a58729a5 | 329 | std::ostream* os = CreateJDLFile(name); |
330 | ||
331 | if (!os) | |
332 | { | |
333 | return kFALSE; | |
334 | } | |
335 | ||
336 | Bool_t final = TString(name).Contains("merge",TString::kIgnoreCase); | |
337 | ||
338 | (*os) << "# Generated merging jdl (production mode)" << std::endl | |
339 | << "# $1 = run number" << std::endl | |
340 | << "# $2 = merging stage" << std::endl | |
341 | << "# Stage_<n>.xml made via: find <OutputDir> *Stage<n-1>/*root_archive.zip" << std::endl; | |
342 | ||
81190958 | 343 | OutputToJDL(*os,"Packages", |
344 | GetMapValue("AliRoot"), | |
345 | GetMapValue("Geant3"), | |
346 | GetMapValue("Root"), | |
347 | GetMapValue("API")); | |
a58729a5 | 348 | |
81190958 | 349 | OutputToJDL(*os,"Executable","AOD_merge.sh"); |
a58729a5 | 350 | |
81190958 | 351 | OutputToJDL(*os,"Price","1"); |
a58729a5 | 352 | |
353 | if ( final ) | |
354 | { | |
81190958 | 355 | OutputToJDL(*os,"Jobtag","comment: AliMuonAccEffSubmitter final merging"); |
a58729a5 | 356 | } |
357 | else | |
358 | { | |
81190958 | 359 | OutputToJDL(*os,"Jobtag","comment: AliMuonAccEffSubmitter merging stage $2"); |
a58729a5 | 360 | } |
361 | ||
81190958 | 362 | OutputToJDL(*os,"Workdirectorysize","5000MB"); |
a58729a5 | 363 | |
81190958 | 364 | OutputToJDL(*os,"Validationcommand",Form("%s/validation_merge.sh",RemoteDir().Data())); |
a58729a5 | 365 | |
3e7b6e7b | 366 | OutputToJDL(*os,"TTL","14400"); |
30138a88 | 367 | |
81190958 | 368 | OutputToJDL(*os,"OutputArchive", |
a58729a5 | 369 | "log_archive.zip:stderr,stdout@disk=1", |
370 | "root_archive.zip:AliAOD.root,AliAOD.Muons.root,AnalysisResults.root@disk=3" | |
371 | ); | |
372 | ||
81190958 | 373 | OutputToJDL(*os,"Arguments",(final ? "2":"1")); // for AOD_merge.sh, 1 means intermediate merging stage, 2 means final merging |
a58729a5 | 374 | |
375 | if ( !final ) | |
376 | { | |
81190958 | 377 | OutputToJDL(*os,"InputFile",Form("LF:%s/AODtrain.C",RemoteDir().Data())); |
378 | OutputToJDL(*os,"OutputDir",Form("%s/$1/Stage_$2/#alien_counter_03i#",RemoteDir().Data())); | |
379 | OutputToJDL(*os,"InputDataCollection",Form("%s/$1/Stage_$2.xml,nodownload",RemoteDir().Data())); | |
380 | OutputToJDL(*os,"split","se"); | |
381 | OutputToJDL(*os,"SplitMaxInputFileNumber",GetSplitMaxInputFileNumber()); | |
382 | OutputToJDL(*os,"InputDataListFormat","xml-single"); | |
383 | OutputToJDL(*os,"InputDataList","wn.xml"); | |
a58729a5 | 384 | } |
385 | else | |
386 | { | |
81190958 | 387 | OutputToJDL(*os,"InputFile",Form("LF:%s/AODtrain.C",RemoteDir().Data()), |
388 | Form("LF:%s/$1/wn.xml",RemoteDir().Data())); | |
389 | OutputToJDL(*os,"OutputDir",Form("%s/$1",RemoteDir().Data())); | |
a58729a5 | 390 | } |
391 | ||
392 | return kTRUE; | |
393 | } | |
394 | ||
395 | //______________________________________________________________________________ | |
81190958 | 396 | Bool_t AliMuonAccEffSubmitter::GenerateRunJDL(const char* name) const |
a58729a5 | 397 | { |
398 | /// Generate (locally) the JDL to perform the simulation+reco+aod filtering | |
399 | /// (to be then copied to the grid and finally submitted) | |
400 | ||
1afce1ce | 401 | AliDebug(1,""); |
402 | ||
a58729a5 | 403 | std::ostream* os = CreateJDLFile(name); |
404 | ||
405 | if (!os) | |
406 | { | |
407 | return kFALSE; | |
408 | } | |
409 | ||
81190958 | 410 | OutputToJDL(*os,"Packages", |
411 | GetMapValue("AliRoot"), | |
412 | GetMapValue("Geant3"), | |
413 | GetMapValue("Root"), | |
414 | GetMapValue("API")); | |
415 | ||
416 | OutputToJDL(*os,"Jobtag","comment: AliMuonAccEffSubmitter RUN $1"); | |
a58729a5 | 417 | |
81190958 | 418 | OutputToJDL(*os,"split","production:1-$2"); |
a58729a5 | 419 | |
81190958 | 420 | OutputToJDL(*os,"Price","1"); |
a58729a5 | 421 | |
81190958 | 422 | OutputToJDL(*os,"OutputDir",Form("%s/$1/#alien_counter_03i#",RemoteDir().Data())); |
a58729a5 | 423 | |
81190958 | 424 | OutputToJDL(*os,"Executable","/alice/bin/aliroot_new"); |
a58729a5 | 425 | |
426 | TObjArray files; | |
427 | files.SetOwner(kTRUE); | |
670f3174 | 428 | TIter next(LocalFileList()); |
a58729a5 | 429 | TObjString* file; |
430 | ||
431 | while ( ( file = static_cast<TObjString*>(next())) ) | |
432 | { | |
433 | if ( !file->String().Contains(".jdl",TString::kIgnoreCase) || | |
434 | !file->String().Contains("OCDB_") ) | |
435 | { | |
81190958 | 436 | files.Add(new TObjString(Form("LF:%s/%s",RemoteDir().Data(),file->String().Data()))); |
a58729a5 | 437 | } |
438 | } | |
439 | ||
440 | if ( fUseOCDBSnapshots ) | |
441 | { | |
81190958 | 442 | files.Add(new TObjString(Form("LF:%s/OCDB/$1/OCDB_sim.root",RemoteDir().Data()))); |
443 | files.Add(new TObjString(Form("LF:%s/OCDB/$1/OCDB_rec.root",RemoteDir().Data()))); | |
a58729a5 | 444 | } |
445 | ||
81190958 | 446 | OutputToJDL(*os,"InputFile",files); |
a58729a5 | 447 | |
448 | if ( CompactMode() == 0 ) | |
449 | { | |
450 | // store everything | |
81190958 | 451 | OutputToJDL(*os,"OutputArchive", "log_archive.zip:stderr,stdout,aod.log,checkaod.log,checkesd.log,rec.log,sim.log@disk=1", |
a58729a5 | 452 | "root_archive.zip:galice*.root,Kinematics*.root,TrackRefs*.root,AliESDs.root,AliAOD.root,AliAOD.Muons.root,Merged.QA.Data.root,Run*.root@disk=2"); |
453 | } | |
454 | else if ( CompactMode() == 1 ) | |
455 | { | |
81190958 | 456 | // keep only muon AODs and QA |
3e7b6e7b | 457 | OutputToJDL(*os,"OutputArchive", "log_archive.zip:stderr,stdout,*.log@disk=1", |
81190958 | 458 | "root_archive.zip:galice*.root,AliAOD.Muons.root,Merged.QA.Data.root@disk=2"); |
a58729a5 | 459 | } |
30138a88 | 460 | else if ( CompactMode() == 2 ) |
461 | { | |
462 | // keep only AODs and QA | |
463 | OutputToJDL(*os,"OutputArchive", "log_archive.zip:stderr,stdout,aod.log,checkaod.log,checkesd.log,rec.log,sim.log@disk=1", | |
464 | "root_archive.zip:galice*.root,AliAOD.root,Merged.QA.Data.root@disk=2"); | |
465 | } | |
a58729a5 | 466 | else |
467 | { | |
468 | AliError(Form("Unknown CompactMode %d",CompactMode())); | |
469 | delete os; | |
470 | return kFALSE; | |
471 | } | |
472 | ||
81190958 | 473 | OutputToJDL(*os,"splitarguments","simrun.C --run $1 --chunk #alien_counter# --event $3"); |
a58729a5 | 474 | |
81190958 | 475 | OutputToJDL(*os,"Workdirectorysize","5000MB"); |
a58729a5 | 476 | |
81190958 | 477 | OutputToJDL(*os,"JDLVariables","Packages","OutputDir"); |
a58729a5 | 478 | |
81190958 | 479 | OutputToJDL(*os,"Validationcommand",Form("%s/validation.sh",RemoteDir().Data())); |
a58729a5 | 480 | |
30138a88 | 481 | if ( GetVar("VAR_GENERATOR").Contains("pythia",TString::kIgnoreCase) ) |
482 | { | |
483 | OutputToJDL(*os,"TTL","36000"); | |
484 | } | |
485 | else | |
486 | { | |
3e7b6e7b | 487 | OutputToJDL(*os,"TTL","14400"); |
30138a88 | 488 | } |
a58729a5 | 489 | |
490 | return kTRUE; | |
491 | } | |
492 | ||
a58729a5 | 493 | //______________________________________________________________________________ |
494 | Bool_t AliMuonAccEffSubmitter::MakeOCDBSnapshots() | |
495 | { | |
496 | /// Run sim.C and rec.C in a special mode to generate OCDB snapshots | |
497 | /// Can only be done after the templates have been copied locally | |
498 | ||
499 | if (!IsValid()) return kFALSE; | |
500 | ||
501 | if (!fUseOCDBSnapshots) return kTRUE; | |
502 | ||
81190958 | 503 | if (!NofRuns()) return kFALSE; |
a58729a5 | 504 | |
1afce1ce | 505 | AliDebug(1,""); |
506 | ||
a58729a5 | 507 | Bool_t ok(kTRUE); |
508 | ||
81190958 | 509 | const std::vector<int>& runs = RunList(); |
510 | ||
a58729a5 | 511 | for ( std::vector<int>::size_type i = 0; i < runs.size(); ++i ) |
512 | { | |
513 | Int_t runNumber = runs[i]; | |
514 | ||
515 | TString ocdbSim(Form("%s/OCDB/%d/OCDB_sim.root",SnapshotDir().Data(),runNumber)); | |
516 | TString ocdbRec(Form("%s/OCDB/%d/OCDB_rec.root",SnapshotDir().Data(),runNumber)); | |
517 | ||
1afce1ce | 518 | if ( !gSystem->AccessPathName(ocdbSim.Data()) && |
a58729a5 | 519 | !gSystem->AccessPathName(ocdbRec.Data()) ) |
520 | { | |
521 | 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 | 522 | continue; |
a58729a5 | 523 | } |
524 | else | |
525 | { | |
526 | gSystem->Exec(Form("aliroot -b -q -x simrun.C --run %d --snapshot",runNumber)); | |
527 | ||
528 | if ( gSystem->AccessPathName(ocdbSim.Data()) ) | |
529 | { | |
530 | AliError(Form("Could not create OCDB snapshot for simulation")); | |
531 | ok = kFALSE; | |
532 | } | |
533 | ||
534 | if ( gSystem->AccessPathName(ocdbRec.Data()) ) | |
535 | { | |
536 | AliError(Form("Could not create OCDB snapshot for reconstruction")); | |
537 | ok = kFALSE; | |
538 | } | |
539 | } | |
540 | ||
eb5de7ee | 541 | AddToLocalFileList(ocdbSim); |
542 | AddToLocalFileList(ocdbRec); | |
a58729a5 | 543 | } |
544 | ||
545 | return ok; | |
546 | } | |
547 | ||
548 | //______________________________________________________________________________ | |
549 | Bool_t AliMuonAccEffSubmitter::Merge(Int_t stage, Bool_t dryRun) | |
550 | { | |
551 | /// Submit multiple merging jobs with the format "submit AOD_merge(_final).jdl run# (stage#)". | |
552 | /// Also produce the xml collection before sending jobs | |
553 | /// Initial AODs will be taken from fRemoteDir/[RUNNUMBER] while the merged | |
554 | /// ones will be put into fMergedDir/AODs/[RUNNUMBER] | |
555 | /// | |
556 | /// Example: | |
557 | /// - inDir = "/alice/sim/2012/LHC12a10_bis" (where to find the data to merge) | |
558 | /// = 0x0 --> inDir = homeDir/outDir/resDir | |
559 | /// - outDir = "Sim/LHC11h/embedding/AODs" (where to store merged results) | |
560 | /// - runList.txt must contains the list of run number | |
561 | /// - stage=0 --> final merging / stage>0 --> intermediate merging i | |
562 | /// | |
563 | ||
81190958 | 564 | if (!RemoteDirectoryExists(MergedDir().Data())) { |
565 | AliError(Form("directory %s does not exist", MergedDir().Data())); | |
a58729a5 | 566 | return kFALSE; |
567 | } | |
568 | ||
81190958 | 569 | gGrid->Cd(MergedDir().Data()); |
a58729a5 | 570 | |
571 | TString jdl = MergeJDLName(stage==0); | |
572 | ||
573 | if (!RemoteFileExists(jdl.Data())) | |
574 | { | |
81190958 | 575 | AliError(Form("file %s does not exist in %s\n", jdl.Data(), RemoteDir().Data())); |
a58729a5 | 576 | return kFALSE; |
577 | } | |
578 | ||
81190958 | 579 | const std::vector<int>& runs = RunList(); |
a58729a5 | 580 | |
581 | if (runs.empty()) | |
582 | { | |
583 | AliError("No run to work with"); | |
3e7b6e7b | 584 | return 0; |
a58729a5 | 585 | } |
586 | ||
587 | TString currRun; | |
588 | TString reply = ""; | |
589 | gSystem->Exec("rm -f __failed__"); | |
590 | Bool_t failedRun = kFALSE; | |
591 | ||
592 | for ( std::vector<int>::size_type i = 0; i < runs.size(); ++i ) | |
593 | { | |
594 | Int_t run = runs[i]; | |
595 | AliInfo(Form("\n --- processing run %d ---\n", run)); | |
596 | ||
81190958 | 597 | TString runDir = Form("%s/%d", MergedDir().Data(), run); |
a58729a5 | 598 | |
599 | if (!RemoteDirectoryExists(runDir.Data())) | |
600 | { | |
601 | AliInfo(Form(" - creating output directory %s\n", runDir.Data())); | |
602 | gSystem->Exec(Form("alien_mkdir -p %s", runDir.Data())); | |
603 | } | |
604 | ||
605 | if (RemoteFileExists(Form("%s/root_archive.zip", runDir.Data()))) | |
606 | { | |
607 | AliWarning(" ! final merging already done"); | |
608 | continue; | |
609 | } | |
610 | ||
611 | Int_t lastStage = GetLastStage(runDir.Data()); | |
612 | ||
613 | if (stage > 0 && stage != lastStage+1) | |
614 | { | |
615 | AliError(Form(" ! lastest merging stage = %d. Next must be stage %d or final stage\n", lastStage, lastStage+1)); | |
616 | continue; | |
617 | } | |
618 | ||
619 | TString wn = (stage > 0) ? Form("Stage_%d.xml", stage) : "wn.xml"; | |
620 | TString find = (lastStage == 0) ? | |
81190958 | 621 | Form("alien_find -x %s %s/%d *root_archive.zip", wn.Data(), RemoteDir().Data(), run) : |
622 | Form("alien_find -x %s %s/%d/Stage_%d *root_archive.zip", wn.Data(), RemoteDir().Data(), run, lastStage); | |
a58729a5 | 623 | gSystem->Exec(Form("%s 1> %s 2>/dev/null", find.Data(), wn.Data())); |
624 | gSystem->Exec(Form("grep -c /event %s > __nfiles__", wn.Data())); | |
625 | ifstream f2("__nfiles__"); | |
626 | TString nFiles; | |
627 | nFiles.ReadLine(f2,kTRUE); | |
628 | f2.close(); | |
629 | gSystem->Exec("rm -f __nfiles__"); | |
630 | printf(" - number of files to merge = %d\n", nFiles.Atoi()); | |
631 | if (nFiles.Atoi() == 0) { | |
632 | printf(" ! collection of files to merge is empty\n"); | |
633 | gSystem->Exec(Form("rm -f %s", wn.Data())); | |
634 | continue; | |
635 | } else if (stage > 0 && nFiles.Atoi() <= splitLevel && !reply.BeginsWith("y")) { | |
636 | if (!reply.BeginsWith("n")) { | |
637 | printf(" ! number of files to merge <= split level (%d). Continue? [Y/n] ", splitLevel); | |
638 | fflush(stdout); | |
639 | reply.Gets(stdin,kTRUE); | |
640 | reply.ToLower(); | |
641 | } | |
642 | if (reply.BeginsWith("n")) { | |
643 | gSystem->Exec(Form("rm -f %s", wn.Data())); | |
644 | continue; | |
645 | } else reply = "y"; | |
646 | } | |
647 | ||
648 | if (!dryRun) | |
649 | { | |
650 | TString dirwn = Form("%s/%s", runDir.Data(), wn.Data()); | |
651 | if (RemoteFileExists(dirwn.Data())) gGrid->Rm(dirwn.Data()); | |
652 | gSystem->Exec(Form("alien_cp file:%s alien://%s", wn.Data(), dirwn.Data())); | |
653 | gSystem->Exec(Form("rm -f %s", wn.Data())); | |
654 | } | |
655 | ||
656 | TString query; | |
657 | if (stage > 0) query = Form("submit %s %d %d", jdl.Data(), run, stage); | |
658 | else query = Form("submit %s %d", jdl.Data(), run); | |
659 | printf(" - %s ...", query.Data()); | |
660 | fflush(stdout); | |
661 | ||
662 | if (dryRun) | |
663 | { | |
664 | AliInfo(" dry run"); | |
665 | continue; | |
666 | } | |
667 | ||
668 | Bool_t done = kFALSE; | |
669 | TGridResult *res = gGrid->Command(query); | |
670 | if (res) | |
671 | { | |
672 | TString cjobId1 = res->GetKey(0,"jobId"); | |
673 | if (!cjobId1.IsDec()) | |
674 | { | |
675 | AliError(" FAILED"); | |
676 | gGrid->Stdout(); | |
677 | gGrid->Stderr(); | |
678 | } | |
679 | else | |
680 | { | |
681 | AliInfo(Form(" DONE\n --> the job Id is: %s \n", cjobId1.Data())); | |
682 | done = kTRUE; | |
683 | } | |
684 | delete res; | |
685 | } | |
686 | else | |
687 | { | |
688 | AliError(" FAILED"); | |
689 | } | |
690 | ||
691 | if (!done) | |
692 | { | |
693 | gSystem->Exec(Form("echo %d >> __failed__", run)); | |
694 | failedRun = kTRUE; | |
695 | } | |
696 | ||
697 | } | |
698 | ||
699 | if (failedRun) | |
700 | { | |
701 | AliInfo("\n--------------------\n"); | |
702 | AliInfo("list of failed runs:\n"); | |
703 | gSystem->Exec("cat __failed__"); | |
704 | gSystem->Exec("rm -f __failed__"); | |
705 | return kFALSE; | |
706 | } | |
707 | ||
708 | return kTRUE; | |
709 | } | |
710 | ||
711 | //______________________________________________________________________________ | |
81190958 | 712 | void AliMuonAccEffSubmitter::Print(Option_t* opt) const |
a58729a5 | 713 | { |
1afce1ce | 714 | /// Printout |
715 | ||
81190958 | 716 | AliMuonGridSubmitter::Print(opt); |
717 | ||
a58729a5 | 718 | if ( fRatio > 0 ) |
719 | { | |
30138a88 | 720 | std::cout << std::endl << Form("-- For each run, will generate %5.2f times the number of real events for trigger %s", |
81190958 | 721 | fRatio,ReferenceTrigger().Data()) << std::endl; |
a58729a5 | 722 | } |
723 | else | |
724 | { | |
30138a88 | 725 | std::cout << std::endl << Form("-- For each run, will generate %10d events",fFixedNofEvents) << std::endl; |
a58729a5 | 726 | } |
727 | ||
30138a88 | 728 | std::cout << "-- MaxEventsPerChunk = " << fMaxEventsPerChunk << std::endl; |
a58729a5 | 729 | |
30138a88 | 730 | std::cout << "-- Will" << (fUseOCDBSnapshots ? "" : " NOT") << " use OCDB snaphosts" << std::endl; |
a58729a5 | 731 | } |
732 | ||
733 | //______________________________________________________________________________ | |
734 | Bool_t AliMuonAccEffSubmitter::Run(const char* mode) | |
735 | { | |
736 | /// mode can be one of (case insensitive) | |
737 | /// | |
738 | /// LOCAL : copy the template files from the template directory to the local one | |
739 | /// UPLOAD : copy the local files to the grid (requires LOCAL) | |
740 | /// OCDB : make ocdb snapshots (requires LOCAL) | |
741 | /// SUBMIT : submit the jobs (requires LOCAL + UPLOAD) | |
742 | /// FULL : all of the above (requires all of the above) | |
743 | /// | |
744 | /// TEST : as SUBMIT, but in dry mode (does not actually submit the jobs) | |
eb5de7ee | 745 | /// |
746 | /// LOCALTEST : completely local test (including execution) | |
a58729a5 | 747 | |
748 | if (!IsValid()) return kFALSE; | |
749 | ||
750 | TString smode(mode); | |
751 | smode.ToUpper(); | |
752 | ||
753 | if ( smode == "FULL") | |
754 | { | |
755 | return ( Run("LOCAL") && Run("OCDB") && Run("UPLOAD") && Run("SUBMIT") ); | |
756 | } | |
757 | ||
758 | if ( smode == "LOCAL") | |
759 | { | |
760 | return CopyTemplateFilesToLocal(); | |
761 | } | |
762 | ||
763 | if ( smode == "UPLOAD" ) | |
764 | { | |
765 | return (CopyLocalFilesToRemote()); | |
766 | } | |
767 | ||
768 | if ( smode == "OCDB" ) | |
769 | { | |
770 | Bool_t ok = Run("LOCAL"); | |
771 | if (ok) | |
772 | { | |
773 | ok = MakeOCDBSnapshots(); | |
774 | } | |
775 | return ok; | |
776 | } | |
777 | ||
778 | if ( smode == "TEST" ) | |
779 | { | |
780 | Bool_t ok = Run("LOCAL") && Run("OCDB") && Run("UPLOAD"); | |
781 | if ( ok ) | |
782 | { | |
783 | ok = (Submit(kTRUE)>0); | |
784 | } | |
785 | return ok; | |
786 | } | |
787 | ||
788 | if ( smode == "FULL" ) | |
789 | { | |
790 | Bool_t ok = Run("LOCAL") && Run("OCDB") && Run("UPLOAD"); | |
791 | if ( ok ) | |
792 | { | |
793 | ok = (Submit(kFALSE)>0); | |
794 | } | |
795 | return ok; | |
796 | } | |
797 | ||
798 | if( smode == "SUBMIT" ) | |
799 | { | |
800 | return (Submit(kFALSE)>0); | |
801 | } | |
802 | ||
eb5de7ee | 803 | if ( smode == "LOCALTEST" ) |
804 | { | |
805 | Bool_t ok = Run("LOCAL"); | |
806 | if ( ok ) | |
807 | { | |
808 | ok = LocalTest(); | |
809 | } | |
810 | return ok; | |
811 | } | |
812 | ||
a58729a5 | 813 | return kFALSE; |
814 | } | |
815 | ||
1afce1ce | 816 | //______________________________________________________________________________ |
817 | Bool_t AliMuonAccEffSubmitter::SetGenerator(const char* generator) | |
818 | { | |
819 | // set the variable to select the generator macro in Config.C | |
820 | ||
821 | gSystem->Load("libEVGEN"); | |
1afce1ce | 822 | |
81190958 | 823 | Invalidate(); |
824 | ||
825 | TString generatorFile(Form("%s/%s.C",TemplateDir().Data(),generator)); | |
1afce1ce | 826 | |
827 | Int_t nofMissingVariables(0); | |
828 | ||
829 | // first check we indeed have such a macro | |
830 | if (!gSystem->AccessPathName(generatorFile.Data())) | |
831 | { | |
832 | TObjArray* variables = GetVariables(generatorFile.Data()); | |
833 | ||
834 | TIter next(variables); | |
835 | TObjString* var; | |
836 | ||
837 | while ( ( var = static_cast<TObjString*>(next())) ) | |
838 | { | |
81190958 | 839 | if ( !Vars()->GetValue(var->String()) ) |
1afce1ce | 840 | { |
841 | ++nofMissingVariables; | |
842 | AliError(Form("file %s expect the variable %s to be defined, but we've not defined it !",generatorFile.Data(),var->String().Data())); | |
843 | } | |
844 | } | |
845 | ||
846 | delete variables; | |
847 | ||
848 | if ( !nofMissingVariables ) | |
849 | { | |
850 | if (CheckCompilation(generatorFile.Data())) | |
851 | { | |
81190958 | 852 | Validate(); |
1afce1ce | 853 | SetVar("VAR_GENERATOR",Form("%s",generator)); |
81190958 | 854 | AddToTemplateFileList(Form("%s.C",generator)); |
1afce1ce | 855 | return kTRUE; |
856 | } | |
857 | } | |
858 | else | |
859 | { | |
860 | return kFALSE; | |
861 | } | |
862 | } | |
863 | else | |
864 | { | |
865 | AliError(Form("Can not work with the macro %s",generatorFile.Data())); | |
866 | } | |
867 | return kFALSE; | |
868 | } | |
869 | ||
1afce1ce | 870 | //______________________________________________________________________________ |
871 | void AliMuonAccEffSubmitter::SetOCDBPath(const char* ocdbPath) | |
872 | { | |
873 | /// Sets the OCDB path to be used | |
874 | ||
81190958 | 875 | SetMapKeyValue("OCDBPath",ocdbPath); |
1afce1ce | 876 | } |
877 | ||
878 | ||
879 | //______________________________________________________________________________ | |
880 | void AliMuonAccEffSubmitter::SetOCDBSnapshotDir(const char* dir) | |
881 | { | |
882 | // change the directory used for snapshot | |
883 | ||
884 | if (gSystem->AccessPathName(Form("%s/OCDB",dir))) | |
885 | { | |
886 | AliError(Form("Snapshot top directory (%s) should contain an OCDB subdir with runnumbers in there",dir)); | |
887 | } | |
888 | else | |
889 | { | |
81190958 | 890 | SetMapKeyValue("OCDBSnapshot",dir); |
1afce1ce | 891 | } |
892 | } | |
893 | ||
a58729a5 | 894 | //______________________________________________________________________________ |
81190958 | 895 | void AliMuonAccEffSubmitter::MakeNofEventsPropToTriggerCount(const char* trigger, Float_t ratio) |
a58729a5 | 896 | { |
81190958 | 897 | SetMapKeyValue("ReferenceTrigger",trigger); |
898 | fRatio = ratio; | |
899 | } | |
900 | ||
901 | //______________________________________________________________________________ | |
902 | void AliMuonAccEffSubmitter::MakeNofEventsFixed(Int_t nevents) | |
903 | { | |
904 | fFixedNofEvents = nevents; | |
905 | fRatio=0.0; | |
906 | SetMapKeyValue("ReferenceTrigger",""); | |
a58729a5 | 907 | } |
908 | ||
eb5de7ee | 909 | //______________________________________________________________________________ |
910 | Int_t AliMuonAccEffSubmitter::LocalTest() | |
911 | { | |
912 | /// Generate a local macro (simrun.sh) to execute locally a full scale test | |
913 | /// Can only be used with a fixed number of events (and runnumber is fixed to zero) | |
914 | ||
915 | if ( fRatio > 0 ) | |
916 | { | |
917 | AliError("Can only work in local test with a fixed number of events"); | |
918 | return 0; | |
919 | } | |
920 | ||
921 | if ( fFixedNofEvents <= 0 ) | |
922 | { | |
923 | AliError("Please fix the number of input events using MakeNofEventsFixed()"); | |
924 | return 0; | |
925 | } | |
8907673b | 926 | |
927 | const std::vector<int>& runs = RunList(); | |
eb5de7ee | 928 | |
3e7b6e7b | 929 | if ( runs.empty() ) |
930 | { | |
931 | AliError("No run to work with"); | |
932 | return 0; | |
933 | } | |
934 | ||
eb5de7ee | 935 | std::cout << "Generating script to execute : ./simrun.sh" << std::endl; |
3e7b6e7b | 936 | |
eb5de7ee | 937 | std::ofstream out("simrun.sh"); |
938 | ||
939 | out << "#!/bin/bash" << std::endl; | |
940 | // root.exe -b -q simrun.C --run <x> --chunk <y> --event <n> | |
8907673b | 941 | out << "root.exe -b -q simrun.C --run "<< runs[0] <<" --event " << fFixedNofEvents << std::endl; |
eb5de7ee | 942 | |
943 | gSystem->Exec("chmod +x simrun.sh"); | |
3e7b6e7b | 944 | |
945 | std::cout << "Cleaning up left-over files from previous simulation/reconstructions" << std::endl; | |
eb5de7ee | 946 | |
3e7b6e7b | 947 | 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"); |
948 | ||
eb5de7ee | 949 | std::cout << "Executing the script : ./simrun.sh" << std::endl; |
950 | ||
3e7b6e7b | 951 | |
eb5de7ee | 952 | gSystem->Exec("./simrun.sh"); |
953 | ||
954 | return 1; | |
955 | } | |
81190958 | 956 | |
3e7b6e7b | 957 | namespace { |
958 | ||
959 | void OutputRunList(const char* filename, const std::vector<int>& runlist) | |
960 | { | |
961 | /// output a runlist to ASCII file | |
962 | ||
963 | std::ofstream out(filename); | |
964 | ||
965 | for ( std::vector<int>::size_type j = 0; j < runlist.size(); ++j ) | |
966 | { | |
967 | out << runlist[j] << std::endl; | |
968 | } | |
969 | } | |
970 | } | |
971 | ||
972 | //______________________________________________________________________________ | |
973 | Int_t AliMuonAccEffSubmitter::SplitRunList(const char* inputList, int maxJobs) | |
974 | { | |
975 | /// In order to be able to submit, split a given runlist into chunks that will | |
976 | /// fit within maxJobs (1500 for a typical user) | |
977 | ||
978 | std::vector<int> runs; | |
979 | ||
980 | AliAnalysisTriggerScalers tmp(inputList); | |
981 | runs = tmp.GetRunList(); | |
982 | ||
983 | AliAnalysisTriggerScalers* ts(0x0); | |
984 | std::vector<int> currentRunList; | |
985 | ||
986 | int nJobs(0); | |
987 | int nTotalJobs(0); | |
988 | int nEvts(0); | |
989 | int nFiles(0); | |
990 | ||
991 | for (std::vector<int>::size_type i=0; i < runs.size(); ++i) | |
992 | { | |
993 | Int_t runNumber = runs[i]; | |
994 | ||
995 | Int_t nEvtRun(fFixedNofEvents); | |
996 | ||
997 | if ( fRatio > 0 ) | |
998 | { | |
999 | if (!ts) | |
1000 | { | |
1001 | AliInfo(Form("Creating AliAnalysisTriggerScalers from OCDB=%s",OCDBPath().Data())); | |
1002 | ts = new AliAnalysisTriggerScalers(runs,OCDBPath().Data()); | |
1003 | } | |
1004 | ||
1005 | AliAnalysisTriggerScalerItem* trigger = ts->GetTriggerScaler(runNumber, "L2A", ReferenceTrigger().Data()); | |
1006 | ||
1007 | if (!trigger) | |
1008 | { | |
1009 | AliError(Form("Could not get trigger %s for run %09d",ReferenceTrigger().Data(),runNumber)); | |
1010 | continue; | |
1011 | } | |
1012 | nEvtRun = TMath::Nint(fRatio * trigger->Value()); | |
1013 | } | |
1014 | ||
1015 | Int_t nChunk = 1; | |
1016 | ||
1017 | while (nEvtRun/nChunk+0.5 > MaxEventsPerChunk()) | |
1018 | { | |
1019 | ++nChunk; | |
1020 | } | |
1021 | ||
1022 | Int_t nEvtChunk = TMath::Nint(nEvtRun/nChunk + 0.5); | |
1023 | ||
1024 | nJobs += nChunk; | |
1025 | ||
1026 | nTotalJobs += nChunk; | |
1027 | ||
1028 | nEvts += nChunk*nEvtChunk; | |
1029 | ||
1030 | if ( nJobs > maxJobs ) | |
1031 | { | |
1032 | ++nFiles; | |
1033 | ||
1034 | OutputRunList(Form("%s.%d",inputList,nFiles),currentRunList); | |
1035 | nJobs = 0; | |
1036 | currentRunList.clear(); | |
1037 | } | |
1038 | ||
1039 | ||
1040 | currentRunList.push_back(runNumber); | |
1041 | ||
1042 | } | |
1043 | ||
1044 | if ( !currentRunList.empty() ) | |
1045 | { | |
1046 | ++nFiles; | |
1047 | OutputRunList(Form("%s.%d",inputList,nFiles),currentRunList); | |
1048 | ||
1049 | } | |
1050 | ||
1051 | delete ts; | |
1052 | ||
1053 | std::cout << Form("input run list was split into %d files. Total number of jobs %d. Total number of events %d", | |
1054 | nFiles,nTotalJobs,nEvts) << std::endl; | |
1055 | ||
1056 | return nFiles; | |
1057 | } | |
1058 | ||
1059 | ||
a58729a5 | 1060 | //______________________________________________________________________________ |
1061 | Int_t AliMuonAccEffSubmitter::Submit(Bool_t dryRun) | |
1062 | { | |
1063 | /// Submit multiple production jobs with the format "submit jdl 000run#.xml 000run#". | |
1064 | /// | |
1065 | /// Return the number of submitted (master) jobs | |
1066 | /// | |
1067 | /// Example: | |
1068 | /// - outputDir = "/alice/cern.ch/user/p/ppillot/Sim/LHC10h/JPsiPbPb276/AlignRawVtxRaw/ESDs" | |
1069 | /// - runList must contains the list of run number | |
1070 | /// - trigger is the (fully qualified) trigger name used to compute the base number of events | |
1071 | /// - mult is the factor to apply to the number of trigger to get the number of events to be generated | |
1072 | /// (# generated events = # triggers x mult | |
1073 | ||
1074 | if (!IsValid()) return 0; | |
1075 | ||
1afce1ce | 1076 | AliDebug(1,""); |
1077 | ||
a58729a5 | 1078 | gGrid->Cd(RemoteDir()); |
1079 | ||
1080 | if (!RemoteFileExists(RunJDLName())) | |
1081 | { | |
1082 | AliError(Form("file %s does not exist in %s", RunJDLName().Data(), RemoteDir().Data())); | |
1083 | return 0; | |
1084 | } | |
1085 | ||
81190958 | 1086 | if ( !NofRuns() ) |
a58729a5 | 1087 | { |
1088 | AliError("No run list set. Use SetRunList"); | |
1089 | return 0; | |
1090 | } | |
81190958 | 1091 | const std::vector<int>& runs = RunList(); |
a58729a5 | 1092 | |
1093 | if (runs.empty()) | |
1094 | { | |
1095 | AliError("No run to work with"); | |
1096 | return 0; | |
1097 | } | |
1098 | ||
1099 | // cout << "total number of selected MB events = " << totEvt << endl; | |
1100 | // cout << "required number of generated events = " << nGenEvents << endl; | |
1101 | // cout << "number of generated events per MB event = " << ratio << endl; | |
1102 | // cout << endl; | |
1103 | ||
1104 | std::cout << "run\tchunks\tevents" << std::endl; | |
1105 | std::cout << "----------------------" << std::endl; | |
1106 | ||
1107 | Int_t nJobs(0); | |
1108 | Int_t nEvts(0); | |
1109 | ||
81190958 | 1110 | AliAnalysisTriggerScalers* ts(0x0); |
1111 | ||
a58729a5 | 1112 | for (std::vector<int>::size_type i=0; i < runs.size(); ++i) |
1113 | { | |
1114 | Int_t runNumber = runs[i]; | |
1115 | ||
1116 | Int_t nEvtRun(fFixedNofEvents); | |
1117 | ||
1118 | if ( fRatio > 0 ) | |
1119 | { | |
81190958 | 1120 | if (!ts) |
1121 | { | |
1122 | AliInfo(Form("Creating AliAnalysisTriggerScalers from OCDB=%s",OCDBPath().Data())); | |
1123 | ts = new AliAnalysisTriggerScalers(runs,OCDBPath().Data()); | |
1124 | } | |
1125 | ||
1126 | AliAnalysisTriggerScalerItem* trigger = ts->GetTriggerScaler(runNumber, "L2A", ReferenceTrigger().Data()); | |
a58729a5 | 1127 | |
1128 | if (!trigger) | |
1129 | { | |
1130 | AliError(Form("Could not get trigger %s for run %09d",ReferenceTrigger().Data(),runNumber)); | |
1131 | continue; | |
1132 | } | |
1133 | nEvtRun = TMath::Nint(fRatio * trigger->Value()); | |
1134 | } | |
1135 | ||
1136 | Int_t nChunk = 1; | |
1137 | ||
1138 | while (nEvtRun/nChunk+0.5 > MaxEventsPerChunk()) | |
1139 | { | |
1140 | ++nChunk; | |
1141 | } | |
1142 | ||
1143 | Int_t nEvtChunk = TMath::Nint(nEvtRun/nChunk + 0.5); | |
1144 | ||
1145 | nJobs += nChunk; | |
1146 | ||
1147 | nEvts += nChunk*nEvtChunk; | |
1148 | ||
1149 | std::cout << runNumber << "\t" << nChunk << "\t" << nEvtChunk << std::endl; | |
1150 | ||
1151 | TString query(Form("submit %s %d %d %d", RunJDLName().Data(), runNumber, nChunk, nEvtChunk)); | |
1152 | ||
1153 | std::cout << query.Data() << " ..." << std::flush; | |
1154 | ||
1155 | TGridResult* res = 0x0; | |
1156 | ||
1157 | if (!dryRun) | |
1158 | { | |
1159 | res = gGrid->Command(query); | |
1160 | } | |
1161 | ||
1162 | if (res) | |
1163 | { | |
1164 | TString cjobId1 = res->GetKey(0,"jobId"); | |
1165 | ||
1166 | if (!cjobId1.Length()) | |
1167 | { | |
1168 | std::cout << " FAILED" << std::endl << std::endl; | |
1169 | gGrid->Stdout(); | |
1170 | gGrid->Stderr(); | |
1171 | } | |
1172 | else | |
1173 | { | |
1174 | std::cout << "DONE" << std::endl; | |
1175 | std::cout << Form(" --> the job Id is: %s",cjobId1.Data()) << std::endl << std::endl; | |
1176 | } | |
1177 | } | |
1178 | else | |
1179 | { | |
1180 | std::cout << " FAILED" << std::endl << std::endl; | |
1181 | } | |
1182 | ||
1183 | delete res; | |
1184 | } | |
1185 | ||
1186 | std::cout << std::endl | |
1187 | << "total number of jobs = " << nJobs << std::endl | |
1188 | << "total number of generated events = " << nEvts << std::endl | |
1189 | << std::endl; | |
1190 | ||
81190958 | 1191 | delete ts; |
a58729a5 | 1192 | |
81190958 | 1193 | return nJobs; |
a58729a5 | 1194 | } |
1195 | ||
1196 | //______________________________________________________________________________ | |
1197 | void AliMuonAccEffSubmitter::UpdateLocalFileList(Bool_t clearSnapshots) | |
1198 | { | |
1afce1ce | 1199 | /// Update the list of local files |
1200 | ||
81190958 | 1201 | AliMuonGridSubmitter::UpdateLocalFileList(); |
1202 | ||
1203 | if (!NofRuns()) return; | |
a58729a5 | 1204 | |
1205 | if ( clearSnapshots ) | |
1206 | { | |
1207 | TIter next(LocalFileList()); | |
1208 | TObjString* file; | |
1209 | ||
1210 | while ( ( file = static_cast<TObjString*>(next())) ) | |
1211 | { | |
1212 | if ( file->String().Contains("OCDB_") ) | |
1213 | { | |
1214 | LocalFileList()->Remove(file); | |
1215 | } | |
1216 | } | |
1217 | LocalFileList()->Compress(); | |
1218 | } | |
1219 | ||
a58729a5 | 1220 | const char* type[] = { "sim","rec" }; |
1221 | ||
81190958 | 1222 | const std::vector<int>& runs = RunList(); |
1223 | ||
a58729a5 | 1224 | for ( std::vector<int>::size_type i = 0; i < runs.size(); ++i ) |
1225 | { | |
1226 | Int_t runNumber = runs[i]; | |
1227 | ||
1228 | for ( Int_t t = 0; t < 2; ++t ) | |
1229 | { | |
1230 | TString snapshot(Form("%s/OCDB/%d/OCDB_%s.root",SnapshotDir().Data(),runNumber,type[t])); | |
1231 | ||
1232 | if ( !gSystem->AccessPathName(snapshot.Data()) ) | |
1233 | { | |
eb5de7ee | 1234 | AddToLocalFileList(snapshot); |
a58729a5 | 1235 | } |
1236 | } | |
1237 | } | |
a58729a5 | 1238 | } |
1239 | ||
1240 | //______________________________________________________________________________ | |
1241 | void AliMuonAccEffSubmitter::UseOCDBSnapshots(Bool_t flag) | |
1242 | { | |
1afce1ce | 1243 | /// Whether or not to use OCDB snapshots |
1244 | /// Using OCDB snapshots will speed-up both the sim and reco initialization | |
1245 | /// phases on each worker node, but takes time to produce... | |
1246 | /// So using them is not always a win-win... | |
1247 | ||
a58729a5 | 1248 | fUseOCDBSnapshots = flag; |
1249 | if ( flag ) | |
1250 | { | |
1251 | SetVar("VAR_OCDB_SNAPSHOT","kTRUE"); | |
30138a88 | 1252 | |
1253 | // for some reason must include ITS objects in the snapshot | |
1254 | // (to be able to instantiante the vertexer later on ?) | |
1255 | ||
1256 | SetVar("VAR_USE_ITS_RECO","1"); | |
a58729a5 | 1257 | } |
1258 | else | |
1259 | { | |
1260 | SetVar("VAR_OCDB_SNAPSHOT","kFALSE"); | |
1261 | } | |
1262 | ||
1263 | UpdateLocalFileList(); | |
1264 | } | |
1265 | ||
a3c2a88b | 1266 | //______________________________________________________________________________ |
1267 | void AliMuonAccEffSubmitter::UseAODMerging(Bool_t flag) | |
1268 | { | |
1269 | /// whether or not we should generate JDL for merging AODs | |
1270 | ||
1271 | fUseAODMerging = flag; | |
81190958 | 1272 | |
1273 | AddToTemplateFileList(MergeJDLName(kFALSE).Data()); | |
1274 | AddToTemplateFileList(MergeJDLName(kTRUE).Data()); | |
1275 | AddToTemplateFileList("AOD_merge.sh"); | |
1276 | AddToTemplateFileList("validation_merge.sh"); | |
1277 | } | |
1278 | ||
1279 | //______________________________________________________________________________ | |
1280 | void AliMuonAccEffSubmitter::UseExternalConfig(const char* externalConfigFullFilePath) | |
1281 | { | |
1282 | // use an external config (or the default Config.C if externalConfigFullFilePath="") | |
1283 | ||
1284 | fExternalConfig = externalConfigFullFilePath; | |
1285 | if ( fExternalConfig.Length() > 0 ) | |
1286 | { | |
1287 | AddToTemplateFileList(fExternalConfig); | |
1288 | } | |
1289 | else | |
1290 | { | |
1291 | AddToTemplateFileList("Config.C"); | |
1292 | } | |
a3c2a88b | 1293 | } |