
%UNIX --- UPDATED ON 14/8/97 
%====================================================================%
%                  ltwol.tex     27-Feb-1995                         %
% This latex file rewritten from various sources for use in the      %
% preparation of the (larger) two-column proceedings Volume, latest  %
% version by Susan Hezlet with acknowledgements to Lukas Nellen.     %
% Some changes are due to David Cassel.                              %
% Additional minor typing changes by M. Comyn for use by ICHEP'98.   %
%====================================================================%

\documentstyle[ltwol]{article}

\font\eightrm=cmr8

%\input{psfig}



\arraycolsep1.5pt 

% A useful Journal macro
\def\Journal#1#2#3#4{{#1} {\bf #2}, #3 (#4)}

% Some useful journal names
\def\NCA{\em Nuovo Cimento}
\def\NIM{\em Nucl. Instrum. Methods}
\def\NIMA{{\em Nucl. Instrum. Methods} A}
\def\NPB{{\em Nucl. Phys.} B}
\def\PLB{{\em Phys. Lett.}  B}
\def\PRL{\em Phys. Rev. Lett.}
\def\PRD{{\em Phys. Rev.} D}  
\def\ZPC{{\em Z. Phys.} C}

% Some other macros used in the sample text
\def\st{\scriptstyle}
\def\sst{\scriptscriptstyle}
\def\mco{\multicolumn}
\def\epp{\epsilon^{\prime}}
\def\vep{\varepsilon}
\def\ra{\rightarrow}
\def\ppg{\pi^+\pi^-\gamma}
\def\vp{{\bf p}}
\def\ko{K^0}
\def\kb{\bar{K^0}}
\def\al{\alpha}
\def\ab{\bar{\alpha}}
\def\be{\begin{equation}}
\def\ee{\end{equation}}
\def\bea{\begin{eqnarray}}
\def\eea{\end{eqnarray}}
\def\CPbar{\hbox{{\rm CP}\hskip-1.80em{/}}}%temp replacemt due to no font

\bibliographystyle{unsrt}    %for BibTeX - sorted numerical labels

\input psfig

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                      BEGINNING OF TEXT                           
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\titlepage
\begin{flushright}
IFT 98/12 \\

\end{flushright}
\vskip 3cm
\centerline{\bf {\Large {{NLO PREDICTION FOR THE PHOTOPRODUCTION}}}}
\vskip 0.4cm 
\centerline{\bf {\Large {OF THE ISOLATED PHOTON AT HERA}}}
\vskip 4cm
\centerline{\Large Maria Krawczyk$^*$ and Andrzej Zembrzuski}                 
\centerline{Institute of Theoretical Physics, Warsaw University,}
\centerline{ul. Ho\.za 69, 00-681 Warsaw, Poland}
\centerline{E-mail: krawczyk@fuw.edu.pl,azem@fuw.edu.pl}

\vskip 4cm
\begin{abstract}
The NLO calculation of the DIC process with the isolated photon
is presented and the
comparison is made \newline
with the other NLO  calculation and
with recent 
measurement at HERA. The satisfactory agreement was found.
\end{abstract}

\footnotetext{$^*$ Talk at ICHEP'98, Vancouver, Canada, 23-29 July 1998} 

\title{
NLO PREDICTION FOR THE PHOTOPRODUCTION OF THE ISOLATED PHOTON AT HERA
}

\author{M. KRAWCZYK, A. ZEMBRZUSKI}

\address{Institute of Theoretical Physics, Warsaw University,
ul. Ho\.za 69, 00-681 Warsaw, 
Poland\\E-mail: krawczyk@fuw.edu.pl,azem@fuw.edu.pl}   


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% You may repeat \author \address as often as necessary      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\twocolumn[\maketitle\abstracts{ 
The NLO calculation of the DIC process with the isolated photon
is presented and the
comparison is made with the other NLO  calculation and with recent 
measurement at HERA. The satisfactory agreement was found.
}]

\section{Introduction}
We consider Deep Inelastic Compton (DIC)  scattering where the photon
with large transverse momentum $p_T$ is produced 
 in $ep$ collision. 
With antitagging or untagging conditions 
such reaction is  dominated by events with 
almost real photons mediating the $ep$ interaction, 
$Q^2\approx 0$, so in practice the photoproduction is considered.
 The observed final $\gamma$
 arises directly from the direct subprocess $\gamma q\ra \gamma q$
or from subprocesses where partonic content of 
the photon contributes.
The final photon may originate also from the fragmentation processes, 
where  $q$ or  $g$ 'decays' into $\gamma$.


In  this talk the results of the 
NLO calculation for DIC process \cite{mkzz} are shown
with the discussion on the choice of the relevant set of diagrams.
Then the influence of the
isolation cuts on the production rate of the final photon
is shown and the role of additional cuts applied in
the experimental analysis of this process at HERA is discussed.
The importance of the box diagram $\gamma g\ra \gamma g$,
being the higher order direct process, is stressed.

 The final results for the isolated photon production in the DIC process  at 
HERA are compared
with the existing in literature calculation \cite{gor98}  and with the corresponding
data \cite{zeus}.

\section{Deep inelastic Compton process in NLO}
\subsection{NLO calculation for processes involving photons}\label{subsec:prod}
We start  by describing processes which are (should be?)
included in the NLO QCD calculation
of the cross section for  the DIC process, 
\be
\gamma p \ra \gamma X.
\ee
Although we will discuss the process (1), the problem which we
touch upon   is more general -  it is related to the different approaches
to   
NLO calculations of  cross sections for hadronic  processes involving photons.
\begin{figure}
\center
%\rule{2cm}{0.2mm}\hfill \rule{2cm}{0.2mm}
\vskip 0.5cm
\psfig{figure=born.ps,height=1.5cm}
%\rule{2cm}{0.2mm}\hfill \rule{2cm}{0.2mm}
\caption{The lowest order Born contribution}
\label{fig:born}
\end{figure}

The Born level contribution to the cross section, the lowest order in the 
strong  coupling constant $\alpha_s$ term,  is based on the Compton process 
on the quark (Fig.~\ref{fig:born}):
\be
\gamma q\ra \gamma q.
\ee
It leads to  the  [$\alpha_{em}^2$] order contributions to
 the  partonic cross section, and at the same $\alpha_{em}^2$  order
it contributes to  the hadronic cross section 
for the process  $\gamma p\ra \gamma X$. In the NLO analysis
the $\alpha_s$ corrections to (2)
are calculated and the terms of order  $\alpha_{em}^2
\alpha_s$ appear (Fig.~\ref{fig:cor}).
\begin{figure}
\center
%\rule{2cm}{0.2mm}\hfill \rule{2cm}{0.2mm}
\vskip 0.5cm
\psfig{figure=virt.ps,height=1.5cm}
\vskip -1.5cm
\psfig{figure=real.ps,height=1.5cm}
%\rule{2cm}{0.2mm}\hfill \rule{2cm}{0.2mm}
\caption{Examples of the virtual and real $\alpha_s$ corrections
to the Born contribution}
\label{fig:cor}
\end{figure}
 
The  Parton Model prediction for the DIC process,
 which applies for $x_T=2p_T/\sqrt{S}\sim{\cal O}(1)$,
relies solely on the Born contribution (2) \cite{dic-pm}.
  For semihard processes, where $x_T \ll 1$, the  prediction
based on (2) is
 not a good approximation, since now 
 one should consider besides (2)
  also contributions involving interactions of the partonic
content of the photon(s). There are two classes of such contributions:
{\underline  {single resolved}} with resolved initial $or$ 
final photon, and {\underline{ double resolved}} with
both the initial $and$ the final photon resolved
(Figs.~\ref{fig:1res}, \ref{fig:2res}).
They give contributions to partonic cross sections of orders 
[$\alpha_{em} \alpha_s$] (single resolved) and [$\alpha_s^2$] 
(double resolved).
%In case of single and double resolved photon  
% subprocesses of orders 
%[$\alpha_{em} \alpha_s$] and [$\alpha_s^2$], convoluted with the relevant
% partonic densities related to photons, 
%contribute to the DIC cross section, respectively. 
 If one takes into account that partonic densities in the photon and
the parton fragmentation into the photon are of order $\sim \alpha_{em}$, 
the final contribution to the hadronic cross section from resolved 
photon processes are  $\sim \alpha_{em}^2 \alpha_s$ and 
$\alpha_{em}^2 \alpha_s^2$, respectively. 
{In the LLO approach 
these three types of subprocesses:  with two direct photons, with
one and two resolved photons,
  convoluted with the relevant LL parton densities, are considered
\cite{dic-ll}.}
\begin{figure}
\center
%\rule{2cm}{0.2mm}\hfill \rule{2cm}{0.2mm}
\vskip 1cm
\psfig{figure=res.ps,height=1.5cm}
\vskip -1.5cm
\psfig{figure=frag.ps,height=1.5cm}
%\rule{2cm}{0.2mm}\hfill \rule{2cm}{0.2mm}
\caption{Examples of single resolved processes.
a) the resolved initial photon, b) the resolved final photon}
\label{fig:1res}
\end{figure}
\begin{figure}
\center
%\rule{2cm}{0.2mm}\hfill \rule{2cm}{0.2mm}
\vskip 1cm
\psfig{figure=resfrag.ps,height=1.5cm}
%\rule{2cm}{0.2mm}\hfill \rule{2cm}{0.2mm}
\caption{An example of double resolved photon process}
\label{fig:2res}
\end{figure}
%The necessity of the inclussion of the 
% {\underline {single}} resolved photon contribution 
%is obvious

 In the NLO approach,
