Writing a text file or similiar with proof

Dear Proof experts,

I was wondering how I could write some Information (two numbers almost each eventin two columns) into a simple text file during a proof session and also read Information out of a text file.
It makes no difference if I get one text file for each worker or if it is merged as one. Of course it would be nicer if the file is merged at end of my Proof session.

I also would be happy if this is possible with lets say a xml file or similar.

thanks,
Chris

Dear Chris,

There is no automatic way to do that, apart from writing the info in the logs and then grep from there.
I see two other ways:
1: If the expected size of the files is not so big, you can fill in a TMacro with your info and get back one instance per workers which you can merge by hand in Terminate() (there is no merge implementation for TMacro, yet).
2: Write your files in the sandbox on the workers (just open the files with the file name) and then access them via some file server (or write them into a shared file system, if you have one …). If you run ROOT >= 5.28/00c you can access them directly via the PROOF daemon with an URL like ‘rootd://<worker_hostname>/<session_dir>/’, where ‘rootd://<worker_hostname>’ can be taken on the workers from the env LOCALDATASERVER,and ‘<session_dir>’ from gSystem->WorkingDirectory() .

If you want to give a try I can give more details.

G. Ganis

Hi Gerri,

I have the same situation to merge text file in Proof. Following your suggestion, I defined TNamed object with name “cutsList”, and title in gSystem->Getenv(“LOCALDATASERVER”)+"/"+gSystem->WorkingDirectory()+"/"+“cutsList.txt”. And in SlaveTerminate() I added those TNamed object to fOutput, but I got the following error message:

Error in TSelectorList::CheckDuplicateName: an object with the same name: evtsList is already in the list
Error in TSelectorList::CheckDuplicateName: an object with the same name: evtsList is already in the list
Error in TSelectorList::CheckDuplicateName: an object with the same name: evtsList is already in the list
Error in TSelectorList::CheckDuplicateName: an object with the same name: evtsList is already in the list
Error in TSelectorList::CheckDuplicateName: an object with the same name: evtsList is already in the list
Error in TSelectorList::CheckDuplicateName: an object with the same name: evtsList is already in the list

It looks like only the first object was added into fOutput, and the other 6 objects on other workers were rejected. Did I do in a wrong way? Please advise. Thanks.

–Shuwei

HI Shuwei,

The best is to find a way to name each of the TNamed object differently on each slave.

Cheers,
Philippe.

Hi Shuwei,

Try something like:

TString name = TString::Format("cutsList_%s", gProofServ->GetOrdinal());
TString title = TString::Format("%s/%s/cutsList.txt", gSystem->Getenv("LOCALDATASERVER"), gSystem->WorkingDirectory());
fOutput->Add(new TNamed(name, title));

You need to include TProofServ.h in the selector.

Let me know,
Gerri

Hi Gerri and Philippe,

Using a different name on each slave makes Merging difficult. With same name from each slaves, I can use its name as identify to merge all objects with identical name in TSelector::Terminate(). Gerri, but why can TH1F and TProofOutputFile be added into fOutput with same name on each node?

–Shuwei

Hi Shuwei,

This is because they can be automatically merge (yes based on the name) since they have implemented the ::Merge functions. If you want PROOF to automatically merge you object, you will need to provide a Merge member function, otherwise the merge must be done by hand and thus the object will need different name.

Cheers,
Philippe.

Hi,

There is one more question. Do I have use TFile to open the text files on proof workers? Given the full URL path of these text files on proof workers, is there any fast way to merge them into one single file at client?

Thanks.

–Shuwei

Hi Shuwei,

I do not think that merging of text files is a well defined operation. Do you mean concatenating them?
In the order of the worker ordinal number?

I think that the best way is to write in the normal log file and then use the TProofLog grep facilities to filter the information that you want and save it in a single file. Have a look at
root.cern.ch/drupal/content/gett … flogviewer
and
root.cern.ch/root/html/TProofLog.html

Gerri