eic / eic-smear

fast simulation tool originally developed by the BNL EIC task force
GNU General Public License v3.0
2 stars 11 forks source link
eic-smear fast-simulation

EIC-smear

About

Additional documentation can be found on the EIC GitHub pages.

Contacts

Overview

eic-smear is a Monte Carlo analysis package originally developed by the BNL EIC task force.

It contains classes and routines for: 1) Building events in a C++ object and writing them to a ROOT file in a tree data structure. 2) Performing fast detector smearing on those Monte Carlo events.

The tree-building portion processes plain text files, formatted according to the EIC convention, into a ROOT TTree containing events. The following Monte Carlo generators are supported:

Most of these are currently hosted at https://gitlab.com/eic/mceg. Please see the associated documentation for further information on individual generators. Creation will typically be of the form

pythiaeRHIC < STEER_FILE > out.log

A few small example files are included for testing.

Each entry in the TTree named EicTree is a single C++ event object, storing event-wise quantities common to all generators, generator-specific variables and a list of particle objects.

The smearing portion of the code provides a collection of classes and routines that allow simple parameterisations of detector performance, provided via a ROOT script, to be applied to any of the above Monte Carlo events. Detector acceptance can also be defined. When run, a ROOT file with smeared events is produced. To access truth level information, use the "friend" mechanism in ROOT, see below.

The output tree, called Smeared, will mirror the behavior of a true detector system, i.e. it will only contain entries for particles that were smeared (=measured), and only partial information if only parts were smeared. E. g., if only momentum is smeared, the energy field will be zero reflecting information gathered only by a tracker. Particles further have methods of the form

bool psmeared = p->IsPSmeared();

to differentiate between "not measured" and "measured as 0". In such a case, the analyzer can of course rely on the truth level, but a more realistic approach would be to make same kind of assumptions that one would have to make for a physical detector, such as assuming pion mass for all tracks baring PID information etc.

Both portions of the code are included in the eic-smear shared library.

Smearing scripts

Detector parameterizations have been moved to their own repository and need to be installed separately.

Building

Prerequisites
Procedure

Create a directory in which to build eic-smear and navigate to that

cd eic-smear
mkdir build
cd build

Configure using cmake. Optionally, you can specify a location where to install include files and libraries: We'll assume that the installation path is in $EICDIRECTORY

setenv EICDIRECTORY </path/to/install>
cmake ../ -DCMAKE_INSTALL_PREFIX=$EICDIRECTORY

Build and install (the -j flag specifies how many parallel compilation threads to use)

make -j 2
make install

Detector parameterizations are developed on a different timescale and are more prone to changes by users; they have therefore been moved to https://github.com/eic/eicsmeardetectors, together with tests and examples You should head over there now and install them.

A wrapper allows to start ROOT with libraries loaded and displays version information as well as the library locations.

$ eic-smear
Using eic-smear version: 1.1.12
Using these eic-smear libraries :
/Users/kkauder/software/lib/libeicsmear.dylib
/Users/kkauder/software/lib/libeicsmeardetectors.dylib
eic-smear [0]

It can also be used for simple one liners:

echo 'BuildTree ("ep_hiQ2.20x250.small.txt.gz");SmearTree(BuildMatrixDetector_0_1(),"ep_hiQ2.20x250.small.root")' | eic-smear

One some architectures and ROOT versions, TRint has an obscure bug that will cause segmentation faults when using std::cout and similar commands inside this interpreter. Use printf instead, or just load the libraries directly in a generic root instance.

Creation of HepMC output

eic-smear's ROOT trees can be converted to HepMC output using the TreeToHepMC macro, e.g.:

$ eic-smear
Using eic-smear version: 1.1.12
Using these eic-smear libraries :
/Users/kkauder/software/lib/libeicsmear.dylib
/Users/kkauder/software/lib/libeicsmeardetectors.dylib
eic-smear [0] BuildTree("pythia6.txt")
eic-smear [1] TreeToHepMC("pythia6.root")

or

$ echo 'BuildTree("pythia6.txt"); TreeToHepMC("pythia6.root")' | eic-smear

BeAGLE's structure is flattened. All intermediate particles are there, but their parental struture may not be preserved. For all generators, including BeAGLE, hadronic and leptonic decays should be correct.

HepMC2 output is possible via a flag:

$ eic-smear
eic-smear [0] TreeToHepMC("beagle_eD.root",".",-1,true);

This macro has been tested to work with HepMC tools and rivet as well as eAST. Any feedback for these or other generators is very welcome!