%, when the $\alpha_s$ corrections are 
%introduced to the basic Born diagram (2),
% leading to  ,
% as we mentioned above.
among  $\alpha_{em}^2 \alpha_s$  terms,
 there are terms related to 
the  collinear singularities, 
which then have to be substracted and treated as 
a part of the corresponding {\underline {single}}
 resolved photon contribution. 
At the same time in the NLO expression there are no 
 collinear singularities
 terms which would correspond to the {\underline {double}}
 resolved photon contributions.
It  indicates that taking into account subprocesses
[$\alpha_s^2$] associated with the both initial and final photons resolved
goes  beyond the accuracy of the NLO calculation.
This will be consistent
 within the  NNLO approach, where $\alpha_s^2$ correction to the Born term and
$\alpha_s$ correction to the single resolved terms should be included,
all giving the same  $\alpha_{em}^2\alpha_s^2$ order contribution to the
 hadronic cross sections.

The other set of diagrams is considered by some authors
in the NLO approach to DIC process (1), due to 
 their different 
 way of the  counting the order of  the parton densities in the  photon 
(or the parton fragmentation into the photon) \cite{dic-nlo}. 
This approach, which we will call
``${{1}\over{\alpha_s}}$'' approach to the structure of photon,
%The origin of this
%``${{1}\over{\alpha_s}}$'' approach 
is motivated by  the existence of the 
large logarithms of $Q^2$ in the $F_2^{\gamma}$ already in PM.
By expressing  $\ln (Q^2/\Lambda_{QCD}^2)$ as $\sim 
{{1}\over{\alpha_s}}$ 
one  treats
the parton densities in photon as proportional to  $\alpha_{em}/\alpha_s$.
By applying this method to the DIC process, we see that here
the single resolved photon contribution to the hadronic cross section
is of the same order as the Born term, namely 
\be
{{\alpha_{em}}\over{\alpha_s}}\otimes [  \alpha_{em} \alpha_s]  
\otimes 1=\alpha_{em}^2,
\ee
also the
double resolved photon contribution is of the same order 
\be
{{\alpha_{em}}\over{\alpha_s}}\otimes [ \alpha_s^2]  \otimes 
 {{{\alpha_{em}}}\over{\alpha_s}}=
\alpha_{em}^2.
\ee
We see that this way,
 the same $\alpha_{em}^2$ order contributions
to the hadronic cross section are given by the Born direct process,
 single resolved photon  and double resolved photon processes,
although  they correspond to    quite different final states 
(observe a lack of the remnant of the photon in the direct process).
Moreover, they constitute the lowest order
(in the strong coupling constant) term in the perturbative expansion,
actually the zeroth order, so 
 the (leading) dependence on the strong coupling constant is absent.  
If  one takes into account that some of these terms  correspond
 to 
 the hard processes involving gluons,  a lack of $\alpha_s$ coupling 
in the cross section   seems to be contrary to the intuition.
On the other hand, on such set of contributions the LL prediction is based.

In this approach beside  the $\alpha_s$ correction to
 the Born process
also the  $\alpha_s$ corrections to the  single  and to the double
resolved photon
processes should be included in the NLO calculation,
since all of them give terms of the same order, $\alpha_{em}^2{ \alpha_s}$.

To summarize, the first NLO approach starts with one basic, direct  
subprocess,
while the second one with three different
 subprocesses (as in LO). 
Obviously, some of NNLO terms in the first method 
belong to the NLO terms in the second one.
%Which way the perturbative QCD series
%converges faster remains to be tested.
%These two approaches correspond to  the different prescriptions
%for the NLO (NNLO ..) calculations  for 
%hadronic processes involving photons since   different
%set of  diagrams are included, and therefore 
%different predictions for cross sections are expected.
%A comparison between these two approaches applied to DIC process
%will be given below, a more general analysis will be given elsewhere
%\cite{mygordon}.
\subsection {$\alpha_{em}^2$, \protect{$\alpha_{em} \alpha_{s}$} 
and $\alpha_s^2$  subprocesses in DIC}
 Below we will discuss our NLO analysis of the DIC process \cite{mkzz},
where the parton densities in the photon (the parton fragmentation 
into the photon) are treated as $\sim$ $\alpha_{em}$.



In the NLO calculation of the DIC process we take the following subprocesses
into account:\\
%A number of subprocesses contributes to the $\gamma 
%p\rightarrow\gamma X$ deep inelastic Compton process in
%the NLO approach, as discussed above. %
%\begin{itemize}
$\bullet$   the  Born contribution (2) (Fig.~\ref{fig:born})\\
$\bullet$  the $\alpha_s$ corrections to the Born diagram
%: virtual one with the same
%final state as in the Born process and a real one with an 
%additional gluon in final state 
(Figs.~\ref{fig:cor})\\
$\bullet$ two types of single resolved photon contributions, 
with the resolved initial and 
with the resolved final photon
(Figs.~\ref{fig:1res})
%shows as a example the interaction of a quark
%from the photon with a gluon from the proton leading to the
%final (direct) photon and a quark,
%while  Figs.3b shows the fragmentation of the final quark
%with  the initial photon interacting directly).
%\end{itemize}

 Beside the above   set of diagrams, the full NLO set, 
  we will in addition  include two  terms
 of order $\alpha_{em}^2 \alpha_s^2$ (formally  from the NNLO set):
 the double resolved contributions 
%${{ \alpha_{em}}}\times [ \alpha_s^2]  \times {{{ \alpha_{em}}}}=
%\alpha_{em}^2 \alpha_s^2$ 
(Fig.~\ref{fig:2res})
and the direct box diagram $\gamma g \ra \gamma g$ (Fig.~\ref{fig:box}),
since they were found to be large \cite{mk}. 
\begin{figure}
\center
%\rule{2cm}{0.2mm}\hfill \rule{2cm}{0.2mm}
\vskip 1.5cm
\psfig{figure=box.ps,height=1.5cm}
%\rule{2cm}{0.2mm}\hfill \rule{2cm}{0.2mm}
\caption{The box diagram}
\label{fig:box}
\end{figure}
\subsection{Inclusive cross section for the DIC process at $ep$ colliders} 
Infrared singularities which appear in the NLO calculations
of the virtual corrections to the
Born process are canceled by infrared singularities in the
real corrections. 
 All collinear (mass) singularities
are factorized into structure and fragmentation functions,
as discussed above, leading to the final formula for the
 inclusive cross section for the $\gamma p\rightarrow\gamma X$
scattering:
\begin{eqnarray}
E_{\gamma}{d^3\sigma^{\gamma p\rightarrow\gamma X}\over
d^3p_{\gamma}} = ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\ \nonumber
\sum\int {dz\over z^2}\int dx_{\gamma}\int dx
f_{a/\gamma}(x_{\gamma},\bar{Q}^2) f_{b/p}(x,\bar{Q}^2)\cdot \\ \nonumber
\cdot D_{\gamma /c}(z,\bar{Q}^2)
E_{\gamma}{d^3\sigma^{ab\rightarrow cd}\over d^3p_{\gamma}}
+\sum\int dx f_{b/p}(x,\bar{Q}^2) {\alpha_S\over 2\pi^2 \hat{s}}
K_b,
\end{eqnarray}
where the second term, K-term, describes the QCD corrections to the
Born process and the first term is a sum over all the other
contributions. The  $f_{b/p}$ is a $b$ parton distribution in
the proton while $f_{a/\gamma}$ is a $a$ parton
distribution in the photon. For direct initial photon 
(where $a=\gamma$):
$f_{a/\gamma}=\delta (x_{\gamma}-1)$.
$D_{\gamma /c}$ is a $c$ parton fragmentation function
into a photon, or for non-fragmentation processes
(where $c=\gamma$) $D_{\gamma /c}=\delta(z-1)$.
$x$, $x_{\gamma}$, $z$ are: a part of the initial proton
momentum taken by the $b$ parton, a part of the initial
photon momentum taken by the $a$ parton, and a part of
the $c$ parton momentum taken by the final photon, 
respectively. The $\bar Q$ scale is provided here by the $p_T$. 

