Macro to finalize queries run with the macro tutorials/runProof .
This macro uses an existing PROOF session or starts one at the indicated URL. In the case non existing PROOF session is found and no URL is given, the macro tries to start a local PROOF session.
To run the macro:
root[] .L proof/finalizeProof.C+ root[] finalizeProof("<analysis>")
See runProof.C for the analysis currently available.
The macro looks for the last completed queries for the chosen analysis and asks which one to finalize. If there is only available, it finalizes it without asking. All queries are considered for this, both those run synchronously and those run asynchronously, e.g. runProof("h1(asyn)").
#include "Getline.h"
void finalizeProof(const char *what = "simple",
const char *url = "proof://localhost:11093",
{
Printf(
"runProof: creating the temporary directory" " for the tutorial (%s) ... ", tutdir.
Data());
Printf(
"runProof: could not assert / create the temporary directory" " for the tutorial (%s)", tutdir.
Data());
return;
}
}
if (!proof) {
Printf(
"runProof: could not start/attach a PROOF session");
return;
}
FILE *fs = fopen(proofsessions.Data(), "r");
if (!fs) {
Printf(
"runProof: could not create files for sessions tags");
} else {
char line[1024];
while (fgets(line, sizeof(line), fs)) {
int l = strlen(line);
if (l <= 0) continue;
if (strncmp(line,"session-",strlen("session-"))) continue;
if (line[l-1] == '\n') line[l-1] = 0;
}
fclose(fs);
}
Printf(
"runProof: no queries to be finalized");
return;
}
if (!rootbin) {
Printf(
"runProof: root.exe not found: please check the environment!");
return;
}
TString tutorials(
Form(
"%s/tutorials", rootsys.Data()));
delete[] rootbin;
args.ReplaceAll("("," ");
args.ReplaceAll(")"," ");
args.ReplaceAll(","," ");
if (!args.Tokenize(act, from, " ")) {
Printf(
"runProof: action not found: check your arguments (%s)", what);
return;
}
if (act == "simple") {
sel = "ProofSimple";
} else if (act == "h1") {
sel = "h1analysis";
} else if (act == "pythia8") {
sel = "ProofPythia";
} else {
Printf(
"runProof: unknown tutorial: %s", what);
}
while (ref.
IsNull() && nt--) {
Printf(
"runProof: checking session: %s", lasttag.
Data());
}
}
Printf(
"finalizeProof: queries completed for analysis '%s'", act.
Data());
}
while (ask) {
char *answer = Getline("finalizeProof: enter the one you would like to finalize? [0] ");
if (answer) {
if (answer[0] == 'Q' || answer[0] == 'q') {
return;
}
sn.Remove(sn.Length()-1);
if (sn.IsDigit()) {
qn = sn.Atoi();
if (qn >= 0 && qn < qa->GetEntriesFast()) {
break;
} else {
Printf(
"finalizeProof: choice must be in [0,%d] ('Q' to quit)",
}
} else {
if (sn.IsNull()) {
qn = 0;
break;
} else {
Printf(
"finalizeProof: choice must be a number in [0,%d] ('Q' to quit) (%s)",
}
}
}
}
}
}
}
if (!ref.IsNull()) {
} else {
Printf(
"runProof: no queries to be finalized for analysis '%s'", act.
Data());
return;
}
}
- Author
- Gerardo Ganis
Definition in file finalizeProof.C.