\documentclass{CHEP2006}
\setlength{\paperheight}{297mm}
\setlength{\paperwidth}{210mm}


\usepackage{graphicx}


\setlength{\titleblockheight}{35mm}

\begin{document}
\title{GFlash  - parameterised shower in CMS }

\author{J. Weng\thanks{Joanna.Weng@cern.ch} \\CERN, Geneva, Switzerland\\
University of Karlsruhe, Germany}

\maketitle

\begin{abstract}

An object-oriented package for parameterising electromagnetic showers in the
framework of the Geant4 toolkit has been developed. This parameterisation is based on
the algorithms in the GFLASH package (implemented in GEANT3 / FORTRAN), 
but has been adapted to the new simulation context of Geant4. The package
substitutes the full tracking of high energy electrons/positrons
(normally form above 800 MeV ) inside Geant4 with the probability 
density function of the shower profile. A mixture of full
simulation and fast parameterisation is also possible. This new implementation of the
GFLASH package leads to a significant gain in simulation time for pp events at 14 TeV
at the LHC, without sacrificing too much the simulation accuracy and can be used for
any calorimeter. GFLASH  has been also included into the GEANT 4.7 release
and the CMS detector simulation OSCAR, which is based on Geant4. Some GFLASH
parameters have been also tuned to achieve better agreement with the CMS
electromagnetic calorimeter. Comparisons between GFLASH and full simulation in timing and physics performance will be presented as well.
\end{abstract}
\section{Introduction}
The  CMS detector simulation is based on the Geant4 package~\cite{Ref:Geant4}. 
Geant4 simulates detector effects on physics events using a detailed microscopic description of the interactions between particles and matter. 
It is very accurate, but it can be very time consuming. 
In particular the simulation of electro-magnetic cascades in calorimeters is 
expected to account for a considerable amount of the total simulation time,
since it increases almost linearly with the energy absorbed in the 
detector.
Consequently, at LHC energies of 14 TeV fully simulating one event, 
using individual particle tracking, may take several minutes, depending on the 
event type and topology. This approach is often not viable, especially when a large number of simulated events are needed for physics analyses.
An alternative is the CMS stand-alone fast simulation \cite{Ref:Famos}, which is, however, less accurate. 
The running of past HEP experiments like  CDF or H1 proved the importance of an intermediate  level of simulation, 
faster than full simulation, but integrated in the same framework 
so that it could provide the same kind of output as full simulation on  which the full reconstruction chain could be run.
A set of equations, derived from the H1
parameterisation (implemented in FORTRAN/GEANT3), 
can be used to parameterise the electro-magnetic shower development in different calorimeters \cite{Ref:Gflash}.  
In this paper we present the implementation of an electro-magnetic
shower parameterisation inside the Geant4 framework\cite{Ref:Geant4}.

Shower parameterisations based on this approach has been also integrated 
in the simulation framework of CMS to speed-up the simulation inside its lead tungstate 
electro-magnetic calorimeter.


