How to Adapt User Macros
        Examples of user scripts adapted to run under phat.C are in the phatloop/macros directory; Mul.h, Mul.C  etc. can be read from these web pages. You will see that variables which must be global have their definitions moved to Mul.h; this is because the scripts used with phat.C are in several { } sections which thus have local scope for the variables defined therein. The adapted scripts have a macro function "wrapper" consisting of several sections chosen by "phase", the first of two macro function parameters. These phases are in general terms initialization, event loop, display, end of run actions and end of run displays. They are flagged by kIni1 etc. as seen in phat.C.

 In more detail, sub-phases are possible in order to control the sequence of dependent tasks in addition to the program order, for example one wants to find a vertex before calculating multiplicity. Note that several common functions are taken over by phat.C (these are generally shared by "tasks"); you must thus delete TPhDetector and TPhDST and their execution in initialization. Input files are handled by phat.C. It also handles the event loop including getting the event and some common operations such as SetEvent and supplying a default vertex if not found. The names det, data, ev, v1 and iev must be used; see the phat.C listing.

 The second parameter "dflag" is meant to control displays. Zero means no displays but no convention yet exists for non-zero values which may be used to select different types of displays.

 In general, you must be careful about the scope of variables, this is perhaps the most common source of difficulty in adapting scripts to phat.C, especially for old FORTRAN retreads (:\>>>.