Back to home page

EIC code displayed by LXR

 
 

    


Warning, /eic-smear/README.md is written in an unsupported language. File is not indexed.

0001 # EIC-smear
0002 
0003 ## About
0004 
0005 Additional documentation can be found on the
0006 [EIC GitHub pages](https://eic.github.io/software/eicsmear.html).
0007 
0008 Contacts
0009 * Alexander Kiselev <ayk@bnl.gov>
0010 * Kolja Kauder <kkauder@bnl.gov>
0011 
0012 #### Overview ####
0013 
0014 eic-smear is a Monte Carlo analysis package originally developed by the BNL EIC task force.
0015 
0016 It contains classes and routines for:
0017 1) Building events in a C++ object and writing them to a ROOT file in a tree data structure.
0018 2) Performing fast detector smearing on those Monte Carlo events.
0019 
0020 The tree-building portion processes plain text files, formatted according to
0021 the EIC convention, into a ROOT TTree containing events.
0022 The following Monte Carlo generators are supported:
0023 * PYTHIA
0024 * RAPGAP
0025 * PEPSI
0026 * DJANGOH
0027 * MILOU
0028 * BeAGLE
0029 * Sartre
0030 * DPMJet
0031 * gmc_trans
0032 * Additionally, HepMC2 and HepMC3 files are supported, allowing for example Pythia8 and eSTARlight output to be processed.
0033 
0034 Most of these are currently hosted at https://gitlab.com/eic/mceg.
0035 Please see the associated documentation for further information on
0036 individual generators.
0037 Creation will typically be of the form
0038 ```
0039 pythiaeRHIC < STEER_FILE > out.log
0040 ```
0041 A few small example files are included for testing.
0042 
0043 Each entry in the TTree named EicTree is a single C++ event object,
0044 storing event-wise quantities common to all generators,
0045 generator-specific variables and a list of particle objects.
0046 
0047 The smearing portion of the code provides a collection of classes and routines
0048 that allow simple parameterisations of detector performance, provided via a
0049 ROOT script, to be applied to any of the above Monte Carlo
0050 events. Detector acceptance can also be defined. When run, a ROOT file with
0051 smeared events is produced.
0052 To access truth level information, use the "friend" mechanism in ROOT,
0053 see below.
0054 
0055 The output tree, called Smeared, will mirror the behavior of a true
0056 detector system, i.e. it will only contain entries for particles that
0057 were smeared (=measured), and only partial information if only parts
0058 were smeared. E. g., if only momentum is smeared, the energy field will be
0059 zero reflecting information gathered only by a tracker.
0060 Particles further have methods of the form
0061 ```c++
0062 bool psmeared = p->IsPSmeared();
0063 ```
0064 to differentiate between "not measured" and "measured as 0".
0065 In such a
0066 case, the analyzer can of course rely on the truth level, but a more
0067 realistic approach would be to make same kind of assumptions that one
0068 would have to make for a physical detector, such as assuming pion mass
0069 for all tracks baring PID information etc.
0070 
0071 
0072 Both portions of the code are included in the eic-smear shared
0073 library.
0074 
0075 #### Smearing scripts ####
0076 Detector parameterizations have been moved to [their own repository](https://github.com/eic/eicsmeardetectors) and need to be installed separately.
0077 
0078 #### Building ####
0079 
0080 ##### Prerequisites #####
0081 
0082 * CMake version >= 3.1 is required.
0083 * Compiler with C++11 support
0084 * ROOT version >= 6.10 is required, testing was only done for at least 6.14.
0085 
0086 ##### Procedure #####
0087 
0088 Create a directory in which to build eic-smear and navigate to that
0089 ```
0090 cd eic-smear
0091 mkdir build
0092 cd build
0093 ```
0094 
0095 Configure using cmake. Optionally, you can specify a location where to
0096 install include files and libraries:
0097 We'll assume that the installation path is in $EICDIRECTORY
0098 ```
0099 setenv EICDIRECTORY </path/to/install>
0100 cmake ../ -DCMAKE_INSTALL_PREFIX=$EICDIRECTORY
0101 ```
0102 
0103 Build and install (the -j flag specifies how many parallel compilation
0104 threads to use)
0105 ```
0106 make -j 2
0107 make install
0108 ```
0109 
0110 Detector parameterizations are developed on a different timescale and
0111 are more prone to changes by users; they have therefore been moved to
0112 https://github.com/eic/eicsmeardetectors, together with tests and
0113 examples You should head over there now and install them.
0114 
0115 A wrapper allows to start ROOT with libraries loaded and displays
0116 version information as well as the library locations.
0117 ```
0118 $ eic-smear
0119 Using eic-smear version: 1.1.12
0120 Using these eic-smear libraries :
0121 /Users/kkauder/software/lib/libeicsmear.dylib
0122 /Users/kkauder/software/lib/libeicsmeardetectors.dylib
0123 eic-smear [0]
0124 ```
0125 
0126 It can also be used for simple one liners:
0127 ```
0128 echo 'BuildTree ("ep_hiQ2.20x250.small.txt.gz");SmearTree(BuildMatrixDetector_0_1(),"ep_hiQ2.20x250.small.root")' | eic-smear
0129 ```
0130 
0131 One some architectures and ROOT versions, ```TRint``` has an obscure
0132 bug that will cause segmentation faults when using ```std::cout``` and
0133 similar commands inside this interpreter. Use printf instead, or just
0134 load the libraries directly in a generic root instance.
0135 
0136 
0137 #### Creation of HepMC output ####
0138 eic-smear's ROOT trees can be converted to HepMC output using the `TreeToHepMC`
0139 macro, e.g.:
0140 ```
0141 $ eic-smear
0142 Using eic-smear version: 1.1.12
0143 Using these eic-smear libraries :
0144 /Users/kkauder/software/lib/libeicsmear.dylib
0145 /Users/kkauder/software/lib/libeicsmeardetectors.dylib
0146 eic-smear [0] BuildTree("pythia6.txt")
0147 eic-smear [1] TreeToHepMC("pythia6.root")
0148 ```
0149 or
0150 ```
0151 $ echo 'BuildTree("pythia6.txt"); TreeToHepMC("pythia6.root")' | eic-smear
0152 
0153 ```
0154 BeAGLE's structure is flattened. All intermediate particles are there,
0155 but their parental struture may not be preserved.
0156 For all generators, including BeAGLE, hadronic and leptonic decays
0157 should be correct.
0158 
0159 HepMC2 output is possible via a flag:
0160 ```
0161 $ eic-smear
0162 eic-smear [0] TreeToHepMC("beagle_eD.root",".",-1,true);
0163 ```
0164 
0165 
0166 This macro has been tested to work with HepMC tools and rivet as well as eAST.
0167 Any feedback for these or other generators is very welcome!
0168 
0169 Note: The necessity to first generate ROOT trees as an intermediate step is
0170 awkward but currently unavoidable.
0171 BuildTree() is inextricably linked with many internal classes and functionalities.
0172 Significant refactorization to eliminate it in the future is possible
0173 but will take longer.
0174 
0175 
0176 ##### Notes: #####
0177 
0178 * If you see instances of things like
0179 ```
0180 Error in cling::AutoloadingVisitor::InsertIntoAutoloadingState:
0181    Missing FileEntry for eicsmear/smear/Smear.h
0182    requested to autoload type erhic::VirtualParticle
0183 ```
0184 please ```setenv``` or ```export``` the environment variable ```ROOT_INCLUDE_PATH``` to point to the include directory in your installation. It should no longer be necessary with recent build improvements, but for ROOT versions above 6.20, the necessity returns.
0185 
0186 * If building at BNL, you can get ROOT6 in the following manner
0187 ```
0188 setenv EIC_LEVEL dev
0189 source /afs/rhic.bnl.gov/eic/restructured/etc/eic_cshrc.csh
0190 #verify
0191 which root
0192 ```
0193 
0194 * If you want to build PYTHIA6-dependent components, pass the location
0195 of libPythia6 to cmake:
0196 ```
0197 cmake ../ -DCMAKE_INSTALL_PREFIX=</path/to/install> -DPYTHIA6_LIBDIR=/path/to/pythia6/lib
0198 ```
0199 This will generate additional classes that allow creation of the
0200 EicTree from within the framework, bypassing the text file generation.
0201 More detailed documentation of this feature to follow.
0202 
0203 * ```BuildTree()``` supports HepMC2 and HepMC3 input, if a HepMC3 installation is found by cmake. One can also pass a specific installation directory:
0204 ```
0205 cmake ../ -DCMAKE_INSTALL_PREFIX=</path/to/install> -DHepMC3=/path/to/HepMC3
0206 ```
0207 The filename should contain `hepmc`, the reader determines the used
0208 version automatically.
0209 
0210 * A recently added script ```TreeToHepMC()``` can be used to transform
0211 our ROOT trees to HepMC3 format.  TObjStrings for cross section etc. are saved in the RunInfo, all event generator-specific variables are saved in the event info. Parent-child relationships are repaired/reserved as much as possible, motherless particles get attached to the exchange boson.
0212 
0213 
0214 * For some reason, tab completion inside ROOT currently only works after
0215 explicitly loading the library
0216 ```
0217 root [] gSystem->Load("libeicsmear");
0218 ```
0219 even if that same command is in your rootlogon.C.
0220 
0221 * The above assumes you are using ```csh```. In ```bash```, simply replace ```setenv A B``` with ```export A=B```.
0222 
0223 
0224 #### Doxygen ####
0225 
0226 A recent version of the detailed class documentation is temporarily
0227 hosted at www4.rcf.bnl.gov/~eickolja/.
0228 You can also create an up-to-date one by running
0229 ```
0230 doxygen
0231 ```
0232 in the top level directory and directing your web browser to the
0233 created local file
0234 ```
0235 doxygen/html/index.html
0236 ```
0237 You can obtain doxygen at www.doxygen.nl.
0238 
0239 ## Developer Notes
0240 
0241 ### Code Conventions
0242 
0243 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.
0244 
0245 #### Naming and file structure
0246 Please observe the following:
0247 * Header files should have a ```.h``` suffix and implementation files should have a ```.cxx``` suffix (following the ROOT convention).
0248 * Stick to "one class, one file", or at most a few closely related classes in a single file. A file name should correspond to the class name, with declarations and definitions in separate header and implementation files. e.g. class ```MyAmazingClass``` should be declared in ```MyAmazingClass.h``` and be implemented in ```MyAmazingClass.cxx```.
0249 * Keep all code in an appropriate namespace e.g. ```namespace erhic``` for general EIC and Monte Carlo code, ```namespace Smear``` for smearing-specific code.
0250 * Files should be placed in the directory structure to match the namespace in which the code appears e.g. class ```erhic::EventDisplay``` would have its header in ```include/eicsmear/erhic/EventDisplay.h``` and its implementation in ```src/erhic/EventDisplay.cxx```.
0251 * All names should follow **camelCase**:
0252   * Class names (and therefore filenames) and member function names are ```CapitalizedLikeThis```.
0253   * Non-class function names are ```capitalizedLikeThis```.
0254   * Member variable names are prefixed with a lower-case "m", and capitalized like ```mSomeMember```.
0255 
0256 ### Documentation
0257 Make liberal use of [Doxygen](https://www.doxygen.nl/manual/docblocks.html) comments to document the code.
0258 HTML documentation is generated automatically from these and is part of the central [EIC Doxygen](https://eic.github.io/doxygen/) page.
0259 At a minimum give a brief description of each file and class, and preferably document all class methods (at least public ones).
0260 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!
0261 Comments in the code at complicated or important points are encouraged to aid fellow developers.
0262 
0263 #### Coding style
0264 Beyond naming and file structure, coding conventions closely follow those of [Google](https://google.github.io/styleguide/cppguide.html), with a few exceptions:
0265 * Streams are permitted, and encouraged in preference to functions such as ```printf()``` and ```scanf()```.
0266 * Non-const reference function arguments are permitted.
0267 There is a script, [cpplint](https://github.com/cpplint/cpplint), produced by Google to check files for compliance with style guidelines.
0268 A (rather old) copy is included in the eicpy directory of the eic-smear distribution.
0269 Run this to check for code compliance before committing changes.
0270 It is not perfect, but catches most issues.
0271 cpplint accepts a ```--filter``` argument to suppress warnings of different types.
0272 To eliminate the exceptions to the Google style guide listed above, run cpplint as follows
0273 ```
0274  cpplint.py --filter=-runtime/references,-readability/streams MyFile.cxx
0275 ```
0276 
0277 Some false positives that are known to occur include:
0278 * Complaining about ROOT- or Doxygen-style inline comments e.g. ```//!``` (ROOT) and ```///<``` (Doxygen).
0279 * ROOT headers will be misinterpreted as C system headers and cpplint will suggest to place them before C++ headers, but do **not** do so. The order of ```#include``` statements should be as follows:
0280   1. (Only in an implementation file) the name of the corresponding header file.
0281   1. C system headers.
0282   1. C++ system headers.
0283   1. 3rd-party package headers (but please think carefully before adding extra external dependencies to eic-smear).
0284   1. ROOT headers.
0285   1. eic-smear headers.
0286 
0287 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.
0288 
0289 #### Contributing
0290 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.
0291 
0292 #### Versioning
0293 Eic-smear is versioned according to (Semantic Versioning)[https://semver.org/], with some relaxation.
0294 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.
0295 
0296 
0297 
0298 
0299 #### Historical, **deprecated** version control and installation instructions
0300 
0301 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:
0302 1. New work is committed to /trunk: new features, bug fixes etc.
0303 1. When the new release is (nearly) ready, copy /trunk to a release branch /branches/1.3 for final development version 1.3.
0304 1. Testing of /branches/1.3 continues in parallel with new additions to /trunk. Port fixes for bugs between the two as they are found.
0305 1. 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.
0306 1. 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.
0307 
0308 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.
0309 
0310 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.
0311 
0312 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.
0313 ```
0314   svn commit -m "AUTHORS: ported r3 (added list of names) from branches/1.3"
0315   svn commit -m "include/eicsmear/erhic/ParticleMC.h: ported r64 (fixed bug in calculation of Feynman x) from trunk"
0316 ```
0317 
0318 
0319 These installation and version control instructions were used in the context of an older configuration
0320 not currently in use. The original Subversion repository (not up to date) is at:
0321 ```
0322  http://svn.racf.bnl.gov/svn/eic/Utilities/eic-smear/trunk eic-smear
0323 ```
0324 
0325 Old source tarballs are still available at
0326 * [Version 1.0.3](https://wiki.bnl.gov/eic/upload/Eic-smear-1.0.3.tar.bz2)
0327 * [Version 1.0.2](https://wiki.bnl.gov/eic/upload/Eic-smear-1.0.2.tar.bz2)
0328 * [Version 1.0.1](https://wiki.bnl.gov/eic/upload/Eic-smear-1.0.1.tar.bz2)
0329 * [Version 1.0.0](https://wiki.bnl.gov/eic/upload/Eic-smear-1.0.0.tar.bz2)
0330 
0331 
0332 It was configured using autoconf:
0333 ```sh
0334 autoreconf --force --install
0335 cd /path/to/eic-smear/
0336 ./configure  --prefix=/path/to/install-dir
0337 make
0338 make install
0339 ```
0340 
0341 If you want to build PYTHIA6-dependent components, pass the location
0342 of libPythia6 to configure via
0343 ```sh
0344 /path/to/eic-smear/configure --with-pythia6-libdir=/path/to/pythia6/lib
0345 ```