\section{Parameterised description of shower profiles}
The spatial energy distribution of electromagnetic showers is given by                    three probability density functions (PDF),                                     
\begin{equation}                                                               
dE (\vec{r}) \, = \, E\, f(t)dt\, f(r)dr\, f(\phi) d\phi ,                    
\end{equation}                                                                 
describing the longitudinal, radial, and azimuthal energy                       
distributions.                                                                 
Here $t$ denotes the longitudinal shower depth in units of                     
radiation length, $r$ measures the radial distance from the shower            
axis in Moli\`{e}re units, and $\phi$ is the azimuthal angle.                  
It is assumed that in $\phi$  the energy is distributed uniformly due to symmetry:                            
 $ f(\phi) = 1/2\pi $.         
The mean longitudinal profile of a shower is described by a gamma
distribution:
\begin{eqnarray}
\langle  
\frac{1}{E} \frac{dE(t)}{dt}
\rangle  =f(t) =\frac{(\beta t)^{\alpha-1} \beta e^{-\beta t} }
{\Gamma (\alpha)}   
\end{eqnarray}
where $t$ is $E$ the shower energy.  
The longitudinal position of the shower maximum is $T=(\alpha -1)/\beta $.                The mean and the sigma of $\ln(T)$ and $\ln(\alpha)$ are used to parameterise the
longitudinal profile, as they are Gaussian distributed variables.
For an homogeneous calorimeter they parameterise as a function of the 
critical energy, the material of the calorimeter, and the direction.            
For the radial distribution, $f(r)$, a two-component Ansatz is chosen. 
\begin{eqnarray}
\label{Eq:frad}
 f(r) &= &p f_C(r) + (1-p) f_T(r) \\
&= &
 p \frac{2 r R_C^2}{(r^2 + R_C^2)^2}
+ (1-p) \frac{2 r R_T^2}{(r^2 + R_T^2)^2} 
\end{eqnarray}

More details are described in the references mentioned above~\cite{Ref:Gflash}.
The shower profiles had to be partially 
tuned to  achieve better agreement with the full simulation - this is especially true
for the radial profiles and for high energetic particles.




% \section{Use cases of the new shower parameterisation  }\label{sec:usecse}
\subsection{Shower parameterisation in Geant4}\label{subsec:g4}
The new implementation of the shower parameterisation(GFlash) has been intergrated into Geant4 and is available from version 7.0 on.~\footnote[1]{Since version 4.8.0  sampling calorimeters are also supported, see Geant4 manual for details.}
The following table shows the performance of the shower parameterisation package in a simple test setup: a block of matrial, in this case lead tungstate, the 
material of the CMS calorimeter. The parameters needed for the parameterisation are calculated on the fly for the considered material. 
Electrons and Positrons are fully tracked by Geant4 until they reach the calorimeter volume and are then parameterised if the shower is expected to be contained in the envelope (technically a G4LogicalVolume~\footnote[2]{From the Geant4 version 8.0 the envelope is defined by a G4Region}) and certain dynamic conditions are satisfied. 
 Photons are parameterised as soon as they have converted; Fully contained secondaries are parameterised as well, if they satisfy the conditions described above. The speed-up obtained with this set-up is significant 
and reaches a factor 100 and more for electrons above 50 GeV, as can be seen in table~\ref{Tab:Geant4SpeedUp}.\\

\begin{table}[hbt]
\begin{center}
\caption{Speed-up of single electrons and positrons in a pure lead tungstate cube in Geant4 
version 4.7.0. The numbers obtained for photons are similar.}
\begin{tabular}{@{}cccc@{}}\\ \hline
\multicolumn{4}{c}{}\\
\textbf{Electron}  & \textbf{Time/event}  & \textbf{Time/event } & \textbf{Speed-up} \\
\textbf{Energy } & \textbf{ full Geant 4} &  \textbf{parameterisation} &  \textbf{factor} \\
\hline
\multicolumn{4}{c}{}\\
1 GeV & 0.10 & 0.006 & 16 \\ 
5 GeV & 0.46 & 0.009 & 48 \\ 
 10 GeV & 0.92 & 0.013 & 67 \\ 
 50 GeV & 4.60 & 0.045 & 102 \\ 
 100 GeV & 9.37 & 0.080 & 117 \\ 
 500 GeV & 46.50 & 0.312 & 149 \\ 
 1000 GeV & 91.75 & 0.566 & 162 \\ 
\hline  


\end{tabular}
\label{Tab:Geant4SpeedUp}
\end{center}
\end{table}
Typical longitudinal and radial profiles in $PbWO_4$ are shown in figure~\ref{Fig:G4showerprofile}. Further tests performed on this calorimeter model have shown that the performance is independent of the angle between the electron trajectory and the calorimeter surface. The relative entry position in the crystal does not show an influence either: the performance is equally
good near the crystal border and in the centre of the crystal. Only if the particle enters exactly in the crack the performance 
gets worse. This case is, however, not very likely. Critical regions of the calorimeter can be excluded from triggering the parameterisation. 
The presence of the magnetic field does not show a significant  influence on the shower shape.
A detailed comparison of the shower shapes shows in general a worse agreement with Geant4 than with GEANT3 -  especially for the radial profiles.
This is on the one hand due to technical differences and implementation details between Geant4 and GEANT3.
On the other hand, the parameterisation obtained from GEANT3 does not 
always describe Geant4 shower profiles with sufficient accuracy. 
Here a retuning may be necessary.
In the case of CMS the radial profiles were retuned, as described in the
next section.


\begin{figure}[htb]
\centering
\includegraphics*[width=80mm]{LongProfbw.eps}
\includegraphics*[width=80mm]{RadialProfbw.eps}

\caption{Longitudinal (top) and radial shower profile (bottom) 
for 50~GeV photons in pure lead tungstate ($PbWO_4$). 
The points correspond to the parameterisation (radial profile retuned), 
the histogram to the full Geant4 simulation.}
\label{Fig:G4showerprofile}
\end{figure}


\subsection{Tuning of the radial profiles}

Detailed studies of the GFlash performance and a comparison with GEANT3 
indicates that especially the parameterisation of the radial profiles might need adjustment when moving to Geant4 and using a $PbWO_4$ calorimeter,  a material, which has not been considered explictly in \cite{Ref:Gflash}. 
Furthermore, the energy range at the LHC is much higher than  the range explored by H1.
From the direct comparison of the energy deposit in the crystal one can see, 
that GFlash tends to deposit too much energy in the central crystal.
In order to stick as close as possible to the original GFlash parameter and get at the same time a better agreement for the transversal profile a correction factor k for the weight p was introduced in equation \ref{Eq:frad} leading to the modified form:

\begin{eqnarray}
\label{Eq:corrected_frad}
 f(r) &= &(p* k) f_C(r) + (1-(p*k)) f_T(r) \\
&= &
 (p* k) \frac{2 r R_C^2}{(r^2 + R_C^2)^2}
+ (1-(p* k) ) \frac{2 r R_T^2}{(r^2 + R_T^2)^2} 
\nonumber 
\label{Eq:frad_tun}
\end{eqnarray}



In other words,  the core and tail component of the radial profile are reweighted.
In figure~\ref{Fig:RadTun} the tuning procedure, as well as the core and the tail components of the radial profile are visualised.

\begin{figure}[ht]
	\centering
	\includegraphics[  width=7.00cm]{radTun.eps}
% radTun.eps: 300dpi, , bb=0 370 696 842
	\caption{The radial function is fitted to the full simulated radial profile (histogram). Left  the core and right the tail component of the radial function are plotted}
	\label{Fig:RadTun}
\end{figure}


The procedure has been as follows:
\begin{enumerate}
\item The radial profile is plotted in bins of the longitudinal shower profile with
the size of one $X_0$  in the range from  $X_0 < t < 20 X_0$ (t being the longitudinal shower coordinate).
\item For each longitudinal interval the radial profile function 
is fitted with only $k$ as free parameter and all others parameters fixed.
\item The obtained correction  factors $k_1 ... k_{20}$ are now fitted as a function of 
the longitudinal coordinate. As a first approach a linear function was taken for $k(t)$
\item At the end, the energy dependence of $k$ is studied and parameterised.
\end{enumerate}
In figure \ref{Fig:RadTun} the tuning procedure, as well as the core and the tail components of the radial profile are visualised.
With this procedure a better agreement of the radial profiles could be achieved. 
The energy deposit in the crystals after retuning showed an agreement to the one 
$1\%$ level in $PbWO_4$.


\subsection{Performance for single electrons in CMS} 
The performance of the shower parameterisation has been tested for single electrons and positrons in the CMS detector simulation OSCAR~\cite{Ref:Oscar} with the full geometry. For this purpose electrons with a flat distribution in $\eta$  were shot from the centre of the detector into the barrel and endcap region of the calorimeter and the energy deposit in the central crystal, the $3 \times 3 $ and the $5 \times 5 $ matrix was compared. The same tests were also performed with photons, which in this model are parameterised  after they have converted into an electron-positron pair. The speed-up factor gained due to shower parameterisation is presented in table \ref{Tab:SpeedUpG4GF}, a plot illustrating the physics performance in the crystals can be seen in figure \ref{Fig:Oscar5x5}. 
% @@@@ Figuers

The speed up is still significant. It is less explicit than in pure lead tungstate since with a complex geometry and 
material in front of the calorimeter not all electrons are fully contained and parameterised and produced secondaries may be fully tracked, which slows down the simulation. Similar results has been found for photons.
%-Table ------
\begin{table}[hbt]
\centering
\begin{tabular}{|c|c|} 
\hline  Energy (GeV)  & Speed-up factor\\ 
\hline

 50 GeV  & 2.0 \\ 
 100 GeV & 3.8 \\ 
 500 GeV & 11.8 \\ 
 1000 GeV & 7.0 \\ 
\hline 
\end{tabular} 
\caption{Speed-up for single electrons in OSCAR 5.0.0 }
\label{Tab:SpeedUpG4GF}
\end{table}
Another problem encountered is the fact that inside a complex geometry it 
may be difficult to find an adequate parameterisation envelope, since besides the active matrial (here $PbWO_4$ )
also other volumes and materials may be contained in the mother volume.
This possibility is neglected in the parameterisation 
and has an impact on the agreement between full and fast simulation. 
If one shoots an electron directly into the calorimeter starting from the crystal surface the difference between
full and parameterised simulation is below one percent. If, on the other hand, the electron comes from the detector centre the difference 
increases to 2 - 3 \%. This is most likely due to the not ideal shower envelope. 
The parameterisation deposits  the energy spots assuming that the whole envelope consists of  $PbWO_4$,  which leads to energy losses if this is not the case. Full tracking handels this situation correctly, since the electron is basically propagated through the (usually thin and not very dense) support material and is still able to deposit energy in the active material. This problem is currently under consideration.  
The new region based parameterisation concept in Geant4 8.0 may improve the situation, since it allows for a more accurate description of the envelope.


\begin{figure}[ht]
	\centering
	\includegraphics[  width=8.00cm]{5x5bw.eps}
% radTun.eps: 300dpi, , bb=0 370 696 842
	\caption{Energy deposit in the $5 \times 5 $ crystal matrix. The points correspond to the parameterisation (radial profile retuned), 
the histogram to the full Geant4 simulation.}
	\label{Fig:Oscar5x5}
\end{figure}

 
% ------------------------------------------------------------------------------------------------------------------

\subsection{Performance for Full LHC events}

Physics studies for the LHC require a large number of simulated proton-proton collisions. 
So the relevant question from the CMS physics point of view has been how much parameterised showers
can speed- up the complete simulation of full events, where only electromagnetic subshower are parameterised. The speed up will depend on the event topology and the final state particles. As a sample, two event types were studied where the contribution from electromagnetic showers dominates the simulation time: the decay of a  Higgs boson to 4 electrons and the production of a high energetic photon together with a graviton in the Arkani-Hamed, Dvali and Dimopolous(ADD) Large Extra Dimension model. The results can be seen in table \ref{Tab:SpeedUpFullLHC}.
The studies have shown that the gain in computing time using the parameterised shower technique  can significantly speed-up full events.
%-Table ------
\begin{table}[hbt]
\centering
\begin{tabular}{|c|c|} 
\hline  Event   & Speed-up factor\\ 
\hline

 Higgs $\rightarrow $ 4e,  & 2.0 \\ 
 ADD Gamma + Gravition & 3.3 \\ 
\hline 
\end{tabular} 
\caption{Speed-up of full LHC events  in OSCAR 5.0.0; For the Higgs a mass of  $m_H=300 \ \rm GeV$ is assumed, in the case of the ADD process the photon has a $p_T >1000 \  \rm GeV$. }
\label{Tab:SpeedUpFullLHC}
\end{table}
The speed-up can still be increased if the electromagnetic sub showers in the hadron  calorimeter are parameterised. This has, however, not been done in this work.

%--------------------------------------------------------------------------------------------------------

\subsection{Conclusion and Outlook }
The parameterisation concept and equations of GFLASH from H1 has been 
successfully ported and object-oriented redesigned in the simulation framework 
of Geant4. This new parameterisation package has been contributed to the Geant4 collaboration and is available since version 7.0 for homogeneous calorimeters and for sampling calorimeters  since version 8.0, featuring also an example to illustrate the usage of the package inside Geant4.
Detailed tests of the performance have been carried out on simple and complex geometries. The radial profiles have been retuned to achieve better agreement with fully simulated  shower profiles in Geant4.
In the next step, the parameterisation has been fully intergrated into 
the current CMS detector simulation suite OSCAR.  
Comparisons of the energy depositions in the central crystal, the 3x3 and 5x5 crystal matrices performed with the GFlash based and the full OSCAR simulation 
show good agreement to the $>1\%$ level. The transverse
and longitudinal shower profiles are also well modeled to within
1-3$\%$. The shower parameterisation concept allows for a significant performance gain in timing, with speed-up factors in the range of a 3-10. The gain for a simulation including the full detector geometry depends on the event type, the particle energy and the detector $\eta$ region. A better physics performance may be achieved by using the new Geant4 region concept once the CMS simulation will be ported to Geant4 8.0, since then a  more accurate definition of the shower envelope is possible. 
The speed-up for full events can be increased by using the parametrisation as well for the electromagnetic components inside the hadronic calorimeter. CMS is currently rewriting its framework (CMSSW), so the porting of GFlash to 
the new simulation environment is another important task to be accomplished in this year. In CMSSW a comparison with the test beam is planned in 2006 which would finally also offer the possibility of a comparison and potential tuning of GFlash to test beam data. 

% ------------------------------------------------------------------------------------------------------------------

\begin{thebibliography}{9}   

\bibitem{Ref:Geant4} Geant4,  
see http://wwwinfo.cern.ch/asd/geant4/geant4.html and documentation therein.
and  paper NIM A 506 (2003), 250-303
\bibitem{Ref:Gflash} G.Grindhammer, M.Rudowicz and S.Peters, NIM A290(1990)469 and G.Grindhammer and S.Peters, hep-ex/0001020
%\bibitem{peso} J. del Peso and E. Ros, NIM A306(1991)485-499
%-----------------------------------------------------------------------------
\bibitem{Ref:Oscar} OSCAR: CMS Simulation Package \\
see http://cmsdoc.cern.ch/oscar
\bibitem{Ref:Famos} FAMOS: CMS Simulation Package \\
see http://cmsdoc.cern.ch/famos

\end{thebibliography}

\end{document}
