1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // AliMuonAccEffSubmitter : a class to help submit Acc x Eff simulations
18 // anchored to real runs for J/psi, upsilon, single muons, etc...
20 // This class is dealing with 3 different directories :
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
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
34 // - remote directory, the alien directory where the files will be copied
35 // (from the local directory) before the actual submission
37 // ==========================================================
41 // AliMuonAccEffSubmitter a;
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);
49 // a.Run("test"); // will do everything but the submit
50 // a.Submit(false); // actual submission
53 // author: Laurent Aphecetche (Subatech
56 #include "AliMuonAccEffSubmitter.h"
58 #include "AliAnalysisTriggerScalers.h"
62 #include "TGridResult.h"
65 #include "TObjString.h"
77 ClassImp(AliMuonAccEffSubmitter)
79 //______________________________________________________________________________
80 AliMuonAccEffSubmitter::AliMuonAccEffSubmitter(const char* generator, Bool_t localOnly)
81 : AliMuonGridSubmitter(AliMuonGridSubmitter::kAccEff,localOnly),
83 fFixedNofEvents(10000),
84 fMaxEventsPerChunk(5000),
86 fSplitMaxInputFileNumber(20),
89 fUseOCDBSnapshots(kFALSE),
91 fUseAODMerging(kFALSE)
95 TString ocdbPath("raw://");
98 ocdbPath = "local://$ALICE_ROOT/OCDB";
101 SetOCDBPath(ocdbPath.Data());
103 SetLocalDirectory("Snapshot",LocalDir());
105 SetVar("VAR_OCDB_PATH",Form("\"%s\"",ocdbPath.Data()));
107 SetVar("VAR_GENPARAM_INCLUDE","AliGenMUONLib.h");
108 SetVar("VAR_GENPARAM_NPART","1");
109 SetVar("VAR_GENPARAM_GENLIB_TYPE","AliGenMUONlib::kJpsi");
110 SetVar("VAR_GENPARAM_GENLIB_PARNAME","\"pPb 5.03\"");
112 SetVar("VAR_GENCORRHF_QUARK","5");
113 SetVar("VAR_GENCORRHF_ENERGY","5");
115 // some default values for J/psi
116 SetVar("VAR_GENPARAMCUSTOM_PDGPARTICLECODE","443");
118 // default values below are from J/psi p+Pb (from muon_calo pass)
119 SetVar("VAR_GENPARAMCUSTOM_Y_P0","4.08E5");
120 SetVar("VAR_GENPARAMCUSTOM_Y_P1","7.1E4");
122 SetVar("VAR_GENPARAMCUSTOM_PT_P0","1.13E9");
123 SetVar("VAR_GENPARAMCUSTOM_PT_P1","18.05");
124 SetVar("VAR_GENPARAMCUSTOM_PT_P2","2.05");
125 SetVar("VAR_GENPARAMCUSTOM_PT_P3","3.34");
127 // some default values for single muons
128 SetVar("VAR_GENPARAMCUSTOMSINGLE_PTMIN","0.35");
130 SetVar("VAR_GENPARAMCUSTOMSINGLE_PT_P0","4.05962");
131 SetVar("VAR_GENPARAMCUSTOMSINGLE_PT_P1","1.0");
132 SetVar("VAR_GENPARAMCUSTOMSINGLE_PT_P2","2.46187");
133 SetVar("VAR_GENPARAMCUSTOMSINGLE_PT_P3","2.08644");
135 SetVar("VAR_GENPARAMCUSTOMSINGLE_Y_P0","0.729545");
136 SetVar("VAR_GENPARAMCUSTOMSINGLE_Y_P1","0.53837");
137 SetVar("VAR_GENPARAMCUSTOMSINGLE_Y_P2","0.141776");
138 SetVar("VAR_GENPARAMCUSTOMSINGLE_Y_P3","0.0130173");
140 SetVar("VAR_PURELY_LOCAL",Form("%d",localOnly));
142 SetVar("VAR_SIM_ALIGNDATA","\"alien://folder=/alice/simulation/2008/v4-15-Release/Ideal\"");
144 SetVar("VAR_REC_ALIGNDATA","\"alien://folder=/alice/simulation/2008/v4-15-Release/Residual\"");
146 UseOCDBSnapshots(fUseOCDBSnapshots);
148 SetGenerator(generator);
150 MakeNofEventsPropToTriggerCount();
152 AddToTemplateFileList("CheckESD.C");
153 AddToTemplateFileList("CheckAOD.C");
154 AddToTemplateFileList("AODtrain.C");
155 AddToTemplateFileList("validation.sh");
157 AddToTemplateFileList("Config.C");
158 AddToTemplateFileList("rec.C");
159 AddToTemplateFileList("sim.C");
160 AddToTemplateFileList("simrun.C");
161 AddToTemplateFileList(RunJDLName().Data());
163 UseExternalConfig(fExternalConfig);
166 //______________________________________________________________________________
167 AliMuonAccEffSubmitter::~AliMuonAccEffSubmitter()
172 ///______________________________________________________________________________
173 Bool_t AliMuonAccEffSubmitter::Generate(const char* jdlname) const
175 if ( TString(jdlname).Contains("merge",TString::kIgnoreCase) )
177 return GenerateMergeJDL(jdlname);
181 return GenerateRunJDL(jdlname);
185 ///______________________________________________________________________________
186 Bool_t AliMuonAccEffSubmitter::GenerateMergeJDL(const char* name) const
188 /// Create the JDL for merging jobs
189 /// FIXME: not checked !
193 std::ostream* os = CreateJDLFile(name);
200 Bool_t final = TString(name).Contains("merge",TString::kIgnoreCase);
202 (*os) << "# Generated merging jdl (production mode)" << std::endl
203 << "# $1 = run number" << std::endl
204 << "# $2 = merging stage" << std::endl
205 << "# Stage_<n>.xml made via: find <OutputDir> *Stage<n-1>/*root_archive.zip" << std::endl;
207 OutputToJDL(*os,"Packages",
208 GetMapValue("AliRoot"),
209 GetMapValue("Geant3"),
213 OutputToJDL(*os,"Executable","AOD_merge.sh");
215 OutputToJDL(*os,"Price","1");
219 OutputToJDL(*os,"Jobtag","comment: AliMuonAccEffSubmitter final merging");
223 OutputToJDL(*os,"Jobtag","comment: AliMuonAccEffSubmitter merging stage $2");
226 OutputToJDL(*os,"Workdirectorysize","5000MB");
228 OutputToJDL(*os,"Validationcommand",Form("%s/validation_merge.sh",RemoteDir().Data()));
230 OutputToJDL(*os,"TTL","7200");
232 OutputToJDL(*os,"OutputArchive",
233 "log_archive.zip:stderr,stdout@disk=1",
234 "root_archive.zip:AliAOD.root,AliAOD.Muons.root,AnalysisResults.root@disk=3"
237 OutputToJDL(*os,"Arguments",(final ? "2":"1")); // for AOD_merge.sh, 1 means intermediate merging stage, 2 means final merging
241 OutputToJDL(*os,"InputFile",Form("LF:%s/AODtrain.C",RemoteDir().Data()));
242 OutputToJDL(*os,"OutputDir",Form("%s/$1/Stage_$2/#alien_counter_03i#",RemoteDir().Data()));
243 OutputToJDL(*os,"InputDataCollection",Form("%s/$1/Stage_$2.xml,nodownload",RemoteDir().Data()));
244 OutputToJDL(*os,"split","se");
245 OutputToJDL(*os,"SplitMaxInputFileNumber",GetSplitMaxInputFileNumber());
246 OutputToJDL(*os,"InputDataListFormat","xml-single");
247 OutputToJDL(*os,"InputDataList","wn.xml");
251 OutputToJDL(*os,"InputFile",Form("LF:%s/AODtrain.C",RemoteDir().Data()),
252 Form("LF:%s/$1/wn.xml",RemoteDir().Data()));
253 OutputToJDL(*os,"OutputDir",Form("%s/$1",RemoteDir().Data()));
259 //______________________________________________________________________________
260 Bool_t AliMuonAccEffSubmitter::GenerateRunJDL(const char* name) const
262 /// Generate (locally) the JDL to perform the simulation+reco+aod filtering
263 /// (to be then copied to the grid and finally submitted)
267 std::ostream* os = CreateJDLFile(name);
274 OutputToJDL(*os,"Packages",
275 GetMapValue("AliRoot"),
276 GetMapValue("Geant3"),
280 OutputToJDL(*os,"Jobtag","comment: AliMuonAccEffSubmitter RUN $1");
282 OutputToJDL(*os,"split","production:1-$2");
284 OutputToJDL(*os,"Price","1");
286 OutputToJDL(*os,"OutputDir",Form("%s/$1/#alien_counter_03i#",RemoteDir().Data()));
288 OutputToJDL(*os,"Executable","/alice/bin/aliroot_new");
291 files.SetOwner(kTRUE);
292 TIter next(LocalFileList());
295 while ( ( file = static_cast<TObjString*>(next())) )
297 if ( !file->String().Contains(".jdl",TString::kIgnoreCase) ||
298 !file->String().Contains("OCDB_") )
300 files.Add(new TObjString(Form("LF:%s/%s",RemoteDir().Data(),file->String().Data())));
304 if ( fUseOCDBSnapshots )
306 files.Add(new TObjString(Form("LF:%s/OCDB/$1/OCDB_sim.root",RemoteDir().Data())));
307 files.Add(new TObjString(Form("LF:%s/OCDB/$1/OCDB_rec.root",RemoteDir().Data())));
310 OutputToJDL(*os,"InputFile",files);
312 if ( CompactMode() == 0 )
315 OutputToJDL(*os,"OutputArchive", "log_archive.zip:stderr,stdout,aod.log,checkaod.log,checkesd.log,rec.log,sim.log@disk=1",
316 "root_archive.zip:galice*.root,Kinematics*.root,TrackRefs*.root,AliESDs.root,AliAOD.root,AliAOD.Muons.root,Merged.QA.Data.root,Run*.root@disk=2");
318 else if ( CompactMode() == 1 )
320 // keep only muon AODs and QA
321 OutputToJDL(*os,"OutputArchive", "log_archive.zip:stderr,stdout,aod.log,checkaod.log,checkesd.log,rec.log,sim.log@disk=1",
322 "root_archive.zip:galice*.root,AliAOD.Muons.root,Merged.QA.Data.root@disk=2");
326 AliError(Form("Unknown CompactMode %d",CompactMode()));
331 OutputToJDL(*os,"splitarguments","simrun.C --run $1 --chunk #alien_counter# --event $3");
333 OutputToJDL(*os,"Workdirectorysize","5000MB");
335 OutputToJDL(*os,"JDLVariables","Packages","OutputDir");
337 OutputToJDL(*os,"Validationcommand",Form("%s/validation.sh",RemoteDir().Data()));
339 OutputToJDL(*os,"TTL","72000");
344 //______________________________________________________________________________
345 Bool_t AliMuonAccEffSubmitter::MakeOCDBSnapshots()
347 /// Run sim.C and rec.C in a special mode to generate OCDB snapshots
348 /// Can only be done after the templates have been copied locally
350 if (!IsValid()) return kFALSE;
352 if (!fUseOCDBSnapshots) return kTRUE;
354 if (!NofRuns()) return kFALSE;
360 const std::vector<int>& runs = RunList();
362 for ( std::vector<int>::size_type i = 0; i < runs.size(); ++i )
364 Int_t runNumber = runs[i];
366 TString ocdbSim(Form("%s/OCDB/%d/OCDB_sim.root",SnapshotDir().Data(),runNumber));
367 TString ocdbRec(Form("%s/OCDB/%d/OCDB_rec.root",SnapshotDir().Data(),runNumber));
369 if ( !gSystem->AccessPathName(ocdbSim.Data()) &&
370 !gSystem->AccessPathName(ocdbRec.Data()) )
372 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));
377 gSystem->Exec(Form("aliroot -b -q -x simrun.C --run %d --snapshot",runNumber));
379 if ( gSystem->AccessPathName(ocdbSim.Data()) )
381 AliError(Form("Could not create OCDB snapshot for simulation"));
385 if ( gSystem->AccessPathName(ocdbRec.Data()) )
387 AliError(Form("Could not create OCDB snapshot for reconstruction"));
392 AddToLocalFileList(ocdbSim);
393 AddToLocalFileList(ocdbRec);
399 //______________________________________________________________________________
400 Bool_t AliMuonAccEffSubmitter::Merge(Int_t stage, Bool_t dryRun)
402 /// Submit multiple merging jobs with the format "submit AOD_merge(_final).jdl run# (stage#)".
403 /// Also produce the xml collection before sending jobs
404 /// Initial AODs will be taken from fRemoteDir/[RUNNUMBER] while the merged
405 /// ones will be put into fMergedDir/AODs/[RUNNUMBER]
408 /// - inDir = "/alice/sim/2012/LHC12a10_bis" (where to find the data to merge)
409 /// = 0x0 --> inDir = homeDir/outDir/resDir
410 /// - outDir = "Sim/LHC11h/embedding/AODs" (where to store merged results)
411 /// - runList.txt must contains the list of run number
412 /// - stage=0 --> final merging / stage>0 --> intermediate merging i
415 if (!RemoteDirectoryExists(MergedDir().Data())) {
416 AliError(Form("directory %s does not exist", MergedDir().Data()));
420 gGrid->Cd(MergedDir().Data());
422 TString jdl = MergeJDLName(stage==0);
424 if (!RemoteFileExists(jdl.Data()))
426 AliError(Form("file %s does not exist in %s\n", jdl.Data(), RemoteDir().Data()));
430 const std::vector<int>& runs = RunList();
434 AliError("No run to work with");
440 gSystem->Exec("rm -f __failed__");
441 Bool_t failedRun = kFALSE;
443 for ( std::vector<int>::size_type i = 0; i < runs.size(); ++i )
446 AliInfo(Form("\n --- processing run %d ---\n", run));
448 TString runDir = Form("%s/%d", MergedDir().Data(), run);
450 if (!RemoteDirectoryExists(runDir.Data()))
452 AliInfo(Form(" - creating output directory %s\n", runDir.Data()));
453 gSystem->Exec(Form("alien_mkdir -p %s", runDir.Data()));
456 if (RemoteFileExists(Form("%s/root_archive.zip", runDir.Data())))
458 AliWarning(" ! final merging already done");
462 Int_t lastStage = GetLastStage(runDir.Data());
464 if (stage > 0 && stage != lastStage+1)
466 AliError(Form(" ! lastest merging stage = %d. Next must be stage %d or final stage\n", lastStage, lastStage+1));
470 TString wn = (stage > 0) ? Form("Stage_%d.xml", stage) : "wn.xml";
471 TString find = (lastStage == 0) ?
472 Form("alien_find -x %s %s/%d *root_archive.zip", wn.Data(), RemoteDir().Data(), run) :
473 Form("alien_find -x %s %s/%d/Stage_%d *root_archive.zip", wn.Data(), RemoteDir().Data(), run, lastStage);
474 gSystem->Exec(Form("%s 1> %s 2>/dev/null", find.Data(), wn.Data()));
475 gSystem->Exec(Form("grep -c /event %s > __nfiles__", wn.Data()));
476 ifstream f2("__nfiles__");
478 nFiles.ReadLine(f2,kTRUE);
480 gSystem->Exec("rm -f __nfiles__");
481 printf(" - number of files to merge = %d\n", nFiles.Atoi());
482 if (nFiles.Atoi() == 0) {
483 printf(" ! collection of files to merge is empty\n");
484 gSystem->Exec(Form("rm -f %s", wn.Data()));
486 } else if (stage > 0 && nFiles.Atoi() <= splitLevel && !reply.BeginsWith("y")) {
487 if (!reply.BeginsWith("n")) {
488 printf(" ! number of files to merge <= split level (%d). Continue? [Y/n] ", splitLevel);
490 reply.Gets(stdin,kTRUE);
493 if (reply.BeginsWith("n")) {
494 gSystem->Exec(Form("rm -f %s", wn.Data()));
501 TString dirwn = Form("%s/%s", runDir.Data(), wn.Data());
502 if (RemoteFileExists(dirwn.Data())) gGrid->Rm(dirwn.Data());
503 gSystem->Exec(Form("alien_cp file:%s alien://%s", wn.Data(), dirwn.Data()));
504 gSystem->Exec(Form("rm -f %s", wn.Data()));
508 if (stage > 0) query = Form("submit %s %d %d", jdl.Data(), run, stage);
509 else query = Form("submit %s %d", jdl.Data(), run);
510 printf(" - %s ...", query.Data());
519 Bool_t done = kFALSE;
520 TGridResult *res = gGrid->Command(query);
523 TString cjobId1 = res->GetKey(0,"jobId");
524 if (!cjobId1.IsDec())
532 AliInfo(Form(" DONE\n --> the job Id is: %s \n", cjobId1.Data()));
544 gSystem->Exec(Form("echo %d >> __failed__", run));
552 AliInfo("\n--------------------\n");
553 AliInfo("list of failed runs:\n");
554 gSystem->Exec("cat __failed__");
555 gSystem->Exec("rm -f __failed__");
562 //______________________________________________________________________________
563 void AliMuonAccEffSubmitter::Print(Option_t* opt) const
567 AliMuonGridSubmitter::Print(opt);
571 std::cout << Form("For each run, will generate %5.2f times the number of real events for trigger %s",
572 fRatio,ReferenceTrigger().Data()) << std::endl;
576 std::cout << Form("For each run, will generate %10d events",fFixedNofEvents) << std::endl;
579 std::cout << "MaxEventsPerChunk = " << fMaxEventsPerChunk << std::endl;
581 std::cout << "Will" << (fUseOCDBSnapshots ? "" : " NOT") << " use OCDB snaphosts" << std::endl;
584 //______________________________________________________________________________
585 Bool_t AliMuonAccEffSubmitter::Run(const char* mode)
587 /// mode can be one of (case insensitive)
589 /// LOCAL : copy the template files from the template directory to the local one
590 /// UPLOAD : copy the local files to the grid (requires LOCAL)
591 /// OCDB : make ocdb snapshots (requires LOCAL)
592 /// SUBMIT : submit the jobs (requires LOCAL + UPLOAD)
593 /// FULL : all of the above (requires all of the above)
595 /// TEST : as SUBMIT, but in dry mode (does not actually submit the jobs)
597 /// LOCALTEST : completely local test (including execution)
599 if (!IsValid()) return kFALSE;
604 if ( smode == "FULL")
606 return ( Run("LOCAL") && Run("OCDB") && Run("UPLOAD") && Run("SUBMIT") );
609 if ( smode == "LOCAL")
611 return CopyTemplateFilesToLocal();
614 if ( smode == "UPLOAD" )
616 return (CopyLocalFilesToRemote());
619 if ( smode == "OCDB" )
621 Bool_t ok = Run("LOCAL");
624 ok = MakeOCDBSnapshots();
629 if ( smode == "TEST" )
631 Bool_t ok = Run("LOCAL") && Run("OCDB") && Run("UPLOAD");
634 ok = (Submit(kTRUE)>0);
639 if ( smode == "FULL" )
641 Bool_t ok = Run("LOCAL") && Run("OCDB") && Run("UPLOAD");
644 ok = (Submit(kFALSE)>0);
649 if( smode == "SUBMIT" )
651 return (Submit(kFALSE)>0);
654 if ( smode == "LOCALTEST" )
656 Bool_t ok = Run("LOCAL");
667 //______________________________________________________________________________
668 Bool_t AliMuonAccEffSubmitter::SetGenerator(const char* generator)
670 // set the variable to select the generator macro in Config.C
672 gSystem->Load("libEVGEN");
676 TString generatorFile(Form("%s/%s.C",TemplateDir().Data(),generator));
678 Int_t nofMissingVariables(0);
680 // first check we indeed have such a macro
681 if (!gSystem->AccessPathName(generatorFile.Data()))
683 TObjArray* variables = GetVariables(generatorFile.Data());
685 TIter next(variables);
688 while ( ( var = static_cast<TObjString*>(next())) )
690 if ( !Vars()->GetValue(var->String()) )
692 ++nofMissingVariables;
693 AliError(Form("file %s expect the variable %s to be defined, but we've not defined it !",generatorFile.Data(),var->String().Data()));
699 if ( !nofMissingVariables )
701 if (CheckCompilation(generatorFile.Data()))
704 SetVar("VAR_GENERATOR",Form("%s",generator));
705 AddToTemplateFileList(Form("%s.C",generator));
716 AliError(Form("Can not work with the macro %s",generatorFile.Data()));
721 //______________________________________________________________________________
722 void AliMuonAccEffSubmitter::SetOCDBPath(const char* ocdbPath)
724 /// Sets the OCDB path to be used
726 SetMapKeyValue("OCDBPath",ocdbPath);
730 //______________________________________________________________________________
731 void AliMuonAccEffSubmitter::SetOCDBSnapshotDir(const char* dir)
733 // change the directory used for snapshot
735 if (gSystem->AccessPathName(Form("%s/OCDB",dir)))
737 AliError(Form("Snapshot top directory (%s) should contain an OCDB subdir with runnumbers in there",dir));
741 SetMapKeyValue("OCDBSnapshot",dir);
745 //______________________________________________________________________________
746 void AliMuonAccEffSubmitter::MakeNofEventsPropToTriggerCount(const char* trigger, Float_t ratio)
748 SetMapKeyValue("ReferenceTrigger",trigger);
752 //______________________________________________________________________________
753 void AliMuonAccEffSubmitter::MakeNofEventsFixed(Int_t nevents)
755 fFixedNofEvents = nevents;
757 SetMapKeyValue("ReferenceTrigger","");
760 //______________________________________________________________________________
761 Int_t AliMuonAccEffSubmitter::LocalTest()
763 /// Generate a local macro (simrun.sh) to execute locally a full scale test
764 /// Can only be used with a fixed number of events (and runnumber is fixed to zero)
768 AliError("Can only work in local test with a fixed number of events");
772 if ( fFixedNofEvents <= 0 )
774 AliError("Please fix the number of input events using MakeNofEventsFixed()");
778 const std::vector<int>& runs = RunList();
780 std::cout << "Generating script to execute : ./simrun.sh" << std::endl;
782 std::ofstream out("simrun.sh");
784 out << "#!/bin/bash" << std::endl;
785 // root.exe -b -q simrun.C --run <x> --chunk <y> --event <n>
786 out << "root.exe -b -q simrun.C --run "<< runs[0] <<" --event " << fFixedNofEvents << std::endl;
788 gSystem->Exec("chmod +x simrun.sh");
790 std::cout << "Executing the script : ./simrun.sh" << std::endl;
792 gSystem->Exec("./simrun.sh");
797 //______________________________________________________________________________
798 Int_t AliMuonAccEffSubmitter::Submit(Bool_t dryRun)
800 /// Submit multiple production jobs with the format "submit jdl 000run#.xml 000run#".
802 /// Return the number of submitted (master) jobs
805 /// - outputDir = "/alice/cern.ch/user/p/ppillot/Sim/LHC10h/JPsiPbPb276/AlignRawVtxRaw/ESDs"
806 /// - runList must contains the list of run number
807 /// - trigger is the (fully qualified) trigger name used to compute the base number of events
808 /// - mult is the factor to apply to the number of trigger to get the number of events to be generated
809 /// (# generated events = # triggers x mult
811 if (!IsValid()) return 0;
815 gGrid->Cd(RemoteDir());
817 if (!RemoteFileExists(RunJDLName()))
819 AliError(Form("file %s does not exist in %s", RunJDLName().Data(), RemoteDir().Data()));
825 AliError("No run list set. Use SetRunList");
828 const std::vector<int>& runs = RunList();
832 AliError("No run to work with");
836 // cout << "total number of selected MB events = " << totEvt << endl;
837 // cout << "required number of generated events = " << nGenEvents << endl;
838 // cout << "number of generated events per MB event = " << ratio << endl;
841 std::cout << "run\tchunks\tevents" << std::endl;
842 std::cout << "----------------------" << std::endl;
847 AliAnalysisTriggerScalers* ts(0x0);
849 for (std::vector<int>::size_type i=0; i < runs.size(); ++i)
851 Int_t runNumber = runs[i];
853 Int_t nEvtRun(fFixedNofEvents);
859 AliInfo(Form("Creating AliAnalysisTriggerScalers from OCDB=%s",OCDBPath().Data()));
860 ts = new AliAnalysisTriggerScalers(runs,OCDBPath().Data());
863 AliAnalysisTriggerScalerItem* trigger = ts->GetTriggerScaler(runNumber, "L2A", ReferenceTrigger().Data());
867 AliError(Form("Could not get trigger %s for run %09d",ReferenceTrigger().Data(),runNumber));
870 nEvtRun = TMath::Nint(fRatio * trigger->Value());
875 while (nEvtRun/nChunk+0.5 > MaxEventsPerChunk())
880 Int_t nEvtChunk = TMath::Nint(nEvtRun/nChunk + 0.5);
884 nEvts += nChunk*nEvtChunk;
886 std::cout << runNumber << "\t" << nChunk << "\t" << nEvtChunk << std::endl;
888 TString query(Form("submit %s %d %d %d", RunJDLName().Data(), runNumber, nChunk, nEvtChunk));
890 std::cout << query.Data() << " ..." << std::flush;
892 TGridResult* res = 0x0;
896 res = gGrid->Command(query);
901 TString cjobId1 = res->GetKey(0,"jobId");
903 if (!cjobId1.Length())
905 std::cout << " FAILED" << std::endl << std::endl;
911 std::cout << "DONE" << std::endl;
912 std::cout << Form(" --> the job Id is: %s",cjobId1.Data()) << std::endl << std::endl;
917 std::cout << " FAILED" << std::endl << std::endl;
923 std::cout << std::endl
924 << "total number of jobs = " << nJobs << std::endl
925 << "total number of generated events = " << nEvts << std::endl
933 //______________________________________________________________________________
934 void AliMuonAccEffSubmitter::UpdateLocalFileList(Bool_t clearSnapshots)
936 /// Update the list of local files
938 AliMuonGridSubmitter::UpdateLocalFileList();
940 if (!NofRuns()) return;
942 if ( clearSnapshots )
944 TIter next(LocalFileList());
947 while ( ( file = static_cast<TObjString*>(next())) )
949 if ( file->String().Contains("OCDB_") )
951 LocalFileList()->Remove(file);
954 LocalFileList()->Compress();
957 const char* type[] = { "sim","rec" };
959 const std::vector<int>& runs = RunList();
961 for ( std::vector<int>::size_type i = 0; i < runs.size(); ++i )
963 Int_t runNumber = runs[i];
965 for ( Int_t t = 0; t < 2; ++t )
967 TString snapshot(Form("%s/OCDB/%d/OCDB_%s.root",SnapshotDir().Data(),runNumber,type[t]));
969 if ( !gSystem->AccessPathName(snapshot.Data()) )
971 AddToLocalFileList(snapshot);
977 //______________________________________________________________________________
978 void AliMuonAccEffSubmitter::UseOCDBSnapshots(Bool_t flag)
980 /// Whether or not to use OCDB snapshots
981 /// Using OCDB snapshots will speed-up both the sim and reco initialization
982 /// phases on each worker node, but takes time to produce...
983 /// So using them is not always a win-win...
985 fUseOCDBSnapshots = flag;
988 SetVar("VAR_OCDB_SNAPSHOT","kTRUE");
992 SetVar("VAR_OCDB_SNAPSHOT","kFALSE");
995 UpdateLocalFileList();
998 //______________________________________________________________________________
999 void AliMuonAccEffSubmitter::UseAODMerging(Bool_t flag)
1001 /// whether or not we should generate JDL for merging AODs
1003 fUseAODMerging = flag;
1005 AddToTemplateFileList(MergeJDLName(kFALSE).Data());
1006 AddToTemplateFileList(MergeJDLName(kTRUE).Data());
1007 AddToTemplateFileList("AOD_merge.sh");
1008 AddToTemplateFileList("validation_merge.sh");
1011 //______________________________________________________________________________
1012 void AliMuonAccEffSubmitter::UseExternalConfig(const char* externalConfigFullFilePath)
1014 // use an external config (or the default Config.C if externalConfigFullFilePath="")
1016 fExternalConfig = externalConfigFullFilePath;
1017 if ( fExternalConfig.Length() > 0 )
1019 AddToTemplateFileList(fExternalConfig);
1023 AddToTemplateFileList("Config.C");