Denoting the differential cross section for the $\gamma p$ scattering (1) 
%(or the related to it the rapidity distribution or similar cross sections) 
by $\tilde {\sigma}^{\gamma p}$ 
we now relate it to the corresponding $ep$ cross section.
The differential cross section for the $ep$ scattering  
in the antitagging conditions  can be calculated using 
the equivalent photon approximation:
\begin{eqnarray}
\tilde {\sigma}^{ep}=\int G_{\gamma/e}(y) 
\tilde {\sigma}^{\gamma p} dy ,
\end{eqnarray}
where  $y=E_{\gamma}/E_e$ is
a fraction of the initial electron energy taken by the
photon, and the (real) photon 
distribution in the electron is given by:
\begin{eqnarray}
G_{\gamma/e}(y)={\alpha\over 2\pi}\cdot
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\ \nonumber
\cdot\{ {1+(1-y)^2\over y}
\ln [{Q^2_{max}(1-y)\over m_e^2 y^2}]\!-\!2(1-y)
+{2m_e^2y^2\over Q^2_{max}}\},
\end{eqnarray}
with $m_e$ being the electron mass. The $Q^2_{max}$ value
we assume as equal to 1 GeV$^2$, which is typical for the 
photoproduction measurements at HERA collider.
\subsection{Isolated photon production in DIC process }\label{subsec:wpp}
%{If you want to use some other form of word-processor\hfilneg}
%\eject
In order to reduce backgrounds from $\pi^0$'s and $\gamma$'s
radiated from final state hadrons isolation cuts on the
observed photon have
to be performed. Experimentally  the isolation cuts are 
defined by demanding that  a sum of 
hadronic energy within a cone of radius $R$ around the final 
photon should be smaller then the final photon energy multiplied
by parameter $\epsilon\sim 0.1$:
\begin{eqnarray}
\sum_{hadrons}E_h<\epsilon E_{\gamma}.
\end{eqnarray} 
The radius is defined in the rapidity and azimutal
angle phase space: $R=\sqrt{\Delta\Phi^2+\Delta\eta^2}$.


The simplest way to calculate the differential cross section
for isolated photon, $\tilde{\sigma}^{isol}$, is to calculate
difference of an inclusive differential cross section,
$\tilde{\sigma}^{incl}$, and a subtraction term,
$\tilde{\sigma}^{subt}$ (see \cite{vog}):
\begin{eqnarray}
\tilde{\sigma}^{isol}=\tilde{\sigma}^{incl}-\tilde{\sigma}^{subt}.
\end{eqnarray}
By the subtraction term we mean differential cross section
with cuts opposite to the isolation cuts, i.e.
within a cone of radius $R$ around the final photon
 there should appear hadrons with total energy 
higher than the photon energy multiplied by $\epsilon$:
\begin{eqnarray}
\sum_{hadrons}E_h>\epsilon E_{\gamma}.
\end{eqnarray} 
The cuts are imposed in the partonic phase space integration (for 
K-term) and integration over $z$ (for fragmentation processes).

We calculate the subtraction term in an approximate way,
with two simplifying assumtions \cite{azem}:\newline 
$\bullet$ the parameter $\epsilon$ is small, 
$\epsilon\ll 1$\newline
$\bullet$ an angle $\delta$ between the final photon and 
a parton (from which a hadronic jet arise) inside the cone 
is small (i.e. the cone is small)
and can be approximated by
$\delta=R/cosh(\eta)$, where $\eta$ is the rapidity of the
photon.

The above approximations are used only when calculating the 
K-term (i.e. the QCD corrections to the Born process)
in the subtraction term $\tilde{\sigma}^{subt}$.
Because this term gives about 4\% of the
inclusive cross section, we expect that the error
resulting from using the approximations is negligible.
%We assume that factorization works for the isolated
%photon cross section.
%All massive singularities are factorizied into fragmentation
%functions in a standard way and there is no
%infrared singularities.
\begin{figure*}
\center
%\rule{2cm}{0.2mm}\hfill \rule{2cm}{0.2mm}
\vskip 1.5cm
\psfig{figure=fig2.ps,height=3cm}
\vskip -3cm
\psfig{figure=fig3.ps,height=3cm}
\vskip -3cm
\psfig{figure=fig5.ps,height=3cm}
%\rule{2cm}{0.2mm}\hfill \rule{2cm}{0.2mm}
\caption{The photon rapidity distributions. a) The differential cross section
$d^2\sigma /dp_Td\eta$ integrated over whole range of $y$ for $p_T$=5 GeV 
for the final photon  not isolated (upper line) or isolated with R=1 and 
$ \epsilon$=0.05, 0.1, 0.2.
b) The cross section $d\sigma /d\eta$ integrated over 0.16$ \le y \le$0.8 and
5 GeV$ \le p_T\le $10 GeV for the isolated final 
photon with R=1 and $ \epsilon$=0.1. 
 The result for $N_f$=4 (solid line) and for 
comparison the same without the box contribution
(dotted line). The result for $N_f$=3 (dashed line) is also shown.
c) The cross section as in b) for $N_f$=4 for 
the isolated photon plus jet production, where the jet obeys 
conditions: -1.5$ \le \eta^{jet} \le $1.8 and  $p_T^{jet} \ge $5 GeV
(solid line).The data are the ZEUS experiment preliminary
results  $^{3}$.}
\label{fig:fig235}
\end{figure*}
\section{Results}
\subsection{Inclusive cross section}
First we will discuss the general features of the inclusive 
cross section for the DIC process in the $ep$ collision.
We take the HERA collider energies: $E_e$=27.5 GeV, $E_p$=820 GeV 
and we limit ourselves to the $p_T$ range of the final photon between 
5 and 10 GeV ($x_T$ is 0.03-0.07).
 The calculation was performed in ${ \overline {\rm MS}}$ scheme and 
 as a  hard (renormalization, factorization) scale we take
$\bar{Q}=p_T$, also $\bar{Q}=p_T/2$ and $2p_T$ was studied. 
Number of active flavours is assumed to be $N_f$=4 (and for comparison
 $N_f$=3).
$N_f$ enters into the evaluation of the 
coupling constant $\alpha_s$.
Note that the assumed NLO form of $\alpha_s$ plays a role, as
 changing the form from: 
\be
\alpha_s={{4 \pi}\over {\beta_0 \ln(\bar{Q}^2/\Lambda_{QCD}^2 )}}
{{1}\over{1+{{2\beta_1}\over{\beta_0^2}} 
{{\ln[\ln(\bar{Q}^2/\Lambda_{QCD}^2)]}\over{\ln(\bar{Q}^2/\Lambda_{QCD}^2)}}}}
\ee
to
\be
\alpha_s={{4 \pi}\over {\beta_0 \ln(\bar{Q}^2/\Lambda_{QCD}^2) }}
[1-{{2\beta_1}\over{\beta_0^2}} {{\ln[\ln(\bar{Q}^2/\Lambda_{QCD}^2)]}
\over{\ln(\bar{Q}^2/\Lambda_{QCD}^2)}}]
\ee
($\beta_0=11-2/3 N_f$ and $\beta_1=51-19/3 N_f$) changes the results by 5\%.
The final results will be given using the latter form with
 parameters: $\Lambda_{QCD}$=0.2 GeV for $N_f$=4 
and 0.248 GeV for  $N_f$=3.


We use Gl\"uck, Reya, Vogt NLO parametrizations of the proton
structure function, the photon structure function
 and the fragmentation function \cite{grv}, for comparison
 also other photon structure functions are used \cite{acfgp,gs}.
The value $\Lambda_{QCD}$ was used here as fitted to the data.

 
The importance of the particular contributions 
to the cross section can be illustrated by 
the following results obtained 
for the {\sl inclusive} cross section integrated over 5 GeV$<p_T<$10 GeV
(where the sum over all subprocesses is equal to 210 pb):
% wyniki z seminarium:
%$$Born=86.6 pb,1res=75 pb,2res=36 pb,box=12 pb,K-term=8 pb,tot=220 pb$$
% wyniki aktualne - zmieniona alfas (wynik maleje o 0, 4.8 lub 9.8% 
% zaleznie od procesu) i EPA (wynik maleje do 2.5% zaleznie od rapidity):
%$$Born=86.1pb,1res=71.9pb,2res=33.0pb,box=11.3pb,K-term=8.0pb,tot=210pb$$
$Born=41.2\% $, $single$ $resolved=34.2\% $,
$double$ $resolved=15.7\%$, $box=5.4\% $, $K$-$term$=3.9\%.
So it is obvious that the single resolved photon processes
give contribution comparable to the Born term. Also the double resolved
 photon processes are  important giving half of the single 
resolved photon process contribution. The overall double resolved photon
cross section is build from   many, relatively small, individual terms.
The box diagram gives 14\% of the Born contribution-
relatively large box contribution is due to  large 
 gluonic content of the proton  at small $x_p$ (the Born process
bases on the quark density at the same value $x_p$). 
\subsection{Inclusive versus isolated photon cross section} 
The isolation cut was introduced with
the radius $R=1$, and $\epsilon$=0.05, 0.1 and 0.2 .
 Results are presented in Fig.6a