Note: The necessity to first generate ROOT trees as an intermediate step is awkward but currently unavoidable. BuildTree() is inextricably linked with many internal classes and functionalities. Significant refactorization to eliminate it in the future is possible but will take longer.

Notes:

Doxygen

A recent version of the detailed class documentation is temporarily hosted at www4.rcf.bnl.gov/~eickolja/. You can also create an up-to-date one by running

doxygen

in the top level directory and directing your web browser to the created local file

doxygen/html/index.html

You can obtain doxygen at www.doxygen.nl.

Developer Notes

Code Conventions

There are clear style guidelines adhered to in the original code, for ease of maintenance and collaboration. Please adhere to all standards unless there are compelling reasons. Note that due to changing maintainers, rapid reactions to immediate issue requests, and things like replacement of deprecated and now removed features pre C++11, these guidelines aren't followed as strictly anymore. Nevertheless, please do your best.

Naming and file structure

Please observe the following:

Documentation

Make liberal use of Doxygen comments to document the code. HTML documentation is generated automatically from these and is part of the central EIC Doxygen page. At a minimum give a brief description of each file and class, and preferably document all class methods (at least public ones). Ask yourself whether a new user would be able to understand the basic purpose of each class or function you write, and how to use it, by looking at the provided comments; if not, write more! Comments in the code at complicated or important points are encouraged to aid fellow developers.

Coding style

Beyond naming and file structure, coding conventions closely follow those of Google, with a few exceptions:

Some false positives that are known to occur include:

While cpplint can also be instructed to filter these types of warnings, this is not recommended as one may then miss genuine errors of that type.

Contributing

We follow the standard (GitHub Standard Fork & Pull Request Workflow )[https://gist.github.com/Chaser324/ce0505fbed06b947d962]. Alternatively to Fork'ing, you can also request to be added to the group of contributors and create a branch for a slightly more convenient work flow.

Versioning

Eic-smear is versioned according to (Semantic Versioning)[https://semver.org/], with some relaxation. PATCH increases should never break backward compatibility. MINOR increases may make a few changes in existing smearing scripts necessary. MAJOR updates introduce significant new functionality and may seriously break backward-compatibility.

Historical, deprecated version control and installation instructions

Version control policy follows "best practices" from the SVN guide. To reiterate, as an example assume we have already released version 1.2, and are working on a new release 1.3:

  1. New work is committed to /trunk: new features, bug fixes etc.
  2. When the new release is (nearly) ready, copy /trunk to a release branch /branches/1.3 for final development version 1.3.
  3. Testing of /branches/1.3 continues in parallel with new additions to /trunk. Port fixes for bugs between the two as they are found.
  4. When testing of version 1.3 is complete, fix the new release by copying /branches/1.3 to /tags/1.3.0. Do not modify anything in /tags - these a fixed "snapshots" of the code.
  5. Maintain /branches/1.3 with bug fixes ported from /trunk. When enough changes are made to warrant a new release, copy /branches/1.3 to /tags/1.3.1 etc.

To summarize: /trunk contains all newly added features and fixes. /branches/X.Y is the "maintenance" branch for version X.Y. /tags/X.Y.Z are fixed "snapshot" releases. /trunk and /branches/X.Y are modified, while /tags/X.Y.Z remain unchanged.

Feel free to create your own personal branches whenever you want to work on new features and fixes without interfering with /trunk. To make life easier, remember to frequently port changes from /trunk to your branch, to avoid problems when merging the branch back to /trunk. Once you are finished and have ported your new features to /trunk, the personal branch can be deleted.

After porting changes between /trunk and a branch with svn merge, always provide the following information in the message when you commit the change: the file or files modified; the revision from which the change came; a brief summary of the change; the source of the change. e.g.

  svn commit -m "AUTHORS: ported r3 (added list of names) from branches/1.3"
  svn commit -m "include/eicsmear/erhic/ParticleMC.h: ported r64 (fixed bug in calculation of Feynman x) from trunk"

These installation and version control instructions were used in the context of an older configuration not currently in use. The original Subversion repository (not up to date) is at:

 http://svn.racf.bnl.gov/svn/eic/Utilities/eic-smear/trunk eic-smear

Old source tarballs are still available at

It was configured using autoconf:

autoreconf --force --install
cd /path/to/eic-smear/
./configure  --prefix=/path/to/install-dir
make
make install

If you want to build PYTHIA6-dependent components, pass the location of libPythia6 to configure via

/path/to/eic-smear/configure --with-pythia6-libdir=/path/to/pythia6/lib