# Alin X

Walter R. Nelson Stanford Linear Accelerator Center Stanford University Stanford, CA 94305, U.S.A. Hideo Hirayama National Laboratory for High Energy Physics (KEK) Oho-machi, Tsukuba-gun, Ibaraki, Japan David W. O. Rogers National Research Council of Canada Ottawa K1A 0R6, Canada 31 December 1985A3. PEGS4 USER MANUALA3.1 Introduction The PEGS code (Preprocessor for EGS) is a stand aloneutility program written in Mortran **. PEGS' purpose is togenerate material data for the EGS code, and to provide otherservices for the user who is studying or simulating electro-magnetic interactions. The active operations of PEGS arefunctionals; that is, they are operations whose arguments arefunctions (the functions related to physics interactions).Included among these operations are: Fitting of functions by means of piecewise linear fits. Production of print plots of selected functions. Evaluation of functions at selected points. Comparision of functions with sampled spectra.Associated with these active functionals are other operations;namely, Selection of material to which the functions refer. Selection of energy cutoffs for fits. Punching of fit data.Note: Those interested in preparing data sets for EGS4 can go directly to Section A3.3* This manual is kept up-to-date on the EGS account at SLAC and is distributed along with other files on the EGS4 distribution tape.** A. J. Cook, "Mortran3 User's Guide", SLAC Computation Research Group Technical Memorandum CGTM-209 (1983) [see also APPENDIX 4: "EGS4 Users Guide to Mortran3"].A3.2 Structural Organization of PEGS The PEGS code contains over 4200 Mortran source lineswhich are the source for a MAIN program, BLOCK DATA subpro-gram, 12 subroutines, and 83 functions. Despite the largenumber of subprograms, PEGS has a simple structure. Fig.A3.2.1 shows a flowchart of the MAIN program of PEGS. Afterthe once-only initializations an option loop is entered.Each time through the option loop, an option is read (optionnames are four characters and are read as 4A1), numeric con-trol parameters are read (using NAMELIST/INP/), and then theoption name is looked up in the option table. If not found,the job is aborted. If found, the appropriate code is exec-uted and return is passed to the beginning of the optionloop. Normal exit from the loop is by selection of the STOPoption, or detection of an End of File condition on the con-trol input file. The details for the use of the options arecontained in Section A3.3. Fig. A3.2.2 shows the subprogram relationships of PEGS.Boxed items are subprograms, and labels for option names(i.e., :CALL:) are used to show which subprograms correspond towhich options. It can be seen that the physical routines areaccessed directly for the PWLF option. For utility options(TEST, PLTN, PLTI, HPLT, and CALL) the physical routines arereferenced using the function FI---the so-called "functionmultiplexer". Function FI has five arguments. The firstargument (I) tells which physical function to invoke, and theother four arguments (X1, X2, X3, X4) are used as needed asarguments for the called function. FI then returns the valuereturned by the called function. This method of implementing options that are functionalswas selected to avoid the necessity of having a separate callto the associated utility routines for each physical functionon which it might be desired to operate. It was also desiredto be able to refer to the particular function symbolically,both at compile time and at run-time, and to know the numberof arguments to each function. In order to have theseconveniences and also allow easy insertion or deletion offunctions to the list of functions accessible to FI, aMortran macro ($FUNCTIONS) was written which takes alist of names of functions (each of which is immediately pre-ceded by the number of arguments it has) and generates othermacros containing the desired information. In particular, +------+ PEGS +------+ +-------------+ initialize +------x OPTION LOOP x-----+ +--------------+ +-------------+ A V V +------------------------+ +-----------------+ Compute Physical & Read Option Mathematical Constants Name (4A1) +------------------------+ & Read Control Parameters V (NAMELIST/INP/) +------------------------+ +-----------------+ Read Pair Production & Photo Cross Sections from File PHPRDAT +------------------------+ V +------+ Yes +--------------+ Stop x------------ End of File? +------+ +--------------+ No V +-----------------------+ +---------------+ Illegal Option---Stop x----- Select Option +-----------------------+ +---------------+ V +x---------------------------------------- + V * * * * * ** 1 * * 2 * * * * * * * Fig. A3.2.1 Flowchart of the MAIN Program of PEGS (continued) * * * * * ** 1 * * 2 * * * * * * * A +-----------------------+ +--x:ELEM: Set Up Element Medium -------------------x +-----------------------+ +-----------------------+ +--x:MIXT: Set Up Mixture Medium -------------------x +-----------------------+ +------------------------+ +--x:COMP: Set Up Compound Medium ------------------x +------------------------+ +------------------------+ +--x:ENER: Set Energy Cutoffs and ------------------x Compute Thresholds +------------------------+ +---------------------+ +--x:PLTN: Plot Named Function ---------------------x +---------------------+ +-----------------------+ +--x:PLTI: Plot Indexed Function -------------------x +-----------------------+ +-----------------------+ +--x:HPLT: Histogram Theoretical -------------------x vs Sampled Spectrum +-----------------------+ +-------------------------+ +--x:CALL: Evaluate Named Function -----------------x +-------------------------+ +-----------------------------+ +--x:TEST: Plot Functions To Be Fitted -------------x +-----------------------------+ +----------------------+ +--x:PWLF: Piecewise Linear Fit --------------------x +----------------------+ +------------------------+ +--x:DECK: Punch Deck of Material ------------------x + Dependent Data +------------------------+ +------+ +--x:STOP: Stop +------+ Fig. A3.2.1 Flowchart of the MAIN Program of PEGS +------------+ +------+ BLOCK DATA MAIN +------------+ +------+ + --- + -- + ----- + ----- + ----- + ----- + ---- + ---- + :PWLF: :DECK: :TEST: :HPLT: :CALL: :ENER: :PLTN: +---+ :PLTI: +-----+ LAY HPLT1 +---+ +-----+ +----+ +------+ +---+----+ PLOT PMDCON +----+ +------+ +-----+ +-----+ EBIND PWLF1 +-----x x--- + +-----+ +-----+ :ELEM: :MIXT: +----+ :COMP: QFIT * +----+ * * + ----- + ----- + * 3 * * *+---+ +------+ +------+ *MIX SPINIT DIFFER +---+ +------+ +------+ + -- + -- + --------------- + +-----+ +-----+ +-----+ EFUNS GFUNS RFUNS +-----+ +-----+ +-----+ +-----+----+-----+--+---+---+ +------+ +-----+ +---PHOTTE AINTP+------+ +------+ +------+ +------+ +-----+SPTOTP ANIHTM BHABTM +------++------+ +------+ +------+ +---COMPTM +------++------+ +------+ +------+ +------+SPTOTE-+ AMOLTM-+ BREMTM-+ +---PAIRTU+------+ +------+ +------+ +------+ +------+ +---COHETM +------+ Fig. A3.2.2 Subprogram Relationships of PEGS (continued) * * * * 3 * * * * + ---------------------- + FI "Function Multiplexer" + ---------------------- + + ------------------------------------- + ALIN APRIM COMPFM PAIRTE ALINI BHABDM COMPRM PAIRTM BHABFM COMPTM PAIRTR ADFMOL BHABRM CRATIO PAIRTU ADIMOL BHABTM EBIND PAIRTZ ADDMOL BREMDR EBR1 PBR1 ALOG BREMFR EDEDX PBR2 EXP BREMDZ ESIG PDEDX AREC BRMSDZ FCOULC PHOTTZ ALKE BREMFZ GBR1 PHOTTE ALKEI BRMSFZ GBR2 PSIG AMOLDM BREMRR GMFP SPIONE AMOLFM BREMRM PAIRDR SPIONP AMOLRM BREMRZ PAIRFR SPTOTE AMOLTM BREMTM PAIRDZ SPTOTP ANIHDM BREMTR PAIRFZ TMXB ANIHFM BRMSRM PAIRRM TMXS ANIHRM BRMSRZ PAIRRR TMXDE2 ANIHTM BRMSTM PAIRRZ XSIF COHETM COHETZ COMPDM + ------------------------------------- + Fig. A3.2.2 Subprogram Relationships of PEGS (continued from previous page)The following macros are defined: $NFUNS - Gives the number of functions. $FLIST$DATA(FNAME) - Generates a data statement init- alizing the array FNAME(6,$NFUNS) so that FNAME(i,j) has the ith character of the name of the jth function. $FLIST$NARGS - Gives a list of the number of arguments for each function, which is used to initialize the run- time array NFARG($NFUNS). $FLIST$FNUMS - Gives a list of numbers from 1 to $NFUNS, which is used to generate the computed GO TO in FI. $FLIST$FCALLS - Generates the function calls in FI with the proper number of arguments for each function taken from the list X1, X2, X3, X4. $FN(function name) - Gives the function index of the specified function. $NA(function name) - Gives the number of arguments for the specified function. It should also be noted that there are relationshipsbetween the functions shown in Fig. A3.2.2 that are notindicated there. We show the most complicated of these inFigs. A3.2.3a,b (Bremsstrahlung Related Functions) and inFigs. A3.2.4a,b (Pair Production Related Functions). Onereason for the complexity of these is that the higher levelforms of the cross sections must be obtained by numericalintegration of the more differential forms. +------+ BREMTM +------+ V +------+ BREMRM +------+ V+------+ +------+ initialize +------+ QD x------------- BREMRZ-------------x BREMDZ+------+ +------+ BREMFZ +------+ V +------+ DCADRE +------+ V V+------+ +------+ +------+BREMFZ-------------x BRMSFZx------------- BRMSDZ+------+ +------+ +------+ A A +------+ +---------------+ +--xAPRIM +------+ +------+ +------+ initialize DCADRE +----BRMSRZ---------------x + +------+ +------+ +------+ BRMSFZ +--x XSIF A A +------+ +------+ +------+ +------+ QD x--+ BRMSRM +--xFCOULC +------+ +------+ +------+ A +------+ +------+ +------+ SPTOTE-----------x BRMSTMx----------- SPTOTP +------+ +------+ +------+ V V +------+ +------+ +------+ SPIONE-----------x SPIONBx----------- SPIONP +------+ +------+ +------+ Fig. A3.2.3a Bremsstrahlung Related Functions---Most Accurate Form (Used to Produce the Total Cross Sections and Stopping Power). +------+ BREMTR +------+ V +------+ BREMRR +------+ initialize V + x---------+--------x + BREMFR V V +------+ +------+ BREMDR QD +------+ +------+ V +------+ DCADRE +------+ +------+ + ----x BREMFR x---- + +------+ Fig. A3.2.3b Bremsstrahlung Related Functions---With Run-Time Approximations (For Comparison with Sampled Spectra). +------+ PAIRTU +------+ + x------------------- + + -------------------x + V V+------+ +------+PAIRTM PAIRTE+------+ +------+ V V+------+ +------+PAIRRM PAIRTZ+------+ +------+ V V+------+ initialize +------+PAIRRZ-------------x + AINTP +------+ PAIRFZ +------+ V V+------+ +------+ +------+ QD PAIRDZ-----+----x XSIF +------+ +------+ +------+ +------+ +----x FCOULC V V +------++------+ +------+DCADRE----------x PAIRFZ+------+ +------+ Fig. A3.2.4a Pair Production Related Functions---Most Accurate Form (Used to Produce the Total Cross Sections and Stopping Power). +------+ PAIRTR +------+ V +------+ PAIRRR +------+ initialize V + x-------- + -------x + PAIRFR V V +------+ +------+ PAIRDR QD +------+ +------+ V +------+ DCADRE +------+ +------+ + ----x PAIRFR x---- + +------+ Fig. A3.2.4b Pair Production Related Functions---With Run-Time Approximations (For Comparison with Sampled Spectra). Table A3.2.1 lists the SUBROUTINES used in PEGS. A briefdescription of their use and page references for a fullerdiscussion is given. Table A3.2.2 lists the FUNCTIONS used in PEGS along withtheir mathematical symbols, definitions, and locations in thisreport for a fuller discussion. The names of most of thefunctions have been chosen in a rather mnemonic way. Thefirst three or four letters suggest the process being con-sidered. The last letter designates the form of the crosssection (Z for element, M for mixture, and R for "run-time"mixture). The next to last letter describes either the part-icular form of the cross section (such as D for differential,T for total or R for range-integrated), or it indicates thatonly the secondary energy is to vary, with other data beingpassed through a common. The letter F is used in such casesand the data in common is initialized using the correspondingfunction that has a next to last letter of D. If the functionword begins with an I through N (i.e., the FORTRAN integerconvention) the word is prefixed with the letter A. A fewexamples are given below: AMOLDM is the differential Moller cross section for a mixture of elements. BREMDR is the differential bremsstrahlung cross section for a "run-time" mixture of elements. BREMRM is the bremsstrahlung cross section, integrated over some energy range, for a mixture of elements. BRMSTM is the soft bremsstrahlung total cross section for a mixture of elements. PAIRRR is the pair production cross section, integrated over some energy range, for a "run-time" mixture of elements. PAIRTZ is the total cross section for pair production for an element. This method of naming is not strictly adhered to,however. For example, SPIONE is the ionization stoppingpower for an electron, PBR1 and PBR2 are positron branchingratios, and GMFP is the gamma-ray mean free path. Table A3.2.1 SUBROUTINES Used In PEGS----------------------------------------------------------------- NAME DESCRIPTION PAGES----------------------------------------------------------------- DIFFER Determines the various parameters A3.2-4, needed for bremsstrahlung and pair A3.3-11 production energy sampling. EFUNS Subprogram to compute electron A3.2-4 functions to be fit in a way that avoids repetition. GFUNS Subprogram to compute photon A3.2-4 functions to be fit in a way that avoids repetition. HPLT1 Creates line printer plot comparisons A3.2-4, of EGS-sampled data (UCTESTSR User A3.3-20,21 Code) and theoretical functions of PEGS. LAY Subprogram to produce a deck of A3.2-4, material dependent data (for sub- A3.3-17 sequent use by EGS). MIX Computes Z-dependent paramaters A3.2-4, that reside in COMMON/MOLVAR/. A3.3-11 MOLIER Computes material independent A3.2-4 multiple scattering data (for EGS2 only). PLOT Subprogram to plot a given function A3.2-4 (referenced by number). PMDCON Determines the physical, mathematical, A3.2-4 and derived constants in a very mnemonic way. PWLF1 Subprogram to piecewise linearly fit A3.2-4,19, up to 10 functions simultaneously on A3.3-14 an interval (XL,XU). RFUNS Subprogram to compute Rayleigh A3.2-4 scattering functions to be fit in a way that avoids repetition. SPINIT Initializes stopping power functions A3.2-4, for a particular medium. A3.3-11 AFFACT Atomic form factor (squared) for an element or mixture of elements. AINTP Linear or log interpolation function. A3.2-4,9 ALKE Log of kinetic energy (ALOG(E-RM)), A3.2-5, used as a cumulative distribution A3.3-20 function for fits and plots. ALKEI Inverse of ALKE (=EXP(X)+RM). A3.2-5 ALIN Linear cumulative distribution func- A3.2-5, tion for plots (ALIN(X)=X). A3.3-20 ALINI Inverse of ALIN (=same as ALIN). A3.2-5 Used as inverse cumulative distri- bution function in plots. ADFMOL Approximate cumulative distribution A3.2-5, function for Moller and Bhabha cross A3.3-20 sections (ADFMOL(E)=-1/(E-RM)). ADIMOL Inverse of ADFMOL. A3.2-5 ADDMOL Derivative of ADFMOL. A3.2-5 AMOLDM Moller differential cross section for A3.2-5,11,14 a mixture of elements. AMOLFM "One argument" form of AMOLDM. A3.2-5 AMOLRM Moller cross section, integrated over A3.2-5 some energy range, for a mixture of elements. AMOLTM Moller total cross section for a A3.2-4,5 mixture of elements. ANIHDM Annihilation differential cross A3.2-5 section for a mixture of elements. ANIHFM "One argument" form of ANIHDM. A3.2-5 ANIHRM Annihilation cross section, integrated A3.2-5 over some energy range, for a mixture of elements. ANIHTM Annihilation total cross section for A3.2-4,5 a mixture of elements. APRIM Empirical correction factor in A3.2-5,7 bremsstrahlung cross section. AREC Reciprocal function (=derivative of A3.2-5 ALOG(X)). Used as probability density function in log plots (AREC(X)=1/X). BHABDM Bhabha differential cross section for A3.2-5 a mixture of elements. BHABFM "One argument" form of BHABDM. A3.2-5 BHABRM Bhabha cross section, integrated over A3.2-5 some energy range, for a mixture of elements. BHABTM Bhabha total cross section for a A3.2-4,5 mixture of elements. BREMDR Bremsstrahlung differential cross A3.2,5,8,11 section for a "run-time" mixture of elements. BREMFR "One argument" form of BREMDR. A3.2-5,8 BREMDZ Bremsstrahlung differential cross A3.2-5,7 section for an element. BREMFZ "One argument" form of BREMDZ. A3.2-5,7 BREMRM Bremsstrahlung cross section, inte- A3.2-5,7,11 grated over some energy range, for a mixture of elements. BREMRR Bremsstrahlung cross section, inte- A3.2-5,8 grated over some energy range, for a "run-time" mixture of elements. BREMRZ Bremsstrahlung cross section, inte- A3.2-5,7 grated over some energy range, for an element. BREMTM Bremsstrahlung total cross section A3.2-4,5,7 for a mixture of elements. BREMTR Bremsstrahlung total cross section A3.2-5,8 for a "run-time" mixture of elements. BRMSDZ Soft bremsstrahlung differential A3.2-5,7 cross section for an element. BRMSFZ "One argument" form of BRMSDZ. A3.2-5,7 BRMSRM Soft bremsstrahlung cross section, A3.2-5,7 integrated over some energy range, for a mixture of elements. BRMSRZ Soft bremsstrahlung cross section A3.2-5,7, integrated over some energy range, A3.3-19,20 for an element. BRMSTM Soft bremsstrahlung total cross A3.2-5,7,11 section for a mixture of elements. COHERTM Coherent (Rayleigh) total cross A3.2-4,5 section for a mixture of elements. COHETZ Coherent (Rayleigh) total cross A3.2-5 section for an element. COMPDM Compton differential cross section A3.2-5 for a mixture of elements. COMPFM "One argument" form for COMPDM. A3.2-5 COMPRM Compton cross section, integrated over A3.2-5 some energy range, for a mixture of elements. COMPTM Compton total cross section for a A3.2-4,5 mixture of elements. CRATIO Coherent (Rayleigh) cross section ratio A3.2-5 DCADRE Quadrature routine to integrate A3.2-7-10,19 f(x) between a and b using cautious Romberg extrapolation. EBIND Function to get an average photo- A3.2-4,5 electric binding energy. EBR1 Function to determine the electron(-) A3.2-5 branching ratio (Brem/Total). EDEDX Evaluates SPTOTE with cutoff energies A3.2-5 of AE and AP. ESIG Determines the total electron(-) A3.2-5 interaction cross section (prob- ability per radiation length). FCOULC Coulomb correction term in pair A3.2-5,7,9 production and bremsstrahlung cross sections. FI Function multiplexer. A3.2-1,5,6 GBR1 Function to determine the gamma-ray A3.2-5 branching ratio (Pair/Total). GBR2 Function to determine the gamma-ray A3.2-5 branching ratio ((Pair+Compton)/Total). GMFP Function to determine the gamma-ray A3.2-5,11, mean free path. A3.3-18,19 IFUNT Given PEGS function name, it looks it up name in table and returns the function index. Used by options that specify functions by name. P