where the {\it inclusive} cross section and the {\it isolated} photon
 cross sections are compared.
Large effect is seen when the isolation cut is imposed on the
final photon  in DIC process, with a larger suppression of the fragmentation
processes (up to 80\%, see \cite{azem}) as expected.
This effect is not very sensitive to the value of $ \epsilon $.
\subsection{Comparison with data}
To compare our results with data 
the calculations were performed for the HERA collider energies
with cuts used in  the ZEUS experiment \cite{zeus}.
For the isolated photon production in DIC process 
we take  $R=$1, $\epsilon=$0.1 and consider 
ranges: $~~~5~ {\rm GeV}\le p_T\le 10 ~{\rm GeV}~,~
0.16\le y\le  0.8.$\\
Two types of final state were measured:\\
''$\gamma$''-- an isolated photon with rapidity $-0.7\le\eta^{\gamma}\le0.9$,\\
``$\gamma$+jet''-- the isolated photon as above plus 
the jet with \\
~~~~~~~~~~$-1.5\le\eta^{jet}\le 1.8~,~~~ p_T^{jet}\ge 5 ~~{\rm GeV}.$
%\end{center}
%In Fig. the results and data as a function of the rapidity are presented...

In Fig.6b the  isolated photon rapidity distributions with the above criteria
are shown. The importance of the box diagram is seen (the double resolved
contribution is smaller than box up to  factor 2 for negative
 $\eta^{\gamma}$).
Note also a large difference between results for $N_f$=4 and 3
(due to fourth power of electric charge
characterizing  processes involving two photons).
The prediction based on the four  massless quarks overestimates 
the production rate, while this with $N_f$=3 underestimates this rate.
We belive that the true prediction lies between two curves, but
closer to the upper one.
(The proper treatment of the charm quark is crucial here
and will be discussed  elsewhere \cite{kto} ).
In Fig.6c the results for the final state with a photon 
and the jet are presented.
The calculation 
bases here on the additional assumption and therefore
should be treated as an estimation of the considered cross section
(see \cite{azem} for details ).
Resonable agreement with data are found for both final states (Figs.6b,c).

Below we discuss results for the isolated photon cross sections  
within the ZEUS cuts listed above, and integrated over 
0.8$\le x_{\gamma}\le 1$ -- a ``direct'' sample.
Particular
 contributions to 
the isolated photon cross section  
are   presented in Table 1 for ``$\gamma$'' and ``$\gamma$+jet'' 
in the final state. (Results correspond to  {$N_f$=4}).
The  total contribution for ``$\gamma$+jet''  is smaller by 2 pb 
as  compared to ``$\gamma$'', nevertheless
 the following ratios have  similar
pattern in both cases: ``Born/tot''=65\% and ``box/tot''=13\%.
We see how much the role of the direct processes is enhanced
by the isolation cut and the range of $\eta^{\gamma}$. Note also that now
 ``box/Born''=20\%, while the ``2res/Born'' $\sim$2\%.
 
Results  obtained using  other choices of the scale $\bar Q$:
$\bar Q$= $p_T/2$, $2p_T$, differ from ones based on 
the reference scale $p_T$ by $\pm$ 4\% (6\%) for ``$\gamma$''
(``$\gamma$+jet'') final state. 
The results based on ACFGP or GS
parton parametrization for the photon differ from GRV predictions
  by less than 4\%.

   The ZEUS measurement for the  ``$\gamma$+jet'' final state leads to 
cross section equals to $15.4\pm1.6\pm2.2$ pb \cite{zeus}.
\begin{table}
\begin{center}
\caption{DIC cross section (pb) for 0.8$ \le x_{\gamma}\le$1}\label{tab:smtab}
\vspace{0.2cm}
\begin{tabular}{|c|c|c|c|c|} 
\hline 
\raisebox{0pt}[12pt][6pt]{$subprocess$} & 
\raisebox{0pt}[12pt][6pt]{$tot$} & 
\raisebox{0pt}[12pt][6pt]{$Born$} &
\raisebox{0pt}[12pt][6pt]{$box$} &
\raisebox{0pt}[12pt][6pt]{$2res$} \\
\hline
\raisebox{0pt}[12pt][6pt]{$\gamma$} & 
\raisebox{0pt}[12pt][6pt]{25.2} & 
\raisebox{0pt}[12pt][6pt]{16.3} & 
\raisebox{0pt}[12pt][6pt]{3.2} &
\raisebox{0pt}[12pt][6pt]{0.39}\\
\hline
%\cline{1-2}
%\multicolumn{2}{|c|}{\raisebox{0pt}[12pt][6pt]{Trans Process
%for Decay}} & &\\
%\cline{1-2}
\raisebox{0pt}[12pt][6pt]{$\gamma+jet$} & 
\raisebox{0pt}[12pt][6pt]{23.4} & 
\raisebox{0pt}[12pt][6pt]{15.1} & 
\raisebox{0pt}[12pt][6pt]{3.0} &
\raisebox{0pt}[12pt][6pt]{0.27} \\ 
\hline
%\raisebox{0pt}[12pt][6pt]{GS} & 
%\raisebox{0pt}[12pt][6pt]{26.3} & 
%\raisebox{0pt}[12pt][6pt]{25.2} & 
%\raisebox{0pt}[12pt][6pt]{24.0} \\ 
%\hline
\end{tabular}
\end{center}
\end{table}
\vspace*{3pt}
\subsection{Comparison with other results}
Our NLO calculation of DIC process 
differs from NLO analysis
presented in Ref.[2],
based on the ``$1/\alpha_s$'' approach,
by types of subprocesses included.
In our analysis we do not include $ \alpha_s $ 
corrections to the single resolved processes, the NNLO term. 
On the other hand we include the box diagram,  
although being also beyond the NLO accuracy, it  was found to be 
large especially in the experimental conditions used in the ZEUS experiment.
Our prediction  (GRV parton parametrizations with
 $N_f=4$, scale $\bar Q$=$p_T$) for the rapidity distribution for 
the  ``$\gamma$''
  is lower by 10\% to 25\% 
for the negative to positive rapidity than in Ref.[2], while
for the ``$\gamma$ +jet'' final state
our results are higher by 25\% to 10\%, respectively.
%Both: our results and results from Ref.. 
%describe the data satisfactory.
\section{Conclusion} 
Results of the NLO calulation for the isolated $ \gamma$ 
production in DIC process at HERA are presented. 
In addition two NNLO contributions: 
double resolved photon processes and box diagram were studied.
The satisfactory agreement with data is obtained for both
``$\gamma$'' and ``$\gamma$+jet'' events for the rapidity distribution.
The box diagram contributes 13\% to the ``direct'' sample
as measured by ZEUS group.

The agreement with the other NLO calculation of the DIC, 
which based on a different set of diagrams, is obtained within 10 to 25\%. 
\section*{Acknowledgements}
We thanks P. Bussey and L. Gordon for important discussions.
MK is grateful to Stan Brodsky for useful discussions and 
hospitality during her stay at SLAC.

Supported by Grant No 2P03B18410.
\section*{References}
\begin{thebibliography}{99}
\bibitem{mkzz}M. Krawczyk, unpublished; J. \.Zochowski, MS thesis 1992;
M. Krawczyk, A. Zembrzuski, J. \.Zochowski - in preparation
\bibitem{gor98} L.E. Gordon, \Journal {\PRD} {57} {235} {1998}
\bibitem{zeus} ZEUS Coll., DESY-97-146 ;
 submitted to ICHEP'98, Vancouver,1998
\bibitem{dic-pm} J.D. Bjorken, E.A. Paschos, {\em Phys. Rev.}{\bf ~185},
~{1975}~({1969})
\bibitem{dic-ll} T.Tu, C. Wu, \Journal {\NPB}{156}{493}{1979}
\bibitem{dic-nlo} D.W.Duke, J.F. Owens, \Journal {\PRD}{26}{1600}{1982};
 P. Aurenche {\it et al.},  \Journal
{\ZPC} {24} {309}{1984}, \Journal {\ZPC} {56} {589}{1992}
\bibitem{mk}
M. Krawczyk, {\em Acta Physica Pol.} {\bf 21}, 999 (1990); 
A.C.Bawa, M. Krawczyk and W.J.Stirling,
\Journal  {\ZPC} {50} {293} {1991}; A.C. Bawa and M. Krawczyk,
 Proc. ``Physics at HERA'',  Hamburg 1991, p. 579, and  IFT 91/17;\\
 B.L. Combridge, \Journal {\NPB}{156}{493}{1979}\\
