If someone has written a file containing FARFALLA trees to disk, you
may read those trees in by calling F_inputTree(),
F_inputTree() provided that you know the type of the
top-level node in the tree. (If not, you will have to use the more
complicated F_inputSubtree() routine, discussed in the reference
section, Section
.) F_inputTree() takes two
arguments. The first is a pointer to a node of the proper type. The
second is a file (actually an iostream) from which to read. The
file must be previously opened. F_inputTree() reads exactly one
entire tree from disk and makes the pointer point at the top node of
the tree. As before, when you are finished using a tree you must
delete it to free up the memory it was occupying.
The following program might be the generic shell for analysis programs. It reads every event from a file of event trees and if the run number passes a cut, calls user analysis routines. The analysis routines receive a pointer to the top of the tree from the main routine. (Usually we use a global variable rather than a subroutine parameter to pass the pointer.) After analysis the tree is deleted. The program continues until the input file is exhausted; at that time F_inputTree returns NULL.
fstream infile;
infile.open("locfile.far",ios::in);
eventNode *evPtr;
F_inputTree(evPtr,infile); // this creates the tree in memory and
// makes evPtr point at its top node
while (evPtr != NULL) // F_inputTree() will make evPtr NULL
// when the input file has been exhausted
{
if (evPtr->run > 1000) do_user_analysis(evPtr);
evPtr->deleteSubtree(); // free up the memory
F_inputTree(evPtr,infile); // get the next tree into memory
}