The document summarizes a CERN summer student project to convert Geant4 Monte Carlo model testing tools from PAW to ROOT and create a database and analysis tools. Key accomplishments included:
1) Converting 3000+ lines of code from PAW macros to ROOT and porting all tests, which increased code length by 40% but allowed larger simulations.
2) Developing tools for creating an experimental database from data, running simulations, and analyzing results with automatic scaling and formatting of output.
3) Creating a database structure and classes to store experimental publications and simulation results in ROOT files for flexible analysis of Geant4 models.
1. Test49: Geant4 Monte-Carlo Models Testing Tools
CERN Summer Student Project Report
PH-SFT Group, CERN
R. Atachiants (roman.atachiants@gmail.com)
Supervised by: M. Kosov (mikhail.kossov@cern.ch)
August 25, 2009
1 Project Overview
During the CERN Summer Student program, I
worked in Geant4 team (PH-SFT). The project
contained several different objectives:
• a full conversion of all Test19 PAW-tests[3] of
existing Geant4 [4] Monte Carlo models testing
to ROOT environment [5] and creation of a
fully automated testing system.
• creation of a special DB (DataBase) for the ex-
perimental data with an automatic process of
comparison of the MC distributions with data.
During the summer student work, the both objec-
tives were accomplished and even more various im-
provements has been made: auto-scaling features
for the plots, graphical user interfaces for the tools,
secondary nuclear fragments retrieval, etc. The cre-
ated tools were designed with the flexibility and
ease-of-use in mind.
2 PAW to ROOT Conversion
Fist step of the project was to convert the several
.kumac files counting approximately 3000 lines of
code. Learning curve of the PAW and ROOT[1]
environments was steeply, therefore the conversion
was achieved in about 1 month. Few insights for
the PAW to ROOT portin can be found on the
CERN ROOT website (http://root.cern.ch/root/
HowtoConvertFromPAW.html), but it was rather
insufficient for the big scale porting and mostly
targeted the people who want to switch from PAW
to ROOT.
During the porting, experience shown that the
C++ methods of ROOT are more comprehensive
and therefore more verbose. First kumac macro
conversion implementation showed 40% increase of
the length of the simple macro port.
3 Simulation and Analysis
After the conversion of all macro files to ROOT,
three comprehensive tools were developed.
• Experimental DB Creation Tool: a graph-
ical tool has been developed for the creation of
publication files (cf. 4) from ASCII data. Fig-
ure 4 shows the GUI of this tool.
• Simulation Tool: the goal of the tool is to
take the publication file as the input and us-
ing a Geant4 testing program (currently only
Test19 executable) to perform a simulation on
a Monte Carlo Model. The output of the
test then transformed from ASCII files, cuts
and rescaling for different secondaries are per-
formed. The histogram data are then saved in
the so-called simulation files for further analy-
sis. The tool also produces a plot for the anal-
ysis of the model on which the simulation was
performed, as illustrated on figure 3.
• Analysis Tool: the goal of the tool is to take
several simulation files produced by the simu-
lation tool and to draw the comparison graphs
in order to compare different MC models in be-
tween. The goal of the analysis is to compare
the data points (spectra, experimental data)
with the simulation curves. Figure 1 shows an
example of the output of the tool.
1
2. 5 ADDITIONAL FEATURES
Figure 1: Output of the analysis tool
4 Universal DataBase for
Geant4 MC Models Testing
The second part of my work at CERN was creating
of a universal DB for Geant4 MC models testing.
The created database consists of a collection of two
types of elements:
• Publication: contains an experimental data
information, with the description a a function,
cuts and secondaries.
• Simulation: contains the simulated data (af-
ter cuts) for a particular publication file.
The publication and simulation files have exactly
the same structure and are different only by seman-
tics. The data is stored in ROOT files (TTrees)
with headers in order to distinguish the items. Fig-
ure 2 shows the structure of the c++ classes, cre-
ated in order to represent the publication and simu-
lation concepts. The header of G4TData class con-
tains the projectile PDG code, target PDG code,
argument (ex: T) and the MC model name which
is only needed if the file is a simulation. The body
of the G4TData contains a vector of G4TDataItem
classes, which have the secondary fragment PDG
code, cut variable (ex.: Θ, 45 degrees), the argu-
ment (ex.: T) and the function (ex.: ∆S
∆E ).
The records of the DB are organised in .root files,
on the Linux file system, in particular the ext3 file
system on Scientific Linux 5, which allows a sin-
gle file of maximum 2TB. Ex-data (ASCII files)
Figure 2: Representation of the Data and DataItem
classes for both publications and simulations stor-
age and manipulation.
are in the test49/ascii directory and the publica-
tions/simulations are in the test49/database direc-
tory.
5 Additional Features
5.1 Automatic Scaling and Layout
Management
An auto-scale feature have been implemented in or-
der to scale automatically the axis of plots, pro-
duced by both analysis and simulation tools. The
scale features supports logarithmic scaling of y-axis
and linear scaling of x-axis.
5.2 Automatic Secondary Frag-
ments Nuclear Mass Calcula-
tions
A feature for the nuclear mass calculation for
secondary fragments have been implemented in
the tools, the API is based on ROOT Geometry
package, made by ALICE experiment, using the
lastest data (NUBASE2003).
August 25, 2009 2 R. Atachiants
3. 7 CONCLUSIONS
5.3 Graphical User Interfaces
Figure 3: A graphical user interface for simulation
tool
Several graphical user interfaces have been made
for the tools in order to give the possibility to
use them in the simplest possible way. The GUIs
have been built using ROOT widgets platform
and therefore portable to different platforms (Mac
OSX, Windows, Linux, ...).
One can see on Figure 4 the GUI created in order to
ease the use of creating publication files, and Fig-
ure 3 shows a GUI for the simulation tool, where
one can simply select the publication file and run
the MC simulation.
5.4 Documentation and ROOT Con-
tributions
An extensive amount of documentation for the tool
have been written, a simple User Guide can be
found in the Geant4 Hadronics Wiki [2] . This User
Guide shows how to get started and work with both
simulation and analysis tools, and create publica-
tion data files from ASCII files (both using ROOT
macros or available GUIs).
A contribution to ROOT also have been made, sev-
eral bugs have been found during the work, submit-
ted to ROOT team of PH-SFT and their correction
have been initiated.
Figure 4: A graphical user interface for making
publication files from ASCII files
6 Results
One of the main goals of the project was the PAW
to ROOT conversion. The goal of this conversion
were mainly to be able to run the simulations and
process (analyse) bigger statistics than in old sys-
tem. In order to prove that the system can han-
dle big statistics, a Monte Carlo simulation using
BERTINI MC Model was performed. This simula-
tion produced 10,000,000 events, 52,508,486 entries
and the output file of about 7.5 GB (Figure 5).
7 Conclusions
In this paper my contribution to Geant4 testing fa-
cility has been discussed. It has been proven that
old PAW .kumac files can be completely ported to
the ROOT platform and exactly the same result
can be achieved. It has also been shown that the
created simulation tool can produce practically un-
limited results, in order of 2 TB statistics, limited
purely by the file system. The simulation and anal-
ysis tools that have been created also have been
designed with the extensibility and ease-of-use in
mind. The extensibility is achieved by using the
abstract classes, data access layers and wrappers.
The ease-of-use is achieved by building a very easy
August 25, 2009 3 R. Atachiants
4. REFERENCES REFERENCES
Figure 5: The post-simulation output of a simula-
tion of 10,000,000 events
to use API and graphical user interfaces.
The experimental DB and different tools are
implemented in ROOT classes, compiled in
libG4ModelTester.so extension library for ROOT
and placed in tests/test49 directory of Geant4 test-
ing facility.
References
[1] The ROOT Users Guide. CERN, 2006.
[2] R. Atachiants. http://geant4hadronics.wikispaces.com/
geant4+test49+documentation. Geant4 Test19
Documentation.
[3] CERN. http://wwwasd.web.cern.ch/wwwasd/paw.
PAW − Physics Analysis Workstation.
[4] CERN. http://www.geant4.org/geant4.
Geant4 Website.
[5] Rademakers F. Introduction to root. CERN
Summer Student Lecture.
August 25, 2009 4 R. Atachiants