M. Fontannaz, D. Schiff, \Journal { \ZPC} {14}{151}{1982} 
\bibitem{vog} L.E. Gordon, W. Vogelsang \Journal {\PRD} {52} {58}{1995}
\bibitem{azem} A. Zembrzuski, IFT 10/98, and PhD thesis in preparation
\bibitem{grv}M. Gl\"{u}ck, E. Reya and A. Vogt, \Journal { \ZPC} {67}
  {433} {1995}; \Journal {\PRD} {46} {1973}{1992}; \Journal {\PRD} {48} 
{116} {1993}   
\bibitem{acfgp} P. Aurenche {\it et al.}, \Journal {\ZPC} {56} {589}{1992} 
\bibitem{gs}L.E. Gordon, J.K. Storrow, \Journal {\ZPC} {56} {307}{1992}
%\bibitem{gs97}L.E. Gordon and J.K. Storrow, \NPB 489 (1997) 405 
\bibitem{kto} in preparation
\end{thebibliography}
\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                      END OF LTWOL.TEX                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Psfig/TeX 
%%%%%%%%%%%%%%% For use at Santa Cruz, file "psfig.tex" must %%%
%%%%%%%%%%%%%%% be in same directory as figure  %%%%%%%%%%%%%%%%
\def\PsfigVersion{1.9}
% dvips version
%
% All psfig/tex software, documentation, and related files
% in this distribution of psfig/tex are 
% Copyright 1987, 1988, 1991 Trevor J. Darrell
%
% Permission is granted for use and non-profit distribution of psfig/tex 
% providing that this notice is clearly maintained. The right to
% distribute any portion of psfig/tex for profit or as part of any commercial
% product is specifically reserved for the author(s) of that portion.
%
% *** Feel free to make local modifications of psfig as you wish,
% *** but DO NOT post any changed or modified versions of ``psfig''
% *** directly to the net. Send them to me and I'll try to incorporate
% *** them into future versions. If you want to take the psfig code 
% *** and make a new program (subject to the copyright above), distribute it, 
% *** (and maintain it) that's fine, just don't call it psfig.
%
% Bugs and improvements to trevor@media.mit.edu.
%
% Thanks to Greg Hager (GDH) and Ned Batchelder for their contributions
% to the original version of this project.
%
% Modified by J. Daniel Smith on 9 October 1990 to accept the
% %%BoundingBox: comment with or without a space after the colon.  Stole
% file reading code from Tom Rokicki's EPSF.TEX file (see below).
%
% More modifications by J. Daniel Smith on 29 March 1991 to allow the
% the included PostScript figure to be rotated.  The amount of
% rotation is specified by the "angle=" parameter of the \psfig command.
%
% Modified by Robert Russell on June 25, 1991 to allow users to specify
% .ps filenames which don't yet exist, provided they explicitly provide
% boundingbox information via the \psfig command. Note: This will only work
% if the "file=" parameter follows all four "bb???=" parameters in the
% command. This is due to the order in which psfig interprets these params.
%
%  3 Jul 1991	JDS	check if file already read in once
%  4 Sep 1991	JDS	fixed incorrect computation of rotated
%			bounding box
% 25 Sep 1991	GVR	expanded synopsis of \psfig
% 14 Oct 1991	JDS	\fbox code from LaTeX so \psdraft works with TeX
%			changed \typeout to \ps@typeout
% 17 Oct 1991	JDS	added \psscalefirst and \psrotatefirst
%

% From: gvr@cs.brown.edu (George V. Reilly)
%
% \psdraft	draws an outline box, but doesn't include the figure
%		in the DVI file.  Useful for previewing.
%
% \psfull	includes the figure in the DVI file (default).
%
% \psscalefirst width= or height= specifies the size of the figure
% 		before rotation.
% \psrotatefirst (default) width= or height= specifies the size of the
% 		 figure after rotation.  Asymetric figures will
% 		 appear to shrink.
%
% \psfigurepath#1	sets the path to search for the figure
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \psfig
% usage: \psfig{file=, figure=, height=, width=,
%			bbllx=, bblly=, bburx=, bbury=,
%			rheight=, rwidth=, clip=, angle=, silent=}
%%%%%%%%%%   EXAMPLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \centerline{\psfig{file=fn.ft,height=6cm,angle=90}}  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	"file" is the filename.  If no path name is specified and the
%		file is not found in the current directory,
%		it will be looked for in directory \psfigurepath.
%	"figure" is a synonym for "file".
%	By default, the width and height of the figure are taken from
%		the BoundingBox of the figure.
%	If "width" is specified, the figure is scaled so that it has
%		the specified width.  Its height changes proportionately.
%	If "height" is specified, the figure is scaled so that it has
%		the specified height.  Its width changes proportionately.
%	If both "width" and "height" are specified, the figure is scaled
%		anamorphically.
%	"bbllx", "bblly", "bburx", and "bbury" control the PostScript
%		BoundingBox.  If these four values are specified
%               *before* the "file" option, the PSFIG will not try to
%               open the PostScript file.
%	"rheight" and "rwidth" are the reserved height and width
%		of the figure, i.e., how big TeX actually thinks
%		the figure is.  They default to "width" and "height".
%	The "clip" option ensures that no portion of the figure will
%		appear outside its BoundingBox.  "clip=" is a switch and
%		takes no value, but the `=' must be present.
%	The "angle" option specifies the angle of rotation (degrees, ccw).
%	The "silent" option makes \psfig work silently.
%

% check to see if macros already loaded in (maybe some other file says
% "\input psfig") ...
\ifx\undefined\psfig\else\endinput\fi

%
% from a suggestion by eijkhout@csrd.uiuc.edu to allow
% loading as a style file. Changed to avoid problems
% with amstex per suggestion by jbence@math.ucla.edu

\let\LaTeXAtSign=\@
\let\@=\relax
\edef\psfigRestoreAt{\catcode`\@=\number\catcode`@\relax}
%\edef\psfigRestoreAt{\catcode`@=\number\catcode`@\relax}
\catcode`\@=11\relax
\newwrite\@unused
\def\ps@typeout#1{{\let\protect\string\immediate\write\@unused{#1}}}
\ps@typeout{psfig/tex \PsfigVersion}

%% Here's how you define your figure path.  Should be set up with null
%% default and a user useable definition.

\def\figurepath{./}
\def\psfigurepath#1{\edef\figurepath{#1}}

%
% @psdo control structure -- similar to Latex @for.
% I redefined these with different names so that psfig can
% be used with TeX as well as LaTeX, and so that it will not 
% be vunerable to future changes in LaTeX's internal
% control structure,
%
\def\@nnil{\@nil}
\def\@empty{}
\def\@psdonoop#1\@@#2#3{}
\def\@psdo#1:=#2\do#3{\edef\@psdotmp{#2}\ifx\@psdotmp\@empty \else
    \expandafter\@psdoloop#2,\@nil,\@nil\@@#1{#3}\fi}
\def\@psdoloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else
       #5\def#4{#2}\ifx #4\@nnil \else#5\@ipsdoloop #3\@@#4{#5}\fi\fi}
\def\@ipsdoloop#1,#2\@@#3#4{\def#3{#1}\ifx #3\@nnil 
       \let\@nextwhile=\@psdonoop \else
      #4\relax\let\@nextwhile=\@ipsdoloop\fi\@nextwhile#2\@@#3{#4}}
\def\@tpsdo#1:=#2\do#3{\xdef\@psdotmp{#2}\ifx\@psdotmp\@empty \else
    \@tpsdoloop#2\@nil\@nil\@@#1{#3}\fi}
\def\@tpsdoloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil 
       \let\@nextwhile=\@psdonoop \else
      #4\relax\let\@nextwhile=\@tpsdoloop\fi\@nextwhile#2\@@#3{#4}}
% 
% \fbox is defined in latex.tex; so if \fbox is undefined, assume that
% we are not in LaTeX.
% Perhaps this could be done better???
\ifx\undefined\fbox
% \fbox code from modified slightly from LaTeX
\newdimen\fboxrule
\newdimen\fboxsep
\newdimen\ps@tempdima
\newbox\ps@tempboxa
\fboxsep = 3pt
\fboxrule = .4pt
\long\def\fbox#1{\leavevmode\setbox\ps@tempboxa\hbox{#1}\ps@tempdima\fboxrule
    \advance\ps@tempdima \fboxsep \advance\ps@tempdima \dp\ps@tempboxa
   \hbox{\lower \ps@tempdima\hbox
  {\vbox{\hrule height \fboxrule
          \hbox{\vrule width \fboxrule \hskip\fboxsep
          \vbox{\vskip\fboxsep \box\ps@tempboxa\vskip\fboxsep}\hskip 
                 \fboxsep\vrule width \fboxrule}
                 \hrule height \fboxrule}}}}
