349 void plotNtuple(TProof *p,
const char *ds,
const char *ntptitle);
350 void SavePerfTree(TProof *proof,
const char *fn);
353 const char *pythia8dir = 0;
354 const char *pythia8data = 0;
356 void runProof(
const char *what =
"simple",
357 const char *masterurl =
"proof://localhost:40000",
358 Int_t nwrks = -1, TList *ins = 0)
361 gEnv->SetValue(
"Proof.StatsHist",1);
363 TString u(masterurl);
365 Bool_t isProofLocal = kFALSE;
366 if (!u.IsNull() && u !=
"lite://") {
368 TString uopts(uu.GetOptions());
369 if ((!strcmp(uu.GetHost(),
"localhost") && !uopts.Contains(
"external")) ||
370 !strcmp(uu.GetHostFQDN(), TUrl(gSystem->HostName()).GetHostFQDN())) {
371 isProofLocal = kTRUE;
374 if (!u.BeginsWith(uu.GetProtocol())) uu.SetProtocol(
"proof");
375 uopts.ReplaceAll(
"external",
"");
376 uu.SetOptions(uopts.Data());
379 const char *url = u.Data();
383 TString tmpdir(
"/tmp");
384 if (gSystem->AccessPathName(tmpdir, kWritePermission)) tmpdir = gSystem->TempDirectory();
386 UserGroup_t *ug = gSystem->GetUserInfo(gSystem->GetUid());
388 Printf(
"runProof: could not get user info");
391 us.Form(
"/%s", ug->fUser.Data());
392 if (!tmpdir.EndsWith(us.Data())) tmpdir += us;
393 gSystem->mkdir(tmpdir.Data(), kTRUE);
394 if (gSystem->AccessPathName(tmpdir, kWritePermission)) {
395 Printf(
"runProof: unable to get a writable tutorial directory (tried: %s)"
396 " - cannot continue", tmpdir.Data());
399 TString tutdir = Form(
"%s/.proof-tutorial", tmpdir.Data());
400 if (gSystem->AccessPathName(tutdir)) {
401 Printf(
"runProof: creating the temporary directory"
402 " for the tutorial (%s) ... ", tutdir.Data());
403 if (gSystem->mkdir(tutdir, kTRUE) != 0) {
404 Printf(
"runProof: could not assert / create the temporary directory"
405 " for the tutorial (%s)", tutdir.Data());
412 if (what && !strncmp(what,
"pythia8", 7)) {
414 pythia8dir = gSystem->Getenv(
"PYTHIA8");
415 if (!pythia8dir || strlen(pythia8dir) <= 0) {
416 Printf(
"runProof: pythia8: environment variable PYTHIA8 undefined:"
417 " it must contain the path to pythia81xx root directory (local and remote) !");
420 pythia8data = gSystem->Getenv(
"PYTHIA8DATA");
421 if (!pythia8data || strlen(pythia8data) <= 0) {
422 gSystem->Setenv(
"PYTHIA8DATA", Form(
"%s/xmldoc", pythia8dir));
423 pythia8data = gSystem->Getenv(
"PYTHIA8DATA");
424 if (!pythia8data || strlen(pythia8data) <= 0) {
425 Printf(
"runProof: pythia8: environment variable PYTHIA8DATA undefined:"
426 " it one must contain the path to pythia81xx/xmldoc"
427 " subdirectory (local and remote) !");
431 TString env = Form(
"echo export PYTHIA8=%s; export PYTHIA8DATA=%s",
432 pythia8dir, pythia8data);
433 TProof::AddEnvVar(
"PROOF_INITCMD", env.Data());
436 Printf(
"tutorial dir:\t%s", tutdir.Data());
439 TProof *proof = getProof(url, nwrks, tutdir.Data(),
"ask");
441 Printf(
"runProof: could not start/attach a PROOF session");
446 if (proof->IsLite()) isProofLocal = kTRUE;
449 if (isProofLocal && what && !strcmp(what,
"ntuple", 6)) {
451 Printf(
"runProof: the 'ntuple' example needs to run xrootd to receive the output file, \n"
452 " but xrootd is not supported on Windows - cannot continue");
457 TString proofsessions(Form(
"%s/sessions",tutdir.Data()));
459 FILE *fs = fopen(proofsessions.Data(),
"a");
461 Printf(
"runProof: could not create files for sessions tags");
463 fprintf(fs,
"session-%s\n", proof->GetSessionTag());
467 Printf(
"runProof: could not start/attach a PROOF session");
474 proof->SetParallel(nwrks);
477 char *rootbin = gSystem->Which(gSystem->Getenv(
"PATH"),
"root.exe", kExecutePermission);
479 Printf(
"runProof: root.exe not found: please check the environment!");
482 TString rootsys(gSystem->DirName(rootbin));
483 rootsys = gSystem->DirName(rootsys);
484 TString tutorials(Form(
"%s/tutorials", rootsys.Data()));
489 args.ReplaceAll(
"(",
" ");
490 args.ReplaceAll(
")",
" ");
491 args.ReplaceAll(
",",
" ");
494 if (!args.Tokenize(act, from,
" ")) {
496 Printf(
"runProof: action not found: check your arguments (%s)", what);
501 if (act.EndsWith(
"+")) {
503 while (act.EndsWith(
"+")) { act.Remove(TString::kTrailing,
'+'); }
505 Printf(
"runProof: %s: ACLiC mode: '%s'", act.Data(), aMode.Data());
508 TString aNevt, aFirst, aNwrk, opt, sel, punzip(
"off"), aCache, aOutFile,
509 aH1Src(
"http://root.cern.ch/files/h1"),
510 aDebug, aDebugEnum, aRateEst, aPerfTree(
"perftree.root"),
511 aFeedback(
"fb=stats");
514 Bool_t useList = kFALSE, makePerfTree = kFALSE;
515 while (args.Tokenize(tok, from,
" ")) {
517 if (tok.BeginsWith(
"debug=")) {
519 aDebug.ReplaceAll(
"debug=",
"");
521 if ((icol = aDebug.Index(
":")) != kNPOS) {
522 aDebugEnum = aDebug(0, icol);
523 aDebug.Remove(0, icol+1);
525 if (!aDebug.IsDigit()) {
526 Printf(
"runProof: %s: error parsing the 'debug=' option (%s) - ignoring", act.Data(), tok.Data());
532 if (tok.BeginsWith(
"nevt=")) {
534 aNevt.ReplaceAll(
"nevt=",
"");
535 if (!aNevt.IsDigit()) {
536 Printf(
"runProof: %s: error parsing the 'nevt=' option (%s) - ignoring", act.Data(), tok.Data());
541 if (tok.BeginsWith(
"first=")) {
543 aFirst.ReplaceAll(
"first=",
"");
544 if (!aFirst.IsDigit()) {
545 Printf(
"runProof: %s: error parsing the 'first=' option (%s) - ignoring", act.Data(), tok.Data());
550 if (tok.BeginsWith(
"asyn"))
553 if (tok.BeginsWith(
"nwrk=")) {
555 aNwrk.ReplaceAll(
"nwrk=",
"");
556 if (!aNwrk.IsDigit()) {
557 Printf(
"runProof: %s: error parsing the 'nwrk=' option (%s) - ignoring", act.Data(), tok.Data());
562 if (tok.BeginsWith(
"punzip"))
565 if (tok.BeginsWith(
"cache=")) {
567 aCache.ReplaceAll(
"cache=",
"");
568 if (aCache.EndsWith(
"k")) { aCache.Remove(TString::kTrailing,
'k'); suf = 1024; }
569 if (aCache.EndsWith(
"K")) { aCache.Remove(TString::kTrailing,
'K'); suf = 1024; }
570 if (aCache.EndsWith(
"M")) { aCache.Remove(TString::kTrailing,
'M'); suf = 1024*1024; }
571 if (!aCache.IsDigit()) {
572 Printf(
"runProof: %s: error parsing the 'cache=' option (%s) - ignoring", act.Data(), tok.Data());
577 if (tok.BeginsWith(
"submergers")) {
578 tok.ReplaceAll(
"submergers",
"");
580 if (tok.BeginsWith(
"=")) {
581 tok.ReplaceAll(
"=",
"");
582 if (tok.IsDigit()) aSubMg = tok.Atoi();
586 if (tok.BeginsWith(
"useList")) {
589 if (tok.BeginsWith(
"fillList")) {
593 if (tok.BeginsWith(
"h1src=")) {
594 tok.ReplaceAll(
"h1src=",
"");
595 if (!(tok.IsNull())) aH1Src = tok;
596 Printf(
"runProof: %s: reading data files from '%s'", act.Data(), aH1Src.Data());
599 if (tok.BeginsWith(
"rateest=")) {
600 tok.ReplaceAll(
"rateest=",
"");
601 if (!(tok.IsNull())) aRateEst = tok;
602 Printf(
"runProof: %s: progress-bar rate estimation option: '%s'", act.Data(), aRateEst.Data());
605 if (tok.BeginsWith(
"perftree")) {
606 makePerfTree = kTRUE;
607 if (tok.BeginsWith(
"perftree=")) {
608 tok.ReplaceAll(
"perftree=",
"");
609 if (!(tok.IsNull())) aPerfTree = tok;
611 Printf(
"runProof: %s: saving performance tree to '%s'", act.Data(), aPerfTree.Data());
614 if (tok.BeginsWith(
"outfile")) {
615 if (tok.BeginsWith(
"outfile=")) {
616 tok.ReplaceAll(
"outfile=",
"");
617 if (!(tok.IsNull())) aOutFile = tok;
619 Printf(
"runProof: %s: output file: '%s'", act.Data(), aOutFile.Data());
622 if (tok.BeginsWith(
"feedback=")) {
623 tok.ReplaceAll(
"feedback=",
"");
624 if (tok ==
"off" || tok ==
"OFF" || tok ==
"0") {
626 }
else if (!(tok.IsNull())) {
627 if (tok.BeginsWith(
"+")) {
631 aFeedback.Form(
"fb=%s", tok.Data());
634 Printf(
"runProof: %s: feedback: '%s'", act.Data(), aFeedback.Data());
637 Long64_t nevt = (aNevt.IsNull()) ? -1 : aNevt.Atoi();
638 Long64_t first = (aFirst.IsNull()) ? 0 : aFirst.Atoi();
639 Long64_t nwrk = (aNwrk.IsNull()) ? -1 : aNwrk.Atoi();
644 if (proof->GetParallel() < nwrk) {
645 Printf(
"runProof: %s: request for a number of workers larger then available - ignored", act.Data());
647 proof->SetParallel(nwrk);
652 if (!aDebug.IsNull()) {
653 Int_t dbg = aDebug.Atoi();
654 Int_t scope = TProofDebug::kAll;
655 if (!aDebugEnum.IsNull()) scope = getDebugEnum(aDebugEnum.Data());
656 proof->SetLogLevel(dbg, scope);
657 Printf(
"runProof: %s: verbose mode for '%s'; level: %d", act.Data(), aDebugEnum.Data(), dbg);
662 if (aRateEst ==
"average")
663 proof->SetParameter(
"PROOF_RateEstimation", aRateEst);
666 if (punzip ==
"on") {
667 proof->SetParameter(
"PROOF_UseParallelUnzip", (Int_t)1);
668 Printf(
"runProof: %s: parallel unzip enabled", act.Data());
670 proof->SetParameter(
"PROOF_UseParallelUnzip", (Int_t)0);
674 if (!aCache.IsNull()) {
675 Long64_t cachesz = aCache.Atoi() * suf;
677 proof->SetParameter(
"PROOF_UseTreeCache", (Int_t)0);
678 Printf(
"runProof: %s: disabling tree cache", act.Data());
680 proof->SetParameter(
"PROOF_UseTreeCache", (Int_t)1);
681 proof->SetParameter(
"PROOF_CacheSize", cachesz);
682 Printf(
"runProof: %s: setting cache size to %lld", act.Data(), cachesz);
686 proof->DeleteParameters(
"PROOF_UseTreeCache");
687 proof->DeleteParameters(
"PROOF_CacheSize");
692 proof->SetParameter(
"PROOF_UseMergers", aSubMg);
694 Printf(
"runProof: %s: enabling merging via %d sub-mergers", act.Data(), aSubMg);
696 Printf(
"runProof: %s: enabling merging via sub-mergers (optimal number)", act.Data());
699 proof->DeleteParameters(
"PROOF_UseMergers");
704 proof->SetParameter(
"PROOF_StatsHist",
"");
705 proof->SetParameter(
"PROOF_StatsTrace",
"");
706 proof->SetParameter(
"PROOF_SlaveStatsTrace",
"");
710 if (ins && ins->GetSize() > 0) {
713 while ((oin = nxo())) { proof->AddInput(oin); }
717 proof->GetInputList()->Print();
720 if (act ==
"simple") {
726 Printf(
"runProof: %s: warning concept of 'first' meaningless for this tutorial"
727 " - ignored", act.Data());
730 nevt = (nevt < 0) ? 100000 : nevt;
732 TString aNhist, aNhist3;
733 while (args.Tokenize(tok, from,
" ")) {
735 if (tok.BeginsWith(
"nhist=")) {
737 aNhist.ReplaceAll(
"nhist=",
"");
738 if (!aNhist.IsDigit()) {
739 Printf(
"runProof: error parsing the 'nhist=' option (%s) - ignoring", tok.Data());
742 }
else if (tok.BeginsWith(
"nhist3=")) {
744 aNhist3.ReplaceAll(
"nhist3=",
"");
745 if (!aNhist3.IsDigit()) {
746 Printf(
"runProof: error parsing the 'nhist3=' option (%s) - ignoring", tok.Data());
751 Int_t nhist = (aNhist.IsNull()) ? 100 : aNhist.Atoi();
752 Int_t nhist3 = (aNhist3.IsNull()) ? -1 : aNhist3.Atoi();
753 Printf(
"\nrunProof: running \"simple\" with nhist= %d, nhist3=%d and nevt= %lld\n", nhist, nhist3, nevt);
756 proof->SetParameter(
"ProofSimple_NHist", (Long_t)nhist);
758 if (nhist3 > 0) proof->SetParameter(
"ProofSimple_NHist3", (Long_t)nhist3);
760 sel.Form(
"%s/proof/ProofSimple.C%s", tutorials.Data(), aMode.Data());
763 TString xopt = aFeedback;
if (!opt.IsNull()) xopt += TString::Format(
" %s", opt.Data());
764 proof->Process(sel.Data(), nevt, xopt);
766 }
else if (act ==
"h1") {
771 TChain *chain =
new TChain(
"h42");
772 chain->Add(TString::Format(
"%s/dstarmb.root", aH1Src.Data()));
773 chain->Add(TString::Format(
"%s/dstarp1a.root", aH1Src.Data()));
774 chain->Add(TString::Format(
"%s/dstarp1b.root", aH1Src.Data()));
775 chain->Add(TString::Format(
"%s/dstarp2.root", aH1Src.Data()));
781 TString eln(
"elist"), elfn(
"elist.root");
782 if (gSystem->AccessPathName(elfn)) {
783 Printf(
"\nrunProof: asked to use an entry list but '%s' not found or not readable", elfn.Data());
784 Printf(
"\nrunProof: did you forget to run with 'fillList=%s'?\n", elfn.Data());
787 if (!(f.IsZombie())) {
788 TEntryList *elist = (TEntryList *)f.Get(eln);
790 elist->SetDirectory(0);
791 chain->SetEntryList(elist);
793 Printf(
"\nrunProof: could not find entry-list '%s' in file '%s': ignoring",
794 eln.Data(), elfn.Data());
797 Printf(
"\nrunProof: requested entry-list file '%s' not existing (or not readable):"
798 " ignoring", elfn.Data());
803 sel.Form(
"%s/tree/h1analysis.C%s", tutorials.Data(), aMode.Data());
805 Printf(
"\nrunProof: running \"h1\"\n");
806 TString xopt = aFeedback;
if (!opt.IsNull()) xopt += TString::Format(
" %s", opt.Data());
807 chain->Process(sel.Data(),xopt,nevt,first);
809 gProof->ClearInputData(
"elist");
810 gProof->ClearInputData(
"elist.root");
811 TIter nxi(gProof->GetInputList());
813 while ((o = nxi())) {
814 if (!strncmp(o->GetName(),
"elist", 5)) {
815 gProof->GetInputList()->Remove(o);
820 }
else if (act ==
"pythia8") {
823 Printf(
"runProof: %s: warning concept of 'first' meaningless for this tutorial"
824 " - ignored", act.Data());
826 TString path(Form(
"%s/Index.xml", pythia8data));
827 gSystem->ExpandPathName(path);
828 if (gSystem->AccessPathName(path)) {
829 Printf(
"runProof: pythia8: PYTHIA8DATA directory (%s) must"
830 " contain the Index.xml file !", pythia8data);
833 TString pythia8par = TString::Format(
"%s/proof/pythia8.par", tutorials.Data());
834 if (gSystem->AccessPathName(pythia8par.Data())) {
835 Printf(
"runProof: pythia8: par file not found (tried %s)", pythia8par.Data());
838 proof->UploadPackage(pythia8par);
839 proof->EnablePackage(
"pythia8");
841 proof->ShowEnabledPackages();
842 Printf(
"runProof: pythia8: check settings:");
843 proof->Exec(
".!echo hostname = `hostname`; echo \"ls pythia8:\"; ls pythia8");
845 if (gSystem->Load(
"libEG.so") < 0) {
846 Printf(
"runProof: pythia8: libEG not found \n");
849 if (gSystem->Load(
"libEGPythia8.so") < 0) {
850 Printf(
"runProof: pythia8: libEGPythia8 not found \n");
854 nevt = (nevt < 0) ? 100 : nevt;
855 Printf(
"\nrunProof: running \"Pythia01\" nevt= %lld\n", nevt);
857 sel.Form(
"%s/proof/ProofPythia.C%s", tutorials.Data(), aMode.Data());
859 TString xopt = aFeedback;
if (!opt.IsNull()) xopt += TString::Format(
" %s", opt.Data());
860 proof->Process(sel.Data(), nevt, xopt);
862 }
else if (act ==
"event") {
866 Printf(
"runProof: %s: warning concept of 'first' meaningless for this tutorial"
867 " - ignored", act.Data());
869 TString eventpar = TString::Format(
"%s/proof/event.par", tutorials.Data());
870 if (gSystem->AccessPathName(eventpar.Data())) {
871 Printf(
"runProof: event: par file not found (tried %s)", eventpar.Data());
875 proof->UploadPackage(eventpar);
876 proof->EnablePackage(
"event");
877 Printf(
"Enabled packages...\n");
878 proof->ShowEnabledPackages();
881 nevt = (nevt < 0) ? 100 : nevt;
882 Printf(
"\nrunProof: running \"event\" nevt= %lld\n", nevt);
884 sel.Form(
"%s/proof/ProofEvent.C%s", tutorials.Data(), aMode.Data());
886 TString xopt = aFeedback;
if (!opt.IsNull()) xopt += TString::Format(
" %s", opt.Data());
887 proof->Process(sel.Data(), nevt, xopt);
889 }
else if (act ==
"eventproc") {
891 TString eventpar = TString::Format(
"%s/proof/event.par", tutorials.Data());
892 gSystem->ExpandPathName(eventpar);
893 if (gSystem->AccessPathName(eventpar.Data())) {
894 Printf(
"runProof: eventproc: par file not found (tried %s)", eventpar.Data());
898 proof->UploadPackage(eventpar);
899 proof->EnablePackage(
"event");
900 Printf(
"Enabled packages...\n");
901 proof->ShowEnabledPackages();
904 TString pfelem = TString::Format(
"%s/proof/ProcFileElements.C", tutorials.Data());
905 gSystem->ExpandPathName(pfelem);
906 if (gSystem->AccessPathName(pfelem.Data())) {
907 Printf(
"runProof: eventproc: ProcFileElements.C not found (tried %s)", pfelem.Data());
912 pfelem += TString::Format(
",%s/proof/EmptyInclude.h", tutorials.Data());
917 Bool_t uneven = kFALSE;
918 TString aFiles, aDataSrc(
"http://root.cern.ch/files/data"), aPartitions;
919 proof->SetParameter(
"ProofEventProc_Read",
"optimized");
920 while (args.Tokenize(tok, from,
" ")) {
922 if (tok.BeginsWith(
"files=")) {
924 aFiles.ReplaceAll(
"files=",
"");
925 if (!aFiles.IsDigit()) {
926 Printf(
"runProof: error parsing the 'files=' option (%s) - ignoring", tok.Data());
929 }
else if (tok.BeginsWith(
"datasrc=")) {
930 tok.ReplaceAll(
"datasrc=",
"");
932 Printf(
"runProof: error parsing the 'datasrc=' option (%s) - ignoring", tok.Data());
935 Printf(
"runProof: reading files from: %s", aDataSrc.Data());
937 }
else if (tok ==
"readall") {
938 proof->SetParameter(
"ProofEventProc_Read",
"readall");
939 Printf(
"runProof: eventproc: reading the full event");
940 }
else if (tok ==
"uneven") {
942 }
else if (tok.BeginsWith(
"partitions=")) {
943 tok.ReplaceAll(
"partitions=",
"");
945 Printf(
"runProof: error parsing the 'partitions=' option (%s) - ignoring", tok.Data());
948 Printf(
"runProof: partitions: %s included in packetizer operations", aPartitions.Data());
952 Int_t nFiles = (aFiles.IsNull()) ? 10 : aFiles.Atoi();
953 Printf(
"runProof: found aFiles: '%s', nFiles: %d", aFiles.Data(), nFiles);
955 Printf(
"runProof: max number of files is 50 - resizing request");
960 TChain *c =
new TChain(
"EventTree");
963 if (gSystem->GetPathInfo(aDataSrc, fst) == 0 && R_ISREG(fst.fMode) &&
964 !gSystem->AccessPathName(aDataSrc, kReadPermission)) {
966 TFileCollection *fc =
new TFileCollection(
"",
"", aDataSrc, nFiles);
967 c->AddFileInfoList(fc->GetList());
974 TObjArray *dsrcs = aDataSrc.Tokenize(
"|");
975 Int_t nds = dsrcs->GetEntries();
980 for (i = 1; i <= nFiles; i++) {
982 TObjString *os = (TObjString *) (*dsrcs)[k];
984 fn.Form(
"%s/event_%d.root", os->GetName(), i);
987 c->AddFile(fn.Data(), 50000);
989 c->AddFile(fn.Data(), 5000);
991 c->AddFile(fn.Data());
1003 proof->SetParameter(
"PROOF_ValidateByFile", 1);
1006 if (!aPartitions.IsNull()) {
1007 aPartitions.ReplaceAll(
"|",
",");
1008 proof->SetParameter(
"PROOF_PacketizerPartitions", aPartitions);
1012 sel.Form(
"%s/proof/ProofEventProc.C%s", tutorials.Data(), aMode.Data());
1014 Printf(
"\nrunProof: running \"eventproc\"\n");
1015 TString xopt = aFeedback;
if (!opt.IsNull()) xopt += TString::Format(
" %s", opt.Data());
1016 c->Process(sel.Data(), xopt, nevt, first);
1018 }
else if (act ==
"ntuple") {
1025 Printf(
"runProof: %s: warning concept of 'first' meaningless for this tutorial"
1026 " - ignored", act.Data());
1029 nevt = (nevt < 0) ? 1000 : nevt;
1030 Printf(
"\nrunProof: running \"ntuple\" with nevt= %lld\n", nevt);
1033 Bool_t usentprndm = kFALSE;
1034 while (args.Tokenize(tok, from,
" ")) {
1035 if (tok ==
"inputrndm") {
1040 if (usentprndm) Printf(
"runProof: taking randoms from input ntuple\n");
1043 TString fout(aOutFile);
1044 if (fout.IsNull()) {
1045 fout.Form(
"%s/ProofNtuple.root", gSystem->WorkingDirectory());
1047 gSystem->Unlink(fout);
1049 if (!isProofLocal) {
1051 Bool_t xrdok = kFALSE;
1053 while (port < 9010) {
1054 if (checkXrootdAt(port) != 1) {
1055 if (startXrootdAt(port, gSystem->WorkingDirectory(), kTRUE) == 0) {
1063 Printf(
"runProof: could not start basic xrootd on ports 9000-9009 - cannot continue");
1066 fout.Insert(0, TString::Format(
"root://%s:%d/", TUrl(gSystem->HostName()).GetHostFQDN(), port));
1068 proof->AddInput(
new TNamed(
"PROOF_OUTPUTFILE_LOCATION",
"LOCAL"));
1071 proof->AddInput(
new TNamed(
"PROOF_OUTPUTFILE", fout.Data()));
1076 TString fnr = TString::Format(
"%s/proof/ntprndm.root", tutorials.Data());
1078 proof->SetInputDataFile(fnr);
1080 proof->SetParameter(
"PROOF_USE_NTP_RNDM",
"yes");
1082 Printf(
"runProof: taking randoms from '%s'", fnr.Data());
1086 sel.Form(
"%s/proof/ProofNtuple.C%s", tutorials.Data(), aMode.Data());
1089 TString xopt = aFeedback;
if (!opt.IsNull()) xopt += TString::Format(
" %s", opt.Data());
1090 Printf(
"runProof: selector file '%s', options: '%s'", sel.Data(), xopt.Data());
1091 proof->Process(sel.Data(), nevt, xopt);
1095 proof->DeleteParameters(
"PROOF_USE_NTP_RNDM");
1096 proof->SetInputDataFile(0);
1099 }
else if (act ==
"dataset") {
1108 Printf(
"runProof: %s: warning concept of 'first' meaningless for this tutorial"
1109 " - ignored", act.Data());
1112 nevt = (nevt < 0) ? 1000000 : nevt;
1113 Printf(
"\nrunProof: running \"dataset\" with nevt= %lld\n", nevt);
1117 proof->SetParameter(
"SimpleNtuple.root",
"testNtuple");
1120 proof->SetParameter(
"PROOF_NTUPLE_DONT_PLOT",
"");
1123 sel.Form(
"%s/proof/ProofNtuple.C%s", tutorials.Data(), aMode.Data());
1126 TString xopt = aFeedback;
if (!opt.IsNull()) xopt += TString::Format(
" %s", opt.Data());
1127 proof->Process(sel.Data(), nevt, xopt);
1130 if (proof->GetOutputList()->FindObject(
"testNtuple")) {
1133 plotNtuple(proof,
"testNtuple",
"proof ntuple from dataset");
1136 Printf(
"runProof: dataset 'testNtuple' not found in the output list");
1139 proof->DeleteParameters(
"PROOF_NTUPLE_DONT_PLOT");
1140 proof->DeleteParameters(
"SimpleNtuple.root");
1142 }
else if (act ==
"friends") {
1150 Printf(
"runProof: %s: warning concept of 'first' meaningless for this tutorial"
1151 " - ignored", act.Data());
1154 Bool_t sameFile = kFALSE;
1155 while (args.Tokenize(tok, from,
" ")) {
1157 if (tok ==
"samefile") {
1164 TList *wrks = proof->GetListOfSlaveInfos();
1166 Printf(
"runProof: could not get the list of information about the workers");
1171 TMap *files =
new TMap;
1172 files->SetName(
"PROOF_FilesToProcess");
1175 while ((wi = (TSlaveInfo *) nxwi())) {
1176 fntree.Form(
"tree_%s.root", wi->GetOrdinal());
1177 THashList *wrklist = (THashList *) files->GetValue(wi->GetName());
1179 wrklist =
new THashList;
1180 wrklist->SetName(wi->GetName());
1181 files->Add(
new TObjString(wi->GetName()), wrklist);
1183 wrklist->Add(
new TObjString(fntree));
1187 proof->AddInput(files);
1189 Printf(
"runProof: friend tree stored in the same file as the main tree");
1190 proof->SetParameter(
"ProofAux_Action",
"GenerateTreesSameFile");
1192 proof->SetParameter(
"ProofAux_Action",
"GenerateTrees");
1195 nevt = (nevt < 0) ? 10000 : nevt;
1196 proof->SetParameter(
"ProofAux_NEvents", (Long64_t)nevt);
1198 proof->SetParameter(
"PROOF_Packetizer",
"TPacketizerFile");
1200 sel.Form(
"%s/proof/ProofAux.C%s", tutorials.Data(), aMode.Data());
1201 proof->Process(sel.Data(), 1);
1203 proof->DeleteParameters(
"PROOF_Packetizer");
1206 TDSet *dset =
new TDSet(
"Tmain",
"Tmain");
1207 TDSet *dsetf =
new TDSet(
"Tfrnd",
"Tfrnd");
1208 if (proof->GetOutputList()) {
1209 TIter nxo(proof->GetOutputList());
1212 while ((o = nxo())) {
1213 TList *l =
dynamic_cast<TList *
> (o);
1214 if (l && !strncmp(l->GetName(),
"MainList-", 9)) {
1216 while ((os = (TObjString *) nxf()))
1217 dset->Add(os->GetName());
1221 while ((o = nxo())) {
1222 TList *l =
dynamic_cast<TList *
> (o);
1223 if (l && !strncmp(l->GetName(),
"FriendList-", 11)) {
1225 while ((os = (TObjString *) nxf()))
1226 dsetf->Add(os->GetName());
1231 dset->AddFriend(dsetf,
"friend");
1232 sel.Form(
"%s/proof/ProofFriends.C%s", tutorials.Data(), aMode.Data());
1233 TString xopt = aFeedback;
if (!opt.IsNull()) xopt += TString::Format(
" %s", opt.Data());
1234 dset->Process(sel, xopt);
1236 proof->ClearData(TProof::kUnregistered | TProof::kForceClear);
1238 }
else if (act ==
"simplefile") {
1246 Printf(
"runProof: %s: warning concept of 'first' meaningless for this tutorial"
1247 " - ignored", act.Data());
1250 nevt = (nevt < 0) ? 1000000 : nevt;
1253 while (args.Tokenize(tok, from,
" ")) {
1255 if (tok.BeginsWith(
"nhist=")) {
1257 aNhist.ReplaceAll(
"nhist=",
"");
1258 if (!aNhist.IsDigit()) {
1259 Printf(
"runProof: error parsing the 'nhist=' option (%s) - ignoring", tok.Data());
1264 Int_t nhist = (aNhist.IsNull()) ? 16 : aNhist.Atoi();
1265 Printf(
"\nrunProof: running \"simplefile\" with nhist= %d and nevt= %lld\n", nhist, nevt);
1268 proof->SetParameter(
"ProofSimple_NHist", (Long_t)nhist);
1271 TString fout(aOutFile);
1272 if (fout.IsNull()) {
1273 fout.Form(
"%s/SimpleFile.root", gSystem->WorkingDirectory());
1275 gSystem->Unlink(fout);
1277 if (!isProofLocal) {
1279 Bool_t xrdok = kFALSE;
1281 while (port < 9010) {
1282 if (checkXrootdAt(port) != 1) {
1283 if (startXrootdAt(port, gSystem->WorkingDirectory(), kTRUE) == 0) {
1291 Printf(
"runProof: could not start basic xrootd on ports 9000-9009 - cannot continue");
1294 fout.Insert(0, TString::Format(
"root://%s:%d/", TUrl(gSystem->HostName()).GetHostFQDN(), port));
1296 proof->AddInput(
new TNamed(
"PROOF_OUTPUTFILE_LOCATION",
"LOCAL"));
1299 proof->AddInput(
new TNamed(
"PROOF_OUTPUTFILE", fout.Data()));
1302 sel.Form(
"%s/proof/ProofSimpleFile.C%s", tutorials.Data(), aMode.Data());
1305 TString xopt = aFeedback;
if (!opt.IsNull()) xopt += TString::Format(
" %s", opt.Data());
1306 proof->Process(sel.Data(), nevt, xopt);
1308 }
else if (act ==
"stdvec") {
1315 Printf(
"runProof: %s: warning concept of 'first' meaningless for this tutorial"
1316 " - ignored", act.Data());
1319 nevt = (nevt < 0) ? 50000 * proof->GetParallel() : nevt;
1320 Printf(
"\nrunProof: running \"stdvec\" with nevt= %lld\n", nevt);
1323 sel.Form(
"%s/proof/ProofStdVect.C%s", tutorials.Data(), aMode.Data());
1327 xopt.Form(
"%s %s create", aFeedback.Data(), opt.Data());
1328 proof->Process(sel.Data(), nevt, xopt);
1331 if (proof->ExistsDataSet(
"TestStdVect")) {
1334 xopt.Form(
"%s %s", aFeedback.Data(), opt.Data());
1335 proof->Process(
"TestStdVect", sel.Data(), xopt);
1338 Printf(
"runProof: dataset 'TestStdVect' not available!");
1343 Printf(
"runProof: unknown tutorial: %s", what);
1348 SavePerfTree(proof, aPerfTree.Data());
1350 gProof->DeleteParameters(
"PROOF_StatsHist");
1351 gProof->DeleteParameters(
"PROOF_StatsTrace");
1352 gProof->DeleteParameters(
"PROOF_SlaveStatsTrace");
1357 void plotNtuple(TProof *p,
const char *ds,
const char *ntptitle)
1364 TCanvas *c1 =
new TCanvas(Form(
"cv-%s", ds), ntptitle,800,10,700,780);
1366 TPad *pad1 = (TPad *) c1->GetPad(1);
1367 TPad *pad2 = (TPad *) c1->GetPad(2);
1374 pad1->GetFrame()->SetFillColor(15);
1376 p->SetParameter(
"PROOF_LineColor", (Int_t)1);
1377 p->SetParameter(
"PROOF_FillStyle", (Int_t)1001);
1378 p->SetParameter(
"PROOF_FillColor", (Int_t)45);
1379 p->DrawSelect(ds,
"3*px+2",
"px**2+py**2>1");
1380 p->SetParameter(
"PROOF_FillColor", (Int_t)38);
1381 p->DrawSelect(ds,
"2*px+2",
"pz>2",
"same");
1382 p->SetParameter(
"PROOF_FillColor", (Int_t)5);
1383 p->DrawSelect(ds,
"1.3*px+2",
"(px^2+py^2>4) && py>0",
"same");
1389 p->DrawSelect(ds,
"pz:py:px",
"(pz<10 && pz>6)+(pz<4 && pz>3)");
1390 p->SetParameter(
"PROOF_MarkerColor", (Int_t)4);
1391 p->DrawSelect(ds,
"pz:py:px",
"pz<6 && pz>4",
"same");
1392 p->SetParameter(
"PROOF_MarkerColor", (Int_t)5);
1393 p->DrawSelect(ds,
"pz:py:px",
"pz<4 && pz>3",
"same");
1394 TPaveText *l2 =
new TPaveText(0.,0.6,0.9,0.95);
1395 l2->SetFillColor(42);
1396 l2->SetTextAlign(12);
1397 l2->AddText(
"You can interactively rotate this view in 2 ways:");
1398 l2->AddText(
" - With the RotateCube in clicking in this pad");
1399 l2->AddText(
" - Selecting View with x3d in the View menu");
1407 p->DeleteParameters(
"PROOF_*Color");
1408 p->DeleteParameters(
"PROOF_*Style");
1412 void SavePerfTree(TProof *proof,
const char *fn)
1417 Printf(
"PROOF must be run to save output performance information");;
1420 if (!proof->GetOutputList() || proof->GetOutputList()->GetSize() <= 0) {
1421 Printf(
"PROOF outputlist undefined or empty");;
1425 TFile f(fn,
"RECREATE");
1427 Printf(
"ERROR: could not open file '%s' for writing", fn);;
1430 TIter nxo(proof->GetOutputList());
1432 while ((obj = nxo())) {
1433 TString objname(obj->GetName());
1434 if (objname.BeginsWith(
"PROOF_")) {
1437 if (objname ==
"PROOF_PerfStats" ||
1438 objname ==
"PROOF_PacketsHist" ||
1439 objname ==
"PROOF_EventsHist" ||
1440 objname ==
"PROOF_NodeHist" ||
1441 objname ==
"PROOF_LatencyHist" ||
1442 objname ==
"PROOF_ProcTimeHist" ||
1443 objname ==
"PROOF_CpuTimeHist")