39 void finalizeProof(
const char *what =
"simple",
40 const char *url =
"proof://localhost:11093",
45 TString tutdir = Form(
"%s/.proof-tutorial", gSystem->TempDirectory());
46 if (gSystem->AccessPathName(tutdir)) {
47 Printf(
"runProof: creating the temporary directory"
48 " for the tutorial (%s) ... ", tutdir.Data());
49 if (gSystem->mkdir(tutdir, kTRUE) != 0) {
50 Printf(
"runProof: could not assert / create the temporary directory"
51 " for the tutorial (%s)", tutdir.Data());
57 TProof *proof = getProof(url, nwrks, tutdir.Data(),
"");
59 Printf(
"runProof: could not start/attach a PROOF session");
64 TObjArray *qt =
new TObjArray();
66 TString proofsessions(Form(
"%s/sessions",tutdir.Data()));
68 FILE *fs = fopen(proofsessions.Data(),
"r");
70 Printf(
"runProof: could not create files for sessions tags");
73 while (fgets(line,
sizeof(line), fs)) {
76 if (strncmp(line,
"session-",strlen(
"session-")))
continue;
77 if (line[l-1] ==
'\n') line[l-1] = 0;
79 qt->Add(
new TObjString(lasttag.Data()));
85 TList *ql = proof->GetListOfQueries(
"A");
86 if (!ql || ql->GetSize() <= 0) {
87 Printf(
"runProof: no queries to be finalized");
93 char *rootbin = gSystem->Which(gSystem->Getenv(
"PATH"),
"root.exe", kExecutePermission);
95 Printf(
"runProof: root.exe not found: please check the environment!");
98 TString rootsys(gSystem->DirName(rootbin));
99 rootsys = gSystem->DirName(rootsys);
100 TString tutorials(Form(
"%s/tutorials", rootsys.Data()));
104 TDrawFeedback fb(proof);
108 args.ReplaceAll(
"(",
" ");
109 args.ReplaceAll(
")",
" ");
110 args.ReplaceAll(
",",
" ");
113 if (!args.Tokenize(act, from,
" ")) {
115 Printf(
"runProof: action not found: check your arguments (%s)", what);
119 TObjArray *qa =
new TObjArray();
122 if (act ==
"simple") {
124 }
else if (act ==
"h1") {
126 }
else if (act ==
"pythia8") {
130 Printf(
"runProof: unknown tutorial: %s", what);
135 Int_t nt = qt->GetEntriesFast();
136 while (ref.IsNull() && nt--) {
137 lasttag = ((TObjString *)(qt->At(nt)))->GetName();
138 if (!lasttag.IsNull())
139 Printf(
"runProof: checking session: %s", lasttag.Data());
141 TQueryResult *qr = 0;
142 while ((qr = (TQueryResult *)nxq())) {
143 if (qr->IsDone() && !lasttag.CompareTo(qr->GetTitle()) &&
144 !sel.CompareTo(qr->GetSelecImp()->GetTitle())) {
145 TString r = Form(
"%s:%s",qr->GetTitle(),qr->GetName());
146 qa->Add(
new TObjString(r.Data()));
149 if (qa->GetEntriesFast() > 0) {
151 if (qa->GetEntriesFast() > 1) {
153 Printf(
"finalizeProof: queries completed for analysis '%s'", act.Data());
154 for (Int_t k = 0; k < qa->GetEntriesFast(); k++) {
155 Printf(
" [%d] %s", k, ((TObjString *)(qa->At(k)))->GetName());
159 char *answer = Getline(
"finalizeProof: enter the one you would like to finalize? [0] ");
161 if (answer[0] ==
'Q' || answer[0] ==
'q') {
166 sn.Remove(sn.Length()-1);
169 if (qn >= 0 && qn < qa->GetEntriesFast()) {
172 Printf(
"finalizeProof: choice must be in [0,%d] ('Q' to quit)",
173 qa->GetEntriesFast()-1);
180 Printf(
"finalizeProof: choice must be a number in [0,%d] ('Q' to quit) (%s)",
181 qa->GetEntriesFast()-1, sn.Data());
187 ref = ((TObjString *)(qa->At(qn)))->GetName();
192 proof->Retrieve(ref);
194 proof->Finalize(ref);
196 Printf(
"runProof: no queries to be finalized for analysis '%s'", act.Data());