\fi
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% file reading stuff from epsf.tex
%   EPSF.TEX macro file:
%   Written by Tomas Rokicki of Radical Eye Software, 29 Mar 1989.
%   Revised by Don Knuth, 3 Jan 1990.
%   Revised by Tomas Rokicki to accept bounding boxes with no
%      space after the colon, 18 Jul 1990.
%   Portions modified/removed for use in PSFIG package by
%      J. Daniel Smith, 9 October 1990.
%
\newread\ps@stream
\newif\ifnot@eof       % continue looking for the bounding box?
\newif\if@noisy        % report what you're making?
\newif\if@atend        % %%BoundingBox: has (at end) specification
\newif\if@psfile       % does this look like a PostScript file?
%
% PostScript files should start with `%!'
%
{\catcode`\%=12\global\gdef\epsf@start{%!}}
\def\epsf@PS{PS}
%
\def\epsf@getbb#1{%
%
%   The first thing we need to do is to open the
%   PostScript file, if possible.
%
\openin\ps@stream=#1
\ifeof\ps@stream\ps@typeout{Error, File #1 not found}\else
%
%   Okay, we got it. Now we'll scan lines until we find one that doesn't
%   start with %. We're looking for the bounding box comment.
%
   {\not@eoftrue \chardef\other=12
    \def\do##1{\catcode`##1=\other}\dospecials \catcode`\ =10
    \loop
       \if@psfile
	  \read\ps@stream to \epsf@fileline
       \else{
	  \obeyspaces
          \read\ps@stream to \epsf@tmp\global\let\epsf@fileline\epsf@tmp}
       \fi
       \ifeof\ps@stream\not@eoffalse\else
%
%   Check the first line for `%!'.  Issue a warning message if its not
%   there, since the file might not be a PostScript file.
%
       \if@psfile\else
       \expandafter\epsf@test\epsf@fileline:. \\%
       \fi
%
%   We check to see if the first character is a % sign;
%   if so, we look further and stop only if the line begins with
%   `%%BoundingBox:' and the `(atend)' specification was not found.
%   That is, the only way to stop is when the end of file is reached,
%   or a `%%BoundingBox: llx lly urx ury' line is found.
%
          \expandafter\epsf@aux\epsf@fileline:. \\%
       \fi
   \ifnot@eof\repeat
   }\closein\ps@stream\fi}%
%
% This tests if the file we are reading looks like a PostScript file.
%
\long\def\epsf@test#1#2#3:#4\\{\def\epsf@testit{#1#2}
			\ifx\epsf@testit\epsf@start\else
\ps@typeout{Warning! File does not start with `\epsf@start'.  It may not be a PostScript file.}
			\fi
			\@psfiletrue} % don't test after 1st line
%
%   We still need to define the tricky \epsf@aux macro. This requires
%   a couple of magic constants for comparison purposes.
%
{\catcode`\%=12\global\let\epsf@percent=%\global\def\epsf@bblit{%BoundingBox}}
%
%
%   So we're ready to check for `%BoundingBox:' and to grab the
%   values if they are found.  We continue searching if `(at end)'
%   was found after the `%BoundingBox:'.
%
\long\def\epsf@aux#1#2:#3\\{\ifx#1\epsf@percent
   \def\epsf@testit{#2}\ifx\epsf@testit\epsf@bblit
	\@atendfalse
        \epsf@atend #3 . \\%
	\if@atend	
	   \if@verbose{
		\ps@typeout{psfig: found `(atend)'; continuing search}
	   }\fi
        \else
        \epsf@grab #3 . . . \\%
        \not@eoffalse
        \global\no@bbfalse
        \fi
   \fi\fi}%
%
%   Here we grab the values and stuff them in the appropriate definitions.
%
\def\epsf@grab #1 #2 #3 #4 #5\\{%
   \global\def\epsf@llx{#1}\ifx\epsf@llx\empty
      \epsf@grab #2 #3 #4 #5 .\\\else
   \global\def\epsf@lly{#2}%
   \global\def\epsf@urx{#3}\global\def\epsf@ury{#4}\fi}%
%
% Determine if the stuff following the %%BoundingBox is `(atend)'
% J. Daniel Smith.  Copied from \epsf@grab above.
%
\def\epsf@atendlit{(atend)} 
\def\epsf@atend #1 #2 #3\\{%
   \def\epsf@tmp{#1}\ifx\epsf@tmp\empty
      \epsf@atend #2 #3 .\\\else
   \ifx\epsf@tmp\epsf@atendlit\@atendtrue\fi\fi}


% End of file reading stuff from epsf.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% trigonometry stuff from "trig.tex"
\chardef\psletter = 11 % won't conflict with \begin{letter} now...
\chardef\other = 12

\newif \ifdebug %%% turn me on to see TeX hard at work ...
\newif\ifc@mpute %%% don't need to compute some values
\c@mputetrue % but assume that we do

\let\then = \relax
\def\r@dian{pt }
\let\r@dians = \r@dian
\let\dimensionless@nit = \r@dian
\let\dimensionless@nits = \dimensionless@nit
\def\internal@nit{sp }
\let\internal@nits = \internal@nit
\newif\ifstillc@nverging
\def \Mess@ge #1{\ifdebug \then \message {#1} \fi}

{ %%% Things that need abnormal catcodes %%%
	\catcode `\@ = \psletter
	\gdef \nodimen {\expandafter \n@dimen \the \dimen}
	\gdef \term #1 #2 #3%
	       {\edef \t@ {\the #1}%%% freeze parameter 1 (count, by value)
		\edef \t@@ {\expandafter \n@dimen \the #2\r@dian}%
				   %%% freeze parameter 2 (dimen, by value)
		\t@rm {\t@} {\t@@} {#3}%
	       }
	\gdef \t@rm #1 #2 #3%
	       {{%
		\count 0 = 0
		\dimen 0 = 1 \dimensionless@nit
		\dimen 2 = #2\relax
		\Mess@ge {Calculating term #1 of \nodimen 2}%
		\loop
		\ifnum	\count 0 < #1
		\then	\advance \count 0 by 1
			\Mess@ge {Iteration \the \count 0 \space}%
			\Multiply \dimen 0 by {\dimen 2}%
			\Mess@ge {After multiplication, term = \nodimen 0}%
			\Divide \dimen 0 by {\count 0}%
			\Mess@ge {After division, term = \nodimen 0}%
		\repeat
		\Mess@ge {Final value for term #1 of 
				\nodimen 2 \space is \nodimen 0}%
		\xdef \Term {#3 = \nodimen 0 \r@dians}%
		\aftergroup \Term
	       }}
	\catcode `\p = \other
	\catcode `\t = \other
	\gdef \n@dimen #1pt{#1} %%% throw away the ``pt''
}

\def \Divide #1by #2{\divide #1 by #2} %%% just a synonym

\def \Multiply #1by #2%%% allows division of a dimen by a dimen
       {{%%% should really freeze parameter 2 (dimen, passed by value)
	\count 0 = #1\relax
	\count 2 = #2\relax
	\count 4 = 65536
	\Mess@ge {Before scaling, count 0 = \the \count 0 \space and
			count 2 = \the \count 2}%
	\ifnum	\count 0 > 32767 %%% do our best to avoid overflow
	\then	\divide \count 0 by 4
		\divide \count 4 by 4
	\else	\ifnum	\count 0 < -32767
		\then	\divide \count 0 by 4
			\divide \count 4 by 4
		\else
		\fi
	\fi
	\ifnum	\count 2 > 32767 %%% while retaining reasonable accuracy
	\then	\divide \count 2 by 4
		\divide \count 4 by 4
	\else	\ifnum	\count 2 < -32767
		\then	\divide \count 2 by 4
			\divide \count 4 by 4
		\else
		\fi
	\fi
	\multiply \count 0 by \count 2
	\divide \count 0 by \count 4
	\xdef \product {#1 = \the \count 0 \internal@nits}%
	\aftergroup \product
       }}

\def\r@duce{\ifdim\dimen0 > 90\r@dian \then   % sin(x+90) = sin(180-x)
		\multiply\dimen0 by -1
		\advance\dimen0 by 180\r@dian
		\r@duce
	    \else \ifdim\dimen0 < -90\r@dian \then  % sin(-x) = sin(360+x)
		\advance\dimen0 by 360\r@dian
		\r@duce
		\fi
	    \fi}

\def\Sine#1%
       {{%
	\dimen 0 = #1 \r@dian
	\r@duce
	\ifdim\dimen0 = -90\r@dian \then
	   \dimen4 = -1\r@dian
	   \c@mputefalse
	\fi
	\ifdim\dimen0 = 90\r@dian \then
	   \dimen4 = 1\r@dian
	   \c@mputefalse
	\fi
	\ifdim\dimen0 = 0\r@dian \then
	   \dimen4 = 0\r@dian
	   \c@mputefalse
	\fi
%
	\ifc@mpute \then
        	% convert degrees to radians
		\divide\dimen0 by 180
		\dimen0=3.141592654\dimen0
%
		\dimen 2 = 3.1415926535897963\r@dian %%% a well-known constant
		\divide\dimen 2 by 2 %%% we only deal with -pi/2 : pi/2
		\Mess@ge {Sin: calculating Sin of \nodimen 0}%
		\count 0 = 1 %%% see power-series expansion for sine
		\dimen 2 = 1 \r@dian %%% ditto
		\dimen 4 = 0 \r@dian %%% ditto
		\loop
			\ifnum	\dimen 2 = 0 %%% then we've done
			\then	\stillc@nvergingfalse 
			\else	\stillc@nvergingtrue
			\fi
			\ifstillc@nverging %%% then calculate next term
			\then	\term {\count 0} {\dimen 0} {\dimen 2}%
				\advance \count 0 by 2
				\count 2 = \count 0
				\divide \count 2 by 2
				\ifodd	\count 2 %%% signs alternate
				\then	\advance \dimen 4 by \dimen 2
				\else	\advance \dimen 4 by -\dimen 2
				\fi
		\repeat
	\fi		
			\xdef \sine {\nodimen 4}%
       }}

% Now the Cosine can be calculated easily by calling \Sine
\def\Cosine#1{\ifx\sine\UnDefined\edef\Savesine{\relax}\else
		             \edef\Savesine{\sine}\fi
	{\dimen0=#1\r@dian\advance\dimen0 by 90\r@dian
	 \Sine{\nodimen 0}
	 \xdef\cosine{\sine}
	 \xdef\sine{\Savesine}}}	      
% end of trig stuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\psdraft{
	\def\@psdraft{0}
	%\ps@typeout{draft level now is \@psdraft \space . }
}
\def\psfull{
	\def\@psdraft{100}
	%\ps@typeout{draft level now is \@psdraft \space . }
}

\psfull

\newif\if@scalefirst
\def\psscalefirst{\@scalefirsttrue}
\def\psrotatefirst{\@scalefirstfalse}
\psrotatefirst

\newif\if@draftbox
\def\psnodraftbox{
	\@draftboxfalse
}
\def\psdraftbox{
	\@draftboxtrue
}
\@draftboxtrue

\newif\if@prologfile
\newif\if@postlogfile
\def\pssilent{
	\@noisyfalse
}
\def\psnoisy{
	\@noisytrue
}
\psnoisy
%%% These are for the option list.
%%% A specification of the form a = b maps to calling \@p@@sa{b}
\newif\if@bbllx
\newif\if@bblly
\newif\if@bburx
\newif\if@bbury
\newif\if@height
\newif\if@width
\newif\if@rheight
\newif\if@rwidth
\newif\if@angle
\newif\if@clip
\newif\if@verbose
\def\@p@@sclip#1{\@cliptrue}


\newif\if@decmpr

%%% GDH 7/26/87 -- changed so that it first looks in the local directory,
%%% then in a specified global directory for the ps file.
%%% RPR 6/25/91 -- changed so that it defaults to user-supplied name if
%%% boundingbox info is specified, assuming graphic will be created by
%%% print time.
%%% TJD 10/19/91 -- added bbfile vs. file distinction, and @decmpr flag

\def\@p@@sfigure#1{\def\@p@sfile{null}\def\@p@sbbfile{null}
	        \openin1=#1.bb
		\ifeof1\closein1
	        	\openin1=\figurepath#1.bb
			\ifeof1\closein1
			        \openin1=#1
				\ifeof1\closein1%
				       \openin1=\figurepath#1
					\ifeof1
					   \ps@typeout{Error, File #1 not found}
						\if@bbllx\if@bblly
				   		\if@bburx\if@bbury
			      				\def\@p@sfile{#1}%
			      				\def\@p@sbbfile{#1}%
							\@decmprfalse
				  	   	\fi\fi\fi\fi
					\else\closein1
				    		\def\@p@sfile{\figurepath#1}%
				    		\def\@p@sbbfile{\figurepath#1}%
						\@decmprfalse
	                       		\fi%
			 	\else\closein1%
					\def\@p@sfile{#1}
					\def\@p@sbbfile{#1}
					\@decmprfalse
			 	\fi
			\else
				\def\@p@sfile{\figurepath#1}
				\def\@p@sbbfile{\figurepath#1.bb}
				\@decmprtrue
			\fi
		\else
			\def\@p@sfile{#1}
			\def\@p@sbbfile{#1.bb}
			\@decmprtrue
		\fi}

\def\@p@@sfile#1{\@p@@sfigure{#1}}

\def\@p@@sbbllx#1{
		%\ps@typeout{bbllx is #1}
		\@bbllxtrue
		\dimen100=#1
		\edef\@p@sbbllx{\number\dimen100}
}
\def\@p@@sbblly#1{
		%\ps@typeout{bblly is #1}
		\@bbllytrue
		\dimen100=#1
		\edef\@p@sbblly{\number\dimen100}
}
\def\@p@@sbburx#1{
		%\ps@typeout{bburx is #1}
		\@bburxtrue
		\dimen100=#1
		\edef\@p@sbburx{\number\dimen100}
}
\def\@p@@sbbury#1{
		%\ps@typeout{bbury is #1}
		\@bburytrue
		\dimen100=#1
		\edef\@p@sbbury{\number\dimen100}
}
\def\@p@@sheight#1{
		\@heighttrue
		\dimen100=#1
   		\edef\@p@sheight{\number\dimen100}
		%\ps@typeout{Height is \@p@sheight}
}
\def\@p@@swidth#1{
		%\ps@typeout{Width is #1}
		\@widthtrue
		\dimen100=#1
		\edef\@p@swidth{\number\dimen100}
}
\def\@p@@srheight#1{
		%\ps@typeout{Reserved height is #1}
		\@rheighttrue
		\dimen100=#1
		\edef\@p@srheight{\number\dimen100}
}
\def\@p@@srwidth#1{
		%\ps@typeout{Reserved width is #1}
		\@rwidthtrue
		\dimen100=#1
		\edef\@p@srwidth{\number\dimen100}
}
\def\@p@@sangle#1{
		%\ps@typeout{Rotation is #1}
		\@angletrue
%		\dimen100=#1
		\edef\@p@sangle{#1} %\number\dimen100}
}
\def\@p@@ssilent#1{ 
		\@verbosefalse
}
\def\@p@@sprolog#1{\@prologfiletrue\def\@prologfileval{#1}}
\def\@p@@spostlog#1{\@postlogfiletrue\def\@postlogfileval{#1}}
\def\@cs@name#1{\csname #1\endcsname}
\def\@setparms#1=#2,{\@cs@name{@p@@s#1}{#2}}
%
% initialize the defaults (size the size of the figure)
%
\def\ps@init@parms{
		\@bbllxfalse \@bbllyfalse
		\@bburxfalse \@bburyfalse
		\@heightfalse \@widthfalse
		\@rheightfalse \@rwidthfalse
		\def\@p@sbbllx{}\def\@p@sbblly{}
		\def\@p@sbburx{}\def\@p@sbbury{}
		\def\@p@sheight{}\def\@p@swidth{}
		\def\@p@srheight{}\def\@p@srwidth{}
		\def\@p@sangle{0}
		\def\@p@sfile{} \def\@p@sbbfile{}
		\def\@p@scost{10}
		\def\@sc{}
		\@prologfilefalse
		\@postlogfilefalse
		\@clipfalse
		\if@noisy
			\@verbosetrue
		\else
			\@verbosefalse
		\fi
}
%
% Go through the options setting things up.
%
\def\parse@ps@parms#1{
	 	\@psdo\@psfiga:=#1\do
		   {\expandafter\@setparms\@psfiga,}}
%
% Compute bb height and width
%
\newif\ifno@bb
\def\bb@missing{
	\if@verbose{
		\ps@typeout{psfig: searching \@p@sbbfile \space  for bounding box}
	}\fi
	\no@bbtrue
	\epsf@getbb{\@p@sbbfile}
        \ifno@bb \else \bb@cull\epsf@llx\epsf@lly\epsf@urx\epsf@ury\fi
}	
\def\bb@cull#1#2#3#4{
	\dimen100=#1 bp\edef\@p@sbbllx{\number\dimen100}
	\dimen100=#2 bp\edef\@p@sbblly{\number\dimen100}
	\dimen100=#3 bp\edef\@p@sbburx{\number\dimen100}
	\dimen100=#4 bp\edef\@p@sbbury{\number\dimen100}
	\no@bbfalse
}
% rotate point (#1,#2) about (0,0).
% The sine and cosine of the angle are already stored in \sine and
% \cosine.  The result is placed in (\p@intvaluex, \p@intvaluey).
\newdimen\p@intvaluex
\newdimen\p@intvaluey
\def\rotate@#1#2{{\dimen0=#1 sp\dimen1=#2 sp
%            	calculate x' = x \cos\theta - y \sin\theta
		  \global\p@intvaluex=\cosine\dimen0
		  \dimen3=\sine\dimen1
		  \global\advance\p@intvaluex by -\dimen3
% 		calculate y' = x \sin\theta + y \cos\theta
		  \global\p@intvaluey=\sine\dimen0
		  \dimen3=\cosine\dimen1
		  \global\advance\p@intvaluey by \dimen3
		  }}
\def\compute@bb{
		\no@bbfalse
		\if@bbllx \else \no@bbtrue \fi
		\if@bblly \else \no@bbtrue \fi
		\if@bburx \else \no@bbtrue \fi
		\if@bbury \else \no@bbtrue \fi
		\ifno@bb \bb@missing \fi
		\ifno@bb \ps@typeout{FATAL ERROR: no bb supplied or found}
			\no-bb-error
		\fi
		%
%\ps@typeout{BB: \@p@sbbllx, \@p@sbblly, \@p@sbburx, \@p@sbbury} 
%
% store height/width of original (unrotated) bounding box
		\count203=\@p@sbburx
		\count204=\@p@sbbury
		\advance\count203 by -\@p@sbbllx
		\advance\count204 by -\@p@sbblly
		\edef\ps@bbw{\number\count203}
		\edef\ps@bbh{\number\count204}
		%\ps@typeout{ psbbh = \ps@bbh, psbbw = \ps@bbw }
		\if@angle 
			\Sine{\@p@sangle}\Cosine{\@p@sangle}
	        	{\dimen100=\maxdimen\xdef\r@p@sbbllx{\number\dimen100}
					    \xdef\r@p@sbblly{\number\dimen100}
			                    \xdef\r@p@sbburx{-\number\dimen100}
					    \xdef\r@p@sbbury{-\number\dimen100}}
%
% Need to rotate all four points and take the X-Y extremes of the new
% points as the new bounding box.
                        \def\minmaxtest{
			   \ifnum\number\p@intvaluex<\r@p@sbbllx
			      \xdef\r@p@sbbllx{\number\p@intvaluex}\fi
			   \ifnum\number\p@intvaluex>\r@p@sbburx
			      \xdef\r@p@sbburx{\number\p@intvaluex}\fi
			   \ifnum\number\p@intvaluey<\r@p@sbblly
			      \xdef\r@p@sbblly{\number\p@intvaluey}\fi
			   \ifnum\number\p@intvaluey>\r@p@sbbury
			      \xdef\r@p@sbbury{\number\p@intvaluey}\fi
			   }
%			lower left
			\rotate@{\@p@sbbllx}{\@p@sbblly}
			\minmaxtest
%			upper left
			\rotate@{\@p@sbbllx}{\@p@sbbury}
			\minmaxtest
%			lower right
			\rotate@{\@p@sbburx}{\@p@sbblly}
			\minmaxtest
%			upper right
			\rotate@{\@p@sbburx}{\@p@sbbury}
			\minmaxtest
			\edef\@p@sbbllx{\r@p@sbbllx}\edef\@p@sbblly{\r@p@sbblly}
			\edef\@p@sbburx{\r@p@sbburx}\edef\@p@sbbury{\r@p@sbbury}
%\ps@typeout{rotated BB: \r@p@sbbllx, \r@p@sbblly, \r@p@sbburx, \r@p@sbbury}
		\fi
		\count203=\@p@sbburx
		\count204=\@p@sbbury
		\advance\count203 by -\@p@sbbllx
		\advance\count204 by -\@p@sbblly
		\edef\@bbw{\number\count203}
		\edef\@bbh{\number\count204}
		%\ps@typeout{ bbh = \@bbh, bbw = \@bbw }
}
%
% \in@hundreds performs #1 * (#2 / #3) correct to the hundreds,
%	then leaves the result in @result
%
\def\in@hundreds#1#2#3{\count240=#2 \count241=#3
		     \count100=\count240	% 100 is first digit #2/#3
		     \divide\count100 by \count241
		     \count101=\count100
		     \multiply\count101 by \count241
		     \advance\count240 by -\count101
		     \multiply\count240 by 10
		     \count101=\count240	%101 is second digit of #2/#3
		     \divide\count101 by \count241
		     \count102=\count101
		     \multiply\count102 by \count241
		     \advance\count240 by -\count102
		     \multiply\count240 by 10
		     \count102=\count240	% 102 is the third digit
		     \divide\count102 by \count241
		     \count200=#1\count205=0
		     \count201=\count200
			\multiply\count201 by \count100
		 	\advance\count205 by \count201
		     \count201=\count200
			\divide\count201 by 10
			\multiply\count201 by \count101
			\advance\count205 by \count201
			%
		     \count201=\count200
			\divide\count201 by 100
			\multiply\count201 by \count102
			\advance\count205 by \count201
			%
		     \edef\@result{\number\count205}
}
\def\compute@wfromh{
		% computing : width = height * (bbw / bbh)
		\in@hundreds{\@p@sheight}{\@bbw}{\@bbh}
		%\ps@typeout{ \@p@sheight * \@bbw / \@bbh, = \@result }
		\edef\@p@swidth{\@result}
		%\ps@typeout{w from h: width is \@p@swidth}
}
\def\compute@hfromw{
		% computing : height = width * (bbh / bbw)
	        \in@hundreds{\@p@swidth}{\@bbh}{\@bbw}
		%\ps@typeout{ \@p@swidth * \@bbh / \@bbw = \@result }
		\edef\@p@sheight{\@result}
		%\ps@typeout{h from w : height is \@p@sheight}
}
\def\compute@handw{
		\if@height 
			\if@width
			\else
				\compute@wfromh
			\fi
		\else 
			\if@width
				\compute@hfromw
			\else
				\edef\@p@sheight{\@bbh}
				\edef\@p@swidth{\@bbw}
			\fi
		\fi
}
\def\compute@resv{
		\if@rheight \else \edef\@p@srheight{\@p@sheight} \fi
		\if@rwidth \else \edef\@p@srwidth{\@p@swidth} \fi
		%\ps@typeout{rheight = \@p@srheight, rwidth = \@p@srwidth}
}
%		
% Compute any missing values
\def\compute@sizes{
	\compute@bb
	\if@scalefirst\if@angle
% at this point the bounding box has been adjsuted correctly for
% rotation.  PSFIG does all of its scaling using \@bbh and \@bbw.  If
% a width= or height= was specified along with \psscalefirst, then the
% width=/height= value needs to be adjusted to match the new (rotated)
% bounding box size (specifed in \@bbw and \@bbh).
%    \ps@bbw       width=
%    -------  =  ---------- 
%    \@bbw       new width=
% so `new width=' = (width= * \@bbw) / \ps@bbw; where \ps@bbw is the
% width of the original (unrotated) bounding box.
	\if@width
	   \in@hundreds{\@p@swidth}{\@bbw}{\ps@bbw}
	   \edef\@p@swidth{\@result}
	\fi
	\if@height
	   \in@hundreds{\@p@sheight}{\@bbh}{\ps@bbh}
	   \edef\@p@sheight{\@result}
	\fi
	\fi\fi
	\compute@handw
	\compute@resv}

%
% \psfig
% usage : \psfig{file=, height=, width=, bbllx=, bblly=, bburx=, bbury=,
%			rheight=, rwidth=, clip=}
%
% "clip=" is a switch and takes no value, but the `=' must be present.
\def\psfig#1{\vbox {
	% do a zero width hard space so that a single
	% \psfig in a centering enviornment will behave nicely
	%{\setbox0=\hbox{\ }\ \hskip-\wd0}
	%
	\ps@init@parms
	\parse@ps@parms{#1}
	\compute@sizes
	%
	\ifnum\@p@scost<\@psdraft{
		%
		\special{ps::[begin] 	\@p@swidth \space \@p@sheight \space
				\@p@sbbllx \space \@p@sbblly \space
				\@p@sbburx \space \@p@sbbury \space
				startTexFig \space }
		\if@angle
			\special {ps:: \@p@sangle \space rotate \space} 
		\fi
		\if@clip{
			\if@verbose{
				\ps@typeout{(clip)}
			}\fi
			\special{ps:: doclip \space }
		}\fi
		\if@prologfile
		    \special{ps: plotfile \@prologfileval \space } \fi
		\if@decmpr{
			\if@verbose{
				\ps@typeout{psfig: including \@p@sfile.Z \space }
			}\fi
			\special{ps: plotfile "`zcat \@p@sfile.Z" \space }
		}\else{
			\if@verbose{
				\ps@typeout{psfig: including \@p@sfile \space }
			}\fi
			\special{ps: plotfile \@p@sfile \space }
		}\fi
		\if@postlogfile
		    \special{ps: plotfile \@postlogfileval \space } \fi
		\special{ps::[end] endTexFig \space }
		% Create the vbox to reserve the space for the figure.
		\vbox to \@p@srheight sp{
		% 1/92 TJD Changed from "true sp" to "sp" for magnification.
			\hbox to \@p@srwidth sp{
				\hss
			}
		\vss
		}
	}\else{
		% draft figure, just reserve the space and print the
		% path name.
		\if@draftbox{		
			% Verbose draft: print file name in box
			\hbox{\frame{\vbox to \@p@srheight sp{
			\vss
			\hbox to \@p@srwidth sp{ \hss \@p@sfile \hss }
			\vss
			}}}
		}\else{
			% Non-verbose draft
			\vbox to \@p@srheight sp{
			\vss
			\hbox to \@p@srwidth sp{\hss}
			\vss
			}
		}\fi	



	}\fi
}}
\psfigRestoreAt
\let\@=\LaTeXAtSign

